var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
var __accessCheck = (obj, member, msg) => {
  if (!member.has(obj))
    throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
  __accessCheck(obj, member, "read from private field");
  return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
  if (member.has(obj))
    throw TypeError("Cannot add the same private member more than once");
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
  __accessCheck(obj, member, "write to private field");
  setter ? setter.call(obj, value) : member.set(obj, value);
  return value;
};
import { g as Rd, c as Jn, E as Cye, p as _ye, i as Yh, U as Tye, a as Eye, s as dW, b as NQ, d as _g, e as Iye, r as $ye, f as Aye, h as Rye, j as Mye, k as hW, l as Dye, m as QQ, n as zQ, u as bT, o as Lye, q as jye, R as Nye, I as Qye, M as zye, A as Fye, t as Bye, D as WP, __tla as __tla_0 } from "./index-c30f3063.js";
let $ae, po, dn, om, Loe, cm, dm, yb, Eqe, Tqe, Um, Un, eqe, Bm, JGe, Xoe, SP, is, Zae, Re, Ve, yle, joe, zm, V, vqe, qo;
let __tla = Promise.all([
  (() => {
    try {
      return __tla_0;
    } catch {
    }
  })()
]).then(async () => {
  var _e, _t2, _n, _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s, _t3;
  function Uye(t, e) {
    for (var n = 0; n < e.length; n++) {
      const r = e[n];
      if (typeof r != "string" && !Array.isArray(r)) {
        for (const i in r)
          if (i !== "default" && !(i in t)) {
            const s = Object.getOwnPropertyDescriptor(r, i);
            s && Object.defineProperty(t, i, s.get ? s : {
              enumerable: true,
              get: () => r[i]
            });
          }
      }
    }
    return Object.freeze(Object.defineProperty(t, Symbol.toStringTag, {
      value: "Module"
    }));
  }
  (function() {
    const e = document.createElement("link").relList;
    if (e && e.supports && e.supports("modulepreload"))
      return;
    for (const i of document.querySelectorAll('link[rel="modulepreload"]'))
      r(i);
    new MutationObserver((i) => {
      for (const s of i)
        if (s.type === "childList")
          for (const o of s.addedNodes)
            o.tagName === "LINK" && o.rel === "modulepreload" && r(o);
    }).observe(document, {
      childList: true,
      subtree: true
    });
    function n(i) {
      const s = {};
      return i.integrity && (s.integrity = i.integrity), i.referrerPolicy && (s.referrerPolicy = i.referrerPolicy), i.crossOrigin === "use-credentials" ? s.credentials = "include" : i.crossOrigin === "anonymous" ? s.credentials = "omit" : s.credentials = "same-origin", s;
    }
    function r(i) {
      if (i.ep)
        return;
      i.ep = true;
      const s = n(i);
      fetch(i.href, s);
    }
  })();
  var fW = {
    exports: {}
  }, St = {};
  var zO = Symbol.for("react.element"), Vye = Symbol.for("react.portal"), Xye = Symbol.for("react.fragment"), Wye = Symbol.for("react.strict_mode"), Zye = Symbol.for("react.profiler"), Hye = Symbol.for("react.provider"), Yye = Symbol.for("react.context"), Gye = Symbol.for("react.forward_ref"), qye = Symbol.for("react.suspense"), Kye = Symbol.for("react.memo"), Jye = Symbol.for("react.lazy"), FQ = Symbol.iterator;
  function e0e(t) {
    return t === null || typeof t != "object" ? null : (t = FQ && t[FQ] || t["@@iterator"], typeof t == "function" ? t : null);
  }
  var pW = {
    isMounted: function() {
      return false;
    },
    enqueueForceUpdate: function() {
    },
    enqueueReplaceState: function() {
    },
    enqueueSetState: function() {
    }
  }, gW = Object.assign, mW = {};
  function mm(t, e, n) {
    this.props = t, this.context = e, this.refs = mW, this.updater = n || pW;
  }
  mm.prototype.isReactComponent = {};
  mm.prototype.setState = function(t, e) {
    if (typeof t != "object" && typeof t != "function" && t != null)
      throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
    this.updater.enqueueSetState(this, t, e, "setState");
  };
  mm.prototype.forceUpdate = function(t) {
    this.updater.enqueueForceUpdate(this, t, "forceUpdate");
  };
  function yW() {
  }
  yW.prototype = mm.prototype;
  function QD(t, e, n) {
    this.props = t, this.context = e, this.refs = mW, this.updater = n || pW;
  }
  var zD = QD.prototype = new yW();
  zD.constructor = QD;
  gW(zD, mm.prototype);
  zD.isPureReactComponent = true;
  var BQ = Array.isArray, vW = Object.prototype.hasOwnProperty, FD = {
    current: null
  }, OW = {
    key: true,
    ref: true,
    __self: true,
    __source: true
  };
  function SW(t, e, n) {
    var r, i = {}, s = null, o = null;
    if (e != null)
      for (r in e.ref !== void 0 && (o = e.ref), e.key !== void 0 && (s = "" + e.key), e)
        vW.call(e, r) && !OW.hasOwnProperty(r) && (i[r] = e[r]);
    var a = arguments.length - 2;
    if (a === 1)
      i.children = n;
    else if (1 < a) {
      for (var l = Array(a), c = 0; c < a; c++)
        l[c] = arguments[c + 2];
      i.children = l;
    }
    if (t && t.defaultProps)
      for (r in a = t.defaultProps, a)
        i[r] === void 0 && (i[r] = a[r]);
    return {
      $$typeof: zO,
      type: t,
      key: s,
      ref: o,
      props: i,
      _owner: FD.current
    };
  }
  function t0e(t, e) {
    return {
      $$typeof: zO,
      type: t.type,
      key: e,
      ref: t.ref,
      props: t.props,
      _owner: t._owner
    };
  }
  function BD(t) {
    return typeof t == "object" && t !== null && t.$$typeof === zO;
  }
  function n0e(t) {
    var e = {
      "=": "=0",
      ":": "=2"
    };
    return "$" + t.replace(/[=:]/g, function(n) {
      return e[n];
    });
  }
  var UQ = /\/+/g;
  function kT(t, e) {
    return typeof t == "object" && t !== null && t.key != null ? n0e("" + t.key) : e.toString(36);
  }
  function Ex(t, e, n, r, i) {
    var s = typeof t;
    (s === "undefined" || s === "boolean") && (t = null);
    var o = false;
    if (t === null)
      o = true;
    else
      switch (s) {
        case "string":
        case "number":
          o = true;
          break;
        case "object":
          switch (t.$$typeof) {
            case zO:
            case Vye:
              o = true;
          }
      }
    if (o)
      return o = t, i = i(o), t = r === "" ? "." + kT(o, 0) : r, BQ(i) ? (n = "", t != null && (n = t.replace(UQ, "$&/") + "/"), Ex(i, e, n, "", function(c) {
        return c;
      })) : i != null && (BD(i) && (i = t0e(i, n + (!i.key || o && o.key === i.key ? "" : ("" + i.key).replace(UQ, "$&/") + "/") + t)), e.push(i)), 1;
    if (o = 0, r = r === "" ? "." : r + ":", BQ(t))
      for (var a = 0; a < t.length; a++) {
        s = t[a];
        var l = r + kT(s, a);
        o += Ex(s, e, n, l, i);
      }
    else if (l = e0e(t), typeof l == "function")
      for (t = l.call(t), a = 0; !(s = t.next()).done; )
        s = s.value, l = r + kT(s, a++), o += Ex(s, e, n, l, i);
    else if (s === "object")
      throw e = String(t), Error("Objects are not valid as a React child (found: " + (e === "[object Object]" ? "object with keys {" + Object.keys(t).join(", ") + "}" : e) + "). If you meant to render a collection of children, use an array instead.");
    return o;
  }
  function Q1(t, e, n) {
    if (t == null)
      return t;
    var r = [], i = 0;
    return Ex(t, r, "", "", function(s) {
      return e.call(n, s, i++);
    }), r;
  }
  function r0e(t) {
    if (t._status === -1) {
      var e = t._result;
      e = e(), e.then(function(n) {
        (t._status === 0 || t._status === -1) && (t._status = 1, t._result = n);
      }, function(n) {
        (t._status === 0 || t._status === -1) && (t._status = 2, t._result = n);
      }), t._status === -1 && (t._status = 0, t._result = e);
    }
    if (t._status === 1)
      return t._result.default;
    throw t._result;
  }
  var Vi = {
    current: null
  }, Ix = {
    transition: null
  }, i0e = {
    ReactCurrentDispatcher: Vi,
    ReactCurrentBatchConfig: Ix,
    ReactCurrentOwner: FD
  };
  function wW() {
    throw Error("act(...) is not supported in production builds of React.");
  }
  St.Children = {
    map: Q1,
    forEach: function(t, e, n) {
      Q1(t, function() {
        e.apply(this, arguments);
      }, n);
    },
    count: function(t) {
      var e = 0;
      return Q1(t, function() {
        e++;
      }), e;
    },
    toArray: function(t) {
      return Q1(t, function(e) {
        return e;
      }) || [];
    },
    only: function(t) {
      if (!BD(t))
        throw Error("React.Children.only expected to receive a single React element child.");
      return t;
    }
  };
  St.Component = mm;
  St.Fragment = Xye;
  St.Profiler = Zye;
  St.PureComponent = QD;
  St.StrictMode = Wye;
  St.Suspense = qye;
  St.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = i0e;
  St.act = wW;
  St.cloneElement = function(t, e, n) {
    if (t == null)
      throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + t + ".");
    var r = gW({}, t.props), i = t.key, s = t.ref, o = t._owner;
    if (e != null) {
      if (e.ref !== void 0 && (s = e.ref, o = FD.current), e.key !== void 0 && (i = "" + e.key), t.type && t.type.defaultProps)
        var a = t.type.defaultProps;
      for (l in e)
        vW.call(e, l) && !OW.hasOwnProperty(l) && (r[l] = e[l] === void 0 && a !== void 0 ? a[l] : e[l]);
    }
    var l = arguments.length - 2;
    if (l === 1)
      r.children = n;
    else if (1 < l) {
      a = Array(l);
      for (var c = 0; c < l; c++)
        a[c] = arguments[c + 2];
      r.children = a;
    }
    return {
      $$typeof: zO,
      type: t.type,
      key: i,
      ref: s,
      props: r,
      _owner: o
    };
  };
  St.createContext = function(t) {
    return t = {
      $$typeof: Yye,
      _currentValue: t,
      _currentValue2: t,
      _threadCount: 0,
      Provider: null,
      Consumer: null,
      _defaultValue: null,
      _globalName: null
    }, t.Provider = {
      $$typeof: Hye,
      _context: t
    }, t.Consumer = t;
  };
  St.createElement = SW;
  St.createFactory = function(t) {
    var e = SW.bind(null, t);
    return e.type = t, e;
  };
  St.createRef = function() {
    return {
      current: null
    };
  };
  St.forwardRef = function(t) {
    return {
      $$typeof: Gye,
      render: t
    };
  };
  St.isValidElement = BD;
  St.lazy = function(t) {
    return {
      $$typeof: Jye,
      _payload: {
        _status: -1,
        _result: t
      },
      _init: r0e
    };
  };
  St.memo = function(t, e) {
    return {
      $$typeof: Kye,
      type: t,
      compare: e === void 0 ? null : e
    };
  };
  St.startTransition = function(t) {
    var e = Ix.transition;
    Ix.transition = {};
    try {
      t();
    } finally {
      Ix.transition = e;
    }
  };
  St.unstable_act = wW;
  St.useCallback = function(t, e) {
    return Vi.current.useCallback(t, e);
  };
  St.useContext = function(t) {
    return Vi.current.useContext(t);
  };
  St.useDebugValue = function() {
  };
  St.useDeferredValue = function(t) {
    return Vi.current.useDeferredValue(t);
  };
  St.useEffect = function(t, e) {
    return Vi.current.useEffect(t, e);
  };
  St.useId = function() {
    return Vi.current.useId();
  };
  St.useImperativeHandle = function(t, e, n) {
    return Vi.current.useImperativeHandle(t, e, n);
  };
  St.useInsertionEffect = function(t, e) {
    return Vi.current.useInsertionEffect(t, e);
  };
  St.useLayoutEffect = function(t, e) {
    return Vi.current.useLayoutEffect(t, e);
  };
  St.useMemo = function(t, e) {
    return Vi.current.useMemo(t, e);
  };
  St.useReducer = function(t, e, n) {
    return Vi.current.useReducer(t, e, n);
  };
  St.useRef = function(t) {
    return Vi.current.useRef(t);
  };
  St.useState = function(t) {
    return Vi.current.useState(t);
  };
  St.useSyncExternalStore = function(t, e, n) {
    return Vi.current.useSyncExternalStore(t, e, n);
  };
  St.useTransition = function() {
    return Vi.current.useTransition();
  };
  St.version = "18.3.1";
  fW.exports = St;
  var b = fW.exports;
  const $e = Rd(b), UD = Uye({
    __proto__: null,
    default: $e
  }, [
    b
  ]), xW = b.createContext(null);
  function Xl() {
    const t = b.useContext(xW);
    if (!t)
      throw new Error("Repo was not found on RepoContext.");
    return t;
  }
  function Ba(t) {
    const e = Xl(), n = t ? e.find(t) : null, r = b.useRef(n);
    n !== r.current && (r.current = n);
    const [, i] = b.useState(0), s = () => i((a) => a + 1);
    b.useEffect(() => !t || !n ? void 0 : (r.current = n, n.doc().then(() => {
      s();
    }).catch((a) => console.error(a)), n.on("change", s), n.on("delete", s), () => {
      n.removeListener("change", s), n.removeListener("delete", s);
    }), [
      t,
      n
    ]);
    const o = b.useCallback((a, l) => {
      n && n.change(a, l);
    }, [
      n
    ]);
    return [
      n == null ? void 0 : n.docSync(),
      o
    ];
  }
  const zh = Symbol.for("_am_meta"), vv = Symbol.for("_am_trace"), Ov = Symbol.for("_am_objectId"), VD = Symbol.for("_am_isProxy"), bW = Symbol.for("_am_clearCache"), s0e = Symbol.for("_am_uint"), o0e = Symbol.for("_am_int"), a0e = Symbol.for("_am_f64"), kW = Symbol.for("_am_counter"), l0e = Symbol.for("_am_text");
  let XD = class $x {
    constructor(e) {
      if (typeof e == "string")
        this.elems = [
          ...e
        ];
      else if (Array.isArray(e))
        this.elems = e;
      else if (e === void 0)
        this.elems = [];
      else
        throw new TypeError(`Unsupported initial value for Text: ${e}`);
      Reflect.defineProperty(this, l0e, {
        value: true
      });
    }
    get length() {
      return this.elems.length;
    }
    get(e) {
      return this.elems[e];
    }
    [Symbol.iterator]() {
      const e = this.elems;
      let n = -1;
      return {
        next() {
          return n += 1, n < e.length ? {
            done: false,
            value: e[n]
          } : {
            done: true
          };
        }
      };
    }
    toString() {
      if (!this.str) {
        this.str = "";
        for (const e of this.elems)
          typeof e == "string" ? this.str += e : this.str += "\uFFFC";
      }
      return this.str;
    }
    toSpans() {
      if (!this.spans) {
        this.spans = [];
        let e = "";
        for (const n of this.elems)
          typeof n == "string" ? e += n : (e.length > 0 && (this.spans.push(e), e = ""), this.spans.push(n));
        e.length > 0 && this.spans.push(e);
      }
      return this.spans;
    }
    toJSON() {
      return this.toString();
    }
    set(e, n) {
      if (this[zh])
        throw new RangeError("object cannot be modified outside of a change block");
      this.elems[e] = n;
    }
    insertAt(e, ...n) {
      if (this[zh])
        throw new RangeError("object cannot be modified outside of a change block");
      n.every((r) => typeof r == "string") ? this.elems.splice(e, 0, ...n.join("")) : this.elems.splice(e, 0, ...n);
    }
    deleteAt(e, n = 1) {
      if (this[zh])
        throw new RangeError("object cannot be modified outside of a change block");
      this.elems.splice(e, n);
    }
    map(e) {
      this.elems.map(e);
    }
    lastIndexOf(e, n) {
      this.elems.lastIndexOf(e, n);
    }
    concat(e) {
      return new $x(this.elems.concat(e.elems));
    }
    every(e) {
      return this.elems.every(e);
    }
    filter(e) {
      return new $x(this.elems.filter(e));
    }
    find(e) {
      return this.elems.find(e);
    }
    findIndex(e) {
      return this.elems.findIndex(e);
    }
    forEach(e) {
      this.elems.forEach(e);
    }
    includes(e) {
      return this.elems.includes(e);
    }
    indexOf(e) {
      return this.elems.indexOf(e);
    }
    join(e) {
      return this.elems.join(e);
    }
    reduce(e) {
      this.elems.reduce(e);
    }
    reduceRight(e) {
      this.elems.reduceRight(e);
    }
    slice(e, n) {
      return new $x(this.elems.slice(e, n));
    }
    some(e) {
      return this.elems.some(e);
    }
    toLocaleString() {
      this.toString();
    }
  };
  class c0e {
    constructor(e) {
      this.value = e || 0, Reflect.defineProperty(this, kW, {
        value: true
      });
    }
    valueOf() {
      return this.value;
    }
    toString() {
      return this.valueOf().toString();
    }
    toJSON() {
      return this.value;
    }
    increment(e) {
      throw new Error("Counters should not be incremented outside of a change callback");
    }
    decrement(e) {
      throw new Error("Counters should not be decremented outside of a change callback");
    }
  }
  class u0e extends c0e {
    constructor(e, n, r, i, s) {
      super(e), this.context = n, this.path = r, this.objectId = i, this.key = s;
    }
    increment(e) {
      return e = typeof e == "number" ? e : 1, this.context.increment(this.objectId, this.key, e), this.value += e, this.value;
    }
    decrement(e) {
      return this.increment(typeof e == "number" ? -e : -1);
    }
  }
  function d0e(t, e, n, r, i) {
    return new u0e(t, e, n, r, i);
  }
  class h0e {
    constructor(e) {
      this.val = e;
    }
    toString() {
      return this.val;
    }
    toJSON() {
      return this.val;
    }
  }
  function wl(t) {
    if (typeof t == "string" && /^[0-9]+$/.test(t) && (t = parseInt(t, 10)), typeof t != "number")
      return t;
    if (t < 0 || isNaN(t) || t === 1 / 0 || t === -1 / 0)
      throw new RangeError("A list index must be positive, but you passed " + t);
    return t;
  }
  function Ao(t, e) {
    const { context: n, objectId: r, path: i, textV2: s } = t, o = n.getWithType(r, e);
    if (o === null)
      return;
    const a = o[0], l = o[1];
    switch (a) {
      case void 0:
        return;
      case "map":
        return HP(n, l, s, [
          ...i,
          e
        ]);
      case "list":
        return YP(n, l, s, [
          ...i,
          e
        ]);
      case "text":
        return s ? n.text(l) : Sv(n, l, [
          ...i,
          e
        ]);
      case "str":
        return l;
      case "uint":
        return l;
      case "int":
        return l;
      case "f64":
        return l;
      case "boolean":
        return l;
      case "null":
        return null;
      case "bytes":
        return l;
      case "timestamp":
        return l;
      case "counter":
        return d0e(l, n, i, r, e);
      default:
        throw RangeError(`datatype ${a} unimplemented`);
    }
  }
  function Mb(t, e, n, r) {
    const i = typeof t;
    switch (i) {
      case "object":
        if (t == null)
          return [
            null,
            "null"
          ];
        if (t[s0e])
          return [
            t.value,
            "uint"
          ];
        if (t[o0e])
          return [
            t.value,
            "int"
          ];
        if (t[a0e])
          return [
            t.value,
            "f64"
          ];
        if (t[kW])
          return [
            t.value,
            "counter"
          ];
        if (t instanceof Date)
          return [
            t.getTime(),
            "timestamp"
          ];
        if (t instanceof h0e)
          return [
            t.toString(),
            "str"
          ];
        if (t instanceof XD)
          return [
            t,
            "text"
          ];
        if (t instanceof Uint8Array)
          return [
            t,
            "bytes"
          ];
        if (t instanceof Array)
          return [
            t,
            "list"
          ];
        if (Object.prototype.toString.call(t) === "[object Object]")
          return [
            t,
            "map"
          ];
        throw ZP(t, r) ? new RangeError("Cannot create a reference to an existing document object") : new RangeError(`Cannot assign unknown object: ${t}`);
      case "boolean":
        return [
          t,
          "boolean"
        ];
      case "number":
        return Number.isInteger(t) ? [
          t,
          "int"
        ] : [
          t,
          "f64"
        ];
      case "string":
        return e ? [
          t,
          "text"
        ] : [
          t,
          "str"
        ];
      case "undefined":
        throw new RangeError([
          `Cannot assign undefined value at ${VQ(n)}, `,
          "because `undefined` is not a valid JSON data type. ",
          "You might consider setting the property's value to `null`, ",
          "or using `delete` to remove it altogether."
        ].join(""));
      default:
        throw new RangeError([
          `Cannot assign ${i} value at ${VQ(n)}. `,
          "All JSON primitive datatypes (object, array, string, number, boolean, null) ",
          `are supported in an Automerge document; ${i} values are not. `
        ].join(""));
    }
  }
  function ZP(t, e) {
    var n, r;
    return t instanceof Date ? false : !!(t && ((r = (n = t[zh]) === null || n === void 0 ? void 0 : n.handle) === null || r === void 0 ? void 0 : r.__wbg_ptr) === e.__wbg_ptr);
  }
  const f0e = {
    get(t, e) {
      const { context: n, objectId: r, cache: i } = t;
      return e === Symbol.toStringTag ? t[Symbol.toStringTag] : e === Ov ? r : e === VD ? true : e === vv ? t.trace : e === zh ? {
        handle: n,
        textV2: t.textV2
      } : (i[e] || (i[e] = Ao(t, e)), i[e]);
    },
    set(t, e, n) {
      const { context: r, objectId: i, path: s, textV2: o } = t;
      if (t.cache = {}, ZP(n, r))
        throw new RangeError("Cannot create a reference to an existing document object");
      if (e === vv)
        return t.trace = n, true;
      if (e === bW)
        return true;
      const [a, l] = Mb(n, o, [
        ...s,
        e
      ], r);
      switch (l) {
        case "list": {
          const c = r.putObject(i, e, []), u = YP(r, c, o, [
            ...s,
            e
          ]);
          for (let d = 0; d < a.length; d++)
            u[d] = a[d];
          break;
        }
        case "text": {
          if (o)
            Db(a), r.putObject(i, e, a);
          else {
            ZD(a);
            const c = r.putObject(i, e, "");
            Sv(r, c, [
              ...s,
              e
            ]).splice(0, 0, ...a);
          }
          break;
        }
        case "map": {
          const c = r.putObject(i, e, {}), u = HP(r, c, o, [
            ...s,
            e
          ]);
          for (const d in a)
            u[d] = a[d];
          break;
        }
        default:
          r.put(i, e, a, l);
      }
      return true;
    },
    deleteProperty(t, e) {
      const { context: n, objectId: r } = t;
      return t.cache = {}, n.delete(r, e), true;
    },
    has(t, e) {
      return this.get(t, e) !== void 0;
    },
    getOwnPropertyDescriptor(t, e) {
      const n = this.get(t, e);
      if (typeof n < "u")
        return {
          configurable: true,
          enumerable: true,
          value: n
        };
    },
    ownKeys(t) {
      const { context: e, objectId: n } = t, r = e.keys(n);
      return [
        ...new Set(r)
      ];
    }
  }, PW = {
    get(t, e) {
      const { context: n, objectId: r } = t;
      return e = wl(e), e === Symbol.hasInstance ? (i) => Array.isArray(i) : e === Symbol.toStringTag ? t[Symbol.toStringTag] : e === Ov ? r : e === VD ? true : e === vv ? t.trace : e === zh ? {
        handle: n
      } : e === "length" ? n.length(r) : typeof e == "number" ? Ao(t, e) : WD(t)[e];
    },
    set(t, e, n) {
      const { context: r, objectId: i, path: s, textV2: o } = t;
      if (e = wl(e), ZP(n, r))
        throw new RangeError("Cannot create a reference to an existing document object");
      if (e === bW)
        return true;
      if (e === vv)
        return t.trace = n, true;
      if (typeof e == "string")
        throw new RangeError("list index must be a number");
      const [a, l] = Mb(n, o, [
        ...s,
        e
      ], r);
      switch (l) {
        case "list": {
          let c;
          e >= r.length(i) ? c = r.insertObject(i, e, []) : c = r.putObject(i, e, []), YP(r, c, o, [
            ...s,
            e
          ]).splice(0, 0, ...a);
          break;
        }
        case "text": {
          if (o)
            Db(a), e >= r.length(i) ? r.insertObject(i, e, a) : r.putObject(i, e, a);
          else {
            let c;
            ZD(a), e >= r.length(i) ? c = r.insertObject(i, e, "") : c = r.putObject(i, e, ""), Sv(r, c, [
              ...s,
              e
            ]).splice(0, 0, ...a);
          }
          break;
        }
        case "map": {
          let c;
          e >= r.length(i) ? c = r.insertObject(i, e, {}) : c = r.putObject(i, e, {});
          const u = HP(r, c, o, [
            ...s,
            e
          ]);
          for (const d in a)
            u[d] = a[d];
          break;
        }
        default:
          e >= r.length(i) ? r.insert(i, e, a, l) : r.put(i, e, a, l);
      }
      return true;
    },
    deleteProperty(t, e) {
      const { context: n, objectId: r } = t;
      e = wl(e);
      const i = n.get(r, e);
      if (i != null && i[0] == "counter")
        throw new TypeError("Unsupported operation: deleting a counter from a list");
      return n.delete(r, e), true;
    },
    has(t, e) {
      const { context: n, objectId: r } = t;
      return e = wl(e), typeof e == "number" ? e < n.length(r) : e === "length";
    },
    getOwnPropertyDescriptor(t, e) {
      const { context: n, objectId: r } = t;
      return e === "length" ? {
        writable: true,
        value: n.length(r)
      } : e === Ov ? {
        configurable: false,
        enumerable: false,
        value: r
      } : (e = wl(e), {
        configurable: true,
        enumerable: true,
        value: Ao(t, e)
      });
    },
    getPrototypeOf(t) {
      return Object.getPrototypeOf(t);
    },
    ownKeys() {
      const t = [];
      return t.push("length"), t;
    }
  }, p0e = Object.assign({}, PW, {
    get(t, e) {
      const { context: n, objectId: r } = t;
      return e = wl(e), e === Symbol.hasInstance ? (i) => Array.isArray(i) : e === Symbol.toStringTag ? t[Symbol.toStringTag] : e === Ov ? r : e === VD ? true : e === vv ? t.trace : e === zh ? {
        handle: n
      } : e === "length" ? n.length(r) : typeof e == "number" ? Ao(t, e) : g0e(t)[e] || WD(t)[e];
    },
    getPrototypeOf() {
      return Object.getPrototypeOf(new XD());
    }
  });
  function HP(t, e, n, r) {
    const i = {
      context: t,
      objectId: e,
      path: r || [],
      cache: {},
      textV2: n
    }, s = {};
    return Object.assign(s, i), new Proxy(s, f0e);
  }
  function YP(t, e, n, r) {
    const i = {
      context: t,
      objectId: e,
      path: r || [],
      cache: {},
      textV2: n
    }, s = [];
    return Object.assign(s, i), new Proxy(s, PW);
  }
  function Sv(t, e, n) {
    const r = {
      context: t,
      objectId: e,
      path: n || [],
      cache: {},
      textV2: false
    }, i = {};
    return Object.assign(i, r), new Proxy(i, p0e);
  }
  function WD(t) {
    const { context: e, objectId: n, path: r, textV2: i } = t;
    return {
      deleteAt(s, o) {
        return typeof o == "number" ? e.splice(n, s, o) : e.delete(n, s), this;
      },
      fill(s, o, a) {
        const [l, c] = Mb(s, i, [
          ...r,
          o
        ], e), u = e.length(n);
        o = wl(o || 0), a = wl(a || u);
        for (let d = o; d < Math.min(a, u); d++)
          if (c === "list" || c === "map")
            e.putObject(n, d, l);
          else if (c === "text")
            if (i)
              Db(l), e.putObject(n, d, l);
            else {
              ZD(l);
              const h = e.putObject(n, d, ""), f = Sv(e, h, [
                ...r,
                d
              ]);
              for (let y = 0; y < l.length; y++)
                f[y] = l.get(y);
            }
          else
            e.put(n, d, l, c);
        return this;
      },
      indexOf(s, o = 0) {
        const a = e.length(n);
        for (let l = o; l < a; l++) {
          const c = e.getWithType(n, l);
          if (c && (c[1] === s[Ov] || c[1] === s))
            return l;
        }
        return -1;
      },
      insertAt(s, ...o) {
        return this.splice(s, 0, ...o), this;
      },
      pop() {
        const s = e.length(n);
        if (s == 0)
          return;
        const o = Ao(t, s - 1);
        return e.delete(n, s - 1), o;
      },
      push(...s) {
        const o = e.length(n);
        return this.splice(o, 0, ...s), e.length(n);
      },
      shift() {
        if (e.length(n) == 0)
          return;
        const s = Ao(t, 0);
        return e.delete(n, 0), s;
      },
      splice(s, o, ...a) {
        s = wl(s), typeof o != "number" && (o = e.length(n) - s), o = wl(o);
        for (const u of a)
          if (ZP(u, e))
            throw new RangeError("Cannot create a reference to an existing document object");
        const l = [];
        for (let u = 0; u < o; u++) {
          const d = Ao(t, s);
          d !== void 0 && l.push(d), e.delete(n, s);
        }
        const c = a.map((u, d) => {
          try {
            return Mb(u, i, [
              ...r
            ], e);
          } catch (h) {
            throw h instanceof RangeError ? new RangeError(`${h.message} (at index ${d} in the input)`) : h;
          }
        });
        for (const [u, d] of c) {
          switch (d) {
            case "list": {
              const h = e.insertObject(n, s, []);
              YP(e, h, i, [
                ...r,
                s
              ]).splice(0, 0, ...u);
              break;
            }
            case "text": {
              if (i)
                Db(u), e.insertObject(n, s, u);
              else {
                const h = e.insertObject(n, s, "");
                Sv(e, h, [
                  ...r,
                  s
                ]).splice(0, 0, ...u);
              }
              break;
            }
            case "map": {
              const h = e.insertObject(n, s, {}), f = HP(e, h, i, [
                ...r,
                s
              ]);
              for (const y in u)
                f[y] = u[y];
              break;
            }
            default:
              e.insert(n, s, u, d);
          }
          s += 1;
        }
        return l;
      },
      unshift(...s) {
        return this.splice(0, 0, ...s), e.length(n);
      },
      entries() {
        let s = 0;
        return {
          next: () => {
            const o = Ao(t, s);
            return o === void 0 ? {
              value: void 0,
              done: true
            } : {
              value: [
                s++,
                o
              ],
              done: false
            };
          },
          [Symbol.iterator]() {
            return this;
          }
        };
      },
      keys() {
        let s = 0;
        const o = e.length(n);
        return {
          next: () => s < o ? {
            value: s++,
            done: false
          } : {
            value: void 0,
            done: true
          },
          [Symbol.iterator]() {
            return this;
          }
        };
      },
      values() {
        let s = 0;
        return {
          next: () => {
            const o = Ao(t, s++);
            return o === void 0 ? {
              value: void 0,
              done: true
            } : {
              value: o,
              done: false
            };
          },
          [Symbol.iterator]() {
            return this;
          }
        };
      },
      toArray() {
        const s = [];
        let o;
        do
          o = Ao(t, s.length), o !== void 0 && s.push(o);
        while (o !== void 0);
        return s;
      },
      map(s) {
        return this.toArray().map(s);
      },
      toString() {
        return this.toArray().toString();
      },
      toLocaleString() {
        return this.toArray().toLocaleString();
      },
      forEach(s) {
        return this.toArray().forEach(s);
      },
      concat(s) {
        return this.toArray().concat(s);
      },
      every(s) {
        return this.toArray().every(s);
      },
      filter(s) {
        return this.toArray().filter(s);
      },
      find(s) {
        let o = 0;
        for (const a of this) {
          if (s(a, o))
            return a;
          o += 1;
        }
      },
      findIndex(s) {
        let o = 0;
        for (const a of this) {
          if (s(a, o))
            return o;
          o += 1;
        }
        return -1;
      },
      includes(s) {
        return this.find((o) => o === s) !== void 0;
      },
      join(s) {
        return this.toArray().join(s);
      },
      reduce(s, o) {
        return this.toArray().reduce(s, o);
      },
      reduceRight(s, o) {
        return this.toArray().reduceRight(s, o);
      },
      lastIndexOf(s, o = 1 / 0) {
        return this.toArray().lastIndexOf(s, o);
      },
      slice(s, o) {
        return this.toArray().slice(s, o);
      },
      some(s) {
        let o = 0;
        for (const a of this) {
          if (s(a, o))
            return true;
          o += 1;
        }
        return false;
      },
      [Symbol.iterator]: function* () {
        let s = 0, o = Ao(t, s);
        for (; o !== void 0; )
          yield o, s += 1, o = Ao(t, s);
      }
    };
  }
  function g0e(t) {
    const { context: e, objectId: n } = t;
    return {
      set(r, i) {
        return this[r] = i;
      },
      get(r) {
        return this[r];
      },
      toString() {
        return e.text(n).replace(/￼/g, "");
      },
      toSpans() {
        const r = [];
        let i = "";
        const s = e.length(n);
        for (let o = 0; o < s; o++) {
          const a = this[o];
          typeof a == "string" ? i += a : (i.length > 0 && (r.push(i), i = ""), r.push(a));
        }
        return i.length > 0 && r.push(i), r;
      },
      toJSON() {
        return this.toString();
      },
      indexOf(r, i = 0) {
        return e.text(n).indexOf(r, i);
      },
      insertAt(r, ...i) {
        i.every((s) => typeof s == "string") ? e.splice(n, r, 0, i.join("")) : WD(t).insertAt(r, ...i);
      }
    };
  }
  function ZD(t) {
    if (!(t instanceof XD))
      throw new Error("value was not a Text instance");
  }
  function Db(t) {
    if (typeof t != "string")
      throw new Error("value was not a string");
  }
  function VQ(t) {
    const e = t.map((n) => {
      if (typeof n == "number")
        return n.toString();
      if (typeof n == "string")
        return n.replace(/~/g, "~0").replace(/\//g, "~1");
    });
    return t.length === 0 ? "" : "/" + e.join("/");
  }
  const m0e = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
  function CW(t) {
    return typeof t == "string" && m0e.test(t);
  }
  const Dr = [];
  for (let t = 0; t < 256; ++t)
    Dr.push((t + 256).toString(16).slice(1));
  function y0e(t, e = 0) {
    return Dr[t[e + 0]] + Dr[t[e + 1]] + Dr[t[e + 2]] + Dr[t[e + 3]] + "-" + Dr[t[e + 4]] + Dr[t[e + 5]] + "-" + Dr[t[e + 6]] + Dr[t[e + 7]] + "-" + Dr[t[e + 8]] + Dr[t[e + 9]] + "-" + Dr[t[e + 10]] + Dr[t[e + 11]] + Dr[t[e + 12]] + Dr[t[e + 13]] + Dr[t[e + 14]] + Dr[t[e + 15]];
  }
  function v0e(t, e = 0) {
    const n = y0e(t, e);
    if (!CW(n))
      throw TypeError("Stringified UUID is invalid");
    return n;
  }
  let _W;
  const TW = new Array(128).fill(void 0);
  TW.push(void 0, null, true, false);
  TW.length;
  const O0e = typeof TextEncoder < "u" ? new TextEncoder("utf-8") : {
    encode: () => {
      throw Error("TextEncoder not available");
    }
  };
  O0e.encodeInto;
  const S0e = typeof TextDecoder < "u" ? new TextDecoder("utf-8", {
    ignoreBOM: true,
    fatal: true
  }) : {
    decode: () => {
      throw Error("TextDecoder not available");
    }
  };
  typeof TextDecoder < "u" && S0e.decode();
  typeof FinalizationRegistry > "u" || new FinalizationRegistry((t) => _W.__wbg_automerge_free(t >>> 0));
  typeof FinalizationRegistry > "u" || new FinalizationRegistry((t) => _W.__wbg_syncstate_free(t >>> 0));
  var w0e = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
  function GP(t) {
    return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
  }
  var Q$ = {
    exports: {}
  }, PT, XQ;
  function x0e() {
    if (XQ)
      return PT;
    XQ = 1;
    var t = 1e3, e = t * 60, n = e * 60, r = n * 24, i = r * 7, s = r * 365.25;
    PT = function(u, d) {
      d = d || {};
      var h = typeof u;
      if (h === "string" && u.length > 0)
        return o(u);
      if (h === "number" && isFinite(u))
        return d.long ? l(u) : a(u);
      throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(u));
    };
    function o(u) {
      if (u = String(u), !(u.length > 100)) {
        var d = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);
        if (d) {
          var h = parseFloat(d[1]), f = (d[2] || "ms").toLowerCase();
          switch (f) {
            case "years":
            case "year":
            case "yrs":
            case "yr":
            case "y":
              return h * s;
            case "weeks":
            case "week":
            case "w":
              return h * i;
            case "days":
            case "day":
            case "d":
              return h * r;
            case "hours":
            case "hour":
            case "hrs":
            case "hr":
            case "h":
              return h * n;
            case "minutes":
            case "minute":
            case "mins":
            case "min":
            case "m":
              return h * e;
            case "seconds":
            case "second":
            case "secs":
            case "sec":
            case "s":
              return h * t;
            case "milliseconds":
            case "millisecond":
            case "msecs":
            case "msec":
            case "ms":
              return h;
            default:
              return;
          }
        }
      }
    }
    function a(u) {
      var d = Math.abs(u);
      return d >= r ? Math.round(u / r) + "d" : d >= n ? Math.round(u / n) + "h" : d >= e ? Math.round(u / e) + "m" : d >= t ? Math.round(u / t) + "s" : u + "ms";
    }
    function l(u) {
      var d = Math.abs(u);
      return d >= r ? c(u, d, r, "day") : d >= n ? c(u, d, n, "hour") : d >= e ? c(u, d, e, "minute") : d >= t ? c(u, d, t, "second") : u + " ms";
    }
    function c(u, d, h, f) {
      var y = d >= h * 1.5;
      return Math.round(u / h) + " " + f + (y ? "s" : "");
    }
    return PT;
  }
  function b0e(t) {
    n.debug = n, n.default = n, n.coerce = l, n.disable = s, n.enable = i, n.enabled = o, n.humanize = x0e(), n.destroy = c, Object.keys(t).forEach((u) => {
      n[u] = t[u];
    }), n.names = [], n.skips = [], n.formatters = {};
    function e(u) {
      let d = 0;
      for (let h = 0; h < u.length; h++)
        d = (d << 5) - d + u.charCodeAt(h), d |= 0;
      return n.colors[Math.abs(d) % n.colors.length];
    }
    n.selectColor = e;
    function n(u) {
      let d, h = null, f, y;
      function g(...O) {
        if (!g.enabled)
          return;
        const S = g, w = Number(/* @__PURE__ */ new Date()), x = w - (d || w);
        S.diff = x, S.prev = d, S.curr = w, d = w, O[0] = n.coerce(O[0]), typeof O[0] != "string" && O.unshift("%O");
        let P = 0;
        O[0] = O[0].replace(/%([a-zA-Z%])/g, (C, _) => {
          if (C === "%%")
            return "%";
          P++;
          const T = n.formatters[_];
          if (typeof T == "function") {
            const $ = O[P];
            C = T.call(S, $), O.splice(P, 1), P--;
          }
          return C;
        }), n.formatArgs.call(S, O), (S.log || n.log).apply(S, O);
      }
      return g.namespace = u, g.useColors = n.useColors(), g.color = n.selectColor(u), g.extend = r, g.destroy = n.destroy, Object.defineProperty(g, "enabled", {
        enumerable: true,
        configurable: false,
        get: () => h !== null ? h : (f !== n.namespaces && (f = n.namespaces, y = n.enabled(u)), y),
        set: (O) => {
          h = O;
        }
      }), typeof n.init == "function" && n.init(g), g;
    }
    function r(u, d) {
      const h = n(this.namespace + (typeof d > "u" ? ":" : d) + u);
      return h.log = this.log, h;
    }
    function i(u) {
      n.save(u), n.namespaces = u, n.names = [], n.skips = [];
      let d;
      const h = (typeof u == "string" ? u : "").split(/[\s,]+/), f = h.length;
      for (d = 0; d < f; d++)
        h[d] && (u = h[d].replace(/\*/g, ".*?"), u[0] === "-" ? n.skips.push(new RegExp("^" + u.slice(1) + "$")) : n.names.push(new RegExp("^" + u + "$")));
    }
    function s() {
      const u = [
        ...n.names.map(a),
        ...n.skips.map(a).map((d) => "-" + d)
      ].join(",");
      return n.enable(""), u;
    }
    function o(u) {
      if (u[u.length - 1] === "*")
        return true;
      let d, h;
      for (d = 0, h = n.skips.length; d < h; d++)
        if (n.skips[d].test(u))
          return false;
      for (d = 0, h = n.names.length; d < h; d++)
        if (n.names[d].test(u))
          return true;
      return false;
    }
    function a(u) {
      return u.toString().substring(2, u.toString().length - 2).replace(/\.\*\?$/, "*");
    }
    function l(u) {
      return u instanceof Error ? u.stack || u.message : u;
    }
    function c() {
      console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
    }
    return n.enable(n.load()), n;
  }
  var k0e = b0e;
  (function(t, e) {
    e.formatArgs = r, e.save = i, e.load = s, e.useColors = n, e.storage = o(), e.destroy = (() => {
      let l = false;
      return () => {
        l || (l = true, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
      };
    })(), e.colors = [
      "#0000CC",
      "#0000FF",
      "#0033CC",
      "#0033FF",
      "#0066CC",
      "#0066FF",
      "#0099CC",
      "#0099FF",
      "#00CC00",
      "#00CC33",
      "#00CC66",
      "#00CC99",
      "#00CCCC",
      "#00CCFF",
      "#3300CC",
      "#3300FF",
      "#3333CC",
      "#3333FF",
      "#3366CC",
      "#3366FF",
      "#3399CC",
      "#3399FF",
      "#33CC00",
      "#33CC33",
      "#33CC66",
      "#33CC99",
      "#33CCCC",
      "#33CCFF",
      "#6600CC",
      "#6600FF",
      "#6633CC",
      "#6633FF",
      "#66CC00",
      "#66CC33",
      "#9900CC",
      "#9900FF",
      "#9933CC",
      "#9933FF",
      "#99CC00",
      "#99CC33",
      "#CC0000",
      "#CC0033",
      "#CC0066",
      "#CC0099",
      "#CC00CC",
      "#CC00FF",
      "#CC3300",
      "#CC3333",
      "#CC3366",
      "#CC3399",
      "#CC33CC",
      "#CC33FF",
      "#CC6600",
      "#CC6633",
      "#CC9900",
      "#CC9933",
      "#CCCC00",
      "#CCCC33",
      "#FF0000",
      "#FF0033",
      "#FF0066",
      "#FF0099",
      "#FF00CC",
      "#FF00FF",
      "#FF3300",
      "#FF3333",
      "#FF3366",
      "#FF3399",
      "#FF33CC",
      "#FF33FF",
      "#FF6600",
      "#FF6633",
      "#FF9900",
      "#FF9933",
      "#FFCC00",
      "#FFCC33"
    ];
    function n() {
      return typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs) ? true : typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/) ? false : typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
    }
    function r(l) {
      if (l[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + l[0] + (this.useColors ? "%c " : " ") + "+" + t.exports.humanize(this.diff), !this.useColors)
        return;
      const c = "color: " + this.color;
      l.splice(1, 0, c, "color: inherit");
      let u = 0, d = 0;
      l[0].replace(/%[a-zA-Z%]/g, (h) => {
        h !== "%%" && (u++, h === "%c" && (d = u));
      }), l.splice(d, 0, c);
    }
    e.log = console.debug || console.log || (() => {
    });
    function i(l) {
      try {
        l ? e.storage.setItem("debug", l) : e.storage.removeItem("debug");
      } catch {
      }
    }
    function s() {
      let l;
      try {
        l = e.storage.getItem("debug");
      } catch {
      }
      return !l && typeof process < "u" && "env" in process && (l = {}.DEBUG), l;
    }
    function o() {
      try {
        return localStorage;
      } catch {
      }
    }
    t.exports = k0e(e);
    const { formatters: a } = t.exports;
    a.j = function(l) {
      try {
        return JSON.stringify(l);
      } catch (c) {
        return "[UnexpectedJSONParseError]: " + c.message;
      }
    };
  })(Q$, Q$.exports);
  var P0e = Q$.exports;
  const C0e = GP(P0e);
  var EW = {
    exports: {}
  };
  (function(t) {
    var e = Object.prototype.hasOwnProperty, n = "~";
    function r() {
    }
    Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (n = false));
    function i(l, c, u) {
      this.fn = l, this.context = c, this.once = u || false;
    }
    function s(l, c, u, d, h) {
      if (typeof u != "function")
        throw new TypeError("The listener must be a function");
      var f = new i(u, d || l, h), y = n ? n + c : c;
      return l._events[y] ? l._events[y].fn ? l._events[y] = [
        l._events[y],
        f
      ] : l._events[y].push(f) : (l._events[y] = f, l._eventsCount++), l;
    }
    function o(l, c) {
      --l._eventsCount === 0 ? l._events = new r() : delete l._events[c];
    }
    function a() {
      this._events = new r(), this._eventsCount = 0;
    }
    a.prototype.eventNames = function() {
      var l = [], c, u;
      if (this._eventsCount === 0)
        return l;
      for (u in c = this._events)
        e.call(c, u) && l.push(n ? u.slice(1) : u);
      return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(c)) : l;
    }, a.prototype.listeners = function(l) {
      var c = n ? n + l : l, u = this._events[c];
      if (!u)
        return [];
      if (u.fn)
        return [
          u.fn
        ];
      for (var d = 0, h = u.length, f = new Array(h); d < h; d++)
        f[d] = u[d].fn;
      return f;
    }, a.prototype.listenerCount = function(l) {
      var c = n ? n + l : l, u = this._events[c];
      return u ? u.fn ? 1 : u.length : 0;
    }, a.prototype.emit = function(l, c, u, d, h, f) {
      var y = n ? n + l : l;
      if (!this._events[y])
        return false;
      var g = this._events[y], O = arguments.length, S, w;
      if (g.fn) {
        switch (g.once && this.removeListener(l, g.fn, void 0, true), O) {
          case 1:
            return g.fn.call(g.context), true;
          case 2:
            return g.fn.call(g.context, c), true;
          case 3:
            return g.fn.call(g.context, c, u), true;
          case 4:
            return g.fn.call(g.context, c, u, d), true;
          case 5:
            return g.fn.call(g.context, c, u, d, h), true;
          case 6:
            return g.fn.call(g.context, c, u, d, h, f), true;
        }
        for (w = 1, S = new Array(O - 1); w < O; w++)
          S[w - 1] = arguments[w];
        g.fn.apply(g.context, S);
      } else {
        var x = g.length, P;
        for (w = 0; w < x; w++)
          switch (g[w].once && this.removeListener(l, g[w].fn, void 0, true), O) {
            case 1:
              g[w].fn.call(g[w].context);
              break;
            case 2:
              g[w].fn.call(g[w].context, c);
              break;
            case 3:
              g[w].fn.call(g[w].context, c, u);
              break;
            case 4:
              g[w].fn.call(g[w].context, c, u, d);
              break;
            default:
              if (!S)
                for (P = 1, S = new Array(O - 1); P < O; P++)
                  S[P - 1] = arguments[P];
              g[w].fn.apply(g[w].context, S);
          }
      }
      return true;
    }, a.prototype.on = function(l, c, u) {
      return s(this, l, c, u, false);
    }, a.prototype.once = function(l, c, u) {
      return s(this, l, c, u, true);
    }, a.prototype.removeListener = function(l, c, u, d) {
      var h = n ? n + l : l;
      if (!this._events[h])
        return this;
      if (!c)
        return o(this, h), this;
      var f = this._events[h];
      if (f.fn)
        f.fn === c && (!d || f.once) && (!u || f.context === u) && o(this, h);
      else {
        for (var y = 0, g = [], O = f.length; y < O; y++)
          (f[y].fn !== c || d && !f[y].once || u && f[y].context !== u) && g.push(f[y]);
        g.length ? this._events[h] = g.length === 1 ? g[0] : g : o(this, h);
      }
      return this;
    }, a.prototype.removeAllListeners = function(l) {
      var c;
      return l ? (c = n ? n + l : l, this._events[c] && o(this, c)) : (this._events = new r(), this._eventsCount = 0), this;
    }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, t.exports = a;
  })(EW);
  var _0e = EW.exports;
  const T0e = GP(_0e);
  var Tg = {}, ad = {}, kr = {};
  Object.defineProperty(kr, "__esModule", {
    value: true
  });
  kr.output = kr.exists = kr.hash = kr.bytes = kr.bool = kr.number = kr.isBytes = void 0;
  function Lb(t) {
    if (!Number.isSafeInteger(t) || t < 0)
      throw new Error(`positive integer expected, not ${t}`);
  }
  kr.number = Lb;
  function IW(t) {
    if (typeof t != "boolean")
      throw new Error(`boolean expected, not ${t}`);
  }
  kr.bool = IW;
  function $W(t) {
    return t instanceof Uint8Array || t != null && typeof t == "object" && t.constructor.name === "Uint8Array";
  }
  kr.isBytes = $W;
  function HD(t, ...e) {
    if (!$W(t))
      throw new Error("Uint8Array expected");
    if (e.length > 0 && !e.includes(t.length))
      throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`);
  }
  kr.bytes = HD;
  function AW(t) {
    if (typeof t != "function" || typeof t.create != "function")
      throw new Error("Hash should be wrapped by utils.wrapConstructor");
    Lb(t.outputLen), Lb(t.blockLen);
  }
  kr.hash = AW;
  function RW(t, e = true) {
    if (t.destroyed)
      throw new Error("Hash instance has been destroyed");
    if (e && t.finished)
      throw new Error("Hash#digest() has already been called");
  }
  kr.exists = RW;
  function MW(t, e) {
    HD(t);
    const n = e.outputLen;
    if (t.length < n)
      throw new Error(`digestInto() expects output buffer of length at least ${n}`);
  }
  kr.output = MW;
  const E0e = {
    number: Lb,
    bool: IW,
    bytes: HD,
    hash: AW,
    exists: RW,
    output: MW
  };
  kr.default = E0e;
  var YD = {}, qP = {};
  Object.defineProperty(qP, "__esModule", {
    value: true
  });
  qP.crypto = void 0;
  qP.crypto = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
  (function(t) {
    Object.defineProperty(t, "__esModule", {
      value: true
    }), t.randomBytes = t.wrapXOFConstructorWithOpts = t.wrapConstructorWithOpts = t.wrapConstructor = t.checkOpts = t.Hash = t.concatBytes = t.toBytes = t.utf8ToBytes = t.asyncLoop = t.nextTick = t.hexToBytes = t.bytesToHex = t.byteSwap32 = t.byteSwapIfBE = t.byteSwap = t.isLE = t.rotl = t.rotr = t.createView = t.u32 = t.u8 = t.isBytes = void 0;
    const e = qP, n = kr;
    function r(M) {
      return M instanceof Uint8Array || M != null && typeof M == "object" && M.constructor.name === "Uint8Array";
    }
    t.isBytes = r;
    const i = (M) => new Uint8Array(M.buffer, M.byteOffset, M.byteLength);
    t.u8 = i;
    const s = (M) => new Uint32Array(M.buffer, M.byteOffset, Math.floor(M.byteLength / 4));
    t.u32 = s;
    const o = (M) => new DataView(M.buffer, M.byteOffset, M.byteLength);
    t.createView = o;
    const a = (M, R) => M << 32 - R | M >>> R;
    t.rotr = a;
    const l = (M, R) => M << R | M >>> 32 - R >>> 0;
    t.rotl = l, t.isLE = new Uint8Array(new Uint32Array([
      287454020
    ]).buffer)[0] === 68;
    const c = (M) => M << 24 & 4278190080 | M << 8 & 16711680 | M >>> 8 & 65280 | M >>> 24 & 255;
    t.byteSwap = c, t.byteSwapIfBE = t.isLE ? (M) => M : (M) => (0, t.byteSwap)(M);
    function u(M) {
      for (let R = 0; R < M.length; R++)
        M[R] = (0, t.byteSwap)(M[R]);
    }
    t.byteSwap32 = u;
    const d = Array.from({
      length: 256
    }, (M, R) => R.toString(16).padStart(2, "0"));
    function h(M) {
      (0, n.bytes)(M);
      let R = "";
      for (let F = 0; F < M.length; F++)
        R += d[M[F]];
      return R;
    }
    t.bytesToHex = h;
    const f = {
      _0: 48,
      _9: 57,
      _A: 65,
      _F: 70,
      _a: 97,
      _f: 102
    };
    function y(M) {
      if (M >= f._0 && M <= f._9)
        return M - f._0;
      if (M >= f._A && M <= f._F)
        return M - (f._A - 10);
      if (M >= f._a && M <= f._f)
        return M - (f._a - 10);
    }
    function g(M) {
      if (typeof M != "string")
        throw new Error("hex string expected, got " + typeof M);
      const R = M.length, F = R / 2;
      if (R % 2)
        throw new Error("padded hex string expected, got unpadded hex of length " + R);
      const Q = new Uint8Array(F);
      for (let X = 0, Z = 0; X < F; X++, Z += 2) {
        const U = y(M.charCodeAt(Z)), H = y(M.charCodeAt(Z + 1));
        if (U === void 0 || H === void 0) {
          const te = M[Z] + M[Z + 1];
          throw new Error('hex string expected, got non-hex character "' + te + '" at index ' + Z);
        }
        Q[X] = U * 16 + H;
      }
      return Q;
    }
    t.hexToBytes = g;
    const O = async () => {
    };
    t.nextTick = O;
    async function S(M, R, F) {
      let Q = Date.now();
      for (let X = 0; X < M; X++) {
        F(X);
        const Z = Date.now() - Q;
        Z >= 0 && Z < R || (await (0, t.nextTick)(), Q += Z);
      }
    }
    t.asyncLoop = S;
    function w(M) {
      if (typeof M != "string")
        throw new Error(`utf8ToBytes expected string, got ${typeof M}`);
      return new Uint8Array(new TextEncoder().encode(M));
    }
    t.utf8ToBytes = w;
    function x(M) {
      return typeof M == "string" && (M = w(M)), (0, n.bytes)(M), M;
    }
    t.toBytes = x;
    function P(...M) {
      let R = 0;
      for (let Q = 0; Q < M.length; Q++) {
        const X = M[Q];
        (0, n.bytes)(X), R += X.length;
      }
      const F = new Uint8Array(R);
      for (let Q = 0, X = 0; Q < M.length; Q++) {
        const Z = M[Q];
        F.set(Z, X), X += Z.length;
      }
      return F;
    }
    t.concatBytes = P;
    class C {
      clone() {
        return this._cloneInto();
      }
    }
    t.Hash = C;
    const _ = {}.toString;
    function T(M, R) {
      if (R !== void 0 && _.call(R) !== "[object Object]")
        throw new Error("Options should be object or undefined");
      return Object.assign(M, R);
    }
    t.checkOpts = T;
    function $(M) {
      const R = (Q) => M().update(x(Q)).digest(), F = M();
      return R.outputLen = F.outputLen, R.blockLen = F.blockLen, R.create = () => M(), R;
    }
    t.wrapConstructor = $;
    function N(M) {
      const R = (Q, X) => M(X).update(x(Q)).digest(), F = M({});
      return R.outputLen = F.outputLen, R.blockLen = F.blockLen, R.create = (Q) => M(Q), R;
    }
    t.wrapConstructorWithOpts = N;
    function L(M) {
      const R = (Q, X) => M(X).update(x(Q)).digest(), F = M({});
      return R.outputLen = F.outputLen, R.blockLen = F.blockLen, R.create = (Q) => M(Q), R;
    }
    t.wrapXOFConstructorWithOpts = L;
    function z(M = 32) {
      if (e.crypto && typeof e.crypto.getRandomValues == "function")
        return e.crypto.getRandomValues(new Uint8Array(M));
      throw new Error("crypto.getRandomValues must be defined");
    }
    t.randomBytes = z;
  })(YD);
  Object.defineProperty(ad, "__esModule", {
    value: true
  });
  ad.HashMD = ad.Maj = ad.Chi = void 0;
  const CT = kr, by = YD;
  function I0e(t, e, n, r) {
    if (typeof t.setBigUint64 == "function")
      return t.setBigUint64(e, n, r);
    const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), a = Number(n & s), l = r ? 4 : 0, c = r ? 0 : 4;
    t.setUint32(e + l, o, r), t.setUint32(e + c, a, r);
  }
  const $0e = (t, e, n) => t & e ^ ~t & n;
  ad.Chi = $0e;
  const A0e = (t, e, n) => t & e ^ t & n ^ e & n;
  ad.Maj = A0e;
  class R0e extends by.Hash {
    constructor(e, n, r, i) {
      super(), this.blockLen = e, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = false, this.length = 0, this.pos = 0, this.destroyed = false, this.buffer = new Uint8Array(e), this.view = (0, by.createView)(this.buffer);
    }
    update(e) {
      (0, CT.exists)(this);
      const { view: n, buffer: r, blockLen: i } = this;
      e = (0, by.toBytes)(e);
      const s = e.length;
      for (let o = 0; o < s; ) {
        const a = Math.min(i - this.pos, s - o);
        if (a === i) {
          const l = (0, by.createView)(e);
          for (; i <= s - o; o += i)
            this.process(l, o);
          continue;
        }
        r.set(e.subarray(o, o + a), this.pos), this.pos += a, o += a, this.pos === i && (this.process(n, 0), this.pos = 0);
      }
      return this.length += e.length, this.roundClean(), this;
    }
    digestInto(e) {
      (0, CT.exists)(this), (0, CT.output)(e, this), this.finished = true;
      const { buffer: n, view: r, blockLen: i, isLE: s } = this;
      let { pos: o } = this;
      n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(r, 0), o = 0);
      for (let d = o; d < i; d++)
        n[d] = 0;
      I0e(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
      const a = (0, by.createView)(e), l = this.outputLen;
      if (l % 4)
        throw new Error("_sha2: outputLen should be aligned to 32bit");
      const c = l / 4, u = this.get();
      if (c > u.length)
        throw new Error("_sha2: outputLen bigger than state");
      for (let d = 0; d < c; d++)
        a.setUint32(4 * d, u[d], s);
    }
    digest() {
      const { buffer: e, outputLen: n } = this;
      this.digestInto(e);
      const r = e.slice(0, n);
      return this.destroy(), r;
    }
    _cloneInto(e) {
      e || (e = new this.constructor()), e.set(...this.get());
      const { blockLen: n, buffer: r, length: i, finished: s, destroyed: o, pos: a } = this;
      return e.length = i, e.pos = a, e.finished = s, e.destroyed = o, i % n && e.buffer.set(r), e;
    }
  }
  ad.HashMD = R0e;
  Object.defineProperty(Tg, "__esModule", {
    value: true
  });
  Tg.sha224 = Tg.sha256 = void 0;
  const _T = ad, $o = YD, M0e = new Uint32Array([
    1116352408,
    1899447441,
    3049323471,
    3921009573,
    961987163,
    1508970993,
    2453635748,
    2870763221,
    3624381080,
    310598401,
    607225278,
    1426881987,
    1925078388,
    2162078206,
    2614888103,
    3248222580,
    3835390401,
    4022224774,
    264347078,
    604807628,
    770255983,
    1249150122,
    1555081692,
    1996064986,
    2554220882,
    2821834349,
    2952996808,
    3210313671,
    3336571891,
    3584528711,
    113926993,
    338241895,
    666307205,
    773529912,
    1294757372,
    1396182291,
    1695183700,
    1986661051,
    2177026350,
    2456956037,
    2730485921,
    2820302411,
    3259730800,
    3345764771,
    3516065817,
    3600352804,
    4094571909,
    275423344,
    430227734,
    506948616,
    659060556,
    883997877,
    958139571,
    1322822218,
    1537002063,
    1747873779,
    1955562222,
    2024104815,
    2227730452,
    2361852424,
    2428436474,
    2756734187,
    3204031479,
    3329325298
  ]), wu = new Uint32Array([
    1779033703,
    3144134277,
    1013904242,
    2773480762,
    1359893119,
    2600822924,
    528734635,
    1541459225
  ]), xu = new Uint32Array(64);
  class DW extends _T.HashMD {
    constructor() {
      super(64, 32, 8, false), this.A = wu[0] | 0, this.B = wu[1] | 0, this.C = wu[2] | 0, this.D = wu[3] | 0, this.E = wu[4] | 0, this.F = wu[5] | 0, this.G = wu[6] | 0, this.H = wu[7] | 0;
    }
    get() {
      const { A: e, B: n, C: r, D: i, E: s, F: o, G: a, H: l } = this;
      return [
        e,
        n,
        r,
        i,
        s,
        o,
        a,
        l
      ];
    }
    set(e, n, r, i, s, o, a, l) {
      this.A = e | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = s | 0, this.F = o | 0, this.G = a | 0, this.H = l | 0;
    }
    process(e, n) {
      for (let d = 0; d < 16; d++, n += 4)
        xu[d] = e.getUint32(n, false);
      for (let d = 16; d < 64; d++) {
        const h = xu[d - 15], f = xu[d - 2], y = (0, $o.rotr)(h, 7) ^ (0, $o.rotr)(h, 18) ^ h >>> 3, g = (0, $o.rotr)(f, 17) ^ (0, $o.rotr)(f, 19) ^ f >>> 10;
        xu[d] = g + xu[d - 7] + y + xu[d - 16] | 0;
      }
      let { A: r, B: i, C: s, D: o, E: a, F: l, G: c, H: u } = this;
      for (let d = 0; d < 64; d++) {
        const h = (0, $o.rotr)(a, 6) ^ (0, $o.rotr)(a, 11) ^ (0, $o.rotr)(a, 25), f = u + h + (0, _T.Chi)(a, l, c) + M0e[d] + xu[d] | 0, y = ((0, $o.rotr)(r, 2) ^ (0, $o.rotr)(r, 13) ^ (0, $o.rotr)(r, 22)) + (0, _T.Maj)(r, i, s) | 0;
        u = c, c = l, l = a, a = o + f | 0, o = s, s = i, i = r, r = f + y | 0;
      }
      r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, l = l + this.F | 0, c = c + this.G | 0, u = u + this.H | 0, this.set(r, i, s, o, a, l, c, u);
    }
    roundClean() {
      xu.fill(0);
    }
    destroy() {
      this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
    }
  }
  class D0e extends DW {
    constructor() {
      super(), this.A = -1056596264, this.B = 914150663, this.C = 812702999, this.D = -150054599, this.E = -4191439, this.F = 1750603025, this.G = 1694076839, this.H = -1090891868, this.outputLen = 28;
    }
  }
  Tg.sha256 = (0, $o.wrapConstructor)(() => new DW());
  Tg.sha224 = (0, $o.wrapConstructor)(() => new D0e());
  function L0e(t) {
    if (t.length >= 255)
      throw new TypeError("Alphabet too long");
    for (var e = new Uint8Array(256), n = 0; n < e.length; n++)
      e[n] = 255;
    for (var r = 0; r < t.length; r++) {
      var i = t.charAt(r), s = i.charCodeAt(0);
      if (e[s] !== 255)
        throw new TypeError(i + " is ambiguous");
      e[s] = r;
    }
    var o = t.length, a = t.charAt(0), l = Math.log(o) / Math.log(256), c = Math.log(256) / Math.log(o);
    function u(f) {
      if (f instanceof Uint8Array || (ArrayBuffer.isView(f) ? f = new Uint8Array(f.buffer, f.byteOffset, f.byteLength) : Array.isArray(f) && (f = Uint8Array.from(f))), !(f instanceof Uint8Array))
        throw new TypeError("Expected Uint8Array");
      if (f.length === 0)
        return "";
      for (var y = 0, g = 0, O = 0, S = f.length; O !== S && f[O] === 0; )
        O++, y++;
      for (var w = (S - O) * c + 1 >>> 0, x = new Uint8Array(w); O !== S; ) {
        for (var P = f[O], C = 0, _ = w - 1; (P !== 0 || C < g) && _ !== -1; _--, C++)
          P += 256 * x[_] >>> 0, x[_] = P % o >>> 0, P = P / o >>> 0;
        if (P !== 0)
          throw new Error("Non-zero carry");
        g = C, O++;
      }
      for (var T = w - g; T !== w && x[T] === 0; )
        T++;
      for (var $ = a.repeat(y); T < w; ++T)
        $ += t.charAt(x[T]);
      return $;
    }
    function d(f) {
      if (typeof f != "string")
        throw new TypeError("Expected String");
      if (f.length === 0)
        return new Uint8Array();
      for (var y = 0, g = 0, O = 0; f[y] === a; )
        g++, y++;
      for (var S = (f.length - y) * l + 1 >>> 0, w = new Uint8Array(S); f[y]; ) {
        var x = e[f.charCodeAt(y)];
        if (x === 255)
          return;
        for (var P = 0, C = S - 1; (x !== 0 || P < O) && C !== -1; C--, P++)
          x += o * w[C] >>> 0, w[C] = x % 256 >>> 0, x = x / 256 >>> 0;
        if (x !== 0)
          throw new Error("Non-zero carry");
        O = P, y++;
      }
      for (var _ = S - O; _ !== S && w[_] === 0; )
        _++;
      for (var T = new Uint8Array(g + (S - _)), $ = g; _ !== S; )
        T[$++] = w[_++];
      return T;
    }
    function h(f) {
      var y = d(f);
      if (y)
        return y;
      throw new Error("Non-base" + o + " character");
    }
    return {
      encode: u,
      decodeUnsafe: d,
      decode: h
    };
  }
  var j0e = L0e;
  const N0e = j0e, Q0e = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
  var z0e = N0e(Q0e), TT = z0e, F0e = function(t) {
    function e(s) {
      var o = Uint8Array.from(s), a = t(o), l = o.length + 4, c = new Uint8Array(l);
      return c.set(o, 0), c.set(a.subarray(0, 4), o.length), TT.encode(c, l);
    }
    function n(s) {
      var o = s.slice(0, -4), a = s.slice(-4), l = t(o);
      if (!(a[0] ^ l[0] | a[1] ^ l[1] | a[2] ^ l[2] | a[3] ^ l[3]))
        return o;
    }
    function r(s) {
      var o = TT.decodeUnsafe(s);
      if (o)
        return n(o);
    }
    function i(s) {
      var o = TT.decode(s), a = n(o);
      if (!a)
        throw new Error("Invalid checksum");
      return a;
    }
    return {
      encode: e,
      decode: i,
      decodeUnsafe: r
    };
  }, { sha256: WQ } = Tg, B0e = F0e;
  function U0e(t) {
    return WQ(WQ(t));
  }
  var V0e = B0e(U0e);
  const X0e = GP(V0e), LW = "automerge:", jW = (t) => {
    const e = new RegExp(`^${LW}(\\w+)$`), [, n] = t.match(e) || [], r = n, i = NW(r);
    if (!i)
      throw new Error("Invalid document URL: " + t);
    return {
      binaryDocumentId: i,
      documentId: r
    };
  }, W0e = (t) => {
    if (!t || !t.startsWith(LW))
      return false;
    const e = t;
    try {
      const { documentId: n } = jW(e);
      return Z0e(n);
    } catch {
      return false;
    }
  }, Z0e = (t) => {
    const e = NW(t);
    if (e === void 0)
      return false;
    const n = v0e(e);
    return CW(n);
  }, NW = (t) => X0e.decodeUnsafe(t);
  let z$;
  try {
    z$ = new TextDecoder();
  } catch {
  }
  let Le, Fh, de = 0;
  const H0e = 105, Y0e = 57342, G0e = 57343, ZQ = 57337, HQ = 6, sp = {};
  let bt = {}, Fn, jb, Nb = 0, wv = 0, mr, Do, cr = [], F$ = [], ds, Ni, h0, YQ = {
    useRecords: false,
    mapsAsObjects: true
  }, xv = false, QW = 2;
  try {
    new Function("");
  } catch {
    QW = 1 / 0;
  }
  let zW = class B$ {
    constructor(e) {
      if (e && ((e.keyMap || e._keyMap) && !e.useRecords && (e.useRecords = false, e.mapsAsObjects = true), e.useRecords === false && e.mapsAsObjects === void 0 && (e.mapsAsObjects = true), e.getStructures && (e.getShared = e.getStructures), e.getShared && !e.structures && ((e.structures = []).uninitialized = true), e.keyMap)) {
        this.mapKey = /* @__PURE__ */ new Map();
        for (let [n, r] of Object.entries(e.keyMap))
          this.mapKey.set(r, n);
      }
      Object.assign(this, e);
    }
    decodeKey(e) {
      return this.keyMap && this.mapKey.get(e) || e;
    }
    encodeKey(e) {
      return this.keyMap && this.keyMap.hasOwnProperty(e) ? this.keyMap[e] : e;
    }
    encodeKeys(e) {
      if (!this._keyMap)
        return e;
      let n = /* @__PURE__ */ new Map();
      for (let [r, i] of Object.entries(e))
        n.set(this._keyMap.hasOwnProperty(r) ? this._keyMap[r] : r, i);
      return n;
    }
    decodeKeys(e) {
      if (!this._keyMap || e.constructor.name != "Map")
        return e;
      if (!this._mapKey) {
        this._mapKey = /* @__PURE__ */ new Map();
        for (let [r, i] of Object.entries(this._keyMap))
          this._mapKey.set(i, r);
      }
      let n = {};
      return e.forEach((r, i) => n[Lo(this._mapKey.has(i) ? this._mapKey.get(i) : i)] = r), n;
    }
    mapDecode(e, n) {
      let r = this.decode(e);
      if (this._keyMap)
        switch (r.constructor.name) {
          case "Array":
            return r.map((i) => this.decodeKeys(i));
        }
      return r;
    }
    decode(e, n) {
      if (Le)
        return VW(() => (W$(), this ? this.decode(e, n) : B$.prototype.decode.call(YQ, e, n)));
      Fh = n > -1 ? n : e.length, de = 0, wv = 0, jb = null, mr = null, Le = e;
      try {
        Ni = e.dataView || (e.dataView = new DataView(e.buffer, e.byteOffset, e.byteLength));
      } catch (r) {
        throw Le = null, e instanceof Uint8Array ? r : new Error("Source must be a Uint8Array or Buffer but was a " + (e && typeof e == "object" ? e.constructor.name : typeof e));
      }
      if (this instanceof B$) {
        if (bt = this, ds = this.sharedValues && (this.pack ? new Array(this.maxPrivatePackedValues || 16).concat(this.sharedValues) : this.sharedValues), this.structures)
          return Fn = this.structures, z1();
        (!Fn || Fn.length > 0) && (Fn = []);
      } else
        bt = YQ, (!Fn || Fn.length > 0) && (Fn = []), ds = null;
      return z1();
    }
    decodeMultiple(e, n) {
      let r, i = 0;
      try {
        let s = e.length;
        xv = true;
        let o = this ? this.decode(e, s) : KD.decode(e, s);
        if (n) {
          if (n(o) === false)
            return;
          for (; de < s; )
            if (i = de, n(z1()) === false)
              return;
        } else {
          for (r = [
            o
          ]; de < s; )
            i = de, r.push(z1());
          return r;
        }
      } catch (s) {
        throw s.lastPosition = i, s.values = r, s;
      } finally {
        xv = false, W$();
      }
    }
  };
  function z1() {
    try {
      let t = _t();
      if (mr) {
        if (de >= mr.postBundlePosition) {
          let e = new Error("Unexpected bundle position");
          throw e.incomplete = true, e;
        }
        de = mr.postBundlePosition, mr = null;
      }
      if (de == Fh)
        Fn = null, Le = null, Do && (Do = null);
      else if (de > Fh) {
        let e = new Error("Unexpected end of CBOR data");
        throw e.incomplete = true, e;
      } else if (!xv)
        throw new Error("Data read, but end of buffer not reached");
      return t;
    } catch (t) {
      throw W$(), (t instanceof RangeError || t.message.startsWith("Unexpected end of buffer")) && (t.incomplete = true), t;
    }
  }
  function _t() {
    let t = Le[de++], e = t >> 5;
    if (t = t & 31, t > 23)
      switch (t) {
        case 24:
          t = Le[de++];
          break;
        case 25:
          if (e == 7)
            return eve();
          t = Ni.getUint16(de), de += 2;
          break;
        case 26:
          if (e == 7) {
            let n = Ni.getFloat32(de);
            if (bt.useFloat32 > 2) {
              let r = qD[(Le[de] & 127) << 1 | Le[de + 1] >> 7];
              return de += 4, (r * n + (n > 0 ? 0.5 : -0.5) >> 0) / r;
            }
            return de += 4, n;
          }
          t = Ni.getUint32(de), de += 4;
          break;
        case 27:
          if (e == 7) {
            let n = Ni.getFloat64(de);
            return de += 8, n;
          }
          if (e > 1) {
            if (Ni.getUint32(de) > 0)
              throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");
            t = Ni.getUint32(de + 4);
          } else
            bt.int64AsNumber ? (t = Ni.getUint32(de) * 4294967296, t += Ni.getUint32(de + 4)) : t = Ni.getBigUint64(de);
          de += 8;
          break;
        case 31:
          switch (e) {
            case 2:
            case 3:
              throw new Error("Indefinite length not supported for byte or text strings");
            case 4:
              let n = [], r, i = 0;
              for (; (r = _t()) != sp; )
                n[i++] = r;
              return e == 4 ? n : e == 3 ? n.join("") : Buffer.concat(n);
            case 5:
              let s;
              if (bt.mapsAsObjects) {
                let o = {};
                if (bt.keyMap)
                  for (; (s = _t()) != sp; )
                    o[Lo(bt.decodeKey(s))] = _t();
                else
                  for (; (s = _t()) != sp; )
                    o[Lo(s)] = _t();
                return o;
              } else {
                h0 && (bt.mapsAsObjects = true, h0 = false);
                let o = /* @__PURE__ */ new Map();
                if (bt.keyMap)
                  for (; (s = _t()) != sp; )
                    o.set(bt.decodeKey(s), _t());
                else
                  for (; (s = _t()) != sp; )
                    o.set(s, _t());
                return o;
              }
            case 7:
              return sp;
            default:
              throw new Error("Invalid major type for indefinite length " + e);
          }
        default:
          throw new Error("Unknown token " + t);
      }
    switch (e) {
      case 0:
        return t;
      case 1:
        return ~t;
      case 2:
        return J0e(t);
      case 3:
        if (wv >= de)
          return jb.slice(de - Nb, (de += t) - Nb);
        if (wv == 0 && Fh < 140 && t < 32) {
          let i = t < 16 ? FW(t) : K0e(t);
          if (i != null)
            return i;
        }
        return q0e(t);
      case 4:
        let n = new Array(t);
        for (let i = 0; i < t; i++)
          n[i] = _t();
        return n;
      case 5:
        if (bt.mapsAsObjects) {
          let i = {};
          if (bt.keyMap)
            for (let s = 0; s < t; s++)
              i[Lo(bt.decodeKey(_t()))] = _t();
          else
            for (let s = 0; s < t; s++)
              i[Lo(_t())] = _t();
          return i;
        } else {
          h0 && (bt.mapsAsObjects = true, h0 = false);
          let i = /* @__PURE__ */ new Map();
          if (bt.keyMap)
            for (let s = 0; s < t; s++)
              i.set(bt.decodeKey(_t()), _t());
          else
            for (let s = 0; s < t; s++)
              i.set(_t(), _t());
          return i;
        }
      case 6:
        if (t >= ZQ) {
          let i = Fn[t & 8191];
          if (i)
            return i.read || (i.read = U$(i)), i.read();
          if (t < 65536) {
            if (t == G0e) {
              let s = Np(), o = _t(), a = _t();
              X$(o, a);
              let l = {};
              if (bt.keyMap)
                for (let c = 2; c < s; c++) {
                  let u = bt.decodeKey(a[c - 2]);
                  l[Lo(u)] = _t();
                }
              else
                for (let c = 2; c < s; c++) {
                  let u = a[c - 2];
                  l[Lo(u)] = _t();
                }
              return l;
            } else if (t == Y0e) {
              let s = Np(), o = _t();
              for (let a = 2; a < s; a++)
                X$(o++, _t());
              return _t();
            } else if (t == ZQ)
              return ove();
            if (bt.getShared && (GD(), i = Fn[t & 8191], i))
              return i.read || (i.read = U$(i)), i.read();
          }
        }
        let r = cr[t];
        if (r)
          return r.handlesRead ? r(_t) : r(_t());
        {
          let i = _t();
          for (let s = 0; s < F$.length; s++) {
            let o = F$[s](t, i);
            if (o !== void 0)
              return o;
          }
          return new Gh(i, t);
        }
      case 7:
        switch (t) {
          case 20:
            return false;
          case 21:
            return true;
          case 22:
            return null;
          case 23:
            return;
          case 31:
          default:
            let i = (ds || mh())[t];
            if (i !== void 0)
              return i;
            throw new Error("Unknown token " + t);
        }
      default:
        if (isNaN(t)) {
          let i = new Error("Unexpected end of CBOR data");
          throw i.incomplete = true, i;
        }
        throw new Error("Unknown CBOR token " + t);
    }
  }
  const GQ = /^[a-zA-Z_$][a-zA-Z\d_$]*$/;
  function U$(t) {
    function e() {
      let n = Le[de++];
      if (n = n & 31, n > 23)
        switch (n) {
          case 24:
            n = Le[de++];
            break;
          case 25:
            n = Ni.getUint16(de), de += 2;
            break;
          case 26:
            n = Ni.getUint32(de), de += 4;
            break;
          default:
            throw new Error("Expected array header, but got " + Le[de - 1]);
        }
      let r = this.compiledReader;
      for (; r; ) {
        if (r.propertyCount === n)
          return r(_t);
        r = r.next;
      }
      if (this.slowReads++ >= QW) {
        let s = this.length == n ? this : this.slice(0, n);
        return r = bt.keyMap ? new Function("r", "return {" + s.map((o) => bt.decodeKey(o)).map((o) => GQ.test(o) ? Lo(o) + ":r()" : "[" + JSON.stringify(o) + "]:r()").join(",") + "}") : new Function("r", "return {" + s.map((o) => GQ.test(o) ? Lo(o) + ":r()" : "[" + JSON.stringify(o) + "]:r()").join(",") + "}"), this.compiledReader && (r.next = this.compiledReader), r.propertyCount = n, this.compiledReader = r, r(_t);
      }
      let i = {};
      if (bt.keyMap)
        for (let s = 0; s < n; s++)
          i[Lo(bt.decodeKey(this[s]))] = _t();
      else
        for (let s = 0; s < n; s++)
          i[Lo(this[s])] = _t();
      return i;
    }
    return t.slowReads = 0, e;
  }
  function Lo(t) {
    if (typeof t == "string")
      return t === "__proto__" ? "__proto_" : t;
    if (typeof t == "number" || typeof t == "boolean" || typeof t == "bigint")
      return t.toString();
    if (t == null)
      return t + "";
    throw new Error("Invalid property name type " + typeof t);
  }
  let q0e = V$;
  function V$(t) {
    let e;
    if (t < 16 && (e = FW(t)))
      return e;
    if (t > 64 && z$)
      return z$.decode(Le.subarray(de, de += t));
    const n = de + t, r = [];
    for (e = ""; de < n; ) {
      const i = Le[de++];
      if (!(i & 128))
        r.push(i);
      else if ((i & 224) === 192) {
        const s = Le[de++] & 63;
        r.push((i & 31) << 6 | s);
      } else if ((i & 240) === 224) {
        const s = Le[de++] & 63, o = Le[de++] & 63;
        r.push((i & 31) << 12 | s << 6 | o);
      } else if ((i & 248) === 240) {
        const s = Le[de++] & 63, o = Le[de++] & 63, a = Le[de++] & 63;
        let l = (i & 7) << 18 | s << 12 | o << 6 | a;
        l > 65535 && (l -= 65536, r.push(l >>> 10 & 1023 | 55296), l = 56320 | l & 1023), r.push(l);
      } else
        r.push(i);
      r.length >= 4096 && (e += wr.apply(String, r), r.length = 0);
    }
    return r.length > 0 && (e += wr.apply(String, r)), e;
  }
  let wr = String.fromCharCode;
  function K0e(t) {
    let e = de, n = new Array(t);
    for (let r = 0; r < t; r++) {
      const i = Le[de++];
      if ((i & 128) > 0) {
        de = e;
        return;
      }
      n[r] = i;
    }
    return wr.apply(String, n);
  }
  function FW(t) {
    if (t < 4)
      if (t < 2) {
        if (t === 0)
          return "";
        {
          let e = Le[de++];
          if ((e & 128) > 1) {
            de -= 1;
            return;
          }
          return wr(e);
        }
      } else {
        let e = Le[de++], n = Le[de++];
        if ((e & 128) > 0 || (n & 128) > 0) {
          de -= 2;
          return;
        }
        if (t < 3)
          return wr(e, n);
        let r = Le[de++];
        if ((r & 128) > 0) {
          de -= 3;
          return;
        }
        return wr(e, n, r);
      }
    else {
      let e = Le[de++], n = Le[de++], r = Le[de++], i = Le[de++];
      if ((e & 128) > 0 || (n & 128) > 0 || (r & 128) > 0 || (i & 128) > 0) {
        de -= 4;
        return;
      }
      if (t < 6) {
        if (t === 4)
          return wr(e, n, r, i);
        {
          let s = Le[de++];
          if ((s & 128) > 0) {
            de -= 5;
            return;
          }
          return wr(e, n, r, i, s);
        }
      } else if (t < 8) {
        let s = Le[de++], o = Le[de++];
        if ((s & 128) > 0 || (o & 128) > 0) {
          de -= 6;
          return;
        }
        if (t < 7)
          return wr(e, n, r, i, s, o);
        let a = Le[de++];
        if ((a & 128) > 0) {
          de -= 7;
          return;
        }
        return wr(e, n, r, i, s, o, a);
      } else {
        let s = Le[de++], o = Le[de++], a = Le[de++], l = Le[de++];
        if ((s & 128) > 0 || (o & 128) > 0 || (a & 128) > 0 || (l & 128) > 0) {
          de -= 8;
          return;
        }
        if (t < 10) {
          if (t === 8)
            return wr(e, n, r, i, s, o, a, l);
          {
            let c = Le[de++];
            if ((c & 128) > 0) {
              de -= 9;
              return;
            }
            return wr(e, n, r, i, s, o, a, l, c);
          }
        } else if (t < 12) {
          let c = Le[de++], u = Le[de++];
          if ((c & 128) > 0 || (u & 128) > 0) {
            de -= 10;
            return;
          }
          if (t < 11)
            return wr(e, n, r, i, s, o, a, l, c, u);
          let d = Le[de++];
          if ((d & 128) > 0) {
            de -= 11;
            return;
          }
          return wr(e, n, r, i, s, o, a, l, c, u, d);
        } else {
          let c = Le[de++], u = Le[de++], d = Le[de++], h = Le[de++];
          if ((c & 128) > 0 || (u & 128) > 0 || (d & 128) > 0 || (h & 128) > 0) {
            de -= 12;
            return;
          }
          if (t < 14) {
            if (t === 12)
              return wr(e, n, r, i, s, o, a, l, c, u, d, h);
            {
              let f = Le[de++];
              if ((f & 128) > 0) {
                de -= 13;
                return;
              }
              return wr(e, n, r, i, s, o, a, l, c, u, d, h, f);
            }
          } else {
            let f = Le[de++], y = Le[de++];
            if ((f & 128) > 0 || (y & 128) > 0) {
              de -= 14;
              return;
            }
            if (t < 15)
              return wr(e, n, r, i, s, o, a, l, c, u, d, h, f, y);
            let g = Le[de++];
            if ((g & 128) > 0) {
              de -= 15;
              return;
            }
            return wr(e, n, r, i, s, o, a, l, c, u, d, h, f, y, g);
          }
        }
      }
    }
  }
  function J0e(t) {
    return bt.copyBuffers ? Uint8Array.prototype.slice.call(Le, de, de += t) : Le.subarray(de, de += t);
  }
  let BW = new Float32Array(1), F1 = new Uint8Array(BW.buffer, 0, 4);
  function eve() {
    let t = Le[de++], e = Le[de++], n = (t & 127) >> 2;
    if (n === 31)
      return e || t & 3 ? NaN : t & 128 ? -1 / 0 : 1 / 0;
    if (n === 0) {
      let r = ((t & 3) << 8 | e) / 16777216;
      return t & 128 ? -r : r;
    }
    return F1[3] = t & 128 | (n >> 1) + 56, F1[2] = (t & 7) << 5 | e >> 3, F1[1] = e << 5, F1[0] = 0, BW[0];
  }
  new Array(4096);
  let Gh = class {
    constructor(e, n) {
      this.value = e, this.tag = n;
    }
  };
  cr[0] = (t) => new Date(t);
  cr[1] = (t) => new Date(Math.round(t * 1e3));
  cr[2] = (t) => {
    let e = BigInt(0);
    for (let n = 0, r = t.byteLength; n < r; n++)
      e = BigInt(t[n]) + e << BigInt(8);
    return e;
  };
  cr[3] = (t) => BigInt(-1) - cr[2](t);
  cr[4] = (t) => +(t[1] + "e" + t[0]);
  cr[5] = (t) => t[1] * Math.exp(t[0] * Math.log(2));
  const X$ = (t, e) => {
    t = t - 57344;
    let n = Fn[t];
    n && n.isShared && ((Fn.restoreStructures || (Fn.restoreStructures = []))[t] = n), Fn[t] = e, e.read = U$(e);
  };
  cr[H0e] = (t) => {
    let e = t.length, n = t[1];
    X$(t[0], n);
    let r = {};
    for (let i = 2; i < e; i++) {
      let s = n[i - 2];
      r[Lo(s)] = t[i];
    }
    return r;
  };
  cr[14] = (t) => mr ? mr[0].slice(mr.position0, mr.position0 += t) : new Gh(t, 14);
  cr[15] = (t) => mr ? mr[1].slice(mr.position1, mr.position1 += t) : new Gh(t, 15);
  let tve = {
    Error,
    RegExp
  };
  cr[27] = (t) => (tve[t[0]] || Error)(t[1], t[2]);
  const UW = (t) => {
    if (Le[de++] != 132) {
      let n = new Error("Packed values structure must be followed by a 4 element array");
      throw Le.length < de && (n.incomplete = true), n;
    }
    let e = t();
    if (!e || !e.length) {
      let n = new Error("Packed values structure must be followed by a 4 element array");
      throw n.incomplete = true, n;
    }
    return ds = ds ? e.concat(ds.slice(e.length)) : e, ds.prefixes = t(), ds.suffixes = t(), t();
  };
  UW.handlesRead = true;
  cr[51] = UW;
  cr[HQ] = (t) => {
    if (!ds)
      if (bt.getShared)
        GD();
      else
        return new Gh(t, HQ);
    if (typeof t == "number")
      return ds[16 + (t >= 0 ? 2 * t : -2 * t - 1)];
    let e = new Error("No support for non-integer packed references yet");
    throw t === void 0 && (e.incomplete = true), e;
  };
  cr[28] = (t) => {
    Do || (Do = /* @__PURE__ */ new Map(), Do.id = 0);
    let e = Do.id++, n = de, r = Le[de], i;
    r >> 5 == 4 ? i = [] : i = {};
    let s = {
      target: i
    };
    Do.set(e, s);
    let o = t();
    return s.used ? (Object.getPrototypeOf(i) !== Object.getPrototypeOf(o) && (de = n, i = o, Do.set(e, {
      target: i
    }), o = t()), Object.assign(i, o)) : (s.target = o, o);
  };
  cr[28].handlesRead = true;
  cr[29] = (t) => {
    let e = Do.get(t);
    return e.used = true, e.target;
  };
  cr[258] = (t) => new Set(t);
  (cr[259] = (t) => (bt.mapsAsObjects && (bt.mapsAsObjects = false, h0 = true), t())).handlesRead = true;
  function op(t, e) {
    return typeof t == "string" ? t + e : t instanceof Array ? t.concat(e) : Object.assign({}, t, e);
  }
  function mh() {
    if (!ds)
      if (bt.getShared)
        GD();
      else
        throw new Error("No packed values available");
    return ds;
  }
  const nve = 1399353956;
  F$.push((t, e) => {
    if (t >= 225 && t <= 255)
      return op(mh().prefixes[t - 224], e);
    if (t >= 28704 && t <= 32767)
      return op(mh().prefixes[t - 28672], e);
    if (t >= 1879052288 && t <= 2147483647)
      return op(mh().prefixes[t - 1879048192], e);
    if (t >= 216 && t <= 223)
      return op(e, mh().suffixes[t - 216]);
    if (t >= 27647 && t <= 28671)
      return op(e, mh().suffixes[t - 27639]);
    if (t >= 1811940352 && t <= 1879048191)
      return op(e, mh().suffixes[t - 1811939328]);
    if (t == nve)
      return {
        packedValues: ds,
        structures: Fn.slice(0),
        version: e
      };
    if (t == 55799)
      return e;
  });
  const rve = new Uint8Array(new Uint16Array([
    1
  ]).buffer)[0] == 1, qQ = [
    Uint8Array,
    Uint8ClampedArray,
    Uint16Array,
    Uint32Array,
    typeof BigUint64Array > "u" ? {
      name: "BigUint64Array"
    } : BigUint64Array,
    Int8Array,
    Int16Array,
    Int32Array,
    typeof BigInt64Array > "u" ? {
      name: "BigInt64Array"
    } : BigInt64Array,
    Float32Array,
    Float64Array
  ], ive = [
    64,
    68,
    69,
    70,
    71,
    72,
    77,
    78,
    79,
    85,
    86
  ];
  for (let t = 0; t < qQ.length; t++)
    sve(qQ[t], ive[t]);
  function sve(t, e) {
    let n = "get" + t.name.slice(0, -5), r;
    typeof t == "function" ? r = t.BYTES_PER_ELEMENT : t = null;
    for (let i = 0; i < 2; i++) {
      if (!i && r == 1)
        continue;
      let s = r == 2 ? 1 : r == 4 ? 2 : r == 8 ? 3 : 0;
      cr[i ? e : e - 4] = r == 1 || i == rve ? (o) => {
        if (!t)
          throw new Error("Could not find typed array for code " + e);
        return !bt.copyBuffers && (r === 1 || r === 2 && !(o.byteOffset & 1) || r === 4 && !(o.byteOffset & 3) || r === 8 && !(o.byteOffset & 7)) ? new t(o.buffer, o.byteOffset, o.byteLength >> s) : new t(Uint8Array.prototype.slice.call(o, 0).buffer);
      } : (o) => {
        if (!t)
          throw new Error("Could not find typed array for code " + e);
        let a = new DataView(o.buffer, o.byteOffset, o.byteLength), l = o.length >> s, c = new t(l), u = a[n];
        for (let d = 0; d < l; d++)
          c[d] = u.call(a, d << s, i);
        return c;
      };
    }
  }
  function ove() {
    let t = Np(), e = de + _t();
    for (let r = 2; r < t; r++) {
      let i = Np();
      de += i;
    }
    let n = de;
    return de = e, mr = [
      V$(Np()),
      V$(Np())
    ], mr.position0 = 0, mr.position1 = 0, mr.postBundlePosition = de, de = n, _t();
  }
  function Np() {
    let t = Le[de++] & 31;
    if (t > 23)
      switch (t) {
        case 24:
          t = Le[de++];
          break;
        case 25:
          t = Ni.getUint16(de), de += 2;
          break;
        case 26:
          t = Ni.getUint32(de), de += 4;
          break;
      }
    return t;
  }
  function GD() {
    if (bt.getShared) {
      let t = VW(() => (Le = null, bt.getShared())) || {}, e = t.structures || [];
      bt.sharedVersion = t.version, ds = bt.sharedValues = t.packedValues, Fn === true ? bt.structures = Fn = e : Fn.splice.apply(Fn, [
        0,
        e.length
      ].concat(e));
    }
  }
  function VW(t) {
    let e = Fh, n = de, r = Nb, i = wv, s = jb, o = Do, a = mr, l = new Uint8Array(Le.slice(0, Fh)), c = Fn, u = bt, d = xv, h = t();
    return Fh = e, de = n, Nb = r, wv = i, jb = s, Do = o, mr = a, Le = l, xv = d, Fn = c, bt = u, Ni = new DataView(Le.buffer, Le.byteOffset, Le.byteLength), h;
  }
  function W$() {
    Le = null, Do = null, Fn = null;
  }
  const qD = new Array(147);
  for (let t = 0; t < 256; t++)
    qD[t] = +("1e" + Math.floor(45.15 - t * 0.30103));
  let KD = new zW({
    useRecords: false
  });
  KD.decode;
  KD.decodeMultiple;
  let Ax;
  try {
    Ax = new TextEncoder();
  } catch {
  }
  let Z$, XW;
  const KP = typeof globalThis == "object" && globalThis.Buffer, FO = typeof KP < "u", ET = FO ? KP.allocUnsafeSlow : Uint8Array, KQ = FO ? KP : Uint8Array, JQ = 256, e6 = FO ? 4294967296 : 2144337920;
  let IT, ne, yn, q = 0, bu, fr = null;
  const ave = 61440, lve = /[\u0080-\uFFFF]/, Rs = Symbol("record-id");
  class cve extends zW {
    constructor(e) {
      super(e), this.offset = 0;
      let n, r, i, s, o;
      e = e || {};
      let a = KQ.prototype.utf8Write ? function(R, F, Q) {
        return ne.utf8Write(R, F, Q);
      } : Ax && Ax.encodeInto ? function(R, F) {
        return Ax.encodeInto(R, ne.subarray(F)).written;
      } : false, l = this, c = e.structures || e.saveStructures, u = e.maxSharedStructures;
      if (u == null && (u = c ? 128 : 0), u > 8190)
        throw new Error("Maximum maxSharedStructure is 8190");
      let d = e.sequential;
      d && (u = 0), this.structures || (this.structures = []), this.saveStructures && (this.saveShared = this.saveStructures);
      let h, f, y = e.sharedValues, g;
      if (y) {
        g = /* @__PURE__ */ Object.create(null);
        for (let R = 0, F = y.length; R < F; R++)
          g[y[R]] = R;
      }
      let O = [], S = 0, w = 0;
      this.mapEncode = function(R, F) {
        if (this._keyMap && !this._mapped)
          switch (R.constructor.name) {
            case "Array":
              R = R.map((Q) => this.encodeKeys(Q));
              break;
          }
        return this.encode(R, F);
      }, this.encode = function(R, F) {
        if (ne || (ne = new ET(8192), yn = new DataView(ne.buffer, 0, 8192), q = 0), bu = ne.length - 10, bu - q < 2048 ? (ne = new ET(ne.length), yn = new DataView(ne.buffer, 0, ne.length), bu = ne.length - 10, q = 0) : F === i6 && (q = q + 7 & 2147483640), n = q, l.useSelfDescribedHeader && (yn.setUint32(q, 3654940416), q += 3), o = l.structuredClone ? /* @__PURE__ */ new Map() : null, l.bundleStrings && typeof R != "string" ? (fr = [], fr.size = 1 / 0) : fr = null, r = l.structures, r) {
          if (r.uninitialized) {
            let X = l.getShared() || {};
            l.structures = r = X.structures || [], l.sharedVersion = X.version;
            let Z = l.sharedValues = X.packedValues;
            if (Z) {
              g = {};
              for (let U = 0, H = Z.length; U < H; U++)
                g[Z[U]] = U;
            }
          }
          let Q = r.length;
          if (Q > u && !d && (Q = u), !r.transitions) {
            r.transitions = /* @__PURE__ */ Object.create(null);
            for (let X = 0; X < Q; X++) {
              let Z = r[X];
              if (!Z)
                continue;
              let U, H = r.transitions;
              for (let te = 0, se = Z.length; te < se; te++) {
                H[Rs] === void 0 && (H[Rs] = X);
                let ae = Z[te];
                U = H[ae], U || (U = H[ae] = /* @__PURE__ */ Object.create(null)), H = U;
              }
              H[Rs] = X | 1048576;
            }
          }
          d || (r.nextId = Q);
        }
        if (i && (i = false), s = r || [], f = g, e.pack) {
          let Q = /* @__PURE__ */ new Map();
          if (Q.values = [], Q.encoder = l, Q.maxValues = e.maxPrivatePackedValues || (g ? 16 : 1 / 0), Q.objectMap = g || false, Q.samplingPackedValues = h, Rx(R, Q), Q.values.length > 0) {
            ne[q++] = 216, ne[q++] = 51, vl(4);
            let X = Q.values;
            x(X), vl(0), vl(0), f = Object.create(g || null);
            for (let Z = 0, U = X.length; Z < U; Z++)
              f[X[Z]] = Z;
          }
        }
        IT = F & AT;
        try {
          if (IT)
            return;
          if (x(R), fr && r6(n, x), l.offset = q, o && o.idsToInsert) {
            q += o.idsToInsert.length * 2, q > bu && C(q), l.offset = q;
            let Q = hve(ne.subarray(n, q), o.idsToInsert);
            return o = null, Q;
          }
          return F & i6 ? (ne.start = n, ne.end = q, ne) : ne.subarray(n, q);
        } finally {
          if (r) {
            if (w < 10 && w++, r.length > u && (r.length = u), S > 1e4)
              r.transitions = null, w = 0, S = 0, O.length > 0 && (O = []);
            else if (O.length > 0 && !d) {
              for (let Q = 0, X = O.length; Q < X; Q++)
                O[Q][Rs] = void 0;
              O = [];
            }
          }
          if (i && l.saveShared) {
            l.structures.length > u && (l.structures = l.structures.slice(0, u));
            let Q = ne.subarray(n, q);
            return l.updateSharedData() === false ? l.encode(R) : Q;
          }
          F & fve && (q = n);
        }
      }, this.findCommonStringsToPack = () => (h = /* @__PURE__ */ new Map(), g || (g = /* @__PURE__ */ Object.create(null)), (R) => {
        let F = R && R.threshold || 4, Q = this.pack ? R.maxPrivatePackedValues || 16 : 0;
        y || (y = this.sharedValues = []);
        for (let [X, Z] of h)
          Z.count > F && (g[X] = Q++, y.push(X), i = true);
        for (; this.saveShared && this.updateSharedData() === false; )
          ;
        h = null;
      });
      const x = (R) => {
        q > bu && (ne = C(q));
        var F = typeof R, Q;
        if (F === "string") {
          if (f) {
            let H = f[R];
            if (H >= 0) {
              H < 16 ? ne[q++] = H + 224 : (ne[q++] = 198, H & 1 ? x(15 - H >> 1) : x(H - 16 >> 1));
              return;
            } else if (h && !e.pack) {
              let te = h.get(R);
              te ? te.count++ : h.set(R, {
                count: 1
              });
            }
          }
          let X = R.length;
          if (fr && X >= 4 && X < 1024) {
            if ((fr.size += X) > ave) {
              let te, se = (fr[0] ? fr[0].length * 3 + fr[1].length : 0) + 10;
              q + se > bu && (ne = C(q + se)), ne[q++] = 217, ne[q++] = 223, ne[q++] = 249, ne[q++] = fr.position ? 132 : 130, ne[q++] = 26, te = q - n, q += 4, fr.position && r6(n, x), fr = [
                "",
                ""
              ], fr.size = 0, fr.position = te;
            }
            let H = lve.test(R);
            fr[H ? 0 : 1] += R, ne[q++] = H ? 206 : 207, x(X);
            return;
          }
          let Z;
          X < 32 ? Z = 1 : X < 256 ? Z = 2 : X < 65536 ? Z = 3 : Z = 5;
          let U = X * 3;
          if (q + U > bu && (ne = C(q + U)), X < 64 || !a) {
            let H, te, se, ae = q + Z;
            for (H = 0; H < X; H++)
              te = R.charCodeAt(H), te < 128 ? ne[ae++] = te : te < 2048 ? (ne[ae++] = te >> 6 | 192, ne[ae++] = te & 63 | 128) : (te & 64512) === 55296 && ((se = R.charCodeAt(H + 1)) & 64512) === 56320 ? (te = 65536 + ((te & 1023) << 10) + (se & 1023), H++, ne[ae++] = te >> 18 | 240, ne[ae++] = te >> 12 & 63 | 128, ne[ae++] = te >> 6 & 63 | 128, ne[ae++] = te & 63 | 128) : (ne[ae++] = te >> 12 | 224, ne[ae++] = te >> 6 & 63 | 128, ne[ae++] = te & 63 | 128);
            Q = ae - q - Z;
          } else
            Q = a(R, q + Z, U);
          Q < 24 ? ne[q++] = 96 | Q : Q < 256 ? (Z < 2 && ne.copyWithin(q + 2, q + 1, q + 1 + Q), ne[q++] = 120, ne[q++] = Q) : Q < 65536 ? (Z < 3 && ne.copyWithin(q + 3, q + 2, q + 2 + Q), ne[q++] = 121, ne[q++] = Q >> 8, ne[q++] = Q & 255) : (Z < 5 && ne.copyWithin(q + 5, q + 3, q + 3 + Q), ne[q++] = 122, yn.setUint32(q, Q), q += 4), q += Q;
        } else if (F === "number")
          if (!this.alwaysUseFloat && R >>> 0 === R)
            R < 24 ? ne[q++] = R : R < 256 ? (ne[q++] = 24, ne[q++] = R) : R < 65536 ? (ne[q++] = 25, ne[q++] = R >> 8, ne[q++] = R & 255) : (ne[q++] = 26, yn.setUint32(q, R), q += 4);
          else if (!this.alwaysUseFloat && R >> 0 === R)
            R >= -24 ? ne[q++] = 31 - R : R >= -256 ? (ne[q++] = 56, ne[q++] = ~R) : R >= -65536 ? (ne[q++] = 57, yn.setUint16(q, ~R), q += 2) : (ne[q++] = 58, yn.setUint32(q, ~R), q += 4);
          else {
            let X;
            if ((X = this.useFloat32) > 0 && R < 4294967296 && R >= -2147483648) {
              ne[q++] = 250, yn.setFloat32(q, R);
              let Z;
              if (X < 4 || (Z = R * qD[(ne[q] & 127) << 1 | ne[q + 1] >> 7]) >> 0 === Z) {
                q += 4;
                return;
              } else
                q--;
            }
            ne[q++] = 251, yn.setFloat64(q, R), q += 8;
          }
        else if (F === "object")
          if (!R)
            ne[q++] = 246;
          else {
            if (o) {
              let Z = o.get(R);
              if (Z) {
                if (ne[q++] = 216, ne[q++] = 29, ne[q++] = 25, !Z.references) {
                  let U = o.idsToInsert || (o.idsToInsert = []);
                  Z.references = [], U.push(Z);
                }
                Z.references.push(q - n), q += 2;
                return;
              } else
                o.set(R, {
                  offset: q - n
                });
            }
            let X = R.constructor;
            if (X === Object)
              P(R);
            else if (X === Array) {
              Q = R.length, Q < 24 ? ne[q++] = 128 | Q : vl(Q);
              for (let Z = 0; Z < Q; Z++)
                x(R[Z]);
            } else if (X === Map)
              if ((this.mapsAsObjects ? this.useTag259ForMaps !== false : this.useTag259ForMaps) && (ne[q++] = 217, ne[q++] = 1, ne[q++] = 3), Q = R.size, Q < 24 ? ne[q++] = 160 | Q : Q < 256 ? (ne[q++] = 184, ne[q++] = Q) : Q < 65536 ? (ne[q++] = 185, ne[q++] = Q >> 8, ne[q++] = Q & 255) : (ne[q++] = 186, yn.setUint32(q, Q), q += 4), l.keyMap)
                for (let [Z, U] of R)
                  x(l.encodeKey(Z)), x(U);
              else
                for (let [Z, U] of R)
                  x(Z), x(U);
            else {
              for (let Z = 0, U = Z$.length; Z < U; Z++) {
                let H = XW[Z];
                if (R instanceof H) {
                  let te = Z$[Z], se = te.tag;
                  se == null && (se = te.getTag && te.getTag.call(this, R)), se < 24 ? ne[q++] = 192 | se : se < 256 ? (ne[q++] = 216, ne[q++] = se) : se < 65536 ? (ne[q++] = 217, ne[q++] = se >> 8, ne[q++] = se & 255) : se > -1 && (ne[q++] = 218, yn.setUint32(q, se), q += 4), te.encode.call(this, R, x, C);
                  return;
                }
              }
              if (R[Symbol.iterator]) {
                if (IT) {
                  let Z = new Error("Iterable should be serialized as iterator");
                  throw Z.iteratorNotHandled = true, Z;
                }
                ne[q++] = 159;
                for (let Z of R)
                  x(Z);
                ne[q++] = 255;
                return;
              }
              if (R[Symbol.asyncIterator] || $T(R)) {
                let Z = new Error("Iterable/blob should be serialized as iterator");
                throw Z.iteratorNotHandled = true, Z;
              }
              if (this.useToJSON && R.toJSON) {
                const Z = R.toJSON();
                if (Z !== R)
                  return x(Z);
              }
              P(R);
            }
          }
        else if (F === "boolean")
          ne[q++] = R ? 245 : 244;
        else if (F === "bigint") {
          if (R < BigInt(1) << BigInt(64) && R >= 0)
            ne[q++] = 27, yn.setBigUint64(q, R);
          else if (R > -(BigInt(1) << BigInt(64)) && R < 0)
            ne[q++] = 59, yn.setBigUint64(q, -R - BigInt(1));
          else if (this.largeBigIntToFloat)
            ne[q++] = 251, yn.setFloat64(q, Number(R));
          else
            throw new RangeError(R + " was too large to fit in CBOR 64-bit integer format, set largeBigIntToFloat to convert to float-64");
          q += 8;
        } else if (F === "undefined")
          ne[q++] = 247;
        else
          throw new Error("Unknown type: " + F);
      }, P = this.useRecords === false ? this.variableMapSize ? (R) => {
        let F = Object.keys(R), Q = Object.values(R), X = F.length;
        if (X < 24 ? ne[q++] = 160 | X : X < 256 ? (ne[q++] = 184, ne[q++] = X) : X < 65536 ? (ne[q++] = 185, ne[q++] = X >> 8, ne[q++] = X & 255) : (ne[q++] = 186, yn.setUint32(q, X), q += 4), l.keyMap)
          for (let Z = 0; Z < X; Z++)
            x(l.encodeKey(F[Z])), x(Q[Z]);
        else
          for (let Z = 0; Z < X; Z++)
            x(F[Z]), x(Q[Z]);
      } : (R) => {
        ne[q++] = 185;
        let F = q - n;
        q += 2;
        let Q = 0;
        if (l.keyMap)
          for (let X in R)
            (typeof R.hasOwnProperty != "function" || R.hasOwnProperty(X)) && (x(l.encodeKey(X)), x(R[X]), Q++);
        else
          for (let X in R)
            (typeof R.hasOwnProperty != "function" || R.hasOwnProperty(X)) && (x(X), x(R[X]), Q++);
        ne[F++ + n] = Q >> 8, ne[F + n] = Q & 255;
      } : (R, F) => {
        let Q, X = s.transitions || (s.transitions = /* @__PURE__ */ Object.create(null)), Z = 0, U = 0, H, te;
        if (this.keyMap) {
          te = Object.keys(R).map((ae) => this.encodeKey(ae)), U = te.length;
          for (let ae = 0; ae < U; ae++) {
            let _e3 = te[ae];
            Q = X[_e3], Q || (Q = X[_e3] = /* @__PURE__ */ Object.create(null), Z++), X = Q;
          }
        } else
          for (let ae in R)
            (typeof R.hasOwnProperty != "function" || R.hasOwnProperty(ae)) && (Q = X[ae], Q || (X[Rs] & 1048576 && (H = X[Rs] & 65535), Q = X[ae] = /* @__PURE__ */ Object.create(null), Z++), X = Q, U++);
        let se = X[Rs];
        if (se !== void 0)
          se &= 65535, ne[q++] = 217, ne[q++] = se >> 8 | 224, ne[q++] = se & 255;
        else if (te || (te = X.__keys__ || (X.__keys__ = Object.keys(R))), H === void 0 ? (se = s.nextId++, se || (se = 0, s.nextId = 1), se >= JQ && (s.nextId = (se = u) + 1)) : se = H, s[se] = te, se < u) {
          ne[q++] = 217, ne[q++] = se >> 8 | 224, ne[q++] = se & 255, X = s.transitions;
          for (let ae = 0; ae < U; ae++)
            (X[Rs] === void 0 || X[Rs] & 1048576) && (X[Rs] = se), X = X[te[ae]];
          X[Rs] = se | 1048576, i = true;
        } else {
          if (X[Rs] = se, yn.setUint32(q, 3655335680), q += 3, Z && (S += w * Z), O.length >= JQ - u && (O.shift()[Rs] = void 0), O.push(X), vl(U + 2), x(57344 + se), x(te), F)
            return;
          for (let ae in R)
            (typeof R.hasOwnProperty != "function" || R.hasOwnProperty(ae)) && x(R[ae]);
          return;
        }
        if (U < 24 ? ne[q++] = 128 | U : vl(U), !F)
          for (let ae in R)
            (typeof R.hasOwnProperty != "function" || R.hasOwnProperty(ae)) && x(R[ae]);
      }, C = (R) => {
        let F;
        if (R > 16777216) {
          if (R - n > e6)
            throw new Error("Encoded buffer would be larger than maximum buffer size");
          F = Math.min(e6, Math.round(Math.max((R - n) * (R > 67108864 ? 1.25 : 2), 4194304) / 4096) * 4096);
        } else
          F = (Math.max(R - n << 2, ne.length - 1) >> 12) + 1 << 12;
        let Q = new ET(F);
        return yn = new DataView(Q.buffer, 0, F), ne.copy ? ne.copy(Q, 0, n, R) : Q.set(ne.slice(n, R)), q -= n, n = 0, bu = Q.length - 10, ne = Q;
      };
      let _ = 100, T = 1e3;
      this.encodeAsIterable = function(R, F) {
        return z(R, F, $);
      }, this.encodeAsAsyncIterable = function(R, F) {
        return z(R, F, M);
      };
      function* $(R, F, Q) {
        let X = R.constructor;
        if (X === Object) {
          let Z = l.useRecords !== false;
          Z ? P(R, true) : t6(Object.keys(R).length, 160);
          for (let U in R) {
            let H = R[U];
            Z || x(U), H && typeof H == "object" ? F[U] ? yield* $(H, F[U]) : yield* N(H, F, U) : x(H);
          }
        } else if (X === Array) {
          let Z = R.length;
          vl(Z);
          for (let U = 0; U < Z; U++) {
            let H = R[U];
            H && (typeof H == "object" || q - n > _) ? F.element ? yield* $(H, F.element) : yield* N(H, F, "element") : x(H);
          }
        } else if (R[Symbol.iterator]) {
          ne[q++] = 159;
          for (let Z of R)
            Z && (typeof Z == "object" || q - n > _) ? F.element ? yield* $(Z, F.element) : yield* N(Z, F, "element") : x(Z);
          ne[q++] = 255;
        } else
          $T(R) ? (t6(R.size, 64), yield ne.subarray(n, q), yield R, L()) : R[Symbol.asyncIterator] ? (ne[q++] = 159, yield ne.subarray(n, q), yield R, L(), ne[q++] = 255) : x(R);
        Q && q > n ? yield ne.subarray(n, q) : q - n > _ && (yield ne.subarray(n, q), L());
      }
      function* N(R, F, Q) {
        let X = q - n;
        try {
          x(R), q - n > _ && (yield ne.subarray(n, q), L());
        } catch (Z) {
          if (Z.iteratorNotHandled)
            F[Q] = {}, q = n + X, yield* $.call(this, R, F[Q]);
          else
            throw Z;
        }
      }
      function L() {
        _ = T, l.encode(null, AT);
      }
      function z(R, F, Q) {
        return F && F.chunkThreshold ? _ = T = F.chunkThreshold : _ = 100, R && typeof R == "object" ? (l.encode(null, AT), Q(R, l.iterateProperties || (l.iterateProperties = {}), true)) : [
          l.encode(R)
        ];
      }
      async function* M(R, F) {
        for (let Q of $(R, F, true)) {
          let X = Q.constructor;
          if (X === KQ || X === Uint8Array)
            yield Q;
          else if ($T(Q)) {
            let Z = Q.stream().getReader(), U;
            for (; !(U = await Z.read()).done; )
              yield U.value;
          } else if (Q[Symbol.asyncIterator])
            for await (let Z of Q)
              L(), Z ? yield* M(Z, F.async || (F.async = {})) : yield l.encode(Z);
          else
            yield Q;
        }
      }
    }
    useBuffer(e) {
      ne = e, yn = new DataView(ne.buffer, ne.byteOffset, ne.byteLength), q = 0;
    }
    clearSharedData() {
      this.structures && (this.structures = []), this.sharedValues && (this.sharedValues = void 0);
    }
    updateSharedData() {
      let e = this.sharedVersion || 0;
      this.sharedVersion = e + 1;
      let n = this.structures.slice(0), r = new WW(n, this.sharedValues, this.sharedVersion), i = this.saveShared(r, (s) => (s && s.version || 0) == e);
      return i === false ? (r = this.getShared() || {}, this.structures = r.structures || [], this.sharedValues = r.packedValues, this.sharedVersion = r.version, this.structures.nextId = this.structures.length) : n.forEach((s, o) => this.structures[o] = s), i;
    }
  }
  function t6(t, e) {
    t < 24 ? ne[q++] = e | t : t < 256 ? (ne[q++] = e | 24, ne[q++] = t) : t < 65536 ? (ne[q++] = e | 25, ne[q++] = t >> 8, ne[q++] = t & 255) : (ne[q++] = e | 26, yn.setUint32(q, t), q += 4);
  }
  class WW {
    constructor(e, n, r) {
      this.structures = e, this.packedValues = n, this.version = r;
    }
  }
  function vl(t) {
    t < 24 ? ne[q++] = 128 | t : t < 256 ? (ne[q++] = 152, ne[q++] = t) : t < 65536 ? (ne[q++] = 153, ne[q++] = t >> 8, ne[q++] = t & 255) : (ne[q++] = 154, yn.setUint32(q, t), q += 4);
  }
  const uve = typeof Blob > "u" ? function() {
  } : Blob;
  function $T(t) {
    if (t instanceof uve)
      return true;
    let e = t[Symbol.toStringTag];
    return e === "Blob" || e === "File";
  }
  function Rx(t, e) {
    switch (typeof t) {
      case "string":
        if (t.length > 3) {
          if (e.objectMap[t] > -1 || e.values.length >= e.maxValues)
            return;
          let r = e.get(t);
          if (r)
            ++r.count == 2 && e.values.push(t);
          else if (e.set(t, {
            count: 1
          }), e.samplingPackedValues) {
            let i = e.samplingPackedValues.get(t);
            i ? i.count++ : e.samplingPackedValues.set(t, {
              count: 1
            });
          }
        }
        break;
      case "object":
        if (t)
          if (t instanceof Array)
            for (let r = 0, i = t.length; r < i; r++)
              Rx(t[r], e);
          else {
            let r = !e.encoder.useRecords;
            for (var n in t)
              t.hasOwnProperty(n) && (r && Rx(n, e), Rx(t[n], e));
          }
        break;
      case "function":
        console.log(t);
    }
  }
  const dve = new Uint8Array(new Uint16Array([
    1
  ]).buffer)[0] == 1;
  XW = [
    Date,
    Set,
    Error,
    RegExp,
    Gh,
    ArrayBuffer,
    Uint8Array,
    Uint8ClampedArray,
    Uint16Array,
    Uint32Array,
    typeof BigUint64Array > "u" ? function() {
    } : BigUint64Array,
    Int8Array,
    Int16Array,
    Int32Array,
    typeof BigInt64Array > "u" ? function() {
    } : BigInt64Array,
    Float32Array,
    Float64Array,
    WW
  ];
  Z$ = [
    {
      tag: 1,
      encode(t, e) {
        let n = t.getTime() / 1e3;
        (this.useTimestamp32 || t.getMilliseconds() === 0) && n >= 0 && n < 4294967296 ? (ne[q++] = 26, yn.setUint32(q, n), q += 4) : (ne[q++] = 251, yn.setFloat64(q, n), q += 8);
      }
    },
    {
      tag: 258,
      encode(t, e) {
        let n = Array.from(t);
        e(n);
      }
    },
    {
      tag: 27,
      encode(t, e) {
        e([
          t.name,
          t.message
        ]);
      }
    },
    {
      tag: 27,
      encode(t, e) {
        e([
          "RegExp",
          t.source,
          t.flags
        ]);
      }
    },
    {
      getTag(t) {
        return t.tag;
      },
      encode(t, e) {
        e(t.value);
      }
    },
    {
      encode(t, e, n) {
        n6(t, n);
      }
    },
    {
      getTag(t) {
        if (t.constructor === Uint8Array && (this.tagUint8Array || FO && this.tagUint8Array !== false))
          return 64;
      },
      encode(t, e, n) {
        n6(t, n);
      }
    },
    rl(68, 1),
    rl(69, 2),
    rl(70, 4),
    rl(71, 8),
    rl(72, 1),
    rl(77, 2),
    rl(78, 4),
    rl(79, 8),
    rl(85, 4),
    rl(86, 8),
    {
      encode(t, e) {
        let n = t.packedValues || [], r = t.structures || [];
        if (n.values.length > 0) {
          ne[q++] = 216, ne[q++] = 51, vl(4);
          let i = n.values;
          e(i), vl(0), vl(0), packedObjectMap = Object.create(sharedPackedObjectMap || null);
          for (let s = 0, o = i.length; s < o; s++)
            packedObjectMap[i[s]] = s;
        }
        if (r) {
          yn.setUint32(q, 3655335424), q += 3;
          let i = r.slice(0);
          i.unshift(57344), i.push(new Gh(t.version, 1399353956)), e(i);
        } else
          e(new Gh(t.version, 1399353956));
      }
    }
  ];
  function rl(t, e) {
    return !dve && e > 1 && (t -= 4), {
      tag: t,
      encode: function(n, r) {
        let i = n.byteLength, s = n.byteOffset || 0, o = n.buffer || n;
        r(FO ? KP.from(o, s, i) : new Uint8Array(o, s, i));
      }
    };
  }
  function n6(t, e) {
    let n = t.byteLength;
    n < 24 ? ne[q++] = 64 + n : n < 256 ? (ne[q++] = 88, ne[q++] = n) : n < 65536 ? (ne[q++] = 89, ne[q++] = n >> 8, ne[q++] = n & 255) : (ne[q++] = 90, yn.setUint32(q, n), q += 4), q + n >= ne.length && e(q + n), ne.set(t.buffer ? t : new Uint8Array(t), q), q += n;
  }
  function hve(t, e) {
    let n, r = e.length * 2, i = t.length - r;
    e.sort((s, o) => s.offset > o.offset ? 1 : -1);
    for (let s = 0; s < e.length; s++) {
      let o = e[s];
      o.id = s;
      for (let a of o.references)
        t[a++] = s >> 8, t[a] = s & 255;
    }
    for (; n = e.pop(); ) {
      let s = n.offset;
      t.copyWithin(s + r, s, i), r -= 2;
      let o = s + r;
      t[o++] = 216, t[o++] = 28, i = s;
    }
    return t;
  }
  function r6(t, e) {
    yn.setUint32(fr.position + t, q - fr.position - t + 1);
    let n = fr;
    fr = null, e(n[0]), e(n[1]);
  }
  let JD = new cve({
    useRecords: false
  });
  JD.encode;
  JD.encodeAsIterable;
  JD.encodeAsAsyncIterable;
  const i6 = 512, fve = 1024, AT = 2048;
  var pve = {
    exports: {}
  };
  (function(t) {
    (function(e, n) {
      var r = {};
      n(r);
      var i = r.default;
      for (var s in r)
        i[s] = r[s];
      t.exports = i;
    })(w0e, function(e) {
      e.__esModule = true, e.digestLength = 32, e.blockSize = 64;
      var n = new Uint32Array([
        1116352408,
        1899447441,
        3049323471,
        3921009573,
        961987163,
        1508970993,
        2453635748,
        2870763221,
        3624381080,
        310598401,
        607225278,
        1426881987,
        1925078388,
        2162078206,
        2614888103,
        3248222580,
        3835390401,
        4022224774,
        264347078,
        604807628,
        770255983,
        1249150122,
        1555081692,
        1996064986,
        2554220882,
        2821834349,
        2952996808,
        3210313671,
        3336571891,
        3584528711,
        113926993,
        338241895,
        666307205,
        773529912,
        1294757372,
        1396182291,
        1695183700,
        1986661051,
        2177026350,
        2456956037,
        2730485921,
        2820302411,
        3259730800,
        3345764771,
        3516065817,
        3600352804,
        4094571909,
        275423344,
        430227734,
        506948616,
        659060556,
        883997877,
        958139571,
        1322822218,
        1537002063,
        1747873779,
        1955562222,
        2024104815,
        2227730452,
        2361852424,
        2428436474,
        2756734187,
        3204031479,
        3329325298
      ]);
      function r(h, f, y, g, O) {
        for (var S, w, x, P, C, _, T, $, N, L, z, M, R; O >= 64; ) {
          for (S = f[0], w = f[1], x = f[2], P = f[3], C = f[4], _ = f[5], T = f[6], $ = f[7], L = 0; L < 16; L++)
            z = g + L * 4, h[L] = (y[z] & 255) << 24 | (y[z + 1] & 255) << 16 | (y[z + 2] & 255) << 8 | y[z + 3] & 255;
          for (L = 16; L < 64; L++)
            N = h[L - 2], M = (N >>> 17 | N << 15) ^ (N >>> 19 | N << 13) ^ N >>> 10, N = h[L - 15], R = (N >>> 7 | N << 25) ^ (N >>> 18 | N << 14) ^ N >>> 3, h[L] = (M + h[L - 7] | 0) + (R + h[L - 16] | 0);
          for (L = 0; L < 64; L++)
            M = (((C >>> 6 | C << 26) ^ (C >>> 11 | C << 21) ^ (C >>> 25 | C << 7)) + (C & _ ^ ~C & T) | 0) + ($ + (n[L] + h[L] | 0) | 0) | 0, R = ((S >>> 2 | S << 30) ^ (S >>> 13 | S << 19) ^ (S >>> 22 | S << 10)) + (S & w ^ S & x ^ w & x) | 0, $ = T, T = _, _ = C, C = P + M | 0, P = x, x = w, w = S, S = M + R | 0;
          f[0] += S, f[1] += w, f[2] += x, f[3] += P, f[4] += C, f[5] += _, f[6] += T, f[7] += $, g += 64, O -= 64;
        }
        return g;
      }
      var i = function() {
        function h() {
          this.digestLength = e.digestLength, this.blockSize = e.blockSize, this.state = new Int32Array(8), this.temp = new Int32Array(64), this.buffer = new Uint8Array(128), this.bufferLength = 0, this.bytesHashed = 0, this.finished = false, this.reset();
        }
        return h.prototype.reset = function() {
          return this.state[0] = 1779033703, this.state[1] = 3144134277, this.state[2] = 1013904242, this.state[3] = 2773480762, this.state[4] = 1359893119, this.state[5] = 2600822924, this.state[6] = 528734635, this.state[7] = 1541459225, this.bufferLength = 0, this.bytesHashed = 0, this.finished = false, this;
        }, h.prototype.clean = function() {
          for (var f = 0; f < this.buffer.length; f++)
            this.buffer[f] = 0;
          for (var f = 0; f < this.temp.length; f++)
            this.temp[f] = 0;
          this.reset();
        }, h.prototype.update = function(f, y) {
          if (y === void 0 && (y = f.length), this.finished)
            throw new Error("SHA256: can't update because hash was finished.");
          var g = 0;
          if (this.bytesHashed += y, this.bufferLength > 0) {
            for (; this.bufferLength < 64 && y > 0; )
              this.buffer[this.bufferLength++] = f[g++], y--;
            this.bufferLength === 64 && (r(this.temp, this.state, this.buffer, 0, 64), this.bufferLength = 0);
          }
          for (y >= 64 && (g = r(this.temp, this.state, f, g, y), y %= 64); y > 0; )
            this.buffer[this.bufferLength++] = f[g++], y--;
          return this;
        }, h.prototype.finish = function(f) {
          if (!this.finished) {
            var y = this.bytesHashed, g = this.bufferLength, O = y / 536870912 | 0, S = y << 3, w = y % 64 < 56 ? 64 : 128;
            this.buffer[g] = 128;
            for (var x = g + 1; x < w - 8; x++)
              this.buffer[x] = 0;
            this.buffer[w - 8] = O >>> 24 & 255, this.buffer[w - 7] = O >>> 16 & 255, this.buffer[w - 6] = O >>> 8 & 255, this.buffer[w - 5] = O >>> 0 & 255, this.buffer[w - 4] = S >>> 24 & 255, this.buffer[w - 3] = S >>> 16 & 255, this.buffer[w - 2] = S >>> 8 & 255, this.buffer[w - 1] = S >>> 0 & 255, r(this.temp, this.state, this.buffer, 0, w), this.finished = true;
          }
          for (var x = 0; x < 8; x++)
            f[x * 4 + 0] = this.state[x] >>> 24 & 255, f[x * 4 + 1] = this.state[x] >>> 16 & 255, f[x * 4 + 2] = this.state[x] >>> 8 & 255, f[x * 4 + 3] = this.state[x] >>> 0 & 255;
          return this;
        }, h.prototype.digest = function() {
          var f = new Uint8Array(this.digestLength);
          return this.finish(f), f;
        }, h.prototype._saveState = function(f) {
          for (var y = 0; y < this.state.length; y++)
            f[y] = this.state[y];
        }, h.prototype._restoreState = function(f, y) {
          for (var g = 0; g < this.state.length; g++)
            this.state[g] = f[g];
          this.bytesHashed = y, this.finished = false, this.bufferLength = 0;
        }, h;
      }();
      e.Hash = i;
      var s = function() {
        function h(f) {
          this.inner = new i(), this.outer = new i(), this.blockSize = this.inner.blockSize, this.digestLength = this.inner.digestLength;
          var y = new Uint8Array(this.blockSize);
          if (f.length > this.blockSize)
            new i().update(f).finish(y).clean();
          else
            for (var g = 0; g < f.length; g++)
              y[g] = f[g];
          for (var g = 0; g < y.length; g++)
            y[g] ^= 54;
          this.inner.update(y);
          for (var g = 0; g < y.length; g++)
            y[g] ^= 106;
          this.outer.update(y), this.istate = new Uint32Array(8), this.ostate = new Uint32Array(8), this.inner._saveState(this.istate), this.outer._saveState(this.ostate);
          for (var g = 0; g < y.length; g++)
            y[g] = 0;
        }
        return h.prototype.reset = function() {
          return this.inner._restoreState(this.istate, this.inner.blockSize), this.outer._restoreState(this.ostate, this.outer.blockSize), this;
        }, h.prototype.clean = function() {
          for (var f = 0; f < this.istate.length; f++)
            this.ostate[f] = this.istate[f] = 0;
          this.inner.clean(), this.outer.clean();
        }, h.prototype.update = function(f) {
          return this.inner.update(f), this;
        }, h.prototype.finish = function(f) {
          return this.outer.finished ? this.outer.finish(f) : (this.inner.finish(f), this.outer.update(f, this.digestLength).finish(f)), this;
        }, h.prototype.digest = function() {
          var f = new Uint8Array(this.digestLength);
          return this.finish(f), f;
        }, h;
      }();
      e.HMAC = s;
      function o(h) {
        var f = new i().update(h), y = f.digest();
        return f.clean(), y;
      }
      e.hash = o, e.default = o;
      function a(h, f) {
        var y = new s(h).update(f), g = y.digest();
        return y.clean(), g;
      }
      e.hmac = a;
      function l(h, f, y, g) {
        var O = g[0];
        if (O === 0)
          throw new Error("hkdf: cannot expand more");
        f.reset(), O > 1 && f.update(h), y && f.update(y), f.update(g), f.finish(h), g[0]++;
      }
      var c = new Uint8Array(e.digestLength);
      function u(h, f, y, g) {
        f === void 0 && (f = c), g === void 0 && (g = 32);
        for (var O = new Uint8Array([
          1
        ]), S = a(f, h), w = new s(S), x = new Uint8Array(w.digestLength), P = x.length, C = new Uint8Array(g), _ = 0; _ < g; _++)
          P === x.length && (l(x, w, y, O), P = 0), C[_] = x[P++];
        return w.clean(), x.fill(0), O.fill(0), C;
      }
      e.hkdf = u;
      function d(h, f, y, g) {
        for (var O = new s(h), S = O.digestLength, w = new Uint8Array(4), x = new Uint8Array(S), P = new Uint8Array(S), C = new Uint8Array(g), _ = 0; _ * S < g; _++) {
          var T = _ + 1;
          w[0] = T >>> 24 & 255, w[1] = T >>> 16 & 255, w[2] = T >>> 8 & 255, w[3] = T >>> 0 & 255, O.reset(), O.update(f), O.update(w), O.finish(P);
          for (var $ = 0; $ < S; $++)
            x[$] = P[$];
          for (var $ = 2; $ <= y; $++) {
            O.reset(), O.update(P).finish(P);
            for (var N = 0; N < S; N++)
              x[N] ^= P[N];
          }
          for (var $ = 0; $ < S && _ * S + $ < g; $++)
            C[_ * S + $] = x[$];
        }
        for (var _ = 0; _ < S; _++)
          x[_] = P[_] = 0;
        for (var _ = 0; _ < 4; _++)
          w[_] = 0;
        return O.clean(), C;
      }
      e.pbkdf2 = d;
    });
  })(pve);
  C0e("automerge-repo:collectionsync");
  const gve = (t) => {
    const [e, n] = b.useState({}), r = Xl(), i = b.useMemo(() => (t == null ? void 0 : t.map((o) => {
      if (W0e(o)) {
        const { documentId: a } = jW(o);
        return a;
      } else
        return o;
    })) ?? [], [
      t
    ]), s = b.useRef([]);
    return b.useEffect(() => {
      const o = {}, a = (h, f) => {
        f && n((y) => ({
          ...y,
          [h]: f
        }));
      }, l = (h) => {
        const f = h.documentId, y = {
          change: ({ doc: g }) => a(f, g),
          delete: () => c(f)
        };
        h.on("change", y.change), h.on("delete", y.delete), o[f] = y;
      }, c = (h) => {
        n((f) => {
          const { [h]: y, ...g } = f;
          return g;
        });
      }, u = (h) => {
        const f = r.find(h);
        f.docSync() ? (a(h, f.docSync()), l(f)) : f.doc().then((y) => {
          a(h, y), l(f);
        }).catch((y) => {
          console.error(`Error loading document ${h} in useDocuments: `, y);
        });
      }, d = () => {
        Object.entries(o).forEach(([h, f]) => {
          const y = r.find(h);
          y.off("change", f.change), y.off("delete", f.delete);
        });
      };
      if (!i)
        return d;
      for (const h of i) {
        const f = r.find(h);
        s.current.includes(h) ? l(f) : u(h);
      }
      return s.current.filter((h) => !i.includes(h)).forEach(c), s.current = i, d;
    }, [
      i,
      r
    ]), e;
  };
  function JP(t) {
    const e = Xl();
    return t ? e.find(t) : void 0;
  }
  var RT = $e, mve = function(t) {
    return typeof t == "function";
  }, yve = function(t) {
    var e = RT.useState(t), n = e[0], r = e[1], i = RT.useRef(n), s = RT.useCallback(function(o) {
      i.current = mve(o) ? o(i.current) : o, r(i.current);
    }, []);
    return [
      n,
      s,
      i
    ];
  }, vve = yve;
  const H$ = GP(vve), Y$ = new T0e(), Ove = ({ handle: t, localUserId: e, offlineTimeout: n = 3e4, getTime: r = () => (/* @__PURE__ */ new Date()).getTime() }) => {
    const [i, s, o] = H$({}), [a, l, c] = H$({});
    return b.useEffect(() => {
      const u = (f) => {
        const [y, g] = f.message;
        y !== e && (c.current[y] || Y$.emit("new_peer", f), s({
          ...o.current,
          [y]: g
        }), l({
          ...c.current,
          [y]: r()
        }));
      }, d = () => {
        const f = o.current, y = c.current, g = r();
        for (const O in y)
          g - y[O] > n && (delete f[O], delete y[O]);
        s(f), l(y);
      };
      t.on("ephemeral-message", u);
      const h = setInterval(d, n);
      return () => {
        t.removeListener("ephemeral-message", u), clearInterval(h);
      };
    }, [
      t,
      e,
      n,
      r
    ]), [
      i,
      a
    ];
  }, Sve = ({ handle: t, userId: e, initialState: n, heartbeatTime: r = 15e3 }) => {
    const [i, s, o] = H$(n), a = (l) => {
      const c = typeof l == "function" ? l(o.current) : l;
      s(c), t.broadcast([
        e,
        c
      ]);
    };
    return b.useEffect(() => {
      if (!e)
        return;
      const l = () => void t.broadcast([
        e,
        o.current
      ]);
      l();
      const c = setInterval(l, r);
      return () => void clearInterval(c);
    }, [
      t,
      e,
      r
    ]), b.useEffect(() => {
      let l;
      const c = Y$.on("new_peer", () => {
        l = setTimeout(() => t.broadcast([
          e,
          o.current
        ]), 500);
      });
      return () => {
        c.off("new_peer"), l && clearTimeout(l);
      };
    }, [
      t,
      e,
      Y$
    ]), [
      i,
      a
    ];
  }, wve = (t) => {
    const [e] = Ba(t);
    return b.useMemo(() => {
      if (!e || !e.data || !e.type)
        return;
      const n = new Blob([
        e.data
      ], {
        type: e.type
      });
      return URL.createObjectURL(n);
    }, [
      e == null ? void 0 : e.data,
      e == null ? void 0 : e.type
    ]);
  }, xve = async (t, e) => {
    const n = new FileReader(), r = t.create(), i = new Promise((s) => {
      n.onload = (o) => {
        r.change((a) => {
          a.type = e.type, a.data = new Uint8Array(o.target.result);
        }), s(true);
      };
    });
    return n.readAsArrayBuffer(e), await i, r.url;
  };
  function MT(t, e = navigator.language) {
    const n = typeof t == "number" ? t : t.getTime(), r = Math.round((n - Date.now()) / 1e3), i = [
      60,
      3600,
      86400,
      86400 * 7,
      86400 * 30,
      86400 * 365,
      1 / 0
    ], s = [
      "second",
      "minute",
      "hour",
      "day",
      "week",
      "month",
      "year"
    ], o = i.findIndex((c) => c > Math.abs(r)), a = o ? i[o - 1] : 1;
    return new Intl.RelativeTimeFormat(e, {
      numeric: "auto"
    }).format(Math.floor(r / a), s[o]);
  }
  function bve(t, e) {
    if (t.length !== e.length)
      return false;
    for (let n = 0; n < t.length; n++)
      if (t[n] !== e[n])
        return false;
    return true;
  }
  const s6 = async (t, e, n) => {
    if ("showSaveFilePicker" in window && (() => {
      try {
        return window.self === window.top;
      } catch {
        return false;
      }
    })())
      try {
        const a = await (await showSaveFilePicker({
          suggestedName: e,
          types: n
        })).createWritable();
        await a.write(t), await a.close();
        return;
      } catch (o) {
        if (o.name === "AbortError")
          return;
      }
    const i = URL.createObjectURL(t), s = document.createElement("a");
    s.href = i, s.download = e, s.style.display = "none", document.body.append(s), s.click(), setTimeout(() => {
      URL.revokeObjectURL(i), s.remove();
    }, 1e3);
  };
  var Qb = {
    exports: {}
  };
  Qb.exports;
  (function(t, e) {
    (function() {
      var n, r = "4.17.21", i = 200, s = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", o = "Expected a function", a = "Invalid `variable` option passed into `_.template`", l = "__lodash_hash_undefined__", c = 500, u = "__lodash_placeholder__", d = 1, h = 2, f = 4, y = 1, g = 2, O = 1, S = 2, w = 4, x = 8, P = 16, C = 32, _ = 64, T = 128, $ = 256, N = 512, L = 30, z = "...", M = 800, R = 16, F = 1, Q = 2, X = 3, Z = 1 / 0, U = 9007199254740991, H = 17976931348623157e292, te = 0 / 0, se = 4294967295, ae = se - 1, _e3 = se >>> 1, Me = [
        [
          "ary",
          T
        ],
        [
          "bind",
          O
        ],
        [
          "bindKey",
          S
        ],
        [
          "curry",
          x
        ],
        [
          "curryRight",
          P
        ],
        [
          "flip",
          N
        ],
        [
          "partial",
          C
        ],
        [
          "partialRight",
          _
        ],
        [
          "rearg",
          $
        ]
      ], ke = "[object Arguments]", tt = "[object Array]", it = "[object AsyncFunction]", pt = "[object Boolean]", kt = "[object Date]", Yt = "[object DOMException]", Ar = "[object Error]", Cn = "[object Function]", Vn = "[object GeneratorFunction]", Lt = "[object Map]", tr = "[object Number]", ql = "[object Null]", nr = "[object Object]", go = "[object Promise]", mo = "[object Proxy]", Jr = "[object RegExp]", ei = "[object Set]", Cs = "[object String]", cu = "[object Symbol]", Ym = "[object Undefined]", Kl = "[object WeakMap]", Gm = "[object WeakSet]", yo = "[object ArrayBuffer]", Ri = "[object DataView]", Af = "[object Float32Array]", qi = "[object Float64Array]", Rf = "[object Int8Array]", Mf = "[object Int16Array]", qm = "[object Int32Array]", Df = "[object Uint8Array]", uu = "[object Uint8ClampedArray]", Lf = "[object Uint16Array]", jf = "[object Uint32Array]", Z2 = /\b__p \+= '';/g, Jl = /\b(__p \+=) '' \+/g, $S = /(__e\(.*?\)|\b__t\)) \+\n'';/g, AS = /&(?:amp|lt|gt|quot|#39);/g, RS = /[&<>"']/g, Km = RegExp(AS.source), Yd = RegExp(RS.source), Jm = /<%-([\s\S]+?)%>/g, ey = /<%([\s\S]+?)%>/g, Nf = /<%=([\s\S]+?)%>/g, Gd = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, H2 = /^\w*$/, Y2 = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, ty = /[\\^$.*+?()[\]{}|]/g, G2 = RegExp(ty.source), ny = /^\s+/, MS = /\s/, ry = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, ec = /\{\n\/\* \[wrapped with (.+)\] \*/, q2 = /,? & /, K2 = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, J2 = /[()=,{}\[\]\/\s]/, e_ = /\\(\\)?/g, t_ = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, vo = /\w*$/, n_ = /^[-+]0x[0-9a-f]+$/i, r_ = /^0b[01]+$/i, i_ = /^\[object .+?Constructor\]$/, s_ = /^0o[0-7]+$/i, o_ = /^(?:0|[1-9]\d*)$/, tc = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Qf = /($^)/, a_ = /['\n\r\u2028\u2029\\]/g, zf = "\\ud800-\\udfff", l_ = "\\u0300-\\u036f", c_ = "\\ufe20-\\ufe2f", Ff = "\\u20d0-\\u20ff", DS = l_ + c_ + Ff, LS = "\\u2700-\\u27bf", ca = "a-z\\xdf-\\xf6\\xf8-\\xff", u_ = "\\xac\\xb1\\xd7\\xf7", d_ = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", h_ = "\\u2000-\\u206f", f_ = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", jS = "A-Z\\xc0-\\xd6\\xd8-\\xde", NS = "\\ufe0e\\ufe0f", qd = u_ + d_ + h_ + f_, iy = "['\u2019]", Kd = "[" + zf + "]", sy = "[" + qd + "]", Jd = "[" + DS + "]", QS = "\\d+", p_ = "[" + LS + "]", zS = "[" + ca + "]", FS = "[^" + zf + qd + QS + LS + ca + jS + "]", Bf = "\\ud83c[\\udffb-\\udfff]", g_ = "(?:" + Jd + "|" + Bf + ")", BS = "[^" + zf + "]", Uf = "(?:\\ud83c[\\udde6-\\uddff]){2}", du = "[\\ud800-\\udbff][\\udc00-\\udfff]", _s2 = "[" + jS + "]", US = "\\u200d", VS = "(?:" + zS + "|" + FS + ")", Ka = "(?:" + _s2 + "|" + FS + ")", XS = "(?:" + iy + "(?:d|ll|m|re|s|t|ve))?", WS = "(?:" + iy + "(?:D|LL|M|RE|S|T|VE))?", ZS = g_ + "?", HS = "[" + NS + "]?", m_ = "(?:" + US + "(?:" + [
        BS,
        Uf,
        du
      ].join("|") + ")" + HS + ZS + ")*", nc = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", YS = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", GS = HS + ZS + m_, Vf = "(?:" + [
        p_,
        Uf,
        du
      ].join("|") + ")" + GS, y_ = "(?:" + [
        BS + Jd + "?",
        Jd,
        Uf,
        du,
        Kd
      ].join("|") + ")", oy = RegExp(iy, "g"), v_ = RegExp(Jd, "g"), Xf = RegExp(Bf + "(?=" + Bf + ")|" + y_ + GS, "g"), qS = RegExp([
        _s2 + "?" + zS + "+" + XS + "(?=" + [
          sy,
          _s2,
          "$"
        ].join("|") + ")",
        Ka + "+" + WS + "(?=" + [
          sy,
          _s2 + VS,
          "$"
        ].join("|") + ")",
        _s2 + "?" + VS + "+" + XS,
        _s2 + "+" + WS,
        YS,
        nc,
        QS,
        Vf
      ].join("|"), "g"), KS = RegExp("[" + US + zf + DS + NS + "]"), eh = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, JS = [
        "Array",
        "Buffer",
        "DataView",
        "Date",
        "Error",
        "Float32Array",
        "Float64Array",
        "Function",
        "Int8Array",
        "Int16Array",
        "Int32Array",
        "Map",
        "Math",
        "Object",
        "Promise",
        "RegExp",
        "Set",
        "String",
        "Symbol",
        "TypeError",
        "Uint8Array",
        "Uint8ClampedArray",
        "Uint16Array",
        "Uint32Array",
        "WeakMap",
        "_",
        "clearTimeout",
        "isFinite",
        "parseInt",
        "setTimeout"
      ], O_ = -1, Jt = {};
      Jt[Af] = Jt[qi] = Jt[Rf] = Jt[Mf] = Jt[qm] = Jt[Df] = Jt[uu] = Jt[Lf] = Jt[jf] = true, Jt[ke] = Jt[tt] = Jt[yo] = Jt[pt] = Jt[Ri] = Jt[kt] = Jt[Ar] = Jt[Cn] = Jt[Lt] = Jt[tr] = Jt[nr] = Jt[Jr] = Jt[ei] = Jt[Cs] = Jt[Kl] = false;
      var Gt = {};
      Gt[ke] = Gt[tt] = Gt[yo] = Gt[Ri] = Gt[pt] = Gt[kt] = Gt[Af] = Gt[qi] = Gt[Rf] = Gt[Mf] = Gt[qm] = Gt[Lt] = Gt[tr] = Gt[nr] = Gt[Jr] = Gt[ei] = Gt[Cs] = Gt[cu] = Gt[Df] = Gt[uu] = Gt[Lf] = Gt[jf] = true, Gt[Ar] = Gt[Cn] = Gt[Kl] = false;
      var B = {
        \u00C0: "A",
        \u00C1: "A",
        \u00C2: "A",
        \u00C3: "A",
        \u00C4: "A",
        \u00C5: "A",
        \u00E0: "a",
        \u00E1: "a",
        \u00E2: "a",
        \u00E3: "a",
        \u00E4: "a",
        \u00E5: "a",
        \u00C7: "C",
        \u00E7: "c",
        \u00D0: "D",
        \u00F0: "d",
        \u00C8: "E",
        \u00C9: "E",
        \u00CA: "E",
        \u00CB: "E",
        \u00E8: "e",
        \u00E9: "e",
        \u00EA: "e",
        \u00EB: "e",
        \u00CC: "I",
        \u00CD: "I",
        \u00CE: "I",
        \u00CF: "I",
        \u00EC: "i",
        \u00ED: "i",
        \u00EE: "i",
        \u00EF: "i",
        \u00D1: "N",
        \u00F1: "n",
        \u00D2: "O",
        \u00D3: "O",
        \u00D4: "O",
        \u00D5: "O",
        \u00D6: "O",
        \u00D8: "O",
        \u00F2: "o",
        \u00F3: "o",
        \u00F4: "o",
        \u00F5: "o",
        \u00F6: "o",
        \u00F8: "o",
        \u00D9: "U",
        \u00DA: "U",
        \u00DB: "U",
        \u00DC: "U",
        \u00F9: "u",
        \u00FA: "u",
        \u00FB: "u",
        \u00FC: "u",
        \u00DD: "Y",
        \u00FD: "y",
        \u00FF: "y",
        \u00C6: "Ae",
        \u00E6: "ae",
        \u00DE: "Th",
        \u00FE: "th",
        \u00DF: "ss",
        \u0100: "A",
        \u0102: "A",
        \u0104: "A",
        \u0101: "a",
        \u0103: "a",
        \u0105: "a",
        \u0106: "C",
        \u0108: "C",
        \u010A: "C",
        \u010C: "C",
        \u0107: "c",
        \u0109: "c",
        \u010B: "c",
        \u010D: "c",
        \u010E: "D",
        \u0110: "D",
        \u010F: "d",
        \u0111: "d",
        \u0112: "E",
        \u0114: "E",
        \u0116: "E",
        \u0118: "E",
        \u011A: "E",
        \u0113: "e",
        \u0115: "e",
        \u0117: "e",
        \u0119: "e",
        \u011B: "e",
        \u011C: "G",
        \u011E: "G",
        \u0120: "G",
        \u0122: "G",
        \u011D: "g",
        \u011F: "g",
        \u0121: "g",
        \u0123: "g",
        \u0124: "H",
        \u0126: "H",
        \u0125: "h",
        \u0127: "h",
        \u0128: "I",
        \u012A: "I",
        \u012C: "I",
        \u012E: "I",
        \u0130: "I",
        \u0129: "i",
        \u012B: "i",
        \u012D: "i",
        \u012F: "i",
        \u0131: "i",
        \u0134: "J",
        \u0135: "j",
        \u0136: "K",
        \u0137: "k",
        \u0138: "k",
        \u0139: "L",
        \u013B: "L",
        \u013D: "L",
        \u013F: "L",
        \u0141: "L",
        \u013A: "l",
        \u013C: "l",
        \u013E: "l",
        \u0140: "l",
        \u0142: "l",
        \u0143: "N",
        \u0145: "N",
        \u0147: "N",
        \u014A: "N",
        \u0144: "n",
        \u0146: "n",
        \u0148: "n",
        \u014B: "n",
        \u014C: "O",
        \u014E: "O",
        \u0150: "O",
        \u014D: "o",
        \u014F: "o",
        \u0151: "o",
        \u0154: "R",
        \u0156: "R",
        \u0158: "R",
        \u0155: "r",
        \u0157: "r",
        \u0159: "r",
        \u015A: "S",
        \u015C: "S",
        \u015E: "S",
        \u0160: "S",
        \u015B: "s",
        \u015D: "s",
        \u015F: "s",
        \u0161: "s",
        \u0162: "T",
        \u0164: "T",
        \u0166: "T",
        \u0163: "t",
        \u0165: "t",
        \u0167: "t",
        \u0168: "U",
        \u016A: "U",
        \u016C: "U",
        \u016E: "U",
        \u0170: "U",
        \u0172: "U",
        \u0169: "u",
        \u016B: "u",
        \u016D: "u",
        \u016F: "u",
        \u0171: "u",
        \u0173: "u",
        \u0174: "W",
        \u0175: "w",
        \u0176: "Y",
        \u0177: "y",
        \u0178: "Y",
        \u0179: "Z",
        \u017B: "Z",
        \u017D: "Z",
        \u017A: "z",
        \u017C: "z",
        \u017E: "z",
        \u0132: "IJ",
        \u0133: "ij",
        \u0152: "Oe",
        \u0153: "oe",
        \u0149: "'n",
        \u017F: "s"
      }, J = {
        "&": "&amp;",
        "<": "&lt;",
        ">": "&gt;",
        '"': "&quot;",
        "'": "&#39;"
      }, ge = {
        "&amp;": "&",
        "&lt;": "<",
        "&gt;": ">",
        "&quot;": '"',
        "&#39;": "'"
      }, Ie = {
        "\\": "\\",
        "'": "'",
        "\n": "n",
        "\r": "r",
        "\u2028": "u2028",
        "\u2029": "u2029"
      }, en = parseFloat, ot = parseInt, fn = typeof Jn == "object" && Jn && Jn.Object === Object && Jn, rr = typeof self == "object" && self && self.Object === Object && self, Pt = fn || rr || Function("return this")(), tn = e && !e.nodeType && e, Xn = tn && true && t && !t.nodeType && t, Ki = Xn && Xn.exports === tn, ir = Ki && fn.process, pn = function() {
        try {
          var K = Xn && Xn.require && Xn.require("util").types;
          return K || ir && ir.binding && ir.binding("util");
        } catch {
        }
      }(), Mi = pn && pn.isArrayBuffer, ua = pn && pn.isDate, Oo = pn && pn.isMap, Ja = pn && pn.isRegExp, ay = pn && pn.isSet, th = pn && pn.isTypedArray;
      function vr(K, ce, oe) {
        switch (oe.length) {
          case 0:
            return K.call(ce);
          case 1:
            return K.call(ce, oe[0]);
          case 2:
            return K.call(ce, oe[0], oe[1]);
          case 3:
            return K.call(ce, oe[0], oe[1], oe[2]);
        }
        return K.apply(ce, oe);
      }
      function Yue(K, ce, oe, Ae) {
        for (var st = -1, jt = K == null ? 0 : K.length; ++st < jt; ) {
          var dr = K[st];
          ce(Ae, dr, oe(dr), K);
        }
        return Ae;
      }
      function So(K, ce) {
        for (var oe = -1, Ae = K == null ? 0 : K.length; ++oe < Ae && ce(K[oe], oe, K) !== false; )
          ;
        return K;
      }
      function Gue(K, ce) {
        for (var oe = K == null ? 0 : K.length; oe-- && ce(K[oe], oe, K) !== false; )
          ;
        return K;
      }
      function QN(K, ce) {
        for (var oe = -1, Ae = K == null ? 0 : K.length; ++oe < Ae; )
          if (!ce(K[oe], oe, K))
            return false;
        return true;
      }
      function hu(K, ce) {
        for (var oe = -1, Ae = K == null ? 0 : K.length, st = 0, jt = []; ++oe < Ae; ) {
          var dr = K[oe];
          ce(dr, oe, K) && (jt[st++] = dr);
        }
        return jt;
      }
      function e1(K, ce) {
        var oe = K == null ? 0 : K.length;
        return !!oe && Wf(K, ce, 0) > -1;
      }
      function S_(K, ce, oe) {
        for (var Ae = -1, st = K == null ? 0 : K.length; ++Ae < st; )
          if (oe(ce, K[Ae]))
            return true;
        return false;
      }
      function _n3(K, ce) {
        for (var oe = -1, Ae = K == null ? 0 : K.length, st = Array(Ae); ++oe < Ae; )
          st[oe] = ce(K[oe], oe, K);
        return st;
      }
      function fu(K, ce) {
        for (var oe = -1, Ae = ce.length, st = K.length; ++oe < Ae; )
          K[st + oe] = ce[oe];
        return K;
      }
      function w_(K, ce, oe, Ae) {
        var st = -1, jt = K == null ? 0 : K.length;
        for (Ae && jt && (oe = K[++st]); ++st < jt; )
          oe = ce(oe, K[st], st, K);
        return oe;
      }
      function que(K, ce, oe, Ae) {
        var st = K == null ? 0 : K.length;
        for (Ae && st && (oe = K[--st]); st--; )
          oe = ce(oe, K[st], st, K);
        return oe;
      }
      function x_(K, ce) {
        for (var oe = -1, Ae = K == null ? 0 : K.length; ++oe < Ae; )
          if (ce(K[oe], oe, K))
            return true;
        return false;
      }
      var Kue = b_("length");
      function Jue(K) {
        return K.split("");
      }
      function ede(K) {
        return K.match(K2) || [];
      }
      function zN(K, ce, oe) {
        var Ae;
        return oe(K, function(st, jt, dr) {
          if (ce(st, jt, dr))
            return Ae = jt, false;
        }), Ae;
      }
      function t1(K, ce, oe, Ae) {
        for (var st = K.length, jt = oe + (Ae ? 1 : -1); Ae ? jt-- : ++jt < st; )
          if (ce(K[jt], jt, K))
            return jt;
        return -1;
      }
      function Wf(K, ce, oe) {
        return ce === ce ? hde(K, ce, oe) : t1(K, FN, oe);
      }
      function tde(K, ce, oe, Ae) {
        for (var st = oe - 1, jt = K.length; ++st < jt; )
          if (Ae(K[st], ce))
            return st;
        return -1;
      }
      function FN(K) {
        return K !== K;
      }
      function BN(K, ce) {
        var oe = K == null ? 0 : K.length;
        return oe ? P_(K, ce) / oe : te;
      }
      function b_(K) {
        return function(ce) {
          return ce == null ? n : ce[K];
        };
      }
      function k_(K) {
        return function(ce) {
          return K == null ? n : K[ce];
        };
      }
      function UN(K, ce, oe, Ae, st) {
        return st(K, function(jt, dr, nn) {
          oe = Ae ? (Ae = false, jt) : ce(oe, jt, dr, nn);
        }), oe;
      }
      function nde(K, ce) {
        var oe = K.length;
        for (K.sort(ce); oe--; )
          K[oe] = K[oe].value;
        return K;
      }
      function P_(K, ce) {
        for (var oe, Ae = -1, st = K.length; ++Ae < st; ) {
          var jt = ce(K[Ae]);
          jt !== n && (oe = oe === n ? jt : oe + jt);
        }
        return oe;
      }
      function C_(K, ce) {
        for (var oe = -1, Ae = Array(K); ++oe < K; )
          Ae[oe] = ce(oe);
        return Ae;
      }
      function rde(K, ce) {
        return _n3(ce, function(oe) {
          return [
            oe,
            K[oe]
          ];
        });
      }
      function VN(K) {
        return K && K.slice(0, HN(K) + 1).replace(ny, "");
      }
      function Ts(K) {
        return function(ce) {
          return K(ce);
        };
      }
      function __(K, ce) {
        return _n3(ce, function(oe) {
          return K[oe];
        });
      }
      function ly(K, ce) {
        return K.has(ce);
      }
      function XN(K, ce) {
        for (var oe = -1, Ae = K.length; ++oe < Ae && Wf(ce, K[oe], 0) > -1; )
          ;
        return oe;
      }
      function WN(K, ce) {
        for (var oe = K.length; oe-- && Wf(ce, K[oe], 0) > -1; )
          ;
        return oe;
      }
      function ide(K, ce) {
        for (var oe = K.length, Ae = 0; oe--; )
          K[oe] === ce && ++Ae;
        return Ae;
      }
      var sde = k_(B), ode = k_(J);
      function ade(K) {
        return "\\" + Ie[K];
      }
      function lde(K, ce) {
        return K == null ? n : K[ce];
      }
      function Zf(K) {
        return KS.test(K);
      }
      function cde(K) {
        return eh.test(K);
      }
      function ude(K) {
        for (var ce, oe = []; !(ce = K.next()).done; )
          oe.push(ce.value);
        return oe;
      }
      function T_(K) {
        var ce = -1, oe = Array(K.size);
        return K.forEach(function(Ae, st) {
          oe[++ce] = [
            st,
            Ae
          ];
        }), oe;
      }
      function ZN(K, ce) {
        return function(oe) {
          return K(ce(oe));
        };
      }
      function pu(K, ce) {
        for (var oe = -1, Ae = K.length, st = 0, jt = []; ++oe < Ae; ) {
          var dr = K[oe];
          (dr === ce || dr === u) && (K[oe] = u, jt[st++] = oe);
        }
        return jt;
      }
      function n1(K) {
        var ce = -1, oe = Array(K.size);
        return K.forEach(function(Ae) {
          oe[++ce] = Ae;
        }), oe;
      }
      function dde(K) {
        var ce = -1, oe = Array(K.size);
        return K.forEach(function(Ae) {
          oe[++ce] = [
            Ae,
            Ae
          ];
        }), oe;
      }
      function hde(K, ce, oe) {
        for (var Ae = oe - 1, st = K.length; ++Ae < st; )
          if (K[Ae] === ce)
            return Ae;
        return -1;
      }
      function fde(K, ce, oe) {
        for (var Ae = oe + 1; Ae--; )
          if (K[Ae] === ce)
            return Ae;
        return Ae;
      }
      function Hf(K) {
        return Zf(K) ? gde(K) : Kue(K);
      }
      function da(K) {
        return Zf(K) ? mde(K) : Jue(K);
      }
      function HN(K) {
        for (var ce = K.length; ce-- && MS.test(K.charAt(ce)); )
          ;
        return ce;
      }
      var pde = k_(ge);
      function gde(K) {
        for (var ce = Xf.lastIndex = 0; Xf.test(K); )
          ++ce;
        return ce;
      }
      function mde(K) {
        return K.match(Xf) || [];
      }
      function yde(K) {
        return K.match(qS) || [];
      }
      var vde = function K(ce) {
        ce = ce == null ? Pt : Yf.defaults(Pt.Object(), ce, Yf.pick(Pt, JS));
        var oe = ce.Array, Ae = ce.Date, st = ce.Error, jt = ce.Function, dr = ce.Math, nn = ce.Object, E_ = ce.RegExp, Ode = ce.String, wo = ce.TypeError, r1 = oe.prototype, Sde = jt.prototype, Gf = nn.prototype, i1 = ce["__core-js_shared__"], s1 = Sde.toString, Xt = Gf.hasOwnProperty, wde = 0, YN = function() {
          var p = /[^.]+$/.exec(i1 && i1.keys && i1.keys.IE_PROTO || "");
          return p ? "Symbol(src)_1." + p : "";
        }(), o1 = Gf.toString, xde = s1.call(nn), bde = Pt._, kde = E_("^" + s1.call(Xt).replace(ty, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), a1 = Ki ? ce.Buffer : n, gu = ce.Symbol, l1 = ce.Uint8Array, GN = a1 ? a1.allocUnsafe : n, c1 = ZN(nn.getPrototypeOf, nn), qN = nn.create, KN = Gf.propertyIsEnumerable, u1 = r1.splice, JN = gu ? gu.isConcatSpreadable : n, cy = gu ? gu.iterator : n, nh = gu ? gu.toStringTag : n, d1 = function() {
          try {
            var p = ah(nn, "defineProperty");
            return p({}, "", {}), p;
          } catch {
          }
        }(), Pde = ce.clearTimeout !== Pt.clearTimeout && ce.clearTimeout, Cde = Ae && Ae.now !== Pt.Date.now && Ae.now, _de = ce.setTimeout !== Pt.setTimeout && ce.setTimeout, h1 = dr.ceil, f1 = dr.floor, I_ = nn.getOwnPropertySymbols, Tde = a1 ? a1.isBuffer : n, e4 = ce.isFinite, Ede = r1.join, Ide = ZN(nn.keys, nn), hr = dr.max, ti = dr.min, $de = Ae.now, Ade = ce.parseInt, t4 = dr.random, Rde = r1.reverse, $_ = ah(ce, "DataView"), uy = ah(ce, "Map"), A_ = ah(ce, "Promise"), qf = ah(ce, "Set"), dy = ah(ce, "WeakMap"), hy = ah(nn, "create"), p1 = dy && new dy(), Kf = {}, Mde = lh($_), Dde = lh(uy), Lde = lh(A_), jde = lh(qf), Nde = lh(dy), g1 = gu ? gu.prototype : n, fy = g1 ? g1.valueOf : n, n4 = g1 ? g1.toString : n;
        function D(p) {
          if (jn(p) && !at(p) && !(p instanceof wt)) {
            if (p instanceof xo)
              return p;
            if (Xt.call(p, "__wrapped__"))
              return rQ(p);
          }
          return new xo(p);
        }
        var Jf = function() {
          function p() {
          }
          return function(v) {
            if (!$n(v))
              return {};
            if (qN)
              return qN(v);
            p.prototype = v;
            var k = new p();
            return p.prototype = n, k;
          };
        }();
        function m1() {
        }
        function xo(p, v) {
          this.__wrapped__ = p, this.__actions__ = [], this.__chain__ = !!v, this.__index__ = 0, this.__values__ = n;
        }
        D.templateSettings = {
          escape: Jm,
          evaluate: ey,
          interpolate: Nf,
          variable: "",
          imports: {
            _: D
          }
        }, D.prototype = m1.prototype, D.prototype.constructor = D, xo.prototype = Jf(m1.prototype), xo.prototype.constructor = xo;
        function wt(p) {
          this.__wrapped__ = p, this.__actions__ = [], this.__dir__ = 1, this.__filtered__ = false, this.__iteratees__ = [], this.__takeCount__ = se, this.__views__ = [];
        }
        function Qde() {
          var p = new wt(this.__wrapped__);
          return p.__actions__ = Ji(this.__actions__), p.__dir__ = this.__dir__, p.__filtered__ = this.__filtered__, p.__iteratees__ = Ji(this.__iteratees__), p.__takeCount__ = this.__takeCount__, p.__views__ = Ji(this.__views__), p;
        }
        function zde() {
          if (this.__filtered__) {
            var p = new wt(this);
            p.__dir__ = -1, p.__filtered__ = true;
          } else
            p = this.clone(), p.__dir__ *= -1;
          return p;
        }
        function Fde() {
          var p = this.__wrapped__.value(), v = this.__dir__, k = at(p), E = v < 0, A = k ? p.length : 0, j = Jhe(0, A, this.__views__), W = j.start, G = j.end, ee = G - W, he = E ? G : W - 1, fe = this.__iteratees__, me = fe.length, be = 0, je = ti(ee, this.__takeCount__);
          if (!k || !E && A == ee && je == ee)
            return C4(p, this.__actions__);
          var qe = [];
          e:
            for (; ee-- && be < je; ) {
              he += v;
              for (var ht = -1, Ke = p[he]; ++ht < me; ) {
                var vt = fe[ht], Ct = vt.iteratee, $s = vt.type, ji = Ct(Ke);
                if ($s == Q)
                  Ke = ji;
                else if (!ji) {
                  if ($s == F)
                    continue e;
                  break e;
                }
              }
              qe[be++] = Ke;
            }
          return qe;
        }
        wt.prototype = Jf(m1.prototype), wt.prototype.constructor = wt;
        function rh(p) {
          var v = -1, k = p == null ? 0 : p.length;
          for (this.clear(); ++v < k; ) {
            var E = p[v];
            this.set(E[0], E[1]);
          }
        }
        function Bde() {
          this.__data__ = hy ? hy(null) : {}, this.size = 0;
        }
        function Ude(p) {
          var v = this.has(p) && delete this.__data__[p];
          return this.size -= v ? 1 : 0, v;
        }
        function Vde(p) {
          var v = this.__data__;
          if (hy) {
            var k = v[p];
            return k === l ? n : k;
          }
          return Xt.call(v, p) ? v[p] : n;
        }
        function Xde(p) {
          var v = this.__data__;
          return hy ? v[p] !== n : Xt.call(v, p);
        }
        function Wde(p, v) {
          var k = this.__data__;
          return this.size += this.has(p) ? 0 : 1, k[p] = hy && v === n ? l : v, this;
        }
        rh.prototype.clear = Bde, rh.prototype.delete = Ude, rh.prototype.get = Vde, rh.prototype.has = Xde, rh.prototype.set = Wde;
        function rc(p) {
          var v = -1, k = p == null ? 0 : p.length;
          for (this.clear(); ++v < k; ) {
            var E = p[v];
            this.set(E[0], E[1]);
          }
        }
        function Zde() {
          this.__data__ = [], this.size = 0;
        }
        function Hde(p) {
          var v = this.__data__, k = y1(v, p);
          if (k < 0)
            return false;
          var E = v.length - 1;
          return k == E ? v.pop() : u1.call(v, k, 1), --this.size, true;
        }
        function Yde(p) {
          var v = this.__data__, k = y1(v, p);
          return k < 0 ? n : v[k][1];
        }
        function Gde(p) {
          return y1(this.__data__, p) > -1;
        }
        function qde(p, v) {
          var k = this.__data__, E = y1(k, p);
          return E < 0 ? (++this.size, k.push([
            p,
            v
          ])) : k[E][1] = v, this;
        }
        rc.prototype.clear = Zde, rc.prototype.delete = Hde, rc.prototype.get = Yde, rc.prototype.has = Gde, rc.prototype.set = qde;
        function ic(p) {
          var v = -1, k = p == null ? 0 : p.length;
          for (this.clear(); ++v < k; ) {
            var E = p[v];
            this.set(E[0], E[1]);
          }
        }
        function Kde() {
          this.size = 0, this.__data__ = {
            hash: new rh(),
            map: new (uy || rc)(),
            string: new rh()
          };
        }
        function Jde(p) {
          var v = E1(this, p).delete(p);
          return this.size -= v ? 1 : 0, v;
        }
        function ehe(p) {
          return E1(this, p).get(p);
        }
        function the(p) {
          return E1(this, p).has(p);
        }
        function nhe(p, v) {
          var k = E1(this, p), E = k.size;
          return k.set(p, v), this.size += k.size == E ? 0 : 1, this;
        }
        ic.prototype.clear = Kde, ic.prototype.delete = Jde, ic.prototype.get = ehe, ic.prototype.has = the, ic.prototype.set = nhe;
        function ih(p) {
          var v = -1, k = p == null ? 0 : p.length;
          for (this.__data__ = new ic(); ++v < k; )
            this.add(p[v]);
        }
        function rhe(p) {
          return this.__data__.set(p, l), this;
        }
        function ihe(p) {
          return this.__data__.has(p);
        }
        ih.prototype.add = ih.prototype.push = rhe, ih.prototype.has = ihe;
        function ha(p) {
          var v = this.__data__ = new rc(p);
          this.size = v.size;
        }
        function she() {
          this.__data__ = new rc(), this.size = 0;
        }
        function ohe(p) {
          var v = this.__data__, k = v.delete(p);
          return this.size = v.size, k;
        }
        function ahe(p) {
          return this.__data__.get(p);
        }
        function lhe(p) {
          return this.__data__.has(p);
        }
        function che(p, v) {
          var k = this.__data__;
          if (k instanceof rc) {
            var E = k.__data__;
            if (!uy || E.length < i - 1)
              return E.push([
                p,
                v
              ]), this.size = ++k.size, this;
            k = this.__data__ = new ic(E);
          }
          return k.set(p, v), this.size = k.size, this;
        }
        ha.prototype.clear = she, ha.prototype.delete = ohe, ha.prototype.get = ahe, ha.prototype.has = lhe, ha.prototype.set = che;
        function r4(p, v) {
          var k = at(p), E = !k && ch(p), A = !k && !E && Su(p), j = !k && !E && !A && rp(p), W = k || E || A || j, G = W ? C_(p.length, Ode) : [], ee = G.length;
          for (var he in p)
            (v || Xt.call(p, he)) && !(W && (he == "length" || A && (he == "offset" || he == "parent") || j && (he == "buffer" || he == "byteLength" || he == "byteOffset") || lc(he, ee))) && G.push(he);
          return G;
        }
        function i4(p) {
          var v = p.length;
          return v ? p[U_(0, v - 1)] : n;
        }
        function uhe(p, v) {
          return I1(Ji(p), sh(v, 0, p.length));
        }
        function dhe(p) {
          return I1(Ji(p));
        }
        function R_(p, v, k) {
          (k !== n && !fa(p[v], k) || k === n && !(v in p)) && sc(p, v, k);
        }
        function py(p, v, k) {
          var E = p[v];
          (!(Xt.call(p, v) && fa(E, k)) || k === n && !(v in p)) && sc(p, v, k);
        }
        function y1(p, v) {
          for (var k = p.length; k--; )
            if (fa(p[k][0], v))
              return k;
          return -1;
        }
        function hhe(p, v, k, E) {
          return mu(p, function(A, j, W) {
            v(E, A, k(A), W);
          }), E;
        }
        function s4(p, v) {
          return p && tl(v, Or(v), p);
        }
        function fhe(p, v) {
          return p && tl(v, ts(v), p);
        }
        function sc(p, v, k) {
          v == "__proto__" && d1 ? d1(p, v, {
            configurable: true,
            enumerable: true,
            value: k,
            writable: true
          }) : p[v] = k;
        }
        function M_(p, v) {
          for (var k = -1, E = v.length, A = oe(E), j = p == null; ++k < E; )
            A[k] = j ? n : pT(p, v[k]);
          return A;
        }
        function sh(p, v, k) {
          return p === p && (k !== n && (p = p <= k ? p : k), v !== n && (p = p >= v ? p : v)), p;
        }
        function bo(p, v, k, E, A, j) {
          var W, G = v & d, ee = v & h, he = v & f;
          if (k && (W = A ? k(p, E, A, j) : k(p)), W !== n)
            return W;
          if (!$n(p))
            return p;
          var fe = at(p);
          if (fe) {
            if (W = tfe(p), !G)
              return Ji(p, W);
          } else {
            var me = ni(p), be = me == Cn || me == Vn;
            if (Su(p))
              return E4(p, G);
            if (me == nr || me == ke || be && !A) {
              if (W = ee || be ? {} : H4(p), !G)
                return ee ? Vhe(p, fhe(W, p)) : Uhe(p, s4(W, p));
            } else {
              if (!Gt[me])
                return A ? p : {};
              W = nfe(p, me, G);
            }
          }
          j || (j = new ha());
          var je = j.get(p);
          if (je)
            return je;
          j.set(p, W), bQ(p) ? p.forEach(function(Ke) {
            W.add(bo(Ke, v, k, Ke, p, j));
          }) : wQ(p) && p.forEach(function(Ke, vt) {
            W.set(vt, bo(Ke, v, k, vt, p, j));
          });
          var qe = he ? ee ? eT : J_ : ee ? ts : Or, ht = fe ? n : qe(p);
          return So(ht || p, function(Ke, vt) {
            ht && (vt = Ke, Ke = p[vt]), py(W, vt, bo(Ke, v, k, vt, p, j));
          }), W;
        }
        function phe(p) {
          var v = Or(p);
          return function(k) {
            return o4(k, p, v);
          };
        }
        function o4(p, v, k) {
          var E = k.length;
          if (p == null)
            return !E;
          for (p = nn(p); E--; ) {
            var A = k[E], j = v[A], W = p[A];
            if (W === n && !(A in p) || !j(W))
              return false;
          }
          return true;
        }
        function a4(p, v, k) {
          if (typeof p != "function")
            throw new wo(o);
          return wy(function() {
            p.apply(n, k);
          }, v);
        }
        function gy(p, v, k, E) {
          var A = -1, j = e1, W = true, G = p.length, ee = [], he = v.length;
          if (!G)
            return ee;
          k && (v = _n3(v, Ts(k))), E ? (j = S_, W = false) : v.length >= i && (j = ly, W = false, v = new ih(v));
          e:
            for (; ++A < G; ) {
              var fe = p[A], me = k == null ? fe : k(fe);
              if (fe = E || fe !== 0 ? fe : 0, W && me === me) {
                for (var be = he; be--; )
                  if (v[be] === me)
                    continue e;
                ee.push(fe);
              } else
                j(v, me, E) || ee.push(fe);
            }
          return ee;
        }
        var mu = M4(el), l4 = M4(L_, true);
        function ghe(p, v) {
          var k = true;
          return mu(p, function(E, A, j) {
            return k = !!v(E, A, j), k;
          }), k;
        }
        function v1(p, v, k) {
          for (var E = -1, A = p.length; ++E < A; ) {
            var j = p[E], W = v(j);
            if (W != null && (G === n ? W === W && !Is(W) : k(W, G)))
              var G = W, ee = j;
          }
          return ee;
        }
        function mhe(p, v, k, E) {
          var A = p.length;
          for (k = dt(k), k < 0 && (k = -k > A ? 0 : A + k), E = E === n || E > A ? A : dt(E), E < 0 && (E += A), E = k > E ? 0 : PQ(E); k < E; )
            p[k++] = v;
          return p;
        }
        function c4(p, v) {
          var k = [];
          return mu(p, function(E, A, j) {
            v(E, A, j) && k.push(E);
          }), k;
        }
        function Rr(p, v, k, E, A) {
          var j = -1, W = p.length;
          for (k || (k = ife), A || (A = []); ++j < W; ) {
            var G = p[j];
            v > 0 && k(G) ? v > 1 ? Rr(G, v - 1, k, E, A) : fu(A, G) : E || (A[A.length] = G);
          }
          return A;
        }
        var D_ = D4(), u4 = D4(true);
        function el(p, v) {
          return p && D_(p, v, Or);
        }
        function L_(p, v) {
          return p && u4(p, v, Or);
        }
        function O1(p, v) {
          return hu(v, function(k) {
            return cc(p[k]);
          });
        }
        function oh(p, v) {
          v = vu(v, p);
          for (var k = 0, E = v.length; p != null && k < E; )
            p = p[nl(v[k++])];
          return k && k == E ? p : n;
        }
        function d4(p, v, k) {
          var E = v(p);
          return at(p) ? E : fu(E, k(p));
        }
        function Di(p) {
          return p == null ? p === n ? Ym : ql : nh && nh in nn(p) ? Khe(p) : dfe(p);
        }
        function j_(p, v) {
          return p > v;
        }
        function yhe(p, v) {
          return p != null && Xt.call(p, v);
        }
        function vhe(p, v) {
          return p != null && v in nn(p);
        }
        function Ohe(p, v, k) {
          return p >= ti(v, k) && p < hr(v, k);
        }
        function N_(p, v, k) {
          for (var E = k ? S_ : e1, A = p[0].length, j = p.length, W = j, G = oe(j), ee = 1 / 0, he = []; W--; ) {
            var fe = p[W];
            W && v && (fe = _n3(fe, Ts(v))), ee = ti(fe.length, ee), G[W] = !k && (v || A >= 120 && fe.length >= 120) ? new ih(W && fe) : n;
          }
          fe = p[0];
          var me = -1, be = G[0];
          e:
            for (; ++me < A && he.length < ee; ) {
              var je = fe[me], qe = v ? v(je) : je;
              if (je = k || je !== 0 ? je : 0, !(be ? ly(be, qe) : E(he, qe, k))) {
                for (W = j; --W; ) {
                  var ht = G[W];
                  if (!(ht ? ly(ht, qe) : E(p[W], qe, k)))
                    continue e;
                }
                be && be.push(qe), he.push(je);
              }
            }
          return he;
        }
        function She(p, v, k, E) {
          return el(p, function(A, j, W) {
            v(E, k(A), j, W);
          }), E;
        }
        function my(p, v, k) {
          v = vu(v, p), p = K4(p, v);
          var E = p == null ? p : p[nl(Po(v))];
          return E == null ? n : vr(E, p, k);
        }
        function h4(p) {
          return jn(p) && Di(p) == ke;
        }
        function whe(p) {
          return jn(p) && Di(p) == yo;
        }
        function xhe(p) {
          return jn(p) && Di(p) == kt;
        }
        function yy(p, v, k, E, A) {
          return p === v ? true : p == null || v == null || !jn(p) && !jn(v) ? p !== p && v !== v : bhe(p, v, k, E, yy, A);
        }
        function bhe(p, v, k, E, A, j) {
          var W = at(p), G = at(v), ee = W ? tt : ni(p), he = G ? tt : ni(v);
          ee = ee == ke ? nr : ee, he = he == ke ? nr : he;
          var fe = ee == nr, me = he == nr, be = ee == he;
          if (be && Su(p)) {
            if (!Su(v))
              return false;
            W = true, fe = false;
          }
          if (be && !fe)
            return j || (j = new ha()), W || rp(p) ? X4(p, v, k, E, A, j) : Ghe(p, v, ee, k, E, A, j);
          if (!(k & y)) {
            var je = fe && Xt.call(p, "__wrapped__"), qe = me && Xt.call(v, "__wrapped__");
            if (je || qe) {
              var ht = je ? p.value() : p, Ke = qe ? v.value() : v;
              return j || (j = new ha()), A(ht, Ke, k, E, j);
            }
          }
          return be ? (j || (j = new ha()), qhe(p, v, k, E, A, j)) : false;
        }
        function khe(p) {
          return jn(p) && ni(p) == Lt;
        }
        function Q_(p, v, k, E) {
          var A = k.length, j = A, W = !E;
          if (p == null)
            return !j;
          for (p = nn(p); A--; ) {
            var G = k[A];
            if (W && G[2] ? G[1] !== p[G[0]] : !(G[0] in p))
              return false;
          }
          for (; ++A < j; ) {
            G = k[A];
            var ee = G[0], he = p[ee], fe = G[1];
            if (W && G[2]) {
              if (he === n && !(ee in p))
                return false;
            } else {
              var me = new ha();
              if (E)
                var be = E(he, fe, ee, p, v, me);
              if (!(be === n ? yy(fe, he, y | g, E, me) : be))
                return false;
            }
          }
          return true;
        }
        function f4(p) {
          if (!$n(p) || ofe(p))
            return false;
          var v = cc(p) ? kde : i_;
          return v.test(lh(p));
        }
        function Phe(p) {
          return jn(p) && Di(p) == Jr;
        }
        function Che(p) {
          return jn(p) && ni(p) == ei;
        }
        function _he(p) {
          return jn(p) && L1(p.length) && !!Jt[Di(p)];
        }
        function p4(p) {
          return typeof p == "function" ? p : p == null ? ns : typeof p == "object" ? at(p) ? y4(p[0], p[1]) : m4(p) : LQ(p);
        }
        function z_(p) {
          if (!Sy(p))
            return Ide(p);
          var v = [];
          for (var k in nn(p))
            Xt.call(p, k) && k != "constructor" && v.push(k);
          return v;
        }
        function The(p) {
          if (!$n(p))
            return ufe(p);
          var v = Sy(p), k = [];
          for (var E in p)
            E == "constructor" && (v || !Xt.call(p, E)) || k.push(E);
          return k;
        }
        function F_(p, v) {
          return p < v;
        }
        function g4(p, v) {
          var k = -1, E = es(p) ? oe(p.length) : [];
          return mu(p, function(A, j, W) {
            E[++k] = v(A, j, W);
          }), E;
        }
        function m4(p) {
          var v = nT(p);
          return v.length == 1 && v[0][2] ? G4(v[0][0], v[0][1]) : function(k) {
            return k === p || Q_(k, p, v);
          };
        }
        function y4(p, v) {
          return iT(p) && Y4(v) ? G4(nl(p), v) : function(k) {
            var E = pT(k, p);
            return E === n && E === v ? gT(k, p) : yy(v, E, y | g);
          };
        }
        function S1(p, v, k, E, A) {
          p !== v && D_(v, function(j, W) {
            if (A || (A = new ha()), $n(j))
              Ehe(p, v, W, k, S1, E, A);
            else {
              var G = E ? E(oT(p, W), j, W + "", p, v, A) : n;
              G === n && (G = j), R_(p, W, G);
            }
          }, ts);
        }
        function Ehe(p, v, k, E, A, j, W) {
          var G = oT(p, k), ee = oT(v, k), he = W.get(ee);
          if (he) {
            R_(p, k, he);
            return;
          }
          var fe = j ? j(G, ee, k + "", p, v, W) : n, me = fe === n;
          if (me) {
            var be = at(ee), je = !be && Su(ee), qe = !be && !je && rp(ee);
            fe = ee, be || je || qe ? at(G) ? fe = G : Wn(G) ? fe = Ji(G) : je ? (me = false, fe = E4(ee, true)) : qe ? (me = false, fe = I4(ee, true)) : fe = [] : xy(ee) || ch(ee) ? (fe = G, ch(G) ? fe = CQ(G) : (!$n(G) || cc(G)) && (fe = H4(ee))) : me = false;
          }
          me && (W.set(ee, fe), A(fe, ee, E, j, W), W.delete(ee)), R_(p, k, fe);
        }
        function v4(p, v) {
          var k = p.length;
          if (k)
            return v += v < 0 ? k : 0, lc(v, k) ? p[v] : n;
        }
        function O4(p, v, k) {
          v.length ? v = _n3(v, function(j) {
            return at(j) ? function(W) {
              return oh(W, j.length === 1 ? j[0] : j);
            } : j;
          }) : v = [
            ns
          ];
          var E = -1;
          v = _n3(v, Ts(Ye()));
          var A = g4(p, function(j, W, G) {
            var ee = _n3(v, function(he) {
              return he(j);
            });
            return {
              criteria: ee,
              index: ++E,
              value: j
            };
          });
          return nde(A, function(j, W) {
            return Bhe(j, W, k);
          });
        }
        function Ihe(p, v) {
          return S4(p, v, function(k, E) {
            return gT(p, E);
          });
        }
        function S4(p, v, k) {
          for (var E = -1, A = v.length, j = {}; ++E < A; ) {
            var W = v[E], G = oh(p, W);
            k(G, W) && vy(j, vu(W, p), G);
          }
          return j;
        }
        function $he(p) {
          return function(v) {
            return oh(v, p);
          };
        }
        function B_(p, v, k, E) {
          var A = E ? tde : Wf, j = -1, W = v.length, G = p;
          for (p === v && (v = Ji(v)), k && (G = _n3(p, Ts(k))); ++j < W; )
            for (var ee = 0, he = v[j], fe = k ? k(he) : he; (ee = A(G, fe, ee, E)) > -1; )
              G !== p && u1.call(G, ee, 1), u1.call(p, ee, 1);
          return p;
        }
        function w4(p, v) {
          for (var k = p ? v.length : 0, E = k - 1; k--; ) {
            var A = v[k];
            if (k == E || A !== j) {
              var j = A;
              lc(A) ? u1.call(p, A, 1) : W_(p, A);
            }
          }
          return p;
        }
        function U_(p, v) {
          return p + f1(t4() * (v - p + 1));
        }
        function Ahe(p, v, k, E) {
          for (var A = -1, j = hr(h1((v - p) / (k || 1)), 0), W = oe(j); j--; )
            W[E ? j : ++A] = p, p += k;
          return W;
        }
        function V_(p, v) {
          var k = "";
          if (!p || v < 1 || v > U)
            return k;
          do
            v % 2 && (k += p), v = f1(v / 2), v && (p += p);
          while (v);
          return k;
        }
        function gt(p, v) {
          return aT(q4(p, v, ns), p + "");
        }
        function Rhe(p) {
          return i4(ip(p));
        }
        function Mhe(p, v) {
          var k = ip(p);
          return I1(k, sh(v, 0, k.length));
        }
        function vy(p, v, k, E) {
          if (!$n(p))
            return p;
          v = vu(v, p);
          for (var A = -1, j = v.length, W = j - 1, G = p; G != null && ++A < j; ) {
            var ee = nl(v[A]), he = k;
            if (ee === "__proto__" || ee === "constructor" || ee === "prototype")
              return p;
            if (A != W) {
              var fe = G[ee];
              he = E ? E(fe, ee, G) : n, he === n && (he = $n(fe) ? fe : lc(v[A + 1]) ? [] : {});
            }
            py(G, ee, he), G = G[ee];
          }
          return p;
        }
        var x4 = p1 ? function(p, v) {
          return p1.set(p, v), p;
        } : ns, Dhe = d1 ? function(p, v) {
          return d1(p, "toString", {
            configurable: true,
            enumerable: false,
            value: yT(v),
            writable: true
          });
        } : ns;
        function Lhe(p) {
          return I1(ip(p));
        }
        function ko(p, v, k) {
          var E = -1, A = p.length;
          v < 0 && (v = -v > A ? 0 : A + v), k = k > A ? A : k, k < 0 && (k += A), A = v > k ? 0 : k - v >>> 0, v >>>= 0;
          for (var j = oe(A); ++E < A; )
            j[E] = p[E + v];
          return j;
        }
        function jhe(p, v) {
          var k;
          return mu(p, function(E, A, j) {
            return k = v(E, A, j), !k;
          }), !!k;
        }
        function w1(p, v, k) {
          var E = 0, A = p == null ? E : p.length;
          if (typeof v == "number" && v === v && A <= _e3) {
            for (; E < A; ) {
              var j = E + A >>> 1, W = p[j];
              W !== null && !Is(W) && (k ? W <= v : W < v) ? E = j + 1 : A = j;
            }
            return A;
          }
          return X_(p, v, ns, k);
        }
        function X_(p, v, k, E) {
          var A = 0, j = p == null ? 0 : p.length;
          if (j === 0)
            return 0;
          v = k(v);
          for (var W = v !== v, G = v === null, ee = Is(v), he = v === n; A < j; ) {
            var fe = f1((A + j) / 2), me = k(p[fe]), be = me !== n, je = me === null, qe = me === me, ht = Is(me);
            if (W)
              var Ke = E || qe;
            else
              he ? Ke = qe && (E || be) : G ? Ke = qe && be && (E || !je) : ee ? Ke = qe && be && !je && (E || !ht) : je || ht ? Ke = false : Ke = E ? me <= v : me < v;
            Ke ? A = fe + 1 : j = fe;
          }
          return ti(j, ae);
        }
        function b4(p, v) {
          for (var k = -1, E = p.length, A = 0, j = []; ++k < E; ) {
            var W = p[k], G = v ? v(W) : W;
            if (!k || !fa(G, ee)) {
              var ee = G;
              j[A++] = W === 0 ? 0 : W;
            }
          }
          return j;
        }
        function k4(p) {
          return typeof p == "number" ? p : Is(p) ? te : +p;
        }
        function Es(p) {
          if (typeof p == "string")
            return p;
          if (at(p))
            return _n3(p, Es) + "";
          if (Is(p))
            return n4 ? n4.call(p) : "";
          var v = p + "";
          return v == "0" && 1 / p == -Z ? "-0" : v;
        }
        function yu(p, v, k) {
          var E = -1, A = e1, j = p.length, W = true, G = [], ee = G;
          if (k)
            W = false, A = S_;
          else if (j >= i) {
            var he = v ? null : Hhe(p);
            if (he)
              return n1(he);
            W = false, A = ly, ee = new ih();
          } else
            ee = v ? [] : G;
          e:
            for (; ++E < j; ) {
              var fe = p[E], me = v ? v(fe) : fe;
              if (fe = k || fe !== 0 ? fe : 0, W && me === me) {
                for (var be = ee.length; be--; )
                  if (ee[be] === me)
                    continue e;
                v && ee.push(me), G.push(fe);
              } else
                A(ee, me, k) || (ee !== G && ee.push(me), G.push(fe));
            }
          return G;
        }
        function W_(p, v) {
          return v = vu(v, p), p = K4(p, v), p == null || delete p[nl(Po(v))];
        }
        function P4(p, v, k, E) {
          return vy(p, v, k(oh(p, v)), E);
        }
        function x1(p, v, k, E) {
          for (var A = p.length, j = E ? A : -1; (E ? j-- : ++j < A) && v(p[j], j, p); )
            ;
          return k ? ko(p, E ? 0 : j, E ? j + 1 : A) : ko(p, E ? j + 1 : 0, E ? A : j);
        }
        function C4(p, v) {
          var k = p;
          return k instanceof wt && (k = k.value()), w_(v, function(E, A) {
            return A.func.apply(A.thisArg, fu([
              E
            ], A.args));
          }, k);
        }
        function Z_(p, v, k) {
          var E = p.length;
          if (E < 2)
            return E ? yu(p[0]) : [];
          for (var A = -1, j = oe(E); ++A < E; )
            for (var W = p[A], G = -1; ++G < E; )
              G != A && (j[A] = gy(j[A] || W, p[G], v, k));
          return yu(Rr(j, 1), v, k);
        }
        function _4(p, v, k) {
          for (var E = -1, A = p.length, j = v.length, W = {}; ++E < A; ) {
            var G = E < j ? v[E] : n;
            k(W, p[E], G);
          }
          return W;
        }
        function H_(p) {
          return Wn(p) ? p : [];
        }
        function Y_(p) {
          return typeof p == "function" ? p : ns;
        }
        function vu(p, v) {
          return at(p) ? p : iT(p, v) ? [
            p
          ] : nQ(Nt(p));
        }
        var Nhe = gt;
        function Ou(p, v, k) {
          var E = p.length;
          return k = k === n ? E : k, !v && k >= E ? p : ko(p, v, k);
        }
        var T4 = Pde || function(p) {
          return Pt.clearTimeout(p);
        };
        function E4(p, v) {
          if (v)
            return p.slice();
          var k = p.length, E = GN ? GN(k) : new p.constructor(k);
          return p.copy(E), E;
        }
        function G_(p) {
          var v = new p.constructor(p.byteLength);
          return new l1(v).set(new l1(p)), v;
        }
        function Qhe(p, v) {
          var k = v ? G_(p.buffer) : p.buffer;
          return new p.constructor(k, p.byteOffset, p.byteLength);
        }
        function zhe(p) {
          var v = new p.constructor(p.source, vo.exec(p));
          return v.lastIndex = p.lastIndex, v;
        }
        function Fhe(p) {
          return fy ? nn(fy.call(p)) : {};
        }
        function I4(p, v) {
          var k = v ? G_(p.buffer) : p.buffer;
          return new p.constructor(k, p.byteOffset, p.length);
        }
        function $4(p, v) {
          if (p !== v) {
            var k = p !== n, E = p === null, A = p === p, j = Is(p), W = v !== n, G = v === null, ee = v === v, he = Is(v);
            if (!G && !he && !j && p > v || j && W && ee && !G && !he || E && W && ee || !k && ee || !A)
              return 1;
            if (!E && !j && !he && p < v || he && k && A && !E && !j || G && k && A || !W && A || !ee)
              return -1;
          }
          return 0;
        }
        function Bhe(p, v, k) {
          for (var E = -1, A = p.criteria, j = v.criteria, W = A.length, G = k.length; ++E < W; ) {
            var ee = $4(A[E], j[E]);
            if (ee) {
              if (E >= G)
                return ee;
              var he = k[E];
              return ee * (he == "desc" ? -1 : 1);
            }
          }
          return p.index - v.index;
        }
        function A4(p, v, k, E) {
          for (var A = -1, j = p.length, W = k.length, G = -1, ee = v.length, he = hr(j - W, 0), fe = oe(ee + he), me = !E; ++G < ee; )
            fe[G] = v[G];
          for (; ++A < W; )
            (me || A < j) && (fe[k[A]] = p[A]);
          for (; he--; )
            fe[G++] = p[A++];
          return fe;
        }
        function R4(p, v, k, E) {
          for (var A = -1, j = p.length, W = -1, G = k.length, ee = -1, he = v.length, fe = hr(j - G, 0), me = oe(fe + he), be = !E; ++A < fe; )
            me[A] = p[A];
          for (var je = A; ++ee < he; )
            me[je + ee] = v[ee];
          for (; ++W < G; )
            (be || A < j) && (me[je + k[W]] = p[A++]);
          return me;
        }
        function Ji(p, v) {
          var k = -1, E = p.length;
          for (v || (v = oe(E)); ++k < E; )
            v[k] = p[k];
          return v;
        }
        function tl(p, v, k, E) {
          var A = !k;
          k || (k = {});
          for (var j = -1, W = v.length; ++j < W; ) {
            var G = v[j], ee = E ? E(k[G], p[G], G, k, p) : n;
            ee === n && (ee = p[G]), A ? sc(k, G, ee) : py(k, G, ee);
          }
          return k;
        }
        function Uhe(p, v) {
          return tl(p, rT(p), v);
        }
        function Vhe(p, v) {
          return tl(p, W4(p), v);
        }
        function b1(p, v) {
          return function(k, E) {
            var A = at(k) ? Yue : hhe, j = v ? v() : {};
            return A(k, p, Ye(E, 2), j);
          };
        }
        function ep(p) {
          return gt(function(v, k) {
            var E = -1, A = k.length, j = A > 1 ? k[A - 1] : n, W = A > 2 ? k[2] : n;
            for (j = p.length > 3 && typeof j == "function" ? (A--, j) : n, W && Li(k[0], k[1], W) && (j = A < 3 ? n : j, A = 1), v = nn(v); ++E < A; ) {
              var G = k[E];
              G && p(v, G, E, j);
            }
            return v;
          });
        }
        function M4(p, v) {
          return function(k, E) {
            if (k == null)
              return k;
            if (!es(k))
              return p(k, E);
            for (var A = k.length, j = v ? A : -1, W = nn(k); (v ? j-- : ++j < A) && E(W[j], j, W) !== false; )
              ;
            return k;
          };
        }
        function D4(p) {
          return function(v, k, E) {
            for (var A = -1, j = nn(v), W = E(v), G = W.length; G--; ) {
              var ee = W[p ? G : ++A];
              if (k(j[ee], ee, j) === false)
                break;
            }
            return v;
          };
        }
        function Xhe(p, v, k) {
          var E = v & O, A = Oy(p);
          function j() {
            var W = this && this !== Pt && this instanceof j ? A : p;
            return W.apply(E ? k : this, arguments);
          }
          return j;
        }
        function L4(p) {
          return function(v) {
            v = Nt(v);
            var k = Zf(v) ? da(v) : n, E = k ? k[0] : v.charAt(0), A = k ? Ou(k, 1).join("") : v.slice(1);
            return E[p]() + A;
          };
        }
        function tp(p) {
          return function(v) {
            return w_(MQ(RQ(v).replace(oy, "")), p, "");
          };
        }
        function Oy(p) {
          return function() {
            var v = arguments;
            switch (v.length) {
              case 0:
                return new p();
              case 1:
                return new p(v[0]);
              case 2:
                return new p(v[0], v[1]);
              case 3:
                return new p(v[0], v[1], v[2]);
              case 4:
                return new p(v[0], v[1], v[2], v[3]);
              case 5:
                return new p(v[0], v[1], v[2], v[3], v[4]);
              case 6:
                return new p(v[0], v[1], v[2], v[3], v[4], v[5]);
              case 7:
                return new p(v[0], v[1], v[2], v[3], v[4], v[5], v[6]);
            }
            var k = Jf(p.prototype), E = p.apply(k, v);
            return $n(E) ? E : k;
          };
        }
        function Whe(p, v, k) {
          var E = Oy(p);
          function A() {
            for (var j = arguments.length, W = oe(j), G = j, ee = np(A); G--; )
              W[G] = arguments[G];
            var he = j < 3 && W[0] !== ee && W[j - 1] !== ee ? [] : pu(W, ee);
            if (j -= he.length, j < k)
              return F4(p, v, k1, A.placeholder, n, W, he, n, n, k - j);
            var fe = this && this !== Pt && this instanceof A ? E : p;
            return vr(fe, this, W);
          }
          return A;
        }
        function j4(p) {
          return function(v, k, E) {
            var A = nn(v);
            if (!es(v)) {
              var j = Ye(k, 3);
              v = Or(v), k = function(G) {
                return j(A[G], G, A);
              };
            }
            var W = p(v, k, E);
            return W > -1 ? A[j ? v[W] : W] : n;
          };
        }
        function N4(p) {
          return ac(function(v) {
            var k = v.length, E = k, A = xo.prototype.thru;
            for (p && v.reverse(); E--; ) {
              var j = v[E];
              if (typeof j != "function")
                throw new wo(o);
              if (A && !W && T1(j) == "wrapper")
                var W = new xo([], true);
            }
            for (E = W ? E : k; ++E < k; ) {
              j = v[E];
              var G = T1(j), ee = G == "wrapper" ? tT(j) : n;
              ee && sT(ee[0]) && ee[1] == (T | x | C | $) && !ee[4].length && ee[9] == 1 ? W = W[T1(ee[0])].apply(W, ee[3]) : W = j.length == 1 && sT(j) ? W[G]() : W.thru(j);
            }
            return function() {
              var he = arguments, fe = he[0];
              if (W && he.length == 1 && at(fe))
                return W.plant(fe).value();
              for (var me = 0, be = k ? v[me].apply(this, he) : fe; ++me < k; )
                be = v[me].call(this, be);
              return be;
            };
          });
        }
        function k1(p, v, k, E, A, j, W, G, ee, he) {
          var fe = v & T, me = v & O, be = v & S, je = v & (x | P), qe = v & N, ht = be ? n : Oy(p);
          function Ke() {
            for (var vt = arguments.length, Ct = oe(vt), $s = vt; $s--; )
              Ct[$s] = arguments[$s];
            if (je)
              var ji = np(Ke), As = ide(Ct, ji);
            if (E && (Ct = A4(Ct, E, A, je)), j && (Ct = R4(Ct, j, W, je)), vt -= As, je && vt < he) {
              var Zn = pu(Ct, ji);
              return F4(p, v, k1, Ke.placeholder, k, Ct, Zn, G, ee, he - vt);
            }
            var pa = me ? k : this, dc = be ? pa[p] : p;
            return vt = Ct.length, G ? Ct = hfe(Ct, G) : qe && vt > 1 && Ct.reverse(), fe && ee < vt && (Ct.length = ee), this && this !== Pt && this instanceof Ke && (dc = ht || Oy(dc)), dc.apply(pa, Ct);
          }
          return Ke;
        }
        function Q4(p, v) {
          return function(k, E) {
            return She(k, p, v(E), {});
          };
        }
        function P1(p, v) {
          return function(k, E) {
            var A;
            if (k === n && E === n)
              return v;
            if (k !== n && (A = k), E !== n) {
              if (A === n)
                return E;
              typeof k == "string" || typeof E == "string" ? (k = Es(k), E = Es(E)) : (k = k4(k), E = k4(E)), A = p(k, E);
            }
            return A;
          };
        }
        function q_(p) {
          return ac(function(v) {
            return v = _n3(v, Ts(Ye())), gt(function(k) {
              var E = this;
              return p(v, function(A) {
                return vr(A, E, k);
              });
            });
          });
        }
        function C1(p, v) {
          v = v === n ? " " : Es(v);
          var k = v.length;
          if (k < 2)
            return k ? V_(v, p) : v;
          var E = V_(v, h1(p / Hf(v)));
          return Zf(v) ? Ou(da(E), 0, p).join("") : E.slice(0, p);
        }
        function Zhe(p, v, k, E) {
          var A = v & O, j = Oy(p);
          function W() {
            for (var G = -1, ee = arguments.length, he = -1, fe = E.length, me = oe(fe + ee), be = this && this !== Pt && this instanceof W ? j : p; ++he < fe; )
              me[he] = E[he];
            for (; ee--; )
              me[he++] = arguments[++G];
            return vr(be, A ? k : this, me);
          }
          return W;
        }
        function z4(p) {
          return function(v, k, E) {
            return E && typeof E != "number" && Li(v, k, E) && (k = E = n), v = uc(v), k === n ? (k = v, v = 0) : k = uc(k), E = E === n ? v < k ? 1 : -1 : uc(E), Ahe(v, k, E, p);
          };
        }
        function _1(p) {
          return function(v, k) {
            return typeof v == "string" && typeof k == "string" || (v = Co(v), k = Co(k)), p(v, k);
          };
        }
        function F4(p, v, k, E, A, j, W, G, ee, he) {
          var fe = v & x, me = fe ? W : n, be = fe ? n : W, je = fe ? j : n, qe = fe ? n : j;
          v |= fe ? C : _, v &= ~(fe ? _ : C), v & w || (v &= ~(O | S));
          var ht = [
            p,
            v,
            A,
            je,
            me,
            qe,
            be,
            G,
            ee,
            he
          ], Ke = k.apply(n, ht);
          return sT(p) && J4(Ke, ht), Ke.placeholder = E, eQ(Ke, p, v);
        }
        function K_(p) {
          var v = dr[p];
          return function(k, E) {
            if (k = Co(k), E = E == null ? 0 : ti(dt(E), 292), E && e4(k)) {
              var A = (Nt(k) + "e").split("e"), j = v(A[0] + "e" + (+A[1] + E));
              return A = (Nt(j) + "e").split("e"), +(A[0] + "e" + (+A[1] - E));
            }
            return v(k);
          };
        }
        var Hhe = qf && 1 / n1(new qf([
          ,
          -0
        ]))[1] == Z ? function(p) {
          return new qf(p);
        } : ST;
        function B4(p) {
          return function(v) {
            var k = ni(v);
            return k == Lt ? T_(v) : k == ei ? dde(v) : rde(v, p(v));
          };
        }
        function oc(p, v, k, E, A, j, W, G) {
          var ee = v & S;
          if (!ee && typeof p != "function")
            throw new wo(o);
          var he = E ? E.length : 0;
          if (he || (v &= ~(C | _), E = A = n), W = W === n ? W : hr(dt(W), 0), G = G === n ? G : dt(G), he -= A ? A.length : 0, v & _) {
            var fe = E, me = A;
            E = A = n;
          }
          var be = ee ? n : tT(p), je = [
            p,
            v,
            k,
            E,
            A,
            fe,
            me,
            j,
            W,
            G
          ];
          if (be && cfe(je, be), p = je[0], v = je[1], k = je[2], E = je[3], A = je[4], G = je[9] = je[9] === n ? ee ? 0 : p.length : hr(je[9] - he, 0), !G && v & (x | P) && (v &= ~(x | P)), !v || v == O)
            var qe = Xhe(p, v, k);
          else
            v == x || v == P ? qe = Whe(p, v, G) : (v == C || v == (O | C)) && !A.length ? qe = Zhe(p, v, k, E) : qe = k1.apply(n, je);
          var ht = be ? x4 : J4;
          return eQ(ht(qe, je), p, v);
        }
        function U4(p, v, k, E) {
          return p === n || fa(p, Gf[k]) && !Xt.call(E, k) ? v : p;
        }
        function V4(p, v, k, E, A, j) {
          return $n(p) && $n(v) && (j.set(v, p), S1(p, v, n, V4, j), j.delete(v)), p;
        }
        function Yhe(p) {
          return xy(p) ? n : p;
        }
        function X4(p, v, k, E, A, j) {
          var W = k & y, G = p.length, ee = v.length;
          if (G != ee && !(W && ee > G))
            return false;
          var he = j.get(p), fe = j.get(v);
          if (he && fe)
            return he == v && fe == p;
          var me = -1, be = true, je = k & g ? new ih() : n;
          for (j.set(p, v), j.set(v, p); ++me < G; ) {
            var qe = p[me], ht = v[me];
            if (E)
              var Ke = W ? E(ht, qe, me, v, p, j) : E(qe, ht, me, p, v, j);
            if (Ke !== n) {
              if (Ke)
                continue;
              be = false;
              break;
            }
            if (je) {
              if (!x_(v, function(vt, Ct) {
                if (!ly(je, Ct) && (qe === vt || A(qe, vt, k, E, j)))
                  return je.push(Ct);
              })) {
                be = false;
                break;
              }
            } else if (!(qe === ht || A(qe, ht, k, E, j))) {
              be = false;
              break;
            }
          }
          return j.delete(p), j.delete(v), be;
        }
        function Ghe(p, v, k, E, A, j, W) {
          switch (k) {
            case Ri:
              if (p.byteLength != v.byteLength || p.byteOffset != v.byteOffset)
                return false;
              p = p.buffer, v = v.buffer;
            case yo:
              return !(p.byteLength != v.byteLength || !j(new l1(p), new l1(v)));
            case pt:
            case kt:
            case tr:
              return fa(+p, +v);
            case Ar:
              return p.name == v.name && p.message == v.message;
            case Jr:
            case Cs:
              return p == v + "";
            case Lt:
              var G = T_;
            case ei:
              var ee = E & y;
              if (G || (G = n1), p.size != v.size && !ee)
                return false;
              var he = W.get(p);
              if (he)
                return he == v;
              E |= g, W.set(p, v);
              var fe = X4(G(p), G(v), E, A, j, W);
              return W.delete(p), fe;
            case cu:
              if (fy)
                return fy.call(p) == fy.call(v);
          }
          return false;
        }
        function qhe(p, v, k, E, A, j) {
          var W = k & y, G = J_(p), ee = G.length, he = J_(v), fe = he.length;
          if (ee != fe && !W)
            return false;
          for (var me = ee; me--; ) {
            var be = G[me];
            if (!(W ? be in v : Xt.call(v, be)))
              return false;
          }
          var je = j.get(p), qe = j.get(v);
          if (je && qe)
            return je == v && qe == p;
          var ht = true;
          j.set(p, v), j.set(v, p);
          for (var Ke = W; ++me < ee; ) {
            be = G[me];
            var vt = p[be], Ct = v[be];
            if (E)
              var $s = W ? E(Ct, vt, be, v, p, j) : E(vt, Ct, be, p, v, j);
            if (!($s === n ? vt === Ct || A(vt, Ct, k, E, j) : $s)) {
              ht = false;
              break;
            }
            Ke || (Ke = be == "constructor");
          }
          if (ht && !Ke) {
            var ji = p.constructor, As = v.constructor;
            ji != As && "constructor" in p && "constructor" in v && !(typeof ji == "function" && ji instanceof ji && typeof As == "function" && As instanceof As) && (ht = false);
          }
          return j.delete(p), j.delete(v), ht;
        }
        function ac(p) {
          return aT(q4(p, n, oQ), p + "");
        }
        function J_(p) {
          return d4(p, Or, rT);
        }
        function eT(p) {
          return d4(p, ts, W4);
        }
        var tT = p1 ? function(p) {
          return p1.get(p);
        } : ST;
        function T1(p) {
          for (var v = p.name + "", k = Kf[v], E = Xt.call(Kf, v) ? k.length : 0; E--; ) {
            var A = k[E], j = A.func;
            if (j == null || j == p)
              return A.name;
          }
          return v;
        }
        function np(p) {
          var v = Xt.call(D, "placeholder") ? D : p;
          return v.placeholder;
        }
        function Ye() {
          var p = D.iteratee || vT;
          return p = p === vT ? p4 : p, arguments.length ? p(arguments[0], arguments[1]) : p;
        }
        function E1(p, v) {
          var k = p.__data__;
          return sfe(v) ? k[typeof v == "string" ? "string" : "hash"] : k.map;
        }
        function nT(p) {
          for (var v = Or(p), k = v.length; k--; ) {
            var E = v[k], A = p[E];
            v[k] = [
              E,
              A,
              Y4(A)
            ];
          }
          return v;
        }
        function ah(p, v) {
          var k = lde(p, v);
          return f4(k) ? k : n;
        }
        function Khe(p) {
          var v = Xt.call(p, nh), k = p[nh];
          try {
            p[nh] = n;
            var E = true;
          } catch {
          }
          var A = o1.call(p);
          return E && (v ? p[nh] = k : delete p[nh]), A;
        }
        var rT = I_ ? function(p) {
          return p == null ? [] : (p = nn(p), hu(I_(p), function(v) {
            return KN.call(p, v);
          }));
        } : wT, W4 = I_ ? function(p) {
          for (var v = []; p; )
            fu(v, rT(p)), p = c1(p);
          return v;
        } : wT, ni = Di;
        ($_ && ni(new $_(new ArrayBuffer(1))) != Ri || uy && ni(new uy()) != Lt || A_ && ni(A_.resolve()) != go || qf && ni(new qf()) != ei || dy && ni(new dy()) != Kl) && (ni = function(p) {
          var v = Di(p), k = v == nr ? p.constructor : n, E = k ? lh(k) : "";
          if (E)
            switch (E) {
              case Mde:
                return Ri;
              case Dde:
                return Lt;
              case Lde:
                return go;
              case jde:
                return ei;
              case Nde:
                return Kl;
            }
          return v;
        });
        function Jhe(p, v, k) {
          for (var E = -1, A = k.length; ++E < A; ) {
            var j = k[E], W = j.size;
            switch (j.type) {
              case "drop":
                p += W;
                break;
              case "dropRight":
                v -= W;
                break;
              case "take":
                v = ti(v, p + W);
                break;
              case "takeRight":
                p = hr(p, v - W);
                break;
            }
          }
          return {
            start: p,
            end: v
          };
        }
        function efe(p) {
          var v = p.match(ec);
          return v ? v[1].split(q2) : [];
        }
        function Z4(p, v, k) {
          v = vu(v, p);
          for (var E = -1, A = v.length, j = false; ++E < A; ) {
            var W = nl(v[E]);
            if (!(j = p != null && k(p, W)))
              break;
            p = p[W];
          }
          return j || ++E != A ? j : (A = p == null ? 0 : p.length, !!A && L1(A) && lc(W, A) && (at(p) || ch(p)));
        }
        function tfe(p) {
          var v = p.length, k = new p.constructor(v);
          return v && typeof p[0] == "string" && Xt.call(p, "index") && (k.index = p.index, k.input = p.input), k;
        }
        function H4(p) {
          return typeof p.constructor == "function" && !Sy(p) ? Jf(c1(p)) : {};
        }
        function nfe(p, v, k) {
          var E = p.constructor;
          switch (v) {
            case yo:
              return G_(p);
            case pt:
            case kt:
              return new E(+p);
            case Ri:
              return Qhe(p, k);
            case Af:
            case qi:
            case Rf:
            case Mf:
            case qm:
            case Df:
            case uu:
            case Lf:
            case jf:
              return I4(p, k);
            case Lt:
              return new E();
            case tr:
            case Cs:
              return new E(p);
            case Jr:
              return zhe(p);
            case ei:
              return new E();
            case cu:
              return Fhe(p);
          }
        }
        function rfe(p, v) {
          var k = v.length;
          if (!k)
            return p;
          var E = k - 1;
          return v[E] = (k > 1 ? "& " : "") + v[E], v = v.join(k > 2 ? ", " : " "), p.replace(ry, `{
/* [wrapped with ` + v + `] */
`);
        }
        function ife(p) {
          return at(p) || ch(p) || !!(JN && p && p[JN]);
        }
        function lc(p, v) {
          var k = typeof p;
          return v = v ?? U, !!v && (k == "number" || k != "symbol" && o_.test(p)) && p > -1 && p % 1 == 0 && p < v;
        }
        function Li(p, v, k) {
          if (!$n(k))
            return false;
          var E = typeof v;
          return (E == "number" ? es(k) && lc(v, k.length) : E == "string" && v in k) ? fa(k[v], p) : false;
        }
        function iT(p, v) {
          if (at(p))
            return false;
          var k = typeof p;
          return k == "number" || k == "symbol" || k == "boolean" || p == null || Is(p) ? true : H2.test(p) || !Gd.test(p) || v != null && p in nn(v);
        }
        function sfe(p) {
          var v = typeof p;
          return v == "string" || v == "number" || v == "symbol" || v == "boolean" ? p !== "__proto__" : p === null;
        }
        function sT(p) {
          var v = T1(p), k = D[v];
          if (typeof k != "function" || !(v in wt.prototype))
            return false;
          if (p === k)
            return true;
          var E = tT(k);
          return !!E && p === E[0];
        }
        function ofe(p) {
          return !!YN && YN in p;
        }
        var afe = i1 ? cc : xT;
        function Sy(p) {
          var v = p && p.constructor, k = typeof v == "function" && v.prototype || Gf;
          return p === k;
        }
        function Y4(p) {
          return p === p && !$n(p);
        }
        function G4(p, v) {
          return function(k) {
            return k == null ? false : k[p] === v && (v !== n || p in nn(k));
          };
        }
        function lfe(p) {
          var v = M1(p, function(E) {
            return k.size === c && k.clear(), E;
          }), k = v.cache;
          return v;
        }
        function cfe(p, v) {
          var k = p[1], E = v[1], A = k | E, j = A < (O | S | T), W = E == T && k == x || E == T && k == $ && p[7].length <= v[8] || E == (T | $) && v[7].length <= v[8] && k == x;
          if (!(j || W))
            return p;
          E & O && (p[2] = v[2], A |= k & O ? 0 : w);
          var G = v[3];
          if (G) {
            var ee = p[3];
            p[3] = ee ? A4(ee, G, v[4]) : G, p[4] = ee ? pu(p[3], u) : v[4];
          }
          return G = v[5], G && (ee = p[5], p[5] = ee ? R4(ee, G, v[6]) : G, p[6] = ee ? pu(p[5], u) : v[6]), G = v[7], G && (p[7] = G), E & T && (p[8] = p[8] == null ? v[8] : ti(p[8], v[8])), p[9] == null && (p[9] = v[9]), p[0] = v[0], p[1] = A, p;
        }
        function ufe(p) {
          var v = [];
          if (p != null)
            for (var k in nn(p))
              v.push(k);
          return v;
        }
        function dfe(p) {
          return o1.call(p);
        }
        function q4(p, v, k) {
          return v = hr(v === n ? p.length - 1 : v, 0), function() {
            for (var E = arguments, A = -1, j = hr(E.length - v, 0), W = oe(j); ++A < j; )
              W[A] = E[v + A];
            A = -1;
            for (var G = oe(v + 1); ++A < v; )
              G[A] = E[A];
            return G[v] = k(W), vr(p, this, G);
          };
        }
        function K4(p, v) {
          return v.length < 2 ? p : oh(p, ko(v, 0, -1));
        }
        function hfe(p, v) {
          for (var k = p.length, E = ti(v.length, k), A = Ji(p); E--; ) {
            var j = v[E];
            p[E] = lc(j, k) ? A[j] : n;
          }
          return p;
        }
        function oT(p, v) {
          if (!(v === "constructor" && typeof p[v] == "function") && v != "__proto__")
            return p[v];
        }
        var J4 = tQ(x4), wy = _de || function(p, v) {
          return Pt.setTimeout(p, v);
        }, aT = tQ(Dhe);
        function eQ(p, v, k) {
          var E = v + "";
          return aT(p, rfe(E, ffe(efe(E), k)));
        }
        function tQ(p) {
          var v = 0, k = 0;
          return function() {
            var E = $de(), A = R - (E - k);
            if (k = E, A > 0) {
              if (++v >= M)
                return arguments[0];
            } else
              v = 0;
            return p.apply(n, arguments);
          };
        }
        function I1(p, v) {
          var k = -1, E = p.length, A = E - 1;
          for (v = v === n ? E : v; ++k < v; ) {
            var j = U_(k, A), W = p[j];
            p[j] = p[k], p[k] = W;
          }
          return p.length = v, p;
        }
        var nQ = lfe(function(p) {
          var v = [];
          return p.charCodeAt(0) === 46 && v.push(""), p.replace(Y2, function(k, E, A, j) {
            v.push(A ? j.replace(e_, "$1") : E || k);
          }), v;
        });
        function nl(p) {
          if (typeof p == "string" || Is(p))
            return p;
          var v = p + "";
          return v == "0" && 1 / p == -Z ? "-0" : v;
        }
        function lh(p) {
          if (p != null) {
            try {
              return s1.call(p);
            } catch {
            }
            try {
              return p + "";
            } catch {
            }
          }
          return "";
        }
        function ffe(p, v) {
          return So(Me, function(k) {
            var E = "_." + k[0];
            v & k[1] && !e1(p, E) && p.push(E);
          }), p.sort();
        }
        function rQ(p) {
          if (p instanceof wt)
            return p.clone();
          var v = new xo(p.__wrapped__, p.__chain__);
          return v.__actions__ = Ji(p.__actions__), v.__index__ = p.__index__, v.__values__ = p.__values__, v;
        }
        function pfe(p, v, k) {
          (k ? Li(p, v, k) : v === n) ? v = 1 : v = hr(dt(v), 0);
          var E = p == null ? 0 : p.length;
          if (!E || v < 1)
            return [];
          for (var A = 0, j = 0, W = oe(h1(E / v)); A < E; )
            W[j++] = ko(p, A, A += v);
          return W;
        }
        function gfe(p) {
          for (var v = -1, k = p == null ? 0 : p.length, E = 0, A = []; ++v < k; ) {
            var j = p[v];
            j && (A[E++] = j);
          }
          return A;
        }
        function mfe() {
          var p = arguments.length;
          if (!p)
            return [];
          for (var v = oe(p - 1), k = arguments[0], E = p; E--; )
            v[E - 1] = arguments[E];
          return fu(at(k) ? Ji(k) : [
            k
          ], Rr(v, 1));
        }
        var yfe = gt(function(p, v) {
          return Wn(p) ? gy(p, Rr(v, 1, Wn, true)) : [];
        }), vfe = gt(function(p, v) {
          var k = Po(v);
          return Wn(k) && (k = n), Wn(p) ? gy(p, Rr(v, 1, Wn, true), Ye(k, 2)) : [];
        }), Ofe = gt(function(p, v) {
          var k = Po(v);
          return Wn(k) && (k = n), Wn(p) ? gy(p, Rr(v, 1, Wn, true), n, k) : [];
        });
        function Sfe(p, v, k) {
          var E = p == null ? 0 : p.length;
          return E ? (v = k || v === n ? 1 : dt(v), ko(p, v < 0 ? 0 : v, E)) : [];
        }
        function wfe(p, v, k) {
          var E = p == null ? 0 : p.length;
          return E ? (v = k || v === n ? 1 : dt(v), v = E - v, ko(p, 0, v < 0 ? 0 : v)) : [];
        }
        function xfe(p, v) {
          return p && p.length ? x1(p, Ye(v, 3), true, true) : [];
        }
        function bfe(p, v) {
          return p && p.length ? x1(p, Ye(v, 3), true) : [];
        }
        function kfe(p, v, k, E) {
          var A = p == null ? 0 : p.length;
          return A ? (k && typeof k != "number" && Li(p, v, k) && (k = 0, E = A), mhe(p, v, k, E)) : [];
        }
        function iQ(p, v, k) {
          var E = p == null ? 0 : p.length;
          if (!E)
            return -1;
          var A = k == null ? 0 : dt(k);
          return A < 0 && (A = hr(E + A, 0)), t1(p, Ye(v, 3), A);
        }
        function sQ(p, v, k) {
          var E = p == null ? 0 : p.length;
          if (!E)
            return -1;
          var A = E - 1;
          return k !== n && (A = dt(k), A = k < 0 ? hr(E + A, 0) : ti(A, E - 1)), t1(p, Ye(v, 3), A, true);
        }
        function oQ(p) {
          var v = p == null ? 0 : p.length;
          return v ? Rr(p, 1) : [];
        }
        function Pfe(p) {
          var v = p == null ? 0 : p.length;
          return v ? Rr(p, Z) : [];
        }
        function Cfe(p, v) {
          var k = p == null ? 0 : p.length;
          return k ? (v = v === n ? 1 : dt(v), Rr(p, v)) : [];
        }
        function _fe(p) {
          for (var v = -1, k = p == null ? 0 : p.length, E = {}; ++v < k; ) {
            var A = p[v];
            E[A[0]] = A[1];
          }
          return E;
        }
        function aQ(p) {
          return p && p.length ? p[0] : n;
        }
        function Tfe(p, v, k) {
          var E = p == null ? 0 : p.length;
          if (!E)
            return -1;
          var A = k == null ? 0 : dt(k);
          return A < 0 && (A = hr(E + A, 0)), Wf(p, v, A);
        }
        function Efe(p) {
          var v = p == null ? 0 : p.length;
          return v ? ko(p, 0, -1) : [];
        }
        var Ife = gt(function(p) {
          var v = _n3(p, H_);
          return v.length && v[0] === p[0] ? N_(v) : [];
        }), $fe = gt(function(p) {
          var v = Po(p), k = _n3(p, H_);
          return v === Po(k) ? v = n : k.pop(), k.length && k[0] === p[0] ? N_(k, Ye(v, 2)) : [];
        }), Afe = gt(function(p) {
          var v = Po(p), k = _n3(p, H_);
          return v = typeof v == "function" ? v : n, v && k.pop(), k.length && k[0] === p[0] ? N_(k, n, v) : [];
        });
        function Rfe(p, v) {
          return p == null ? "" : Ede.call(p, v);
        }
        function Po(p) {
          var v = p == null ? 0 : p.length;
          return v ? p[v - 1] : n;
        }
        function Mfe(p, v, k) {
          var E = p == null ? 0 : p.length;
          if (!E)
            return -1;
          var A = E;
          return k !== n && (A = dt(k), A = A < 0 ? hr(E + A, 0) : ti(A, E - 1)), v === v ? fde(p, v, A) : t1(p, FN, A, true);
        }
        function Dfe(p, v) {
          return p && p.length ? v4(p, dt(v)) : n;
        }
        var Lfe = gt(lQ);
        function lQ(p, v) {
          return p && p.length && v && v.length ? B_(p, v) : p;
        }
        function jfe(p, v, k) {
          return p && p.length && v && v.length ? B_(p, v, Ye(k, 2)) : p;
        }
        function Nfe(p, v, k) {
          return p && p.length && v && v.length ? B_(p, v, n, k) : p;
        }
        var Qfe = ac(function(p, v) {
          var k = p == null ? 0 : p.length, E = M_(p, v);
          return w4(p, _n3(v, function(A) {
            return lc(A, k) ? +A : A;
          }).sort($4)), E;
        });
        function zfe(p, v) {
          var k = [];
          if (!(p && p.length))
            return k;
          var E = -1, A = [], j = p.length;
          for (v = Ye(v, 3); ++E < j; ) {
            var W = p[E];
            v(W, E, p) && (k.push(W), A.push(E));
          }
          return w4(p, A), k;
        }
        function lT(p) {
          return p == null ? p : Rde.call(p);
        }
        function Ffe(p, v, k) {
          var E = p == null ? 0 : p.length;
          return E ? (k && typeof k != "number" && Li(p, v, k) ? (v = 0, k = E) : (v = v == null ? 0 : dt(v), k = k === n ? E : dt(k)), ko(p, v, k)) : [];
        }
        function Bfe(p, v) {
          return w1(p, v);
        }
        function Ufe(p, v, k) {
          return X_(p, v, Ye(k, 2));
        }
        function Vfe(p, v) {
          var k = p == null ? 0 : p.length;
          if (k) {
            var E = w1(p, v);
            if (E < k && fa(p[E], v))
              return E;
          }
          return -1;
        }
        function Xfe(p, v) {
          return w1(p, v, true);
        }
        function Wfe(p, v, k) {
          return X_(p, v, Ye(k, 2), true);
        }
        function Zfe(p, v) {
          var k = p == null ? 0 : p.length;
          if (k) {
            var E = w1(p, v, true) - 1;
            if (fa(p[E], v))
              return E;
          }
          return -1;
        }
        function Hfe(p) {
          return p && p.length ? b4(p) : [];
        }
        function Yfe(p, v) {
          return p && p.length ? b4(p, Ye(v, 2)) : [];
        }
        function Gfe(p) {
          var v = p == null ? 0 : p.length;
          return v ? ko(p, 1, v) : [];
        }
        function qfe(p, v, k) {
          return p && p.length ? (v = k || v === n ? 1 : dt(v), ko(p, 0, v < 0 ? 0 : v)) : [];
        }
        function Kfe(p, v, k) {
          var E = p == null ? 0 : p.length;
          return E ? (v = k || v === n ? 1 : dt(v), v = E - v, ko(p, v < 0 ? 0 : v, E)) : [];
        }
        function Jfe(p, v) {
          return p && p.length ? x1(p, Ye(v, 3), false, true) : [];
        }
        function epe(p, v) {
          return p && p.length ? x1(p, Ye(v, 3)) : [];
        }
        var tpe = gt(function(p) {
          return yu(Rr(p, 1, Wn, true));
        }), npe = gt(function(p) {
          var v = Po(p);
          return Wn(v) && (v = n), yu(Rr(p, 1, Wn, true), Ye(v, 2));
        }), rpe = gt(function(p) {
          var v = Po(p);
          return v = typeof v == "function" ? v : n, yu(Rr(p, 1, Wn, true), n, v);
        });
        function ipe(p) {
          return p && p.length ? yu(p) : [];
        }
        function spe(p, v) {
          return p && p.length ? yu(p, Ye(v, 2)) : [];
        }
        function ope(p, v) {
          return v = typeof v == "function" ? v : n, p && p.length ? yu(p, n, v) : [];
        }
        function cT(p) {
          if (!(p && p.length))
            return [];
          var v = 0;
          return p = hu(p, function(k) {
            if (Wn(k))
              return v = hr(k.length, v), true;
          }), C_(v, function(k) {
            return _n3(p, b_(k));
          });
        }
        function cQ(p, v) {
          if (!(p && p.length))
            return [];
          var k = cT(p);
          return v == null ? k : _n3(k, function(E) {
            return vr(v, n, E);
          });
        }
        var ape = gt(function(p, v) {
          return Wn(p) ? gy(p, v) : [];
        }), lpe = gt(function(p) {
          return Z_(hu(p, Wn));
        }), cpe = gt(function(p) {
          var v = Po(p);
          return Wn(v) && (v = n), Z_(hu(p, Wn), Ye(v, 2));
        }), upe = gt(function(p) {
          var v = Po(p);
          return v = typeof v == "function" ? v : n, Z_(hu(p, Wn), n, v);
        }), dpe = gt(cT);
        function hpe(p, v) {
          return _4(p || [], v || [], py);
        }
        function fpe(p, v) {
          return _4(p || [], v || [], vy);
        }
        var ppe = gt(function(p) {
          var v = p.length, k = v > 1 ? p[v - 1] : n;
          return k = typeof k == "function" ? (p.pop(), k) : n, cQ(p, k);
        });
        function uQ(p) {
          var v = D(p);
          return v.__chain__ = true, v;
        }
        function gpe(p, v) {
          return v(p), p;
        }
        function $1(p, v) {
          return v(p);
        }
        var mpe = ac(function(p) {
          var v = p.length, k = v ? p[0] : 0, E = this.__wrapped__, A = function(j) {
            return M_(j, p);
          };
          return v > 1 || this.__actions__.length || !(E instanceof wt) || !lc(k) ? this.thru(A) : (E = E.slice(k, +k + (v ? 1 : 0)), E.__actions__.push({
            func: $1,
            args: [
              A
            ],
            thisArg: n
          }), new xo(E, this.__chain__).thru(function(j) {
            return v && !j.length && j.push(n), j;
          }));
        });
        function ype() {
          return uQ(this);
        }
        function vpe() {
          return new xo(this.value(), this.__chain__);
        }
        function Ope() {
          this.__values__ === n && (this.__values__ = kQ(this.value()));
          var p = this.__index__ >= this.__values__.length, v = p ? n : this.__values__[this.__index__++];
          return {
            done: p,
            value: v
          };
        }
        function Spe() {
          return this;
        }
        function wpe(p) {
          for (var v, k = this; k instanceof m1; ) {
            var E = rQ(k);
            E.__index__ = 0, E.__values__ = n, v ? A.__wrapped__ = E : v = E;
            var A = E;
            k = k.__wrapped__;
          }
          return A.__wrapped__ = p, v;
        }
        function xpe() {
          var p = this.__wrapped__;
          if (p instanceof wt) {
            var v = p;
            return this.__actions__.length && (v = new wt(this)), v = v.reverse(), v.__actions__.push({
              func: $1,
              args: [
                lT
              ],
              thisArg: n
            }), new xo(v, this.__chain__);
          }
          return this.thru(lT);
        }
        function bpe() {
          return C4(this.__wrapped__, this.__actions__);
        }
        var kpe = b1(function(p, v, k) {
          Xt.call(p, k) ? ++p[k] : sc(p, k, 1);
        });
        function Ppe(p, v, k) {
          var E = at(p) ? QN : ghe;
          return k && Li(p, v, k) && (v = n), E(p, Ye(v, 3));
        }
        function Cpe(p, v) {
          var k = at(p) ? hu : c4;
          return k(p, Ye(v, 3));
        }
        var _pe = j4(iQ), Tpe = j4(sQ);
        function Epe(p, v) {
          return Rr(A1(p, v), 1);
        }
        function Ipe(p, v) {
          return Rr(A1(p, v), Z);
        }
        function $pe(p, v, k) {
          return k = k === n ? 1 : dt(k), Rr(A1(p, v), k);
        }
        function dQ(p, v) {
          var k = at(p) ? So : mu;
          return k(p, Ye(v, 3));
        }
        function hQ(p, v) {
          var k = at(p) ? Gue : l4;
          return k(p, Ye(v, 3));
        }
        var Ape = b1(function(p, v, k) {
          Xt.call(p, k) ? p[k].push(v) : sc(p, k, [
            v
          ]);
        });
        function Rpe(p, v, k, E) {
          p = es(p) ? p : ip(p), k = k && !E ? dt(k) : 0;
          var A = p.length;
          return k < 0 && (k = hr(A + k, 0)), j1(p) ? k <= A && p.indexOf(v, k) > -1 : !!A && Wf(p, v, k) > -1;
        }
        var Mpe = gt(function(p, v, k) {
          var E = -1, A = typeof v == "function", j = es(p) ? oe(p.length) : [];
          return mu(p, function(W) {
            j[++E] = A ? vr(v, W, k) : my(W, v, k);
          }), j;
        }), Dpe = b1(function(p, v, k) {
          sc(p, k, v);
        });
        function A1(p, v) {
          var k = at(p) ? _n3 : g4;
          return k(p, Ye(v, 3));
        }
        function Lpe(p, v, k, E) {
          return p == null ? [] : (at(v) || (v = v == null ? [] : [
            v
          ]), k = E ? n : k, at(k) || (k = k == null ? [] : [
            k
          ]), O4(p, v, k));
        }
        var jpe = b1(function(p, v, k) {
          p[k ? 0 : 1].push(v);
        }, function() {
          return [
            [],
            []
          ];
        });
        function Npe(p, v, k) {
          var E = at(p) ? w_ : UN, A = arguments.length < 3;
          return E(p, Ye(v, 4), k, A, mu);
        }
        function Qpe(p, v, k) {
          var E = at(p) ? que : UN, A = arguments.length < 3;
          return E(p, Ye(v, 4), k, A, l4);
        }
        function zpe(p, v) {
          var k = at(p) ? hu : c4;
          return k(p, D1(Ye(v, 3)));
        }
        function Fpe(p) {
          var v = at(p) ? i4 : Rhe;
          return v(p);
        }
        function Bpe(p, v, k) {
          (k ? Li(p, v, k) : v === n) ? v = 1 : v = dt(v);
          var E = at(p) ? uhe : Mhe;
          return E(p, v);
        }
        function Upe(p) {
          var v = at(p) ? dhe : Lhe;
          return v(p);
        }
        function Vpe(p) {
          if (p == null)
            return 0;
          if (es(p))
            return j1(p) ? Hf(p) : p.length;
          var v = ni(p);
          return v == Lt || v == ei ? p.size : z_(p).length;
        }
        function Xpe(p, v, k) {
          var E = at(p) ? x_ : jhe;
          return k && Li(p, v, k) && (v = n), E(p, Ye(v, 3));
        }
        var Wpe = gt(function(p, v) {
          if (p == null)
            return [];
          var k = v.length;
          return k > 1 && Li(p, v[0], v[1]) ? v = [] : k > 2 && Li(v[0], v[1], v[2]) && (v = [
            v[0]
          ]), O4(p, Rr(v, 1), []);
        }), R1 = Cde || function() {
          return Pt.Date.now();
        };
        function Zpe(p, v) {
          if (typeof v != "function")
            throw new wo(o);
          return p = dt(p), function() {
            if (--p < 1)
              return v.apply(this, arguments);
          };
        }
        function fQ(p, v, k) {
          return v = k ? n : v, v = p && v == null ? p.length : v, oc(p, T, n, n, n, n, v);
        }
        function pQ(p, v) {
          var k;
          if (typeof v != "function")
            throw new wo(o);
          return p = dt(p), function() {
            return --p > 0 && (k = v.apply(this, arguments)), p <= 1 && (v = n), k;
          };
        }
        var uT = gt(function(p, v, k) {
          var E = O;
          if (k.length) {
            var A = pu(k, np(uT));
            E |= C;
          }
          return oc(p, E, v, k, A);
        }), gQ = gt(function(p, v, k) {
          var E = O | S;
          if (k.length) {
            var A = pu(k, np(gQ));
            E |= C;
          }
          return oc(v, E, p, k, A);
        });
        function mQ(p, v, k) {
          v = k ? n : v;
          var E = oc(p, x, n, n, n, n, n, v);
          return E.placeholder = mQ.placeholder, E;
        }
        function yQ(p, v, k) {
          v = k ? n : v;
          var E = oc(p, P, n, n, n, n, n, v);
          return E.placeholder = yQ.placeholder, E;
        }
        function vQ(p, v, k) {
          var E, A, j, W, G, ee, he = 0, fe = false, me = false, be = true;
          if (typeof p != "function")
            throw new wo(o);
          v = Co(v) || 0, $n(k) && (fe = !!k.leading, me = "maxWait" in k, j = me ? hr(Co(k.maxWait) || 0, v) : j, be = "trailing" in k ? !!k.trailing : be);
          function je(Zn) {
            var pa = E, dc = A;
            return E = A = n, he = Zn, W = p.apply(dc, pa), W;
          }
          function qe(Zn) {
            return he = Zn, G = wy(vt, v), fe ? je(Zn) : W;
          }
          function ht(Zn) {
            var pa = Zn - ee, dc = Zn - he, jQ = v - pa;
            return me ? ti(jQ, j - dc) : jQ;
          }
          function Ke(Zn) {
            var pa = Zn - ee, dc = Zn - he;
            return ee === n || pa >= v || pa < 0 || me && dc >= j;
          }
          function vt() {
            var Zn = R1();
            if (Ke(Zn))
              return Ct(Zn);
            G = wy(vt, ht(Zn));
          }
          function Ct(Zn) {
            return G = n, be && E ? je(Zn) : (E = A = n, W);
          }
          function $s() {
            G !== n && T4(G), he = 0, E = ee = A = G = n;
          }
          function ji() {
            return G === n ? W : Ct(R1());
          }
          function As() {
            var Zn = R1(), pa = Ke(Zn);
            if (E = arguments, A = this, ee = Zn, pa) {
              if (G === n)
                return qe(ee);
              if (me)
                return T4(G), G = wy(vt, v), je(ee);
            }
            return G === n && (G = wy(vt, v)), W;
          }
          return As.cancel = $s, As.flush = ji, As;
        }
        var Hpe = gt(function(p, v) {
          return a4(p, 1, v);
        }), Ype = gt(function(p, v, k) {
          return a4(p, Co(v) || 0, k);
        });
        function Gpe(p) {
          return oc(p, N);
        }
        function M1(p, v) {
          if (typeof p != "function" || v != null && typeof v != "function")
            throw new wo(o);
          var k = function() {
            var E = arguments, A = v ? v.apply(this, E) : E[0], j = k.cache;
            if (j.has(A))
              return j.get(A);
            var W = p.apply(this, E);
            return k.cache = j.set(A, W) || j, W;
          };
          return k.cache = new (M1.Cache || ic)(), k;
        }
        M1.Cache = ic;
        function D1(p) {
          if (typeof p != "function")
            throw new wo(o);
          return function() {
            var v = arguments;
            switch (v.length) {
              case 0:
                return !p.call(this);
              case 1:
                return !p.call(this, v[0]);
              case 2:
                return !p.call(this, v[0], v[1]);
              case 3:
                return !p.call(this, v[0], v[1], v[2]);
            }
            return !p.apply(this, v);
          };
        }
        function qpe(p) {
          return pQ(2, p);
        }
        var Kpe = Nhe(function(p, v) {
          v = v.length == 1 && at(v[0]) ? _n3(v[0], Ts(Ye())) : _n3(Rr(v, 1), Ts(Ye()));
          var k = v.length;
          return gt(function(E) {
            for (var A = -1, j = ti(E.length, k); ++A < j; )
              E[A] = v[A].call(this, E[A]);
            return vr(p, this, E);
          });
        }), dT = gt(function(p, v) {
          var k = pu(v, np(dT));
          return oc(p, C, n, v, k);
        }), OQ = gt(function(p, v) {
          var k = pu(v, np(OQ));
          return oc(p, _, n, v, k);
        }), Jpe = ac(function(p, v) {
          return oc(p, $, n, n, n, v);
        });
        function ege(p, v) {
          if (typeof p != "function")
            throw new wo(o);
          return v = v === n ? v : dt(v), gt(p, v);
        }
        function tge(p, v) {
          if (typeof p != "function")
            throw new wo(o);
          return v = v == null ? 0 : hr(dt(v), 0), gt(function(k) {
            var E = k[v], A = Ou(k, 0, v);
            return E && fu(A, E), vr(p, this, A);
          });
        }
        function nge(p, v, k) {
          var E = true, A = true;
          if (typeof p != "function")
            throw new wo(o);
          return $n(k) && (E = "leading" in k ? !!k.leading : E, A = "trailing" in k ? !!k.trailing : A), vQ(p, v, {
            leading: E,
            maxWait: v,
            trailing: A
          });
        }
        function rge(p) {
          return fQ(p, 1);
        }
        function ige(p, v) {
          return dT(Y_(v), p);
        }
        function sge() {
          if (!arguments.length)
            return [];
          var p = arguments[0];
          return at(p) ? p : [
            p
          ];
        }
        function oge(p) {
          return bo(p, f);
        }
        function age(p, v) {
          return v = typeof v == "function" ? v : n, bo(p, f, v);
        }
        function lge(p) {
          return bo(p, d | f);
        }
        function cge(p, v) {
          return v = typeof v == "function" ? v : n, bo(p, d | f, v);
        }
        function uge(p, v) {
          return v == null || o4(p, v, Or(v));
        }
        function fa(p, v) {
          return p === v || p !== p && v !== v;
        }
        var dge = _1(j_), hge = _1(function(p, v) {
          return p >= v;
        }), ch = h4(function() {
          return arguments;
        }()) ? h4 : function(p) {
          return jn(p) && Xt.call(p, "callee") && !KN.call(p, "callee");
        }, at = oe.isArray, fge = Mi ? Ts(Mi) : whe;
        function es(p) {
          return p != null && L1(p.length) && !cc(p);
        }
        function Wn(p) {
          return jn(p) && es(p);
        }
        function pge(p) {
          return p === true || p === false || jn(p) && Di(p) == pt;
        }
        var Su = Tde || xT, gge = ua ? Ts(ua) : xhe;
        function mge(p) {
          return jn(p) && p.nodeType === 1 && !xy(p);
        }
        function yge(p) {
          if (p == null)
            return true;
          if (es(p) && (at(p) || typeof p == "string" || typeof p.splice == "function" || Su(p) || rp(p) || ch(p)))
            return !p.length;
          var v = ni(p);
          if (v == Lt || v == ei)
            return !p.size;
          if (Sy(p))
            return !z_(p).length;
          for (var k in p)
            if (Xt.call(p, k))
              return false;
          return true;
        }
        function vge(p, v) {
          return yy(p, v);
        }
        function Oge(p, v, k) {
          k = typeof k == "function" ? k : n;
          var E = k ? k(p, v) : n;
          return E === n ? yy(p, v, n, k) : !!E;
        }
        function hT(p) {
          if (!jn(p))
            return false;
          var v = Di(p);
          return v == Ar || v == Yt || typeof p.message == "string" && typeof p.name == "string" && !xy(p);
        }
        function Sge(p) {
          return typeof p == "number" && e4(p);
        }
        function cc(p) {
          if (!$n(p))
            return false;
          var v = Di(p);
          return v == Cn || v == Vn || v == it || v == mo;
        }
        function SQ(p) {
          return typeof p == "number" && p == dt(p);
        }
        function L1(p) {
          return typeof p == "number" && p > -1 && p % 1 == 0 && p <= U;
        }
        function $n(p) {
          var v = typeof p;
          return p != null && (v == "object" || v == "function");
        }
        function jn(p) {
          return p != null && typeof p == "object";
        }
        var wQ = Oo ? Ts(Oo) : khe;
        function wge(p, v) {
          return p === v || Q_(p, v, nT(v));
        }
        function xge(p, v, k) {
          return k = typeof k == "function" ? k : n, Q_(p, v, nT(v), k);
        }
        function bge(p) {
          return xQ(p) && p != +p;
        }
        function kge(p) {
          if (afe(p))
            throw new st(s);
          return f4(p);
        }
        function Pge(p) {
          return p === null;
        }
        function Cge(p) {
          return p == null;
        }
        function xQ(p) {
          return typeof p == "number" || jn(p) && Di(p) == tr;
        }
        function xy(p) {
          if (!jn(p) || Di(p) != nr)
            return false;
          var v = c1(p);
          if (v === null)
            return true;
          var k = Xt.call(v, "constructor") && v.constructor;
          return typeof k == "function" && k instanceof k && s1.call(k) == xde;
        }
        var fT = Ja ? Ts(Ja) : Phe;
        function _ge(p) {
          return SQ(p) && p >= -U && p <= U;
        }
        var bQ = ay ? Ts(ay) : Che;
        function j1(p) {
          return typeof p == "string" || !at(p) && jn(p) && Di(p) == Cs;
        }
        function Is(p) {
          return typeof p == "symbol" || jn(p) && Di(p) == cu;
        }
        var rp = th ? Ts(th) : _he;
        function Tge(p) {
          return p === n;
        }
        function Ege(p) {
          return jn(p) && ni(p) == Kl;
        }
        function Ige(p) {
          return jn(p) && Di(p) == Gm;
        }
        var $ge = _1(F_), Age = _1(function(p, v) {
          return p <= v;
        });
        function kQ(p) {
          if (!p)
            return [];
          if (es(p))
            return j1(p) ? da(p) : Ji(p);
          if (cy && p[cy])
            return ude(p[cy]());
          var v = ni(p), k = v == Lt ? T_ : v == ei ? n1 : ip;
          return k(p);
        }
        function uc(p) {
          if (!p)
            return p === 0 ? p : 0;
          if (p = Co(p), p === Z || p === -Z) {
            var v = p < 0 ? -1 : 1;
            return v * H;
          }
          return p === p ? p : 0;
        }
        function dt(p) {
          var v = uc(p), k = v % 1;
          return v === v ? k ? v - k : v : 0;
        }
        function PQ(p) {
          return p ? sh(dt(p), 0, se) : 0;
        }
        function Co(p) {
          if (typeof p == "number")
            return p;
          if (Is(p))
            return te;
          if ($n(p)) {
            var v = typeof p.valueOf == "function" ? p.valueOf() : p;
            p = $n(v) ? v + "" : v;
          }
          if (typeof p != "string")
            return p === 0 ? p : +p;
          p = VN(p);
          var k = r_.test(p);
          return k || s_.test(p) ? ot(p.slice(2), k ? 2 : 8) : n_.test(p) ? te : +p;
        }
        function CQ(p) {
          return tl(p, ts(p));
        }
        function Rge(p) {
          return p ? sh(dt(p), -U, U) : p === 0 ? p : 0;
        }
        function Nt(p) {
          return p == null ? "" : Es(p);
        }
        var Mge = ep(function(p, v) {
          if (Sy(v) || es(v)) {
            tl(v, Or(v), p);
            return;
          }
          for (var k in v)
            Xt.call(v, k) && py(p, k, v[k]);
        }), _Q = ep(function(p, v) {
          tl(v, ts(v), p);
        }), N1 = ep(function(p, v, k, E) {
          tl(v, ts(v), p, E);
        }), Dge = ep(function(p, v, k, E) {
          tl(v, Or(v), p, E);
        }), Lge = ac(M_);
        function jge(p, v) {
          var k = Jf(p);
          return v == null ? k : s4(k, v);
        }
        var Nge = gt(function(p, v) {
          p = nn(p);
          var k = -1, E = v.length, A = E > 2 ? v[2] : n;
          for (A && Li(v[0], v[1], A) && (E = 1); ++k < E; )
            for (var j = v[k], W = ts(j), G = -1, ee = W.length; ++G < ee; ) {
              var he = W[G], fe = p[he];
              (fe === n || fa(fe, Gf[he]) && !Xt.call(p, he)) && (p[he] = j[he]);
            }
          return p;
        }), Qge = gt(function(p) {
          return p.push(n, V4), vr(TQ, n, p);
        });
        function zge(p, v) {
          return zN(p, Ye(v, 3), el);
        }
        function Fge(p, v) {
          return zN(p, Ye(v, 3), L_);
        }
        function Bge(p, v) {
          return p == null ? p : D_(p, Ye(v, 3), ts);
        }
        function Uge(p, v) {
          return p == null ? p : u4(p, Ye(v, 3), ts);
        }
        function Vge(p, v) {
          return p && el(p, Ye(v, 3));
        }
        function Xge(p, v) {
          return p && L_(p, Ye(v, 3));
        }
        function Wge(p) {
          return p == null ? [] : O1(p, Or(p));
        }
        function Zge(p) {
          return p == null ? [] : O1(p, ts(p));
        }
        function pT(p, v, k) {
          var E = p == null ? n : oh(p, v);
          return E === n ? k : E;
        }
        function Hge(p, v) {
          return p != null && Z4(p, v, yhe);
        }
        function gT(p, v) {
          return p != null && Z4(p, v, vhe);
        }
        var Yge = Q4(function(p, v, k) {
          v != null && typeof v.toString != "function" && (v = o1.call(v)), p[v] = k;
        }, yT(ns)), Gge = Q4(function(p, v, k) {
          v != null && typeof v.toString != "function" && (v = o1.call(v)), Xt.call(p, v) ? p[v].push(k) : p[v] = [
            k
          ];
        }, Ye), qge = gt(my);
        function Or(p) {
          return es(p) ? r4(p) : z_(p);
        }
        function ts(p) {
          return es(p) ? r4(p, true) : The(p);
        }
        function Kge(p, v) {
          var k = {};
          return v = Ye(v, 3), el(p, function(E, A, j) {
            sc(k, v(E, A, j), E);
          }), k;
        }
        function Jge(p, v) {
          var k = {};
          return v = Ye(v, 3), el(p, function(E, A, j) {
            sc(k, A, v(E, A, j));
          }), k;
        }
        var eme = ep(function(p, v, k) {
          S1(p, v, k);
        }), TQ = ep(function(p, v, k, E) {
          S1(p, v, k, E);
        }), tme = ac(function(p, v) {
          var k = {};
          if (p == null)
            return k;
          var E = false;
          v = _n3(v, function(j) {
            return j = vu(j, p), E || (E = j.length > 1), j;
          }), tl(p, eT(p), k), E && (k = bo(k, d | h | f, Yhe));
          for (var A = v.length; A--; )
            W_(k, v[A]);
          return k;
        });
        function nme(p, v) {
          return EQ(p, D1(Ye(v)));
        }
        var rme = ac(function(p, v) {
          return p == null ? {} : Ihe(p, v);
        });
        function EQ(p, v) {
          if (p == null)
            return {};
          var k = _n3(eT(p), function(E) {
            return [
              E
            ];
          });
          return v = Ye(v), S4(p, k, function(E, A) {
            return v(E, A[0]);
          });
        }
        function ime(p, v, k) {
          v = vu(v, p);
          var E = -1, A = v.length;
          for (A || (A = 1, p = n); ++E < A; ) {
            var j = p == null ? n : p[nl(v[E])];
            j === n && (E = A, j = k), p = cc(j) ? j.call(p) : j;
          }
          return p;
        }
        function sme(p, v, k) {
          return p == null ? p : vy(p, v, k);
        }
        function ome(p, v, k, E) {
          return E = typeof E == "function" ? E : n, p == null ? p : vy(p, v, k, E);
        }
        var IQ = B4(Or), $Q = B4(ts);
        function ame(p, v, k) {
          var E = at(p), A = E || Su(p) || rp(p);
          if (v = Ye(v, 4), k == null) {
            var j = p && p.constructor;
            A ? k = E ? new j() : [] : $n(p) ? k = cc(j) ? Jf(c1(p)) : {} : k = {};
          }
          return (A ? So : el)(p, function(W, G, ee) {
            return v(k, W, G, ee);
          }), k;
        }
        function lme(p, v) {
          return p == null ? true : W_(p, v);
        }
        function cme(p, v, k) {
          return p == null ? p : P4(p, v, Y_(k));
        }
        function ume(p, v, k, E) {
          return E = typeof E == "function" ? E : n, p == null ? p : P4(p, v, Y_(k), E);
        }
        function ip(p) {
          return p == null ? [] : __(p, Or(p));
        }
        function dme(p) {
          return p == null ? [] : __(p, ts(p));
        }
        function hme(p, v, k) {
          return k === n && (k = v, v = n), k !== n && (k = Co(k), k = k === k ? k : 0), v !== n && (v = Co(v), v = v === v ? v : 0), sh(Co(p), v, k);
        }
        function fme(p, v, k) {
          return v = uc(v), k === n ? (k = v, v = 0) : k = uc(k), p = Co(p), Ohe(p, v, k);
        }
        function pme(p, v, k) {
          if (k && typeof k != "boolean" && Li(p, v, k) && (v = k = n), k === n && (typeof v == "boolean" ? (k = v, v = n) : typeof p == "boolean" && (k = p, p = n)), p === n && v === n ? (p = 0, v = 1) : (p = uc(p), v === n ? (v = p, p = 0) : v = uc(v)), p > v) {
            var E = p;
            p = v, v = E;
          }
          if (k || p % 1 || v % 1) {
            var A = t4();
            return ti(p + A * (v - p + en("1e-" + ((A + "").length - 1))), v);
          }
          return U_(p, v);
        }
        var gme = tp(function(p, v, k) {
          return v = v.toLowerCase(), p + (k ? AQ(v) : v);
        });
        function AQ(p) {
          return mT(Nt(p).toLowerCase());
        }
        function RQ(p) {
          return p = Nt(p), p && p.replace(tc, sde).replace(v_, "");
        }
        function mme(p, v, k) {
          p = Nt(p), v = Es(v);
          var E = p.length;
          k = k === n ? E : sh(dt(k), 0, E);
          var A = k;
          return k -= v.length, k >= 0 && p.slice(k, A) == v;
        }
        function yme(p) {
          return p = Nt(p), p && Yd.test(p) ? p.replace(RS, ode) : p;
        }
        function vme(p) {
          return p = Nt(p), p && G2.test(p) ? p.replace(ty, "\\$&") : p;
        }
        var Ome = tp(function(p, v, k) {
          return p + (k ? "-" : "") + v.toLowerCase();
        }), Sme = tp(function(p, v, k) {
          return p + (k ? " " : "") + v.toLowerCase();
        }), wme = L4("toLowerCase");
        function xme(p, v, k) {
          p = Nt(p), v = dt(v);
          var E = v ? Hf(p) : 0;
          if (!v || E >= v)
            return p;
          var A = (v - E) / 2;
          return C1(f1(A), k) + p + C1(h1(A), k);
        }
        function bme(p, v, k) {
          p = Nt(p), v = dt(v);
          var E = v ? Hf(p) : 0;
          return v && E < v ? p + C1(v - E, k) : p;
        }
        function kme(p, v, k) {
          p = Nt(p), v = dt(v);
          var E = v ? Hf(p) : 0;
          return v && E < v ? C1(v - E, k) + p : p;
        }
        function Pme(p, v, k) {
          return k || v == null ? v = 0 : v && (v = +v), Ade(Nt(p).replace(ny, ""), v || 0);
        }
        function Cme(p, v, k) {
          return (k ? Li(p, v, k) : v === n) ? v = 1 : v = dt(v), V_(Nt(p), v);
        }
        function _me() {
          var p = arguments, v = Nt(p[0]);
          return p.length < 3 ? v : v.replace(p[1], p[2]);
        }
        var Tme = tp(function(p, v, k) {
          return p + (k ? "_" : "") + v.toLowerCase();
        });
        function Eme(p, v, k) {
          return k && typeof k != "number" && Li(p, v, k) && (v = k = n), k = k === n ? se : k >>> 0, k ? (p = Nt(p), p && (typeof v == "string" || v != null && !fT(v)) && (v = Es(v), !v && Zf(p)) ? Ou(da(p), 0, k) : p.split(v, k)) : [];
        }
        var Ime = tp(function(p, v, k) {
          return p + (k ? " " : "") + mT(v);
        });
        function $me(p, v, k) {
          return p = Nt(p), k = k == null ? 0 : sh(dt(k), 0, p.length), v = Es(v), p.slice(k, k + v.length) == v;
        }
        function Ame(p, v, k) {
          var E = D.templateSettings;
          k && Li(p, v, k) && (v = n), p = Nt(p), v = N1({}, v, E, U4);
          var A = N1({}, v.imports, E.imports, U4), j = Or(A), W = __(A, j), G, ee, he = 0, fe = v.interpolate || Qf, me = "__p += '", be = E_((v.escape || Qf).source + "|" + fe.source + "|" + (fe === Nf ? t_ : Qf).source + "|" + (v.evaluate || Qf).source + "|$", "g"), je = "//# sourceURL=" + (Xt.call(v, "sourceURL") ? (v.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++O_ + "]") + `
`;
          p.replace(be, function(Ke, vt, Ct, $s, ji, As) {
            return Ct || (Ct = $s), me += p.slice(he, As).replace(a_, ade), vt && (G = true, me += `' +
__e(` + vt + `) +
'`), ji && (ee = true, me += `';
` + ji + `;
__p += '`), Ct && (me += `' +
((__t = (` + Ct + `)) == null ? '' : __t) +
'`), he = As + Ke.length, Ke;
          }), me += `';
`;
          var qe = Xt.call(v, "variable") && v.variable;
          if (!qe)
            me = `with (obj) {
` + me + `
}
`;
          else if (J2.test(qe))
            throw new st(a);
          me = (ee ? me.replace(Z2, "") : me).replace(Jl, "$1").replace($S, "$1;"), me = "function(" + (qe || "obj") + `) {
` + (qe ? "" : `obj || (obj = {});
`) + "var __t, __p = ''" + (G ? ", __e = _.escape" : "") + (ee ? `, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
` : `;
`) + me + `return __p
}`;
          var ht = DQ(function() {
            return jt(j, je + "return " + me).apply(n, W);
          });
          if (ht.source = me, hT(ht))
            throw ht;
          return ht;
        }
        function Rme(p) {
          return Nt(p).toLowerCase();
        }
        function Mme(p) {
          return Nt(p).toUpperCase();
        }
        function Dme(p, v, k) {
          if (p = Nt(p), p && (k || v === n))
            return VN(p);
          if (!p || !(v = Es(v)))
            return p;
          var E = da(p), A = da(v), j = XN(E, A), W = WN(E, A) + 1;
          return Ou(E, j, W).join("");
        }
        function Lme(p, v, k) {
          if (p = Nt(p), p && (k || v === n))
            return p.slice(0, HN(p) + 1);
          if (!p || !(v = Es(v)))
            return p;
          var E = da(p), A = WN(E, da(v)) + 1;
          return Ou(E, 0, A).join("");
        }
        function jme(p, v, k) {
          if (p = Nt(p), p && (k || v === n))
            return p.replace(ny, "");
          if (!p || !(v = Es(v)))
            return p;
          var E = da(p), A = XN(E, da(v));
          return Ou(E, A).join("");
        }
        function Nme(p, v) {
          var k = L, E = z;
          if ($n(v)) {
            var A = "separator" in v ? v.separator : A;
            k = "length" in v ? dt(v.length) : k, E = "omission" in v ? Es(v.omission) : E;
          }
          p = Nt(p);
          var j = p.length;
          if (Zf(p)) {
            var W = da(p);
            j = W.length;
          }
          if (k >= j)
            return p;
          var G = k - Hf(E);
          if (G < 1)
            return E;
          var ee = W ? Ou(W, 0, G).join("") : p.slice(0, G);
          if (A === n)
            return ee + E;
          if (W && (G += ee.length - G), fT(A)) {
            if (p.slice(G).search(A)) {
              var he, fe = ee;
              for (A.global || (A = E_(A.source, Nt(vo.exec(A)) + "g")), A.lastIndex = 0; he = A.exec(fe); )
                var me = he.index;
              ee = ee.slice(0, me === n ? G : me);
            }
          } else if (p.indexOf(Es(A), G) != G) {
            var be = ee.lastIndexOf(A);
            be > -1 && (ee = ee.slice(0, be));
          }
          return ee + E;
        }
        function Qme(p) {
          return p = Nt(p), p && Km.test(p) ? p.replace(AS, pde) : p;
        }
        var zme = tp(function(p, v, k) {
          return p + (k ? " " : "") + v.toUpperCase();
        }), mT = L4("toUpperCase");
        function MQ(p, v, k) {
          return p = Nt(p), v = k ? n : v, v === n ? cde(p) ? yde(p) : ede(p) : p.match(v) || [];
        }
        var DQ = gt(function(p, v) {
          try {
            return vr(p, n, v);
          } catch (k) {
            return hT(k) ? k : new st(k);
          }
        }), Fme = ac(function(p, v) {
          return So(v, function(k) {
            k = nl(k), sc(p, k, uT(p[k], p));
          }), p;
        });
        function Bme(p) {
          var v = p == null ? 0 : p.length, k = Ye();
          return p = v ? _n3(p, function(E) {
            if (typeof E[1] != "function")
              throw new wo(o);
            return [
              k(E[0]),
              E[1]
            ];
          }) : [], gt(function(E) {
            for (var A = -1; ++A < v; ) {
              var j = p[A];
              if (vr(j[0], this, E))
                return vr(j[1], this, E);
            }
          });
        }
        function Ume(p) {
          return phe(bo(p, d));
        }
        function yT(p) {
          return function() {
            return p;
          };
        }
        function Vme(p, v) {
          return p == null || p !== p ? v : p;
        }
        var Xme = N4(), Wme = N4(true);
        function ns(p) {
          return p;
        }
        function vT(p) {
          return p4(typeof p == "function" ? p : bo(p, d));
        }
        function Zme(p) {
          return m4(bo(p, d));
        }
        function Hme(p, v) {
          return y4(p, bo(v, d));
        }
        var Yme = gt(function(p, v) {
          return function(k) {
            return my(k, p, v);
          };
        }), Gme = gt(function(p, v) {
          return function(k) {
            return my(p, k, v);
          };
        });
        function OT(p, v, k) {
          var E = Or(v), A = O1(v, E);
          k == null && !($n(v) && (A.length || !E.length)) && (k = v, v = p, p = this, A = O1(v, Or(v)));
          var j = !($n(k) && "chain" in k) || !!k.chain, W = cc(p);
          return So(A, function(G) {
            var ee = v[G];
            p[G] = ee, W && (p.prototype[G] = function() {
              var he = this.__chain__;
              if (j || he) {
                var fe = p(this.__wrapped__), me = fe.__actions__ = Ji(this.__actions__);
                return me.push({
                  func: ee,
                  args: arguments,
                  thisArg: p
                }), fe.__chain__ = he, fe;
              }
              return ee.apply(p, fu([
                this.value()
              ], arguments));
            });
          }), p;
        }
        function qme() {
          return Pt._ === this && (Pt._ = bde), this;
        }
        function ST() {
        }
        function Kme(p) {
          return p = dt(p), gt(function(v) {
            return v4(v, p);
          });
        }
        var Jme = q_(_n3), eye = q_(QN), tye = q_(x_);
        function LQ(p) {
          return iT(p) ? b_(nl(p)) : $he(p);
        }
        function nye(p) {
          return function(v) {
            return p == null ? n : oh(p, v);
          };
        }
        var rye = z4(), iye = z4(true);
        function wT() {
          return [];
        }
        function xT() {
          return false;
        }
        function sye() {
          return {};
        }
        function oye() {
          return "";
        }
        function aye() {
          return true;
        }
        function lye(p, v) {
          if (p = dt(p), p < 1 || p > U)
            return [];
          var k = se, E = ti(p, se);
          v = Ye(v), p -= se;
          for (var A = C_(E, v); ++k < p; )
            v(k);
          return A;
        }
        function cye(p) {
          return at(p) ? _n3(p, nl) : Is(p) ? [
            p
          ] : Ji(nQ(Nt(p)));
        }
        function uye(p) {
          var v = ++wde;
          return Nt(p) + v;
        }
        var dye = P1(function(p, v) {
          return p + v;
        }, 0), hye = K_("ceil"), fye = P1(function(p, v) {
          return p / v;
        }, 1), pye = K_("floor");
        function gye(p) {
          return p && p.length ? v1(p, ns, j_) : n;
        }
        function mye(p, v) {
          return p && p.length ? v1(p, Ye(v, 2), j_) : n;
        }
        function yye(p) {
          return BN(p, ns);
        }
        function vye(p, v) {
          return BN(p, Ye(v, 2));
        }
        function Oye(p) {
          return p && p.length ? v1(p, ns, F_) : n;
        }
        function Sye(p, v) {
          return p && p.length ? v1(p, Ye(v, 2), F_) : n;
        }
        var wye = P1(function(p, v) {
          return p * v;
        }, 1), xye = K_("round"), bye = P1(function(p, v) {
          return p - v;
        }, 0);
        function kye(p) {
          return p && p.length ? P_(p, ns) : 0;
        }
        function Pye(p, v) {
          return p && p.length ? P_(p, Ye(v, 2)) : 0;
        }
        return D.after = Zpe, D.ary = fQ, D.assign = Mge, D.assignIn = _Q, D.assignInWith = N1, D.assignWith = Dge, D.at = Lge, D.before = pQ, D.bind = uT, D.bindAll = Fme, D.bindKey = gQ, D.castArray = sge, D.chain = uQ, D.chunk = pfe, D.compact = gfe, D.concat = mfe, D.cond = Bme, D.conforms = Ume, D.constant = yT, D.countBy = kpe, D.create = jge, D.curry = mQ, D.curryRight = yQ, D.debounce = vQ, D.defaults = Nge, D.defaultsDeep = Qge, D.defer = Hpe, D.delay = Ype, D.difference = yfe, D.differenceBy = vfe, D.differenceWith = Ofe, D.drop = Sfe, D.dropRight = wfe, D.dropRightWhile = xfe, D.dropWhile = bfe, D.fill = kfe, D.filter = Cpe, D.flatMap = Epe, D.flatMapDeep = Ipe, D.flatMapDepth = $pe, D.flatten = oQ, D.flattenDeep = Pfe, D.flattenDepth = Cfe, D.flip = Gpe, D.flow = Xme, D.flowRight = Wme, D.fromPairs = _fe, D.functions = Wge, D.functionsIn = Zge, D.groupBy = Ape, D.initial = Efe, D.intersection = Ife, D.intersectionBy = $fe, D.intersectionWith = Afe, D.invert = Yge, D.invertBy = Gge, D.invokeMap = Mpe, D.iteratee = vT, D.keyBy = Dpe, D.keys = Or, D.keysIn = ts, D.map = A1, D.mapKeys = Kge, D.mapValues = Jge, D.matches = Zme, D.matchesProperty = Hme, D.memoize = M1, D.merge = eme, D.mergeWith = TQ, D.method = Yme, D.methodOf = Gme, D.mixin = OT, D.negate = D1, D.nthArg = Kme, D.omit = tme, D.omitBy = nme, D.once = qpe, D.orderBy = Lpe, D.over = Jme, D.overArgs = Kpe, D.overEvery = eye, D.overSome = tye, D.partial = dT, D.partialRight = OQ, D.partition = jpe, D.pick = rme, D.pickBy = EQ, D.property = LQ, D.propertyOf = nye, D.pull = Lfe, D.pullAll = lQ, D.pullAllBy = jfe, D.pullAllWith = Nfe, D.pullAt = Qfe, D.range = rye, D.rangeRight = iye, D.rearg = Jpe, D.reject = zpe, D.remove = zfe, D.rest = ege, D.reverse = lT, D.sampleSize = Bpe, D.set = sme, D.setWith = ome, D.shuffle = Upe, D.slice = Ffe, D.sortBy = Wpe, D.sortedUniq = Hfe, D.sortedUniqBy = Yfe, D.split = Eme, D.spread = tge, D.tail = Gfe, D.take = qfe, D.takeRight = Kfe, D.takeRightWhile = Jfe, D.takeWhile = epe, D.tap = gpe, D.throttle = nge, D.thru = $1, D.toArray = kQ, D.toPairs = IQ, D.toPairsIn = $Q, D.toPath = cye, D.toPlainObject = CQ, D.transform = ame, D.unary = rge, D.union = tpe, D.unionBy = npe, D.unionWith = rpe, D.uniq = ipe, D.uniqBy = spe, D.uniqWith = ope, D.unset = lme, D.unzip = cT, D.unzipWith = cQ, D.update = cme, D.updateWith = ume, D.values = ip, D.valuesIn = dme, D.without = ape, D.words = MQ, D.wrap = ige, D.xor = lpe, D.xorBy = cpe, D.xorWith = upe, D.zip = dpe, D.zipObject = hpe, D.zipObjectDeep = fpe, D.zipWith = ppe, D.entries = IQ, D.entriesIn = $Q, D.extend = _Q, D.extendWith = N1, OT(D, D), D.add = dye, D.attempt = DQ, D.camelCase = gme, D.capitalize = AQ, D.ceil = hye, D.clamp = hme, D.clone = oge, D.cloneDeep = lge, D.cloneDeepWith = cge, D.cloneWith = age, D.conformsTo = uge, D.deburr = RQ, D.defaultTo = Vme, D.divide = fye, D.endsWith = mme, D.eq = fa, D.escape = yme, D.escapeRegExp = vme, D.every = Ppe, D.find = _pe, D.findIndex = iQ, D.findKey = zge, D.findLast = Tpe, D.findLastIndex = sQ, D.findLastKey = Fge, D.floor = pye, D.forEach = dQ, D.forEachRight = hQ, D.forIn = Bge, D.forInRight = Uge, D.forOwn = Vge, D.forOwnRight = Xge, D.get = pT, D.gt = dge, D.gte = hge, D.has = Hge, D.hasIn = gT, D.head = aQ, D.identity = ns, D.includes = Rpe, D.indexOf = Tfe, D.inRange = fme, D.invoke = qge, D.isArguments = ch, D.isArray = at, D.isArrayBuffer = fge, D.isArrayLike = es, D.isArrayLikeObject = Wn, D.isBoolean = pge, D.isBuffer = Su, D.isDate = gge, D.isElement = mge, D.isEmpty = yge, D.isEqual = vge, D.isEqualWith = Oge, D.isError = hT, D.isFinite = Sge, D.isFunction = cc, D.isInteger = SQ, D.isLength = L1, D.isMap = wQ, D.isMatch = wge, D.isMatchWith = xge, D.isNaN = bge, D.isNative = kge, D.isNil = Cge, D.isNull = Pge, D.isNumber = xQ, D.isObject = $n, D.isObjectLike = jn, D.isPlainObject = xy, D.isRegExp = fT, D.isSafeInteger = _ge, D.isSet = bQ, D.isString = j1, D.isSymbol = Is, D.isTypedArray = rp, D.isUndefined = Tge, D.isWeakMap = Ege, D.isWeakSet = Ige, D.join = Rfe, D.kebabCase = Ome, D.last = Po, D.lastIndexOf = Mfe, D.lowerCase = Sme, D.lowerFirst = wme, D.lt = $ge, D.lte = Age, D.max = gye, D.maxBy = mye, D.mean = yye, D.meanBy = vye, D.min = Oye, D.minBy = Sye, D.stubArray = wT, D.stubFalse = xT, D.stubObject = sye, D.stubString = oye, D.stubTrue = aye, D.multiply = wye, D.nth = Dfe, D.noConflict = qme, D.noop = ST, D.now = R1, D.pad = xme, D.padEnd = bme, D.padStart = kme, D.parseInt = Pme, D.random = pme, D.reduce = Npe, D.reduceRight = Qpe, D.repeat = Cme, D.replace = _me, D.result = ime, D.round = xye, D.runInContext = K, D.sample = Fpe, D.size = Vpe, D.snakeCase = Tme, D.some = Xpe, D.sortedIndex = Bfe, D.sortedIndexBy = Ufe, D.sortedIndexOf = Vfe, D.sortedLastIndex = Xfe, D.sortedLastIndexBy = Wfe, D.sortedLastIndexOf = Zfe, D.startCase = Ime, D.startsWith = $me, D.subtract = bye, D.sum = kye, D.sumBy = Pye, D.template = Ame, D.times = lye, D.toFinite = uc, D.toInteger = dt, D.toLength = PQ, D.toLower = Rme, D.toNumber = Co, D.toSafeInteger = Rge, D.toString = Nt, D.toUpper = Mme, D.trim = Dme, D.trimEnd = Lme, D.trimStart = jme, D.truncate = Nme, D.unescape = Qme, D.uniqueId = uye, D.upperCase = zme, D.upperFirst = mT, D.each = dQ, D.eachRight = hQ, D.first = aQ, OT(D, function() {
          var p = {};
          return el(D, function(v, k) {
            Xt.call(D.prototype, k) || (p[k] = v);
          }), p;
        }(), {
          chain: false
        }), D.VERSION = r, So([
          "bind",
          "bindKey",
          "curry",
          "curryRight",
          "partial",
          "partialRight"
        ], function(p) {
          D[p].placeholder = D;
        }), So([
          "drop",
          "take"
        ], function(p, v) {
          wt.prototype[p] = function(k) {
            k = k === n ? 1 : hr(dt(k), 0);
            var E = this.__filtered__ && !v ? new wt(this) : this.clone();
            return E.__filtered__ ? E.__takeCount__ = ti(k, E.__takeCount__) : E.__views__.push({
              size: ti(k, se),
              type: p + (E.__dir__ < 0 ? "Right" : "")
            }), E;
          }, wt.prototype[p + "Right"] = function(k) {
            return this.reverse()[p](k).reverse();
          };
        }), So([
          "filter",
          "map",
          "takeWhile"
        ], function(p, v) {
          var k = v + 1, E = k == F || k == X;
          wt.prototype[p] = function(A) {
            var j = this.clone();
            return j.__iteratees__.push({
              iteratee: Ye(A, 3),
              type: k
            }), j.__filtered__ = j.__filtered__ || E, j;
          };
        }), So([
          "head",
          "last"
        ], function(p, v) {
          var k = "take" + (v ? "Right" : "");
          wt.prototype[p] = function() {
            return this[k](1).value()[0];
          };
        }), So([
          "initial",
          "tail"
        ], function(p, v) {
          var k = "drop" + (v ? "" : "Right");
          wt.prototype[p] = function() {
            return this.__filtered__ ? new wt(this) : this[k](1);
          };
        }), wt.prototype.compact = function() {
          return this.filter(ns);
        }, wt.prototype.find = function(p) {
          return this.filter(p).head();
        }, wt.prototype.findLast = function(p) {
          return this.reverse().find(p);
        }, wt.prototype.invokeMap = gt(function(p, v) {
          return typeof p == "function" ? new wt(this) : this.map(function(k) {
            return my(k, p, v);
          });
        }), wt.prototype.reject = function(p) {
          return this.filter(D1(Ye(p)));
        }, wt.prototype.slice = function(p, v) {
          p = dt(p);
          var k = this;
          return k.__filtered__ && (p > 0 || v < 0) ? new wt(k) : (p < 0 ? k = k.takeRight(-p) : p && (k = k.drop(p)), v !== n && (v = dt(v), k = v < 0 ? k.dropRight(-v) : k.take(v - p)), k);
        }, wt.prototype.takeRightWhile = function(p) {
          return this.reverse().takeWhile(p).reverse();
        }, wt.prototype.toArray = function() {
          return this.take(se);
        }, el(wt.prototype, function(p, v) {
          var k = /^(?:filter|find|map|reject)|While$/.test(v), E = /^(?:head|last)$/.test(v), A = D[E ? "take" + (v == "last" ? "Right" : "") : v], j = E || /^find/.test(v);
          A && (D.prototype[v] = function() {
            var W = this.__wrapped__, G = E ? [
              1
            ] : arguments, ee = W instanceof wt, he = G[0], fe = ee || at(W), me = function(vt) {
              var Ct = A.apply(D, fu([
                vt
              ], G));
              return E && be ? Ct[0] : Ct;
            };
            fe && k && typeof he == "function" && he.length != 1 && (ee = fe = false);
            var be = this.__chain__, je = !!this.__actions__.length, qe = j && !be, ht = ee && !je;
            if (!j && fe) {
              W = ht ? W : new wt(this);
              var Ke = p.apply(W, G);
              return Ke.__actions__.push({
                func: $1,
                args: [
                  me
                ],
                thisArg: n
              }), new xo(Ke, be);
            }
            return qe && ht ? p.apply(this, G) : (Ke = this.thru(me), qe ? E ? Ke.value()[0] : Ke.value() : Ke);
          });
        }), So([
          "pop",
          "push",
          "shift",
          "sort",
          "splice",
          "unshift"
        ], function(p) {
          var v = r1[p], k = /^(?:push|sort|unshift)$/.test(p) ? "tap" : "thru", E = /^(?:pop|shift)$/.test(p);
          D.prototype[p] = function() {
            var A = arguments;
            if (E && !this.__chain__) {
              var j = this.value();
              return v.apply(at(j) ? j : [], A);
            }
            return this[k](function(W) {
              return v.apply(at(W) ? W : [], A);
            });
          };
        }), el(wt.prototype, function(p, v) {
          var k = D[v];
          if (k) {
            var E = k.name + "";
            Xt.call(Kf, E) || (Kf[E] = []), Kf[E].push({
              name: v,
              func: k
            });
          }
        }), Kf[k1(n, S).name] = [
          {
            name: "wrapper",
            func: n
          }
        ], wt.prototype.clone = Qde, wt.prototype.reverse = zde, wt.prototype.value = Fde, D.prototype.at = mpe, D.prototype.chain = ype, D.prototype.commit = vpe, D.prototype.next = Ope, D.prototype.plant = wpe, D.prototype.reverse = xpe, D.prototype.toJSON = D.prototype.valueOf = D.prototype.value = bpe, D.prototype.first = D.prototype.head, cy && (D.prototype[cy] = Spe), D;
      }, Yf = vde();
      Xn ? ((Xn.exports = Yf)._ = Yf, tn._ = Yf) : Pt._ = Yf;
    }).call(Jn);
  })(Qb, Qb.exports);
  var ym = Qb.exports;
  const ul = Rd(ym), kve = ({ rootUrl: t, findLinks: e, materializeLinks: n }) => {
    const [r, i] = b.useState(t ? [
      t
    ] : []), s = gve(r), o = b.useMemo(() => ym.mapKeys(s, (h, f) => `automerge:${f}`), [
      s
    ]), a = b.useMemo(() => o[t], [
      o,
      t
    ]), l = b.useMemo(() => a ? n(a, o) : void 0, [
      a,
      o,
      n
    ]), c = b.useMemo(() => l ? [
      t,
      ...e(l)
    ] : void 0, [
      l,
      e,
      t
    ]);
    b.useEffect(() => {
      if (!t) {
        i([]);
        return;
      }
      if (!a) {
        i([
          t
        ]);
        return;
      }
      i(c);
    }, [
      t,
      a,
      c
    ]);
    const d = !a || Object.keys(o).length < c.length ? "loading" : "loaded";
    return {
      doc: l,
      status: d
    };
  }, ZW = ({ folderPath: t, doc: e, status: n }) => {
    if (n !== "loading")
      return e == null ? void 0 : e.docs.flatMap((r) => r.type === "folder" && r.folderContents ? [
        {
          ...r,
          folderPath: t
        },
        ...ZW({
          doc: r.folderContents,
          status: n,
          folderPath: [
            ...t,
            r.url
          ]
        })
      ] : {
        ...r,
        folderPath: t
      });
  };
  function Pve(t) {
    const e = b.useCallback((s, o) => ({
      ...s,
      docs: s.docs.map((a) => o[a.url] ? {
        ...a,
        folderContents: e(o[a.url], o)
      } : a)
    }), []), n = b.useCallback((s) => {
      const o = [];
      for (const a of s.docs)
        a.type === "folder" && o.push(a.url), a.folderContents && o.push(...n(a.folderContents));
      return o;
    }, []), r = kve({
      rootUrl: t,
      findLinks: n,
      materializeLinks: e
    }), i = ZW({
      doc: r.doc,
      status: r.status,
      folderPath: [
        t
      ]
    });
    return {
      ...r,
      rootFolderUrl: t,
      flatDocLinks: i
    };
  }
  class o6 extends Cye {
    constructor(e, n, r) {
      super();
      __privateAdd(this, _e, void 0);
      __privateAdd(this, _t2, void 0);
      __privateAdd(this, _n, void 0);
      __privateSet(this, _e, e), __privateSet(this, _t2, n), __privateSet(this, _n, r), window.addEventListener("storage", async (i) => {
        if (i.key === L0) {
          const s = i.newValue, o = __privateGet(this, _e).find(s);
          if ((await o.doc()).contactUrl) {
            this.logIn(s);
            return;
          }
          o.on("change", ({ doc: l }) => {
            l.contactUrl && this.logIn(s);
          });
        }
      });
    }
    async logIn(e) {
      localStorage.setItem(L0, e);
      const n = __privateGet(this, _e).find(e), r = await n.doc(), i = __privateGet(this, _e).find(r.contactUrl);
      __privateSet(this, _n, i), __privateSet(this, _t2, n), this.emit("change");
    }
    async signUp({ name: e, avatar: n }) {
      let r;
      n && (r = await xve(__privateGet(this, _e), n)), this.contactHandle.change((i) => {
        i.type = "registered", i.name = e, r && (i.avatarUrl = r);
      });
    }
    async logOut() {
      const { accountHandle: e, contactHandle: n } = YW(__privateGet(this, _e));
      localStorage.setItem(L0, e.url), __privateSet(this, _t2, e), __privateSet(this, _n, n), this.emit("change");
    }
    get handle() {
      return __privateGet(this, _t2);
    }
    get contactHandle() {
      return __privateGet(this, _n);
    }
  }
  _e = new WeakMap();
  _t2 = new WeakMap();
  _n = new WeakMap();
  const L0 = "tinyEssayEditor:accountUrl";
  let ky;
  async function HW(t) {
    if (!t.storageSubsystem)
      throw new Error("cannot create account without storage");
    if (ky) {
      const s = await ky;
      if (s)
        return s;
    }
    const e = localStorage.getItem(L0);
    if (e)
      return ky = new Promise(async (s) => {
        const o = t.find(e), a = t.find((await o.doc()).contactUrl);
        s(new o6(t, o, a));
      }), ky;
    const { accountHandle: n, contactHandle: r } = YW(t);
    localStorage.setItem(L0, n.url);
    const i = new o6(t, n, r);
    return ky = Promise.resolve(i), i;
  }
  const YW = (t) => {
    const e = t.create(), n = t.create(), r = t.create();
    return n.change((i) => {
      i.type = "anonymous";
    }), r.change((i) => {
      i.docs = [];
    }), e.change((i) => {
      i.contactUrl = n.url, i.rootFolderUrl = r.url;
    }), {
      accountHandle: e,
      contactHandle: n,
      rootFolderHandle: r
    };
  };
  function Cve() {
    const [, t] = b.useReducer((e) => e + 1, 0);
    return t;
  }
  function BO() {
    const t = Xl(), [e, n] = b.useState(void 0);
    window.currentAccount = e;
    const r = Cve();
    return b.useEffect(() => {
      HW(t).then(n);
    }, [
      t
    ]), b.useEffect(() => {
      if (e)
        return e.on("change", r), () => {
          e.off("change", r);
        };
    }, [
      e
    ]), b.useEffect(() => {
      const i = e == null ? void 0 : e.handle.docSync();
      if (i && i.rootFolderUrl === void 0) {
        const s = t.create();
        s.change((o) => {
          o.docs = [];
        }), e.handle.change((o) => {
          o.rootFolderUrl = s.url;
        });
      }
    }, [
      e == null ? void 0 : e.handle.docSync()
    ]), e;
  }
  function e3() {
    const t = BO(), [e, n] = Ba(t == null ? void 0 : t.handle.url);
    return [
      e,
      n
    ];
  }
  function _ve() {
    const [t] = e3(), e = Xl();
    return b.useEffect(() => {
      t && (window.rootFolderHandle = e.find(t.rootFolderUrl));
    }, [
      e,
      t
    ]), Pve(t == null ? void 0 : t.rootFolderUrl);
  }
  function Tve() {
    const [t] = e3(), [e] = Ba(t == null ? void 0 : t.contactUrl);
    return e;
  }
  function Eve(t, e) {
    const { documentId: n } = _ye(t);
    return `account:${encodeURIComponent(e)}/${n}`;
  }
  function Ive(t) {
    const e = t.match(/^account:([^/]+)\/(.+)$/);
    if (!e || !e[2])
      return;
    const r = `automerge:${e[2]}`;
    if (Yh(r))
      return r;
  }
  var G$ = {}, GW = {
    exports: {}
  }, lo = {}, qW = {
    exports: {}
  }, KW = {};
  (function(t) {
    function e(U, H) {
      var te = U.length;
      U.push(H);
      e:
        for (; 0 < te; ) {
          var se = te - 1 >>> 1, ae = U[se];
          if (0 < i(ae, H))
            U[se] = H, U[te] = ae, te = se;
          else
            break e;
        }
    }
    function n(U) {
      return U.length === 0 ? null : U[0];
    }
    function r(U) {
      if (U.length === 0)
        return null;
      var H = U[0], te = U.pop();
      if (te !== H) {
        U[0] = te;
        e:
          for (var se = 0, ae = U.length, _e3 = ae >>> 1; se < _e3; ) {
            var Me = 2 * (se + 1) - 1, ke = U[Me], tt = Me + 1, it = U[tt];
            if (0 > i(ke, te))
              tt < ae && 0 > i(it, ke) ? (U[se] = it, U[tt] = te, se = tt) : (U[se] = ke, U[Me] = te, se = Me);
            else if (tt < ae && 0 > i(it, te))
              U[se] = it, U[tt] = te, se = tt;
            else
              break e;
          }
      }
      return H;
    }
    function i(U, H) {
      var te = U.sortIndex - H.sortIndex;
      return te !== 0 ? te : U.id - H.id;
    }
    if (typeof performance == "object" && typeof performance.now == "function") {
      var s = performance;
      t.unstable_now = function() {
        return s.now();
      };
    } else {
      var o = Date, a = o.now();
      t.unstable_now = function() {
        return o.now() - a;
      };
    }
    var l = [], c = [], u = 1, d = null, h = 3, f = false, y = false, g = false, O = typeof setTimeout == "function" ? setTimeout : null, S = typeof clearTimeout == "function" ? clearTimeout : null, w = typeof setImmediate < "u" ? setImmediate : null;
    typeof navigator < "u" && navigator.scheduling !== void 0 && navigator.scheduling.isInputPending !== void 0 && navigator.scheduling.isInputPending.bind(navigator.scheduling);
    function x(U) {
      for (var H = n(c); H !== null; ) {
        if (H.callback === null)
          r(c);
        else if (H.startTime <= U)
          r(c), H.sortIndex = H.expirationTime, e(l, H);
        else
          break;
        H = n(c);
      }
    }
    function P(U) {
      if (g = false, x(U), !y)
        if (n(l) !== null)
          y = true, X(C);
        else {
          var H = n(c);
          H !== null && Z(P, H.startTime - U);
        }
    }
    function C(U, H) {
      y = false, g && (g = false, S($), $ = -1), f = true;
      var te = h;
      try {
        for (x(H), d = n(l); d !== null && (!(d.expirationTime > H) || U && !z()); ) {
          var se = d.callback;
          if (typeof se == "function") {
            d.callback = null, h = d.priorityLevel;
            var ae = se(d.expirationTime <= H);
            H = t.unstable_now(), typeof ae == "function" ? d.callback = ae : d === n(l) && r(l), x(H);
          } else
            r(l);
          d = n(l);
        }
        if (d !== null)
          var _e3 = true;
        else {
          var Me = n(c);
          Me !== null && Z(P, Me.startTime - H), _e3 = false;
        }
        return _e3;
      } finally {
        d = null, h = te, f = false;
      }
    }
    var _ = false, T = null, $ = -1, N = 5, L = -1;
    function z() {
      return !(t.unstable_now() - L < N);
    }
    function M() {
      if (T !== null) {
        var U = t.unstable_now();
        L = U;
        var H = true;
        try {
          H = T(true, U);
        } finally {
          H ? R() : (_ = false, T = null);
        }
      } else
        _ = false;
    }
    var R;
    if (typeof w == "function")
      R = function() {
        w(M);
      };
    else if (typeof MessageChannel < "u") {
      var F = new MessageChannel(), Q = F.port2;
      F.port1.onmessage = M, R = function() {
        Q.postMessage(null);
      };
    } else
      R = function() {
        O(M, 0);
      };
    function X(U) {
      T = U, _ || (_ = true, R());
    }
    function Z(U, H) {
      $ = O(function() {
        U(t.unstable_now());
      }, H);
    }
    t.unstable_IdlePriority = 5, t.unstable_ImmediatePriority = 1, t.unstable_LowPriority = 4, t.unstable_NormalPriority = 3, t.unstable_Profiling = null, t.unstable_UserBlockingPriority = 2, t.unstable_cancelCallback = function(U) {
      U.callback = null;
    }, t.unstable_continueExecution = function() {
      y || f || (y = true, X(C));
    }, t.unstable_forceFrameRate = function(U) {
      0 > U || 125 < U ? console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported") : N = 0 < U ? Math.floor(1e3 / U) : 5;
    }, t.unstable_getCurrentPriorityLevel = function() {
      return h;
    }, t.unstable_getFirstCallbackNode = function() {
      return n(l);
    }, t.unstable_next = function(U) {
      switch (h) {
        case 1:
        case 2:
        case 3:
          var H = 3;
          break;
        default:
          H = h;
      }
      var te = h;
      h = H;
      try {
        return U();
      } finally {
        h = te;
      }
    }, t.unstable_pauseExecution = function() {
    }, t.unstable_requestPaint = function() {
    }, t.unstable_runWithPriority = function(U, H) {
      switch (U) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
          break;
        default:
          U = 3;
      }
      var te = h;
      h = U;
      try {
        return H();
      } finally {
        h = te;
      }
    }, t.unstable_scheduleCallback = function(U, H, te) {
      var se = t.unstable_now();
      switch (typeof te == "object" && te !== null ? (te = te.delay, te = typeof te == "number" && 0 < te ? se + te : se) : te = se, U) {
        case 1:
          var ae = -1;
          break;
        case 2:
          ae = 250;
          break;
        case 5:
          ae = 1073741823;
          break;
        case 4:
          ae = 1e4;
          break;
        default:
          ae = 5e3;
      }
      return ae = te + ae, U = {
        id: u++,
        callback: H,
        priorityLevel: U,
        startTime: te,
        expirationTime: ae,
        sortIndex: -1
      }, te > se ? (U.sortIndex = te, e(c, U), n(l) === null && U === n(c) && (g ? (S($), $ = -1) : g = true, Z(P, te - se))) : (U.sortIndex = ae, e(l, U), y || f || (y = true, X(C))), U;
    }, t.unstable_shouldYield = z, t.unstable_wrapCallback = function(U) {
      var H = h;
      return function() {
        var te = h;
        h = H;
        try {
          return U.apply(this, arguments);
        } finally {
          h = te;
        }
      };
    };
  })(KW);
  qW.exports = KW;
  var $ve = qW.exports;
  var Ave = b, ao = $ve;
  function Oe(t) {
    for (var e = "https://reactjs.org/docs/error-decoder.html?invariant=" + t, n = 1; n < arguments.length; n++)
      e += "&args[]=" + encodeURIComponent(arguments[n]);
    return "Minified React error #" + t + "; visit " + e + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  var JW = /* @__PURE__ */ new Set(), bv = {};
  function mf(t, e) {
    Eg(t, e), Eg(t + "Capture", e);
  }
  function Eg(t, e) {
    for (bv[t] = e, t = 0; t < e.length; t++)
      JW.add(e[t]);
  }
  var Uc = !(typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u"), q$ = Object.prototype.hasOwnProperty, Rve = /^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/, a6 = {}, l6 = {};
  function Mve(t) {
    return q$.call(l6, t) ? true : q$.call(a6, t) ? false : Rve.test(t) ? l6[t] = true : (a6[t] = true, false);
  }
  function Dve(t, e, n, r) {
    if (n !== null && n.type === 0)
      return false;
    switch (typeof e) {
      case "function":
      case "symbol":
        return true;
      case "boolean":
        return r ? false : n !== null ? !n.acceptsBooleans : (t = t.toLowerCase().slice(0, 5), t !== "data-" && t !== "aria-");
      default:
        return false;
    }
  }
  function Lve(t, e, n, r) {
    if (e === null || typeof e > "u" || Dve(t, e, n, r))
      return true;
    if (r)
      return false;
    if (n !== null)
      switch (n.type) {
        case 3:
          return !e;
        case 4:
          return e === false;
        case 5:
          return isNaN(e);
        case 6:
          return isNaN(e) || 1 > e;
      }
    return false;
  }
  function Xi(t, e, n, r, i, s, o) {
    this.acceptsBooleans = e === 2 || e === 3 || e === 4, this.attributeName = r, this.attributeNamespace = i, this.mustUseProperty = n, this.propertyName = t, this.type = e, this.sanitizeURL = s, this.removeEmptyString = o;
  }
  var Hr = {};
  "children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t) {
    Hr[t] = new Xi(t, 0, false, t, null, false, false);
  });
  [
    [
      "acceptCharset",
      "accept-charset"
    ],
    [
      "className",
      "class"
    ],
    [
      "htmlFor",
      "for"
    ],
    [
      "httpEquiv",
      "http-equiv"
    ]
  ].forEach(function(t) {
    var e = t[0];
    Hr[e] = new Xi(e, 1, false, t[1], null, false, false);
  });
  [
    "contentEditable",
    "draggable",
    "spellCheck",
    "value"
  ].forEach(function(t) {
    Hr[t] = new Xi(t, 2, false, t.toLowerCase(), null, false, false);
  });
  [
    "autoReverse",
    "externalResourcesRequired",
    "focusable",
    "preserveAlpha"
  ].forEach(function(t) {
    Hr[t] = new Xi(t, 2, false, t, null, false, false);
  });
  "allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t) {
    Hr[t] = new Xi(t, 3, false, t.toLowerCase(), null, false, false);
  });
  [
    "checked",
    "multiple",
    "muted",
    "selected"
  ].forEach(function(t) {
    Hr[t] = new Xi(t, 3, true, t, null, false, false);
  });
  [
    "capture",
    "download"
  ].forEach(function(t) {
    Hr[t] = new Xi(t, 4, false, t, null, false, false);
  });
  [
    "cols",
    "rows",
    "size",
    "span"
  ].forEach(function(t) {
    Hr[t] = new Xi(t, 6, false, t, null, false, false);
  });
  [
    "rowSpan",
    "start"
  ].forEach(function(t) {
    Hr[t] = new Xi(t, 5, false, t.toLowerCase(), null, false, false);
  });
  var t3 = /[\-:]([a-z])/g;
  function n3(t) {
    return t[1].toUpperCase();
  }
  "accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t) {
    var e = t.replace(t3, n3);
    Hr[e] = new Xi(e, 1, false, t, null, false, false);
  });
  "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t) {
    var e = t.replace(t3, n3);
    Hr[e] = new Xi(e, 1, false, t, "http://www.w3.org/1999/xlink", false, false);
  });
  [
    "xml:base",
    "xml:lang",
    "xml:space"
  ].forEach(function(t) {
    var e = t.replace(t3, n3);
    Hr[e] = new Xi(e, 1, false, t, "http://www.w3.org/XML/1998/namespace", false, false);
  });
  [
    "tabIndex",
    "crossOrigin"
  ].forEach(function(t) {
    Hr[t] = new Xi(t, 1, false, t.toLowerCase(), null, false, false);
  });
  Hr.xlinkHref = new Xi("xlinkHref", 1, false, "xlink:href", "http://www.w3.org/1999/xlink", true, false);
  [
    "src",
    "href",
    "action",
    "formAction"
  ].forEach(function(t) {
    Hr[t] = new Xi(t, 1, false, t.toLowerCase(), null, true, true);
  });
  function r3(t, e, n, r) {
    var i = Hr.hasOwnProperty(e) ? Hr[e] : null;
    (i !== null ? i.type !== 0 : r || !(2 < e.length) || e[0] !== "o" && e[0] !== "O" || e[1] !== "n" && e[1] !== "N") && (Lve(e, n, i, r) && (n = null), r || i === null ? Mve(e) && (n === null ? t.removeAttribute(e) : t.setAttribute(e, "" + n)) : i.mustUseProperty ? t[i.propertyName] = n === null ? i.type === 3 ? false : "" : n : (e = i.attributeName, r = i.attributeNamespace, n === null ? t.removeAttribute(e) : (i = i.type, n = i === 3 || i === 4 && n === true ? "" : "" + n, r ? t.setAttributeNS(r, e, n) : t.setAttribute(e, n))));
  }
  var eu = Ave.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, B1 = Symbol.for("react.element"), Qp = Symbol.for("react.portal"), zp = Symbol.for("react.fragment"), i3 = Symbol.for("react.strict_mode"), K$ = Symbol.for("react.profiler"), eZ = Symbol.for("react.provider"), tZ = Symbol.for("react.context"), s3 = Symbol.for("react.forward_ref"), J$ = Symbol.for("react.suspense"), eA = Symbol.for("react.suspense_list"), o3 = Symbol.for("react.memo"), Ru = Symbol.for("react.lazy"), nZ = Symbol.for("react.offscreen"), c6 = Symbol.iterator;
  function Py(t) {
    return t === null || typeof t != "object" ? null : (t = c6 && t[c6] || t["@@iterator"], typeof t == "function" ? t : null);
  }
  var Ln = Object.assign, DT;
  function f0(t) {
    if (DT === void 0)
      try {
        throw Error();
      } catch (n) {
        var e = n.stack.trim().match(/\n( *(at )?)/);
        DT = e && e[1] || "";
      }
    return `
` + DT + t;
  }
  var LT = false;
  function jT(t, e) {
    if (!t || LT)
      return "";
    LT = true;
    var n = Error.prepareStackTrace;
    Error.prepareStackTrace = void 0;
    try {
      if (e)
        if (e = function() {
          throw Error();
        }, Object.defineProperty(e.prototype, "props", {
          set: function() {
            throw Error();
          }
        }), typeof Reflect == "object" && Reflect.construct) {
          try {
            Reflect.construct(e, []);
          } catch (c) {
            var r = c;
          }
          Reflect.construct(t, [], e);
        } else {
          try {
            e.call();
          } catch (c) {
            r = c;
          }
          t.call(e.prototype);
        }
      else {
        try {
          throw Error();
        } catch (c) {
          r = c;
        }
        t();
      }
    } catch (c) {
      if (c && r && typeof c.stack == "string") {
        for (var i = c.stack.split(`
`), s = r.stack.split(`
`), o = i.length - 1, a = s.length - 1; 1 <= o && 0 <= a && i[o] !== s[a]; )
          a--;
        for (; 1 <= o && 0 <= a; o--, a--)
          if (i[o] !== s[a]) {
            if (o !== 1 || a !== 1)
              do
                if (o--, a--, 0 > a || i[o] !== s[a]) {
                  var l = `
` + i[o].replace(" at new ", " at ");
                  return t.displayName && l.includes("<anonymous>") && (l = l.replace("<anonymous>", t.displayName)), l;
                }
              while (1 <= o && 0 <= a);
            break;
          }
      }
    } finally {
      LT = false, Error.prepareStackTrace = n;
    }
    return (t = t ? t.displayName || t.name : "") ? f0(t) : "";
  }
  function jve(t) {
    switch (t.tag) {
      case 5:
        return f0(t.type);
      case 16:
        return f0("Lazy");
      case 13:
        return f0("Suspense");
      case 19:
        return f0("SuspenseList");
      case 0:
      case 2:
      case 15:
        return t = jT(t.type, false), t;
      case 11:
        return t = jT(t.type.render, false), t;
      case 1:
        return t = jT(t.type, true), t;
      default:
        return "";
    }
  }
  function tA(t) {
    if (t == null)
      return null;
    if (typeof t == "function")
      return t.displayName || t.name || null;
    if (typeof t == "string")
      return t;
    switch (t) {
      case zp:
        return "Fragment";
      case Qp:
        return "Portal";
      case K$:
        return "Profiler";
      case i3:
        return "StrictMode";
      case J$:
        return "Suspense";
      case eA:
        return "SuspenseList";
    }
    if (typeof t == "object")
      switch (t.$$typeof) {
        case tZ:
          return (t.displayName || "Context") + ".Consumer";
        case eZ:
          return (t._context.displayName || "Context") + ".Provider";
        case s3:
          var e = t.render;
          return t = t.displayName, t || (t = e.displayName || e.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
        case o3:
          return e = t.displayName || null, e !== null ? e : tA(t.type) || "Memo";
        case Ru:
          e = t._payload, t = t._init;
          try {
            return tA(t(e));
          } catch {
          }
      }
    return null;
  }
  function Nve(t) {
    var e = t.type;
    switch (t.tag) {
      case 24:
        return "Cache";
      case 9:
        return (e.displayName || "Context") + ".Consumer";
      case 10:
        return (e._context.displayName || "Context") + ".Provider";
      case 18:
        return "DehydratedFragment";
      case 11:
        return t = e.render, t = t.displayName || t.name || "", e.displayName || (t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef");
      case 7:
        return "Fragment";
      case 5:
        return e;
      case 4:
        return "Portal";
      case 3:
        return "Root";
      case 6:
        return "Text";
      case 16:
        return tA(e);
      case 8:
        return e === i3 ? "StrictMode" : "Mode";
      case 22:
        return "Offscreen";
      case 12:
        return "Profiler";
      case 21:
        return "Scope";
      case 13:
        return "Suspense";
      case 19:
        return "SuspenseList";
      case 25:
        return "TracingMarker";
      case 1:
      case 0:
      case 17:
      case 2:
      case 14:
      case 15:
        if (typeof e == "function")
          return e.displayName || e.name || null;
        if (typeof e == "string")
          return e;
    }
    return null;
  }
  function Od(t) {
    switch (typeof t) {
      case "boolean":
      case "number":
      case "string":
      case "undefined":
        return t;
      case "object":
        return t;
      default:
        return "";
    }
  }
  function rZ(t) {
    var e = t.type;
    return (t = t.nodeName) && t.toLowerCase() === "input" && (e === "checkbox" || e === "radio");
  }
  function Qve(t) {
    var e = rZ(t) ? "checked" : "value", n = Object.getOwnPropertyDescriptor(t.constructor.prototype, e), r = "" + t[e];
    if (!t.hasOwnProperty(e) && typeof n < "u" && typeof n.get == "function" && typeof n.set == "function") {
      var i = n.get, s = n.set;
      return Object.defineProperty(t, e, {
        configurable: true,
        get: function() {
          return i.call(this);
        },
        set: function(o) {
          r = "" + o, s.call(this, o);
        }
      }), Object.defineProperty(t, e, {
        enumerable: n.enumerable
      }), {
        getValue: function() {
          return r;
        },
        setValue: function(o) {
          r = "" + o;
        },
        stopTracking: function() {
          t._valueTracker = null, delete t[e];
        }
      };
    }
  }
  function U1(t) {
    t._valueTracker || (t._valueTracker = Qve(t));
  }
  function iZ(t) {
    if (!t)
      return false;
    var e = t._valueTracker;
    if (!e)
      return true;
    var n = e.getValue(), r = "";
    return t && (r = rZ(t) ? t.checked ? "true" : "false" : t.value), t = r, t !== n ? (e.setValue(t), true) : false;
  }
  function zb(t) {
    if (t = t || (typeof document < "u" ? document : void 0), typeof t > "u")
      return null;
    try {
      return t.activeElement || t.body;
    } catch {
      return t.body;
    }
  }
  function nA(t, e) {
    var n = e.checked;
    return Ln({}, e, {
      defaultChecked: void 0,
      defaultValue: void 0,
      value: void 0,
      checked: n ?? t._wrapperState.initialChecked
    });
  }
  function u6(t, e) {
    var n = e.defaultValue == null ? "" : e.defaultValue, r = e.checked != null ? e.checked : e.defaultChecked;
    n = Od(e.value != null ? e.value : n), t._wrapperState = {
      initialChecked: r,
      initialValue: n,
      controlled: e.type === "checkbox" || e.type === "radio" ? e.checked != null : e.value != null
    };
  }
  function sZ(t, e) {
    e = e.checked, e != null && r3(t, "checked", e, false);
  }
  function rA(t, e) {
    sZ(t, e);
    var n = Od(e.value), r = e.type;
    if (n != null)
      r === "number" ? (n === 0 && t.value === "" || t.value != n) && (t.value = "" + n) : t.value !== "" + n && (t.value = "" + n);
    else if (r === "submit" || r === "reset") {
      t.removeAttribute("value");
      return;
    }
    e.hasOwnProperty("value") ? iA(t, e.type, n) : e.hasOwnProperty("defaultValue") && iA(t, e.type, Od(e.defaultValue)), e.checked == null && e.defaultChecked != null && (t.defaultChecked = !!e.defaultChecked);
  }
  function d6(t, e, n) {
    if (e.hasOwnProperty("value") || e.hasOwnProperty("defaultValue")) {
      var r = e.type;
      if (!(r !== "submit" && r !== "reset" || e.value !== void 0 && e.value !== null))
        return;
      e = "" + t._wrapperState.initialValue, n || e === t.value || (t.value = e), t.defaultValue = e;
    }
    n = t.name, n !== "" && (t.name = ""), t.defaultChecked = !!t._wrapperState.initialChecked, n !== "" && (t.name = n);
  }
  function iA(t, e, n) {
    (e !== "number" || zb(t.ownerDocument) !== t) && (n == null ? t.defaultValue = "" + t._wrapperState.initialValue : t.defaultValue !== "" + n && (t.defaultValue = "" + n));
  }
  var p0 = Array.isArray;
  function ag(t, e, n, r) {
    if (t = t.options, e) {
      e = {};
      for (var i = 0; i < n.length; i++)
        e["$" + n[i]] = true;
      for (n = 0; n < t.length; n++)
        i = e.hasOwnProperty("$" + t[n].value), t[n].selected !== i && (t[n].selected = i), i && r && (t[n].defaultSelected = true);
    } else {
      for (n = "" + Od(n), e = null, i = 0; i < t.length; i++) {
        if (t[i].value === n) {
          t[i].selected = true, r && (t[i].defaultSelected = true);
          return;
        }
        e !== null || t[i].disabled || (e = t[i]);
      }
      e !== null && (e.selected = true);
    }
  }
  function sA(t, e) {
    if (e.dangerouslySetInnerHTML != null)
      throw Error(Oe(91));
    return Ln({}, e, {
      value: void 0,
      defaultValue: void 0,
      children: "" + t._wrapperState.initialValue
    });
  }
  function h6(t, e) {
    var n = e.value;
    if (n == null) {
      if (n = e.children, e = e.defaultValue, n != null) {
        if (e != null)
          throw Error(Oe(92));
        if (p0(n)) {
          if (1 < n.length)
            throw Error(Oe(93));
          n = n[0];
        }
        e = n;
      }
      e == null && (e = ""), n = e;
    }
    t._wrapperState = {
      initialValue: Od(n)
    };
  }
  function oZ(t, e) {
    var n = Od(e.value), r = Od(e.defaultValue);
    n != null && (n = "" + n, n !== t.value && (t.value = n), e.defaultValue == null && t.defaultValue !== n && (t.defaultValue = n)), r != null && (t.defaultValue = "" + r);
  }
  function f6(t) {
    var e = t.textContent;
    e === t._wrapperState.initialValue && e !== "" && e !== null && (t.value = e);
  }
  function aZ(t) {
    switch (t) {
      case "svg":
        return "http://www.w3.org/2000/svg";
      case "math":
        return "http://www.w3.org/1998/Math/MathML";
      default:
        return "http://www.w3.org/1999/xhtml";
    }
  }
  function oA(t, e) {
    return t == null || t === "http://www.w3.org/1999/xhtml" ? aZ(e) : t === "http://www.w3.org/2000/svg" && e === "foreignObject" ? "http://www.w3.org/1999/xhtml" : t;
  }
  var V1, lZ = function(t) {
    return typeof MSApp < "u" && MSApp.execUnsafeLocalFunction ? function(e, n, r, i) {
      MSApp.execUnsafeLocalFunction(function() {
        return t(e, n, r, i);
      });
    } : t;
  }(function(t, e) {
    if (t.namespaceURI !== "http://www.w3.org/2000/svg" || "innerHTML" in t)
      t.innerHTML = e;
    else {
      for (V1 = V1 || document.createElement("div"), V1.innerHTML = "<svg>" + e.valueOf().toString() + "</svg>", e = V1.firstChild; t.firstChild; )
        t.removeChild(t.firstChild);
      for (; e.firstChild; )
        t.appendChild(e.firstChild);
    }
  });
  function kv(t, e) {
    if (e) {
      var n = t.firstChild;
      if (n && n === t.lastChild && n.nodeType === 3) {
        n.nodeValue = e;
        return;
      }
    }
    t.textContent = e;
  }
  var j0 = {
    animationIterationCount: true,
    aspectRatio: true,
    borderImageOutset: true,
    borderImageSlice: true,
    borderImageWidth: true,
    boxFlex: true,
    boxFlexGroup: true,
    boxOrdinalGroup: true,
    columnCount: true,
    columns: true,
    flex: true,
    flexGrow: true,
    flexPositive: true,
    flexShrink: true,
    flexNegative: true,
    flexOrder: true,
    gridArea: true,
    gridRow: true,
    gridRowEnd: true,
    gridRowSpan: true,
    gridRowStart: true,
    gridColumn: true,
    gridColumnEnd: true,
    gridColumnSpan: true,
    gridColumnStart: true,
    fontWeight: true,
    lineClamp: true,
    lineHeight: true,
    opacity: true,
    order: true,
    orphans: true,
    tabSize: true,
    widows: true,
    zIndex: true,
    zoom: true,
    fillOpacity: true,
    floodOpacity: true,
    stopOpacity: true,
    strokeDasharray: true,
    strokeDashoffset: true,
    strokeMiterlimit: true,
    strokeOpacity: true,
    strokeWidth: true
  }, zve = [
    "Webkit",
    "ms",
    "Moz",
    "O"
  ];
  Object.keys(j0).forEach(function(t) {
    zve.forEach(function(e) {
      e = e + t.charAt(0).toUpperCase() + t.substring(1), j0[e] = j0[t];
    });
  });
  function cZ(t, e, n) {
    return e == null || typeof e == "boolean" || e === "" ? "" : n || typeof e != "number" || e === 0 || j0.hasOwnProperty(t) && j0[t] ? ("" + e).trim() : e + "px";
  }
  function uZ(t, e) {
    t = t.style;
    for (var n in e)
      if (e.hasOwnProperty(n)) {
        var r = n.indexOf("--") === 0, i = cZ(n, e[n], r);
        n === "float" && (n = "cssFloat"), r ? t.setProperty(n, i) : t[n] = i;
      }
  }
  var Fve = Ln({
    menuitem: true
  }, {
    area: true,
    base: true,
    br: true,
    col: true,
    embed: true,
    hr: true,
    img: true,
    input: true,
    keygen: true,
    link: true,
    meta: true,
    param: true,
    source: true,
    track: true,
    wbr: true
  });
  function aA(t, e) {
    if (e) {
      if (Fve[t] && (e.children != null || e.dangerouslySetInnerHTML != null))
        throw Error(Oe(137, t));
      if (e.dangerouslySetInnerHTML != null) {
        if (e.children != null)
          throw Error(Oe(60));
        if (typeof e.dangerouslySetInnerHTML != "object" || !("__html" in e.dangerouslySetInnerHTML))
          throw Error(Oe(61));
      }
      if (e.style != null && typeof e.style != "object")
        throw Error(Oe(62));
    }
  }
  function lA(t, e) {
    if (t.indexOf("-") === -1)
      return typeof e.is == "string";
    switch (t) {
      case "annotation-xml":
      case "color-profile":
      case "font-face":
      case "font-face-src":
      case "font-face-uri":
      case "font-face-format":
      case "font-face-name":
      case "missing-glyph":
        return false;
      default:
        return true;
    }
  }
  var cA = null;
  function a3(t) {
    return t = t.target || t.srcElement || window, t.correspondingUseElement && (t = t.correspondingUseElement), t.nodeType === 3 ? t.parentNode : t;
  }
  var uA = null, lg = null, cg = null;
  function p6(t) {
    if (t = XO(t)) {
      if (typeof uA != "function")
        throw Error(Oe(280));
      var e = t.stateNode;
      e && (e = iC(e), uA(t.stateNode, t.type, e));
    }
  }
  function dZ(t) {
    lg ? cg ? cg.push(t) : cg = [
      t
    ] : lg = t;
  }
  function hZ() {
    if (lg) {
      var t = lg, e = cg;
      if (cg = lg = null, p6(t), e)
        for (t = 0; t < e.length; t++)
          p6(e[t]);
    }
  }
  function fZ(t, e) {
    return t(e);
  }
  function pZ() {
  }
  var NT = false;
  function gZ(t, e, n) {
    if (NT)
      return t(e, n);
    NT = true;
    try {
      return fZ(t, e, n);
    } finally {
      NT = false, (lg !== null || cg !== null) && (pZ(), hZ());
    }
  }
  function Pv(t, e) {
    var n = t.stateNode;
    if (n === null)
      return null;
    var r = iC(n);
    if (r === null)
      return null;
    n = r[e];
    e:
      switch (e) {
        case "onClick":
        case "onClickCapture":
        case "onDoubleClick":
        case "onDoubleClickCapture":
        case "onMouseDown":
        case "onMouseDownCapture":
        case "onMouseMove":
        case "onMouseMoveCapture":
        case "onMouseUp":
        case "onMouseUpCapture":
        case "onMouseEnter":
          (r = !r.disabled) || (t = t.type, r = !(t === "button" || t === "input" || t === "select" || t === "textarea")), t = !r;
          break e;
        default:
          t = false;
      }
    if (t)
      return null;
    if (n && typeof n != "function")
      throw Error(Oe(231, e, typeof n));
    return n;
  }
  var dA = false;
  if (Uc)
    try {
      var Cy = {};
      Object.defineProperty(Cy, "passive", {
        get: function() {
          dA = true;
        }
      }), window.addEventListener("test", Cy, Cy), window.removeEventListener("test", Cy, Cy);
    } catch {
      dA = false;
    }
  function Bve(t, e, n, r, i, s, o, a, l) {
    var c = Array.prototype.slice.call(arguments, 3);
    try {
      e.apply(n, c);
    } catch (u) {
      this.onError(u);
    }
  }
  var N0 = false, Fb = null, Bb = false, hA = null, Uve = {
    onError: function(t) {
      N0 = true, Fb = t;
    }
  };
  function Vve(t, e, n, r, i, s, o, a, l) {
    N0 = false, Fb = null, Bve.apply(Uve, arguments);
  }
  function Xve(t, e, n, r, i, s, o, a, l) {
    if (Vve.apply(this, arguments), N0) {
      if (N0) {
        var c = Fb;
        N0 = false, Fb = null;
      } else
        throw Error(Oe(198));
      Bb || (Bb = true, hA = c);
    }
  }
  function yf(t) {
    var e = t, n = t;
    if (t.alternate)
      for (; e.return; )
        e = e.return;
    else {
      t = e;
      do
        e = t, e.flags & 4098 && (n = e.return), t = e.return;
      while (t);
    }
    return e.tag === 3 ? n : null;
  }
  function mZ(t) {
    if (t.tag === 13) {
      var e = t.memoizedState;
      if (e === null && (t = t.alternate, t !== null && (e = t.memoizedState)), e !== null)
        return e.dehydrated;
    }
    return null;
  }
  function g6(t) {
    if (yf(t) !== t)
      throw Error(Oe(188));
  }
  function Wve(t) {
    var e = t.alternate;
    if (!e) {
      if (e = yf(t), e === null)
        throw Error(Oe(188));
      return e !== t ? null : t;
    }
    for (var n = t, r = e; ; ) {
      var i = n.return;
      if (i === null)
        break;
      var s = i.alternate;
      if (s === null) {
        if (r = i.return, r !== null) {
          n = r;
          continue;
        }
        break;
      }
      if (i.child === s.child) {
        for (s = i.child; s; ) {
          if (s === n)
            return g6(i), t;
          if (s === r)
            return g6(i), e;
          s = s.sibling;
        }
        throw Error(Oe(188));
      }
      if (n.return !== r.return)
        n = i, r = s;
      else {
        for (var o = false, a = i.child; a; ) {
          if (a === n) {
            o = true, n = i, r = s;
            break;
          }
          if (a === r) {
            o = true, r = i, n = s;
            break;
          }
          a = a.sibling;
        }
        if (!o) {
          for (a = s.child; a; ) {
            if (a === n) {
              o = true, n = s, r = i;
              break;
            }
            if (a === r) {
              o = true, r = s, n = i;
              break;
            }
            a = a.sibling;
          }
          if (!o)
            throw Error(Oe(189));
        }
      }
      if (n.alternate !== r)
        throw Error(Oe(190));
    }
    if (n.tag !== 3)
      throw Error(Oe(188));
    return n.stateNode.current === n ? t : e;
  }
  function yZ(t) {
    return t = Wve(t), t !== null ? vZ(t) : null;
  }
  function vZ(t) {
    if (t.tag === 5 || t.tag === 6)
      return t;
    for (t = t.child; t !== null; ) {
      var e = vZ(t);
      if (e !== null)
        return e;
      t = t.sibling;
    }
    return null;
  }
  var OZ = ao.unstable_scheduleCallback, m6 = ao.unstable_cancelCallback, Zve = ao.unstable_shouldYield, Hve = ao.unstable_requestPaint, Gn = ao.unstable_now, Yve = ao.unstable_getCurrentPriorityLevel, l3 = ao.unstable_ImmediatePriority, SZ = ao.unstable_UserBlockingPriority, Ub = ao.unstable_NormalPriority, Gve = ao.unstable_LowPriority, wZ = ao.unstable_IdlePriority, eC = null, Il = null;
  function qve(t) {
    if (Il && typeof Il.onCommitFiberRoot == "function")
      try {
        Il.onCommitFiberRoot(eC, t, void 0, (t.current.flags & 128) === 128);
      } catch {
      }
  }
  var Da = Math.clz32 ? Math.clz32 : eOe, Kve = Math.log, Jve = Math.LN2;
  function eOe(t) {
    return t >>>= 0, t === 0 ? 32 : 31 - (Kve(t) / Jve | 0) | 0;
  }
  var X1 = 64, W1 = 4194304;
  function g0(t) {
    switch (t & -t) {
      case 1:
        return 1;
      case 2:
        return 2;
      case 4:
        return 4;
      case 8:
        return 8;
      case 16:
        return 16;
      case 32:
        return 32;
      case 64:
      case 128:
      case 256:
      case 512:
      case 1024:
      case 2048:
      case 4096:
      case 8192:
      case 16384:
      case 32768:
      case 65536:
      case 131072:
      case 262144:
      case 524288:
      case 1048576:
      case 2097152:
        return t & 4194240;
      case 4194304:
      case 8388608:
      case 16777216:
      case 33554432:
      case 67108864:
        return t & 130023424;
      case 134217728:
        return 134217728;
      case 268435456:
        return 268435456;
      case 536870912:
        return 536870912;
      case 1073741824:
        return 1073741824;
      default:
        return t;
    }
  }
  function Vb(t, e) {
    var n = t.pendingLanes;
    if (n === 0)
      return 0;
    var r = 0, i = t.suspendedLanes, s = t.pingedLanes, o = n & 268435455;
    if (o !== 0) {
      var a = o & ~i;
      a !== 0 ? r = g0(a) : (s &= o, s !== 0 && (r = g0(s)));
    } else
      o = n & ~i, o !== 0 ? r = g0(o) : s !== 0 && (r = g0(s));
    if (r === 0)
      return 0;
    if (e !== 0 && e !== r && !(e & i) && (i = r & -r, s = e & -e, i >= s || i === 16 && (s & 4194240) !== 0))
      return e;
    if (r & 4 && (r |= n & 16), e = t.entangledLanes, e !== 0)
      for (t = t.entanglements, e &= r; 0 < e; )
        n = 31 - Da(e), i = 1 << n, r |= t[n], e &= ~i;
    return r;
  }
  function tOe(t, e) {
    switch (t) {
      case 1:
      case 2:
      case 4:
        return e + 250;
      case 8:
      case 16:
      case 32:
      case 64:
      case 128:
      case 256:
      case 512:
      case 1024:
      case 2048:
      case 4096:
      case 8192:
      case 16384:
      case 32768:
      case 65536:
      case 131072:
      case 262144:
      case 524288:
      case 1048576:
      case 2097152:
        return e + 5e3;
      case 4194304:
      case 8388608:
      case 16777216:
      case 33554432:
      case 67108864:
        return -1;
      case 134217728:
      case 268435456:
      case 536870912:
      case 1073741824:
        return -1;
      default:
        return -1;
    }
  }
  function nOe(t, e) {
    for (var n = t.suspendedLanes, r = t.pingedLanes, i = t.expirationTimes, s = t.pendingLanes; 0 < s; ) {
      var o = 31 - Da(s), a = 1 << o, l = i[o];
      l === -1 ? (!(a & n) || a & r) && (i[o] = tOe(a, e)) : l <= e && (t.expiredLanes |= a), s &= ~a;
    }
  }
  function fA(t) {
    return t = t.pendingLanes & -1073741825, t !== 0 ? t : t & 1073741824 ? 1073741824 : 0;
  }
  function xZ() {
    var t = X1;
    return X1 <<= 1, !(X1 & 4194240) && (X1 = 64), t;
  }
  function QT(t) {
    for (var e = [], n = 0; 31 > n; n++)
      e.push(t);
    return e;
  }
  function UO(t, e, n) {
    t.pendingLanes |= e, e !== 536870912 && (t.suspendedLanes = 0, t.pingedLanes = 0), t = t.eventTimes, e = 31 - Da(e), t[e] = n;
  }
  function rOe(t, e) {
    var n = t.pendingLanes & ~e;
    t.pendingLanes = e, t.suspendedLanes = 0, t.pingedLanes = 0, t.expiredLanes &= e, t.mutableReadLanes &= e, t.entangledLanes &= e, e = t.entanglements;
    var r = t.eventTimes;
    for (t = t.expirationTimes; 0 < n; ) {
      var i = 31 - Da(n), s = 1 << i;
      e[i] = 0, r[i] = -1, t[i] = -1, n &= ~s;
    }
  }
  function c3(t, e) {
    var n = t.entangledLanes |= e;
    for (t = t.entanglements; n; ) {
      var r = 31 - Da(n), i = 1 << r;
      i & e | t[r] & e && (t[r] |= e), n &= ~i;
    }
  }
  var Zt = 0;
  function bZ(t) {
    return t &= -t, 1 < t ? 4 < t ? t & 268435455 ? 16 : 536870912 : 4 : 1;
  }
  var kZ, u3, PZ, CZ, _Z, pA = false, Z1 = [], ld = null, cd = null, ud = null, Cv = /* @__PURE__ */ new Map(), _v = /* @__PURE__ */ new Map(), Qu = [], iOe = "mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");
  function y6(t, e) {
    switch (t) {
      case "focusin":
      case "focusout":
        ld = null;
        break;
      case "dragenter":
      case "dragleave":
        cd = null;
        break;
      case "mouseover":
      case "mouseout":
        ud = null;
        break;
      case "pointerover":
      case "pointerout":
        Cv.delete(e.pointerId);
        break;
      case "gotpointercapture":
      case "lostpointercapture":
        _v.delete(e.pointerId);
    }
  }
  function _y(t, e, n, r, i, s) {
    return t === null || t.nativeEvent !== s ? (t = {
      blockedOn: e,
      domEventName: n,
      eventSystemFlags: r,
      nativeEvent: s,
      targetContainers: [
        i
      ]
    }, e !== null && (e = XO(e), e !== null && u3(e)), t) : (t.eventSystemFlags |= r, e = t.targetContainers, i !== null && e.indexOf(i) === -1 && e.push(i), t);
  }
  function sOe(t, e, n, r, i) {
    switch (e) {
      case "focusin":
        return ld = _y(ld, t, e, n, r, i), true;
      case "dragenter":
        return cd = _y(cd, t, e, n, r, i), true;
      case "mouseover":
        return ud = _y(ud, t, e, n, r, i), true;
      case "pointerover":
        var s = i.pointerId;
        return Cv.set(s, _y(Cv.get(s) || null, t, e, n, r, i)), true;
      case "gotpointercapture":
        return s = i.pointerId, _v.set(s, _y(_v.get(s) || null, t, e, n, r, i)), true;
    }
    return false;
  }
  function TZ(t) {
    var e = Eh(t.target);
    if (e !== null) {
      var n = yf(e);
      if (n !== null) {
        if (e = n.tag, e === 13) {
          if (e = mZ(n), e !== null) {
            t.blockedOn = e, _Z(t.priority, function() {
              PZ(n);
            });
            return;
          }
        } else if (e === 3 && n.stateNode.current.memoizedState.isDehydrated) {
          t.blockedOn = n.tag === 3 ? n.stateNode.containerInfo : null;
          return;
        }
      }
    }
    t.blockedOn = null;
  }
  function Mx(t) {
    if (t.blockedOn !== null)
      return false;
    for (var e = t.targetContainers; 0 < e.length; ) {
      var n = gA(t.domEventName, t.eventSystemFlags, e[0], t.nativeEvent);
      if (n === null) {
        n = t.nativeEvent;
        var r = new n.constructor(n.type, n);
        cA = r, n.target.dispatchEvent(r), cA = null;
      } else
        return e = XO(n), e !== null && u3(e), t.blockedOn = n, false;
      e.shift();
    }
    return true;
  }
  function v6(t, e, n) {
    Mx(t) && n.delete(e);
  }
  function oOe() {
    pA = false, ld !== null && Mx(ld) && (ld = null), cd !== null && Mx(cd) && (cd = null), ud !== null && Mx(ud) && (ud = null), Cv.forEach(v6), _v.forEach(v6);
  }
  function Ty(t, e) {
    t.blockedOn === e && (t.blockedOn = null, pA || (pA = true, ao.unstable_scheduleCallback(ao.unstable_NormalPriority, oOe)));
  }
  function Tv(t) {
    function e(i) {
      return Ty(i, t);
    }
    if (0 < Z1.length) {
      Ty(Z1[0], t);
      for (var n = 1; n < Z1.length; n++) {
        var r = Z1[n];
        r.blockedOn === t && (r.blockedOn = null);
      }
    }
    for (ld !== null && Ty(ld, t), cd !== null && Ty(cd, t), ud !== null && Ty(ud, t), Cv.forEach(e), _v.forEach(e), n = 0; n < Qu.length; n++)
      r = Qu[n], r.blockedOn === t && (r.blockedOn = null);
    for (; 0 < Qu.length && (n = Qu[0], n.blockedOn === null); )
      TZ(n), n.blockedOn === null && Qu.shift();
  }
  var ug = eu.ReactCurrentBatchConfig, Xb = true;
  function aOe(t, e, n, r) {
    var i = Zt, s = ug.transition;
    ug.transition = null;
    try {
      Zt = 1, d3(t, e, n, r);
    } finally {
      Zt = i, ug.transition = s;
    }
  }
  function lOe(t, e, n, r) {
    var i = Zt, s = ug.transition;
    ug.transition = null;
    try {
      Zt = 4, d3(t, e, n, r);
    } finally {
      Zt = i, ug.transition = s;
    }
  }
  function d3(t, e, n, r) {
    if (Xb) {
      var i = gA(t, e, n, r);
      if (i === null)
        YT(t, e, r, Wb, n), y6(t, r);
      else if (sOe(i, t, e, n, r))
        r.stopPropagation();
      else if (y6(t, r), e & 4 && -1 < iOe.indexOf(t)) {
        for (; i !== null; ) {
          var s = XO(i);
          if (s !== null && kZ(s), s = gA(t, e, n, r), s === null && YT(t, e, r, Wb, n), s === i)
            break;
          i = s;
        }
        i !== null && r.stopPropagation();
      } else
        YT(t, e, r, null, n);
    }
  }
  var Wb = null;
  function gA(t, e, n, r) {
    if (Wb = null, t = a3(r), t = Eh(t), t !== null)
      if (e = yf(t), e === null)
        t = null;
      else if (n = e.tag, n === 13) {
        if (t = mZ(e), t !== null)
          return t;
        t = null;
      } else if (n === 3) {
        if (e.stateNode.current.memoizedState.isDehydrated)
          return e.tag === 3 ? e.stateNode.containerInfo : null;
        t = null;
      } else
        e !== t && (t = null);
    return Wb = t, null;
  }
  function EZ(t) {
    switch (t) {
      case "cancel":
      case "click":
      case "close":
      case "contextmenu":
      case "copy":
      case "cut":
      case "auxclick":
      case "dblclick":
      case "dragend":
      case "dragstart":
      case "drop":
      case "focusin":
      case "focusout":
      case "input":
      case "invalid":
      case "keydown":
      case "keypress":
      case "keyup":
      case "mousedown":
      case "mouseup":
      case "paste":
      case "pause":
      case "play":
      case "pointercancel":
      case "pointerdown":
      case "pointerup":
      case "ratechange":
      case "reset":
      case "resize":
      case "seeked":
      case "submit":
      case "touchcancel":
      case "touchend":
      case "touchstart":
      case "volumechange":
      case "change":
      case "selectionchange":
      case "textInput":
      case "compositionstart":
      case "compositionend":
      case "compositionupdate":
      case "beforeblur":
      case "afterblur":
      case "beforeinput":
      case "blur":
      case "fullscreenchange":
      case "focus":
      case "hashchange":
      case "popstate":
      case "select":
      case "selectstart":
        return 1;
      case "drag":
      case "dragenter":
      case "dragexit":
      case "dragleave":
      case "dragover":
      case "mousemove":
      case "mouseout":
      case "mouseover":
      case "pointermove":
      case "pointerout":
      case "pointerover":
      case "scroll":
      case "toggle":
      case "touchmove":
      case "wheel":
      case "mouseenter":
      case "mouseleave":
      case "pointerenter":
      case "pointerleave":
        return 4;
      case "message":
        switch (Yve()) {
          case l3:
            return 1;
          case SZ:
            return 4;
          case Ub:
          case Gve:
            return 16;
          case wZ:
            return 536870912;
          default:
            return 16;
        }
      default:
        return 16;
    }
  }
  var Wu = null, h3 = null, Dx = null;
  function IZ() {
    if (Dx)
      return Dx;
    var t, e = h3, n = e.length, r, i = "value" in Wu ? Wu.value : Wu.textContent, s = i.length;
    for (t = 0; t < n && e[t] === i[t]; t++)
      ;
    var o = n - t;
    for (r = 1; r <= o && e[n - r] === i[s - r]; r++)
      ;
    return Dx = i.slice(t, 1 < r ? 1 - r : void 0);
  }
  function Lx(t) {
    var e = t.keyCode;
    return "charCode" in t ? (t = t.charCode, t === 0 && e === 13 && (t = 13)) : t = e, t === 10 && (t = 13), 32 <= t || t === 13 ? t : 0;
  }
  function H1() {
    return true;
  }
  function O6() {
    return false;
  }
  function co(t) {
    function e(n, r, i, s, o) {
      this._reactName = n, this._targetInst = i, this.type = r, this.nativeEvent = s, this.target = o, this.currentTarget = null;
      for (var a in t)
        t.hasOwnProperty(a) && (n = t[a], this[a] = n ? n(s) : s[a]);
      return this.isDefaultPrevented = (s.defaultPrevented != null ? s.defaultPrevented : s.returnValue === false) ? H1 : O6, this.isPropagationStopped = O6, this;
    }
    return Ln(e.prototype, {
      preventDefault: function() {
        this.defaultPrevented = true;
        var n = this.nativeEvent;
        n && (n.preventDefault ? n.preventDefault() : typeof n.returnValue != "unknown" && (n.returnValue = false), this.isDefaultPrevented = H1);
      },
      stopPropagation: function() {
        var n = this.nativeEvent;
        n && (n.stopPropagation ? n.stopPropagation() : typeof n.cancelBubble != "unknown" && (n.cancelBubble = true), this.isPropagationStopped = H1);
      },
      persist: function() {
      },
      isPersistent: H1
    }), e;
  }
  var vm = {
    eventPhase: 0,
    bubbles: 0,
    cancelable: 0,
    timeStamp: function(t) {
      return t.timeStamp || Date.now();
    },
    defaultPrevented: 0,
    isTrusted: 0
  }, f3 = co(vm), VO = Ln({}, vm, {
    view: 0,
    detail: 0
  }), cOe = co(VO), zT, FT, Ey, tC = Ln({}, VO, {
    screenX: 0,
    screenY: 0,
    clientX: 0,
    clientY: 0,
    pageX: 0,
    pageY: 0,
    ctrlKey: 0,
    shiftKey: 0,
    altKey: 0,
    metaKey: 0,
    getModifierState: p3,
    button: 0,
    buttons: 0,
    relatedTarget: function(t) {
      return t.relatedTarget === void 0 ? t.fromElement === t.srcElement ? t.toElement : t.fromElement : t.relatedTarget;
    },
    movementX: function(t) {
      return "movementX" in t ? t.movementX : (t !== Ey && (Ey && t.type === "mousemove" ? (zT = t.screenX - Ey.screenX, FT = t.screenY - Ey.screenY) : FT = zT = 0, Ey = t), zT);
    },
    movementY: function(t) {
      return "movementY" in t ? t.movementY : FT;
    }
  }), S6 = co(tC), uOe = Ln({}, tC, {
    dataTransfer: 0
  }), dOe = co(uOe), hOe = Ln({}, VO, {
    relatedTarget: 0
  }), BT = co(hOe), fOe = Ln({}, vm, {
    animationName: 0,
    elapsedTime: 0,
    pseudoElement: 0
  }), pOe = co(fOe), gOe = Ln({}, vm, {
    clipboardData: function(t) {
      return "clipboardData" in t ? t.clipboardData : window.clipboardData;
    }
  }), mOe = co(gOe), yOe = Ln({}, vm, {
    data: 0
  }), w6 = co(yOe), vOe = {
    Esc: "Escape",
    Spacebar: " ",
    Left: "ArrowLeft",
    Up: "ArrowUp",
    Right: "ArrowRight",
    Down: "ArrowDown",
    Del: "Delete",
    Win: "OS",
    Menu: "ContextMenu",
    Apps: "ContextMenu",
    Scroll: "ScrollLock",
    MozPrintableKey: "Unidentified"
  }, OOe = {
    8: "Backspace",
    9: "Tab",
    12: "Clear",
    13: "Enter",
    16: "Shift",
    17: "Control",
    18: "Alt",
    19: "Pause",
    20: "CapsLock",
    27: "Escape",
    32: " ",
    33: "PageUp",
    34: "PageDown",
    35: "End",
    36: "Home",
    37: "ArrowLeft",
    38: "ArrowUp",
    39: "ArrowRight",
    40: "ArrowDown",
    45: "Insert",
    46: "Delete",
    112: "F1",
    113: "F2",
    114: "F3",
    115: "F4",
    116: "F5",
    117: "F6",
    118: "F7",
    119: "F8",
    120: "F9",
    121: "F10",
    122: "F11",
    123: "F12",
    144: "NumLock",
    145: "ScrollLock",
    224: "Meta"
  }, SOe = {
    Alt: "altKey",
    Control: "ctrlKey",
    Meta: "metaKey",
    Shift: "shiftKey"
  };
  function wOe(t) {
    var e = this.nativeEvent;
    return e.getModifierState ? e.getModifierState(t) : (t = SOe[t]) ? !!e[t] : false;
  }
  function p3() {
    return wOe;
  }
  var xOe = Ln({}, VO, {
    key: function(t) {
      if (t.key) {
        var e = vOe[t.key] || t.key;
        if (e !== "Unidentified")
          return e;
      }
      return t.type === "keypress" ? (t = Lx(t), t === 13 ? "Enter" : String.fromCharCode(t)) : t.type === "keydown" || t.type === "keyup" ? OOe[t.keyCode] || "Unidentified" : "";
    },
    code: 0,
    location: 0,
    ctrlKey: 0,
    shiftKey: 0,
    altKey: 0,
    metaKey: 0,
    repeat: 0,
    locale: 0,
    getModifierState: p3,
    charCode: function(t) {
      return t.type === "keypress" ? Lx(t) : 0;
    },
    keyCode: function(t) {
      return t.type === "keydown" || t.type === "keyup" ? t.keyCode : 0;
    },
    which: function(t) {
      return t.type === "keypress" ? Lx(t) : t.type === "keydown" || t.type === "keyup" ? t.keyCode : 0;
    }
  }), bOe = co(xOe), kOe = Ln({}, tC, {
    pointerId: 0,
    width: 0,
    height: 0,
    pressure: 0,
    tangentialPressure: 0,
    tiltX: 0,
    tiltY: 0,
    twist: 0,
    pointerType: 0,
    isPrimary: 0
  }), x6 = co(kOe), POe = Ln({}, VO, {
    touches: 0,
    targetTouches: 0,
    changedTouches: 0,
    altKey: 0,
    metaKey: 0,
    ctrlKey: 0,
    shiftKey: 0,
    getModifierState: p3
  }), COe = co(POe), _Oe = Ln({}, vm, {
    propertyName: 0,
    elapsedTime: 0,
    pseudoElement: 0
  }), TOe = co(_Oe), EOe = Ln({}, tC, {
    deltaX: function(t) {
      return "deltaX" in t ? t.deltaX : "wheelDeltaX" in t ? -t.wheelDeltaX : 0;
    },
    deltaY: function(t) {
      return "deltaY" in t ? t.deltaY : "wheelDeltaY" in t ? -t.wheelDeltaY : "wheelDelta" in t ? -t.wheelDelta : 0;
    },
    deltaZ: 0,
    deltaMode: 0
  }), IOe = co(EOe), $Oe = [
    9,
    13,
    27,
    32
  ], g3 = Uc && "CompositionEvent" in window, Q0 = null;
  Uc && "documentMode" in document && (Q0 = document.documentMode);
  var AOe = Uc && "TextEvent" in window && !Q0, $Z = Uc && (!g3 || Q0 && 8 < Q0 && 11 >= Q0), b6 = String.fromCharCode(32), k6 = false;
  function AZ(t, e) {
    switch (t) {
      case "keyup":
        return $Oe.indexOf(e.keyCode) !== -1;
      case "keydown":
        return e.keyCode !== 229;
      case "keypress":
      case "mousedown":
      case "focusout":
        return true;
      default:
        return false;
    }
  }
  function RZ(t) {
    return t = t.detail, typeof t == "object" && "data" in t ? t.data : null;
  }
  var Fp = false;
  function ROe(t, e) {
    switch (t) {
      case "compositionend":
        return RZ(e);
      case "keypress":
        return e.which !== 32 ? null : (k6 = true, b6);
      case "textInput":
        return t = e.data, t === b6 && k6 ? null : t;
      default:
        return null;
    }
  }
  function MOe(t, e) {
    if (Fp)
      return t === "compositionend" || !g3 && AZ(t, e) ? (t = IZ(), Dx = h3 = Wu = null, Fp = false, t) : null;
    switch (t) {
      case "paste":
        return null;
      case "keypress":
        if (!(e.ctrlKey || e.altKey || e.metaKey) || e.ctrlKey && e.altKey) {
          if (e.char && 1 < e.char.length)
            return e.char;
          if (e.which)
            return String.fromCharCode(e.which);
        }
        return null;
      case "compositionend":
        return $Z && e.locale !== "ko" ? null : e.data;
      default:
        return null;
    }
  }
  var DOe = {
    color: true,
    date: true,
    datetime: true,
    "datetime-local": true,
    email: true,
    month: true,
    number: true,
    password: true,
    range: true,
    search: true,
    tel: true,
    text: true,
    time: true,
    url: true,
    week: true
  };
  function P6(t) {
    var e = t && t.nodeName && t.nodeName.toLowerCase();
    return e === "input" ? !!DOe[t.type] : e === "textarea";
  }
  function MZ(t, e, n, r) {
    dZ(r), e = Zb(e, "onChange"), 0 < e.length && (n = new f3("onChange", "change", null, n, r), t.push({
      event: n,
      listeners: e
    }));
  }
  var z0 = null, Ev = null;
  function LOe(t) {
    XZ(t, 0);
  }
  function nC(t) {
    var e = Vp(t);
    if (iZ(e))
      return t;
  }
  function jOe(t, e) {
    if (t === "change")
      return e;
  }
  var DZ = false;
  if (Uc) {
    var UT;
    if (Uc) {
      var VT = "oninput" in document;
      if (!VT) {
        var C6 = document.createElement("div");
        C6.setAttribute("oninput", "return;"), VT = typeof C6.oninput == "function";
      }
      UT = VT;
    } else
      UT = false;
    DZ = UT && (!document.documentMode || 9 < document.documentMode);
  }
  function _6() {
    z0 && (z0.detachEvent("onpropertychange", LZ), Ev = z0 = null);
  }
  function LZ(t) {
    if (t.propertyName === "value" && nC(Ev)) {
      var e = [];
      MZ(e, Ev, t, a3(t)), gZ(LOe, e);
    }
  }
  function NOe(t, e, n) {
    t === "focusin" ? (_6(), z0 = e, Ev = n, z0.attachEvent("onpropertychange", LZ)) : t === "focusout" && _6();
  }
  function QOe(t) {
    if (t === "selectionchange" || t === "keyup" || t === "keydown")
      return nC(Ev);
  }
  function zOe(t, e) {
    if (t === "click")
      return nC(e);
  }
  function FOe(t, e) {
    if (t === "input" || t === "change")
      return nC(e);
  }
  function BOe(t, e) {
    return t === e && (t !== 0 || 1 / t === 1 / e) || t !== t && e !== e;
  }
  var Ua = typeof Object.is == "function" ? Object.is : BOe;
  function Iv(t, e) {
    if (Ua(t, e))
      return true;
    if (typeof t != "object" || t === null || typeof e != "object" || e === null)
      return false;
    var n = Object.keys(t), r = Object.keys(e);
    if (n.length !== r.length)
      return false;
    for (r = 0; r < n.length; r++) {
      var i = n[r];
      if (!q$.call(e, i) || !Ua(t[i], e[i]))
        return false;
    }
    return true;
  }
  function T6(t) {
    for (; t && t.firstChild; )
      t = t.firstChild;
    return t;
  }
  function E6(t, e) {
    var n = T6(t);
    t = 0;
    for (var r; n; ) {
      if (n.nodeType === 3) {
        if (r = t + n.textContent.length, t <= e && r >= e)
          return {
            node: n,
            offset: e - t
          };
        t = r;
      }
      e: {
        for (; n; ) {
          if (n.nextSibling) {
            n = n.nextSibling;
            break e;
          }
          n = n.parentNode;
        }
        n = void 0;
      }
      n = T6(n);
    }
  }
  function jZ(t, e) {
    return t && e ? t === e ? true : t && t.nodeType === 3 ? false : e && e.nodeType === 3 ? jZ(t, e.parentNode) : "contains" in t ? t.contains(e) : t.compareDocumentPosition ? !!(t.compareDocumentPosition(e) & 16) : false : false;
  }
  function NZ() {
    for (var t = window, e = zb(); e instanceof t.HTMLIFrameElement; ) {
      try {
        var n = typeof e.contentWindow.location.href == "string";
      } catch {
        n = false;
      }
      if (n)
        t = e.contentWindow;
      else
        break;
      e = zb(t.document);
    }
    return e;
  }
  function m3(t) {
    var e = t && t.nodeName && t.nodeName.toLowerCase();
    return e && (e === "input" && (t.type === "text" || t.type === "search" || t.type === "tel" || t.type === "url" || t.type === "password") || e === "textarea" || t.contentEditable === "true");
  }
  function UOe(t) {
    var e = NZ(), n = t.focusedElem, r = t.selectionRange;
    if (e !== n && n && n.ownerDocument && jZ(n.ownerDocument.documentElement, n)) {
      if (r !== null && m3(n)) {
        if (e = r.start, t = r.end, t === void 0 && (t = e), "selectionStart" in n)
          n.selectionStart = e, n.selectionEnd = Math.min(t, n.value.length);
        else if (t = (e = n.ownerDocument || document) && e.defaultView || window, t.getSelection) {
          t = t.getSelection();
          var i = n.textContent.length, s = Math.min(r.start, i);
          r = r.end === void 0 ? s : Math.min(r.end, i), !t.extend && s > r && (i = r, r = s, s = i), i = E6(n, s);
          var o = E6(n, r);
          i && o && (t.rangeCount !== 1 || t.anchorNode !== i.node || t.anchorOffset !== i.offset || t.focusNode !== o.node || t.focusOffset !== o.offset) && (e = e.createRange(), e.setStart(i.node, i.offset), t.removeAllRanges(), s > r ? (t.addRange(e), t.extend(o.node, o.offset)) : (e.setEnd(o.node, o.offset), t.addRange(e)));
        }
      }
      for (e = [], t = n; t = t.parentNode; )
        t.nodeType === 1 && e.push({
          element: t,
          left: t.scrollLeft,
          top: t.scrollTop
        });
      for (typeof n.focus == "function" && n.focus(), n = 0; n < e.length; n++)
        t = e[n], t.element.scrollLeft = t.left, t.element.scrollTop = t.top;
    }
  }
  var VOe = Uc && "documentMode" in document && 11 >= document.documentMode, Bp = null, mA = null, F0 = null, yA = false;
  function I6(t, e, n) {
    var r = n.window === n ? n.document : n.nodeType === 9 ? n : n.ownerDocument;
    yA || Bp == null || Bp !== zb(r) || (r = Bp, "selectionStart" in r && m3(r) ? r = {
      start: r.selectionStart,
      end: r.selectionEnd
    } : (r = (r.ownerDocument && r.ownerDocument.defaultView || window).getSelection(), r = {
      anchorNode: r.anchorNode,
      anchorOffset: r.anchorOffset,
      focusNode: r.focusNode,
      focusOffset: r.focusOffset
    }), F0 && Iv(F0, r) || (F0 = r, r = Zb(mA, "onSelect"), 0 < r.length && (e = new f3("onSelect", "select", null, e, n), t.push({
      event: e,
      listeners: r
    }), e.target = Bp)));
  }
  function Y1(t, e) {
    var n = {};
    return n[t.toLowerCase()] = e.toLowerCase(), n["Webkit" + t] = "webkit" + e, n["Moz" + t] = "moz" + e, n;
  }
  var Up = {
    animationend: Y1("Animation", "AnimationEnd"),
    animationiteration: Y1("Animation", "AnimationIteration"),
    animationstart: Y1("Animation", "AnimationStart"),
    transitionend: Y1("Transition", "TransitionEnd")
  }, XT = {}, QZ = {};
  Uc && (QZ = document.createElement("div").style, "AnimationEvent" in window || (delete Up.animationend.animation, delete Up.animationiteration.animation, delete Up.animationstart.animation), "TransitionEvent" in window || delete Up.transitionend.transition);
  function rC(t) {
    if (XT[t])
      return XT[t];
    if (!Up[t])
      return t;
    var e = Up[t], n;
    for (n in e)
      if (e.hasOwnProperty(n) && n in QZ)
        return XT[t] = e[n];
    return t;
  }
  var zZ = rC("animationend"), FZ = rC("animationiteration"), BZ = rC("animationstart"), UZ = rC("transitionend"), VZ = /* @__PURE__ */ new Map(), $6 = "abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");
  function Md(t, e) {
    VZ.set(t, e), mf(e, [
      t
    ]);
  }
  for (var WT = 0; WT < $6.length; WT++) {
    var ZT = $6[WT], XOe = ZT.toLowerCase(), WOe = ZT[0].toUpperCase() + ZT.slice(1);
    Md(XOe, "on" + WOe);
  }
  Md(zZ, "onAnimationEnd");
  Md(FZ, "onAnimationIteration");
  Md(BZ, "onAnimationStart");
  Md("dblclick", "onDoubleClick");
  Md("focusin", "onFocus");
  Md("focusout", "onBlur");
  Md(UZ, "onTransitionEnd");
  Eg("onMouseEnter", [
    "mouseout",
    "mouseover"
  ]);
  Eg("onMouseLeave", [
    "mouseout",
    "mouseover"
  ]);
  Eg("onPointerEnter", [
    "pointerout",
    "pointerover"
  ]);
  Eg("onPointerLeave", [
    "pointerout",
    "pointerover"
  ]);
  mf("onChange", "change click focusin focusout input keydown keyup selectionchange".split(" "));
  mf("onSelect", "focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));
  mf("onBeforeInput", [
    "compositionend",
    "keypress",
    "textInput",
    "paste"
  ]);
  mf("onCompositionEnd", "compositionend focusout keydown keypress keyup mousedown".split(" "));
  mf("onCompositionStart", "compositionstart focusout keydown keypress keyup mousedown".split(" "));
  mf("onCompositionUpdate", "compositionupdate focusout keydown keypress keyup mousedown".split(" "));
  var m0 = "abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "), ZOe = new Set("cancel close invalid load scroll toggle".split(" ").concat(m0));
  function A6(t, e, n) {
    var r = t.type || "unknown-event";
    t.currentTarget = n, Xve(r, e, void 0, t), t.currentTarget = null;
  }
  function XZ(t, e) {
    e = (e & 4) !== 0;
    for (var n = 0; n < t.length; n++) {
      var r = t[n], i = r.event;
      r = r.listeners;
      e: {
        var s = void 0;
        if (e)
          for (var o = r.length - 1; 0 <= o; o--) {
            var a = r[o], l = a.instance, c = a.currentTarget;
            if (a = a.listener, l !== s && i.isPropagationStopped())
              break e;
            A6(i, a, c), s = l;
          }
        else
          for (o = 0; o < r.length; o++) {
            if (a = r[o], l = a.instance, c = a.currentTarget, a = a.listener, l !== s && i.isPropagationStopped())
              break e;
            A6(i, a, c), s = l;
          }
      }
    }
    if (Bb)
      throw t = hA, Bb = false, hA = null, t;
  }
  function mn(t, e) {
    var n = e[xA];
    n === void 0 && (n = e[xA] = /* @__PURE__ */ new Set());
    var r = t + "__bubble";
    n.has(r) || (WZ(e, t, 2, false), n.add(r));
  }
  function HT(t, e, n) {
    var r = 0;
    e && (r |= 4), WZ(n, t, r, e);
  }
  var G1 = "_reactListening" + Math.random().toString(36).slice(2);
  function $v(t) {
    if (!t[G1]) {
      t[G1] = true, JW.forEach(function(n) {
        n !== "selectionchange" && (ZOe.has(n) || HT(n, false, t), HT(n, true, t));
      });
      var e = t.nodeType === 9 ? t : t.ownerDocument;
      e === null || e[G1] || (e[G1] = true, HT("selectionchange", false, e));
    }
  }
  function WZ(t, e, n, r) {
    switch (EZ(e)) {
      case 1:
        var i = aOe;
        break;
      case 4:
        i = lOe;
        break;
      default:
        i = d3;
    }
    n = i.bind(null, e, n, t), i = void 0, !dA || e !== "touchstart" && e !== "touchmove" && e !== "wheel" || (i = true), r ? i !== void 0 ? t.addEventListener(e, n, {
      capture: true,
      passive: i
    }) : t.addEventListener(e, n, true) : i !== void 0 ? t.addEventListener(e, n, {
      passive: i
    }) : t.addEventListener(e, n, false);
  }
  function YT(t, e, n, r, i) {
    var s = r;
    if (!(e & 1) && !(e & 2) && r !== null)
      e:
        for (; ; ) {
          if (r === null)
            return;
          var o = r.tag;
          if (o === 3 || o === 4) {
            var a = r.stateNode.containerInfo;
            if (a === i || a.nodeType === 8 && a.parentNode === i)
              break;
            if (o === 4)
              for (o = r.return; o !== null; ) {
                var l = o.tag;
                if ((l === 3 || l === 4) && (l = o.stateNode.containerInfo, l === i || l.nodeType === 8 && l.parentNode === i))
                  return;
                o = o.return;
              }
            for (; a !== null; ) {
              if (o = Eh(a), o === null)
                return;
              if (l = o.tag, l === 5 || l === 6) {
                r = s = o;
                continue e;
              }
              a = a.parentNode;
            }
          }
          r = r.return;
        }
    gZ(function() {
      var c = s, u = a3(n), d = [];
      e: {
        var h = VZ.get(t);
        if (h !== void 0) {
          var f = f3, y = t;
          switch (t) {
            case "keypress":
              if (Lx(n) === 0)
                break e;
            case "keydown":
            case "keyup":
              f = bOe;
              break;
            case "focusin":
              y = "focus", f = BT;
              break;
            case "focusout":
              y = "blur", f = BT;
              break;
            case "beforeblur":
            case "afterblur":
              f = BT;
              break;
            case "click":
              if (n.button === 2)
                break e;
            case "auxclick":
            case "dblclick":
            case "mousedown":
            case "mousemove":
            case "mouseup":
            case "mouseout":
            case "mouseover":
            case "contextmenu":
              f = S6;
              break;
            case "drag":
            case "dragend":
            case "dragenter":
            case "dragexit":
            case "dragleave":
            case "dragover":
            case "dragstart":
            case "drop":
              f = dOe;
              break;
            case "touchcancel":
            case "touchend":
            case "touchmove":
            case "touchstart":
              f = COe;
              break;
            case zZ:
            case FZ:
            case BZ:
              f = pOe;
              break;
            case UZ:
              f = TOe;
              break;
            case "scroll":
              f = cOe;
              break;
            case "wheel":
              f = IOe;
              break;
            case "copy":
            case "cut":
            case "paste":
              f = mOe;
              break;
            case "gotpointercapture":
            case "lostpointercapture":
            case "pointercancel":
            case "pointerdown":
            case "pointermove":
            case "pointerout":
            case "pointerover":
            case "pointerup":
              f = x6;
          }
          var g = (e & 4) !== 0, O = !g && t === "scroll", S = g ? h !== null ? h + "Capture" : null : h;
          g = [];
          for (var w = c, x; w !== null; ) {
            x = w;
            var P = x.stateNode;
            if (x.tag === 5 && P !== null && (x = P, S !== null && (P = Pv(w, S), P != null && g.push(Av(w, P, x)))), O)
              break;
            w = w.return;
          }
          0 < g.length && (h = new f(h, y, null, n, u), d.push({
            event: h,
            listeners: g
          }));
        }
      }
      if (!(e & 7)) {
        e: {
          if (h = t === "mouseover" || t === "pointerover", f = t === "mouseout" || t === "pointerout", h && n !== cA && (y = n.relatedTarget || n.fromElement) && (Eh(y) || y[Vc]))
            break e;
          if ((f || h) && (h = u.window === u ? u : (h = u.ownerDocument) ? h.defaultView || h.parentWindow : window, f ? (y = n.relatedTarget || n.toElement, f = c, y = y ? Eh(y) : null, y !== null && (O = yf(y), y !== O || y.tag !== 5 && y.tag !== 6) && (y = null)) : (f = null, y = c), f !== y)) {
            if (g = S6, P = "onMouseLeave", S = "onMouseEnter", w = "mouse", (t === "pointerout" || t === "pointerover") && (g = x6, P = "onPointerLeave", S = "onPointerEnter", w = "pointer"), O = f == null ? h : Vp(f), x = y == null ? h : Vp(y), h = new g(P, w + "leave", f, n, u), h.target = O, h.relatedTarget = x, P = null, Eh(u) === c && (g = new g(S, w + "enter", y, n, u), g.target = x, g.relatedTarget = O, P = g), O = P, f && y)
              t: {
                for (g = f, S = y, w = 0, x = g; x; x = ap(x))
                  w++;
                for (x = 0, P = S; P; P = ap(P))
                  x++;
                for (; 0 < w - x; )
                  g = ap(g), w--;
                for (; 0 < x - w; )
                  S = ap(S), x--;
                for (; w--; ) {
                  if (g === S || S !== null && g === S.alternate)
                    break t;
                  g = ap(g), S = ap(S);
                }
                g = null;
              }
            else
              g = null;
            f !== null && R6(d, h, f, g, false), y !== null && O !== null && R6(d, O, y, g, true);
          }
        }
        e: {
          if (h = c ? Vp(c) : window, f = h.nodeName && h.nodeName.toLowerCase(), f === "select" || f === "input" && h.type === "file")
            var C = jOe;
          else if (P6(h))
            if (DZ)
              C = FOe;
            else {
              C = QOe;
              var _ = NOe;
            }
          else
            (f = h.nodeName) && f.toLowerCase() === "input" && (h.type === "checkbox" || h.type === "radio") && (C = zOe);
          if (C && (C = C(t, c))) {
            MZ(d, C, n, u);
            break e;
          }
          _ && _(t, h, c), t === "focusout" && (_ = h._wrapperState) && _.controlled && h.type === "number" && iA(h, "number", h.value);
        }
        switch (_ = c ? Vp(c) : window, t) {
          case "focusin":
            (P6(_) || _.contentEditable === "true") && (Bp = _, mA = c, F0 = null);
            break;
          case "focusout":
            F0 = mA = Bp = null;
            break;
          case "mousedown":
            yA = true;
            break;
          case "contextmenu":
          case "mouseup":
          case "dragend":
            yA = false, I6(d, n, u);
            break;
          case "selectionchange":
            if (VOe)
              break;
          case "keydown":
          case "keyup":
            I6(d, n, u);
        }
        var T;
        if (g3)
          e: {
            switch (t) {
              case "compositionstart":
                var $ = "onCompositionStart";
                break e;
              case "compositionend":
                $ = "onCompositionEnd";
                break e;
              case "compositionupdate":
                $ = "onCompositionUpdate";
                break e;
            }
            $ = void 0;
          }
        else
          Fp ? AZ(t, n) && ($ = "onCompositionEnd") : t === "keydown" && n.keyCode === 229 && ($ = "onCompositionStart");
        $ && ($Z && n.locale !== "ko" && (Fp || $ !== "onCompositionStart" ? $ === "onCompositionEnd" && Fp && (T = IZ()) : (Wu = u, h3 = "value" in Wu ? Wu.value : Wu.textContent, Fp = true)), _ = Zb(c, $), 0 < _.length && ($ = new w6($, t, null, n, u), d.push({
          event: $,
          listeners: _
        }), T ? $.data = T : (T = RZ(n), T !== null && ($.data = T)))), (T = AOe ? ROe(t, n) : MOe(t, n)) && (c = Zb(c, "onBeforeInput"), 0 < c.length && (u = new w6("onBeforeInput", "beforeinput", null, n, u), d.push({
          event: u,
          listeners: c
        }), u.data = T));
      }
      XZ(d, e);
    });
  }
  function Av(t, e, n) {
    return {
      instance: t,
      listener: e,
      currentTarget: n
    };
  }
  function Zb(t, e) {
    for (var n = e + "Capture", r = []; t !== null; ) {
      var i = t, s = i.stateNode;
      i.tag === 5 && s !== null && (i = s, s = Pv(t, n), s != null && r.unshift(Av(t, s, i)), s = Pv(t, e), s != null && r.push(Av(t, s, i))), t = t.return;
    }
    return r;
  }
  function ap(t) {
    if (t === null)
      return null;
    do
      t = t.return;
    while (t && t.tag !== 5);
    return t || null;
  }
  function R6(t, e, n, r, i) {
    for (var s = e._reactName, o = []; n !== null && n !== r; ) {
      var a = n, l = a.alternate, c = a.stateNode;
      if (l !== null && l === r)
        break;
      a.tag === 5 && c !== null && (a = c, i ? (l = Pv(n, s), l != null && o.unshift(Av(n, l, a))) : i || (l = Pv(n, s), l != null && o.push(Av(n, l, a)))), n = n.return;
    }
    o.length !== 0 && t.push({
      event: e,
      listeners: o
    });
  }
  var HOe = /\r\n?/g, YOe = /\u0000|\uFFFD/g;
  function M6(t) {
    return (typeof t == "string" ? t : "" + t).replace(HOe, `
`).replace(YOe, "");
  }
  function q1(t, e, n) {
    if (e = M6(e), M6(t) !== e && n)
      throw Error(Oe(425));
  }
  function Hb() {
  }
  var vA = null, OA = null;
  function SA(t, e) {
    return t === "textarea" || t === "noscript" || typeof e.children == "string" || typeof e.children == "number" || typeof e.dangerouslySetInnerHTML == "object" && e.dangerouslySetInnerHTML !== null && e.dangerouslySetInnerHTML.__html != null;
  }
  var wA = typeof setTimeout == "function" ? setTimeout : void 0, GOe = typeof clearTimeout == "function" ? clearTimeout : void 0, D6 = typeof Promise == "function" ? Promise : void 0, qOe = typeof queueMicrotask == "function" ? queueMicrotask : typeof D6 < "u" ? function(t) {
    return D6.resolve(null).then(t).catch(KOe);
  } : wA;
  function KOe(t) {
    setTimeout(function() {
      throw t;
    });
  }
  function GT(t, e) {
    var n = e, r = 0;
    do {
      var i = n.nextSibling;
      if (t.removeChild(n), i && i.nodeType === 8)
        if (n = i.data, n === "/$") {
          if (r === 0) {
            t.removeChild(i), Tv(e);
            return;
          }
          r--;
        } else
          n !== "$" && n !== "$?" && n !== "$!" || r++;
      n = i;
    } while (n);
    Tv(e);
  }
  function dd(t) {
    for (; t != null; t = t.nextSibling) {
      var e = t.nodeType;
      if (e === 1 || e === 3)
        break;
      if (e === 8) {
        if (e = t.data, e === "$" || e === "$!" || e === "$?")
          break;
        if (e === "/$")
          return null;
      }
    }
    return t;
  }
  function L6(t) {
    t = t.previousSibling;
    for (var e = 0; t; ) {
      if (t.nodeType === 8) {
        var n = t.data;
        if (n === "$" || n === "$!" || n === "$?") {
          if (e === 0)
            return t;
          e--;
        } else
          n === "/$" && e++;
      }
      t = t.previousSibling;
    }
    return null;
  }
  var Om = Math.random().toString(36).slice(2), xl = "__reactFiber$" + Om, Rv = "__reactProps$" + Om, Vc = "__reactContainer$" + Om, xA = "__reactEvents$" + Om, JOe = "__reactListeners$" + Om, eSe = "__reactHandles$" + Om;
  function Eh(t) {
    var e = t[xl];
    if (e)
      return e;
    for (var n = t.parentNode; n; ) {
      if (e = n[Vc] || n[xl]) {
        if (n = e.alternate, e.child !== null || n !== null && n.child !== null)
          for (t = L6(t); t !== null; ) {
            if (n = t[xl])
              return n;
            t = L6(t);
          }
        return e;
      }
      t = n, n = t.parentNode;
    }
    return null;
  }
  function XO(t) {
    return t = t[xl] || t[Vc], !t || t.tag !== 5 && t.tag !== 6 && t.tag !== 13 && t.tag !== 3 ? null : t;
  }
  function Vp(t) {
    if (t.tag === 5 || t.tag === 6)
      return t.stateNode;
    throw Error(Oe(33));
  }
  function iC(t) {
    return t[Rv] || null;
  }
  var bA = [], Xp = -1;
  function Dd(t) {
    return {
      current: t
    };
  }
  function xn(t) {
    0 > Xp || (t.current = bA[Xp], bA[Xp] = null, Xp--);
  }
  function hn(t, e) {
    Xp++, bA[Xp] = t.current, t.current = e;
  }
  var Sd = {}, bi = Dd(Sd), ys = Dd(false), qh = Sd;
  function Ig(t, e) {
    var n = t.type.contextTypes;
    if (!n)
      return Sd;
    var r = t.stateNode;
    if (r && r.__reactInternalMemoizedUnmaskedChildContext === e)
      return r.__reactInternalMemoizedMaskedChildContext;
    var i = {}, s;
    for (s in n)
      i[s] = e[s];
    return r && (t = t.stateNode, t.__reactInternalMemoizedUnmaskedChildContext = e, t.__reactInternalMemoizedMaskedChildContext = i), i;
  }
  function vs(t) {
    return t = t.childContextTypes, t != null;
  }
  function Yb() {
    xn(ys), xn(bi);
  }
  function j6(t, e, n) {
    if (bi.current !== Sd)
      throw Error(Oe(168));
    hn(bi, e), hn(ys, n);
  }
  function ZZ(t, e, n) {
    var r = t.stateNode;
    if (e = e.childContextTypes, typeof r.getChildContext != "function")
      return n;
    r = r.getChildContext();
    for (var i in r)
      if (!(i in e))
        throw Error(Oe(108, Nve(t) || "Unknown", i));
    return Ln({}, n, r);
  }
  function Gb(t) {
    return t = (t = t.stateNode) && t.__reactInternalMemoizedMergedChildContext || Sd, qh = bi.current, hn(bi, t), hn(ys, ys.current), true;
  }
  function N6(t, e, n) {
    var r = t.stateNode;
    if (!r)
      throw Error(Oe(169));
    n ? (t = ZZ(t, e, qh), r.__reactInternalMemoizedMergedChildContext = t, xn(ys), xn(bi), hn(bi, t)) : xn(ys), hn(ys, n);
  }
  var Sc = null, sC = false, qT = false;
  function HZ(t) {
    Sc === null ? Sc = [
      t
    ] : Sc.push(t);
  }
  function tSe(t) {
    sC = true, HZ(t);
  }
  function Ld() {
    if (!qT && Sc !== null) {
      qT = true;
      var t = 0, e = Zt;
      try {
        var n = Sc;
        for (Zt = 1; t < n.length; t++) {
          var r = n[t];
          do
            r = r(true);
          while (r !== null);
        }
        Sc = null, sC = false;
      } catch (i) {
        throw Sc !== null && (Sc = Sc.slice(t + 1)), OZ(l3, Ld), i;
      } finally {
        Zt = e, qT = false;
      }
    }
    return null;
  }
  var Wp = [], Zp = 0, qb = null, Kb = 0, jo = [], No = 0, Kh = null, Tc = 1, Ec = "";
  function yh(t, e) {
    Wp[Zp++] = Kb, Wp[Zp++] = qb, qb = t, Kb = e;
  }
  function YZ(t, e, n) {
    jo[No++] = Tc, jo[No++] = Ec, jo[No++] = Kh, Kh = t;
    var r = Tc;
    t = Ec;
    var i = 32 - Da(r) - 1;
    r &= ~(1 << i), n += 1;
    var s = 32 - Da(e) + i;
    if (30 < s) {
      var o = i - i % 5;
      s = (r & (1 << o) - 1).toString(32), r >>= o, i -= o, Tc = 1 << 32 - Da(e) + i | n << i | r, Ec = s + t;
    } else
      Tc = 1 << s | n << i | r, Ec = t;
  }
  function y3(t) {
    t.return !== null && (yh(t, 1), YZ(t, 1, 0));
  }
  function v3(t) {
    for (; t === qb; )
      qb = Wp[--Zp], Wp[Zp] = null, Kb = Wp[--Zp], Wp[Zp] = null;
    for (; t === Kh; )
      Kh = jo[--No], jo[No] = null, Ec = jo[--No], jo[No] = null, Tc = jo[--No], jo[No] = null;
  }
  var ro = null, to = null, En = false, Pa = null;
  function GZ(t, e) {
    var n = Uo(5, null, null, 0);
    n.elementType = "DELETED", n.stateNode = e, n.return = t, e = t.deletions, e === null ? (t.deletions = [
      n
    ], t.flags |= 16) : e.push(n);
  }
  function Q6(t, e) {
    switch (t.tag) {
      case 5:
        var n = t.type;
        return e = e.nodeType !== 1 || n.toLowerCase() !== e.nodeName.toLowerCase() ? null : e, e !== null ? (t.stateNode = e, ro = t, to = dd(e.firstChild), true) : false;
      case 6:
        return e = t.pendingProps === "" || e.nodeType !== 3 ? null : e, e !== null ? (t.stateNode = e, ro = t, to = null, true) : false;
      case 13:
        return e = e.nodeType !== 8 ? null : e, e !== null ? (n = Kh !== null ? {
          id: Tc,
          overflow: Ec
        } : null, t.memoizedState = {
          dehydrated: e,
          treeContext: n,
          retryLane: 1073741824
        }, n = Uo(18, null, null, 0), n.stateNode = e, n.return = t, t.child = n, ro = t, to = null, true) : false;
      default:
        return false;
    }
  }
  function kA(t) {
    return (t.mode & 1) !== 0 && (t.flags & 128) === 0;
  }
  function PA(t) {
    if (En) {
      var e = to;
      if (e) {
        var n = e;
        if (!Q6(t, e)) {
          if (kA(t))
            throw Error(Oe(418));
          e = dd(n.nextSibling);
          var r = ro;
          e && Q6(t, e) ? GZ(r, n) : (t.flags = t.flags & -4097 | 2, En = false, ro = t);
        }
      } else {
        if (kA(t))
          throw Error(Oe(418));
        t.flags = t.flags & -4097 | 2, En = false, ro = t;
      }
    }
  }
  function z6(t) {
    for (t = t.return; t !== null && t.tag !== 5 && t.tag !== 3 && t.tag !== 13; )
      t = t.return;
    ro = t;
  }
  function K1(t) {
    if (t !== ro)
      return false;
    if (!En)
      return z6(t), En = true, false;
    var e;
    if ((e = t.tag !== 3) && !(e = t.tag !== 5) && (e = t.type, e = e !== "head" && e !== "body" && !SA(t.type, t.memoizedProps)), e && (e = to)) {
      if (kA(t))
        throw qZ(), Error(Oe(418));
      for (; e; )
        GZ(t, e), e = dd(e.nextSibling);
    }
    if (z6(t), t.tag === 13) {
      if (t = t.memoizedState, t = t !== null ? t.dehydrated : null, !t)
        throw Error(Oe(317));
      e: {
        for (t = t.nextSibling, e = 0; t; ) {
          if (t.nodeType === 8) {
            var n = t.data;
            if (n === "/$") {
              if (e === 0) {
                to = dd(t.nextSibling);
                break e;
              }
              e--;
            } else
              n !== "$" && n !== "$!" && n !== "$?" || e++;
          }
          t = t.nextSibling;
        }
        to = null;
      }
    } else
      to = ro ? dd(t.stateNode.nextSibling) : null;
    return true;
  }
  function qZ() {
    for (var t = to; t; )
      t = dd(t.nextSibling);
  }
  function $g() {
    to = ro = null, En = false;
  }
  function O3(t) {
    Pa === null ? Pa = [
      t
    ] : Pa.push(t);
  }
  var nSe = eu.ReactCurrentBatchConfig;
  function Iy(t, e, n) {
    if (t = n.ref, t !== null && typeof t != "function" && typeof t != "object") {
      if (n._owner) {
        if (n = n._owner, n) {
          if (n.tag !== 1)
            throw Error(Oe(309));
          var r = n.stateNode;
        }
        if (!r)
          throw Error(Oe(147, t));
        var i = r, s = "" + t;
        return e !== null && e.ref !== null && typeof e.ref == "function" && e.ref._stringRef === s ? e.ref : (e = function(o) {
          var a = i.refs;
          o === null ? delete a[s] : a[s] = o;
        }, e._stringRef = s, e);
      }
      if (typeof t != "string")
        throw Error(Oe(284));
      if (!n._owner)
        throw Error(Oe(290, t));
    }
    return t;
  }
  function J1(t, e) {
    throw t = Object.prototype.toString.call(e), Error(Oe(31, t === "[object Object]" ? "object with keys {" + Object.keys(e).join(", ") + "}" : t));
  }
  function F6(t) {
    var e = t._init;
    return e(t._payload);
  }
  function KZ(t) {
    function e(S, w) {
      if (t) {
        var x = S.deletions;
        x === null ? (S.deletions = [
          w
        ], S.flags |= 16) : x.push(w);
      }
    }
    function n(S, w) {
      if (!t)
        return null;
      for (; w !== null; )
        e(S, w), w = w.sibling;
      return null;
    }
    function r(S, w) {
      for (S = /* @__PURE__ */ new Map(); w !== null; )
        w.key !== null ? S.set(w.key, w) : S.set(w.index, w), w = w.sibling;
      return S;
    }
    function i(S, w) {
      return S = gd(S, w), S.index = 0, S.sibling = null, S;
    }
    function s(S, w, x) {
      return S.index = x, t ? (x = S.alternate, x !== null ? (x = x.index, x < w ? (S.flags |= 2, w) : x) : (S.flags |= 2, w)) : (S.flags |= 1048576, w);
    }
    function o(S) {
      return t && S.alternate === null && (S.flags |= 2), S;
    }
    function a(S, w, x, P) {
      return w === null || w.tag !== 6 ? (w = iE(x, S.mode, P), w.return = S, w) : (w = i(w, x), w.return = S, w);
    }
    function l(S, w, x, P) {
      var C = x.type;
      return C === zp ? u(S, w, x.props.children, P, x.key) : w !== null && (w.elementType === C || typeof C == "object" && C !== null && C.$$typeof === Ru && F6(C) === w.type) ? (P = i(w, x.props), P.ref = Iy(S, w, x), P.return = S, P) : (P = Ux(x.type, x.key, x.props, null, S.mode, P), P.ref = Iy(S, w, x), P.return = S, P);
    }
    function c(S, w, x, P) {
      return w === null || w.tag !== 4 || w.stateNode.containerInfo !== x.containerInfo || w.stateNode.implementation !== x.implementation ? (w = sE(x, S.mode, P), w.return = S, w) : (w = i(w, x.children || []), w.return = S, w);
    }
    function u(S, w, x, P, C) {
      return w === null || w.tag !== 7 ? (w = Uh(x, S.mode, P, C), w.return = S, w) : (w = i(w, x), w.return = S, w);
    }
    function d(S, w, x) {
      if (typeof w == "string" && w !== "" || typeof w == "number")
        return w = iE("" + w, S.mode, x), w.return = S, w;
      if (typeof w == "object" && w !== null) {
        switch (w.$$typeof) {
          case B1:
            return x = Ux(w.type, w.key, w.props, null, S.mode, x), x.ref = Iy(S, null, w), x.return = S, x;
          case Qp:
            return w = sE(w, S.mode, x), w.return = S, w;
          case Ru:
            var P = w._init;
            return d(S, P(w._payload), x);
        }
        if (p0(w) || Py(w))
          return w = Uh(w, S.mode, x, null), w.return = S, w;
        J1(S, w);
      }
      return null;
    }
    function h(S, w, x, P) {
      var C = w !== null ? w.key : null;
      if (typeof x == "string" && x !== "" || typeof x == "number")
        return C !== null ? null : a(S, w, "" + x, P);
      if (typeof x == "object" && x !== null) {
        switch (x.$$typeof) {
          case B1:
            return x.key === C ? l(S, w, x, P) : null;
          case Qp:
            return x.key === C ? c(S, w, x, P) : null;
          case Ru:
            return C = x._init, h(S, w, C(x._payload), P);
        }
        if (p0(x) || Py(x))
          return C !== null ? null : u(S, w, x, P, null);
        J1(S, x);
      }
      return null;
    }
    function f(S, w, x, P, C) {
      if (typeof P == "string" && P !== "" || typeof P == "number")
        return S = S.get(x) || null, a(w, S, "" + P, C);
      if (typeof P == "object" && P !== null) {
        switch (P.$$typeof) {
          case B1:
            return S = S.get(P.key === null ? x : P.key) || null, l(w, S, P, C);
          case Qp:
            return S = S.get(P.key === null ? x : P.key) || null, c(w, S, P, C);
          case Ru:
            var _ = P._init;
            return f(S, w, x, _(P._payload), C);
        }
        if (p0(P) || Py(P))
          return S = S.get(x) || null, u(w, S, P, C, null);
        J1(w, P);
      }
      return null;
    }
    function y(S, w, x, P) {
      for (var C = null, _ = null, T = w, $ = w = 0, N = null; T !== null && $ < x.length; $++) {
        T.index > $ ? (N = T, T = null) : N = T.sibling;
        var L = h(S, T, x[$], P);
        if (L === null) {
          T === null && (T = N);
          break;
        }
        t && T && L.alternate === null && e(S, T), w = s(L, w, $), _ === null ? C = L : _.sibling = L, _ = L, T = N;
      }
      if ($ === x.length)
        return n(S, T), En && yh(S, $), C;
      if (T === null) {
        for (; $ < x.length; $++)
          T = d(S, x[$], P), T !== null && (w = s(T, w, $), _ === null ? C = T : _.sibling = T, _ = T);
        return En && yh(S, $), C;
      }
      for (T = r(S, T); $ < x.length; $++)
        N = f(T, S, $, x[$], P), N !== null && (t && N.alternate !== null && T.delete(N.key === null ? $ : N.key), w = s(N, w, $), _ === null ? C = N : _.sibling = N, _ = N);
      return t && T.forEach(function(z) {
        return e(S, z);
      }), En && yh(S, $), C;
    }
    function g(S, w, x, P) {
      var C = Py(x);
      if (typeof C != "function")
        throw Error(Oe(150));
      if (x = C.call(x), x == null)
        throw Error(Oe(151));
      for (var _ = C = null, T = w, $ = w = 0, N = null, L = x.next(); T !== null && !L.done; $++, L = x.next()) {
        T.index > $ ? (N = T, T = null) : N = T.sibling;
        var z = h(S, T, L.value, P);
        if (z === null) {
          T === null && (T = N);
          break;
        }
        t && T && z.alternate === null && e(S, T), w = s(z, w, $), _ === null ? C = z : _.sibling = z, _ = z, T = N;
      }
      if (L.done)
        return n(S, T), En && yh(S, $), C;
      if (T === null) {
        for (; !L.done; $++, L = x.next())
          L = d(S, L.value, P), L !== null && (w = s(L, w, $), _ === null ? C = L : _.sibling = L, _ = L);
        return En && yh(S, $), C;
      }
      for (T = r(S, T); !L.done; $++, L = x.next())
        L = f(T, S, $, L.value, P), L !== null && (t && L.alternate !== null && T.delete(L.key === null ? $ : L.key), w = s(L, w, $), _ === null ? C = L : _.sibling = L, _ = L);
      return t && T.forEach(function(M) {
        return e(S, M);
      }), En && yh(S, $), C;
    }
    function O(S, w, x, P) {
      if (typeof x == "object" && x !== null && x.type === zp && x.key === null && (x = x.props.children), typeof x == "object" && x !== null) {
        switch (x.$$typeof) {
          case B1:
            e: {
              for (var C = x.key, _ = w; _ !== null; ) {
                if (_.key === C) {
                  if (C = x.type, C === zp) {
                    if (_.tag === 7) {
                      n(S, _.sibling), w = i(_, x.props.children), w.return = S, S = w;
                      break e;
                    }
                  } else if (_.elementType === C || typeof C == "object" && C !== null && C.$$typeof === Ru && F6(C) === _.type) {
                    n(S, _.sibling), w = i(_, x.props), w.ref = Iy(S, _, x), w.return = S, S = w;
                    break e;
                  }
                  n(S, _);
                  break;
                } else
                  e(S, _);
                _ = _.sibling;
              }
              x.type === zp ? (w = Uh(x.props.children, S.mode, P, x.key), w.return = S, S = w) : (P = Ux(x.type, x.key, x.props, null, S.mode, P), P.ref = Iy(S, w, x), P.return = S, S = P);
            }
            return o(S);
          case Qp:
            e: {
              for (_ = x.key; w !== null; ) {
                if (w.key === _)
                  if (w.tag === 4 && w.stateNode.containerInfo === x.containerInfo && w.stateNode.implementation === x.implementation) {
                    n(S, w.sibling), w = i(w, x.children || []), w.return = S, S = w;
                    break e;
                  } else {
                    n(S, w);
                    break;
                  }
                else
                  e(S, w);
                w = w.sibling;
              }
              w = sE(x, S.mode, P), w.return = S, S = w;
            }
            return o(S);
          case Ru:
            return _ = x._init, O(S, w, _(x._payload), P);
        }
        if (p0(x))
          return y(S, w, x, P);
        if (Py(x))
          return g(S, w, x, P);
        J1(S, x);
      }
      return typeof x == "string" && x !== "" || typeof x == "number" ? (x = "" + x, w !== null && w.tag === 6 ? (n(S, w.sibling), w = i(w, x), w.return = S, S = w) : (n(S, w), w = iE(x, S.mode, P), w.return = S, S = w), o(S)) : n(S, w);
    }
    return O;
  }
  var Ag = KZ(true), JZ = KZ(false), Jb = Dd(null), ek = null, Hp = null, S3 = null;
  function w3() {
    S3 = Hp = ek = null;
  }
  function x3(t) {
    var e = Jb.current;
    xn(Jb), t._currentValue = e;
  }
  function CA(t, e, n) {
    for (; t !== null; ) {
      var r = t.alternate;
      if ((t.childLanes & e) !== e ? (t.childLanes |= e, r !== null && (r.childLanes |= e)) : r !== null && (r.childLanes & e) !== e && (r.childLanes |= e), t === n)
        break;
      t = t.return;
    }
  }
  function dg(t, e) {
    ek = t, S3 = Hp = null, t = t.dependencies, t !== null && t.firstContext !== null && (t.lanes & e && (hs = true), t.firstContext = null);
  }
  function Jo(t) {
    var e = t._currentValue;
    if (S3 !== t)
      if (t = {
        context: t,
        memoizedValue: e,
        next: null
      }, Hp === null) {
        if (ek === null)
          throw Error(Oe(308));
        Hp = t, ek.dependencies = {
          lanes: 0,
          firstContext: t
        };
      } else
        Hp = Hp.next = t;
    return e;
  }
  var Ih = null;
  function b3(t) {
    Ih === null ? Ih = [
      t
    ] : Ih.push(t);
  }
  function eH(t, e, n, r) {
    var i = e.interleaved;
    return i === null ? (n.next = n, b3(e)) : (n.next = i.next, i.next = n), e.interleaved = n, Xc(t, r);
  }
  function Xc(t, e) {
    t.lanes |= e;
    var n = t.alternate;
    for (n !== null && (n.lanes |= e), n = t, t = t.return; t !== null; )
      t.childLanes |= e, n = t.alternate, n !== null && (n.childLanes |= e), n = t, t = t.return;
    return n.tag === 3 ? n.stateNode : null;
  }
  var Mu = false;
  function k3(t) {
    t.updateQueue = {
      baseState: t.memoizedState,
      firstBaseUpdate: null,
      lastBaseUpdate: null,
      shared: {
        pending: null,
        interleaved: null,
        lanes: 0
      },
      effects: null
    };
  }
  function tH(t, e) {
    t = t.updateQueue, e.updateQueue === t && (e.updateQueue = {
      baseState: t.baseState,
      firstBaseUpdate: t.firstBaseUpdate,
      lastBaseUpdate: t.lastBaseUpdate,
      shared: t.shared,
      effects: t.effects
    });
  }
  function Ac(t, e) {
    return {
      eventTime: t,
      lane: e,
      tag: 0,
      payload: null,
      callback: null,
      next: null
    };
  }
  function hd(t, e, n) {
    var r = t.updateQueue;
    if (r === null)
      return null;
    if (r = r.shared, Mt & 2) {
      var i = r.pending;
      return i === null ? e.next = e : (e.next = i.next, i.next = e), r.pending = e, Xc(t, n);
    }
    return i = r.interleaved, i === null ? (e.next = e, b3(r)) : (e.next = i.next, i.next = e), r.interleaved = e, Xc(t, n);
  }
  function jx(t, e, n) {
    if (e = e.updateQueue, e !== null && (e = e.shared, (n & 4194240) !== 0)) {
      var r = e.lanes;
      r &= t.pendingLanes, n |= r, e.lanes = n, c3(t, n);
    }
  }
  function B6(t, e) {
    var n = t.updateQueue, r = t.alternate;
    if (r !== null && (r = r.updateQueue, n === r)) {
      var i = null, s = null;
      if (n = n.firstBaseUpdate, n !== null) {
        do {
          var o = {
            eventTime: n.eventTime,
            lane: n.lane,
            tag: n.tag,
            payload: n.payload,
            callback: n.callback,
            next: null
          };
          s === null ? i = s = o : s = s.next = o, n = n.next;
        } while (n !== null);
        s === null ? i = s = e : s = s.next = e;
      } else
        i = s = e;
      n = {
        baseState: r.baseState,
        firstBaseUpdate: i,
        lastBaseUpdate: s,
        shared: r.shared,
        effects: r.effects
      }, t.updateQueue = n;
      return;
    }
    t = n.lastBaseUpdate, t === null ? n.firstBaseUpdate = e : t.next = e, n.lastBaseUpdate = e;
  }
  function tk(t, e, n, r) {
    var i = t.updateQueue;
    Mu = false;
    var s = i.firstBaseUpdate, o = i.lastBaseUpdate, a = i.shared.pending;
    if (a !== null) {
      i.shared.pending = null;
      var l = a, c = l.next;
      l.next = null, o === null ? s = c : o.next = c, o = l;
      var u = t.alternate;
      u !== null && (u = u.updateQueue, a = u.lastBaseUpdate, a !== o && (a === null ? u.firstBaseUpdate = c : a.next = c, u.lastBaseUpdate = l));
    }
    if (s !== null) {
      var d = i.baseState;
      o = 0, u = c = l = null, a = s;
      do {
        var h = a.lane, f = a.eventTime;
        if ((r & h) === h) {
          u !== null && (u = u.next = {
            eventTime: f,
            lane: 0,
            tag: a.tag,
            payload: a.payload,
            callback: a.callback,
            next: null
          });
          e: {
            var y = t, g = a;
            switch (h = e, f = n, g.tag) {
              case 1:
                if (y = g.payload, typeof y == "function") {
                  d = y.call(f, d, h);
                  break e;
                }
                d = y;
                break e;
              case 3:
                y.flags = y.flags & -65537 | 128;
              case 0:
                if (y = g.payload, h = typeof y == "function" ? y.call(f, d, h) : y, h == null)
                  break e;
                d = Ln({}, d, h);
                break e;
              case 2:
                Mu = true;
            }
          }
          a.callback !== null && a.lane !== 0 && (t.flags |= 64, h = i.effects, h === null ? i.effects = [
            a
          ] : h.push(a));
        } else
          f = {
            eventTime: f,
            lane: h,
            tag: a.tag,
            payload: a.payload,
            callback: a.callback,
            next: null
          }, u === null ? (c = u = f, l = d) : u = u.next = f, o |= h;
        if (a = a.next, a === null) {
          if (a = i.shared.pending, a === null)
            break;
          h = a, a = h.next, h.next = null, i.lastBaseUpdate = h, i.shared.pending = null;
        }
      } while (1);
      if (u === null && (l = d), i.baseState = l, i.firstBaseUpdate = c, i.lastBaseUpdate = u, e = i.shared.interleaved, e !== null) {
        i = e;
        do
          o |= i.lane, i = i.next;
        while (i !== e);
      } else
        s === null && (i.shared.lanes = 0);
      ef |= o, t.lanes = o, t.memoizedState = d;
    }
  }
  function U6(t, e, n) {
    if (t = e.effects, e.effects = null, t !== null)
      for (e = 0; e < t.length; e++) {
        var r = t[e], i = r.callback;
        if (i !== null) {
          if (r.callback = null, r = n, typeof i != "function")
            throw Error(Oe(191, i));
          i.call(r);
        }
      }
  }
  var WO = {}, $l = Dd(WO), Mv = Dd(WO), Dv = Dd(WO);
  function $h(t) {
    if (t === WO)
      throw Error(Oe(174));
    return t;
  }
  function P3(t, e) {
    switch (hn(Dv, e), hn(Mv, t), hn($l, WO), t = e.nodeType, t) {
      case 9:
      case 11:
        e = (e = e.documentElement) ? e.namespaceURI : oA(null, "");
        break;
      default:
        t = t === 8 ? e.parentNode : e, e = t.namespaceURI || null, t = t.tagName, e = oA(e, t);
    }
    xn($l), hn($l, e);
  }
  function Rg() {
    xn($l), xn(Mv), xn(Dv);
  }
  function nH(t) {
    $h(Dv.current);
    var e = $h($l.current), n = oA(e, t.type);
    e !== n && (hn(Mv, t), hn($l, n));
  }
  function C3(t) {
    Mv.current === t && (xn($l), xn(Mv));
  }
  var An = Dd(0);
  function nk(t) {
    for (var e = t; e !== null; ) {
      if (e.tag === 13) {
        var n = e.memoizedState;
        if (n !== null && (n = n.dehydrated, n === null || n.data === "$?" || n.data === "$!"))
          return e;
      } else if (e.tag === 19 && e.memoizedProps.revealOrder !== void 0) {
        if (e.flags & 128)
          return e;
      } else if (e.child !== null) {
        e.child.return = e, e = e.child;
        continue;
      }
      if (e === t)
        break;
      for (; e.sibling === null; ) {
        if (e.return === null || e.return === t)
          return null;
        e = e.return;
      }
      e.sibling.return = e.return, e = e.sibling;
    }
    return null;
  }
  var KT = [];
  function _3() {
    for (var t = 0; t < KT.length; t++)
      KT[t]._workInProgressVersionPrimary = null;
    KT.length = 0;
  }
  var Nx = eu.ReactCurrentDispatcher, JT = eu.ReactCurrentBatchConfig, Jh = 0, Dn = null, gr = null, br = null, rk = false, B0 = false, Lv = 0, rSe = 0;
  function ri() {
    throw Error(Oe(321));
  }
  function T3(t, e) {
    if (e === null)
      return false;
    for (var n = 0; n < e.length && n < t.length; n++)
      if (!Ua(t[n], e[n]))
        return false;
    return true;
  }
  function E3(t, e, n, r, i, s) {
    if (Jh = s, Dn = e, e.memoizedState = null, e.updateQueue = null, e.lanes = 0, Nx.current = t === null || t.memoizedState === null ? aSe : lSe, t = n(r, i), B0) {
      s = 0;
      do {
        if (B0 = false, Lv = 0, 25 <= s)
          throw Error(Oe(301));
        s += 1, br = gr = null, e.updateQueue = null, Nx.current = cSe, t = n(r, i);
      } while (B0);
    }
    if (Nx.current = ik, e = gr !== null && gr.next !== null, Jh = 0, br = gr = Dn = null, rk = false, e)
      throw Error(Oe(300));
    return t;
  }
  function I3() {
    var t = Lv !== 0;
    return Lv = 0, t;
  }
  function ml() {
    var t = {
      memoizedState: null,
      baseState: null,
      baseQueue: null,
      queue: null,
      next: null
    };
    return br === null ? Dn.memoizedState = br = t : br = br.next = t, br;
  }
  function ea() {
    if (gr === null) {
      var t = Dn.alternate;
      t = t !== null ? t.memoizedState : null;
    } else
      t = gr.next;
    var e = br === null ? Dn.memoizedState : br.next;
    if (e !== null)
      br = e, gr = t;
    else {
      if (t === null)
        throw Error(Oe(310));
      gr = t, t = {
        memoizedState: gr.memoizedState,
        baseState: gr.baseState,
        baseQueue: gr.baseQueue,
        queue: gr.queue,
        next: null
      }, br === null ? Dn.memoizedState = br = t : br = br.next = t;
    }
    return br;
  }
  function jv(t, e) {
    return typeof e == "function" ? e(t) : e;
  }
  function eE(t) {
    var e = ea(), n = e.queue;
    if (n === null)
      throw Error(Oe(311));
    n.lastRenderedReducer = t;
    var r = gr, i = r.baseQueue, s = n.pending;
    if (s !== null) {
      if (i !== null) {
        var o = i.next;
        i.next = s.next, s.next = o;
      }
      r.baseQueue = i = s, n.pending = null;
    }
    if (i !== null) {
      s = i.next, r = r.baseState;
      var a = o = null, l = null, c = s;
      do {
        var u = c.lane;
        if ((Jh & u) === u)
          l !== null && (l = l.next = {
            lane: 0,
            action: c.action,
            hasEagerState: c.hasEagerState,
            eagerState: c.eagerState,
            next: null
          }), r = c.hasEagerState ? c.eagerState : t(r, c.action);
        else {
          var d = {
            lane: u,
            action: c.action,
            hasEagerState: c.hasEagerState,
            eagerState: c.eagerState,
            next: null
          };
          l === null ? (a = l = d, o = r) : l = l.next = d, Dn.lanes |= u, ef |= u;
        }
        c = c.next;
      } while (c !== null && c !== s);
      l === null ? o = r : l.next = a, Ua(r, e.memoizedState) || (hs = true), e.memoizedState = r, e.baseState = o, e.baseQueue = l, n.lastRenderedState = r;
    }
    if (t = n.interleaved, t !== null) {
      i = t;
      do
        s = i.lane, Dn.lanes |= s, ef |= s, i = i.next;
      while (i !== t);
    } else
      i === null && (n.lanes = 0);
    return [
      e.memoizedState,
      n.dispatch
    ];
  }
  function tE(t) {
    var e = ea(), n = e.queue;
    if (n === null)
      throw Error(Oe(311));
    n.lastRenderedReducer = t;
    var r = n.dispatch, i = n.pending, s = e.memoizedState;
    if (i !== null) {
      n.pending = null;
      var o = i = i.next;
      do
        s = t(s, o.action), o = o.next;
      while (o !== i);
      Ua(s, e.memoizedState) || (hs = true), e.memoizedState = s, e.baseQueue === null && (e.baseState = s), n.lastRenderedState = s;
    }
    return [
      s,
      r
    ];
  }
  function rH() {
  }
  function iH(t, e) {
    var n = Dn, r = ea(), i = e(), s = !Ua(r.memoizedState, i);
    if (s && (r.memoizedState = i, hs = true), r = r.queue, $3(aH.bind(null, n, r, t), [
      t
    ]), r.getSnapshot !== e || s || br !== null && br.memoizedState.tag & 1) {
      if (n.flags |= 2048, Nv(9, oH.bind(null, n, r, i, e), void 0, null), Cr === null)
        throw Error(Oe(349));
      Jh & 30 || sH(n, e, i);
    }
    return i;
  }
  function sH(t, e, n) {
    t.flags |= 16384, t = {
      getSnapshot: e,
      value: n
    }, e = Dn.updateQueue, e === null ? (e = {
      lastEffect: null,
      stores: null
    }, Dn.updateQueue = e, e.stores = [
      t
    ]) : (n = e.stores, n === null ? e.stores = [
      t
    ] : n.push(t));
  }
  function oH(t, e, n, r) {
    e.value = n, e.getSnapshot = r, lH(e) && cH(t);
  }
  function aH(t, e, n) {
    return n(function() {
      lH(e) && cH(t);
    });
  }
  function lH(t) {
    var e = t.getSnapshot;
    t = t.value;
    try {
      var n = e();
      return !Ua(t, n);
    } catch {
      return true;
    }
  }
  function cH(t) {
    var e = Xc(t, 1);
    e !== null && La(e, t, 1, -1);
  }
  function V6(t) {
    var e = ml();
    return typeof t == "function" && (t = t()), e.memoizedState = e.baseState = t, t = {
      pending: null,
      interleaved: null,
      lanes: 0,
      dispatch: null,
      lastRenderedReducer: jv,
      lastRenderedState: t
    }, e.queue = t, t = t.dispatch = oSe.bind(null, Dn, t), [
      e.memoizedState,
      t
    ];
  }
  function Nv(t, e, n, r) {
    return t = {
      tag: t,
      create: e,
      destroy: n,
      deps: r,
      next: null
    }, e = Dn.updateQueue, e === null ? (e = {
      lastEffect: null,
      stores: null
    }, Dn.updateQueue = e, e.lastEffect = t.next = t) : (n = e.lastEffect, n === null ? e.lastEffect = t.next = t : (r = n.next, n.next = t, t.next = r, e.lastEffect = t)), t;
  }
  function uH() {
    return ea().memoizedState;
  }
  function Qx(t, e, n, r) {
    var i = ml();
    Dn.flags |= t, i.memoizedState = Nv(1 | e, n, void 0, r === void 0 ? null : r);
  }
  function oC(t, e, n, r) {
    var i = ea();
    r = r === void 0 ? null : r;
    var s = void 0;
    if (gr !== null) {
      var o = gr.memoizedState;
      if (s = o.destroy, r !== null && T3(r, o.deps)) {
        i.memoizedState = Nv(e, n, s, r);
        return;
      }
    }
    Dn.flags |= t, i.memoizedState = Nv(1 | e, n, s, r);
  }
  function X6(t, e) {
    return Qx(8390656, 8, t, e);
  }
  function $3(t, e) {
    return oC(2048, 8, t, e);
  }
  function dH(t, e) {
    return oC(4, 2, t, e);
  }
  function hH(t, e) {
    return oC(4, 4, t, e);
  }
  function fH(t, e) {
    if (typeof e == "function")
      return t = t(), e(t), function() {
        e(null);
      };
    if (e != null)
      return t = t(), e.current = t, function() {
        e.current = null;
      };
  }
  function pH(t, e, n) {
    return n = n != null ? n.concat([
      t
    ]) : null, oC(4, 4, fH.bind(null, e, t), n);
  }
  function A3() {
  }
  function gH(t, e) {
    var n = ea();
    e = e === void 0 ? null : e;
    var r = n.memoizedState;
    return r !== null && e !== null && T3(e, r[1]) ? r[0] : (n.memoizedState = [
      t,
      e
    ], t);
  }
  function mH(t, e) {
    var n = ea();
    e = e === void 0 ? null : e;
    var r = n.memoizedState;
    return r !== null && e !== null && T3(e, r[1]) ? r[0] : (t = t(), n.memoizedState = [
      t,
      e
    ], t);
  }
  function yH(t, e, n) {
    return Jh & 21 ? (Ua(n, e) || (n = xZ(), Dn.lanes |= n, ef |= n, t.baseState = true), e) : (t.baseState && (t.baseState = false, hs = true), t.memoizedState = n);
  }
  function iSe(t, e) {
    var n = Zt;
    Zt = n !== 0 && 4 > n ? n : 4, t(true);
    var r = JT.transition;
    JT.transition = {};
    try {
      t(false), e();
    } finally {
      Zt = n, JT.transition = r;
    }
  }
  function vH() {
    return ea().memoizedState;
  }
  function sSe(t, e, n) {
    var r = pd(t);
    if (n = {
      lane: r,
      action: n,
      hasEagerState: false,
      eagerState: null,
      next: null
    }, OH(t))
      SH(e, n);
    else if (n = eH(t, e, n, r), n !== null) {
      var i = Bi();
      La(n, t, r, i), wH(n, e, r);
    }
  }
  function oSe(t, e, n) {
    var r = pd(t), i = {
      lane: r,
      action: n,
      hasEagerState: false,
      eagerState: null,
      next: null
    };
    if (OH(t))
      SH(e, i);
    else {
      var s = t.alternate;
      if (t.lanes === 0 && (s === null || s.lanes === 0) && (s = e.lastRenderedReducer, s !== null))
        try {
          var o = e.lastRenderedState, a = s(o, n);
          if (i.hasEagerState = true, i.eagerState = a, Ua(a, o)) {
            var l = e.interleaved;
            l === null ? (i.next = i, b3(e)) : (i.next = l.next, l.next = i), e.interleaved = i;
            return;
          }
        } catch {
        } finally {
        }
      n = eH(t, e, i, r), n !== null && (i = Bi(), La(n, t, r, i), wH(n, e, r));
    }
  }
  function OH(t) {
    var e = t.alternate;
    return t === Dn || e !== null && e === Dn;
  }
  function SH(t, e) {
    B0 = rk = true;
    var n = t.pending;
    n === null ? e.next = e : (e.next = n.next, n.next = e), t.pending = e;
  }
  function wH(t, e, n) {
    if (n & 4194240) {
      var r = e.lanes;
      r &= t.pendingLanes, n |= r, e.lanes = n, c3(t, n);
    }
  }
  var ik = {
    readContext: Jo,
    useCallback: ri,
    useContext: ri,
    useEffect: ri,
    useImperativeHandle: ri,
    useInsertionEffect: ri,
    useLayoutEffect: ri,
    useMemo: ri,
    useReducer: ri,
    useRef: ri,
    useState: ri,
    useDebugValue: ri,
    useDeferredValue: ri,
    useTransition: ri,
    useMutableSource: ri,
    useSyncExternalStore: ri,
    useId: ri,
    unstable_isNewReconciler: false
  }, aSe = {
    readContext: Jo,
    useCallback: function(t, e) {
      return ml().memoizedState = [
        t,
        e === void 0 ? null : e
      ], t;
    },
    useContext: Jo,
    useEffect: X6,
    useImperativeHandle: function(t, e, n) {
      return n = n != null ? n.concat([
        t
      ]) : null, Qx(4194308, 4, fH.bind(null, e, t), n);
    },
    useLayoutEffect: function(t, e) {
      return Qx(4194308, 4, t, e);
    },
    useInsertionEffect: function(t, e) {
      return Qx(4, 2, t, e);
    },
    useMemo: function(t, e) {
      var n = ml();
      return e = e === void 0 ? null : e, t = t(), n.memoizedState = [
        t,
        e
      ], t;
    },
    useReducer: function(t, e, n) {
      var r = ml();
      return e = n !== void 0 ? n(e) : e, r.memoizedState = r.baseState = e, t = {
        pending: null,
        interleaved: null,
        lanes: 0,
        dispatch: null,
        lastRenderedReducer: t,
        lastRenderedState: e
      }, r.queue = t, t = t.dispatch = sSe.bind(null, Dn, t), [
        r.memoizedState,
        t
      ];
    },
    useRef: function(t) {
      var e = ml();
      return t = {
        current: t
      }, e.memoizedState = t;
    },
    useState: V6,
    useDebugValue: A3,
    useDeferredValue: function(t) {
      return ml().memoizedState = t;
    },
    useTransition: function() {
      var t = V6(false), e = t[0];
      return t = iSe.bind(null, t[1]), ml().memoizedState = t, [
        e,
        t
      ];
    },
    useMutableSource: function() {
    },
    useSyncExternalStore: function(t, e, n) {
      var r = Dn, i = ml();
      if (En) {
        if (n === void 0)
          throw Error(Oe(407));
        n = n();
      } else {
        if (n = e(), Cr === null)
          throw Error(Oe(349));
        Jh & 30 || sH(r, e, n);
      }
      i.memoizedState = n;
      var s = {
        value: n,
        getSnapshot: e
      };
      return i.queue = s, X6(aH.bind(null, r, s, t), [
        t
      ]), r.flags |= 2048, Nv(9, oH.bind(null, r, s, n, e), void 0, null), n;
    },
    useId: function() {
      var t = ml(), e = Cr.identifierPrefix;
      if (En) {
        var n = Ec, r = Tc;
        n = (r & ~(1 << 32 - Da(r) - 1)).toString(32) + n, e = ":" + e + "R" + n, n = Lv++, 0 < n && (e += "H" + n.toString(32)), e += ":";
      } else
        n = rSe++, e = ":" + e + "r" + n.toString(32) + ":";
      return t.memoizedState = e;
    },
    unstable_isNewReconciler: false
  }, lSe = {
    readContext: Jo,
    useCallback: gH,
    useContext: Jo,
    useEffect: $3,
    useImperativeHandle: pH,
    useInsertionEffect: dH,
    useLayoutEffect: hH,
    useMemo: mH,
    useReducer: eE,
    useRef: uH,
    useState: function() {
      return eE(jv);
    },
    useDebugValue: A3,
    useDeferredValue: function(t) {
      var e = ea();
      return yH(e, gr.memoizedState, t);
    },
    useTransition: function() {
      var t = eE(jv)[0], e = ea().memoizedState;
      return [
        t,
        e
      ];
    },
    useMutableSource: rH,
    useSyncExternalStore: iH,
    useId: vH,
    unstable_isNewReconciler: false
  }, cSe = {
    readContext: Jo,
    useCallback: gH,
    useContext: Jo,
    useEffect: $3,
    useImperativeHandle: pH,
    useInsertionEffect: dH,
    useLayoutEffect: hH,
    useMemo: mH,
    useReducer: tE,
    useRef: uH,
    useState: function() {
      return tE(jv);
    },
    useDebugValue: A3,
    useDeferredValue: function(t) {
      var e = ea();
      return gr === null ? e.memoizedState = t : yH(e, gr.memoizedState, t);
    },
    useTransition: function() {
      var t = tE(jv)[0], e = ea().memoizedState;
      return [
        t,
        e
      ];
    },
    useMutableSource: rH,
    useSyncExternalStore: iH,
    useId: vH,
    unstable_isNewReconciler: false
  };
  function wa(t, e) {
    if (t && t.defaultProps) {
      e = Ln({}, e), t = t.defaultProps;
      for (var n in t)
        e[n] === void 0 && (e[n] = t[n]);
      return e;
    }
    return e;
  }
  function _A(t, e, n, r) {
    e = t.memoizedState, n = n(r, e), n = n == null ? e : Ln({}, e, n), t.memoizedState = n, t.lanes === 0 && (t.updateQueue.baseState = n);
  }
  var aC = {
    isMounted: function(t) {
      return (t = t._reactInternals) ? yf(t) === t : false;
    },
    enqueueSetState: function(t, e, n) {
      t = t._reactInternals;
      var r = Bi(), i = pd(t), s = Ac(r, i);
      s.payload = e, n != null && (s.callback = n), e = hd(t, s, i), e !== null && (La(e, t, i, r), jx(e, t, i));
    },
    enqueueReplaceState: function(t, e, n) {
      t = t._reactInternals;
      var r = Bi(), i = pd(t), s = Ac(r, i);
      s.tag = 1, s.payload = e, n != null && (s.callback = n), e = hd(t, s, i), e !== null && (La(e, t, i, r), jx(e, t, i));
    },
    enqueueForceUpdate: function(t, e) {
      t = t._reactInternals;
      var n = Bi(), r = pd(t), i = Ac(n, r);
      i.tag = 2, e != null && (i.callback = e), e = hd(t, i, r), e !== null && (La(e, t, r, n), jx(e, t, r));
    }
  };
  function W6(t, e, n, r, i, s, o) {
    return t = t.stateNode, typeof t.shouldComponentUpdate == "function" ? t.shouldComponentUpdate(r, s, o) : e.prototype && e.prototype.isPureReactComponent ? !Iv(n, r) || !Iv(i, s) : true;
  }
  function xH(t, e, n) {
    var r = false, i = Sd, s = e.contextType;
    return typeof s == "object" && s !== null ? s = Jo(s) : (i = vs(e) ? qh : bi.current, r = e.contextTypes, s = (r = r != null) ? Ig(t, i) : Sd), e = new e(n, s), t.memoizedState = e.state !== null && e.state !== void 0 ? e.state : null, e.updater = aC, t.stateNode = e, e._reactInternals = t, r && (t = t.stateNode, t.__reactInternalMemoizedUnmaskedChildContext = i, t.__reactInternalMemoizedMaskedChildContext = s), e;
  }
  function Z6(t, e, n, r) {
    t = e.state, typeof e.componentWillReceiveProps == "function" && e.componentWillReceiveProps(n, r), typeof e.UNSAFE_componentWillReceiveProps == "function" && e.UNSAFE_componentWillReceiveProps(n, r), e.state !== t && aC.enqueueReplaceState(e, e.state, null);
  }
  function TA(t, e, n, r) {
    var i = t.stateNode;
    i.props = n, i.state = t.memoizedState, i.refs = {}, k3(t);
    var s = e.contextType;
    typeof s == "object" && s !== null ? i.context = Jo(s) : (s = vs(e) ? qh : bi.current, i.context = Ig(t, s)), i.state = t.memoizedState, s = e.getDerivedStateFromProps, typeof s == "function" && (_A(t, e, s, n), i.state = t.memoizedState), typeof e.getDerivedStateFromProps == "function" || typeof i.getSnapshotBeforeUpdate == "function" || typeof i.UNSAFE_componentWillMount != "function" && typeof i.componentWillMount != "function" || (e = i.state, typeof i.componentWillMount == "function" && i.componentWillMount(), typeof i.UNSAFE_componentWillMount == "function" && i.UNSAFE_componentWillMount(), e !== i.state && aC.enqueueReplaceState(i, i.state, null), tk(t, n, i, r), i.state = t.memoizedState), typeof i.componentDidMount == "function" && (t.flags |= 4194308);
  }
  function Mg(t, e) {
    try {
      var n = "", r = e;
      do
        n += jve(r), r = r.return;
      while (r);
      var i = n;
    } catch (s) {
      i = `
Error generating stack: ` + s.message + `
` + s.stack;
    }
    return {
      value: t,
      source: e,
      stack: i,
      digest: null
    };
  }
  function nE(t, e, n) {
    return {
      value: t,
      source: null,
      stack: n ?? null,
      digest: e ?? null
    };
  }
  function EA(t, e) {
    try {
      console.error(e.value);
    } catch (n) {
      setTimeout(function() {
        throw n;
      });
    }
  }
  var uSe = typeof WeakMap == "function" ? WeakMap : Map;
  function bH(t, e, n) {
    n = Ac(-1, n), n.tag = 3, n.payload = {
      element: null
    };
    var r = e.value;
    return n.callback = function() {
      ok || (ok = true, QA = r), EA(t, e);
    }, n;
  }
  function kH(t, e, n) {
    n = Ac(-1, n), n.tag = 3;
    var r = t.type.getDerivedStateFromError;
    if (typeof r == "function") {
      var i = e.value;
      n.payload = function() {
        return r(i);
      }, n.callback = function() {
        EA(t, e);
      };
    }
    var s = t.stateNode;
    return s !== null && typeof s.componentDidCatch == "function" && (n.callback = function() {
      EA(t, e), typeof r != "function" && (fd === null ? fd = /* @__PURE__ */ new Set([
        this
      ]) : fd.add(this));
      var o = e.stack;
      this.componentDidCatch(e.value, {
        componentStack: o !== null ? o : ""
      });
    }), n;
  }
  function H6(t, e, n) {
    var r = t.pingCache;
    if (r === null) {
      r = t.pingCache = new uSe();
      var i = /* @__PURE__ */ new Set();
      r.set(e, i);
    } else
      i = r.get(e), i === void 0 && (i = /* @__PURE__ */ new Set(), r.set(e, i));
    i.has(n) || (i.add(n), t = kSe.bind(null, t, e, n), e.then(t, t));
  }
  function Y6(t) {
    do {
      var e;
      if ((e = t.tag === 13) && (e = t.memoizedState, e = e !== null ? e.dehydrated !== null : true), e)
        return t;
      t = t.return;
    } while (t !== null);
    return null;
  }
  function G6(t, e, n, r, i) {
    return t.mode & 1 ? (t.flags |= 65536, t.lanes = i, t) : (t === e ? t.flags |= 65536 : (t.flags |= 128, n.flags |= 131072, n.flags &= -52805, n.tag === 1 && (n.alternate === null ? n.tag = 17 : (e = Ac(-1, 1), e.tag = 2, hd(n, e, 1))), n.lanes |= 1), t);
  }
  var dSe = eu.ReactCurrentOwner, hs = false;
  function Qi(t, e, n, r) {
    e.child = t === null ? JZ(e, null, n, r) : Ag(e, t.child, n, r);
  }
  function q6(t, e, n, r, i) {
    n = n.render;
    var s = e.ref;
    return dg(e, i), r = E3(t, e, n, r, s, i), n = I3(), t !== null && !hs ? (e.updateQueue = t.updateQueue, e.flags &= -2053, t.lanes &= ~i, Wc(t, e, i)) : (En && n && y3(e), e.flags |= 1, Qi(t, e, r, i), e.child);
  }
  function K6(t, e, n, r, i) {
    if (t === null) {
      var s = n.type;
      return typeof s == "function" && !z3(s) && s.defaultProps === void 0 && n.compare === null && n.defaultProps === void 0 ? (e.tag = 15, e.type = s, PH(t, e, s, r, i)) : (t = Ux(n.type, null, r, e, e.mode, i), t.ref = e.ref, t.return = e, e.child = t);
    }
    if (s = t.child, !(t.lanes & i)) {
      var o = s.memoizedProps;
      if (n = n.compare, n = n !== null ? n : Iv, n(o, r) && t.ref === e.ref)
        return Wc(t, e, i);
    }
    return e.flags |= 1, t = gd(s, r), t.ref = e.ref, t.return = e, e.child = t;
  }
  function PH(t, e, n, r, i) {
    if (t !== null) {
      var s = t.memoizedProps;
      if (Iv(s, r) && t.ref === e.ref)
        if (hs = false, e.pendingProps = r = s, (t.lanes & i) !== 0)
          t.flags & 131072 && (hs = true);
        else
          return e.lanes = t.lanes, Wc(t, e, i);
    }
    return IA(t, e, n, r, i);
  }
  function CH(t, e, n) {
    var r = e.pendingProps, i = r.children, s = t !== null ? t.memoizedState : null;
    if (r.mode === "hidden")
      if (!(e.mode & 1))
        e.memoizedState = {
          baseLanes: 0,
          cachePool: null,
          transitions: null
        }, hn(Gp, Us), Us |= n;
      else {
        if (!(n & 1073741824))
          return t = s !== null ? s.baseLanes | n : n, e.lanes = e.childLanes = 1073741824, e.memoizedState = {
            baseLanes: t,
            cachePool: null,
            transitions: null
          }, e.updateQueue = null, hn(Gp, Us), Us |= t, null;
        e.memoizedState = {
          baseLanes: 0,
          cachePool: null,
          transitions: null
        }, r = s !== null ? s.baseLanes : n, hn(Gp, Us), Us |= r;
      }
    else
      s !== null ? (r = s.baseLanes | n, e.memoizedState = null) : r = n, hn(Gp, Us), Us |= r;
    return Qi(t, e, i, n), e.child;
  }
  function _H(t, e) {
    var n = e.ref;
    (t === null && n !== null || t !== null && t.ref !== n) && (e.flags |= 512, e.flags |= 2097152);
  }
  function IA(t, e, n, r, i) {
    var s = vs(n) ? qh : bi.current;
    return s = Ig(e, s), dg(e, i), n = E3(t, e, n, r, s, i), r = I3(), t !== null && !hs ? (e.updateQueue = t.updateQueue, e.flags &= -2053, t.lanes &= ~i, Wc(t, e, i)) : (En && r && y3(e), e.flags |= 1, Qi(t, e, n, i), e.child);
  }
  function J6(t, e, n, r, i) {
    if (vs(n)) {
      var s = true;
      Gb(e);
    } else
      s = false;
    if (dg(e, i), e.stateNode === null)
      zx(t, e), xH(e, n, r), TA(e, n, r, i), r = true;
    else if (t === null) {
      var o = e.stateNode, a = e.memoizedProps;
      o.props = a;
      var l = o.context, c = n.contextType;
      typeof c == "object" && c !== null ? c = Jo(c) : (c = vs(n) ? qh : bi.current, c = Ig(e, c));
      var u = n.getDerivedStateFromProps, d = typeof u == "function" || typeof o.getSnapshotBeforeUpdate == "function";
      d || typeof o.UNSAFE_componentWillReceiveProps != "function" && typeof o.componentWillReceiveProps != "function" || (a !== r || l !== c) && Z6(e, o, r, c), Mu = false;
      var h = e.memoizedState;
      o.state = h, tk(e, r, o, i), l = e.memoizedState, a !== r || h !== l || ys.current || Mu ? (typeof u == "function" && (_A(e, n, u, r), l = e.memoizedState), (a = Mu || W6(e, n, a, r, h, l, c)) ? (d || typeof o.UNSAFE_componentWillMount != "function" && typeof o.componentWillMount != "function" || (typeof o.componentWillMount == "function" && o.componentWillMount(), typeof o.UNSAFE_componentWillMount == "function" && o.UNSAFE_componentWillMount()), typeof o.componentDidMount == "function" && (e.flags |= 4194308)) : (typeof o.componentDidMount == "function" && (e.flags |= 4194308), e.memoizedProps = r, e.memoizedState = l), o.props = r, o.state = l, o.context = c, r = a) : (typeof o.componentDidMount == "function" && (e.flags |= 4194308), r = false);
    } else {
      o = e.stateNode, tH(t, e), a = e.memoizedProps, c = e.type === e.elementType ? a : wa(e.type, a), o.props = c, d = e.pendingProps, h = o.context, l = n.contextType, typeof l == "object" && l !== null ? l = Jo(l) : (l = vs(n) ? qh : bi.current, l = Ig(e, l));
      var f = n.getDerivedStateFromProps;
      (u = typeof f == "function" || typeof o.getSnapshotBeforeUpdate == "function") || typeof o.UNSAFE_componentWillReceiveProps != "function" && typeof o.componentWillReceiveProps != "function" || (a !== d || h !== l) && Z6(e, o, r, l), Mu = false, h = e.memoizedState, o.state = h, tk(e, r, o, i);
      var y = e.memoizedState;
      a !== d || h !== y || ys.current || Mu ? (typeof f == "function" && (_A(e, n, f, r), y = e.memoizedState), (c = Mu || W6(e, n, c, r, h, y, l) || false) ? (u || typeof o.UNSAFE_componentWillUpdate != "function" && typeof o.componentWillUpdate != "function" || (typeof o.componentWillUpdate == "function" && o.componentWillUpdate(r, y, l), typeof o.UNSAFE_componentWillUpdate == "function" && o.UNSAFE_componentWillUpdate(r, y, l)), typeof o.componentDidUpdate == "function" && (e.flags |= 4), typeof o.getSnapshotBeforeUpdate == "function" && (e.flags |= 1024)) : (typeof o.componentDidUpdate != "function" || a === t.memoizedProps && h === t.memoizedState || (e.flags |= 4), typeof o.getSnapshotBeforeUpdate != "function" || a === t.memoizedProps && h === t.memoizedState || (e.flags |= 1024), e.memoizedProps = r, e.memoizedState = y), o.props = r, o.state = y, o.context = l, r = c) : (typeof o.componentDidUpdate != "function" || a === t.memoizedProps && h === t.memoizedState || (e.flags |= 4), typeof o.getSnapshotBeforeUpdate != "function" || a === t.memoizedProps && h === t.memoizedState || (e.flags |= 1024), r = false);
    }
    return $A(t, e, n, r, s, i);
  }
  function $A(t, e, n, r, i, s) {
    _H(t, e);
    var o = (e.flags & 128) !== 0;
    if (!r && !o)
      return i && N6(e, n, false), Wc(t, e, s);
    r = e.stateNode, dSe.current = e;
    var a = o && typeof n.getDerivedStateFromError != "function" ? null : r.render();
    return e.flags |= 1, t !== null && o ? (e.child = Ag(e, t.child, null, s), e.child = Ag(e, null, a, s)) : Qi(t, e, a, s), e.memoizedState = r.state, i && N6(e, n, true), e.child;
  }
  function TH(t) {
    var e = t.stateNode;
    e.pendingContext ? j6(t, e.pendingContext, e.pendingContext !== e.context) : e.context && j6(t, e.context, false), P3(t, e.containerInfo);
  }
  function ez(t, e, n, r, i) {
    return $g(), O3(i), e.flags |= 256, Qi(t, e, n, r), e.child;
  }
  var AA = {
    dehydrated: null,
    treeContext: null,
    retryLane: 0
  };
  function RA(t) {
    return {
      baseLanes: t,
      cachePool: null,
      transitions: null
    };
  }
  function EH(t, e, n) {
    var r = e.pendingProps, i = An.current, s = false, o = (e.flags & 128) !== 0, a;
    if ((a = o) || (a = t !== null && t.memoizedState === null ? false : (i & 2) !== 0), a ? (s = true, e.flags &= -129) : (t === null || t.memoizedState !== null) && (i |= 1), hn(An, i & 1), t === null)
      return PA(e), t = e.memoizedState, t !== null && (t = t.dehydrated, t !== null) ? (e.mode & 1 ? t.data === "$!" ? e.lanes = 8 : e.lanes = 1073741824 : e.lanes = 1, null) : (o = r.children, t = r.fallback, s ? (r = e.mode, s = e.child, o = {
        mode: "hidden",
        children: o
      }, !(r & 1) && s !== null ? (s.childLanes = 0, s.pendingProps = o) : s = uC(o, r, 0, null), t = Uh(t, r, n, null), s.return = e, t.return = e, s.sibling = t, e.child = s, e.child.memoizedState = RA(n), e.memoizedState = AA, t) : R3(e, o));
    if (i = t.memoizedState, i !== null && (a = i.dehydrated, a !== null))
      return hSe(t, e, o, r, a, i, n);
    if (s) {
      s = r.fallback, o = e.mode, i = t.child, a = i.sibling;
      var l = {
        mode: "hidden",
        children: r.children
      };
      return !(o & 1) && e.child !== i ? (r = e.child, r.childLanes = 0, r.pendingProps = l, e.deletions = null) : (r = gd(i, l), r.subtreeFlags = i.subtreeFlags & 14680064), a !== null ? s = gd(a, s) : (s = Uh(s, o, n, null), s.flags |= 2), s.return = e, r.return = e, r.sibling = s, e.child = r, r = s, s = e.child, o = t.child.memoizedState, o = o === null ? RA(n) : {
        baseLanes: o.baseLanes | n,
        cachePool: null,
        transitions: o.transitions
      }, s.memoizedState = o, s.childLanes = t.childLanes & ~n, e.memoizedState = AA, r;
    }
    return s = t.child, t = s.sibling, r = gd(s, {
      mode: "visible",
      children: r.children
    }), !(e.mode & 1) && (r.lanes = n), r.return = e, r.sibling = null, t !== null && (n = e.deletions, n === null ? (e.deletions = [
      t
    ], e.flags |= 16) : n.push(t)), e.child = r, e.memoizedState = null, r;
  }
  function R3(t, e) {
    return e = uC({
      mode: "visible",
      children: e
    }, t.mode, 0, null), e.return = t, t.child = e;
  }
  function ew(t, e, n, r) {
    return r !== null && O3(r), Ag(e, t.child, null, n), t = R3(e, e.pendingProps.children), t.flags |= 2, e.memoizedState = null, t;
  }
  function hSe(t, e, n, r, i, s, o) {
    if (n)
      return e.flags & 256 ? (e.flags &= -257, r = nE(Error(Oe(422))), ew(t, e, o, r)) : e.memoizedState !== null ? (e.child = t.child, e.flags |= 128, null) : (s = r.fallback, i = e.mode, r = uC({
        mode: "visible",
        children: r.children
      }, i, 0, null), s = Uh(s, i, o, null), s.flags |= 2, r.return = e, s.return = e, r.sibling = s, e.child = r, e.mode & 1 && Ag(e, t.child, null, o), e.child.memoizedState = RA(o), e.memoizedState = AA, s);
    if (!(e.mode & 1))
      return ew(t, e, o, null);
    if (i.data === "$!") {
      if (r = i.nextSibling && i.nextSibling.dataset, r)
        var a = r.dgst;
      return r = a, s = Error(Oe(419)), r = nE(s, r, void 0), ew(t, e, o, r);
    }
    if (a = (o & t.childLanes) !== 0, hs || a) {
      if (r = Cr, r !== null) {
        switch (o & -o) {
          case 4:
            i = 2;
            break;
          case 16:
            i = 8;
            break;
          case 64:
          case 128:
          case 256:
          case 512:
          case 1024:
          case 2048:
          case 4096:
          case 8192:
          case 16384:
          case 32768:
          case 65536:
          case 131072:
          case 262144:
          case 524288:
          case 1048576:
          case 2097152:
          case 4194304:
          case 8388608:
          case 16777216:
          case 33554432:
          case 67108864:
            i = 32;
            break;
          case 536870912:
            i = 268435456;
            break;
          default:
            i = 0;
        }
        i = i & (r.suspendedLanes | o) ? 0 : i, i !== 0 && i !== s.retryLane && (s.retryLane = i, Xc(t, i), La(r, t, i, -1));
      }
      return Q3(), r = nE(Error(Oe(421))), ew(t, e, o, r);
    }
    return i.data === "$?" ? (e.flags |= 128, e.child = t.child, e = PSe.bind(null, t), i._reactRetry = e, null) : (t = s.treeContext, to = dd(i.nextSibling), ro = e, En = true, Pa = null, t !== null && (jo[No++] = Tc, jo[No++] = Ec, jo[No++] = Kh, Tc = t.id, Ec = t.overflow, Kh = e), e = R3(e, r.children), e.flags |= 4096, e);
  }
  function tz(t, e, n) {
    t.lanes |= e;
    var r = t.alternate;
    r !== null && (r.lanes |= e), CA(t.return, e, n);
  }
  function rE(t, e, n, r, i) {
    var s = t.memoizedState;
    s === null ? t.memoizedState = {
      isBackwards: e,
      rendering: null,
      renderingStartTime: 0,
      last: r,
      tail: n,
      tailMode: i
    } : (s.isBackwards = e, s.rendering = null, s.renderingStartTime = 0, s.last = r, s.tail = n, s.tailMode = i);
  }
  function IH(t, e, n) {
    var r = e.pendingProps, i = r.revealOrder, s = r.tail;
    if (Qi(t, e, r.children, n), r = An.current, r & 2)
      r = r & 1 | 2, e.flags |= 128;
    else {
      if (t !== null && t.flags & 128)
        e:
          for (t = e.child; t !== null; ) {
            if (t.tag === 13)
              t.memoizedState !== null && tz(t, n, e);
            else if (t.tag === 19)
              tz(t, n, e);
            else if (t.child !== null) {
              t.child.return = t, t = t.child;
              continue;
            }
            if (t === e)
              break e;
            for (; t.sibling === null; ) {
              if (t.return === null || t.return === e)
                break e;
              t = t.return;
            }
            t.sibling.return = t.return, t = t.sibling;
          }
      r &= 1;
    }
    if (hn(An, r), !(e.mode & 1))
      e.memoizedState = null;
    else
      switch (i) {
        case "forwards":
          for (n = e.child, i = null; n !== null; )
            t = n.alternate, t !== null && nk(t) === null && (i = n), n = n.sibling;
          n = i, n === null ? (i = e.child, e.child = null) : (i = n.sibling, n.sibling = null), rE(e, false, i, n, s);
          break;
        case "backwards":
          for (n = null, i = e.child, e.child = null; i !== null; ) {
            if (t = i.alternate, t !== null && nk(t) === null) {
              e.child = i;
              break;
            }
            t = i.sibling, i.sibling = n, n = i, i = t;
          }
          rE(e, true, n, null, s);
          break;
        case "together":
          rE(e, false, null, null, void 0);
          break;
        default:
          e.memoizedState = null;
      }
    return e.child;
  }
  function zx(t, e) {
    !(e.mode & 1) && t !== null && (t.alternate = null, e.alternate = null, e.flags |= 2);
  }
  function Wc(t, e, n) {
    if (t !== null && (e.dependencies = t.dependencies), ef |= e.lanes, !(n & e.childLanes))
      return null;
    if (t !== null && e.child !== t.child)
      throw Error(Oe(153));
    if (e.child !== null) {
      for (t = e.child, n = gd(t, t.pendingProps), e.child = n, n.return = e; t.sibling !== null; )
        t = t.sibling, n = n.sibling = gd(t, t.pendingProps), n.return = e;
      n.sibling = null;
    }
    return e.child;
  }
  function fSe(t, e, n) {
    switch (e.tag) {
      case 3:
        TH(e), $g();
        break;
      case 5:
        nH(e);
        break;
      case 1:
        vs(e.type) && Gb(e);
        break;
      case 4:
        P3(e, e.stateNode.containerInfo);
        break;
      case 10:
        var r = e.type._context, i = e.memoizedProps.value;
        hn(Jb, r._currentValue), r._currentValue = i;
        break;
      case 13:
        if (r = e.memoizedState, r !== null)
          return r.dehydrated !== null ? (hn(An, An.current & 1), e.flags |= 128, null) : n & e.child.childLanes ? EH(t, e, n) : (hn(An, An.current & 1), t = Wc(t, e, n), t !== null ? t.sibling : null);
        hn(An, An.current & 1);
        break;
      case 19:
        if (r = (n & e.childLanes) !== 0, t.flags & 128) {
          if (r)
            return IH(t, e, n);
          e.flags |= 128;
        }
        if (i = e.memoizedState, i !== null && (i.rendering = null, i.tail = null, i.lastEffect = null), hn(An, An.current), r)
          break;
        return null;
      case 22:
      case 23:
        return e.lanes = 0, CH(t, e, n);
    }
    return Wc(t, e, n);
  }
  var $H, MA, AH, RH;
  $H = function(t, e) {
    for (var n = e.child; n !== null; ) {
      if (n.tag === 5 || n.tag === 6)
        t.appendChild(n.stateNode);
      else if (n.tag !== 4 && n.child !== null) {
        n.child.return = n, n = n.child;
        continue;
      }
      if (n === e)
        break;
      for (; n.sibling === null; ) {
        if (n.return === null || n.return === e)
          return;
        n = n.return;
      }
      n.sibling.return = n.return, n = n.sibling;
    }
  };
  MA = function() {
  };
  AH = function(t, e, n, r) {
    var i = t.memoizedProps;
    if (i !== r) {
      t = e.stateNode, $h($l.current);
      var s = null;
      switch (n) {
        case "input":
          i = nA(t, i), r = nA(t, r), s = [];
          break;
        case "select":
          i = Ln({}, i, {
            value: void 0
          }), r = Ln({}, r, {
            value: void 0
          }), s = [];
          break;
        case "textarea":
          i = sA(t, i), r = sA(t, r), s = [];
          break;
        default:
          typeof i.onClick != "function" && typeof r.onClick == "function" && (t.onclick = Hb);
      }
      aA(n, r);
      var o;
      n = null;
      for (c in i)
        if (!r.hasOwnProperty(c) && i.hasOwnProperty(c) && i[c] != null)
          if (c === "style") {
            var a = i[c];
            for (o in a)
              a.hasOwnProperty(o) && (n || (n = {}), n[o] = "");
          } else
            c !== "dangerouslySetInnerHTML" && c !== "children" && c !== "suppressContentEditableWarning" && c !== "suppressHydrationWarning" && c !== "autoFocus" && (bv.hasOwnProperty(c) ? s || (s = []) : (s = s || []).push(c, null));
      for (c in r) {
        var l = r[c];
        if (a = i == null ? void 0 : i[c], r.hasOwnProperty(c) && l !== a && (l != null || a != null))
          if (c === "style")
            if (a) {
              for (o in a)
                !a.hasOwnProperty(o) || l && l.hasOwnProperty(o) || (n || (n = {}), n[o] = "");
              for (o in l)
                l.hasOwnProperty(o) && a[o] !== l[o] && (n || (n = {}), n[o] = l[o]);
            } else
              n || (s || (s = []), s.push(c, n)), n = l;
          else
            c === "dangerouslySetInnerHTML" ? (l = l ? l.__html : void 0, a = a ? a.__html : void 0, l != null && a !== l && (s = s || []).push(c, l)) : c === "children" ? typeof l != "string" && typeof l != "number" || (s = s || []).push(c, "" + l) : c !== "suppressContentEditableWarning" && c !== "suppressHydrationWarning" && (bv.hasOwnProperty(c) ? (l != null && c === "onScroll" && mn("scroll", t), s || a === l || (s = [])) : (s = s || []).push(c, l));
      }
      n && (s = s || []).push("style", n);
      var c = s;
      (e.updateQueue = c) && (e.flags |= 4);
    }
  };
  RH = function(t, e, n, r) {
    n !== r && (e.flags |= 4);
  };
  function $y(t, e) {
    if (!En)
      switch (t.tailMode) {
        case "hidden":
          e = t.tail;
          for (var n = null; e !== null; )
            e.alternate !== null && (n = e), e = e.sibling;
          n === null ? t.tail = null : n.sibling = null;
          break;
        case "collapsed":
          n = t.tail;
          for (var r = null; n !== null; )
            n.alternate !== null && (r = n), n = n.sibling;
          r === null ? e || t.tail === null ? t.tail = null : t.tail.sibling = null : r.sibling = null;
      }
  }
  function ii(t) {
    var e = t.alternate !== null && t.alternate.child === t.child, n = 0, r = 0;
    if (e)
      for (var i = t.child; i !== null; )
        n |= i.lanes | i.childLanes, r |= i.subtreeFlags & 14680064, r |= i.flags & 14680064, i.return = t, i = i.sibling;
    else
      for (i = t.child; i !== null; )
        n |= i.lanes | i.childLanes, r |= i.subtreeFlags, r |= i.flags, i.return = t, i = i.sibling;
    return t.subtreeFlags |= r, t.childLanes = n, e;
  }
  function pSe(t, e, n) {
    var r = e.pendingProps;
    switch (v3(e), e.tag) {
      case 2:
      case 16:
      case 15:
      case 0:
      case 11:
      case 7:
      case 8:
      case 12:
      case 9:
      case 14:
        return ii(e), null;
      case 1:
        return vs(e.type) && Yb(), ii(e), null;
      case 3:
        return r = e.stateNode, Rg(), xn(ys), xn(bi), _3(), r.pendingContext && (r.context = r.pendingContext, r.pendingContext = null), (t === null || t.child === null) && (K1(e) ? e.flags |= 4 : t === null || t.memoizedState.isDehydrated && !(e.flags & 256) || (e.flags |= 1024, Pa !== null && (BA(Pa), Pa = null))), MA(t, e), ii(e), null;
      case 5:
        C3(e);
        var i = $h(Dv.current);
        if (n = e.type, t !== null && e.stateNode != null)
          AH(t, e, n, r, i), t.ref !== e.ref && (e.flags |= 512, e.flags |= 2097152);
        else {
          if (!r) {
            if (e.stateNode === null)
              throw Error(Oe(166));
            return ii(e), null;
          }
          if (t = $h($l.current), K1(e)) {
            r = e.stateNode, n = e.type;
            var s = e.memoizedProps;
            switch (r[xl] = e, r[Rv] = s, t = (e.mode & 1) !== 0, n) {
              case "dialog":
                mn("cancel", r), mn("close", r);
                break;
              case "iframe":
              case "object":
              case "embed":
                mn("load", r);
                break;
              case "video":
              case "audio":
                for (i = 0; i < m0.length; i++)
                  mn(m0[i], r);
                break;
              case "source":
                mn("error", r);
                break;
              case "img":
              case "image":
              case "link":
                mn("error", r), mn("load", r);
                break;
              case "details":
                mn("toggle", r);
                break;
              case "input":
                u6(r, s), mn("invalid", r);
                break;
              case "select":
                r._wrapperState = {
                  wasMultiple: !!s.multiple
                }, mn("invalid", r);
                break;
              case "textarea":
                h6(r, s), mn("invalid", r);
            }
            aA(n, s), i = null;
            for (var o in s)
              if (s.hasOwnProperty(o)) {
                var a = s[o];
                o === "children" ? typeof a == "string" ? r.textContent !== a && (s.suppressHydrationWarning !== true && q1(r.textContent, a, t), i = [
                  "children",
                  a
                ]) : typeof a == "number" && r.textContent !== "" + a && (s.suppressHydrationWarning !== true && q1(r.textContent, a, t), i = [
                  "children",
                  "" + a
                ]) : bv.hasOwnProperty(o) && a != null && o === "onScroll" && mn("scroll", r);
              }
            switch (n) {
              case "input":
                U1(r), d6(r, s, true);
                break;
              case "textarea":
                U1(r), f6(r);
                break;
              case "select":
              case "option":
                break;
              default:
                typeof s.onClick == "function" && (r.onclick = Hb);
            }
            r = i, e.updateQueue = r, r !== null && (e.flags |= 4);
          } else {
            o = i.nodeType === 9 ? i : i.ownerDocument, t === "http://www.w3.org/1999/xhtml" && (t = aZ(n)), t === "http://www.w3.org/1999/xhtml" ? n === "script" ? (t = o.createElement("div"), t.innerHTML = "<script><\/script>", t = t.removeChild(t.firstChild)) : typeof r.is == "string" ? t = o.createElement(n, {
              is: r.is
            }) : (t = o.createElement(n), n === "select" && (o = t, r.multiple ? o.multiple = true : r.size && (o.size = r.size))) : t = o.createElementNS(t, n), t[xl] = e, t[Rv] = r, $H(t, e, false, false), e.stateNode = t;
            e: {
              switch (o = lA(n, r), n) {
                case "dialog":
                  mn("cancel", t), mn("close", t), i = r;
                  break;
                case "iframe":
                case "object":
                case "embed":
                  mn("load", t), i = r;
                  break;
                case "video":
                case "audio":
                  for (i = 0; i < m0.length; i++)
                    mn(m0[i], t);
                  i = r;
                  break;
                case "source":
                  mn("error", t), i = r;
                  break;
                case "img":
                case "image":
                case "link":
                  mn("error", t), mn("load", t), i = r;
                  break;
                case "details":
                  mn("toggle", t), i = r;
                  break;
                case "input":
                  u6(t, r), i = nA(t, r), mn("invalid", t);
                  break;
                case "option":
                  i = r;
                  break;
                case "select":
                  t._wrapperState = {
                    wasMultiple: !!r.multiple
                  }, i = Ln({}, r, {
                    value: void 0
                  }), mn("invalid", t);
                  break;
                case "textarea":
                  h6(t, r), i = sA(t, r), mn("invalid", t);
                  break;
                default:
                  i = r;
              }
              aA(n, i), a = i;
              for (s in a)
                if (a.hasOwnProperty(s)) {
                  var l = a[s];
                  s === "style" ? uZ(t, l) : s === "dangerouslySetInnerHTML" ? (l = l ? l.__html : void 0, l != null && lZ(t, l)) : s === "children" ? typeof l == "string" ? (n !== "textarea" || l !== "") && kv(t, l) : typeof l == "number" && kv(t, "" + l) : s !== "suppressContentEditableWarning" && s !== "suppressHydrationWarning" && s !== "autoFocus" && (bv.hasOwnProperty(s) ? l != null && s === "onScroll" && mn("scroll", t) : l != null && r3(t, s, l, o));
                }
              switch (n) {
                case "input":
                  U1(t), d6(t, r, false);
                  break;
                case "textarea":
                  U1(t), f6(t);
                  break;
                case "option":
                  r.value != null && t.setAttribute("value", "" + Od(r.value));
                  break;
                case "select":
                  t.multiple = !!r.multiple, s = r.value, s != null ? ag(t, !!r.multiple, s, false) : r.defaultValue != null && ag(t, !!r.multiple, r.defaultValue, true);
                  break;
                default:
                  typeof i.onClick == "function" && (t.onclick = Hb);
              }
              switch (n) {
                case "button":
                case "input":
                case "select":
                case "textarea":
                  r = !!r.autoFocus;
                  break e;
                case "img":
                  r = true;
                  break e;
                default:
                  r = false;
              }
            }
            r && (e.flags |= 4);
          }
          e.ref !== null && (e.flags |= 512, e.flags |= 2097152);
        }
        return ii(e), null;
      case 6:
        if (t && e.stateNode != null)
          RH(t, e, t.memoizedProps, r);
        else {
          if (typeof r != "string" && e.stateNode === null)
            throw Error(Oe(166));
          if (n = $h(Dv.current), $h($l.current), K1(e)) {
            if (r = e.stateNode, n = e.memoizedProps, r[xl] = e, (s = r.nodeValue !== n) && (t = ro, t !== null))
              switch (t.tag) {
                case 3:
                  q1(r.nodeValue, n, (t.mode & 1) !== 0);
                  break;
                case 5:
                  t.memoizedProps.suppressHydrationWarning !== true && q1(r.nodeValue, n, (t.mode & 1) !== 0);
              }
            s && (e.flags |= 4);
          } else
            r = (n.nodeType === 9 ? n : n.ownerDocument).createTextNode(r), r[xl] = e, e.stateNode = r;
        }
        return ii(e), null;
      case 13:
        if (xn(An), r = e.memoizedState, t === null || t.memoizedState !== null && t.memoizedState.dehydrated !== null) {
          if (En && to !== null && e.mode & 1 && !(e.flags & 128))
            qZ(), $g(), e.flags |= 98560, s = false;
          else if (s = K1(e), r !== null && r.dehydrated !== null) {
            if (t === null) {
              if (!s)
                throw Error(Oe(318));
              if (s = e.memoizedState, s = s !== null ? s.dehydrated : null, !s)
                throw Error(Oe(317));
              s[xl] = e;
            } else
              $g(), !(e.flags & 128) && (e.memoizedState = null), e.flags |= 4;
            ii(e), s = false;
          } else
            Pa !== null && (BA(Pa), Pa = null), s = true;
          if (!s)
            return e.flags & 65536 ? e : null;
        }
        return e.flags & 128 ? (e.lanes = n, e) : (r = r !== null, r !== (t !== null && t.memoizedState !== null) && r && (e.child.flags |= 8192, e.mode & 1 && (t === null || An.current & 1 ? yr === 0 && (yr = 3) : Q3())), e.updateQueue !== null && (e.flags |= 4), ii(e), null);
      case 4:
        return Rg(), MA(t, e), t === null && $v(e.stateNode.containerInfo), ii(e), null;
      case 10:
        return x3(e.type._context), ii(e), null;
      case 17:
        return vs(e.type) && Yb(), ii(e), null;
      case 19:
        if (xn(An), s = e.memoizedState, s === null)
          return ii(e), null;
        if (r = (e.flags & 128) !== 0, o = s.rendering, o === null)
          if (r)
            $y(s, false);
          else {
            if (yr !== 0 || t !== null && t.flags & 128)
              for (t = e.child; t !== null; ) {
                if (o = nk(t), o !== null) {
                  for (e.flags |= 128, $y(s, false), r = o.updateQueue, r !== null && (e.updateQueue = r, e.flags |= 4), e.subtreeFlags = 0, r = n, n = e.child; n !== null; )
                    s = n, t = r, s.flags &= 14680066, o = s.alternate, o === null ? (s.childLanes = 0, s.lanes = t, s.child = null, s.subtreeFlags = 0, s.memoizedProps = null, s.memoizedState = null, s.updateQueue = null, s.dependencies = null, s.stateNode = null) : (s.childLanes = o.childLanes, s.lanes = o.lanes, s.child = o.child, s.subtreeFlags = 0, s.deletions = null, s.memoizedProps = o.memoizedProps, s.memoizedState = o.memoizedState, s.updateQueue = o.updateQueue, s.type = o.type, t = o.dependencies, s.dependencies = t === null ? null : {
                      lanes: t.lanes,
                      firstContext: t.firstContext
                    }), n = n.sibling;
                  return hn(An, An.current & 1 | 2), e.child;
                }
                t = t.sibling;
              }
            s.tail !== null && Gn() > Dg && (e.flags |= 128, r = true, $y(s, false), e.lanes = 4194304);
          }
        else {
          if (!r)
            if (t = nk(o), t !== null) {
              if (e.flags |= 128, r = true, n = t.updateQueue, n !== null && (e.updateQueue = n, e.flags |= 4), $y(s, true), s.tail === null && s.tailMode === "hidden" && !o.alternate && !En)
                return ii(e), null;
            } else
              2 * Gn() - s.renderingStartTime > Dg && n !== 1073741824 && (e.flags |= 128, r = true, $y(s, false), e.lanes = 4194304);
          s.isBackwards ? (o.sibling = e.child, e.child = o) : (n = s.last, n !== null ? n.sibling = o : e.child = o, s.last = o);
        }
        return s.tail !== null ? (e = s.tail, s.rendering = e, s.tail = e.sibling, s.renderingStartTime = Gn(), e.sibling = null, n = An.current, hn(An, r ? n & 1 | 2 : n & 1), e) : (ii(e), null);
      case 22:
      case 23:
        return N3(), r = e.memoizedState !== null, t !== null && t.memoizedState !== null !== r && (e.flags |= 8192), r && e.mode & 1 ? Us & 1073741824 && (ii(e), e.subtreeFlags & 6 && (e.flags |= 8192)) : ii(e), null;
      case 24:
        return null;
      case 25:
        return null;
    }
    throw Error(Oe(156, e.tag));
  }
  function gSe(t, e) {
    switch (v3(e), e.tag) {
      case 1:
        return vs(e.type) && Yb(), t = e.flags, t & 65536 ? (e.flags = t & -65537 | 128, e) : null;
      case 3:
        return Rg(), xn(ys), xn(bi), _3(), t = e.flags, t & 65536 && !(t & 128) ? (e.flags = t & -65537 | 128, e) : null;
      case 5:
        return C3(e), null;
      case 13:
        if (xn(An), t = e.memoizedState, t !== null && t.dehydrated !== null) {
          if (e.alternate === null)
            throw Error(Oe(340));
          $g();
        }
        return t = e.flags, t & 65536 ? (e.flags = t & -65537 | 128, e) : null;
      case 19:
        return xn(An), null;
      case 4:
        return Rg(), null;
      case 10:
        return x3(e.type._context), null;
      case 22:
      case 23:
        return N3(), null;
      case 24:
        return null;
      default:
        return null;
    }
  }
  var tw = false, di = false, mSe = typeof WeakSet == "function" ? WeakSet : Set, De = null;
  function Yp(t, e) {
    var n = t.ref;
    if (n !== null)
      if (typeof n == "function")
        try {
          n(null);
        } catch (r) {
          zn(t, e, r);
        }
      else
        n.current = null;
  }
  function DA(t, e, n) {
    try {
      n();
    } catch (r) {
      zn(t, e, r);
    }
  }
  var nz = false;
  function ySe(t, e) {
    if (vA = Xb, t = NZ(), m3(t)) {
      if ("selectionStart" in t)
        var n = {
          start: t.selectionStart,
          end: t.selectionEnd
        };
      else
        e: {
          n = (n = t.ownerDocument) && n.defaultView || window;
          var r = n.getSelection && n.getSelection();
          if (r && r.rangeCount !== 0) {
            n = r.anchorNode;
            var i = r.anchorOffset, s = r.focusNode;
            r = r.focusOffset;
            try {
              n.nodeType, s.nodeType;
            } catch {
              n = null;
              break e;
            }
            var o = 0, a = -1, l = -1, c = 0, u = 0, d = t, h = null;
            t:
              for (; ; ) {
                for (var f; d !== n || i !== 0 && d.nodeType !== 3 || (a = o + i), d !== s || r !== 0 && d.nodeType !== 3 || (l = o + r), d.nodeType === 3 && (o += d.nodeValue.length), (f = d.firstChild) !== null; )
                  h = d, d = f;
                for (; ; ) {
                  if (d === t)
                    break t;
                  if (h === n && ++c === i && (a = o), h === s && ++u === r && (l = o), (f = d.nextSibling) !== null)
                    break;
                  d = h, h = d.parentNode;
                }
                d = f;
              }
            n = a === -1 || l === -1 ? null : {
              start: a,
              end: l
            };
          } else
            n = null;
        }
      n = n || {
        start: 0,
        end: 0
      };
    } else
      n = null;
    for (OA = {
      focusedElem: t,
      selectionRange: n
    }, Xb = false, De = e; De !== null; )
      if (e = De, t = e.child, (e.subtreeFlags & 1028) !== 0 && t !== null)
        t.return = e, De = t;
      else
        for (; De !== null; ) {
          e = De;
          try {
            var y = e.alternate;
            if (e.flags & 1024)
              switch (e.tag) {
                case 0:
                case 11:
                case 15:
                  break;
                case 1:
                  if (y !== null) {
                    var g = y.memoizedProps, O = y.memoizedState, S = e.stateNode, w = S.getSnapshotBeforeUpdate(e.elementType === e.type ? g : wa(e.type, g), O);
                    S.__reactInternalSnapshotBeforeUpdate = w;
                  }
                  break;
                case 3:
                  var x = e.stateNode.containerInfo;
                  x.nodeType === 1 ? x.textContent = "" : x.nodeType === 9 && x.documentElement && x.removeChild(x.documentElement);
                  break;
                case 5:
                case 6:
                case 4:
                case 17:
                  break;
                default:
                  throw Error(Oe(163));
              }
          } catch (P) {
            zn(e, e.return, P);
          }
          if (t = e.sibling, t !== null) {
            t.return = e.return, De = t;
            break;
          }
          De = e.return;
        }
    return y = nz, nz = false, y;
  }
  function U0(t, e, n) {
    var r = e.updateQueue;
    if (r = r !== null ? r.lastEffect : null, r !== null) {
      var i = r = r.next;
      do {
        if ((i.tag & t) === t) {
          var s = i.destroy;
          i.destroy = void 0, s !== void 0 && DA(e, n, s);
        }
        i = i.next;
      } while (i !== r);
    }
  }
  function lC(t, e) {
    if (e = e.updateQueue, e = e !== null ? e.lastEffect : null, e !== null) {
      var n = e = e.next;
      do {
        if ((n.tag & t) === t) {
          var r = n.create;
          n.destroy = r();
        }
        n = n.next;
      } while (n !== e);
    }
  }
  function LA(t) {
    var e = t.ref;
    if (e !== null) {
      var n = t.stateNode;
      switch (t.tag) {
        case 5:
          t = n;
          break;
        default:
          t = n;
      }
      typeof e == "function" ? e(t) : e.current = t;
    }
  }
  function MH(t) {
    var e = t.alternate;
    e !== null && (t.alternate = null, MH(e)), t.child = null, t.deletions = null, t.sibling = null, t.tag === 5 && (e = t.stateNode, e !== null && (delete e[xl], delete e[Rv], delete e[xA], delete e[JOe], delete e[eSe])), t.stateNode = null, t.return = null, t.dependencies = null, t.memoizedProps = null, t.memoizedState = null, t.pendingProps = null, t.stateNode = null, t.updateQueue = null;
  }
  function DH(t) {
    return t.tag === 5 || t.tag === 3 || t.tag === 4;
  }
  function rz(t) {
    e:
      for (; ; ) {
        for (; t.sibling === null; ) {
          if (t.return === null || DH(t.return))
            return null;
          t = t.return;
        }
        for (t.sibling.return = t.return, t = t.sibling; t.tag !== 5 && t.tag !== 6 && t.tag !== 18; ) {
          if (t.flags & 2 || t.child === null || t.tag === 4)
            continue e;
          t.child.return = t, t = t.child;
        }
        if (!(t.flags & 2))
          return t.stateNode;
      }
  }
  function jA(t, e, n) {
    var r = t.tag;
    if (r === 5 || r === 6)
      t = t.stateNode, e ? n.nodeType === 8 ? n.parentNode.insertBefore(t, e) : n.insertBefore(t, e) : (n.nodeType === 8 ? (e = n.parentNode, e.insertBefore(t, n)) : (e = n, e.appendChild(t)), n = n._reactRootContainer, n != null || e.onclick !== null || (e.onclick = Hb));
    else if (r !== 4 && (t = t.child, t !== null))
      for (jA(t, e, n), t = t.sibling; t !== null; )
        jA(t, e, n), t = t.sibling;
  }
  function NA(t, e, n) {
    var r = t.tag;
    if (r === 5 || r === 6)
      t = t.stateNode, e ? n.insertBefore(t, e) : n.appendChild(t);
    else if (r !== 4 && (t = t.child, t !== null))
      for (NA(t, e, n), t = t.sibling; t !== null; )
        NA(t, e, n), t = t.sibling;
  }
  var Lr = null, xa = false;
  function ku(t, e, n) {
    for (n = n.child; n !== null; )
      LH(t, e, n), n = n.sibling;
  }
  function LH(t, e, n) {
    if (Il && typeof Il.onCommitFiberUnmount == "function")
      try {
        Il.onCommitFiberUnmount(eC, n);
      } catch {
      }
    switch (n.tag) {
      case 5:
        di || Yp(n, e);
      case 6:
        var r = Lr, i = xa;
        Lr = null, ku(t, e, n), Lr = r, xa = i, Lr !== null && (xa ? (t = Lr, n = n.stateNode, t.nodeType === 8 ? t.parentNode.removeChild(n) : t.removeChild(n)) : Lr.removeChild(n.stateNode));
        break;
      case 18:
        Lr !== null && (xa ? (t = Lr, n = n.stateNode, t.nodeType === 8 ? GT(t.parentNode, n) : t.nodeType === 1 && GT(t, n), Tv(t)) : GT(Lr, n.stateNode));
        break;
      case 4:
        r = Lr, i = xa, Lr = n.stateNode.containerInfo, xa = true, ku(t, e, n), Lr = r, xa = i;
        break;
      case 0:
      case 11:
      case 14:
      case 15:
        if (!di && (r = n.updateQueue, r !== null && (r = r.lastEffect, r !== null))) {
          i = r = r.next;
          do {
            var s = i, o = s.destroy;
            s = s.tag, o !== void 0 && (s & 2 || s & 4) && DA(n, e, o), i = i.next;
          } while (i !== r);
        }
        ku(t, e, n);
        break;
      case 1:
        if (!di && (Yp(n, e), r = n.stateNode, typeof r.componentWillUnmount == "function"))
          try {
            r.props = n.memoizedProps, r.state = n.memoizedState, r.componentWillUnmount();
          } catch (a) {
            zn(n, e, a);
          }
        ku(t, e, n);
        break;
      case 21:
        ku(t, e, n);
        break;
      case 22:
        n.mode & 1 ? (di = (r = di) || n.memoizedState !== null, ku(t, e, n), di = r) : ku(t, e, n);
        break;
      default:
        ku(t, e, n);
    }
  }
  function iz(t) {
    var e = t.updateQueue;
    if (e !== null) {
      t.updateQueue = null;
      var n = t.stateNode;
      n === null && (n = t.stateNode = new mSe()), e.forEach(function(r) {
        var i = CSe.bind(null, t, r);
        n.has(r) || (n.add(r), r.then(i, i));
      });
    }
  }
  function ga(t, e) {
    var n = e.deletions;
    if (n !== null)
      for (var r = 0; r < n.length; r++) {
        var i = n[r];
        try {
          var s = t, o = e, a = o;
          e:
            for (; a !== null; ) {
              switch (a.tag) {
                case 5:
                  Lr = a.stateNode, xa = false;
                  break e;
                case 3:
                  Lr = a.stateNode.containerInfo, xa = true;
                  break e;
                case 4:
                  Lr = a.stateNode.containerInfo, xa = true;
                  break e;
              }
              a = a.return;
            }
          if (Lr === null)
            throw Error(Oe(160));
          LH(s, o, i), Lr = null, xa = false;
          var l = i.alternate;
          l !== null && (l.return = null), i.return = null;
        } catch (c) {
          zn(i, e, c);
        }
      }
    if (e.subtreeFlags & 12854)
      for (e = e.child; e !== null; )
        jH(e, t), e = e.sibling;
  }
  function jH(t, e) {
    var n = t.alternate, r = t.flags;
    switch (t.tag) {
      case 0:
      case 11:
      case 14:
      case 15:
        if (ga(e, t), il(t), r & 4) {
          try {
            U0(3, t, t.return), lC(3, t);
          } catch (g) {
            zn(t, t.return, g);
          }
          try {
            U0(5, t, t.return);
          } catch (g) {
            zn(t, t.return, g);
          }
        }
        break;
      case 1:
        ga(e, t), il(t), r & 512 && n !== null && Yp(n, n.return);
        break;
      case 5:
        if (ga(e, t), il(t), r & 512 && n !== null && Yp(n, n.return), t.flags & 32) {
          var i = t.stateNode;
          try {
            kv(i, "");
          } catch (g) {
            zn(t, t.return, g);
          }
        }
        if (r & 4 && (i = t.stateNode, i != null)) {
          var s = t.memoizedProps, o = n !== null ? n.memoizedProps : s, a = t.type, l = t.updateQueue;
          if (t.updateQueue = null, l !== null)
            try {
              a === "input" && s.type === "radio" && s.name != null && sZ(i, s), lA(a, o);
              var c = lA(a, s);
              for (o = 0; o < l.length; o += 2) {
                var u = l[o], d = l[o + 1];
                u === "style" ? uZ(i, d) : u === "dangerouslySetInnerHTML" ? lZ(i, d) : u === "children" ? kv(i, d) : r3(i, u, d, c);
              }
              switch (a) {
                case "input":
                  rA(i, s);
                  break;
                case "textarea":
                  oZ(i, s);
                  break;
                case "select":
                  var h = i._wrapperState.wasMultiple;
                  i._wrapperState.wasMultiple = !!s.multiple;
                  var f = s.value;
                  f != null ? ag(i, !!s.multiple, f, false) : h !== !!s.multiple && (s.defaultValue != null ? ag(i, !!s.multiple, s.defaultValue, true) : ag(i, !!s.multiple, s.multiple ? [] : "", false));
              }
              i[Rv] = s;
            } catch (g) {
              zn(t, t.return, g);
            }
        }
        break;
      case 6:
        if (ga(e, t), il(t), r & 4) {
          if (t.stateNode === null)
            throw Error(Oe(162));
          i = t.stateNode, s = t.memoizedProps;
          try {
            i.nodeValue = s;
          } catch (g) {
            zn(t, t.return, g);
          }
        }
        break;
      case 3:
        if (ga(e, t), il(t), r & 4 && n !== null && n.memoizedState.isDehydrated)
          try {
            Tv(e.containerInfo);
          } catch (g) {
            zn(t, t.return, g);
          }
        break;
      case 4:
        ga(e, t), il(t);
        break;
      case 13:
        ga(e, t), il(t), i = t.child, i.flags & 8192 && (s = i.memoizedState !== null, i.stateNode.isHidden = s, !s || i.alternate !== null && i.alternate.memoizedState !== null || (L3 = Gn())), r & 4 && iz(t);
        break;
      case 22:
        if (u = n !== null && n.memoizedState !== null, t.mode & 1 ? (di = (c = di) || u, ga(e, t), di = c) : ga(e, t), il(t), r & 8192) {
          if (c = t.memoizedState !== null, (t.stateNode.isHidden = c) && !u && t.mode & 1)
            for (De = t, u = t.child; u !== null; ) {
              for (d = De = u; De !== null; ) {
                switch (h = De, f = h.child, h.tag) {
                  case 0:
                  case 11:
                  case 14:
                  case 15:
                    U0(4, h, h.return);
                    break;
                  case 1:
                    Yp(h, h.return);
                    var y = h.stateNode;
                    if (typeof y.componentWillUnmount == "function") {
                      r = h, n = h.return;
                      try {
                        e = r, y.props = e.memoizedProps, y.state = e.memoizedState, y.componentWillUnmount();
                      } catch (g) {
                        zn(r, n, g);
                      }
                    }
                    break;
                  case 5:
                    Yp(h, h.return);
                    break;
                  case 22:
                    if (h.memoizedState !== null) {
                      oz(d);
                      continue;
                    }
                }
                f !== null ? (f.return = h, De = f) : oz(d);
              }
              u = u.sibling;
            }
          e:
            for (u = null, d = t; ; ) {
              if (d.tag === 5) {
                if (u === null) {
                  u = d;
                  try {
                    i = d.stateNode, c ? (s = i.style, typeof s.setProperty == "function" ? s.setProperty("display", "none", "important") : s.display = "none") : (a = d.stateNode, l = d.memoizedProps.style, o = l != null && l.hasOwnProperty("display") ? l.display : null, a.style.display = cZ("display", o));
                  } catch (g) {
                    zn(t, t.return, g);
                  }
                }
              } else if (d.tag === 6) {
                if (u === null)
                  try {
                    d.stateNode.nodeValue = c ? "" : d.memoizedProps;
                  } catch (g) {
                    zn(t, t.return, g);
                  }
              } else if ((d.tag !== 22 && d.tag !== 23 || d.memoizedState === null || d === t) && d.child !== null) {
                d.child.return = d, d = d.child;
                continue;
              }
              if (d === t)
                break e;
              for (; d.sibling === null; ) {
                if (d.return === null || d.return === t)
                  break e;
                u === d && (u = null), d = d.return;
              }
              u === d && (u = null), d.sibling.return = d.return, d = d.sibling;
            }
        }
        break;
      case 19:
        ga(e, t), il(t), r & 4 && iz(t);
        break;
      case 21:
        break;
      default:
        ga(e, t), il(t);
    }
  }
  function il(t) {
    var e = t.flags;
    if (e & 2) {
      try {
        e: {
          for (var n = t.return; n !== null; ) {
            if (DH(n)) {
              var r = n;
              break e;
            }
            n = n.return;
          }
          throw Error(Oe(160));
        }
        switch (r.tag) {
          case 5:
            var i = r.stateNode;
            r.flags & 32 && (kv(i, ""), r.flags &= -33);
            var s = rz(t);
            NA(t, s, i);
            break;
          case 3:
          case 4:
            var o = r.stateNode.containerInfo, a = rz(t);
            jA(t, a, o);
            break;
          default:
            throw Error(Oe(161));
        }
      } catch (l) {
        zn(t, t.return, l);
      }
      t.flags &= -3;
    }
    e & 4096 && (t.flags &= -4097);
  }
  function vSe(t, e, n) {
    De = t, NH(t);
  }
  function NH(t, e, n) {
    for (var r = (t.mode & 1) !== 0; De !== null; ) {
      var i = De, s = i.child;
      if (i.tag === 22 && r) {
        var o = i.memoizedState !== null || tw;
        if (!o) {
          var a = i.alternate, l = a !== null && a.memoizedState !== null || di;
          a = tw;
          var c = di;
          if (tw = o, (di = l) && !c)
            for (De = i; De !== null; )
              o = De, l = o.child, o.tag === 22 && o.memoizedState !== null ? az(i) : l !== null ? (l.return = o, De = l) : az(i);
          for (; s !== null; )
            De = s, NH(s), s = s.sibling;
          De = i, tw = a, di = c;
        }
        sz(t);
      } else
        i.subtreeFlags & 8772 && s !== null ? (s.return = i, De = s) : sz(t);
    }
  }
  function sz(t) {
    for (; De !== null; ) {
      var e = De;
      if (e.flags & 8772) {
        var n = e.alternate;
        try {
          if (e.flags & 8772)
            switch (e.tag) {
              case 0:
              case 11:
              case 15:
                di || lC(5, e);
                break;
              case 1:
                var r = e.stateNode;
                if (e.flags & 4 && !di)
                  if (n === null)
                    r.componentDidMount();
                  else {
                    var i = e.elementType === e.type ? n.memoizedProps : wa(e.type, n.memoizedProps);
                    r.componentDidUpdate(i, n.memoizedState, r.__reactInternalSnapshotBeforeUpdate);
                  }
                var s = e.updateQueue;
                s !== null && U6(e, s, r);
                break;
              case 3:
                var o = e.updateQueue;
                if (o !== null) {
                  if (n = null, e.child !== null)
                    switch (e.child.tag) {
                      case 5:
                        n = e.child.stateNode;
                        break;
                      case 1:
                        n = e.child.stateNode;
                    }
                  U6(e, o, n);
                }
                break;
              case 5:
                var a = e.stateNode;
                if (n === null && e.flags & 4) {
                  n = a;
                  var l = e.memoizedProps;
                  switch (e.type) {
                    case "button":
                    case "input":
                    case "select":
                    case "textarea":
                      l.autoFocus && n.focus();
                      break;
                    case "img":
                      l.src && (n.src = l.src);
                  }
                }
                break;
              case 6:
                break;
              case 4:
                break;
              case 12:
                break;
              case 13:
                if (e.memoizedState === null) {
                  var c = e.alternate;
                  if (c !== null) {
                    var u = c.memoizedState;
                    if (u !== null) {
                      var d = u.dehydrated;
                      d !== null && Tv(d);
                    }
                  }
                }
                break;
              case 19:
              case 17:
              case 21:
              case 22:
              case 23:
              case 25:
                break;
              default:
                throw Error(Oe(163));
            }
          di || e.flags & 512 && LA(e);
        } catch (h) {
          zn(e, e.return, h);
        }
      }
      if (e === t) {
        De = null;
        break;
      }
      if (n = e.sibling, n !== null) {
        n.return = e.return, De = n;
        break;
      }
      De = e.return;
    }
  }
  function oz(t) {
    for (; De !== null; ) {
      var e = De;
      if (e === t) {
        De = null;
        break;
      }
      var n = e.sibling;
      if (n !== null) {
        n.return = e.return, De = n;
        break;
      }
      De = e.return;
    }
  }
  function az(t) {
    for (; De !== null; ) {
      var e = De;
      try {
        switch (e.tag) {
          case 0:
          case 11:
          case 15:
            var n = e.return;
            try {
              lC(4, e);
            } catch (l) {
              zn(e, n, l);
            }
            break;
          case 1:
            var r = e.stateNode;
            if (typeof r.componentDidMount == "function") {
              var i = e.return;
              try {
                r.componentDidMount();
              } catch (l) {
                zn(e, i, l);
              }
            }
            var s = e.return;
            try {
              LA(e);
            } catch (l) {
              zn(e, s, l);
            }
            break;
          case 5:
            var o = e.return;
            try {
              LA(e);
            } catch (l) {
              zn(e, o, l);
            }
        }
      } catch (l) {
        zn(e, e.return, l);
      }
      if (e === t) {
        De = null;
        break;
      }
      var a = e.sibling;
      if (a !== null) {
        a.return = e.return, De = a;
        break;
      }
      De = e.return;
    }
  }
  var OSe = Math.ceil, sk = eu.ReactCurrentDispatcher, M3 = eu.ReactCurrentOwner, Zo = eu.ReactCurrentBatchConfig, Mt = 0, Cr = null, ar = null, Zr = 0, Us = 0, Gp = Dd(0), yr = 0, Qv = null, ef = 0, cC = 0, D3 = 0, V0 = null, ls = null, L3 = 0, Dg = 1 / 0, vc = null, ok = false, QA = null, fd = null, nw = false, Zu = null, ak = 0, X0 = 0, zA = null, Fx = -1, Bx = 0;
  function Bi() {
    return Mt & 6 ? Gn() : Fx !== -1 ? Fx : Fx = Gn();
  }
  function pd(t) {
    return t.mode & 1 ? Mt & 2 && Zr !== 0 ? Zr & -Zr : nSe.transition !== null ? (Bx === 0 && (Bx = xZ()), Bx) : (t = Zt, t !== 0 || (t = window.event, t = t === void 0 ? 16 : EZ(t.type)), t) : 1;
  }
  function La(t, e, n, r) {
    if (50 < X0)
      throw X0 = 0, zA = null, Error(Oe(185));
    UO(t, n, r), (!(Mt & 2) || t !== Cr) && (t === Cr && (!(Mt & 2) && (cC |= n), yr === 4 && zu(t, Zr)), Os(t, r), n === 1 && Mt === 0 && !(e.mode & 1) && (Dg = Gn() + 500, sC && Ld()));
  }
  function Os(t, e) {
    var n = t.callbackNode;
    nOe(t, e);
    var r = Vb(t, t === Cr ? Zr : 0);
    if (r === 0)
      n !== null && m6(n), t.callbackNode = null, t.callbackPriority = 0;
    else if (e = r & -r, t.callbackPriority !== e) {
      if (n != null && m6(n), e === 1)
        t.tag === 0 ? tSe(lz.bind(null, t)) : HZ(lz.bind(null, t)), qOe(function() {
          !(Mt & 6) && Ld();
        }), n = null;
      else {
        switch (bZ(r)) {
          case 1:
            n = l3;
            break;
          case 4:
            n = SZ;
            break;
          case 16:
            n = Ub;
            break;
          case 536870912:
            n = wZ;
            break;
          default:
            n = Ub;
        }
        n = WH(n, QH.bind(null, t));
      }
      t.callbackPriority = e, t.callbackNode = n;
    }
  }
  function QH(t, e) {
    if (Fx = -1, Bx = 0, Mt & 6)
      throw Error(Oe(327));
    var n = t.callbackNode;
    if (hg() && t.callbackNode !== n)
      return null;
    var r = Vb(t, t === Cr ? Zr : 0);
    if (r === 0)
      return null;
    if (r & 30 || r & t.expiredLanes || e)
      e = lk(t, r);
    else {
      e = r;
      var i = Mt;
      Mt |= 2;
      var s = FH();
      (Cr !== t || Zr !== e) && (vc = null, Dg = Gn() + 500, Bh(t, e));
      do
        try {
          xSe();
          break;
        } catch (a) {
          zH(t, a);
        }
      while (1);
      w3(), sk.current = s, Mt = i, ar !== null ? e = 0 : (Cr = null, Zr = 0, e = yr);
    }
    if (e !== 0) {
      if (e === 2 && (i = fA(t), i !== 0 && (r = i, e = FA(t, i))), e === 1)
        throw n = Qv, Bh(t, 0), zu(t, r), Os(t, Gn()), n;
      if (e === 6)
        zu(t, r);
      else {
        if (i = t.current.alternate, !(r & 30) && !SSe(i) && (e = lk(t, r), e === 2 && (s = fA(t), s !== 0 && (r = s, e = FA(t, s))), e === 1))
          throw n = Qv, Bh(t, 0), zu(t, r), Os(t, Gn()), n;
        switch (t.finishedWork = i, t.finishedLanes = r, e) {
          case 0:
          case 1:
            throw Error(Oe(345));
          case 2:
            vh(t, ls, vc);
            break;
          case 3:
            if (zu(t, r), (r & 130023424) === r && (e = L3 + 500 - Gn(), 10 < e)) {
              if (Vb(t, 0) !== 0)
                break;
              if (i = t.suspendedLanes, (i & r) !== r) {
                Bi(), t.pingedLanes |= t.suspendedLanes & i;
                break;
              }
              t.timeoutHandle = wA(vh.bind(null, t, ls, vc), e);
              break;
            }
            vh(t, ls, vc);
            break;
          case 4:
            if (zu(t, r), (r & 4194240) === r)
              break;
            for (e = t.eventTimes, i = -1; 0 < r; ) {
              var o = 31 - Da(r);
              s = 1 << o, o = e[o], o > i && (i = o), r &= ~s;
            }
            if (r = i, r = Gn() - r, r = (120 > r ? 120 : 480 > r ? 480 : 1080 > r ? 1080 : 1920 > r ? 1920 : 3e3 > r ? 3e3 : 4320 > r ? 4320 : 1960 * OSe(r / 1960)) - r, 10 < r) {
              t.timeoutHandle = wA(vh.bind(null, t, ls, vc), r);
              break;
            }
            vh(t, ls, vc);
            break;
          case 5:
            vh(t, ls, vc);
            break;
          default:
            throw Error(Oe(329));
        }
      }
    }
    return Os(t, Gn()), t.callbackNode === n ? QH.bind(null, t) : null;
  }
  function FA(t, e) {
    var n = V0;
    return t.current.memoizedState.isDehydrated && (Bh(t, e).flags |= 256), t = lk(t, e), t !== 2 && (e = ls, ls = n, e !== null && BA(e)), t;
  }
  function BA(t) {
    ls === null ? ls = t : ls.push.apply(ls, t);
  }
  function SSe(t) {
    for (var e = t; ; ) {
      if (e.flags & 16384) {
        var n = e.updateQueue;
        if (n !== null && (n = n.stores, n !== null))
          for (var r = 0; r < n.length; r++) {
            var i = n[r], s = i.getSnapshot;
            i = i.value;
            try {
              if (!Ua(s(), i))
                return false;
            } catch {
              return false;
            }
          }
      }
      if (n = e.child, e.subtreeFlags & 16384 && n !== null)
        n.return = e, e = n;
      else {
        if (e === t)
          break;
        for (; e.sibling === null; ) {
          if (e.return === null || e.return === t)
            return true;
          e = e.return;
        }
        e.sibling.return = e.return, e = e.sibling;
      }
    }
    return true;
  }
  function zu(t, e) {
    for (e &= ~D3, e &= ~cC, t.suspendedLanes |= e, t.pingedLanes &= ~e, t = t.expirationTimes; 0 < e; ) {
      var n = 31 - Da(e), r = 1 << n;
      t[n] = -1, e &= ~r;
    }
  }
  function lz(t) {
    if (Mt & 6)
      throw Error(Oe(327));
    hg();
    var e = Vb(t, 0);
    if (!(e & 1))
      return Os(t, Gn()), null;
    var n = lk(t, e);
    if (t.tag !== 0 && n === 2) {
      var r = fA(t);
      r !== 0 && (e = r, n = FA(t, r));
    }
    if (n === 1)
      throw n = Qv, Bh(t, 0), zu(t, e), Os(t, Gn()), n;
    if (n === 6)
      throw Error(Oe(345));
    return t.finishedWork = t.current.alternate, t.finishedLanes = e, vh(t, ls, vc), Os(t, Gn()), null;
  }
  function j3(t, e) {
    var n = Mt;
    Mt |= 1;
    try {
      return t(e);
    } finally {
      Mt = n, Mt === 0 && (Dg = Gn() + 500, sC && Ld());
    }
  }
  function tf(t) {
    Zu !== null && Zu.tag === 0 && !(Mt & 6) && hg();
    var e = Mt;
    Mt |= 1;
    var n = Zo.transition, r = Zt;
    try {
      if (Zo.transition = null, Zt = 1, t)
        return t();
    } finally {
      Zt = r, Zo.transition = n, Mt = e, !(Mt & 6) && Ld();
    }
  }
  function N3() {
    Us = Gp.current, xn(Gp);
  }
  function Bh(t, e) {
    t.finishedWork = null, t.finishedLanes = 0;
    var n = t.timeoutHandle;
    if (n !== -1 && (t.timeoutHandle = -1, GOe(n)), ar !== null)
      for (n = ar.return; n !== null; ) {
        var r = n;
        switch (v3(r), r.tag) {
          case 1:
            r = r.type.childContextTypes, r != null && Yb();
            break;
          case 3:
            Rg(), xn(ys), xn(bi), _3();
            break;
          case 5:
            C3(r);
            break;
          case 4:
            Rg();
            break;
          case 13:
            xn(An);
            break;
          case 19:
            xn(An);
            break;
          case 10:
            x3(r.type._context);
            break;
          case 22:
          case 23:
            N3();
        }
        n = n.return;
      }
    if (Cr = t, ar = t = gd(t.current, null), Zr = Us = e, yr = 0, Qv = null, D3 = cC = ef = 0, ls = V0 = null, Ih !== null) {
      for (e = 0; e < Ih.length; e++)
        if (n = Ih[e], r = n.interleaved, r !== null) {
          n.interleaved = null;
          var i = r.next, s = n.pending;
          if (s !== null) {
            var o = s.next;
            s.next = i, r.next = o;
          }
          n.pending = r;
        }
      Ih = null;
    }
    return t;
  }
  function zH(t, e) {
    do {
      var n = ar;
      try {
        if (w3(), Nx.current = ik, rk) {
          for (var r = Dn.memoizedState; r !== null; ) {
            var i = r.queue;
            i !== null && (i.pending = null), r = r.next;
          }
          rk = false;
        }
        if (Jh = 0, br = gr = Dn = null, B0 = false, Lv = 0, M3.current = null, n === null || n.return === null) {
          yr = 1, Qv = e, ar = null;
          break;
        }
        e: {
          var s = t, o = n.return, a = n, l = e;
          if (e = Zr, a.flags |= 32768, l !== null && typeof l == "object" && typeof l.then == "function") {
            var c = l, u = a, d = u.tag;
            if (!(u.mode & 1) && (d === 0 || d === 11 || d === 15)) {
              var h = u.alternate;
              h ? (u.updateQueue = h.updateQueue, u.memoizedState = h.memoizedState, u.lanes = h.lanes) : (u.updateQueue = null, u.memoizedState = null);
            }
            var f = Y6(o);
            if (f !== null) {
              f.flags &= -257, G6(f, o, a, s, e), f.mode & 1 && H6(s, c, e), e = f, l = c;
              var y = e.updateQueue;
              if (y === null) {
                var g = /* @__PURE__ */ new Set();
                g.add(l), e.updateQueue = g;
              } else
                y.add(l);
              break e;
            } else {
              if (!(e & 1)) {
                H6(s, c, e), Q3();
                break e;
              }
              l = Error(Oe(426));
            }
          } else if (En && a.mode & 1) {
            var O = Y6(o);
            if (O !== null) {
              !(O.flags & 65536) && (O.flags |= 256), G6(O, o, a, s, e), O3(Mg(l, a));
              break e;
            }
          }
          s = l = Mg(l, a), yr !== 4 && (yr = 2), V0 === null ? V0 = [
            s
          ] : V0.push(s), s = o;
          do {
            switch (s.tag) {
              case 3:
                s.flags |= 65536, e &= -e, s.lanes |= e;
                var S = bH(s, l, e);
                B6(s, S);
                break e;
              case 1:
                a = l;
                var w = s.type, x = s.stateNode;
                if (!(s.flags & 128) && (typeof w.getDerivedStateFromError == "function" || x !== null && typeof x.componentDidCatch == "function" && (fd === null || !fd.has(x)))) {
                  s.flags |= 65536, e &= -e, s.lanes |= e;
                  var P = kH(s, a, e);
                  B6(s, P);
                  break e;
                }
            }
            s = s.return;
          } while (s !== null);
        }
        UH(n);
      } catch (C) {
        e = C, ar === n && n !== null && (ar = n = n.return);
        continue;
      }
      break;
    } while (1);
  }
  function FH() {
    var t = sk.current;
    return sk.current = ik, t === null ? ik : t;
  }
  function Q3() {
    (yr === 0 || yr === 3 || yr === 2) && (yr = 4), Cr === null || !(ef & 268435455) && !(cC & 268435455) || zu(Cr, Zr);
  }
  function lk(t, e) {
    var n = Mt;
    Mt |= 2;
    var r = FH();
    (Cr !== t || Zr !== e) && (vc = null, Bh(t, e));
    do
      try {
        wSe();
        break;
      } catch (i) {
        zH(t, i);
      }
    while (1);
    if (w3(), Mt = n, sk.current = r, ar !== null)
      throw Error(Oe(261));
    return Cr = null, Zr = 0, yr;
  }
  function wSe() {
    for (; ar !== null; )
      BH(ar);
  }
  function xSe() {
    for (; ar !== null && !Zve(); )
      BH(ar);
  }
  function BH(t) {
    var e = XH(t.alternate, t, Us);
    t.memoizedProps = t.pendingProps, e === null ? UH(t) : ar = e, M3.current = null;
  }
  function UH(t) {
    var e = t;
    do {
      var n = e.alternate;
      if (t = e.return, e.flags & 32768) {
        if (n = gSe(n, e), n !== null) {
          n.flags &= 32767, ar = n;
          return;
        }
        if (t !== null)
          t.flags |= 32768, t.subtreeFlags = 0, t.deletions = null;
        else {
          yr = 6, ar = null;
          return;
        }
      } else if (n = pSe(n, e, Us), n !== null) {
        ar = n;
        return;
      }
      if (e = e.sibling, e !== null) {
        ar = e;
        return;
      }
      ar = e = t;
    } while (e !== null);
    yr === 0 && (yr = 5);
  }
  function vh(t, e, n) {
    var r = Zt, i = Zo.transition;
    try {
      Zo.transition = null, Zt = 1, bSe(t, e, n, r);
    } finally {
      Zo.transition = i, Zt = r;
    }
    return null;
  }
  function bSe(t, e, n, r) {
    do
      hg();
    while (Zu !== null);
    if (Mt & 6)
      throw Error(Oe(327));
    n = t.finishedWork;
    var i = t.finishedLanes;
    if (n === null)
      return null;
    if (t.finishedWork = null, t.finishedLanes = 0, n === t.current)
      throw Error(Oe(177));
    t.callbackNode = null, t.callbackPriority = 0;
    var s = n.lanes | n.childLanes;
    if (rOe(t, s), t === Cr && (ar = Cr = null, Zr = 0), !(n.subtreeFlags & 2064) && !(n.flags & 2064) || nw || (nw = true, WH(Ub, function() {
      return hg(), null;
    })), s = (n.flags & 15990) !== 0, n.subtreeFlags & 15990 || s) {
      s = Zo.transition, Zo.transition = null;
      var o = Zt;
      Zt = 1;
      var a = Mt;
      Mt |= 4, M3.current = null, ySe(t, n), jH(n, t), UOe(OA), Xb = !!vA, OA = vA = null, t.current = n, vSe(n), Hve(), Mt = a, Zt = o, Zo.transition = s;
    } else
      t.current = n;
    if (nw && (nw = false, Zu = t, ak = i), s = t.pendingLanes, s === 0 && (fd = null), qve(n.stateNode), Os(t, Gn()), e !== null)
      for (r = t.onRecoverableError, n = 0; n < e.length; n++)
        i = e[n], r(i.value, {
          componentStack: i.stack,
          digest: i.digest
        });
    if (ok)
      throw ok = false, t = QA, QA = null, t;
    return ak & 1 && t.tag !== 0 && hg(), s = t.pendingLanes, s & 1 ? t === zA ? X0++ : (X0 = 0, zA = t) : X0 = 0, Ld(), null;
  }
  function hg() {
    if (Zu !== null) {
      var t = bZ(ak), e = Zo.transition, n = Zt;
      try {
        if (Zo.transition = null, Zt = 16 > t ? 16 : t, Zu === null)
          var r = false;
        else {
          if (t = Zu, Zu = null, ak = 0, Mt & 6)
            throw Error(Oe(331));
          var i = Mt;
          for (Mt |= 4, De = t.current; De !== null; ) {
            var s = De, o = s.child;
            if (De.flags & 16) {
              var a = s.deletions;
              if (a !== null) {
                for (var l = 0; l < a.length; l++) {
                  var c = a[l];
                  for (De = c; De !== null; ) {
                    var u = De;
                    switch (u.tag) {
                      case 0:
                      case 11:
                      case 15:
                        U0(8, u, s);
                    }
                    var d = u.child;
                    if (d !== null)
                      d.return = u, De = d;
                    else
                      for (; De !== null; ) {
                        u = De;
                        var h = u.sibling, f = u.return;
                        if (MH(u), u === c) {
                          De = null;
                          break;
                        }
                        if (h !== null) {
                          h.return = f, De = h;
                          break;
                        }
                        De = f;
                      }
                  }
                }
                var y = s.alternate;
                if (y !== null) {
                  var g = y.child;
                  if (g !== null) {
                    y.child = null;
                    do {
                      var O = g.sibling;
                      g.sibling = null, g = O;
                    } while (g !== null);
                  }
                }
                De = s;
              }
            }
            if (s.subtreeFlags & 2064 && o !== null)
              o.return = s, De = o;
            else
              e:
                for (; De !== null; ) {
                  if (s = De, s.flags & 2048)
                    switch (s.tag) {
                      case 0:
                      case 11:
                      case 15:
                        U0(9, s, s.return);
                    }
                  var S = s.sibling;
                  if (S !== null) {
                    S.return = s.return, De = S;
                    break e;
                  }
                  De = s.return;
                }
          }
          var w = t.current;
          for (De = w; De !== null; ) {
            o = De;
            var x = o.child;
            if (o.subtreeFlags & 2064 && x !== null)
              x.return = o, De = x;
            else
              e:
                for (o = w; De !== null; ) {
                  if (a = De, a.flags & 2048)
                    try {
                      switch (a.tag) {
                        case 0:
                        case 11:
                        case 15:
                          lC(9, a);
                      }
                    } catch (C) {
                      zn(a, a.return, C);
                    }
                  if (a === o) {
                    De = null;
                    break e;
                  }
                  var P = a.sibling;
                  if (P !== null) {
                    P.return = a.return, De = P;
                    break e;
                  }
                  De = a.return;
                }
          }
          if (Mt = i, Ld(), Il && typeof Il.onPostCommitFiberRoot == "function")
            try {
              Il.onPostCommitFiberRoot(eC, t);
            } catch {
            }
          r = true;
        }
        return r;
      } finally {
        Zt = n, Zo.transition = e;
      }
    }
    return false;
  }
  function cz(t, e, n) {
    e = Mg(n, e), e = bH(t, e, 1), t = hd(t, e, 1), e = Bi(), t !== null && (UO(t, 1, e), Os(t, e));
  }
  function zn(t, e, n) {
    if (t.tag === 3)
      cz(t, t, n);
    else
      for (; e !== null; ) {
        if (e.tag === 3) {
          cz(e, t, n);
          break;
        } else if (e.tag === 1) {
          var r = e.stateNode;
          if (typeof e.type.getDerivedStateFromError == "function" || typeof r.componentDidCatch == "function" && (fd === null || !fd.has(r))) {
            t = Mg(n, t), t = kH(e, t, 1), e = hd(e, t, 1), t = Bi(), e !== null && (UO(e, 1, t), Os(e, t));
            break;
          }
        }
        e = e.return;
      }
  }
  function kSe(t, e, n) {
    var r = t.pingCache;
    r !== null && r.delete(e), e = Bi(), t.pingedLanes |= t.suspendedLanes & n, Cr === t && (Zr & n) === n && (yr === 4 || yr === 3 && (Zr & 130023424) === Zr && 500 > Gn() - L3 ? Bh(t, 0) : D3 |= n), Os(t, e);
  }
  function VH(t, e) {
    e === 0 && (t.mode & 1 ? (e = W1, W1 <<= 1, !(W1 & 130023424) && (W1 = 4194304)) : e = 1);
    var n = Bi();
    t = Xc(t, e), t !== null && (UO(t, e, n), Os(t, n));
  }
  function PSe(t) {
    var e = t.memoizedState, n = 0;
    e !== null && (n = e.retryLane), VH(t, n);
  }
  function CSe(t, e) {
    var n = 0;
    switch (t.tag) {
      case 13:
        var r = t.stateNode, i = t.memoizedState;
        i !== null && (n = i.retryLane);
        break;
      case 19:
        r = t.stateNode;
        break;
      default:
        throw Error(Oe(314));
    }
    r !== null && r.delete(e), VH(t, n);
  }
  var XH;
  XH = function(t, e, n) {
    if (t !== null)
      if (t.memoizedProps !== e.pendingProps || ys.current)
        hs = true;
      else {
        if (!(t.lanes & n) && !(e.flags & 128))
          return hs = false, fSe(t, e, n);
        hs = !!(t.flags & 131072);
      }
    else
      hs = false, En && e.flags & 1048576 && YZ(e, Kb, e.index);
    switch (e.lanes = 0, e.tag) {
      case 2:
        var r = e.type;
        zx(t, e), t = e.pendingProps;
        var i = Ig(e, bi.current);
        dg(e, n), i = E3(null, e, r, t, i, n);
        var s = I3();
        return e.flags |= 1, typeof i == "object" && i !== null && typeof i.render == "function" && i.$$typeof === void 0 ? (e.tag = 1, e.memoizedState = null, e.updateQueue = null, vs(r) ? (s = true, Gb(e)) : s = false, e.memoizedState = i.state !== null && i.state !== void 0 ? i.state : null, k3(e), i.updater = aC, e.stateNode = i, i._reactInternals = e, TA(e, r, t, n), e = $A(null, e, r, true, s, n)) : (e.tag = 0, En && s && y3(e), Qi(null, e, i, n), e = e.child), e;
      case 16:
        r = e.elementType;
        e: {
          switch (zx(t, e), t = e.pendingProps, i = r._init, r = i(r._payload), e.type = r, i = e.tag = TSe(r), t = wa(r, t), i) {
            case 0:
              e = IA(null, e, r, t, n);
              break e;
            case 1:
              e = J6(null, e, r, t, n);
              break e;
            case 11:
              e = q6(null, e, r, t, n);
              break e;
            case 14:
              e = K6(null, e, r, wa(r.type, t), n);
              break e;
          }
          throw Error(Oe(306, r, ""));
        }
        return e;
      case 0:
        return r = e.type, i = e.pendingProps, i = e.elementType === r ? i : wa(r, i), IA(t, e, r, i, n);
      case 1:
        return r = e.type, i = e.pendingProps, i = e.elementType === r ? i : wa(r, i), J6(t, e, r, i, n);
      case 3:
        e: {
          if (TH(e), t === null)
            throw Error(Oe(387));
          r = e.pendingProps, s = e.memoizedState, i = s.element, tH(t, e), tk(e, r, null, n);
          var o = e.memoizedState;
          if (r = o.element, s.isDehydrated)
            if (s = {
              element: r,
              isDehydrated: false,
              cache: o.cache,
              pendingSuspenseBoundaries: o.pendingSuspenseBoundaries,
              transitions: o.transitions
            }, e.updateQueue.baseState = s, e.memoizedState = s, e.flags & 256) {
              i = Mg(Error(Oe(423)), e), e = ez(t, e, r, n, i);
              break e;
            } else if (r !== i) {
              i = Mg(Error(Oe(424)), e), e = ez(t, e, r, n, i);
              break e;
            } else
              for (to = dd(e.stateNode.containerInfo.firstChild), ro = e, En = true, Pa = null, n = JZ(e, null, r, n), e.child = n; n; )
                n.flags = n.flags & -3 | 4096, n = n.sibling;
          else {
            if ($g(), r === i) {
              e = Wc(t, e, n);
              break e;
            }
            Qi(t, e, r, n);
          }
          e = e.child;
        }
        return e;
      case 5:
        return nH(e), t === null && PA(e), r = e.type, i = e.pendingProps, s = t !== null ? t.memoizedProps : null, o = i.children, SA(r, i) ? o = null : s !== null && SA(r, s) && (e.flags |= 32), _H(t, e), Qi(t, e, o, n), e.child;
      case 6:
        return t === null && PA(e), null;
      case 13:
        return EH(t, e, n);
      case 4:
        return P3(e, e.stateNode.containerInfo), r = e.pendingProps, t === null ? e.child = Ag(e, null, r, n) : Qi(t, e, r, n), e.child;
      case 11:
        return r = e.type, i = e.pendingProps, i = e.elementType === r ? i : wa(r, i), q6(t, e, r, i, n);
      case 7:
        return Qi(t, e, e.pendingProps, n), e.child;
      case 8:
        return Qi(t, e, e.pendingProps.children, n), e.child;
      case 12:
        return Qi(t, e, e.pendingProps.children, n), e.child;
      case 10:
        e: {
          if (r = e.type._context, i = e.pendingProps, s = e.memoizedProps, o = i.value, hn(Jb, r._currentValue), r._currentValue = o, s !== null)
            if (Ua(s.value, o)) {
              if (s.children === i.children && !ys.current) {
                e = Wc(t, e, n);
                break e;
              }
            } else
              for (s = e.child, s !== null && (s.return = e); s !== null; ) {
                var a = s.dependencies;
                if (a !== null) {
                  o = s.child;
                  for (var l = a.firstContext; l !== null; ) {
                    if (l.context === r) {
                      if (s.tag === 1) {
                        l = Ac(-1, n & -n), l.tag = 2;
                        var c = s.updateQueue;
                        if (c !== null) {
                          c = c.shared;
                          var u = c.pending;
                          u === null ? l.next = l : (l.next = u.next, u.next = l), c.pending = l;
                        }
                      }
                      s.lanes |= n, l = s.alternate, l !== null && (l.lanes |= n), CA(s.return, n, e), a.lanes |= n;
                      break;
                    }
                    l = l.next;
                  }
                } else if (s.tag === 10)
                  o = s.type === e.type ? null : s.child;
                else if (s.tag === 18) {
                  if (o = s.return, o === null)
                    throw Error(Oe(341));
                  o.lanes |= n, a = o.alternate, a !== null && (a.lanes |= n), CA(o, n, e), o = s.sibling;
                } else
                  o = s.child;
                if (o !== null)
                  o.return = s;
                else
                  for (o = s; o !== null; ) {
                    if (o === e) {
                      o = null;
                      break;
                    }
                    if (s = o.sibling, s !== null) {
                      s.return = o.return, o = s;
                      break;
                    }
                    o = o.return;
                  }
                s = o;
              }
          Qi(t, e, i.children, n), e = e.child;
        }
        return e;
      case 9:
        return i = e.type, r = e.pendingProps.children, dg(e, n), i = Jo(i), r = r(i), e.flags |= 1, Qi(t, e, r, n), e.child;
      case 14:
        return r = e.type, i = wa(r, e.pendingProps), i = wa(r.type, i), K6(t, e, r, i, n);
      case 15:
        return PH(t, e, e.type, e.pendingProps, n);
      case 17:
        return r = e.type, i = e.pendingProps, i = e.elementType === r ? i : wa(r, i), zx(t, e), e.tag = 1, vs(r) ? (t = true, Gb(e)) : t = false, dg(e, n), xH(e, r, i), TA(e, r, i, n), $A(null, e, r, true, t, n);
      case 19:
        return IH(t, e, n);
      case 22:
        return CH(t, e, n);
    }
    throw Error(Oe(156, e.tag));
  };
  function WH(t, e) {
    return OZ(t, e);
  }
  function _Se(t, e, n, r) {
    this.tag = t, this.key = n, this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null, this.index = 0, this.ref = null, this.pendingProps = e, this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null, this.mode = r, this.subtreeFlags = this.flags = 0, this.deletions = null, this.childLanes = this.lanes = 0, this.alternate = null;
  }
  function Uo(t, e, n, r) {
    return new _Se(t, e, n, r);
  }
  function z3(t) {
    return t = t.prototype, !(!t || !t.isReactComponent);
  }
  function TSe(t) {
    if (typeof t == "function")
      return z3(t) ? 1 : 0;
    if (t != null) {
      if (t = t.$$typeof, t === s3)
        return 11;
      if (t === o3)
        return 14;
    }
    return 2;
  }
  function gd(t, e) {
    var n = t.alternate;
    return n === null ? (n = Uo(t.tag, e, t.key, t.mode), n.elementType = t.elementType, n.type = t.type, n.stateNode = t.stateNode, n.alternate = t, t.alternate = n) : (n.pendingProps = e, n.type = t.type, n.flags = 0, n.subtreeFlags = 0, n.deletions = null), n.flags = t.flags & 14680064, n.childLanes = t.childLanes, n.lanes = t.lanes, n.child = t.child, n.memoizedProps = t.memoizedProps, n.memoizedState = t.memoizedState, n.updateQueue = t.updateQueue, e = t.dependencies, n.dependencies = e === null ? null : {
      lanes: e.lanes,
      firstContext: e.firstContext
    }, n.sibling = t.sibling, n.index = t.index, n.ref = t.ref, n;
  }
  function Ux(t, e, n, r, i, s) {
    var o = 2;
    if (r = t, typeof t == "function")
      z3(t) && (o = 1);
    else if (typeof t == "string")
      o = 5;
    else
      e:
        switch (t) {
          case zp:
            return Uh(n.children, i, s, e);
          case i3:
            o = 8, i |= 8;
            break;
          case K$:
            return t = Uo(12, n, e, i | 2), t.elementType = K$, t.lanes = s, t;
          case J$:
            return t = Uo(13, n, e, i), t.elementType = J$, t.lanes = s, t;
          case eA:
            return t = Uo(19, n, e, i), t.elementType = eA, t.lanes = s, t;
          case nZ:
            return uC(n, i, s, e);
          default:
            if (typeof t == "object" && t !== null)
              switch (t.$$typeof) {
                case eZ:
                  o = 10;
                  break e;
                case tZ:
                  o = 9;
                  break e;
                case s3:
                  o = 11;
                  break e;
                case o3:
                  o = 14;
                  break e;
                case Ru:
                  o = 16, r = null;
                  break e;
              }
            throw Error(Oe(130, t == null ? t : typeof t, ""));
        }
    return e = Uo(o, n, e, i), e.elementType = t, e.type = r, e.lanes = s, e;
  }
  function Uh(t, e, n, r) {
    return t = Uo(7, t, r, e), t.lanes = n, t;
  }
  function uC(t, e, n, r) {
    return t = Uo(22, t, r, e), t.elementType = nZ, t.lanes = n, t.stateNode = {
      isHidden: false
    }, t;
  }
  function iE(t, e, n) {
    return t = Uo(6, t, null, e), t.lanes = n, t;
  }
  function sE(t, e, n) {
    return e = Uo(4, t.children !== null ? t.children : [], t.key, e), e.lanes = n, e.stateNode = {
      containerInfo: t.containerInfo,
      pendingChildren: null,
      implementation: t.implementation
    }, e;
  }
  function ESe(t, e, n, r, i) {
    this.tag = e, this.containerInfo = t, this.finishedWork = this.pingCache = this.current = this.pendingChildren = null, this.timeoutHandle = -1, this.callbackNode = this.pendingContext = this.context = null, this.callbackPriority = 0, this.eventTimes = QT(0), this.expirationTimes = QT(-1), this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0, this.entanglements = QT(0), this.identifierPrefix = r, this.onRecoverableError = i, this.mutableSourceEagerHydrationData = null;
  }
  function F3(t, e, n, r, i, s, o, a, l) {
    return t = new ESe(t, e, n, a, l), e === 1 ? (e = 1, s === true && (e |= 8)) : e = 0, s = Uo(3, null, null, e), t.current = s, s.stateNode = t, s.memoizedState = {
      element: r,
      isDehydrated: n,
      cache: null,
      transitions: null,
      pendingSuspenseBoundaries: null
    }, k3(s), t;
  }
  function ISe(t, e, n) {
    var r = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
    return {
      $$typeof: Qp,
      key: r == null ? null : "" + r,
      children: t,
      containerInfo: e,
      implementation: n
    };
  }
  function ZH(t) {
    if (!t)
      return Sd;
    t = t._reactInternals;
    e: {
      if (yf(t) !== t || t.tag !== 1)
        throw Error(Oe(170));
      var e = t;
      do {
        switch (e.tag) {
          case 3:
            e = e.stateNode.context;
            break e;
          case 1:
            if (vs(e.type)) {
              e = e.stateNode.__reactInternalMemoizedMergedChildContext;
              break e;
            }
        }
        e = e.return;
      } while (e !== null);
      throw Error(Oe(171));
    }
    if (t.tag === 1) {
      var n = t.type;
      if (vs(n))
        return ZZ(t, n, e);
    }
    return e;
  }
  function HH(t, e, n, r, i, s, o, a, l) {
    return t = F3(n, r, true, t, i, s, o, a, l), t.context = ZH(null), n = t.current, r = Bi(), i = pd(n), s = Ac(r, i), s.callback = e ?? null, hd(n, s, i), t.current.lanes = i, UO(t, i, r), Os(t, r), t;
  }
  function dC(t, e, n, r) {
    var i = e.current, s = Bi(), o = pd(i);
    return n = ZH(n), e.context === null ? e.context = n : e.pendingContext = n, e = Ac(s, o), e.payload = {
      element: t
    }, r = r === void 0 ? null : r, r !== null && (e.callback = r), t = hd(i, e, o), t !== null && (La(t, i, o, s), jx(t, i, o)), o;
  }
  function ck(t) {
    if (t = t.current, !t.child)
      return null;
    switch (t.child.tag) {
      case 5:
        return t.child.stateNode;
      default:
        return t.child.stateNode;
    }
  }
  function uz(t, e) {
    if (t = t.memoizedState, t !== null && t.dehydrated !== null) {
      var n = t.retryLane;
      t.retryLane = n !== 0 && n < e ? n : e;
    }
  }
  function B3(t, e) {
    uz(t, e), (t = t.alternate) && uz(t, e);
  }
  function $Se() {
    return null;
  }
  var YH = typeof reportError == "function" ? reportError : function(t) {
    console.error(t);
  };
  function U3(t) {
    this._internalRoot = t;
  }
  hC.prototype.render = U3.prototype.render = function(t) {
    var e = this._internalRoot;
    if (e === null)
      throw Error(Oe(409));
    dC(t, e, null, null);
  };
  hC.prototype.unmount = U3.prototype.unmount = function() {
    var t = this._internalRoot;
    if (t !== null) {
      this._internalRoot = null;
      var e = t.containerInfo;
      tf(function() {
        dC(null, t, null, null);
      }), e[Vc] = null;
    }
  };
  function hC(t) {
    this._internalRoot = t;
  }
  hC.prototype.unstable_scheduleHydration = function(t) {
    if (t) {
      var e = CZ();
      t = {
        blockedOn: null,
        target: t,
        priority: e
      };
      for (var n = 0; n < Qu.length && e !== 0 && e < Qu[n].priority; n++)
        ;
      Qu.splice(n, 0, t), n === 0 && TZ(t);
    }
  };
  function V3(t) {
    return !(!t || t.nodeType !== 1 && t.nodeType !== 9 && t.nodeType !== 11);
  }
  function fC(t) {
    return !(!t || t.nodeType !== 1 && t.nodeType !== 9 && t.nodeType !== 11 && (t.nodeType !== 8 || t.nodeValue !== " react-mount-point-unstable "));
  }
  function dz() {
  }
  function ASe(t, e, n, r, i) {
    if (i) {
      if (typeof r == "function") {
        var s = r;
        r = function() {
          var c = ck(o);
          s.call(c);
        };
      }
      var o = HH(e, r, t, 0, null, false, false, "", dz);
      return t._reactRootContainer = o, t[Vc] = o.current, $v(t.nodeType === 8 ? t.parentNode : t), tf(), o;
    }
    for (; i = t.lastChild; )
      t.removeChild(i);
    if (typeof r == "function") {
      var a = r;
      r = function() {
        var c = ck(l);
        a.call(c);
      };
    }
    var l = F3(t, 0, false, null, null, false, false, "", dz);
    return t._reactRootContainer = l, t[Vc] = l.current, $v(t.nodeType === 8 ? t.parentNode : t), tf(function() {
      dC(e, l, n, r);
    }), l;
  }
  function pC(t, e, n, r, i) {
    var s = n._reactRootContainer;
    if (s) {
      var o = s;
      if (typeof i == "function") {
        var a = i;
        i = function() {
          var l = ck(o);
          a.call(l);
        };
      }
      dC(e, o, t, i);
    } else
      o = ASe(n, e, t, i, r);
    return ck(o);
  }
  kZ = function(t) {
    switch (t.tag) {
      case 3:
        var e = t.stateNode;
        if (e.current.memoizedState.isDehydrated) {
          var n = g0(e.pendingLanes);
          n !== 0 && (c3(e, n | 1), Os(e, Gn()), !(Mt & 6) && (Dg = Gn() + 500, Ld()));
        }
        break;
      case 13:
        tf(function() {
          var r = Xc(t, 1);
          if (r !== null) {
            var i = Bi();
            La(r, t, 1, i);
          }
        }), B3(t, 1);
    }
  };
  u3 = function(t) {
    if (t.tag === 13) {
      var e = Xc(t, 134217728);
      if (e !== null) {
        var n = Bi();
        La(e, t, 134217728, n);
      }
      B3(t, 134217728);
    }
  };
  PZ = function(t) {
    if (t.tag === 13) {
      var e = pd(t), n = Xc(t, e);
      if (n !== null) {
        var r = Bi();
        La(n, t, e, r);
      }
      B3(t, e);
    }
  };
  CZ = function() {
    return Zt;
  };
  _Z = function(t, e) {
    var n = Zt;
    try {
      return Zt = t, e();
    } finally {
      Zt = n;
    }
  };
  uA = function(t, e, n) {
    switch (e) {
      case "input":
        if (rA(t, n), e = n.name, n.type === "radio" && e != null) {
          for (n = t; n.parentNode; )
            n = n.parentNode;
          for (n = n.querySelectorAll("input[name=" + JSON.stringify("" + e) + '][type="radio"]'), e = 0; e < n.length; e++) {
            var r = n[e];
            if (r !== t && r.form === t.form) {
              var i = iC(r);
              if (!i)
                throw Error(Oe(90));
              iZ(r), rA(r, i);
            }
          }
        }
        break;
      case "textarea":
        oZ(t, n);
        break;
      case "select":
        e = n.value, e != null && ag(t, !!n.multiple, e, false);
    }
  };
  fZ = j3;
  pZ = tf;
  var RSe = {
    usingClientEntryPoint: false,
    Events: [
      XO,
      Vp,
      iC,
      dZ,
      hZ,
      j3
    ]
  }, Ay = {
    findFiberByHostInstance: Eh,
    bundleType: 0,
    version: "18.3.1",
    rendererPackageName: "react-dom"
  }, MSe = {
    bundleType: Ay.bundleType,
    version: Ay.version,
    rendererPackageName: Ay.rendererPackageName,
    rendererConfig: Ay.rendererConfig,
    overrideHookState: null,
    overrideHookStateDeletePath: null,
    overrideHookStateRenamePath: null,
    overrideProps: null,
    overridePropsDeletePath: null,
    overridePropsRenamePath: null,
    setErrorHandler: null,
    setSuspenseHandler: null,
    scheduleUpdate: null,
    currentDispatcherRef: eu.ReactCurrentDispatcher,
    findHostInstanceByFiber: function(t) {
      return t = yZ(t), t === null ? null : t.stateNode;
    },
    findFiberByHostInstance: Ay.findFiberByHostInstance || $Se,
    findHostInstancesForRefresh: null,
    scheduleRefresh: null,
    scheduleRoot: null,
    setRefreshHandler: null,
    getCurrentFiber: null,
    reconcilerVersion: "18.3.1-next-f1338f8080-20240426"
  };
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u") {
    var rw = __REACT_DEVTOOLS_GLOBAL_HOOK__;
    if (!rw.isDisabled && rw.supportsFiber)
      try {
        eC = rw.inject(MSe), Il = rw;
      } catch {
      }
  }
  lo.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = RSe;
  lo.createPortal = function(t, e) {
    var n = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null;
    if (!V3(e))
      throw Error(Oe(200));
    return ISe(t, e, null, n);
  };
  lo.createRoot = function(t, e) {
    if (!V3(t))
      throw Error(Oe(299));
    var n = false, r = "", i = YH;
    return e != null && (e.unstable_strictMode === true && (n = true), e.identifierPrefix !== void 0 && (r = e.identifierPrefix), e.onRecoverableError !== void 0 && (i = e.onRecoverableError)), e = F3(t, 1, false, null, null, n, false, r, i), t[Vc] = e.current, $v(t.nodeType === 8 ? t.parentNode : t), new U3(e);
  };
  lo.findDOMNode = function(t) {
    if (t == null)
      return null;
    if (t.nodeType === 1)
      return t;
    var e = t._reactInternals;
    if (e === void 0)
      throw typeof t.render == "function" ? Error(Oe(188)) : (t = Object.keys(t).join(","), Error(Oe(268, t)));
    return t = yZ(e), t = t === null ? null : t.stateNode, t;
  };
  lo.flushSync = function(t) {
    return tf(t);
  };
  lo.hydrate = function(t, e, n) {
    if (!fC(e))
      throw Error(Oe(200));
    return pC(null, t, e, true, n);
  };
  lo.hydrateRoot = function(t, e, n) {
    if (!V3(t))
      throw Error(Oe(405));
    var r = n != null && n.hydratedSources || null, i = false, s = "", o = YH;
    if (n != null && (n.unstable_strictMode === true && (i = true), n.identifierPrefix !== void 0 && (s = n.identifierPrefix), n.onRecoverableError !== void 0 && (o = n.onRecoverableError)), e = HH(e, null, t, 1, n ?? null, i, false, s, o), t[Vc] = e.current, $v(t), r)
      for (t = 0; t < r.length; t++)
        n = r[t], i = n._getVersion, i = i(n._source), e.mutableSourceEagerHydrationData == null ? e.mutableSourceEagerHydrationData = [
          n,
          i
        ] : e.mutableSourceEagerHydrationData.push(n, i);
    return new hC(e);
  };
  lo.render = function(t, e, n) {
    if (!fC(e))
      throw Error(Oe(200));
    return pC(null, t, e, false, n);
  };
  lo.unmountComponentAtNode = function(t) {
    if (!fC(t))
      throw Error(Oe(40));
    return t._reactRootContainer ? (tf(function() {
      pC(null, null, t, false, function() {
        t._reactRootContainer = null, t[Vc] = null;
      });
    }), true) : false;
  };
  lo.unstable_batchedUpdates = j3;
  lo.unstable_renderSubtreeIntoContainer = function(t, e, n, r) {
    if (!fC(n))
      throw Error(Oe(200));
    if (t == null || t._reactInternals === void 0)
      throw Error(Oe(38));
    return pC(t, e, n, false, r);
  };
  lo.version = "18.3.1-next-f1338f8080-20240426";
  function GH() {
    if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ > "u" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function"))
      try {
        __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(GH);
      } catch (t) {
        console.error(t);
      }
  }
  GH(), GW.exports = lo;
  var jd = GW.exports;
  const qH = Rd(jd);
  var hz = jd;
  G$.createRoot = hz.createRoot, G$.hydrateRoot = hz.hydrateRoot;
  var KH = {
    exports: {}
  }, gC = {};
  var DSe = b, LSe = Symbol.for("react.element"), jSe = Symbol.for("react.fragment"), NSe = Object.prototype.hasOwnProperty, QSe = DSe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, zSe = {
    key: true,
    ref: true,
    __self: true,
    __source: true
  };
  function JH(t, e, n) {
    var r, i = {}, s = null, o = null;
    n !== void 0 && (s = "" + n), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (o = e.ref);
    for (r in e)
      NSe.call(e, r) && !zSe.hasOwnProperty(r) && (i[r] = e[r]);
    if (t && t.defaultProps)
      for (r in e = t.defaultProps, e)
        i[r] === void 0 && (i[r] = e[r]);
    return {
      $$typeof: LSe,
      type: t,
      key: s,
      ref: o,
      props: i,
      _owner: QSe.current
    };
  }
  gC.Fragment = jSe;
  gC.jsx = JH;
  gC.jsxs = JH;
  KH.exports = gC;
  var m = KH.exports;
  function fz(t, e) {
    if (typeof t == "function")
      return t(e);
    t != null && (t.current = e);
  }
  function mC(...t) {
    return (e) => {
      let n = false;
      const r = t.map((i) => {
        const s = fz(i, e);
        return !n && typeof s == "function" && (n = true), s;
      });
      if (n)
        return () => {
          for (let i = 0; i < r.length; i++) {
            const s = r[i];
            typeof s == "function" ? s() : fz(t[i], null);
          }
        };
    };
  }
  function Ht(...t) {
    return b.useCallback(mC(...t), t);
  }
  function nf(t) {
    const e = BSe(t), n = b.forwardRef((r, i) => {
      const { children: s, ...o } = r, a = b.Children.toArray(s), l = a.find(VSe);
      if (l) {
        const c = l.props.children, u = a.map((d) => d === l ? b.Children.count(c) > 1 ? b.Children.only(null) : b.isValidElement(c) ? c.props.children : null : d);
        return m.jsx(e, {
          ...o,
          ref: i,
          children: b.isValidElement(c) ? b.cloneElement(c, void 0, u) : null
        });
      }
      return m.jsx(e, {
        ...o,
        ref: i,
        children: s
      });
    });
    return n.displayName = `${t}.Slot`, n;
  }
  var FSe = nf("Slot");
  function BSe(t) {
    const e = b.forwardRef((n, r) => {
      const { children: i, ...s } = n;
      if (b.isValidElement(i)) {
        const o = WSe(i), a = XSe(s, i.props);
        return i.type !== b.Fragment && (a.ref = r ? mC(r, o) : o), b.cloneElement(i, a);
      }
      return b.Children.count(i) > 1 ? b.Children.only(null) : null;
    });
    return e.displayName = `${t}.SlotClone`, e;
  }
  var eY = Symbol("radix.slottable");
  function USe(t) {
    const e = ({ children: n }) => m.jsx(m.Fragment, {
      children: n
    });
    return e.displayName = `${t}.Slottable`, e.__radixId = eY, e;
  }
  function VSe(t) {
    return b.isValidElement(t) && typeof t.type == "function" && "__radixId" in t.type && t.type.__radixId === eY;
  }
  function XSe(t, e) {
    const n = {
      ...e
    };
    for (const r in e) {
      const i = t[r], s = e[r];
      /^on[A-Z]/.test(r) ? i && s ? n[r] = (...a) => {
        const l = s(...a);
        return i(...a), l;
      } : i && (n[r] = i) : r === "style" ? n[r] = {
        ...i,
        ...s
      } : r === "className" && (n[r] = [
        i,
        s
      ].filter(Boolean).join(" "));
    }
    return {
      ...t,
      ...n
    };
  }
  function WSe(t) {
    var _a3, _b3;
    let e = (_a3 = Object.getOwnPropertyDescriptor(t.props, "ref")) == null ? void 0 : _a3.get, n = e && "isReactWarning" in e && e.isReactWarning;
    return n ? t.ref : (e = (_b3 = Object.getOwnPropertyDescriptor(t, "ref")) == null ? void 0 : _b3.get, n = e && "isReactWarning" in e && e.isReactWarning, n ? t.props.ref : t.props.ref || t.ref);
  }
  function tY(t) {
    var e, n, r = "";
    if (typeof t == "string" || typeof t == "number")
      r += t;
    else if (typeof t == "object")
      if (Array.isArray(t)) {
        var i = t.length;
        for (e = 0; e < i; e++)
          t[e] && (n = tY(t[e])) && (r && (r += " "), r += n);
      } else
        for (n in t)
          t[n] && (r && (r += " "), r += n);
    return r;
  }
  function nY() {
    for (var t, e, n = 0, r = "", i = arguments.length; n < i; n++)
      (t = arguments[n]) && (e = tY(t)) && (r && (r += " "), r += e);
    return r;
  }
  const pz = (t) => typeof t == "boolean" ? `${t}` : t === 0 ? "0" : t, gz = nY, X3 = (t, e) => (n) => {
    var r;
    if ((e == null ? void 0 : e.variants) == null)
      return gz(t, n == null ? void 0 : n.class, n == null ? void 0 : n.className);
    const { variants: i, defaultVariants: s } = e, o = Object.keys(i).map((c) => {
      const u = n == null ? void 0 : n[c], d = s == null ? void 0 : s[c];
      if (u === null)
        return null;
      const h = pz(u) || pz(d);
      return i[c][h];
    }), a = n && Object.entries(n).reduce((c, u) => {
      let [d, h] = u;
      return h === void 0 || (c[d] = h), c;
    }, {}), l = e == null || (r = e.compoundVariants) === null || r === void 0 ? void 0 : r.reduce((c, u) => {
      let { class: d, className: h, ...f } = u;
      return Object.entries(f).every((y) => {
        let [g, O] = y;
        return Array.isArray(O) ? O.includes({
          ...s,
          ...a
        }[g]) : {
          ...s,
          ...a
        }[g] === O;
      }) ? [
        ...c,
        d,
        h
      ] : c;
    }, []);
    return gz(t, o, l, n == null ? void 0 : n.class, n == null ? void 0 : n.className);
  };
  function ZSe() {
    for (var t = 0, e, n, r = ""; t < arguments.length; )
      (e = arguments[t++]) && (n = rY(e)) && (r && (r += " "), r += n);
    return r;
  }
  function rY(t) {
    if (typeof t == "string")
      return t;
    for (var e, n = "", r = 0; r < t.length; r++)
      t[r] && (e = rY(t[r])) && (n && (n += " "), n += e);
    return n;
  }
  var W3 = "-";
  function HSe(t) {
    var e = GSe(t), n = t.conflictingClassGroups, r = t.conflictingClassGroupModifiers, i = r === void 0 ? {} : r;
    function s(a) {
      var l = a.split(W3);
      return l[0] === "" && l.length !== 1 && l.shift(), iY(l, e) || YSe(a);
    }
    function o(a, l) {
      var c = n[a] || [];
      return l && i[a] ? [].concat(c, i[a]) : c;
    }
    return {
      getClassGroupId: s,
      getConflictingClassGroupIds: o
    };
  }
  function iY(t, e) {
    var _a3;
    if (t.length === 0)
      return e.classGroupId;
    var n = t[0], r = e.nextPart.get(n), i = r ? iY(t.slice(1), r) : void 0;
    if (i)
      return i;
    if (e.validators.length !== 0) {
      var s = t.join(W3);
      return (_a3 = e.validators.find(function(o) {
        var a = o.validator;
        return a(s);
      })) == null ? void 0 : _a3.classGroupId;
    }
  }
  var mz = /^\[(.+)\]$/;
  function YSe(t) {
    if (mz.test(t)) {
      var e = mz.exec(t)[1], n = e == null ? void 0 : e.substring(0, e.indexOf(":"));
      if (n)
        return "arbitrary.." + n;
    }
  }
  function GSe(t) {
    var e = t.theme, n = t.prefix, r = {
      nextPart: /* @__PURE__ */ new Map(),
      validators: []
    }, i = KSe(Object.entries(t.classGroups), n);
    return i.forEach(function(s) {
      var o = s[0], a = s[1];
      UA(a, r, o, e);
    }), r;
  }
  function UA(t, e, n, r) {
    t.forEach(function(i) {
      if (typeof i == "string") {
        var s = i === "" ? e : yz(e, i);
        s.classGroupId = n;
        return;
      }
      if (typeof i == "function") {
        if (qSe(i)) {
          UA(i(r), e, n, r);
          return;
        }
        e.validators.push({
          validator: i,
          classGroupId: n
        });
        return;
      }
      Object.entries(i).forEach(function(o) {
        var a = o[0], l = o[1];
        UA(l, yz(e, a), n, r);
      });
    });
  }
  function yz(t, e) {
    var n = t;
    return e.split(W3).forEach(function(r) {
      n.nextPart.has(r) || n.nextPart.set(r, {
        nextPart: /* @__PURE__ */ new Map(),
        validators: []
      }), n = n.nextPart.get(r);
    }), n;
  }
  function qSe(t) {
    return t.isThemeGetter;
  }
  function KSe(t, e) {
    return e ? t.map(function(n) {
      var r = n[0], i = n[1], s = i.map(function(o) {
        return typeof o == "string" ? e + o : typeof o == "object" ? Object.fromEntries(Object.entries(o).map(function(a) {
          var l = a[0], c = a[1];
          return [
            e + l,
            c
          ];
        })) : o;
      });
      return [
        r,
        s
      ];
    }) : t;
  }
  function JSe(t) {
    if (t < 1)
      return {
        get: function() {
        },
        set: function() {
        }
      };
    var e = 0, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
    function i(s, o) {
      n.set(s, o), e++, e > t && (e = 0, r = n, n = /* @__PURE__ */ new Map());
    }
    return {
      get: function(o) {
        var a = n.get(o);
        if (a !== void 0)
          return a;
        if ((a = r.get(o)) !== void 0)
          return i(o, a), a;
      },
      set: function(o, a) {
        n.has(o) ? n.set(o, a) : i(o, a);
      }
    };
  }
  var sY = "!";
  function e1e(t) {
    var e = t.separator || ":", n = e.length === 1, r = e[0], i = e.length;
    return function(o) {
      for (var a = [], l = 0, c = 0, u, d = 0; d < o.length; d++) {
        var h = o[d];
        if (l === 0) {
          if (h === r && (n || o.slice(d, d + i) === e)) {
            a.push(o.slice(c, d)), c = d + i;
            continue;
          }
          if (h === "/") {
            u = d;
            continue;
          }
        }
        h === "[" ? l++ : h === "]" && l--;
      }
      var f = a.length === 0 ? o : o.substring(c), y = f.startsWith(sY), g = y ? f.substring(1) : f, O = u && u > c ? u - c : void 0;
      return {
        modifiers: a,
        hasImportantModifier: y,
        baseClassName: g,
        maybePostfixModifierPosition: O
      };
    };
  }
  function t1e(t) {
    if (t.length <= 1)
      return t;
    var e = [], n = [];
    return t.forEach(function(r) {
      var i = r[0] === "[";
      i ? (e.push.apply(e, n.sort().concat([
        r
      ])), n = []) : n.push(r);
    }), e.push.apply(e, n.sort()), e;
  }
  function n1e(t) {
    return {
      cache: JSe(t.cacheSize),
      splitModifiers: e1e(t),
      ...HSe(t)
    };
  }
  var r1e = /\s+/;
  function i1e(t, e) {
    var n = e.splitModifiers, r = e.getClassGroupId, i = e.getConflictingClassGroupIds, s = /* @__PURE__ */ new Set();
    return t.trim().split(r1e).map(function(o) {
      var a = n(o), l = a.modifiers, c = a.hasImportantModifier, u = a.baseClassName, d = a.maybePostfixModifierPosition, h = r(d ? u.substring(0, d) : u), f = !!d;
      if (!h) {
        if (!d)
          return {
            isTailwindClass: false,
            originalClassName: o
          };
        if (h = r(u), !h)
          return {
            isTailwindClass: false,
            originalClassName: o
          };
        f = false;
      }
      var y = t1e(l).join(":"), g = c ? y + sY : y;
      return {
        isTailwindClass: true,
        modifierId: g,
        classGroupId: h,
        originalClassName: o,
        hasPostfixModifier: f
      };
    }).reverse().filter(function(o) {
      if (!o.isTailwindClass)
        return true;
      var a = o.modifierId, l = o.classGroupId, c = o.hasPostfixModifier, u = a + l;
      return s.has(u) ? false : (s.add(u), i(l, c).forEach(function(d) {
        return s.add(a + d);
      }), true);
    }).reverse().map(function(o) {
      return o.originalClassName;
    }).join(" ");
  }
  function s1e() {
    for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
      e[n] = arguments[n];
    var r, i, s, o = a;
    function a(c) {
      var u = e[0], d = e.slice(1), h = d.reduce(function(f, y) {
        return y(f);
      }, u());
      return r = n1e(h), i = r.cache.get, s = r.cache.set, o = l, l(c);
    }
    function l(c) {
      var u = i(c);
      if (u)
        return u;
      var d = i1e(c, r);
      return s(c, d), d;
    }
    return function() {
      return o(ZSe.apply(null, arguments));
    };
  }
  function gn(t) {
    var e = function(r) {
      return r[t] || [];
    };
    return e.isThemeGetter = true, e;
  }
  var oY = /^\[(?:([a-z-]+):)?(.+)\]$/i, o1e = /^\d+\/\d+$/, a1e = /* @__PURE__ */ new Set([
    "px",
    "full",
    "screen"
  ]), l1e = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, c1e = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, u1e = /^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/;
  function ma(t) {
    return Ah(t) || a1e.has(t) || o1e.test(t) || VA(t);
  }
  function VA(t) {
    return vf(t, "length", m1e);
  }
  function d1e(t) {
    return vf(t, "size", aY);
  }
  function h1e(t) {
    return vf(t, "position", aY);
  }
  function f1e(t) {
    return vf(t, "url", y1e);
  }
  function iw(t) {
    return vf(t, "number", Ah);
  }
  function Ah(t) {
    return !Number.isNaN(Number(t));
  }
  function p1e(t) {
    return t.endsWith("%") && Ah(t.slice(0, -1));
  }
  function Ry(t) {
    return vz(t) || vf(t, "number", vz);
  }
  function xt(t) {
    return oY.test(t);
  }
  function My() {
    return true;
  }
  function Pu(t) {
    return l1e.test(t);
  }
  function g1e(t) {
    return vf(t, "", v1e);
  }
  function vf(t, e, n) {
    var r = oY.exec(t);
    return r ? r[1] ? r[1] === e : n(r[2]) : false;
  }
  function m1e(t) {
    return c1e.test(t);
  }
  function aY() {
    return false;
  }
  function y1e(t) {
    return t.startsWith("url(");
  }
  function vz(t) {
    return Number.isInteger(Number(t));
  }
  function v1e(t) {
    return u1e.test(t);
  }
  function O1e() {
    var t = gn("colors"), e = gn("spacing"), n = gn("blur"), r = gn("brightness"), i = gn("borderColor"), s = gn("borderRadius"), o = gn("borderSpacing"), a = gn("borderWidth"), l = gn("contrast"), c = gn("grayscale"), u = gn("hueRotate"), d = gn("invert"), h = gn("gap"), f = gn("gradientColorStops"), y = gn("gradientColorStopPositions"), g = gn("inset"), O = gn("margin"), S = gn("opacity"), w = gn("padding"), x = gn("saturate"), P = gn("scale"), C = gn("sepia"), _ = gn("skew"), T = gn("space"), $ = gn("translate"), N = function() {
      return [
        "auto",
        "contain",
        "none"
      ];
    }, L = function() {
      return [
        "auto",
        "hidden",
        "clip",
        "visible",
        "scroll"
      ];
    }, z = function() {
      return [
        "auto",
        xt,
        e
      ];
    }, M = function() {
      return [
        xt,
        e
      ];
    }, R = function() {
      return [
        "",
        ma
      ];
    }, F = function() {
      return [
        "auto",
        Ah,
        xt
      ];
    }, Q = function() {
      return [
        "bottom",
        "center",
        "left",
        "left-bottom",
        "left-top",
        "right",
        "right-bottom",
        "right-top",
        "top"
      ];
    }, X = function() {
      return [
        "solid",
        "dashed",
        "dotted",
        "double",
        "none"
      ];
    }, Z = function() {
      return [
        "normal",
        "multiply",
        "screen",
        "overlay",
        "darken",
        "lighten",
        "color-dodge",
        "color-burn",
        "hard-light",
        "soft-light",
        "difference",
        "exclusion",
        "hue",
        "saturation",
        "color",
        "luminosity",
        "plus-lighter"
      ];
    }, U = function() {
      return [
        "start",
        "end",
        "center",
        "between",
        "around",
        "evenly",
        "stretch"
      ];
    }, H = function() {
      return [
        "",
        "0",
        xt
      ];
    }, te = function() {
      return [
        "auto",
        "avoid",
        "all",
        "avoid-page",
        "page",
        "left",
        "right",
        "column"
      ];
    }, se = function() {
      return [
        Ah,
        iw
      ];
    }, ae = function() {
      return [
        Ah,
        xt
      ];
    };
    return {
      cacheSize: 500,
      theme: {
        colors: [
          My
        ],
        spacing: [
          ma
        ],
        blur: [
          "none",
          "",
          Pu,
          xt
        ],
        brightness: se(),
        borderColor: [
          t
        ],
        borderRadius: [
          "none",
          "",
          "full",
          Pu,
          xt
        ],
        borderSpacing: M(),
        borderWidth: R(),
        contrast: se(),
        grayscale: H(),
        hueRotate: ae(),
        invert: H(),
        gap: M(),
        gradientColorStops: [
          t
        ],
        gradientColorStopPositions: [
          p1e,
          VA
        ],
        inset: z(),
        margin: z(),
        opacity: se(),
        padding: M(),
        saturate: se(),
        scale: se(),
        sepia: H(),
        skew: ae(),
        space: M(),
        translate: M()
      },
      classGroups: {
        aspect: [
          {
            aspect: [
              "auto",
              "square",
              "video",
              xt
            ]
          }
        ],
        container: [
          "container"
        ],
        columns: [
          {
            columns: [
              Pu
            ]
          }
        ],
        "break-after": [
          {
            "break-after": te()
          }
        ],
        "break-before": [
          {
            "break-before": te()
          }
        ],
        "break-inside": [
          {
            "break-inside": [
              "auto",
              "avoid",
              "avoid-page",
              "avoid-column"
            ]
          }
        ],
        "box-decoration": [
          {
            "box-decoration": [
              "slice",
              "clone"
            ]
          }
        ],
        box: [
          {
            box: [
              "border",
              "content"
            ]
          }
        ],
        display: [
          "block",
          "inline-block",
          "inline",
          "flex",
          "inline-flex",
          "table",
          "inline-table",
          "table-caption",
          "table-cell",
          "table-column",
          "table-column-group",
          "table-footer-group",
          "table-header-group",
          "table-row-group",
          "table-row",
          "flow-root",
          "grid",
          "inline-grid",
          "contents",
          "list-item",
          "hidden"
        ],
        float: [
          {
            float: [
              "right",
              "left",
              "none"
            ]
          }
        ],
        clear: [
          {
            clear: [
              "left",
              "right",
              "both",
              "none"
            ]
          }
        ],
        isolation: [
          "isolate",
          "isolation-auto"
        ],
        "object-fit": [
          {
            object: [
              "contain",
              "cover",
              "fill",
              "none",
              "scale-down"
            ]
          }
        ],
        "object-position": [
          {
            object: [].concat(Q(), [
              xt
            ])
          }
        ],
        overflow: [
          {
            overflow: L()
          }
        ],
        "overflow-x": [
          {
            "overflow-x": L()
          }
        ],
        "overflow-y": [
          {
            "overflow-y": L()
          }
        ],
        overscroll: [
          {
            overscroll: N()
          }
        ],
        "overscroll-x": [
          {
            "overscroll-x": N()
          }
        ],
        "overscroll-y": [
          {
            "overscroll-y": N()
          }
        ],
        position: [
          "static",
          "fixed",
          "absolute",
          "relative",
          "sticky"
        ],
        inset: [
          {
            inset: [
              g
            ]
          }
        ],
        "inset-x": [
          {
            "inset-x": [
              g
            ]
          }
        ],
        "inset-y": [
          {
            "inset-y": [
              g
            ]
          }
        ],
        start: [
          {
            start: [
              g
            ]
          }
        ],
        end: [
          {
            end: [
              g
            ]
          }
        ],
        top: [
          {
            top: [
              g
            ]
          }
        ],
        right: [
          {
            right: [
              g
            ]
          }
        ],
        bottom: [
          {
            bottom: [
              g
            ]
          }
        ],
        left: [
          {
            left: [
              g
            ]
          }
        ],
        visibility: [
          "visible",
          "invisible",
          "collapse"
        ],
        z: [
          {
            z: [
              "auto",
              Ry
            ]
          }
        ],
        basis: [
          {
            basis: z()
          }
        ],
        "flex-direction": [
          {
            flex: [
              "row",
              "row-reverse",
              "col",
              "col-reverse"
            ]
          }
        ],
        "flex-wrap": [
          {
            flex: [
              "wrap",
              "wrap-reverse",
              "nowrap"
            ]
          }
        ],
        flex: [
          {
            flex: [
              "1",
              "auto",
              "initial",
              "none",
              xt
            ]
          }
        ],
        grow: [
          {
            grow: H()
          }
        ],
        shrink: [
          {
            shrink: H()
          }
        ],
        order: [
          {
            order: [
              "first",
              "last",
              "none",
              Ry
            ]
          }
        ],
        "grid-cols": [
          {
            "grid-cols": [
              My
            ]
          }
        ],
        "col-start-end": [
          {
            col: [
              "auto",
              {
                span: [
                  "full",
                  Ry
                ]
              },
              xt
            ]
          }
        ],
        "col-start": [
          {
            "col-start": F()
          }
        ],
        "col-end": [
          {
            "col-end": F()
          }
        ],
        "grid-rows": [
          {
            "grid-rows": [
              My
            ]
          }
        ],
        "row-start-end": [
          {
            row: [
              "auto",
              {
                span: [
                  Ry
                ]
              },
              xt
            ]
          }
        ],
        "row-start": [
          {
            "row-start": F()
          }
        ],
        "row-end": [
          {
            "row-end": F()
          }
        ],
        "grid-flow": [
          {
            "grid-flow": [
              "row",
              "col",
              "dense",
              "row-dense",
              "col-dense"
            ]
          }
        ],
        "auto-cols": [
          {
            "auto-cols": [
              "auto",
              "min",
              "max",
              "fr",
              xt
            ]
          }
        ],
        "auto-rows": [
          {
            "auto-rows": [
              "auto",
              "min",
              "max",
              "fr",
              xt
            ]
          }
        ],
        gap: [
          {
            gap: [
              h
            ]
          }
        ],
        "gap-x": [
          {
            "gap-x": [
              h
            ]
          }
        ],
        "gap-y": [
          {
            "gap-y": [
              h
            ]
          }
        ],
        "justify-content": [
          {
            justify: [
              "normal"
            ].concat(U())
          }
        ],
        "justify-items": [
          {
            "justify-items": [
              "start",
              "end",
              "center",
              "stretch"
            ]
          }
        ],
        "justify-self": [
          {
            "justify-self": [
              "auto",
              "start",
              "end",
              "center",
              "stretch"
            ]
          }
        ],
        "align-content": [
          {
            content: [
              "normal"
            ].concat(U(), [
              "baseline"
            ])
          }
        ],
        "align-items": [
          {
            items: [
              "start",
              "end",
              "center",
              "baseline",
              "stretch"
            ]
          }
        ],
        "align-self": [
          {
            self: [
              "auto",
              "start",
              "end",
              "center",
              "stretch",
              "baseline"
            ]
          }
        ],
        "place-content": [
          {
            "place-content": [].concat(U(), [
              "baseline"
            ])
          }
        ],
        "place-items": [
          {
            "place-items": [
              "start",
              "end",
              "center",
              "baseline",
              "stretch"
            ]
          }
        ],
        "place-self": [
          {
            "place-self": [
              "auto",
              "start",
              "end",
              "center",
              "stretch"
            ]
          }
        ],
        p: [
          {
            p: [
              w
            ]
          }
        ],
        px: [
          {
            px: [
              w
            ]
          }
        ],
        py: [
          {
            py: [
              w
            ]
          }
        ],
        ps: [
          {
            ps: [
              w
            ]
          }
        ],
        pe: [
          {
            pe: [
              w
            ]
          }
        ],
        pt: [
          {
            pt: [
              w
            ]
          }
        ],
        pr: [
          {
            pr: [
              w
            ]
          }
        ],
        pb: [
          {
            pb: [
              w
            ]
          }
        ],
        pl: [
          {
            pl: [
              w
            ]
          }
        ],
        m: [
          {
            m: [
              O
            ]
          }
        ],
        mx: [
          {
            mx: [
              O
            ]
          }
        ],
        my: [
          {
            my: [
              O
            ]
          }
        ],
        ms: [
          {
            ms: [
              O
            ]
          }
        ],
        me: [
          {
            me: [
              O
            ]
          }
        ],
        mt: [
          {
            mt: [
              O
            ]
          }
        ],
        mr: [
          {
            mr: [
              O
            ]
          }
        ],
        mb: [
          {
            mb: [
              O
            ]
          }
        ],
        ml: [
          {
            ml: [
              O
            ]
          }
        ],
        "space-x": [
          {
            "space-x": [
              T
            ]
          }
        ],
        "space-x-reverse": [
          "space-x-reverse"
        ],
        "space-y": [
          {
            "space-y": [
              T
            ]
          }
        ],
        "space-y-reverse": [
          "space-y-reverse"
        ],
        w: [
          {
            w: [
              "auto",
              "min",
              "max",
              "fit",
              xt,
              e
            ]
          }
        ],
        "min-w": [
          {
            "min-w": [
              "min",
              "max",
              "fit",
              xt,
              ma
            ]
          }
        ],
        "max-w": [
          {
            "max-w": [
              "0",
              "none",
              "full",
              "min",
              "max",
              "fit",
              "prose",
              {
                screen: [
                  Pu
                ]
              },
              Pu,
              xt
            ]
          }
        ],
        h: [
          {
            h: [
              xt,
              e,
              "auto",
              "min",
              "max",
              "fit"
            ]
          }
        ],
        "min-h": [
          {
            "min-h": [
              "min",
              "max",
              "fit",
              xt,
              ma
            ]
          }
        ],
        "max-h": [
          {
            "max-h": [
              xt,
              e,
              "min",
              "max",
              "fit"
            ]
          }
        ],
        "font-size": [
          {
            text: [
              "base",
              Pu,
              VA
            ]
          }
        ],
        "font-smoothing": [
          "antialiased",
          "subpixel-antialiased"
        ],
        "font-style": [
          "italic",
          "not-italic"
        ],
        "font-weight": [
          {
            font: [
              "thin",
              "extralight",
              "light",
              "normal",
              "medium",
              "semibold",
              "bold",
              "extrabold",
              "black",
              iw
            ]
          }
        ],
        "font-family": [
          {
            font: [
              My
            ]
          }
        ],
        "fvn-normal": [
          "normal-nums"
        ],
        "fvn-ordinal": [
          "ordinal"
        ],
        "fvn-slashed-zero": [
          "slashed-zero"
        ],
        "fvn-figure": [
          "lining-nums",
          "oldstyle-nums"
        ],
        "fvn-spacing": [
          "proportional-nums",
          "tabular-nums"
        ],
        "fvn-fraction": [
          "diagonal-fractions",
          "stacked-fractons"
        ],
        tracking: [
          {
            tracking: [
              "tighter",
              "tight",
              "normal",
              "wide",
              "wider",
              "widest",
              xt
            ]
          }
        ],
        "line-clamp": [
          {
            "line-clamp": [
              "none",
              Ah,
              iw
            ]
          }
        ],
        leading: [
          {
            leading: [
              "none",
              "tight",
              "snug",
              "normal",
              "relaxed",
              "loose",
              xt,
              ma
            ]
          }
        ],
        "list-image": [
          {
            "list-image": [
              "none",
              xt
            ]
          }
        ],
        "list-style-type": [
          {
            list: [
              "none",
              "disc",
              "decimal",
              xt
            ]
          }
        ],
        "list-style-position": [
          {
            list: [
              "inside",
              "outside"
            ]
          }
        ],
        "placeholder-color": [
          {
            placeholder: [
              t
            ]
          }
        ],
        "placeholder-opacity": [
          {
            "placeholder-opacity": [
              S
            ]
          }
        ],
        "text-alignment": [
          {
            text: [
              "left",
              "center",
              "right",
              "justify",
              "start",
              "end"
            ]
          }
        ],
        "text-color": [
          {
            text: [
              t
            ]
          }
        ],
        "text-opacity": [
          {
            "text-opacity": [
              S
            ]
          }
        ],
        "text-decoration": [
          "underline",
          "overline",
          "line-through",
          "no-underline"
        ],
        "text-decoration-style": [
          {
            decoration: [].concat(X(), [
              "wavy"
            ])
          }
        ],
        "text-decoration-thickness": [
          {
            decoration: [
              "auto",
              "from-font",
              ma
            ]
          }
        ],
        "underline-offset": [
          {
            "underline-offset": [
              "auto",
              xt,
              ma
            ]
          }
        ],
        "text-decoration-color": [
          {
            decoration: [
              t
            ]
          }
        ],
        "text-transform": [
          "uppercase",
          "lowercase",
          "capitalize",
          "normal-case"
        ],
        "text-overflow": [
          "truncate",
          "text-ellipsis",
          "text-clip"
        ],
        indent: [
          {
            indent: M()
          }
        ],
        "vertical-align": [
          {
            align: [
              "baseline",
              "top",
              "middle",
              "bottom",
              "text-top",
              "text-bottom",
              "sub",
              "super",
              xt
            ]
          }
        ],
        whitespace: [
          {
            whitespace: [
              "normal",
              "nowrap",
              "pre",
              "pre-line",
              "pre-wrap",
              "break-spaces"
            ]
          }
        ],
        break: [
          {
            break: [
              "normal",
              "words",
              "all",
              "keep"
            ]
          }
        ],
        hyphens: [
          {
            hyphens: [
              "none",
              "manual",
              "auto"
            ]
          }
        ],
        content: [
          {
            content: [
              "none",
              xt
            ]
          }
        ],
        "bg-attachment": [
          {
            bg: [
              "fixed",
              "local",
              "scroll"
            ]
          }
        ],
        "bg-clip": [
          {
            "bg-clip": [
              "border",
              "padding",
              "content",
              "text"
            ]
          }
        ],
        "bg-opacity": [
          {
            "bg-opacity": [
              S
            ]
          }
        ],
        "bg-origin": [
          {
            "bg-origin": [
              "border",
              "padding",
              "content"
            ]
          }
        ],
        "bg-position": [
          {
            bg: [].concat(Q(), [
              h1e
            ])
          }
        ],
        "bg-repeat": [
          {
            bg: [
              "no-repeat",
              {
                repeat: [
                  "",
                  "x",
                  "y",
                  "round",
                  "space"
                ]
              }
            ]
          }
        ],
        "bg-size": [
          {
            bg: [
              "auto",
              "cover",
              "contain",
              d1e
            ]
          }
        ],
        "bg-image": [
          {
            bg: [
              "none",
              {
                "gradient-to": [
                  "t",
                  "tr",
                  "r",
                  "br",
                  "b",
                  "bl",
                  "l",
                  "tl"
                ]
              },
              f1e
            ]
          }
        ],
        "bg-color": [
          {
            bg: [
              t
            ]
          }
        ],
        "gradient-from-pos": [
          {
            from: [
              y
            ]
          }
        ],
        "gradient-via-pos": [
          {
            via: [
              y
            ]
          }
        ],
        "gradient-to-pos": [
          {
            to: [
              y
            ]
          }
        ],
        "gradient-from": [
          {
            from: [
              f
            ]
          }
        ],
        "gradient-via": [
          {
            via: [
              f
            ]
          }
        ],
        "gradient-to": [
          {
            to: [
              f
            ]
          }
        ],
        rounded: [
          {
            rounded: [
              s
            ]
          }
        ],
        "rounded-s": [
          {
            "rounded-s": [
              s
            ]
          }
        ],
        "rounded-e": [
          {
            "rounded-e": [
              s
            ]
          }
        ],
        "rounded-t": [
          {
            "rounded-t": [
              s
            ]
          }
        ],
        "rounded-r": [
          {
            "rounded-r": [
              s
            ]
          }
        ],
        "rounded-b": [
          {
            "rounded-b": [
              s
            ]
          }
        ],
        "rounded-l": [
          {
            "rounded-l": [
              s
            ]
          }
        ],
        "rounded-ss": [
          {
            "rounded-ss": [
              s
            ]
          }
        ],
        "rounded-se": [
          {
            "rounded-se": [
              s
            ]
          }
        ],
        "rounded-ee": [
          {
            "rounded-ee": [
              s
            ]
          }
        ],
        "rounded-es": [
          {
            "rounded-es": [
              s
            ]
          }
        ],
        "rounded-tl": [
          {
            "rounded-tl": [
              s
            ]
          }
        ],
        "rounded-tr": [
          {
            "rounded-tr": [
              s
            ]
          }
        ],
        "rounded-br": [
          {
            "rounded-br": [
              s
            ]
          }
        ],
        "rounded-bl": [
          {
            "rounded-bl": [
              s
            ]
          }
        ],
        "border-w": [
          {
            border: [
              a
            ]
          }
        ],
        "border-w-x": [
          {
            "border-x": [
              a
            ]
          }
        ],
        "border-w-y": [
          {
            "border-y": [
              a
            ]
          }
        ],
        "border-w-s": [
          {
            "border-s": [
              a
            ]
          }
        ],
        "border-w-e": [
          {
            "border-e": [
              a
            ]
          }
        ],
        "border-w-t": [
          {
            "border-t": [
              a
            ]
          }
        ],
        "border-w-r": [
          {
            "border-r": [
              a
            ]
          }
        ],
        "border-w-b": [
          {
            "border-b": [
              a
            ]
          }
        ],
        "border-w-l": [
          {
            "border-l": [
              a
            ]
          }
        ],
        "border-opacity": [
          {
            "border-opacity": [
              S
            ]
          }
        ],
        "border-style": [
          {
            border: [].concat(X(), [
              "hidden"
            ])
          }
        ],
        "divide-x": [
          {
            "divide-x": [
              a
            ]
          }
        ],
        "divide-x-reverse": [
          "divide-x-reverse"
        ],
        "divide-y": [
          {
            "divide-y": [
              a
            ]
          }
        ],
        "divide-y-reverse": [
          "divide-y-reverse"
        ],
        "divide-opacity": [
          {
            "divide-opacity": [
              S
            ]
          }
        ],
        "divide-style": [
          {
            divide: X()
          }
        ],
        "border-color": [
          {
            border: [
              i
            ]
          }
        ],
        "border-color-x": [
          {
            "border-x": [
              i
            ]
          }
        ],
        "border-color-y": [
          {
            "border-y": [
              i
            ]
          }
        ],
        "border-color-t": [
          {
            "border-t": [
              i
            ]
          }
        ],
        "border-color-r": [
          {
            "border-r": [
              i
            ]
          }
        ],
        "border-color-b": [
          {
            "border-b": [
              i
            ]
          }
        ],
        "border-color-l": [
          {
            "border-l": [
              i
            ]
          }
        ],
        "divide-color": [
          {
            divide: [
              i
            ]
          }
        ],
        "outline-style": [
          {
            outline: [
              ""
            ].concat(X())
          }
        ],
        "outline-offset": [
          {
            "outline-offset": [
              xt,
              ma
            ]
          }
        ],
        "outline-w": [
          {
            outline: [
              ma
            ]
          }
        ],
        "outline-color": [
          {
            outline: [
              t
            ]
          }
        ],
        "ring-w": [
          {
            ring: R()
          }
        ],
        "ring-w-inset": [
          "ring-inset"
        ],
        "ring-color": [
          {
            ring: [
              t
            ]
          }
        ],
        "ring-opacity": [
          {
            "ring-opacity": [
              S
            ]
          }
        ],
        "ring-offset-w": [
          {
            "ring-offset": [
              ma
            ]
          }
        ],
        "ring-offset-color": [
          {
            "ring-offset": [
              t
            ]
          }
        ],
        shadow: [
          {
            shadow: [
              "",
              "inner",
              "none",
              Pu,
              g1e
            ]
          }
        ],
        "shadow-color": [
          {
            shadow: [
              My
            ]
          }
        ],
        opacity: [
          {
            opacity: [
              S
            ]
          }
        ],
        "mix-blend": [
          {
            "mix-blend": Z()
          }
        ],
        "bg-blend": [
          {
            "bg-blend": Z()
          }
        ],
        filter: [
          {
            filter: [
              "",
              "none"
            ]
          }
        ],
        blur: [
          {
            blur: [
              n
            ]
          }
        ],
        brightness: [
          {
            brightness: [
              r
            ]
          }
        ],
        contrast: [
          {
            contrast: [
              l
            ]
          }
        ],
        "drop-shadow": [
          {
            "drop-shadow": [
              "",
              "none",
              Pu,
              xt
            ]
          }
        ],
        grayscale: [
          {
            grayscale: [
              c
            ]
          }
        ],
        "hue-rotate": [
          {
            "hue-rotate": [
              u
            ]
          }
        ],
        invert: [
          {
            invert: [
              d
            ]
          }
        ],
        saturate: [
          {
            saturate: [
              x
            ]
          }
        ],
        sepia: [
          {
            sepia: [
              C
            ]
          }
        ],
        "backdrop-filter": [
          {
            "backdrop-filter": [
              "",
              "none"
            ]
          }
        ],
        "backdrop-blur": [
          {
            "backdrop-blur": [
              n
            ]
          }
        ],
        "backdrop-brightness": [
          {
            "backdrop-brightness": [
              r
            ]
          }
        ],
        "backdrop-contrast": [
          {
            "backdrop-contrast": [
              l
            ]
          }
        ],
        "backdrop-grayscale": [
          {
            "backdrop-grayscale": [
              c
            ]
          }
        ],
        "backdrop-hue-rotate": [
          {
            "backdrop-hue-rotate": [
              u
            ]
          }
        ],
        "backdrop-invert": [
          {
            "backdrop-invert": [
              d
            ]
          }
        ],
        "backdrop-opacity": [
          {
            "backdrop-opacity": [
              S
            ]
          }
        ],
        "backdrop-saturate": [
          {
            "backdrop-saturate": [
              x
            ]
          }
        ],
        "backdrop-sepia": [
          {
            "backdrop-sepia": [
              C
            ]
          }
        ],
        "border-collapse": [
          {
            border: [
              "collapse",
              "separate"
            ]
          }
        ],
        "border-spacing": [
          {
            "border-spacing": [
              o
            ]
          }
        ],
        "border-spacing-x": [
          {
            "border-spacing-x": [
              o
            ]
          }
        ],
        "border-spacing-y": [
          {
            "border-spacing-y": [
              o
            ]
          }
        ],
        "table-layout": [
          {
            table: [
              "auto",
              "fixed"
            ]
          }
        ],
        caption: [
          {
            caption: [
              "top",
              "bottom"
            ]
          }
        ],
        transition: [
          {
            transition: [
              "none",
              "all",
              "",
              "colors",
              "opacity",
              "shadow",
              "transform",
              xt
            ]
          }
        ],
        duration: [
          {
            duration: ae()
          }
        ],
        ease: [
          {
            ease: [
              "linear",
              "in",
              "out",
              "in-out",
              xt
            ]
          }
        ],
        delay: [
          {
            delay: ae()
          }
        ],
        animate: [
          {
            animate: [
              "none",
              "spin",
              "ping",
              "pulse",
              "bounce",
              xt
            ]
          }
        ],
        transform: [
          {
            transform: [
              "",
              "gpu",
              "none"
            ]
          }
        ],
        scale: [
          {
            scale: [
              P
            ]
          }
        ],
        "scale-x": [
          {
            "scale-x": [
              P
            ]
          }
        ],
        "scale-y": [
          {
            "scale-y": [
              P
            ]
          }
        ],
        rotate: [
          {
            rotate: [
              Ry,
              xt
            ]
          }
        ],
        "translate-x": [
          {
            "translate-x": [
              $
            ]
          }
        ],
        "translate-y": [
          {
            "translate-y": [
              $
            ]
          }
        ],
        "skew-x": [
          {
            "skew-x": [
              _
            ]
          }
        ],
        "skew-y": [
          {
            "skew-y": [
              _
            ]
          }
        ],
        "transform-origin": [
          {
            origin: [
              "center",
              "top",
              "top-right",
              "right",
              "bottom-right",
              "bottom",
              "bottom-left",
              "left",
              "top-left",
              xt
            ]
          }
        ],
        accent: [
          {
            accent: [
              "auto",
              t
            ]
          }
        ],
        appearance: [
          "appearance-none"
        ],
        cursor: [
          {
            cursor: [
              "auto",
              "default",
              "pointer",
              "wait",
              "text",
              "move",
              "help",
              "not-allowed",
              "none",
              "context-menu",
              "progress",
              "cell",
              "crosshair",
              "vertical-text",
              "alias",
              "copy",
              "no-drop",
              "grab",
              "grabbing",
              "all-scroll",
              "col-resize",
              "row-resize",
              "n-resize",
              "e-resize",
              "s-resize",
              "w-resize",
              "ne-resize",
              "nw-resize",
              "se-resize",
              "sw-resize",
              "ew-resize",
              "ns-resize",
              "nesw-resize",
              "nwse-resize",
              "zoom-in",
              "zoom-out",
              xt
            ]
          }
        ],
        "caret-color": [
          {
            caret: [
              t
            ]
          }
        ],
        "pointer-events": [
          {
            "pointer-events": [
              "none",
              "auto"
            ]
          }
        ],
        resize: [
          {
            resize: [
              "none",
              "y",
              "x",
              ""
            ]
          }
        ],
        "scroll-behavior": [
          {
            scroll: [
              "auto",
              "smooth"
            ]
          }
        ],
        "scroll-m": [
          {
            "scroll-m": M()
          }
        ],
        "scroll-mx": [
          {
            "scroll-mx": M()
          }
        ],
        "scroll-my": [
          {
            "scroll-my": M()
          }
        ],
        "scroll-ms": [
          {
            "scroll-ms": M()
          }
        ],
        "scroll-me": [
          {
            "scroll-me": M()
          }
        ],
        "scroll-mt": [
          {
            "scroll-mt": M()
          }
        ],
        "scroll-mr": [
          {
            "scroll-mr": M()
          }
        ],
        "scroll-mb": [
          {
            "scroll-mb": M()
          }
        ],
        "scroll-ml": [
          {
            "scroll-ml": M()
          }
        ],
        "scroll-p": [
          {
            "scroll-p": M()
          }
        ],
        "scroll-px": [
          {
            "scroll-px": M()
          }
        ],
        "scroll-py": [
          {
            "scroll-py": M()
          }
        ],
        "scroll-ps": [
          {
            "scroll-ps": M()
          }
        ],
        "scroll-pe": [
          {
            "scroll-pe": M()
          }
        ],
        "scroll-pt": [
          {
            "scroll-pt": M()
          }
        ],
        "scroll-pr": [
          {
            "scroll-pr": M()
          }
        ],
        "scroll-pb": [
          {
            "scroll-pb": M()
          }
        ],
        "scroll-pl": [
          {
            "scroll-pl": M()
          }
        ],
        "snap-align": [
          {
            snap: [
              "start",
              "end",
              "center",
              "align-none"
            ]
          }
        ],
        "snap-stop": [
          {
            snap: [
              "normal",
              "always"
            ]
          }
        ],
        "snap-type": [
          {
            snap: [
              "none",
              "x",
              "y",
              "both"
            ]
          }
        ],
        "snap-strictness": [
          {
            snap: [
              "mandatory",
              "proximity"
            ]
          }
        ],
        touch: [
          {
            touch: [
              "auto",
              "none",
              "pinch-zoom",
              "manipulation",
              {
                pan: [
                  "x",
                  "left",
                  "right",
                  "y",
                  "up",
                  "down"
                ]
              }
            ]
          }
        ],
        select: [
          {
            select: [
              "none",
              "text",
              "all",
              "auto"
            ]
          }
        ],
        "will-change": [
          {
            "will-change": [
              "auto",
              "scroll",
              "contents",
              "transform",
              xt
            ]
          }
        ],
        fill: [
          {
            fill: [
              t,
              "none"
            ]
          }
        ],
        "stroke-w": [
          {
            stroke: [
              ma,
              iw
            ]
          }
        ],
        stroke: [
          {
            stroke: [
              t,
              "none"
            ]
          }
        ],
        sr: [
          "sr-only",
          "not-sr-only"
        ]
      },
      conflictingClassGroups: {
        overflow: [
          "overflow-x",
          "overflow-y"
        ],
        overscroll: [
          "overscroll-x",
          "overscroll-y"
        ],
        inset: [
          "inset-x",
          "inset-y",
          "start",
          "end",
          "top",
          "right",
          "bottom",
          "left"
        ],
        "inset-x": [
          "right",
          "left"
        ],
        "inset-y": [
          "top",
          "bottom"
        ],
        flex: [
          "basis",
          "grow",
          "shrink"
        ],
        gap: [
          "gap-x",
          "gap-y"
        ],
        p: [
          "px",
          "py",
          "ps",
          "pe",
          "pt",
          "pr",
          "pb",
          "pl"
        ],
        px: [
          "pr",
          "pl"
        ],
        py: [
          "pt",
          "pb"
        ],
        m: [
          "mx",
          "my",
          "ms",
          "me",
          "mt",
          "mr",
          "mb",
          "ml"
        ],
        mx: [
          "mr",
          "ml"
        ],
        my: [
          "mt",
          "mb"
        ],
        "font-size": [
          "leading"
        ],
        "fvn-normal": [
          "fvn-ordinal",
          "fvn-slashed-zero",
          "fvn-figure",
          "fvn-spacing",
          "fvn-fraction"
        ],
        "fvn-ordinal": [
          "fvn-normal"
        ],
        "fvn-slashed-zero": [
          "fvn-normal"
        ],
        "fvn-figure": [
          "fvn-normal"
        ],
        "fvn-spacing": [
          "fvn-normal"
        ],
        "fvn-fraction": [
          "fvn-normal"
        ],
        rounded: [
          "rounded-s",
          "rounded-e",
          "rounded-t",
          "rounded-r",
          "rounded-b",
          "rounded-l",
          "rounded-ss",
          "rounded-se",
          "rounded-ee",
          "rounded-es",
          "rounded-tl",
          "rounded-tr",
          "rounded-br",
          "rounded-bl"
        ],
        "rounded-s": [
          "rounded-ss",
          "rounded-es"
        ],
        "rounded-e": [
          "rounded-se",
          "rounded-ee"
        ],
        "rounded-t": [
          "rounded-tl",
          "rounded-tr"
        ],
        "rounded-r": [
          "rounded-tr",
          "rounded-br"
        ],
        "rounded-b": [
          "rounded-br",
          "rounded-bl"
        ],
        "rounded-l": [
          "rounded-tl",
          "rounded-bl"
        ],
        "border-spacing": [
          "border-spacing-x",
          "border-spacing-y"
        ],
        "border-w": [
          "border-w-s",
          "border-w-e",
          "border-w-t",
          "border-w-r",
          "border-w-b",
          "border-w-l"
        ],
        "border-w-x": [
          "border-w-r",
          "border-w-l"
        ],
        "border-w-y": [
          "border-w-t",
          "border-w-b"
        ],
        "border-color": [
          "border-color-t",
          "border-color-r",
          "border-color-b",
          "border-color-l"
        ],
        "border-color-x": [
          "border-color-r",
          "border-color-l"
        ],
        "border-color-y": [
          "border-color-t",
          "border-color-b"
        ],
        "scroll-m": [
          "scroll-mx",
          "scroll-my",
          "scroll-ms",
          "scroll-me",
          "scroll-mt",
          "scroll-mr",
          "scroll-mb",
          "scroll-ml"
        ],
        "scroll-mx": [
          "scroll-mr",
          "scroll-ml"
        ],
        "scroll-my": [
          "scroll-mt",
          "scroll-mb"
        ],
        "scroll-p": [
          "scroll-px",
          "scroll-py",
          "scroll-ps",
          "scroll-pe",
          "scroll-pt",
          "scroll-pr",
          "scroll-pb",
          "scroll-pl"
        ],
        "scroll-px": [
          "scroll-pr",
          "scroll-pl"
        ],
        "scroll-py": [
          "scroll-pt",
          "scroll-pb"
        ]
      },
      conflictingClassGroupModifiers: {
        "font-size": [
          "leading"
        ]
      }
    };
  }
  var S1e = s1e(O1e);
  function on(...t) {
    return S1e(nY(t));
  }
  const w1e = X3("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground hover:bg-primary/90",
        destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
        outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
        secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
        ghost: "hover:bg-accent hover:text-accent-foreground",
        link: "text-primary underline-offset-4 hover:underline"
      },
      size: {
        default: "h-10 px-4 py-2",
        sm: "h-9 rounded-md px-3",
        lg: "h-11 rounded-md px-8",
        icon: "h-10 w-10"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }), Ea = b.forwardRef(({ className: t, variant: e, size: n, asChild: r = false, ...i }, s) => {
    const o = r ? FSe : "button";
    return m.jsx(o, {
      className: on(w1e({
        variant: e,
        size: n,
        className: t
      })),
      ref: s,
      ...i
    });
  });
  Ea.displayName = "Button";
  const x1e = {
    store: {
      "document:document": {
        gridSize: 10,
        name: "",
        meta: {},
        id: "document:document",
        typeName: "document"
      },
      "pointer:pointer": {
        id: "pointer:pointer",
        typeName: "pointer",
        x: 0,
        y: 0,
        lastActivityTimestamp: 0,
        meta: {}
      },
      "page:page": {
        meta: {},
        id: "page:page",
        name: "Page 1",
        index: "a1",
        typeName: "page"
      },
      "camera:page:page": {
        x: 0,
        y: 0,
        z: 1,
        meta: {},
        id: "camera:page:page",
        typeName: "camera"
      },
      "instance_page_state:page:page": {
        editingShapeId: null,
        croppingShapeId: null,
        selectedShapeIds: [],
        hoveredShapeId: null,
        erasingShapeIds: [],
        hintingShapeIds: [],
        focusedGroupId: null,
        meta: {},
        id: "instance_page_state:page:page",
        pageId: "page:page",
        typeName: "instance_page_state"
      },
      "instance:instance": {
        followingUserId: null,
        opacityForNextShape: 1,
        stylesForNextShape: {},
        brush: null,
        scribble: null,
        cursor: {
          type: "default",
          rotation: 0
        },
        isFocusMode: false,
        exportBackground: true,
        isDebugMode: false,
        isToolLocked: false,
        screenBounds: {
          x: 0,
          y: 0,
          w: 720,
          h: 400
        },
        zoomBrush: null,
        isGridMode: false,
        isPenMode: false,
        chatMessage: "",
        isChatting: false,
        highlightedUserIds: [],
        canMoveCamera: true,
        isFocused: true,
        devicePixelRatio: 2,
        isCoarsePointer: false,
        isHoveringCanvas: false,
        openMenus: [],
        isChangingStyle: false,
        isReadonly: false,
        meta: {},
        id: "instance:instance",
        currentPageId: "page:page",
        typeName: "instance"
      }
    },
    schema: {
      schemaVersion: 1,
      storeVersion: 4,
      recordVersions: {
        asset: {
          version: 1,
          subTypeKey: "type",
          subTypeVersions: {
            image: 2,
            video: 2,
            bookmark: 0
          }
        },
        camera: {
          version: 1
        },
        document: {
          version: 2
        },
        instance: {
          version: 21
        },
        instance_page_state: {
          version: 5
        },
        page: {
          version: 1
        },
        shape: {
          version: 3,
          subTypeKey: "type",
          subTypeVersions: {
            group: 0,
            text: 1,
            bookmark: 1,
            draw: 1,
            geo: 7,
            note: 4,
            line: 1,
            frame: 0,
            arrow: 1,
            highlight: 0,
            embed: 4,
            image: 2,
            video: 1
          }
        },
        instance_presence: {
          version: 5
        },
        pointer: {
          version: 1
        }
      }
    }
  };
  function Pe(t, e, { checkForDefaultPrevented: n = true } = {}) {
    return function(i) {
      if (t == null ? void 0 : t(i), n === false || !i.defaultPrevented)
        return e == null ? void 0 : e(i);
    };
  }
  function b1e(t, e) {
    const n = b.createContext(e), r = (s) => {
      const { children: o, ...a } = s, l = b.useMemo(() => a, Object.values(a));
      return m.jsx(n.Provider, {
        value: l,
        children: o
      });
    };
    r.displayName = t + "Provider";
    function i(s) {
      const o = b.useContext(n);
      if (o)
        return o;
      if (e !== void 0)
        return e;
      throw new Error(`\`${s}\` must be used within \`${t}\``);
    }
    return [
      r,
      i
    ];
  }
  function Ps(t, e = []) {
    let n = [];
    function r(s, o) {
      const a = b.createContext(o), l = n.length;
      n = [
        ...n,
        o
      ];
      const c = (d) => {
        var _a3;
        const { scope: h, children: f, ...y } = d, g = ((_a3 = h == null ? void 0 : h[t]) == null ? void 0 : _a3[l]) || a, O = b.useMemo(() => y, Object.values(y));
        return m.jsx(g.Provider, {
          value: O,
          children: f
        });
      };
      c.displayName = s + "Provider";
      function u(d, h) {
        var _a3;
        const f = ((_a3 = h == null ? void 0 : h[t]) == null ? void 0 : _a3[l]) || a, y = b.useContext(f);
        if (y)
          return y;
        if (o !== void 0)
          return o;
        throw new Error(`\`${d}\` must be used within \`${s}\``);
      }
      return [
        c,
        u
      ];
    }
    const i = () => {
      const s = n.map((o) => b.createContext(o));
      return function(a) {
        const l = (a == null ? void 0 : a[t]) || s;
        return b.useMemo(() => ({
          [`__scope${t}`]: {
            ...a,
            [t]: l
          }
        }), [
          a,
          l
        ]);
      };
    };
    return i.scopeName = t, [
      r,
      k1e(i, ...e)
    ];
  }
  function k1e(...t) {
    const e = t[0];
    if (t.length === 1)
      return e;
    const n = () => {
      const r = t.map((i) => ({
        useScope: i(),
        scopeName: i.scopeName
      }));
      return function(s) {
        const o = r.reduce((a, { useScope: l, scopeName: c }) => {
          const d = l(s)[`__scope${c}`];
          return {
            ...a,
            ...d
          };
        }, {});
        return b.useMemo(() => ({
          [`__scope${e.scopeName}`]: o
        }), [
          o
        ]);
      };
    };
    return n.scopeName = e.scopeName, n;
  }
  var ta = (globalThis == null ? void 0 : globalThis.document) ? b.useLayoutEffect : () => {
  }, P1e = UD[" useId ".trim().toString()] || (() => {
  }), C1e = 0;
  function ja(t) {
    const [e, n] = b.useState(P1e());
    return ta(() => {
      t || n((r) => r ?? String(C1e++));
    }, [
      t
    ]), t || (e ? `radix-${e}` : "");
  }
  var _1e = UD[" useInsertionEffect ".trim().toString()] || ta;
  function Wl({ prop: t, defaultProp: e, onChange: n = () => {
  }, caller: r }) {
    const [i, s, o] = T1e({
      defaultProp: e,
      onChange: n
    }), a = t !== void 0, l = a ? t : i;
    {
      const u = b.useRef(t !== void 0);
      b.useEffect(() => {
        const d = u.current;
        d !== a && console.warn(`${r} is changing from ${d ? "controlled" : "uncontrolled"} to ${a ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`), u.current = a;
      }, [
        a,
        r
      ]);
    }
    const c = b.useCallback((u) => {
      var _a3;
      if (a) {
        const d = E1e(u) ? u(t) : u;
        d !== t && ((_a3 = o.current) == null ? void 0 : _a3.call(o, d));
      } else
        s(u);
    }, [
      a,
      t,
      s,
      o
    ]);
    return [
      l,
      c
    ];
  }
  function T1e({ defaultProp: t, onChange: e }) {
    const [n, r] = b.useState(t), i = b.useRef(n), s = b.useRef(e);
    return _1e(() => {
      s.current = e;
    }, [
      e
    ]), b.useEffect(() => {
      var _a3;
      i.current !== n && ((_a3 = s.current) == null ? void 0 : _a3.call(s, n), i.current = n);
    }, [
      n,
      i
    ]), [
      n,
      r,
      s
    ];
  }
  function E1e(t) {
    return typeof t == "function";
  }
  var I1e = [
    "a",
    "button",
    "div",
    "form",
    "h2",
    "h3",
    "img",
    "input",
    "label",
    "li",
    "nav",
    "ol",
    "p",
    "select",
    "span",
    "svg",
    "ul"
  ], rt = I1e.reduce((t, e) => {
    const n = nf(`Primitive.${e}`), r = b.forwardRef((i, s) => {
      const { asChild: o, ...a } = i, l = o ? n : e;
      return typeof window < "u" && (window[Symbol.for("radix-ui")] = true), m.jsx(l, {
        ...a,
        ref: s
      });
    });
    return r.displayName = `Primitive.${e}`, {
      ...t,
      [e]: r
    };
  }, {});
  function Z3(t, e) {
    t && jd.flushSync(() => t.dispatchEvent(e));
  }
  function ki(t) {
    const e = b.useRef(t);
    return b.useEffect(() => {
      e.current = t;
    }), b.useMemo(() => (...n) => {
      var _a3;
      return (_a3 = e.current) == null ? void 0 : _a3.call(e, ...n);
    }, []);
  }
  function $1e(t, e = globalThis == null ? void 0 : globalThis.document) {
    const n = ki(t);
    b.useEffect(() => {
      const r = (i) => {
        i.key === "Escape" && n(i);
      };
      return e.addEventListener("keydown", r, {
        capture: true
      }), () => e.removeEventListener("keydown", r, {
        capture: true
      });
    }, [
      n,
      e
    ]);
  }
  var A1e = "DismissableLayer", XA = "dismissableLayer.update", R1e = "dismissableLayer.pointerDownOutside", M1e = "dismissableLayer.focusOutside", Oz, lY = b.createContext({
    layers: /* @__PURE__ */ new Set(),
    layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
    branches: /* @__PURE__ */ new Set()
  }), Sm = b.forwardRef((t, e) => {
    const { disableOutsidePointerEvents: n = false, onEscapeKeyDown: r, onPointerDownOutside: i, onFocusOutside: s, onInteractOutside: o, onDismiss: a, ...l } = t, c = b.useContext(lY), [u, d] = b.useState(null), h = (u == null ? void 0 : u.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, f] = b.useState({}), y = Ht(e, (T) => d(T)), g = Array.from(c.layers), [O] = [
      ...c.layersWithOutsidePointerEventsDisabled
    ].slice(-1), S = g.indexOf(O), w = u ? g.indexOf(u) : -1, x = c.layersWithOutsidePointerEventsDisabled.size > 0, P = w >= S, C = L1e((T) => {
      const $ = T.target, N = [
        ...c.branches
      ].some((L) => L.contains($));
      !P || N || (i == null ? void 0 : i(T), o == null ? void 0 : o(T), T.defaultPrevented || (a == null ? void 0 : a()));
    }, h), _ = j1e((T) => {
      const $ = T.target;
      [
        ...c.branches
      ].some((L) => L.contains($)) || (s == null ? void 0 : s(T), o == null ? void 0 : o(T), T.defaultPrevented || (a == null ? void 0 : a()));
    }, h);
    return $1e((T) => {
      w === c.layers.size - 1 && (r == null ? void 0 : r(T), !T.defaultPrevented && a && (T.preventDefault(), a()));
    }, h), b.useEffect(() => {
      if (u)
        return n && (c.layersWithOutsidePointerEventsDisabled.size === 0 && (Oz = h.body.style.pointerEvents, h.body.style.pointerEvents = "none"), c.layersWithOutsidePointerEventsDisabled.add(u)), c.layers.add(u), Sz(), () => {
          n && c.layersWithOutsidePointerEventsDisabled.size === 1 && (h.body.style.pointerEvents = Oz);
        };
    }, [
      u,
      h,
      n,
      c
    ]), b.useEffect(() => () => {
      u && (c.layers.delete(u), c.layersWithOutsidePointerEventsDisabled.delete(u), Sz());
    }, [
      u,
      c
    ]), b.useEffect(() => {
      const T = () => f({});
      return document.addEventListener(XA, T), () => document.removeEventListener(XA, T);
    }, []), m.jsx(rt.div, {
      ...l,
      ref: y,
      style: {
        pointerEvents: x ? P ? "auto" : "none" : void 0,
        ...t.style
      },
      onFocusCapture: Pe(t.onFocusCapture, _.onFocusCapture),
      onBlurCapture: Pe(t.onBlurCapture, _.onBlurCapture),
      onPointerDownCapture: Pe(t.onPointerDownCapture, C.onPointerDownCapture)
    });
  });
  Sm.displayName = A1e;
  var D1e = "DismissableLayerBranch", cY = b.forwardRef((t, e) => {
    const n = b.useContext(lY), r = b.useRef(null), i = Ht(e, r);
    return b.useEffect(() => {
      const s = r.current;
      if (s)
        return n.branches.add(s), () => {
          n.branches.delete(s);
        };
    }, [
      n.branches
    ]), m.jsx(rt.div, {
      ...t,
      ref: i
    });
  });
  cY.displayName = D1e;
  function L1e(t, e = globalThis == null ? void 0 : globalThis.document) {
    const n = ki(t), r = b.useRef(false), i = b.useRef(() => {
    });
    return b.useEffect(() => {
      const s = (a) => {
        if (a.target && !r.current) {
          let l = function() {
            uY(R1e, n, c, {
              discrete: true
            });
          };
          const c = {
            originalEvent: a
          };
          a.pointerType === "touch" ? (e.removeEventListener("click", i.current), i.current = l, e.addEventListener("click", i.current, {
            once: true
          })) : l();
        } else
          e.removeEventListener("click", i.current);
        r.current = false;
      }, o = window.setTimeout(() => {
        e.addEventListener("pointerdown", s);
      }, 0);
      return () => {
        window.clearTimeout(o), e.removeEventListener("pointerdown", s), e.removeEventListener("click", i.current);
      };
    }, [
      e,
      n
    ]), {
      onPointerDownCapture: () => r.current = true
    };
  }
  function j1e(t, e = globalThis == null ? void 0 : globalThis.document) {
    const n = ki(t), r = b.useRef(false);
    return b.useEffect(() => {
      const i = (s) => {
        s.target && !r.current && uY(M1e, n, {
          originalEvent: s
        }, {
          discrete: false
        });
      };
      return e.addEventListener("focusin", i), () => e.removeEventListener("focusin", i);
    }, [
      e,
      n
    ]), {
      onFocusCapture: () => r.current = true,
      onBlurCapture: () => r.current = false
    };
  }
  function Sz() {
    const t = new CustomEvent(XA);
    document.dispatchEvent(t);
  }
  function uY(t, e, n, { discrete: r }) {
    const i = n.originalEvent.target, s = new CustomEvent(t, {
      bubbles: false,
      cancelable: true,
      detail: n
    });
    e && i.addEventListener(t, e, {
      once: true
    }), r ? Z3(i, s) : i.dispatchEvent(s);
  }
  var N1e = Sm, Q1e = cY, oE = "focusScope.autoFocusOnMount", aE = "focusScope.autoFocusOnUnmount", wz = {
    bubbles: false,
    cancelable: true
  }, z1e = "FocusScope", yC = b.forwardRef((t, e) => {
    const { loop: n = false, trapped: r = false, onMountAutoFocus: i, onUnmountAutoFocus: s, ...o } = t, [a, l] = b.useState(null), c = ki(i), u = ki(s), d = b.useRef(null), h = Ht(e, (g) => l(g)), f = b.useRef({
      paused: false,
      pause() {
        this.paused = true;
      },
      resume() {
        this.paused = false;
      }
    }).current;
    b.useEffect(() => {
      if (r) {
        let g = function(x) {
          if (f.paused || !a)
            return;
          const P = x.target;
          a.contains(P) ? d.current = P : Eu(d.current, {
            select: true
          });
        }, O = function(x) {
          if (f.paused || !a)
            return;
          const P = x.relatedTarget;
          P !== null && (a.contains(P) || Eu(d.current, {
            select: true
          }));
        }, S = function(x) {
          if (document.activeElement === document.body)
            for (const C of x)
              C.removedNodes.length > 0 && Eu(a);
        };
        document.addEventListener("focusin", g), document.addEventListener("focusout", O);
        const w = new MutationObserver(S);
        return a && w.observe(a, {
          childList: true,
          subtree: true
        }), () => {
          document.removeEventListener("focusin", g), document.removeEventListener("focusout", O), w.disconnect();
        };
      }
    }, [
      r,
      a,
      f.paused
    ]), b.useEffect(() => {
      if (a) {
        bz.add(f);
        const g = document.activeElement;
        if (!a.contains(g)) {
          const S = new CustomEvent(oE, wz);
          a.addEventListener(oE, c), a.dispatchEvent(S), S.defaultPrevented || (F1e(W1e(dY(a)), {
            select: true
          }), document.activeElement === g && Eu(a));
        }
        return () => {
          a.removeEventListener(oE, c), setTimeout(() => {
            const S = new CustomEvent(aE, wz);
            a.addEventListener(aE, u), a.dispatchEvent(S), S.defaultPrevented || Eu(g ?? document.body, {
              select: true
            }), a.removeEventListener(aE, u), bz.remove(f);
          }, 0);
        };
      }
    }, [
      a,
      c,
      u,
      f
    ]);
    const y = b.useCallback((g) => {
      if (!n && !r || f.paused)
        return;
      const O = g.key === "Tab" && !g.altKey && !g.ctrlKey && !g.metaKey, S = document.activeElement;
      if (O && S) {
        const w = g.currentTarget, [x, P] = B1e(w);
        x && P ? !g.shiftKey && S === P ? (g.preventDefault(), n && Eu(x, {
          select: true
        })) : g.shiftKey && S === x && (g.preventDefault(), n && Eu(P, {
          select: true
        })) : S === w && g.preventDefault();
      }
    }, [
      n,
      r,
      f.paused
    ]);
    return m.jsx(rt.div, {
      tabIndex: -1,
      ...o,
      ref: h,
      onKeyDown: y
    });
  });
  yC.displayName = z1e;
  function F1e(t, { select: e = false } = {}) {
    const n = document.activeElement;
    for (const r of t)
      if (Eu(r, {
        select: e
      }), document.activeElement !== n)
        return;
  }
  function B1e(t) {
    const e = dY(t), n = xz(e, t), r = xz(e.reverse(), t);
    return [
      n,
      r
    ];
  }
  function dY(t) {
    const e = [], n = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
      acceptNode: (r) => {
        const i = r.tagName === "INPUT" && r.type === "hidden";
        return r.disabled || r.hidden || i ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
      }
    });
    for (; n.nextNode(); )
      e.push(n.currentNode);
    return e;
  }
  function xz(t, e) {
    for (const n of t)
      if (!U1e(n, {
        upTo: e
      }))
        return n;
  }
  function U1e(t, { upTo: e }) {
    if (getComputedStyle(t).visibility === "hidden")
      return true;
    for (; t; ) {
      if (e !== void 0 && t === e)
        return false;
      if (getComputedStyle(t).display === "none")
        return true;
      t = t.parentElement;
    }
    return false;
  }
  function V1e(t) {
    return t instanceof HTMLInputElement && "select" in t;
  }
  function Eu(t, { select: e = false } = {}) {
    if (t && t.focus) {
      const n = document.activeElement;
      t.focus({
        preventScroll: true
      }), t !== n && V1e(t) && e && t.select();
    }
  }
  var bz = X1e();
  function X1e() {
    let t = [];
    return {
      add(e) {
        const n = t[0];
        e !== n && (n == null ? void 0 : n.pause()), t = kz(t, e), t.unshift(e);
      },
      remove(e) {
        var _a3;
        t = kz(t, e), (_a3 = t[0]) == null ? void 0 : _a3.resume();
      }
    };
  }
  function kz(t, e) {
    const n = [
      ...t
    ], r = n.indexOf(e);
    return r !== -1 && n.splice(r, 1), n;
  }
  function W1e(t) {
    return t.filter((e) => e.tagName !== "A");
  }
  var Z1e = "Portal", ZO = b.forwardRef((t, e) => {
    var _a3;
    const { container: n, ...r } = t, [i, s] = b.useState(false);
    ta(() => s(true), []);
    const o = n || i && ((_a3 = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a3.body);
    return o ? qH.createPortal(m.jsx(rt.div, {
      ...r,
      ref: e
    }), o) : null;
  });
  ZO.displayName = Z1e;
  function H1e(t, e) {
    return b.useReducer((n, r) => e[n][r] ?? n, t);
  }
  var uo = (t) => {
    const { present: e, children: n } = t, r = Y1e(e), i = typeof n == "function" ? n({
      present: r.isPresent
    }) : b.Children.only(n), s = Ht(r.ref, G1e(i));
    return typeof n == "function" || r.isPresent ? b.cloneElement(i, {
      ref: s
    }) : null;
  };
  uo.displayName = "Presence";
  function Y1e(t) {
    const [e, n] = b.useState(), r = b.useRef(null), i = b.useRef(t), s = b.useRef("none"), o = t ? "mounted" : "unmounted", [a, l] = H1e(o, {
      mounted: {
        UNMOUNT: "unmounted",
        ANIMATION_OUT: "unmountSuspended"
      },
      unmountSuspended: {
        MOUNT: "mounted",
        ANIMATION_END: "unmounted"
      },
      unmounted: {
        MOUNT: "mounted"
      }
    });
    return b.useEffect(() => {
      const c = sw(r.current);
      s.current = a === "mounted" ? c : "none";
    }, [
      a
    ]), ta(() => {
      const c = r.current, u = i.current;
      if (u !== t) {
        const h = s.current, f = sw(c);
        t ? l("MOUNT") : f === "none" || (c == null ? void 0 : c.display) === "none" ? l("UNMOUNT") : l(u && h !== f ? "ANIMATION_OUT" : "UNMOUNT"), i.current = t;
      }
    }, [
      t,
      l
    ]), ta(() => {
      if (e) {
        let c;
        const u = e.ownerDocument.defaultView ?? window, d = (f) => {
          const g = sw(r.current).includes(CSS.escape(f.animationName));
          if (f.target === e && g && (l("ANIMATION_END"), !i.current)) {
            const O = e.style.animationFillMode;
            e.style.animationFillMode = "forwards", c = u.setTimeout(() => {
              e.style.animationFillMode === "forwards" && (e.style.animationFillMode = O);
            });
          }
        }, h = (f) => {
          f.target === e && (s.current = sw(r.current));
        };
        return e.addEventListener("animationstart", h), e.addEventListener("animationcancel", d), e.addEventListener("animationend", d), () => {
          u.clearTimeout(c), e.removeEventListener("animationstart", h), e.removeEventListener("animationcancel", d), e.removeEventListener("animationend", d);
        };
      } else
        l("ANIMATION_END");
    }, [
      e,
      l
    ]), {
      isPresent: [
        "mounted",
        "unmountSuspended"
      ].includes(a),
      ref: b.useCallback((c) => {
        r.current = c ? getComputedStyle(c) : null, n(c);
      }, [])
    };
  }
  function sw(t) {
    return (t == null ? void 0 : t.animationName) || "none";
  }
  function G1e(t) {
    var _a3, _b3;
    let e = (_a3 = Object.getOwnPropertyDescriptor(t.props, "ref")) == null ? void 0 : _a3.get, n = e && "isReactWarning" in e && e.isReactWarning;
    return n ? t.ref : (e = (_b3 = Object.getOwnPropertyDescriptor(t, "ref")) == null ? void 0 : _b3.get, n = e && "isReactWarning" in e && e.isReactWarning, n ? t.props.ref : t.props.ref || t.ref);
  }
  var lE = 0;
  function H3() {
    b.useEffect(() => {
      const t = document.querySelectorAll("[data-radix-focus-guard]");
      return document.body.insertAdjacentElement("afterbegin", t[0] ?? Pz()), document.body.insertAdjacentElement("beforeend", t[1] ?? Pz()), lE++, () => {
        lE === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((e) => e.remove()), lE--;
      };
    }, []);
  }
  function Pz() {
    const t = document.createElement("span");
    return t.setAttribute("data-radix-focus-guard", ""), t.tabIndex = 0, t.style.outline = "none", t.style.opacity = "0", t.style.position = "fixed", t.style.pointerEvents = "none", t;
  }
  var pi = function() {
    return pi = Object.assign || function(e) {
      for (var n, r = 1, i = arguments.length; r < i; r++) {
        n = arguments[r];
        for (var s in n)
          Object.prototype.hasOwnProperty.call(n, s) && (e[s] = n[s]);
      }
      return e;
    }, pi.apply(this, arguments);
  };
  function Y3(t, e) {
    var n = {};
    for (var r in t)
      Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
    if (t != null && typeof Object.getOwnPropertySymbols == "function")
      for (var i = 0, r = Object.getOwnPropertySymbols(t); i < r.length; i++)
        e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
    return n;
  }
  function hY(t, e, n) {
    if (n || arguments.length === 2)
      for (var r = 0, i = e.length, s; r < i; r++)
        (s || !(r in e)) && (s || (s = Array.prototype.slice.call(e, 0, r)), s[r] = e[r]);
    return t.concat(s || Array.prototype.slice.call(e));
  }
  var W0 = "right-scroll-bar-position", Z0 = "width-before-scroll-bar", q1e = "with-scroll-bars-hidden", K1e = "--removed-body-scroll-bar-size";
  function cE(t, e) {
    return typeof t == "function" ? t(e) : t && (t.current = e), t;
  }
  function J1e(t, e) {
    var n = b.useState(function() {
      return {
        value: t,
        callback: e,
        facade: {
          get current() {
            return n.value;
          },
          set current(r) {
            var i = n.value;
            i !== r && (n.value = r, n.callback(r, i));
          }
        }
      };
    })[0];
    return n.callback = e, n.facade;
  }
  var ewe = typeof window < "u" ? b.useLayoutEffect : b.useEffect, Cz = /* @__PURE__ */ new WeakMap();
  function fY(t, e) {
    var n = J1e(e || null, function(r) {
      return t.forEach(function(i) {
        return cE(i, r);
      });
    });
    return ewe(function() {
      var r = Cz.get(n);
      if (r) {
        var i = new Set(r), s = new Set(t), o = n.current;
        i.forEach(function(a) {
          s.has(a) || cE(a, null);
        }), s.forEach(function(a) {
          i.has(a) || cE(a, o);
        });
      }
      Cz.set(n, t);
    }, [
      t
    ]), n;
  }
  function twe(t) {
    return t;
  }
  function nwe(t, e) {
    e === void 0 && (e = twe);
    var n = [], r = false, i = {
      read: function() {
        if (r)
          throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
        return n.length ? n[n.length - 1] : t;
      },
      useMedium: function(s) {
        var o = e(s, r);
        return n.push(o), function() {
          n = n.filter(function(a) {
            return a !== o;
          });
        };
      },
      assignSyncMedium: function(s) {
        for (r = true; n.length; ) {
          var o = n;
          n = [], o.forEach(s);
        }
        n = {
          push: function(a) {
            return s(a);
          },
          filter: function() {
            return n;
          }
        };
      },
      assignMedium: function(s) {
        r = true;
        var o = [];
        if (n.length) {
          var a = n;
          n = [], a.forEach(s), o = n;
        }
        var l = function() {
          var u = o;
          o = [], u.forEach(s);
        }, c = function() {
          return Promise.resolve().then(l);
        };
        c(), n = {
          push: function(u) {
            o.push(u), c();
          },
          filter: function(u) {
            return o = o.filter(u), n;
          }
        };
      }
    };
    return i;
  }
  function pY(t) {
    t === void 0 && (t = {});
    var e = nwe(null);
    return e.options = pi({
      async: true,
      ssr: false
    }, t), e;
  }
  var gY = function(t) {
    var e = t.sideCar, n = Y3(t, [
      "sideCar"
    ]);
    if (!e)
      throw new Error("Sidecar: please provide `sideCar` property to import the right car");
    var r = e.read();
    if (!r)
      throw new Error("Sidecar medium not found");
    return b.createElement(r, pi({}, n));
  };
  gY.isSideCarExport = true;
  function mY(t, e) {
    return t.useMedium(e), gY;
  }
  var yY = pY(), uE = function() {
  }, vC = b.forwardRef(function(t, e) {
    var n = b.useRef(null), r = b.useState({
      onScrollCapture: uE,
      onWheelCapture: uE,
      onTouchMoveCapture: uE
    }), i = r[0], s = r[1], o = t.forwardProps, a = t.children, l = t.className, c = t.removeScrollBar, u = t.enabled, d = t.shards, h = t.sideCar, f = t.noRelative, y = t.noIsolation, g = t.inert, O = t.allowPinchZoom, S = t.as, w = S === void 0 ? "div" : S, x = t.gapMode, P = Y3(t, [
      "forwardProps",
      "children",
      "className",
      "removeScrollBar",
      "enabled",
      "shards",
      "sideCar",
      "noRelative",
      "noIsolation",
      "inert",
      "allowPinchZoom",
      "as",
      "gapMode"
    ]), C = h, _ = fY([
      n,
      e
    ]), T = pi(pi({}, P), i);
    return b.createElement(b.Fragment, null, u && b.createElement(C, {
      sideCar: yY,
      removeScrollBar: c,
      shards: d,
      noRelative: f,
      noIsolation: y,
      inert: g,
      setCallbacks: s,
      allowPinchZoom: !!O,
      lockRef: n,
      gapMode: x
    }), o ? b.cloneElement(b.Children.only(a), pi(pi({}, T), {
      ref: _
    })) : b.createElement(w, pi({}, T, {
      className: l,
      ref: _
    }), a));
  });
  vC.defaultProps = {
    enabled: true,
    removeScrollBar: true,
    inert: false
  };
  vC.classNames = {
    fullWidth: Z0,
    zeroRight: W0
  };
  var _z, rwe = function() {
    if (_z)
      return _z;
    if (typeof __webpack_nonce__ < "u")
      return __webpack_nonce__;
  };
  function iwe() {
    if (!document)
      return null;
    var t = document.createElement("style");
    t.type = "text/css";
    var e = rwe();
    return e && t.setAttribute("nonce", e), t;
  }
  function swe(t, e) {
    t.styleSheet ? t.styleSheet.cssText = e : t.appendChild(document.createTextNode(e));
  }
  function owe(t) {
    var e = document.head || document.getElementsByTagName("head")[0];
    e.appendChild(t);
  }
  var awe = function() {
    var t = 0, e = null;
    return {
      add: function(n) {
        t == 0 && (e = iwe()) && (swe(e, n), owe(e)), t++;
      },
      remove: function() {
        t--, !t && e && (e.parentNode && e.parentNode.removeChild(e), e = null);
      }
    };
  }, lwe = function() {
    var t = awe();
    return function(e, n) {
      b.useEffect(function() {
        return t.add(e), function() {
          t.remove();
        };
      }, [
        e && n
      ]);
    };
  }, G3 = function() {
    var t = lwe(), e = function(n) {
      var r = n.styles, i = n.dynamic;
      return t(r, i), null;
    };
    return e;
  }, cwe = {
    left: 0,
    top: 0,
    right: 0,
    gap: 0
  }, dE = function(t) {
    return parseInt(t || "", 10) || 0;
  }, uwe = function(t) {
    var e = window.getComputedStyle(document.body), n = e[t === "padding" ? "paddingLeft" : "marginLeft"], r = e[t === "padding" ? "paddingTop" : "marginTop"], i = e[t === "padding" ? "paddingRight" : "marginRight"];
    return [
      dE(n),
      dE(r),
      dE(i)
    ];
  }, dwe = function(t) {
    if (t === void 0 && (t = "margin"), typeof window > "u")
      return cwe;
    var e = uwe(t), n = document.documentElement.clientWidth, r = window.innerWidth;
    return {
      left: e[0],
      top: e[1],
      right: e[2],
      gap: Math.max(0, r - n + e[2] - e[0])
    };
  }, hwe = G3(), fg = "data-scroll-locked", fwe = function(t, e, n, r) {
    var i = t.left, s = t.top, o = t.right, a = t.gap;
    return n === void 0 && (n = "margin"), `
  .`.concat(q1e, ` {
   overflow: hidden `).concat(r, `;
   padding-right: `).concat(a, "px ").concat(r, `;
  }
  body[`).concat(fg, `] {
    overflow: hidden `).concat(r, `;
    overscroll-behavior: contain;
    `).concat([
      e && "position: relative ".concat(r, ";"),
      n === "margin" && `
    padding-left: `.concat(i, `px;
    padding-top: `).concat(s, `px;
    padding-right: `).concat(o, `px;
    margin-left:0;
    margin-top:0;
    margin-right: `).concat(a, "px ").concat(r, `;
    `),
      n === "padding" && "padding-right: ".concat(a, "px ").concat(r, ";")
    ].filter(Boolean).join(""), `
  }
  
  .`).concat(W0, ` {
    right: `).concat(a, "px ").concat(r, `;
  }
  
  .`).concat(Z0, ` {
    margin-right: `).concat(a, "px ").concat(r, `;
  }
  
  .`).concat(W0, " .").concat(W0, ` {
    right: 0 `).concat(r, `;
  }
  
  .`).concat(Z0, " .").concat(Z0, ` {
    margin-right: 0 `).concat(r, `;
  }
  
  body[`).concat(fg, `] {
    `).concat(K1e, ": ").concat(a, `px;
  }
`);
  }, Tz = function() {
    var t = parseInt(document.body.getAttribute(fg) || "0", 10);
    return isFinite(t) ? t : 0;
  }, pwe = function() {
    b.useEffect(function() {
      return document.body.setAttribute(fg, (Tz() + 1).toString()), function() {
        var t = Tz() - 1;
        t <= 0 ? document.body.removeAttribute(fg) : document.body.setAttribute(fg, t.toString());
      };
    }, []);
  }, vY = function(t) {
    var e = t.noRelative, n = t.noImportant, r = t.gapMode, i = r === void 0 ? "margin" : r;
    pwe();
    var s = b.useMemo(function() {
      return dwe(i);
    }, [
      i
    ]);
    return b.createElement(hwe, {
      styles: fwe(s, !e, i, n ? "" : "!important")
    });
  }, WA = false;
  if (typeof window < "u")
    try {
      var ow = Object.defineProperty({}, "passive", {
        get: function() {
          return WA = true, true;
        }
      });
      window.addEventListener("test", ow, ow), window.removeEventListener("test", ow, ow);
    } catch {
      WA = false;
    }
  var lp = WA ? {
    passive: false
  } : false, gwe = function(t) {
    return t.tagName === "TEXTAREA";
  }, OY = function(t, e) {
    if (!(t instanceof Element))
      return false;
    var n = window.getComputedStyle(t);
    return n[e] !== "hidden" && !(n.overflowY === n.overflowX && !gwe(t) && n[e] === "visible");
  }, mwe = function(t) {
    return OY(t, "overflowY");
  }, ywe = function(t) {
    return OY(t, "overflowX");
  }, Ez = function(t, e) {
    var n = e.ownerDocument, r = e;
    do {
      typeof ShadowRoot < "u" && r instanceof ShadowRoot && (r = r.host);
      var i = SY(t, r);
      if (i) {
        var s = wY(t, r), o = s[1], a = s[2];
        if (o > a)
          return true;
      }
      r = r.parentNode;
    } while (r && r !== n.body);
    return false;
  }, vwe = function(t) {
    var e = t.scrollTop, n = t.scrollHeight, r = t.clientHeight;
    return [
      e,
      n,
      r
    ];
  }, Owe = function(t) {
    var e = t.scrollLeft, n = t.scrollWidth, r = t.clientWidth;
    return [
      e,
      n,
      r
    ];
  }, SY = function(t, e) {
    return t === "v" ? mwe(e) : ywe(e);
  }, wY = function(t, e) {
    return t === "v" ? vwe(e) : Owe(e);
  }, Swe = function(t, e) {
    return t === "h" && e === "rtl" ? -1 : 1;
  }, wwe = function(t, e, n, r, i) {
    var s = Swe(t, window.getComputedStyle(e).direction), o = s * r, a = n.target, l = e.contains(a), c = false, u = o > 0, d = 0, h = 0;
    do {
      if (!a)
        break;
      var f = wY(t, a), y = f[0], g = f[1], O = f[2], S = g - O - s * y;
      (y || S) && SY(t, a) && (d += S, h += y);
      var w = a.parentNode;
      a = w && w.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? w.host : w;
    } while (!l && a !== document.body || l && (e.contains(a) || e === a));
    return (u && (i && Math.abs(d) < 1 || !i && o > d) || !u && (i && Math.abs(h) < 1 || !i && -o > h)) && (c = true), c;
  }, aw = function(t) {
    return "changedTouches" in t ? [
      t.changedTouches[0].clientX,
      t.changedTouches[0].clientY
    ] : [
      0,
      0
    ];
  }, Iz = function(t) {
    return [
      t.deltaX,
      t.deltaY
    ];
  }, $z = function(t) {
    return t && "current" in t ? t.current : t;
  }, xwe = function(t, e) {
    return t[0] === e[0] && t[1] === e[1];
  }, bwe = function(t) {
    return `
  .block-interactivity-`.concat(t, ` {pointer-events: none;}
  .allow-interactivity-`).concat(t, ` {pointer-events: all;}
`);
  }, kwe = 0, cp = [];
  function Pwe(t) {
    var e = b.useRef([]), n = b.useRef([
      0,
      0
    ]), r = b.useRef(), i = b.useState(kwe++)[0], s = b.useState(G3)[0], o = b.useRef(t);
    b.useEffect(function() {
      o.current = t;
    }, [
      t
    ]), b.useEffect(function() {
      if (t.inert) {
        document.body.classList.add("block-interactivity-".concat(i));
        var g = hY([
          t.lockRef.current
        ], (t.shards || []).map($z), true).filter(Boolean);
        return g.forEach(function(O) {
          return O.classList.add("allow-interactivity-".concat(i));
        }), function() {
          document.body.classList.remove("block-interactivity-".concat(i)), g.forEach(function(O) {
            return O.classList.remove("allow-interactivity-".concat(i));
          });
        };
      }
    }, [
      t.inert,
      t.lockRef.current,
      t.shards
    ]);
    var a = b.useCallback(function(g, O) {
      if ("touches" in g && g.touches.length === 2 || g.type === "wheel" && g.ctrlKey)
        return !o.current.allowPinchZoom;
      var S = aw(g), w = n.current, x = "deltaX" in g ? g.deltaX : w[0] - S[0], P = "deltaY" in g ? g.deltaY : w[1] - S[1], C, _ = g.target, T = Math.abs(x) > Math.abs(P) ? "h" : "v";
      if ("touches" in g && T === "h" && _.type === "range")
        return false;
      var $ = Ez(T, _);
      if (!$)
        return true;
      if ($ ? C = T : (C = T === "v" ? "h" : "v", $ = Ez(T, _)), !$)
        return false;
      if (!r.current && "changedTouches" in g && (x || P) && (r.current = C), !C)
        return true;
      var N = r.current || C;
      return wwe(N, O, g, N === "h" ? x : P, true);
    }, []), l = b.useCallback(function(g) {
      var O = g;
      if (!(!cp.length || cp[cp.length - 1] !== s)) {
        var S = "deltaY" in O ? Iz(O) : aw(O), w = e.current.filter(function(C) {
          return C.name === O.type && (C.target === O.target || O.target === C.shadowParent) && xwe(C.delta, S);
        })[0];
        if (w && w.should) {
          O.cancelable && O.preventDefault();
          return;
        }
        if (!w) {
          var x = (o.current.shards || []).map($z).filter(Boolean).filter(function(C) {
            return C.contains(O.target);
          }), P = x.length > 0 ? a(O, x[0]) : !o.current.noIsolation;
          P && O.cancelable && O.preventDefault();
        }
      }
    }, []), c = b.useCallback(function(g, O, S, w) {
      var x = {
        name: g,
        delta: O,
        target: S,
        should: w,
        shadowParent: Cwe(S)
      };
      e.current.push(x), setTimeout(function() {
        e.current = e.current.filter(function(P) {
          return P !== x;
        });
      }, 1);
    }, []), u = b.useCallback(function(g) {
      n.current = aw(g), r.current = void 0;
    }, []), d = b.useCallback(function(g) {
      c(g.type, Iz(g), g.target, a(g, t.lockRef.current));
    }, []), h = b.useCallback(function(g) {
      c(g.type, aw(g), g.target, a(g, t.lockRef.current));
    }, []);
    b.useEffect(function() {
      return cp.push(s), t.setCallbacks({
        onScrollCapture: d,
        onWheelCapture: d,
        onTouchMoveCapture: h
      }), document.addEventListener("wheel", l, lp), document.addEventListener("touchmove", l, lp), document.addEventListener("touchstart", u, lp), function() {
        cp = cp.filter(function(g) {
          return g !== s;
        }), document.removeEventListener("wheel", l, lp), document.removeEventListener("touchmove", l, lp), document.removeEventListener("touchstart", u, lp);
      };
    }, []);
    var f = t.removeScrollBar, y = t.inert;
    return b.createElement(b.Fragment, null, y ? b.createElement(s, {
      styles: bwe(i)
    }) : null, f ? b.createElement(vY, {
      noRelative: t.noRelative,
      gapMode: t.gapMode
    }) : null);
  }
  function Cwe(t) {
    for (var e = null; t !== null; )
      t instanceof ShadowRoot && (e = t.host, t = t.host), t = t.parentNode;
    return e;
  }
  const _we = mY(yY, Pwe);
  var xY = b.forwardRef(function(t, e) {
    return b.createElement(vC, pi({}, t, {
      ref: e,
      sideCar: _we
    }));
  });
  xY.classNames = vC.classNames;
  const q3 = xY;
  var Twe = function(t) {
    if (typeof document > "u")
      return null;
    var e = Array.isArray(t) ? t[0] : t;
    return e.ownerDocument.body;
  }, up = /* @__PURE__ */ new WeakMap(), lw = /* @__PURE__ */ new WeakMap(), cw = {}, hE = 0, bY = function(t) {
    return t && (t.host || bY(t.parentNode));
  }, Ewe = function(t, e) {
    return e.map(function(n) {
      if (t.contains(n))
        return n;
      var r = bY(n);
      return r && t.contains(r) ? r : (console.error("aria-hidden", n, "in not contained inside", t, ". Doing nothing"), null);
    }).filter(function(n) {
      return !!n;
    });
  }, Iwe = function(t, e, n, r) {
    var i = Ewe(e, Array.isArray(t) ? t : [
      t
    ]);
    cw[n] || (cw[n] = /* @__PURE__ */ new WeakMap());
    var s = cw[n], o = [], a = /* @__PURE__ */ new Set(), l = new Set(i), c = function(d) {
      !d || a.has(d) || (a.add(d), c(d.parentNode));
    };
    i.forEach(c);
    var u = function(d) {
      !d || l.has(d) || Array.prototype.forEach.call(d.children, function(h) {
        if (a.has(h))
          u(h);
        else
          try {
            var f = h.getAttribute(r), y = f !== null && f !== "false", g = (up.get(h) || 0) + 1, O = (s.get(h) || 0) + 1;
            up.set(h, g), s.set(h, O), o.push(h), g === 1 && y && lw.set(h, true), O === 1 && h.setAttribute(n, "true"), y || h.setAttribute(r, "true");
          } catch (S) {
            console.error("aria-hidden: cannot operate on ", h, S);
          }
      });
    };
    return u(e), a.clear(), hE++, function() {
      o.forEach(function(d) {
        var h = up.get(d) - 1, f = s.get(d) - 1;
        up.set(d, h), s.set(d, f), h || (lw.has(d) || d.removeAttribute(r), lw.delete(d)), f || d.removeAttribute(n);
      }), hE--, hE || (up = /* @__PURE__ */ new WeakMap(), up = /* @__PURE__ */ new WeakMap(), lw = /* @__PURE__ */ new WeakMap(), cw = {});
    };
  }, OC = function(t, e, n) {
    n === void 0 && (n = "data-aria-hidden");
    var r = Array.from(Array.isArray(t) ? t : [
      t
    ]), i = e || Twe(t);
    return i ? (r.push.apply(r, Array.from(i.querySelectorAll("[aria-live], script"))), Iwe(r, i, n, "aria-hidden")) : function() {
      return null;
    };
  }, SC = "Dialog", [kY, Iot] = Ps(SC), [$we, Ga] = kY(SC), PY = (t) => {
    const { __scopeDialog: e, children: n, open: r, defaultOpen: i, onOpenChange: s, modal: o = true } = t, a = b.useRef(null), l = b.useRef(null), [c, u] = Wl({
      prop: r,
      defaultProp: i ?? false,
      onChange: s,
      caller: SC
    });
    return m.jsx($we, {
      scope: e,
      triggerRef: a,
      contentRef: l,
      contentId: ja(),
      titleId: ja(),
      descriptionId: ja(),
      open: c,
      onOpenChange: u,
      onOpenToggle: b.useCallback(() => u((d) => !d), [
        u
      ]),
      modal: o,
      children: n
    });
  };
  PY.displayName = SC;
  var CY = "DialogTrigger", _Y = b.forwardRef((t, e) => {
    const { __scopeDialog: n, ...r } = t, i = Ga(CY, n), s = Ht(e, i.triggerRef);
    return m.jsx(rt.button, {
      type: "button",
      "aria-haspopup": "dialog",
      "aria-expanded": i.open,
      "aria-controls": i.contentId,
      "data-state": n5(i.open),
      ...r,
      ref: s,
      onClick: Pe(t.onClick, i.onOpenToggle)
    });
  });
  _Y.displayName = CY;
  var K3 = "DialogPortal", [Awe, TY] = kY(K3, {
    forceMount: void 0
  }), EY = (t) => {
    const { __scopeDialog: e, forceMount: n, children: r, container: i } = t, s = Ga(K3, e);
    return m.jsx(Awe, {
      scope: e,
      forceMount: n,
      children: b.Children.map(r, (o) => m.jsx(uo, {
        present: n || s.open,
        children: m.jsx(ZO, {
          asChild: true,
          container: i,
          children: o
        })
      }))
    });
  };
  EY.displayName = K3;
  var uk = "DialogOverlay", IY = b.forwardRef((t, e) => {
    const n = TY(uk, t.__scopeDialog), { forceMount: r = n.forceMount, ...i } = t, s = Ga(uk, t.__scopeDialog);
    return s.modal ? m.jsx(uo, {
      present: r || s.open,
      children: m.jsx(Mwe, {
        ...i,
        ref: e
      })
    }) : null;
  });
  IY.displayName = uk;
  var Rwe = nf("DialogOverlay.RemoveScroll"), Mwe = b.forwardRef((t, e) => {
    const { __scopeDialog: n, ...r } = t, i = Ga(uk, n);
    return m.jsx(q3, {
      as: Rwe,
      allowPinchZoom: true,
      shards: [
        i.contentRef
      ],
      children: m.jsx(rt.div, {
        "data-state": n5(i.open),
        ...r,
        ref: e,
        style: {
          pointerEvents: "auto",
          ...r.style
        }
      })
    });
  }), rf = "DialogContent", $Y = b.forwardRef((t, e) => {
    const n = TY(rf, t.__scopeDialog), { forceMount: r = n.forceMount, ...i } = t, s = Ga(rf, t.__scopeDialog);
    return m.jsx(uo, {
      present: r || s.open,
      children: s.modal ? m.jsx(Dwe, {
        ...i,
        ref: e
      }) : m.jsx(Lwe, {
        ...i,
        ref: e
      })
    });
  });
  $Y.displayName = rf;
  var Dwe = b.forwardRef((t, e) => {
    const n = Ga(rf, t.__scopeDialog), r = b.useRef(null), i = Ht(e, n.contentRef, r);
    return b.useEffect(() => {
      const s = r.current;
      if (s)
        return OC(s);
    }, []), m.jsx(AY, {
      ...t,
      ref: i,
      trapFocus: n.open,
      disableOutsidePointerEvents: true,
      onCloseAutoFocus: Pe(t.onCloseAutoFocus, (s) => {
        var _a3;
        s.preventDefault(), (_a3 = n.triggerRef.current) == null ? void 0 : _a3.focus();
      }),
      onPointerDownOutside: Pe(t.onPointerDownOutside, (s) => {
        const o = s.detail.originalEvent, a = o.button === 0 && o.ctrlKey === true;
        (o.button === 2 || a) && s.preventDefault();
      }),
      onFocusOutside: Pe(t.onFocusOutside, (s) => s.preventDefault())
    });
  }), Lwe = b.forwardRef((t, e) => {
    const n = Ga(rf, t.__scopeDialog), r = b.useRef(false), i = b.useRef(false);
    return m.jsx(AY, {
      ...t,
      ref: e,
      trapFocus: false,
      disableOutsidePointerEvents: false,
      onCloseAutoFocus: (s) => {
        var _a3, _b3;
        (_a3 = t.onCloseAutoFocus) == null ? void 0 : _a3.call(t, s), s.defaultPrevented || (r.current || ((_b3 = n.triggerRef.current) == null ? void 0 : _b3.focus()), s.preventDefault()), r.current = false, i.current = false;
      },
      onInteractOutside: (s) => {
        var _a3, _b3;
        (_a3 = t.onInteractOutside) == null ? void 0 : _a3.call(t, s), s.defaultPrevented || (r.current = true, s.detail.originalEvent.type === "pointerdown" && (i.current = true));
        const o = s.target;
        ((_b3 = n.triggerRef.current) == null ? void 0 : _b3.contains(o)) && s.preventDefault(), s.detail.originalEvent.type === "focusin" && i.current && s.preventDefault();
      }
    });
  }), AY = b.forwardRef((t, e) => {
    const { __scopeDialog: n, trapFocus: r, onOpenAutoFocus: i, onCloseAutoFocus: s, ...o } = t, a = Ga(rf, n), l = b.useRef(null), c = Ht(e, l);
    return H3(), m.jsxs(m.Fragment, {
      children: [
        m.jsx(yC, {
          asChild: true,
          loop: true,
          trapped: r,
          onMountAutoFocus: i,
          onUnmountAutoFocus: s,
          children: m.jsx(Sm, {
            role: "dialog",
            id: a.contentId,
            "aria-describedby": a.descriptionId,
            "aria-labelledby": a.titleId,
            "data-state": n5(a.open),
            ...o,
            ref: c,
            onDismiss: () => a.onOpenChange(false)
          })
        }),
        m.jsxs(m.Fragment, {
          children: [
            m.jsx(jwe, {
              titleId: a.titleId
            }),
            m.jsx(Qwe, {
              contentRef: l,
              descriptionId: a.descriptionId
            })
          ]
        })
      ]
    });
  }), J3 = "DialogTitle", e5 = b.forwardRef((t, e) => {
    const { __scopeDialog: n, ...r } = t, i = Ga(J3, n);
    return m.jsx(rt.h2, {
      id: i.titleId,
      ...r,
      ref: e
    });
  });
  e5.displayName = J3;
  var RY = "DialogDescription", MY = b.forwardRef((t, e) => {
    const { __scopeDialog: n, ...r } = t, i = Ga(RY, n);
    return m.jsx(rt.p, {
      id: i.descriptionId,
      ...r,
      ref: e
    });
  });
  MY.displayName = RY;
  var DY = "DialogClose", t5 = b.forwardRef((t, e) => {
    const { __scopeDialog: n, ...r } = t, i = Ga(DY, n);
    return m.jsx(rt.button, {
      type: "button",
      ...r,
      ref: e,
      onClick: Pe(t.onClick, () => i.onOpenChange(false))
    });
  });
  t5.displayName = DY;
  function n5(t) {
    return t ? "open" : "closed";
  }
  var LY = "DialogTitleWarning", [$ot, jY] = b1e(LY, {
    contentName: rf,
    titleName: J3,
    docsSlug: "dialog"
  }), jwe = ({ titleId: t }) => {
    const e = jY(LY), n = `\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.

If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.

For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;
    return b.useEffect(() => {
      t && (document.getElementById(t) || console.error(n));
    }, [
      n,
      t
    ]), null;
  }, Nwe = "DialogDescriptionWarning", Qwe = ({ contentRef: t, descriptionId: e }) => {
    const r = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${jY(Nwe).contentName}}.`;
    return b.useEffect(() => {
      var _a3;
      const i = (_a3 = t.current) == null ? void 0 : _a3.getAttribute("aria-describedby");
      e && i && (document.getElementById(e) || console.warn(r));
    }, [
      r,
      t,
      e
    ]), null;
  }, NY = PY, zwe = _Y, QY = EY, r5 = IY, i5 = $Y, zY = e5, FY = MY, Fwe = t5, BY = {
    exports: {}
  };
  (function(t) {
    (function() {
      var e = {}.hasOwnProperty;
      function n() {
        for (var s = "", o = 0; o < arguments.length; o++) {
          var a = arguments[o];
          a && (s = i(s, r(a)));
        }
        return s;
      }
      function r(s) {
        if (typeof s == "string" || typeof s == "number")
          return s;
        if (typeof s != "object")
          return "";
        if (Array.isArray(s))
          return n.apply(null, s);
        if (s.toString !== Object.prototype.toString && !s.toString.toString().includes("[native code]"))
          return s.toString();
        var o = "";
        for (var a in s)
          e.call(s, a) && s[a] && (o = i(o, a));
        return o;
      }
      function i(s, o) {
        return o ? s ? s + " " + o : s + o : s;
      }
      t.exports ? (n.default = n, t.exports = n) : window.classNames = n;
    })();
  })(BY);
  var Bwe = BY.exports;
  const Ze = Rd(Bwe), Az = 8;
  class UY {
    constructor() {
      __publicField(this, "arraySize", 0);
      __publicField(this, "array", Array(Az));
      __publicField(this, "set", null);
    }
    get isEmpty() {
      if (this.array)
        return this.arraySize === 0;
      if (this.set)
        return this.set.size === 0;
      throw new Error("no set or array");
    }
    add(e) {
      if (this.array)
        return this.array.indexOf(e) !== -1 ? false : this.arraySize < Az ? (this.array[this.arraySize] = e, this.arraySize++, true) : (this.set = new Set(this.array), this.array = null, this.set.add(e), true);
      if (this.set)
        return this.set.has(e) ? false : (this.set.add(e), true);
      throw new Error("no set or array");
    }
    remove(e) {
      if (this.array) {
        const n = this.array.indexOf(e);
        return n === -1 ? false : (this.array[n] = void 0, this.arraySize--, n !== this.arraySize && (this.array[n] = this.array[this.arraySize], this.array[this.arraySize] = void 0), true);
      }
      if (this.set)
        return this.set.has(e) ? (this.set.delete(e), true) : false;
      throw new Error("no set or array");
    }
    visit(e) {
      if (this.array) {
        for (let n = 0; n < this.arraySize; n++) {
          const r = this.array[n];
          typeof r < "u" && e(r);
        }
        return;
      }
      if (this.set) {
        this.set.forEach(e);
        return;
      }
      throw new Error("no set or array");
    }
  }
  function VY(t) {
    return t && typeof t == "object" && "parents" in t;
  }
  function XY(t) {
    for (let e = 0, n = t.parents.length; e < n; e++)
      if (t.parents[e].__unsafe__getWithoutCapture(), t.parents[e].lastChangedEpoch !== t.parentEpochs[e])
        return true;
    return false;
  }
  const dk = (t, e) => {
    if (t.children.remove(e) && t.children.isEmpty && VY(t))
      for (let n = 0, r = t.parents.length; n < r; n++)
        dk(t.parents[n], t);
  }, s5 = (t, e) => {
    if (t.children.add(e) && VY(t))
      for (let n = 0, r = t.parents.length; n < r; n++)
        s5(t.parents[n], t);
  };
  function WY(t, e) {
    return t === e || Object.is(t, e) || !!(t && e && typeof t.equals == "function" && t.equals(e));
  }
  const Rc = Object.freeze([]), Rz = Symbol.for("__@tldraw/state__"), Mz = globalThis;
  Mz[Rz] ? console.error('Multiple versions of @tldraw/state detected. This will cause unexpected behavior. Please add "resolutions" (yarn/pnpm) or "overrides" (npm) in your package.json to ensure only one version of @tldraw/state is loaded.') : Mz[Rz] = true;
  class Uwe {
    constructor(e, n) {
      __publicField(this, "offset", 0);
      __publicField(this, "numNewParents", 0);
      __publicField(this, "maybeRemoved");
      this.below = e, this.child = n;
    }
  }
  let vn = null;
  function ZY(t) {
    vn = new Uwe(vn, t);
  }
  function HY() {
    const t = vn;
    if (vn = t.below, t.numNewParents > 0 || t.offset !== t.child.parents.length) {
      for (let n = t.offset; n < t.child.parents.length; n++) {
        const r = t.child.parents[n];
        t.child.parents.indexOf(r) >= t.offset && dk(r, t.child);
      }
      if (t.child.parents.length = t.offset, t.child.parentEpochs.length = t.offset, vn == null ? void 0 : vn.maybeRemoved)
        for (let n = 0; n < vn.maybeRemoved.length; n++) {
          const r = vn.maybeRemoved[n];
          t.child.parents.indexOf(r) === -1 && dk(r, t.child);
        }
    }
  }
  function ZA(t) {
    if (vn) {
      const e = vn.child.parents.indexOf(t);
      if (e < 0 && (vn.numNewParents++, vn.child.isActivelyListening && s5(t, vn.child)), e < 0 || e >= vn.offset) {
        if (e !== vn.offset && e > 0) {
          const n = vn.child.parents[vn.offset];
          vn.maybeRemoved ? vn.maybeRemoved.indexOf(n) === -1 && vn.maybeRemoved.push(n) : vn.maybeRemoved = [
            n
          ];
        }
        vn.child.parents[vn.offset] = t, vn.child.parentEpochs[vn.offset] = t.lastChangedEpoch, vn.offset++;
      }
    }
  }
  const io = Symbol("RESET_VALUE");
  class YY {
    constructor(e) {
      __publicField(this, "index", 0);
      __publicField(this, "buffer");
      this.capacity = e, this.buffer = new Array(e);
    }
    pushEntry(e, n, r) {
      if (r !== void 0) {
        if (r === io) {
          this.clear();
          return;
        }
        this.buffer[this.index] = [
          e,
          n,
          r
        ], this.index = (this.index + 1) % this.capacity;
      }
    }
    clear() {
      this.index = 0, this.buffer.fill(void 0);
    }
    getChangesSince(e) {
      const { index: n, capacity: r, buffer: i } = this;
      for (let s = 0; s < r; s++) {
        const o = (n - 1 + r - s) % r, a = i[o];
        if (!a)
          return io;
        const [l, c] = a;
        if (s === 0 && e >= c)
          return [];
        if (l <= e && e < c) {
          const u = s + 1, d = new Array(u);
          for (let h = 0; h < u; h++)
            d[h] = i[(o + h) % r][2];
          return d;
        }
      }
      return io;
    }
  }
  const Rh = -1;
  let Br = Rh + 1, fE = false;
  function Vwe() {
    Br++;
  }
  let Xwe = class {
    constructor(e) {
      __publicField(this, "initialAtomValues", /* @__PURE__ */ new Map());
      this.parent = e;
    }
    get isRoot() {
      return this.parent === null;
    }
    commit() {
      if (this.isRoot) {
        const e = this.initialAtomValues;
        this.initialAtomValues = /* @__PURE__ */ new Map(), GY(e.keys());
      } else
        this.initialAtomValues.forEach((e, n) => {
          this.parent.initialAtomValues.has(n) || this.parent.initialAtomValues.set(n, e);
        });
    }
    abort() {
      Br++, this.initialAtomValues.forEach((e, n) => {
        var _a3;
        n.set(e), (_a3 = n.historyBuffer) == null ? void 0 : _a3.clear();
      }), this.commit();
    }
  };
  function GY(t) {
    if (fE)
      throw new Error("cannot change atoms during reaction cycle");
    try {
      fE = true;
      const e = /* @__PURE__ */ new Set(), n = (r) => {
        r.lastTraversedEpoch !== Br && (r.lastTraversedEpoch = Br, "maybeScheduleEffect" in r ? e.add(r) : r.children.visit(n));
      };
      for (const r of t)
        r.children.visit(n);
      for (const r of e)
        r.maybeScheduleEffect();
    } finally {
      fE = false;
    }
  }
  function Wwe(t, e) {
    Hu ? Hu.initialAtomValues.has(t) || Hu.initialAtomValues.set(t, e) : GY([
      t
    ]);
  }
  let Hu = null;
  function Zwe(t) {
    const e = new Xwe(Hu);
    Hu = e;
    try {
      let n = false;
      const r = t(() => n = true);
      return n ? e.abort() : e.commit(), r;
    } catch (n) {
      throw e.abort(), n;
    } finally {
      Hu = Hu.parent;
    }
  }
  function Ca(t) {
    return Hu ? t() : Zwe(t);
  }
  class Hwe {
    constructor(e, n, r) {
      __publicField(this, "isEqual");
      __publicField(this, "computeDiff");
      __publicField(this, "lastChangedEpoch", Br);
      __publicField(this, "children", new UY());
      __publicField(this, "historyBuffer");
      this.name = e, this.current = n, this.isEqual = (r == null ? void 0 : r.isEqual) ?? null, r && (r.historyLength && (this.historyBuffer = new YY(r.historyLength)), this.computeDiff = r.computeDiff);
    }
    __unsafe__getWithoutCapture() {
      return this.current;
    }
    get value() {
      return ZA(this), this.current;
    }
    set(e, n) {
      var _a3, _b3;
      if (((_a3 = this.isEqual) == null ? void 0 : _a3.call(this, this.current, e)) ?? WY(this.current, e))
        return this.current;
      Vwe(), this.historyBuffer && this.historyBuffer.pushEntry(this.lastChangedEpoch, Br, n ?? ((_b3 = this.computeDiff) == null ? void 0 : _b3.call(this, this.current, e, this.lastChangedEpoch, Br)) ?? io), this.lastChangedEpoch = Br;
      const r = this.current;
      return this.current = e, Wwe(this, r), e;
    }
    update(e) {
      return this.set(e(this.current));
    }
    getDiffSince(e) {
      var _a3;
      return ZA(this), e >= this.lastChangedEpoch ? Rc : ((_a3 = this.historyBuffer) == null ? void 0 : _a3.getChangesSince(e)) ?? io;
    }
  }
  function fs(t, e, n) {
    return new Hwe(t, e, n);
  }
  const HA = Symbol("UNINITIALIZED"), pg = (t) => t === HA;
  class YA {
    constructor(e, n) {
      this.value = e, this.diff = n;
    }
  }
  function y0(t, e) {
    return new YA(t, e);
  }
  class qY {
    constructor(e, n, r) {
      __publicField(this, "lastChangedEpoch", Rh);
      __publicField(this, "lastTraversedEpoch", Rh);
      __publicField(this, "lastCheckedEpoch", Rh);
      __publicField(this, "parents", []);
      __publicField(this, "parentEpochs", []);
      __publicField(this, "children", new UY());
      __publicField(this, "historyBuffer");
      __publicField(this, "state", HA);
      __publicField(this, "computeDiff");
      __publicField(this, "isEqual");
      this.name = e, this.derive = n, (r == null ? void 0 : r.historyLength) && (this.historyBuffer = new YY(r.historyLength)), this.computeDiff = r == null ? void 0 : r.computeDiff, this.isEqual = (r == null ? void 0 : r.isEqual) ?? WY;
    }
    get isActivelyListening() {
      return !this.children.isEmpty;
    }
    __unsafe__getWithoutCapture() {
      var _a3;
      const e = this.lastChangedEpoch === Rh;
      if (!e && (this.lastCheckedEpoch === Br || !XY(this)))
        return this.lastCheckedEpoch = Br, this.state;
      try {
        ZY(this);
        const n = this.derive(this.state, this.lastCheckedEpoch), r = n instanceof YA ? n.value : n;
        if (this.state === HA || !this.isEqual(r, this.state)) {
          if (this.historyBuffer && !e) {
            const i = n instanceof YA ? n.diff : void 0;
            this.historyBuffer.pushEntry(this.lastChangedEpoch, Br, i ?? ((_a3 = this.computeDiff) == null ? void 0 : _a3.call(this, this.state, r, this.lastCheckedEpoch, Br)) ?? io);
          }
          this.lastChangedEpoch = Br, this.state = r;
        }
        return this.lastCheckedEpoch = Br, this.state;
      } finally {
        HY();
      }
    }
    get value() {
      const e = this.__unsafe__getWithoutCapture();
      return ZA(this), e;
    }
    getDiffSince(e) {
      var _a3;
      return this.value, e >= this.lastChangedEpoch ? Rc : ((_a3 = this.historyBuffer) == null ? void 0 : _a3.getChangesSince(e)) ?? io;
    }
  }
  function Dz(t = {}, e, n, r) {
    const i = r.get, s = Symbol.for("__@tldraw/state__computed__" + n);
    return r.get = function() {
      let o = this[s];
      return o || (o = new qY(n, i.bind(this), t), Object.defineProperty(this, s, {
        enumerable: false,
        configurable: false,
        writable: false,
        value: o
      })), o.value;
    }, r;
  }
  function ve() {
    if (arguments.length === 1) {
      const t = arguments[0];
      return (e, n, r) => Dz(t, e, n, r);
    } else
      return typeof arguments[0] == "string" ? new qY(arguments[0], arguments[1], arguments[2]) : Dz(void 0, arguments[0], arguments[1], arguments[2]);
  }
  class HO {
    constructor(e, n, r) {
      __publicField(this, "_isActivelyListening", false);
      __publicField(this, "lastTraversedEpoch", Rh);
      __publicField(this, "lastReactedEpoch", Rh);
      __publicField(this, "_scheduleCount", 0);
      __publicField(this, "parentEpochs", []);
      __publicField(this, "parents", []);
      __publicField(this, "_scheduleEffect");
      __publicField(this, "maybeExecute", () => {
        this._isActivelyListening && this.execute();
      });
      this.name = e, this.runEffect = n, this._scheduleEffect = r == null ? void 0 : r.scheduleEffect;
    }
    get isActivelyListening() {
      return this._isActivelyListening;
    }
    get scheduleCount() {
      return this._scheduleCount;
    }
    maybeScheduleEffect() {
      if (this._isActivelyListening && this.lastReactedEpoch !== Br) {
        if (this.parents.length && !XY(this)) {
          this.lastReactedEpoch = Br;
          return;
        }
        this.scheduleEffect();
      }
    }
    scheduleEffect() {
      this._scheduleCount++, this._scheduleEffect ? this._scheduleEffect(this.maybeExecute) : this.execute();
    }
    attach() {
      this._isActivelyListening = true;
      for (let e = 0, n = this.parents.length; e < n; e++)
        s5(this.parents[e], this);
    }
    detach() {
      this._isActivelyListening = false;
      for (let e = 0, n = this.parents.length; e < n; e++)
        dk(this.parents[e], this);
    }
    execute() {
      try {
        ZY(this);
        const e = this.runEffect(this.lastReactedEpoch);
        return this.lastReactedEpoch = Br, e;
      } finally {
        HY();
      }
    }
  }
  function wm(t, e, n) {
    const r = new HO(t, e, n);
    return r.attach(), r.scheduleEffect(), () => {
      r.detach();
    };
  }
  function Ywe(t, e, n) {
    const r = new HO(t, e, n);
    return {
      scheduler: r,
      start: (i) => {
        const s = (i == null ? void 0 : i.force) ?? false;
        r.attach(), s ? r.scheduleEffect() : r.maybeScheduleEffect();
      },
      stop: () => {
        r.detach();
      }
    };
  }
  function wC(t, e) {
    const n = $e.useRef(e);
    n.current = e;
    const [r, i, s] = $e.useMemo(() => {
      let o = null;
      const a = (u) => (o = u, () => {
        o = null;
      }), l = new HO(`useStateTracking(${t})`, () => {
        var _a3;
        return (_a3 = n.current) == null ? void 0 : _a3.call(n);
      }, {
        scheduleEffect() {
          o == null ? void 0 : o();
        }
      });
      return [
        l,
        a,
        () => l.scheduleCount
      ];
    }, [
      t
    ]);
    return $e.useSyncExternalStore(i, s, s), $e.useEffect(() => (r.attach(), r.maybeScheduleEffect(), () => {
      r.detach();
    }), [
      r
    ]), r.execute();
  }
  const Lz = {
    apply(t, e, n) {
      return wC(t.displayName ?? t.name ?? "tracked(???)", () => t.apply(e, n));
    }
  }, Gwe = Symbol.for("react.memo"), qwe = Symbol.for("react.forward_ref");
  function Vt(t) {
    let e = null;
    const n = t.$$typeof;
    return n === Gwe && (t = t.type, e = t.compare), n === qwe ? b.memo(b.forwardRef(new Proxy(t.render, Lz))) : b.memo(new Proxy(t, Lz), e);
  }
  function KY() {
    const t = arguments[0], e = arguments[1], n = arguments.length === 3 ? void 0 : arguments[2], r = arguments.length === 3 ? arguments[2] : arguments[3];
    return b.useMemo(() => ve(`useComputed(${t})`, e, n), r);
  }
  function Vh(t, e, n = Rc) {
    b.useEffect(() => {
      const r = new HO(t, e);
      return r.attach(), r.execute(), () => {
        r.detach();
      };
    }, n);
  }
  function ye() {
    const t = arguments, e = t.length === 3 ? t[2] : [
      t[0]
    ], n = t.length === 3 ? t[0] : `useValue(${t[0].name})`, r = b.useRef(true);
    r.current = true;
    const i = b.useMemo(() => t.length === 1 ? t[0] : ve(n, () => {
      if (r.current)
        return t[1]();
      try {
        return t[1]();
      } catch {
        return {};
      }
    }), e);
    try {
      const { subscribe: s, getSnapshot: o } = b.useMemo(() => ({
        subscribe: (a) => wm(`useValue(${n})`, () => {
          i.value, a();
        }),
        getSnapshot: () => i.value
      }), [
        i
      ]);
      return b.useSyncExternalStore(s, o, o);
    } finally {
      r.current = false;
    }
  }
  class Vx {
    constructor(e) {
      __publicField(this, "nextValue");
      __publicField(this, "diff");
      this.previousValue = e;
    }
    get() {
      var _a3, _b3, _c3, _d3;
      const e = ((_b3 = (_a3 = this.diff) == null ? void 0 : _a3.removed) == null ? void 0 : _b3.size) ?? 0, n = ((_d3 = (_c3 = this.diff) == null ? void 0 : _c3.added) == null ? void 0 : _d3.size) ?? 0;
      if (!(e === 0 && n === 0))
        return {
          value: this.nextValue,
          diff: this.diff
        };
    }
    _add(e, n) {
      var _a3, _b3;
      this.nextValue ?? (this.nextValue = new Set(this.previousValue)), this.nextValue.add(e), this.diff ?? (this.diff = {}), n ? (_a3 = this.diff.removed) == null ? void 0 : _a3.delete(e) : ((_b3 = this.diff).added ?? (_b3.added = /* @__PURE__ */ new Set()), this.diff.added.add(e));
    }
    add(e) {
      var _a3, _b3, _c3;
      const n = this.previousValue.has(e);
      if (n)
        return ((_b3 = (_a3 = this.diff) == null ? void 0 : _a3.removed) == null ? void 0 : _b3.has(e)) ? this._add(e, n) : void 0;
      ((_c3 = this.nextValue) == null ? void 0 : _c3.has(e)) || this._add(e, n);
    }
    _remove(e, n) {
      var _a3, _b3;
      this.nextValue ?? (this.nextValue = new Set(this.previousValue)), this.nextValue.delete(e), this.diff ?? (this.diff = {}), n ? ((_a3 = this.diff).removed ?? (_a3.removed = /* @__PURE__ */ new Set()), this.diff.removed.add(e)) : (_b3 = this.diff.added) == null ? void 0 : _b3.delete(e);
    }
    remove(e) {
      var _a3, _b3, _c3, _d3;
      const n = this.previousValue.has(e);
      if (!n)
        return ((_b3 = (_a3 = this.diff) == null ? void 0 : _a3.added) == null ? void 0 : _b3.has(e)) ? this._remove(e, n) : void 0;
      ((_d3 = (_c3 = this.diff) == null ? void 0 : _c3.removed) == null ? void 0 : _d3.has(e)) || this._remove(e, n);
    }
  }
  function hk(t, e) {
    const n = [];
    e:
      for (const r of t) {
        for (const i of n)
          if (e ? e(r, i) : r === i)
            continue e;
        n.push(r);
      }
    return n;
  }
  function Je(t) {
    return t.filter((e) => e != null);
  }
  function as(t) {
    return t[t.length - 1];
  }
  function Kwe(t, e) {
    let n, r = 1 / 0;
    for (const i of t) {
      const s = e(i);
      s < r && (n = i, r = s);
    }
    return n;
  }
  function JY(t) {
    const e = (...n) => {
      try {
        return t(...n);
      } catch (r) {
        throw r instanceof Error && Error.captureStackTrace && Error.captureStackTrace(r, e), r;
      }
    };
    return e;
  }
  function o5(t, e) {
    const n = e && t && typeof t == "object" && e in t ? t[e] : t;
    throw new Error(`Unknown switch case ${n}`);
  }
  const xC = JY((t, e) => {
    if (!t)
      throw new Error(e || "Assertion Error");
  }), Jwe = JY((t, e) => {
    if (t == null)
      throw new Error(e ?? "value must be defined");
    return t;
  });
  function eG(t, e) {
    let n;
    const r = (...i) => (n || (n = {}, n.promise = new Promise((s, o) => {
      n.resolve = s, n.reject = o;
    })), clearTimeout(n.timeout), n.latestArgs = i, n.timeout = setTimeout(() => {
      const s = n;
      n = void 0;
      try {
        s.resolve(t(...s.latestArgs));
      } catch (o) {
        s.reject(o);
      }
    }, e), n.promise);
    return r.cancel = () => {
      n && clearTimeout(n.timeout);
    }, r;
  }
  const jz = /* @__PURE__ */ new WeakMap();
  function a5(t, e) {
    if (typeof t != "object" || t === null)
      return;
    let n = jz.get(t);
    n || (n = {
      tags: {},
      extras: {}
    }, jz.set(t, n)), e.tags && (n.tags = {
      ...n.tags,
      ...e.tags
    }), e.extras && (n.extras = {
      ...n.extras,
      ...e.extras
    });
  }
  class exe {
    static async base64ToFile(e) {
      return fetch(e).then(function(n) {
        return n.arrayBuffer();
      });
    }
    static async fileToBase64(e) {
      return await new Promise((n, r) => {
        if (e) {
          const i = new FileReader();
          i.readAsDataURL(e), i.onload = () => n(i.result), i.onerror = (s) => r(s), i.onabort = (s) => r(s);
        }
      });
    }
  }
  function Xx(t) {
    let e = 0;
    for (let n = 0; n < t.length; n++)
      e = (e << 5) - e + t.charCodeAt(n), e |= 0;
    return e + "";
  }
  let GA = [
    0,
    1996959894,
    3993919788,
    2567524794,
    124634137,
    1886057615,
    3915621685,
    2657392035,
    249268274,
    2044508324,
    3772115230,
    2547177864,
    162941995,
    2125561021,
    3887607047,
    2428444049,
    498536548,
    1789927666,
    4089016648,
    2227061214,
    450548861,
    1843258603,
    4107580753,
    2211677639,
    325883990,
    1684777152,
    4251122042,
    2321926636,
    335633487,
    1661365465,
    4195302755,
    2366115317,
    997073096,
    1281953886,
    3579855332,
    2724688242,
    1006888145,
    1258607687,
    3524101629,
    2768942443,
    901097722,
    1119000684,
    3686517206,
    2898065728,
    853044451,
    1172266101,
    3705015759,
    2882616665,
    651767980,
    1373503546,
    3369554304,
    3218104598,
    565507253,
    1454621731,
    3485111705,
    3099436303,
    671266974,
    1594198024,
    3322730930,
    2970347812,
    795835527,
    1483230225,
    3244367275,
    3060149565,
    1994146192,
    31158534,
    2563907772,
    4023717930,
    1907459465,
    112637215,
    2680153253,
    3904427059,
    2013776290,
    251722036,
    2517215374,
    3775830040,
    2137656763,
    141376813,
    2439277719,
    3865271297,
    1802195444,
    476864866,
    2238001368,
    4066508878,
    1812370925,
    453092731,
    2181625025,
    4111451223,
    1706088902,
    314042704,
    2344532202,
    4240017532,
    1658658271,
    366619977,
    2362670323,
    4224994405,
    1303535960,
    984961486,
    2747007092,
    3569037538,
    1256170817,
    1037604311,
    2765210733,
    3554079995,
    1131014506,
    879679996,
    2909243462,
    3663771856,
    1141124467,
    855842277,
    2852801631,
    3708648649,
    1342533948,
    654459306,
    3188396048,
    3373015174,
    1466479909,
    544179635,
    3110523913,
    3462522015,
    1591671054,
    702138776,
    2966460450,
    3352799412,
    1504918807,
    783551873,
    3082640443,
    3233442989,
    3988292384,
    2596254646,
    62317068,
    1957810842,
    3939845945,
    2647816111,
    81470997,
    1943803523,
    3814918930,
    2489596804,
    225274430,
    2053790376,
    3826175755,
    2466906013,
    167816743,
    2097651377,
    4027552580,
    2265490386,
    503444072,
    1762050814,
    4150417245,
    2154129355,
    426522225,
    1852507879,
    4275313526,
    2312317920,
    282753626,
    1742555852,
    4189708143,
    2394877945,
    397917763,
    1622183637,
    3604390888,
    2714866558,
    953729732,
    1340076626,
    3518719985,
    2797360999,
    1068828381,
    1219638859,
    3624741850,
    2936675148,
    906185462,
    1090812512,
    3747672003,
    2825379669,
    829329135,
    1181335161,
    3412177804,
    3160834842,
    628085408,
    1382605366,
    3423369109,
    3138078467,
    570562233,
    1426400815,
    3317316542,
    2998733608,
    733239954,
    1555261956,
    3268935591,
    3050360625,
    752459403,
    1541320221,
    2607071920,
    3965973030,
    1969922972,
    40735498,
    2617837225,
    3943577151,
    1913087877,
    83908371,
    2512341634,
    3803740692,
    2075208622,
    213261112,
    2463272603,
    3855990285,
    2094854071,
    198958881,
    2262029012,
    4057260610,
    1759359992,
    534414190,
    2176718541,
    4139329115,
    1873836001,
    414664567,
    2282248934,
    4279200368,
    1711684554,
    285281116,
    2405801727,
    4167216745,
    1634467795,
    376229701,
    2685067896,
    3608007406,
    1308918612,
    956543938,
    2808555105,
    3495958263,
    1231636301,
    1047427035,
    2932959818,
    3654703836,
    1088359270,
    936918e3,
    2847714899,
    3736837829,
    1202900863,
    817233897,
    3183342108,
    3401237130,
    1404277552,
    615818150,
    3134207493,
    3453421203,
    1423857449,
    601450431,
    3009837614,
    3294710456,
    1567103746,
    711928724,
    3020668471,
    3272380065,
    1510334235,
    755167117
  ];
  typeof Int32Array < "u" && (GA = new Int32Array(GA));
  const txe = (t, e) => {
    let n = e === 0 ? 0 : ~~e ^ -1;
    for (let r = 0; r < t.length; r++)
      n = GA[(n ^ t[r]) & 255] ^ n >>> 8;
    return n ^ -1;
  }, Nz = 4, Qz = 4;
  class bl {
    static isPng(e, n) {
      return e.getUint8(n + 0) === 137 && e.getUint8(n + 1) === 80 && e.getUint8(n + 2) === 78 && e.getUint8(n + 3) === 71 && e.getUint8(n + 4) === 13 && e.getUint8(n + 5) === 10 && e.getUint8(n + 6) === 26 && e.getUint8(n + 7) === 10;
    }
    static getChunkType(e, n) {
      return [
        String.fromCharCode(e.getUint8(n)),
        String.fromCharCode(e.getUint8(n + 1)),
        String.fromCharCode(e.getUint8(n + 2)),
        String.fromCharCode(e.getUint8(n + 3))
      ].join("");
    }
    static readChunks(e, n = 0) {
      const r = {};
      if (!bl.isPng(e, n))
        throw new Error("Not a PNG");
      for (n += 8; n <= e.buffer.byteLength; ) {
        const i = n, s = e.getInt32(n);
        n += 4;
        const o = bl.getChunkType(e, n);
        if (o === "IDAT" && r[o]) {
          n += s + Nz + Qz;
          continue;
        }
        if (o === "IEND")
          break;
        r[o] = {
          start: i,
          dataOffset: n + 4,
          size: s
        }, n += s + Nz + Qz;
      }
      return r;
    }
    static parsePhys(e, n) {
      return {
        ppux: e.getUint32(n),
        ppuy: e.getUint32(n + 4),
        unit: e.getUint8(n + 4)
      };
    }
    static findChunk(e, n) {
      return bl.readChunks(e)[n];
    }
    static setPhysChunk(e, n = 1, r) {
      let i = 46, s = 0;
      const o = bl.findChunk(e, "pHYs");
      o && (i = o.start, s = o.size);
      const a = bl.findChunk(e, "IDAT");
      a && (i = a.start, s = 0);
      const l = new ArrayBuffer(21), c = new DataView(l);
      c.setUint32(0, 9), c.setUint8(4, "p".charCodeAt(0)), c.setUint8(5, "H".charCodeAt(0)), c.setUint8(6, "Y".charCodeAt(0)), c.setUint8(7, "s".charCodeAt(0));
      const u = 2835.5;
      c.setInt32(8, u * n), c.setInt32(12, u * n), c.setInt8(16, 1);
      const d = new Uint8Array(l.slice(4, 17));
      c.setInt32(17, txe(d));
      const h = e.buffer.slice(0, i), f = e.buffer.slice(i + s);
      return new Blob([
        h,
        l,
        f
      ], r);
    }
  }
  class zz {
    static async getVideoSizeFromSrc(e) {
      return await new Promise((n, r) => {
        const i = document.createElement("video");
        i.onloadeddata = () => n({
          w: i.videoWidth,
          h: i.videoHeight
        }), i.onerror = (s) => {
          console.error(s), r(new Error("Could not get video size"));
        }, i.crossOrigin = "anonymous", i.src = e;
      });
    }
    static async getImageSizeFromSrc(e) {
      return await new Promise((n, r) => {
        const i = new Image();
        i.onload = async () => {
          try {
            const s = await exe.base64ToFile(e), o = new DataView(s);
            if (bl.isPng(o, 0)) {
              const a = bl.findChunk(o, "pHYs");
              if (a) {
                const l = bl.parsePhys(o, a.dataOffset);
                if (l.unit === 0 && l.ppux === l.ppuy) {
                  const c = Math.round(l.ppux / 2834.5);
                  n({
                    w: i.width / c,
                    h: i.height / c
                  });
                  return;
                }
              }
            }
            n({
              w: i.width,
              h: i.height
            });
          } catch (s) {
            console.error(s), n({
              w: i.width,
              h: i.height
            });
          }
        }, i.onerror = (s) => {
          console.error(s), r(new Error("Could not get image size"));
        }, i.crossOrigin = "anonymous", i.src = e;
      });
    }
  }
  function md(t = "") {
    let e = 0, n = 0, r = 0, i = 0;
    function s() {
      const o = e ^ e << 11;
      return e = n, n = r, r = i, i ^= (i >>> 19 ^ o ^ o >>> 8) >>> 0, i / 4294967296 * 2;
    }
    for (let o = 0; o < t.length + 64; o++)
      e ^= t.charCodeAt(o) | 0, s();
    return s;
  }
  function fk(t, e, n, r = false) {
    const [i, s] = e, [o, a] = n, l = o + (t - i) / (s - i) * (a - o);
    return r ? o < a ? Math.max(Math.min(l, a), o) : Math.max(Math.min(l, o), a) : l;
  }
  function bC(t, e) {
    return Object.prototype.hasOwnProperty.call(t, e);
  }
  function Xh(t, e) {
    if (bC(t, e))
      return t[e];
  }
  function wi(t) {
    if (!t)
      return t;
    if (Array.isArray(t)) {
      const e = [], n = t.length;
      for (let r = 0; r < n; r++)
        e.push(wi(t[r]));
      return e;
    } else if (typeof t == "object") {
      const e = Object.keys(t), n = e.length, r = {};
      for (let i = 0; i < n; i++) {
        const s = e[i];
        r[s] = wi(t[s]);
      }
      return r;
    }
    return t;
  }
  function Fz(t) {
    return Object.keys(t);
  }
  function Qn(t) {
    return Object.values(t);
  }
  function Mc(t) {
    return Object.entries(t);
  }
  function tG(t) {
    return Object.fromEntries(t);
  }
  function pE(t, e) {
    const n = {};
    let r = false;
    for (const [i, s] of Mc(t))
      e(i, s) ? n[i] = s : r = true;
    return r ? n : t;
  }
  function Bz(t, e) {
    const n = {};
    for (const [r, i] of Mc(t)) {
      const s = e(r, i);
      n[r] = s;
    }
    return n;
  }
  const nxe = () => typeof process < "u" && false, pk = [], rxe = () => {
    const t = pk.splice(0, pk.length);
    for (const e of t)
      e();
  };
  let gE;
  function ixe() {
    gE || (gE = requestAnimationFrame(() => {
      gE = void 0, rxe();
    }));
  }
  function sxe(t) {
    if (nxe())
      return t();
    pk.includes(t) || (pk.push(t), ixe());
  }
  function oxe(t, e) {
    return t.id > e.id ? 1 : -1;
  }
  const axe = new RegExp(/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i);
  function qA(t) {
    return axe.test(t);
  }
  function lxe(t) {
    return t !== null;
  }
  const Dc = typeof window < "u" && window.structuredClone ? window.structuredClone : (t) => t && JSON.parse(JSON.stringify(t));
  let kC = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e, n) => (n &= 63, n < 36 ? e += n.toString(36) : n < 62 ? e += (n - 26).toString(36).toUpperCase() : n > 62 ? e += "-" : e += "_", e), "");
  class l5 {
    constructor(e, n) {
      __publicField(this, "createDefaultProperties");
      __publicField(this, "migrations");
      __publicField(this, "validator");
      __publicField(this, "scope");
      __publicField(this, "isInstance", (e) => (e == null ? void 0 : e.typeName) === this.typeName);
      this.typeName = e, this.createDefaultProperties = n.createDefaultProperties, this.migrations = n.migrations, this.validator = n.validator ?? {
        validate: (r) => r
      }, this.scope = n.scope ?? "document";
    }
    create(e) {
      const n = {
        ...this.createDefaultProperties(),
        id: this.createId()
      };
      for (const [r, i] of Object.entries(e))
        i !== void 0 && (n[r] = i);
      return n.typeName = this.typeName, n;
    }
    clone(e) {
      return {
        ...Dc(e),
        id: this.createId()
      };
    }
    createId(e) {
      return this.typeName + ":" + (e ?? kC());
    }
    createCustomId(e) {
      return this.typeName + ":" + e;
    }
    parseId(e) {
      if (!this.isId(e))
        throw new Error(`ID "${e}" is not a valid ID for type "${this.typeName}"`);
      return e.slice(this.typeName.length + 1);
    }
    isId(e) {
      if (!e)
        return false;
      for (let n = 0; n < this.typeName.length; n++)
        if (e[n] !== this.typeName[n])
          return false;
      return e[this.typeName.length] === ":";
    }
    withDefaultProperties(e) {
      return new l5(this.typeName, {
        createDefaultProperties: e,
        migrations: this.migrations,
        validator: this.validator,
        scope: this.scope
      });
    }
    validate(e) {
      return this.validator.validate(e);
    }
  }
  function tu(t, e) {
    return new l5(t, {
      createDefaultProperties: () => ({}),
      migrations: e.migrations ?? {
        currentVersion: 0,
        firstVersion: 0,
        migrators: {}
      },
      validator: e.validator,
      scope: e.scope
    });
  }
  class Uz {
    constructor() {
      __publicField(this, "items", /* @__PURE__ */ new WeakMap());
    }
    get(e, n) {
      return this.items.has(e) || this.items.set(e, n(e)), this.items.get(e);
    }
  }
  var gk = {
    exports: {}
  };
  gk.exports;
  (function(t, e) {
    var n = 200, r = "__lodash_hash_undefined__", i = 1, s = 2, o = 9007199254740991, a = "[object Arguments]", l = "[object Array]", c = "[object AsyncFunction]", u = "[object Boolean]", d = "[object Date]", h = "[object Error]", f = "[object Function]", y = "[object GeneratorFunction]", g = "[object Map]", O = "[object Number]", S = "[object Null]", w = "[object Object]", x = "[object Promise]", P = "[object Proxy]", C = "[object RegExp]", _ = "[object Set]", T = "[object String]", $ = "[object Symbol]", N = "[object Undefined]", L = "[object WeakMap]", z = "[object ArrayBuffer]", M = "[object DataView]", R = "[object Float32Array]", F = "[object Float64Array]", Q = "[object Int8Array]", X = "[object Int16Array]", Z = "[object Int32Array]", U = "[object Uint8Array]", H = "[object Uint8ClampedArray]", te = "[object Uint16Array]", se = "[object Uint32Array]", ae = /[\\^$.*+?()[\]{}|]/g, _e3 = /^\[object .+?Constructor\]$/, Me = /^(?:0|[1-9]\d*)$/, ke = {};
    ke[R] = ke[F] = ke[Q] = ke[X] = ke[Z] = ke[U] = ke[H] = ke[te] = ke[se] = true, ke[a] = ke[l] = ke[z] = ke[u] = ke[M] = ke[d] = ke[h] = ke[f] = ke[g] = ke[O] = ke[w] = ke[C] = ke[_] = ke[T] = ke[L] = false;
    var tt = typeof Jn == "object" && Jn && Jn.Object === Object && Jn, it = typeof self == "object" && self && self.Object === Object && self, pt = tt || it || Function("return this")(), kt = e && !e.nodeType && e, Yt = kt && true && t && !t.nodeType && t, Ar = Yt && Yt.exports === kt, Cn = Ar && tt.process, Vn = function() {
      try {
        return Cn && Cn.binding && Cn.binding("util");
      } catch {
      }
    }(), Lt = Vn && Vn.isTypedArray;
    function tr(B, J) {
      for (var ge = -1, Ie = B == null ? 0 : B.length, en = 0, ot = []; ++ge < Ie; ) {
        var fn = B[ge];
        J(fn, ge, B) && (ot[en++] = fn);
      }
      return ot;
    }
    function ql(B, J) {
      for (var ge = -1, Ie = J.length, en = B.length; ++ge < Ie; )
        B[en + ge] = J[ge];
      return B;
    }
    function nr(B, J) {
      for (var ge = -1, Ie = B == null ? 0 : B.length; ++ge < Ie; )
        if (J(B[ge], ge, B))
          return true;
      return false;
    }
    function go(B, J) {
      for (var ge = -1, Ie = Array(B); ++ge < B; )
        Ie[ge] = J(ge);
      return Ie;
    }
    function mo(B) {
      return function(J) {
        return B(J);
      };
    }
    function Jr(B, J) {
      return B.has(J);
    }
    function ei(B, J) {
      return B == null ? void 0 : B[J];
    }
    function Cs(B) {
      var J = -1, ge = Array(B.size);
      return B.forEach(function(Ie, en) {
        ge[++J] = [
          en,
          Ie
        ];
      }), ge;
    }
    function cu(B, J) {
      return function(ge) {
        return B(J(ge));
      };
    }
    function Ym(B) {
      var J = -1, ge = Array(B.size);
      return B.forEach(function(Ie) {
        ge[++J] = Ie;
      }), ge;
    }
    var Kl = Array.prototype, Gm = Function.prototype, yo = Object.prototype, Ri = pt["__core-js_shared__"], Af = Gm.toString, qi = yo.hasOwnProperty, Rf = function() {
      var B = /[^.]+$/.exec(Ri && Ri.keys && Ri.keys.IE_PROTO || "");
      return B ? "Symbol(src)_1." + B : "";
    }(), Mf = yo.toString, qm = RegExp("^" + Af.call(qi).replace(ae, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), Df = Ar ? pt.Buffer : void 0, uu = pt.Symbol, Lf = pt.Uint8Array, jf = yo.propertyIsEnumerable, Z2 = Kl.splice, Jl = uu ? uu.toStringTag : void 0, $S = Object.getOwnPropertySymbols, AS = Df ? Df.isBuffer : void 0, RS = cu(Object.keys, Object), Km = _s2(pt, "DataView"), Yd = _s2(pt, "Map"), Jm = _s2(pt, "Promise"), ey = _s2(pt, "Set"), Nf = _s2(pt, "WeakMap"), Gd = _s2(Object, "create"), H2 = nc(Km), Y2 = nc(Yd), ty = nc(Jm), G2 = nc(ey), ny = nc(Nf), MS = uu ? uu.prototype : void 0, ry = MS ? MS.valueOf : void 0;
    function ec(B) {
      var J = -1, ge = B == null ? 0 : B.length;
      for (this.clear(); ++J < ge; ) {
        var Ie = B[J];
        this.set(Ie[0], Ie[1]);
      }
    }
    function q2() {
      this.__data__ = Gd ? Gd(null) : {}, this.size = 0;
    }
    function K2(B) {
      var J = this.has(B) && delete this.__data__[B];
      return this.size -= J ? 1 : 0, J;
    }
    function J2(B) {
      var J = this.__data__;
      if (Gd) {
        var ge = J[B];
        return ge === r ? void 0 : ge;
      }
      return qi.call(J, B) ? J[B] : void 0;
    }
    function e_(B) {
      var J = this.__data__;
      return Gd ? J[B] !== void 0 : qi.call(J, B);
    }
    function t_(B, J) {
      var ge = this.__data__;
      return this.size += this.has(B) ? 0 : 1, ge[B] = Gd && J === void 0 ? r : J, this;
    }
    ec.prototype.clear = q2, ec.prototype.delete = K2, ec.prototype.get = J2, ec.prototype.has = e_, ec.prototype.set = t_;
    function vo(B) {
      var J = -1, ge = B == null ? 0 : B.length;
      for (this.clear(); ++J < ge; ) {
        var Ie = B[J];
        this.set(Ie[0], Ie[1]);
      }
    }
    function n_() {
      this.__data__ = [], this.size = 0;
    }
    function r_(B) {
      var J = this.__data__, ge = qd(J, B);
      if (ge < 0)
        return false;
      var Ie = J.length - 1;
      return ge == Ie ? J.pop() : Z2.call(J, ge, 1), --this.size, true;
    }
    function i_(B) {
      var J = this.__data__, ge = qd(J, B);
      return ge < 0 ? void 0 : J[ge][1];
    }
    function s_(B) {
      return qd(this.__data__, B) > -1;
    }
    function o_(B, J) {
      var ge = this.__data__, Ie = qd(ge, B);
      return Ie < 0 ? (++this.size, ge.push([
        B,
        J
      ])) : ge[Ie][1] = J, this;
    }
    vo.prototype.clear = n_, vo.prototype.delete = r_, vo.prototype.get = i_, vo.prototype.has = s_, vo.prototype.set = o_;
    function tc(B) {
      var J = -1, ge = B == null ? 0 : B.length;
      for (this.clear(); ++J < ge; ) {
        var Ie = B[J];
        this.set(Ie[0], Ie[1]);
      }
    }
    function Qf() {
      this.size = 0, this.__data__ = {
        hash: new ec(),
        map: new (Yd || vo)(),
        string: new ec()
      };
    }
    function a_(B) {
      var J = du(this, B).delete(B);
      return this.size -= J ? 1 : 0, J;
    }
    function zf(B) {
      return du(this, B).get(B);
    }
    function l_(B) {
      return du(this, B).has(B);
    }
    function c_(B, J) {
      var ge = du(this, B), Ie = ge.size;
      return ge.set(B, J), this.size += ge.size == Ie ? 0 : 1, this;
    }
    tc.prototype.clear = Qf, tc.prototype.delete = a_, tc.prototype.get = zf, tc.prototype.has = l_, tc.prototype.set = c_;
    function Ff(B) {
      var J = -1, ge = B == null ? 0 : B.length;
      for (this.__data__ = new tc(); ++J < ge; )
        this.add(B[J]);
    }
    function DS(B) {
      return this.__data__.set(B, r), this;
    }
    function LS(B) {
      return this.__data__.has(B);
    }
    Ff.prototype.add = Ff.prototype.push = DS, Ff.prototype.has = LS;
    function ca(B) {
      var J = this.__data__ = new vo(B);
      this.size = J.size;
    }
    function u_() {
      this.__data__ = new vo(), this.size = 0;
    }
    function d_(B) {
      var J = this.__data__, ge = J.delete(B);
      return this.size = J.size, ge;
    }
    function h_(B) {
      return this.__data__.get(B);
    }
    function f_(B) {
      return this.__data__.has(B);
    }
    function jS(B, J) {
      var ge = this.__data__;
      if (ge instanceof vo) {
        var Ie = ge.__data__;
        if (!Yd || Ie.length < n - 1)
          return Ie.push([
            B,
            J
          ]), this.size = ++ge.size, this;
        ge = this.__data__ = new tc(Ie);
      }
      return ge.set(B, J), this.size = ge.size, this;
    }
    ca.prototype.clear = u_, ca.prototype.delete = d_, ca.prototype.get = h_, ca.prototype.has = f_, ca.prototype.set = jS;
    function NS(B, J) {
      var ge = Vf(B), Ie = !ge && GS(B), en = !ge && !Ie && oy(B), ot = !ge && !Ie && !en && JS(B), fn = ge || Ie || en || ot, rr = fn ? go(B.length, String) : [], Pt = rr.length;
      for (var tn in B)
        (J || qi.call(B, tn)) && !(fn && (tn == "length" || en && (tn == "offset" || tn == "parent") || ot && (tn == "buffer" || tn == "byteLength" || tn == "byteOffset") || XS(tn, Pt))) && rr.push(tn);
      return rr;
    }
    function qd(B, J) {
      for (var ge = B.length; ge--; )
        if (YS(B[ge][0], J))
          return ge;
      return -1;
    }
    function iy(B, J, ge) {
      var Ie = J(B);
      return Vf(B) ? Ie : ql(Ie, ge(B));
    }
    function Kd(B) {
      return B == null ? B === void 0 ? N : S : Jl && Jl in Object(B) ? US(B) : m_(B);
    }
    function sy(B) {
      return eh(B) && Kd(B) == a;
    }
    function Jd(B, J, ge, Ie, en) {
      return B === J ? true : B == null || J == null || !eh(B) && !eh(J) ? B !== B && J !== J : QS(B, J, ge, Ie, Jd, en);
    }
    function QS(B, J, ge, Ie, en, ot) {
      var fn = Vf(B), rr = Vf(J), Pt = fn ? l : Ka(B), tn = rr ? l : Ka(J);
      Pt = Pt == a ? w : Pt, tn = tn == a ? w : tn;
      var Xn = Pt == w, Ki = tn == w, ir = Pt == tn;
      if (ir && oy(B)) {
        if (!oy(J))
          return false;
        fn = true, Xn = false;
      }
      if (ir && !Xn)
        return ot || (ot = new ca()), fn || JS(B) ? Bf(B, J, ge, Ie, en, ot) : g_(B, J, Pt, ge, Ie, en, ot);
      if (!(ge & i)) {
        var pn = Xn && qi.call(B, "__wrapped__"), Mi = Ki && qi.call(J, "__wrapped__");
        if (pn || Mi) {
          var ua = pn ? B.value() : B, Oo = Mi ? J.value() : J;
          return ot || (ot = new ca()), en(ua, Oo, ge, Ie, ot);
        }
      }
      return ir ? (ot || (ot = new ca()), BS(B, J, ge, Ie, en, ot)) : false;
    }
    function p_(B) {
      if (!KS(B) || ZS(B))
        return false;
      var J = Xf(B) ? qm : _e3;
      return J.test(nc(B));
    }
    function zS(B) {
      return eh(B) && qS(B.length) && !!ke[Kd(B)];
    }
    function FS(B) {
      if (!HS(B))
        return RS(B);
      var J = [];
      for (var ge in Object(B))
        qi.call(B, ge) && ge != "constructor" && J.push(ge);
      return J;
    }
    function Bf(B, J, ge, Ie, en, ot) {
      var fn = ge & i, rr = B.length, Pt = J.length;
      if (rr != Pt && !(fn && Pt > rr))
        return false;
      var tn = ot.get(B);
      if (tn && ot.get(J))
        return tn == J;
      var Xn = -1, Ki = true, ir = ge & s ? new Ff() : void 0;
      for (ot.set(B, J), ot.set(J, B); ++Xn < rr; ) {
        var pn = B[Xn], Mi = J[Xn];
        if (Ie)
          var ua = fn ? Ie(Mi, pn, Xn, J, B, ot) : Ie(pn, Mi, Xn, B, J, ot);
        if (ua !== void 0) {
          if (ua)
            continue;
          Ki = false;
          break;
        }
        if (ir) {
          if (!nr(J, function(Oo, Ja) {
            if (!Jr(ir, Ja) && (pn === Oo || en(pn, Oo, ge, Ie, ot)))
              return ir.push(Ja);
          })) {
            Ki = false;
            break;
          }
        } else if (!(pn === Mi || en(pn, Mi, ge, Ie, ot))) {
          Ki = false;
          break;
        }
      }
      return ot.delete(B), ot.delete(J), Ki;
    }
    function g_(B, J, ge, Ie, en, ot, fn) {
      switch (ge) {
        case M:
          if (B.byteLength != J.byteLength || B.byteOffset != J.byteOffset)
            return false;
          B = B.buffer, J = J.buffer;
        case z:
          return !(B.byteLength != J.byteLength || !ot(new Lf(B), new Lf(J)));
        case u:
        case d:
        case O:
          return YS(+B, +J);
        case h:
          return B.name == J.name && B.message == J.message;
        case C:
        case T:
          return B == J + "";
        case g:
          var rr = Cs;
        case _:
          var Pt = Ie & i;
          if (rr || (rr = Ym), B.size != J.size && !Pt)
            return false;
          var tn = fn.get(B);
          if (tn)
            return tn == J;
          Ie |= s, fn.set(B, J);
          var Xn = Bf(rr(B), rr(J), Ie, en, ot, fn);
          return fn.delete(B), Xn;
        case $:
          if (ry)
            return ry.call(B) == ry.call(J);
      }
      return false;
    }
    function BS(B, J, ge, Ie, en, ot) {
      var fn = ge & i, rr = Uf(B), Pt = rr.length, tn = Uf(J), Xn = tn.length;
      if (Pt != Xn && !fn)
        return false;
      for (var Ki = Pt; Ki--; ) {
        var ir = rr[Ki];
        if (!(fn ? ir in J : qi.call(J, ir)))
          return false;
      }
      var pn = ot.get(B);
      if (pn && ot.get(J))
        return pn == J;
      var Mi = true;
      ot.set(B, J), ot.set(J, B);
      for (var ua = fn; ++Ki < Pt; ) {
        ir = rr[Ki];
        var Oo = B[ir], Ja = J[ir];
        if (Ie)
          var ay = fn ? Ie(Ja, Oo, ir, J, B, ot) : Ie(Oo, Ja, ir, B, J, ot);
        if (!(ay === void 0 ? Oo === Ja || en(Oo, Ja, ge, Ie, ot) : ay)) {
          Mi = false;
          break;
        }
        ua || (ua = ir == "constructor");
      }
      if (Mi && !ua) {
        var th = B.constructor, vr = J.constructor;
        th != vr && "constructor" in B && "constructor" in J && !(typeof th == "function" && th instanceof th && typeof vr == "function" && vr instanceof vr) && (Mi = false);
      }
      return ot.delete(B), ot.delete(J), Mi;
    }
    function Uf(B) {
      return iy(B, O_, VS);
    }
    function du(B, J) {
      var ge = B.__data__;
      return WS(J) ? ge[typeof J == "string" ? "string" : "hash"] : ge.map;
    }
    function _s2(B, J) {
      var ge = ei(B, J);
      return p_(ge) ? ge : void 0;
    }
    function US(B) {
      var J = qi.call(B, Jl), ge = B[Jl];
      try {
        B[Jl] = void 0;
        var Ie = true;
      } catch {
      }
      var en = Mf.call(B);
      return Ie && (J ? B[Jl] = ge : delete B[Jl]), en;
    }
    var VS = $S ? function(B) {
      return B == null ? [] : (B = Object(B), tr($S(B), function(J) {
        return jf.call(B, J);
      }));
    } : Jt, Ka = Kd;
    (Km && Ka(new Km(new ArrayBuffer(1))) != M || Yd && Ka(new Yd()) != g || Jm && Ka(Jm.resolve()) != x || ey && Ka(new ey()) != _ || Nf && Ka(new Nf()) != L) && (Ka = function(B) {
      var J = Kd(B), ge = J == w ? B.constructor : void 0, Ie = ge ? nc(ge) : "";
      if (Ie)
        switch (Ie) {
          case H2:
            return M;
          case Y2:
            return g;
          case ty:
            return x;
          case G2:
            return _;
          case ny:
            return L;
        }
      return J;
    });
    function XS(B, J) {
      return J = J ?? o, !!J && (typeof B == "number" || Me.test(B)) && B > -1 && B % 1 == 0 && B < J;
    }
    function WS(B) {
      var J = typeof B;
      return J == "string" || J == "number" || J == "symbol" || J == "boolean" ? B !== "__proto__" : B === null;
    }
    function ZS(B) {
      return !!Rf && Rf in B;
    }
    function HS(B) {
      var J = B && B.constructor, ge = typeof J == "function" && J.prototype || yo;
      return B === ge;
    }
    function m_(B) {
      return Mf.call(B);
    }
    function nc(B) {
      if (B != null) {
        try {
          return Af.call(B);
        } catch {
        }
        try {
          return B + "";
        } catch {
        }
      }
      return "";
    }
    function YS(B, J) {
      return B === J || B !== B && J !== J;
    }
    var GS = sy(function() {
      return arguments;
    }()) ? sy : function(B) {
      return eh(B) && qi.call(B, "callee") && !jf.call(B, "callee");
    }, Vf = Array.isArray;
    function y_(B) {
      return B != null && qS(B.length) && !Xf(B);
    }
    var oy = AS || Gt;
    function v_(B, J) {
      return Jd(B, J);
    }
    function Xf(B) {
      if (!KS(B))
        return false;
      var J = Kd(B);
      return J == f || J == y || J == c || J == P;
    }
    function qS(B) {
      return typeof B == "number" && B > -1 && B % 1 == 0 && B <= o;
    }
    function KS(B) {
      var J = typeof B;
      return B != null && (J == "object" || J == "function");
    }
    function eh(B) {
      return B != null && typeof B == "object";
    }
    var JS = Lt ? mo(Lt) : zS;
    function O_(B) {
      return y_(B) ? NS(B) : FS(B);
    }
    function Jt() {
      return [];
    }
    function Gt() {
      return false;
    }
    t.exports = v_;
  })(gk, gk.exports);
  var cxe = gk.exports;
  const uxe = Rd(cxe);
  function dxe(t) {
    if (t.length === 0)
      return /* @__PURE__ */ new Set();
    const e = t[0], n = t.slice(1), r = /* @__PURE__ */ new Set();
    for (const i of e)
      n.every((s) => s.has(i)) && r.add(i);
    return r;
  }
  function hxe(t, e) {
    const n = {};
    for (const r of e)
      t.has(r) || (n.added ?? (n.added = /* @__PURE__ */ new Set()), n.added.add(r));
    for (const r of t)
      e.has(r) || (n.removed ?? (n.removed = /* @__PURE__ */ new Set()), n.removed.add(r));
    return n.added || n.removed ? n : void 0;
  }
  function Vz(t, e) {
    for (const [n, r] of Object.entries(t)) {
      const i = r, s = e[n];
      if ("eq" in i && s !== i.eq || "neq" in i && s === i.neq || "gt" in i && (typeof s != "number" || s <= i.gt))
        return false;
    }
    return true;
  }
  function Xz(t, e, n) {
    const r = Object.fromEntries(Object.keys(n).map((i) => [
      i,
      /* @__PURE__ */ new Set()
    ]));
    for (const [i, s] of Object.entries(n))
      if ("eq" in s) {
        const a = t.index(e, i).value.get(s.eq);
        if (a)
          for (const l of a)
            r[i].add(l);
      } else if ("neq" in s) {
        const o = t.index(e, i);
        for (const [a, l] of o.value)
          if (a !== s.neq)
            for (const c of l)
              r[i].add(c);
      } else if ("gt" in s) {
        const o = t.index(e, i);
        for (const [a, l] of o.value)
          if (a > s.gt)
            for (const c of l)
              r[i].add(c);
      }
    return dxe(Object.values(r));
  }
  class fxe {
    constructor(e, n) {
      __publicField(this, "indexCache", /* @__PURE__ */ new Map());
      __publicField(this, "historyCache", /* @__PURE__ */ new Map());
      this.atoms = e, this.history = n;
    }
    filterHistory(e) {
      if (this.historyCache.has(e))
        return this.historyCache.get(e);
      const n = ve("filterHistory:" + e, (r, i) => {
        if (pg(r))
          return this.history.value;
        const s = this.history.getDiffSince(i);
        if (s === io)
          return this.history.value;
        const o = {
          added: {},
          removed: {},
          updated: {}
        };
        let a = 0, l = 0, c = 0;
        for (const u of s) {
          for (const d of Qn(u.added))
            if (d.typeName === e)
              if (o.removed[d.id]) {
                const h = o.removed[d.id];
                delete o.removed[d.id], l--, h !== d && (o.updated[d.id] = [
                  h,
                  d
                ], c++);
              } else
                o.added[d.id] = d, a++;
          for (const [d, h] of Qn(u.updated))
            h.typeName === e && (o.added[h.id] ? o.added[h.id] = h : o.updated[h.id] ? o.updated[h.id] = [
              o.updated[h.id][0],
              h
            ] : (o.updated[h.id] = [
              d,
              h
            ], c++));
          for (const d of Qn(u.removed))
            d.typeName === e && (o.added[d.id] ? (delete o.added[d.id], a--) : o.updated[d.id] ? (o.removed[d.id] = o.updated[d.id][0], delete o.updated[d.id], c--, l++) : (o.removed[d.id] = d, l++));
        }
        return a || l || c ? y0(this.history.value, o) : r;
      }, {
        historyLength: 100
      });
      return this.historyCache.set(e, n), n;
    }
    index(e, n) {
      const r = e + ":" + n;
      if (this.indexCache.has(r))
        return this.indexCache.get(r);
      const i = this.__uncached_createIndex(e, n);
      return this.indexCache.set(r, i), i;
    }
    __uncached_createIndex(e, n) {
      const r = this.filterHistory(e), i = () => {
        r.value;
        const s = /* @__PURE__ */ new Map();
        for (const o of Qn(this.atoms.value)) {
          const a = o.value;
          if (a.typeName === e) {
            const l = a[n];
            s.has(l) || s.set(l, /* @__PURE__ */ new Set()), s.get(l).add(a.id);
          }
        }
        return s;
      };
      return ve("index:" + e + ":" + n, (s, o) => {
        if (pg(s))
          return i();
        const a = r.getDiffSince(o);
        if (a === io)
          return i();
        const l = /* @__PURE__ */ new Map(), c = (f, y) => {
          let g = l.get(f);
          g || (g = new Vx(s.get(f) ?? /* @__PURE__ */ new Set())), g.add(y), l.set(f, g);
        }, u = (f, y) => {
          let g = l.get(f);
          g || (g = new Vx(s.get(f) ?? /* @__PURE__ */ new Set())), g.remove(y), l.set(f, g);
        };
        for (const f of a) {
          for (const y of Qn(f.added))
            if (y.typeName === e) {
              const g = y[n];
              c(g, y.id);
            }
          for (const [y, g] of Qn(f.updated))
            if (g.typeName === e) {
              const O = y[n], S = g[n];
              O !== S && (u(O, g.id), c(S, g.id));
            }
          for (const y of Qn(f.removed))
            if (y.typeName === e) {
              const g = y[n];
              u(g, y.id);
            }
        }
        let d, h;
        for (const [f, y] of l) {
          const g = y.get();
          g && (d || (d = new Map(s)), h || (h = /* @__PURE__ */ new Map()), g.value.size === 0 ? d.delete(f) : d.set(f, g.value), h.set(f, g.diff));
        }
        return d && h ? y0(d, h) : s;
      }, {
        historyLength: 100
      });
    }
    record(e, n = () => ({}), r = "record:" + e + (n ? ":" + n.toString() : "")) {
      const i = this.ids(e, n, r);
      return ve(r, () => {
        var _a3;
        for (const s of i.value)
          return (_a3 = this.atoms.value[s]) == null ? void 0 : _a3.value;
      });
    }
    records(e, n = () => ({}), r = "records:" + e + (n ? ":" + n.toString() : "")) {
      const i = this.ids(e, n, "ids:" + r);
      return ve(r, () => [
        ...i.value
      ].map((s) => {
        const o = this.atoms.value[s];
        if (!o)
          throw new Error("no atom found for record id: " + s);
        return o.value;
      }));
    }
    ids(e, n = () => ({}), r = "ids:" + e + (n ? ":" + n.toString() : "")) {
      const i = this.filterHistory(e), s = () => {
        i.value;
        const l = n();
        return Object.keys(l).length === 0 ? new Set(Qn(this.atoms.value).flatMap((c) => {
          const u = c.value;
          return u.typeName === e ? u.id : [];
        })) : Xz(this, e, l);
      }, o = (l) => {
        const c = s(), u = hxe(l, c);
        return u ? y0(c, u) : l;
      }, a = ve("ids_query:" + r, n, {
        isEqual: uxe
      });
      return ve("query:" + r, (l, c) => {
        const u = a.value;
        if (pg(l))
          return s();
        if (c < a.lastChangedEpoch)
          return o(l);
        const d = i.getDiffSince(c);
        if (d === io)
          return o(l);
        const h = new Vx(l);
        for (const y of d) {
          for (const g of Qn(y.added))
            g.typeName === e && Vz(u, g) && h.add(g.id);
          for (const [g, O] of Qn(y.updated))
            O.typeName === e && (Vz(u, O) ? h.add(O.id) : h.remove(O.id));
          for (const g of Qn(y.removed))
            g.typeName === e && h.remove(g.id);
        }
        const f = h.get();
        return f ? y0(f.value, f.diff) : l;
      }, {
        historyLength: 50
      });
    }
    exec(e, n) {
      const r = Xz(this, e, n);
      if (r.size === 0)
        return Rc;
      const i = this.atoms.value;
      return [
        ...r
      ].map((s) => i[s].value);
    }
  }
  class nG {
    constructor(e) {
      __publicField(this, "id", kC());
      __publicField(this, "atoms", fs("store_atoms", {}));
      __publicField(this, "history", fs("history", 0, {
        historyLength: 1e3
      }));
      __publicField(this, "query", new fxe(this.atoms, this.history));
      __publicField(this, "listeners", /* @__PURE__ */ new Set());
      __publicField(this, "historyAccumulator", new gxe());
      __publicField(this, "historyReactor");
      __publicField(this, "schema");
      __publicField(this, "props");
      __publicField(this, "scopedTypes");
      __publicField(this, "onBeforeCreate");
      __publicField(this, "onAfterCreate");
      __publicField(this, "onBeforeChange");
      __publicField(this, "onAfterChange");
      __publicField(this, "onBeforeDelete");
      __publicField(this, "onAfterDelete");
      __publicField(this, "_runCallbacks", true);
      __publicField(this, "put", (e, n) => {
        Ca(() => {
          const r = {}, i = {}, s = this.atoms.__unsafe__getWithoutCapture();
          let o = null, a, l = false;
          const c = this.onBeforeCreate && this._runCallbacks ? this.onBeforeCreate : null, u = this.onBeforeChange && this._runCallbacks ? this.onBeforeChange : null, d = this.isMergingRemoteChanges ? "remote" : "user";
          for (let h = 0, f = e.length; h < f; h++) {
            a = e[h];
            const y = (o ?? s)[a.id];
            if (y) {
              u && (a = u(y.value, a, d));
              const g = y.__unsafe__getWithoutCapture();
              a = this.schema.validateRecord(this, a, n ?? "updateRecord", g), y.set(a);
              const O = y.__unsafe__getWithoutCapture();
              g !== O && (l = true, r[a.id] = [
                g,
                O
              ]);
            } else
              c && (a = c(a, d)), l = true, a = this.schema.validateRecord(this, a, n ?? "createRecord", null), i[a.id] = a, o || (o = {
                ...s
              }), o[a.id] = fs("atom:" + a.id, a);
          }
          if (o && this.atoms.set(o), !!l && (this.updateHistory({
            added: i,
            updated: r,
            removed: {}
          }), this._runCallbacks)) {
            const { onAfterCreate: h, onAfterChange: f } = this;
            h && Object.values(i).forEach((y) => {
              h(y, d);
            }), f && Object.values(r).forEach(([y, g]) => {
              f(y, g, d);
            });
          }
        });
      });
      __publicField(this, "remove", (e) => {
        Ca(() => {
          const n = [], r = this.isMergingRemoteChanges ? "remote" : "user";
          if (this.onBeforeDelete && this._runCallbacks)
            for (const s of e) {
              const o = this.atoms.__unsafe__getWithoutCapture()[s];
              o && this.onBeforeDelete(o.value, r) === false && n.push(s);
            }
          let i;
          if (this.atoms.update((s) => {
            let o;
            for (const a of e)
              n.includes(a) || a in s && (o || (o = {
                ...s
              }), i || (i = {}), delete o[a], i[a] = s[a].value);
            return o ?? s;
          }), !!i && (this.updateHistory({
            added: {},
            updated: {},
            removed: i
          }), this.onAfterDelete && this._runCallbacks)) {
            let s;
            for (let o = 0, a = e.length; o < a; o++)
              s = i[e[o]], s && this.onAfterDelete(s, r);
          }
        });
      });
      __publicField(this, "get", (e) => {
        var _a3;
        return (_a3 = this.atoms.value[e]) == null ? void 0 : _a3.value;
      });
      __publicField(this, "unsafeGetWithoutCapture", (e) => {
        var _a3;
        return (_a3 = this.atoms.value[e]) == null ? void 0 : _a3.__unsafe__getWithoutCapture();
      });
      __publicField(this, "serialize", (e = "document") => {
        const n = {};
        for (const [r, i] of Mc(this.atoms.value)) {
          const s = i.value;
          (e === "all" || this.scopedTypes[e].has(s.typeName)) && (n[r] = s);
        }
        return n;
      });
      __publicField(this, "allRecords", () => Qn(this.atoms.value).map((e) => e.value));
      __publicField(this, "clear", () => {
        this.remove(Fz(this.atoms.value));
      });
      __publicField(this, "update", (e, n) => {
        const r = this.atoms.value[e];
        if (!r) {
          console.error(`Record ${e} not found. This is probably an error`);
          return;
        }
        this.put([
          n(r.__unsafe__getWithoutCapture())
        ]);
      });
      __publicField(this, "has", (e) => !!this.atoms.value[e]);
      __publicField(this, "listen", (e, n) => {
        this._flushHistory();
        const r = {
          onHistory: e,
          filters: {
            source: (n == null ? void 0 : n.source) ?? "all",
            scope: (n == null ? void 0 : n.scope) ?? "all"
          }
        };
        return this.listeners.add(r), this.historyReactor.scheduler.isActivelyListening || this.historyReactor.start(), () => {
          this.listeners.delete(r), this.listeners.size === 0 && this.historyReactor.stop();
        };
      });
      __publicField(this, "isMergingRemoteChanges", false);
      __publicField(this, "mergeRemoteChanges", (e) => {
        if (this.isMergingRemoteChanges)
          return e();
        try {
          this.isMergingRemoteChanges = true, Ca(e);
        } finally {
          this.isMergingRemoteChanges = false;
        }
      });
      __publicField(this, "createComputedCache", (e, n, r) => {
        const i = new Uz();
        return {
          get: (s) => {
            const o = this.atoms.value[s];
            if (o)
              return i.get(o, () => {
                const a = r ? ve(o.name + ":equals", () => o.value, {
                  isEqual: r
                }) : o;
                return ve(e + ":" + s, () => n(a.value));
              }).value;
          }
        };
      });
      __publicField(this, "createSelectedComputedCache", (e, n, r) => {
        const i = new Uz();
        return {
          get: (s) => {
            const o = this.atoms.value[s];
            if (!o)
              return;
            const a = ve(e + ":" + s + ":selector", () => n(o.value));
            return i.get(o, () => ve(e + ":" + s, () => r(a.value))).value;
          }
        };
      });
      __publicField(this, "getRecordType", (e) => {
        const n = this.schema.types[e.typeName];
        if (!n)
          throw new Error(`Record type ${e.typeName} not found`);
        return n;
      });
      __publicField(this, "_integrityChecker");
      __publicField(this, "_isPossiblyCorrupted", false);
      const { initialData: n, schema: r } = e;
      this.schema = r, this.props = e.props, n && this.atoms.set(tG(Mc(n).map(([i, s]) => [
        i,
        fs("atom:" + i, this.schema.validateRecord(this, s, "initialize", null))
      ]))), this.historyReactor = Ywe("Store.historyReactor", () => {
        this.history.value, this._flushHistory();
      }, {
        scheduleEffect: (i) => sxe(i)
      }), this.scopedTypes = {
        document: new Set(Qn(this.schema.types).filter((i) => i.scope === "document").map((i) => i.typeName)),
        session: new Set(Qn(this.schema.types).filter((i) => i.scope === "session").map((i) => i.typeName)),
        presence: new Set(Qn(this.schema.types).filter((i) => i.scope === "presence").map((i) => i.typeName))
      };
    }
    _flushHistory() {
      if (this.historyAccumulator.hasChanges()) {
        const e = this.historyAccumulator.flush();
        for (const { changes: n, source: r } of e) {
          let i = null, s = null, o = null;
          for (const { onHistory: a, filters: l } of this.listeners)
            if (!(l.source !== "all" && l.source !== r))
              if (l.scope !== "all")
                if (l.scope === "document") {
                  if (s ?? (s = this.filterChangesByScope(n, "document")), !s)
                    continue;
                  a({
                    changes: s,
                    source: r
                  });
                } else if (l.scope === "session") {
                  if (i ?? (i = this.filterChangesByScope(n, "session")), !i)
                    continue;
                  a({
                    changes: i,
                    source: r
                  });
                } else {
                  if (o ?? (o = this.filterChangesByScope(n, "presence")), !o)
                    continue;
                  a({
                    changes: o,
                    source: r
                  });
                }
              else
                a({
                  changes: n,
                  source: r
                });
        }
      }
    }
    filterChangesByScope(e, n) {
      const r = {
        added: pE(e.added, (i, s) => this.scopedTypes[n].has(s.typeName)),
        updated: pE(e.updated, (i, s) => this.scopedTypes[n].has(s[1].typeName)),
        removed: pE(e.removed, (i, s) => this.scopedTypes[n].has(s.typeName))
      };
      return Object.keys(r.added).length === 0 && Object.keys(r.updated).length === 0 && Object.keys(r.removed).length === 0 ? null : r;
    }
    updateHistory(e) {
      this.historyAccumulator.add({
        changes: e,
        source: this.isMergingRemoteChanges ? "remote" : "user"
      }), this.listeners.size === 0 && this.historyAccumulator.clear(), this.history.set(this.history.value + 1, e);
    }
    validate(e) {
      this.allRecords().forEach((n) => this.schema.validateRecord(this, n, e, null));
    }
    getSnapshot(e = "document") {
      return {
        store: this.serialize(e),
        schema: this.schema.serialize()
      };
    }
    migrateSnapshot(e) {
      const n = this.schema.migrateStoreSnapshot(e);
      if (n.type === "error")
        throw new Error(`Failed to migrate snapshot: ${n.reason}`);
      return {
        store: n.value,
        schema: this.schema.serialize()
      };
    }
    loadSnapshot(e) {
      const n = this.schema.migrateStoreSnapshot(e);
      if (n.type === "error")
        throw new Error(`Failed to migrate snapshot: ${n.reason}`);
      Ca(() => {
        this.clear(), this.put(Object.values(n.value)), this.ensureStoreIsUsable();
      });
    }
    extractingChanges(e) {
      const n = [], r = this.historyAccumulator.intercepting((i) => n.push(i.changes));
      try {
        return Ca(e), PC(n);
      } finally {
        r();
      }
    }
    applyDiff(e, n = true) {
      const r = this._runCallbacks;
      try {
        this._runCallbacks = n, Ca(() => {
          const i = Qn(e.added).concat(Qn(e.updated).map(([o, a]) => a)), s = Fz(e.removed);
          i.length && this.put(i), s.length && this.remove(s);
        });
      } finally {
        this._runCallbacks = r;
      }
    }
    ensureStoreIsUsable() {
      var _a3;
      this._integrityChecker ?? (this._integrityChecker = this.schema.createIntegrityChecker(this)), (_a3 = this._integrityChecker) == null ? void 0 : _a3.call(this);
    }
    markAsPossiblyCorrupted() {
      this._isPossiblyCorrupted = true;
    }
    isPossiblyCorrupted() {
      return this._isPossiblyCorrupted;
    }
  }
  function PC(t) {
    const e = {
      added: {},
      removed: {},
      updated: {}
    };
    for (const n of t) {
      for (const [r, i] of Mc(n.added))
        if (e.removed[r]) {
          const s = e.removed[r];
          delete e.removed[r], s !== i && (e.updated[r] = [
            s,
            i
          ]);
        } else
          e.added[r] = i;
      for (const [r, [i, s]] of Mc(n.updated)) {
        if (e.added[r]) {
          e.added[r] = s, delete e.updated[r], delete e.removed[r];
          continue;
        }
        if (e.updated[r]) {
          e.updated[r][1] = s, delete e.removed[r];
          continue;
        }
        e.updated[r] = n.updated[r], delete e.removed[r];
      }
      for (const [r, i] of Mc(n.removed))
        e.added[r] ? delete e.added[r] : e.updated[r] ? (e.removed[r] = e.updated[r][0], delete e.updated[r]) : e.removed[r] = i;
    }
    return e;
  }
  function pxe(t) {
    const e = [];
    let n = t[0], r;
    for (let i = 1, s = t.length; i < s; i++)
      r = t[i], n.source !== r.source ? (e.push(n), n = r) : n = {
        source: n.source,
        changes: PC([
          n.changes,
          r.changes
        ])
      };
    return e.push(n), e;
  }
  class gxe {
    constructor() {
      __publicField(this, "_history", []);
      __publicField(this, "_interceptors", /* @__PURE__ */ new Set());
    }
    intercepting(e) {
      return this._interceptors.add(e), () => {
        this._interceptors.delete(e);
      };
    }
    add(e) {
      this._history.push(e);
      for (const n of this._interceptors)
        n(e);
    }
    flush() {
      const e = pxe(this._history);
      return this._history = [], e;
    }
    clear() {
      this._history = [];
    }
    hasChanges() {
      return this._history.length > 0;
    }
  }
  function mxe(t) {
    return typeof t == "object" && t !== null && "id" in t && "typeName" in t;
  }
  function Ut(t) {
    const { currentVersion: e, firstVersion: n, migrators: r = {}, subTypeKey: i, subTypeMigrations: s } = t;
    if (typeof e == "number" && typeof n == "number") {
      if (e === n)
        throw Error("Current version is equal to initial version.");
      if (e < n)
        throw Error("Current version is lower than initial version.");
    }
    return {
      firstVersion: n ?? 0,
      currentVersion: e ?? 0,
      migrators: r,
      subTypeKey: i,
      subTypeMigrations: s
    };
  }
  var v0 = ((t) => (t.IncompatibleSubtype = "incompatible-subtype", t.UnknownType = "unknown-type", t.TargetVersionTooNew = "target-version-too-new", t.TargetVersionTooOld = "target-version-too-old", t.MigrationError = "migration-error", t.UnrecognizedSubtype = "unrecognized-subtype", t))(v0 || {});
  function uw({ record: t, migrations: e, fromVersion: n, toVersion: r }) {
    let i = n;
    if (!mxe(t))
      throw new Error("[migrateRecord] object is not a record");
    const { typeName: s, id: o, ...a } = t;
    let l = a;
    for (; i < r; ) {
      const c = i + 1, u = e.migrators[c];
      if (!u)
        return {
          type: "error",
          reason: "target-version-too-new"
        };
      l = u.up(l), i = c;
    }
    for (; i > r; ) {
      const c = i - 1, u = e.migrators[i];
      if (!u)
        return {
          type: "error",
          reason: "target-version-too-old"
        };
      l = u.down(l), i = c;
    }
    return {
      type: "success",
      value: {
        ...l,
        id: o,
        typeName: s
      }
    };
  }
  function c5({ value: t, migrations: e, fromVersion: n, toVersion: r }) {
    let i = n;
    for (; i < r; ) {
      const s = i + 1, o = e.migrators[s];
      if (!o)
        return {
          type: "error",
          reason: "target-version-too-new"
        };
      t = o.up(t), i = s;
    }
    for (; i > r; ) {
      const s = i - 1, o = e.migrators[i];
      if (!o)
        return {
          type: "error",
          reason: "target-version-too-old"
        };
      t = o.down(t), i = s;
    }
    return {
      type: "success",
      value: t
    };
  }
  class u5 {
    constructor(e, n) {
      this.types = e, this.options = n;
    }
    static create(e, n) {
      return new u5(e, n ?? {});
    }
    get currentStoreVersion() {
      var _a3;
      return ((_a3 = this.options.snapshotMigrations) == null ? void 0 : _a3.currentVersion) ?? 0;
    }
    validateRecord(e, n, r, i) {
      try {
        const s = Xh(this.types, n.typeName);
        if (!s)
          throw new Error(`Missing definition for record type ${n.typeName}`);
        return s.validate(n);
      } catch (s) {
        if (this.options.onValidationFailure)
          return this.options.onValidationFailure({
            store: e,
            record: n,
            phase: r,
            recordBefore: i,
            error: s
          });
        throw s;
      }
    }
    migratePersistedRecord(e, n, r = "up") {
      var _a3;
      const i = Xh(this.types, e.typeName), s = n.recordVersions[e.typeName];
      if (!s || !i)
        return {
          type: "error",
          reason: v0.UnknownType
        };
      const o = i.migrations.currentVersion, a = s.version;
      if (o !== a) {
        const d = uw(r === "up" ? {
          record: e,
          migrations: i.migrations,
          fromVersion: a,
          toVersion: o
        } : {
          record: e,
          migrations: i.migrations,
          fromVersion: o,
          toVersion: a
        });
        if (d.type === "error")
          return d;
        e = d.value;
      }
      if (!i.migrations.subTypeKey)
        return {
          type: "success",
          value: e
        };
      const l = (_a3 = i.migrations.subTypeMigrations) == null ? void 0 : _a3[e[i.migrations.subTypeKey]], c = "subTypeVersions" in s ? s.subTypeVersions[e[i.migrations.subTypeKey]] : void 0;
      if (l === void 0)
        return {
          type: "error",
          reason: v0.UnrecognizedSubtype
        };
      if (c === void 0)
        return {
          type: "error",
          reason: v0.IncompatibleSubtype
        };
      const u = uw(r === "up" ? {
        record: e,
        migrations: l,
        fromVersion: c,
        toVersion: l.currentVersion
      } : {
        record: e,
        migrations: l,
        fromVersion: l.currentVersion,
        toVersion: c
      });
      return u.type === "error" ? u : {
        type: "success",
        value: u.value
      };
    }
    migrateStoreSnapshot(e) {
      let { store: n } = e;
      const r = this.options.snapshotMigrations;
      if (!r)
        return {
          type: "success",
          value: n
        };
      const i = r.currentVersion, s = e.schema.storeVersion ?? 0;
      if (i < s)
        return {
          type: "error",
          reason: v0.TargetVersionTooOld
        };
      if (i > s) {
        const a = c5({
          value: n,
          migrations: r,
          fromVersion: s,
          toVersion: i
        });
        if (a.type === "error")
          return a;
        n = a.value;
      }
      const o = [];
      for (const a of Qn(n)) {
        const l = this.migratePersistedRecord(a, e.schema);
        if (l.type === "error")
          return l;
        l.value && l.value !== a && o.push(l.value);
      }
      if (o.length) {
        n = {
          ...n
        };
        for (const a of o)
          n[a.id] = a;
      }
      return {
        type: "success",
        value: n
      };
    }
    createIntegrityChecker(e) {
      var _a3, _b3;
      return ((_b3 = (_a3 = this.options).createIntegrityChecker) == null ? void 0 : _b3.call(_a3, e)) ?? void 0;
    }
    serialize() {
      var _a3;
      return {
        schemaVersion: 1,
        storeVersion: ((_a3 = this.options.snapshotMigrations) == null ? void 0 : _a3.currentVersion) ?? 0,
        recordVersions: Object.fromEntries(Qn(this.types).map((e) => [
          e.typeName,
          e.migrations.subTypeKey && e.migrations.subTypeMigrations ? {
            version: e.migrations.currentVersion,
            subTypeKey: e.migrations.subTypeKey,
            subTypeVersions: e.migrations.subTypeMigrations ? Object.fromEntries(Object.entries(e.migrations.subTypeMigrations).map(([n, r]) => [
              n,
              r.currentVersion
            ])) : void 0
          } : {
            version: e.migrations.currentVersion
          }
        ]))
      };
    }
    serializeEarliestVersion() {
      var _a3;
      return {
        schemaVersion: 1,
        storeVersion: ((_a3 = this.options.snapshotMigrations) == null ? void 0 : _a3.firstVersion) ?? 0,
        recordVersions: Object.fromEntries(Qn(this.types).map((e) => [
          e.typeName,
          e.migrations.subTypeKey && e.migrations.subTypeMigrations ? {
            version: e.migrations.firstVersion,
            subTypeKey: e.migrations.subTypeKey,
            subTypeVersions: e.migrations.subTypeMigrations ? Object.fromEntries(Object.entries(e.migrations.subTypeMigrations).map(([n, r]) => [
              n,
              r.firstVersion
            ])) : void 0
          } : {
            version: e.migrations.firstVersion
          }
        ]))
      };
    }
  }
  const yxe = (t, e) => {
    if (t.schemaVersion > e.schemaVersion)
      return 1;
    if (t.schemaVersion < e.schemaVersion)
      return -1;
    if (t.storeVersion > e.storeVersion)
      return 1;
    if (t.storeVersion < e.storeVersion)
      return -1;
    for (const n of Object.keys(t.recordVersions)) {
      const r = t.recordVersions[n], i = e.recordVersions[n];
      if (r.version > i.version)
        return 1;
      if (r.version < i.version)
        return -1;
      if ("subTypeVersions" in r && !("subTypeVersions" in i))
        return 1;
      if (!("subTypeVersions" in r) && "subTypeVersions" in i)
        return -1;
      if (!(!("subTypeVersions" in r) || !("subTypeVersions" in i)))
        for (const s of Object.keys(r.subTypeVersions)) {
          const o = r.subTypeVersions[s], a = i.subTypeVersions[s];
          if (o > a)
            return 1;
          if (o < a)
            return -1;
        }
    }
    return 0;
  };
  function vxe(t) {
    if (!t.length)
      return null;
    let e = "";
    for (const n of t)
      typeof n == "number" ? e += `.${n}` : n.startsWith("(") ? e.endsWith(")") ? e = `${e.slice(0, -1)}, ${n.slice(1)}` : e += n : e += `.${n}`;
    return e.startsWith(".") ? e.slice(1) : e;
  }
  class In extends Error {
    constructor(e, n = []) {
      const r = vxe(n), i = e.split(`
`).map((s, o) => o === 0 ? s : `  ${s}`).join(`
`);
      super(n ? `At ${r}: ${i}` : i);
      __publicField(this, "name", "ValidationError");
      this.rawMessage = e, this.path = n;
    }
  }
  function xm(t, e) {
    try {
      return e();
    } catch (n) {
      throw n instanceof In ? new In(n.rawMessage, [
        t,
        ...n.path
      ]) : new In(n.toString(), [
        t
      ]);
    }
  }
  function Lg(t) {
    if (t === null)
      return "null";
    if (Array.isArray(t))
      return "an array";
    const e = typeof t;
    switch (e) {
      case "bigint":
      case "boolean":
      case "function":
      case "number":
      case "string":
      case "symbol":
        return `a ${e}`;
      case "object":
        return `an ${e}`;
      case "undefined":
        return "undefined";
      default:
        o5(e);
    }
  }
  class Wi {
    constructor(e) {
      this.validationFn = e;
    }
    validate(e) {
      return this.validationFn(e);
    }
    nullable() {
      return kxe(this);
    }
    optional() {
      return iG(this);
    }
    refine(e) {
      return new Wi((n) => e(this.validate(n)));
    }
    check(e, n) {
      return typeof e == "string" ? this.refine((r) => (xm(`(check ${e})`, () => n(r)), r)) : this.refine((r) => (e(r), r));
    }
  }
  class Oxe extends Wi {
    constructor(e) {
      super((n) => {
        const r = bxe.validate(n);
        for (let i = 0; i < r.length; i++)
          xm(i, () => e.validate(r[i]));
        return r;
      }), this.itemValidator = e;
    }
    nonEmpty() {
      return this.check((e) => {
        if (e.length === 0)
          throw new In("Expected a non-empty array");
      });
    }
    lengthGreaterThan1() {
      return this.check((e) => {
        if (e.length <= 1)
          throw new In("Expected an array with length greater than 1");
      });
    }
  }
  class mk extends Wi {
    constructor(e, n = false) {
      super((r) => {
        if (typeof r != "object" || r === null)
          throw new In(`Expected object, got ${Lg(r)}`);
        for (const [i, s] of Object.entries(e))
          xm(i, () => {
            s.validate(Xh(r, i));
          });
        if (!n) {
          for (const i of Object.keys(r))
            if (!bC(e, i))
              throw new In("Unexpected property", [
                i
              ]);
        }
        return r;
      }), this.config = e, this.shouldAllowUnknownProperties = n;
    }
    allowUnknownProperties() {
      return new mk(this.config, true);
    }
    extend(e) {
      return new mk({
        ...this.config,
        ...e
      });
    }
  }
  class d5 extends Wi {
    constructor(e, n, r) {
      super((i) => {
        if (typeof i != "object" || i === null)
          throw new In(`Expected an object, got ${Lg(i)}`, []);
        const s = Xh(i, e);
        if (typeof s != "string")
          throw new In(`Expected a string for key "${e}", got ${Lg(s)}`);
        const o = bC(n, s) ? n[s] : void 0;
        return o === void 0 ? this.unknownValueValidation(i, s) : xm(`(${e} = ${s})`, () => o.validate(i));
      }), this.key = e, this.config = n, this.unknownValueValidation = r;
    }
    validateUnknownVariants(e) {
      return new d5(this.key, this.config, e);
    }
  }
  class Sxe extends Wi {
    constructor(e, n) {
      super((r) => {
        if (typeof r != "object" || r === null)
          throw new In(`Expected object, got ${Lg(r)}`);
        for (const [i, s] of Object.entries(r))
          xm(i, () => {
            e.validate(i), n.validate(s);
          });
        return r;
      }), this.keyValidator = e, this.valueValidator = n;
    }
  }
  function h5(t) {
    return new Wi((e) => {
      if (typeof e !== t)
        throw new In(`Expected ${t}, got ${Lg(e)}`);
      return e;
    });
  }
  const wxe = new Wi((t) => t), et = h5("string"), nt = h5("number").check((t) => {
    if (Number.isNaN(t))
      throw new In("Expected a number, got NaN");
    if (!Number.isFinite(t))
      throw new In(`Expected a finite number, got ${t}`);
  }), f5 = nt.check((t) => {
    if (t < 0)
      throw new In(`Expected a positive number, got ${t}`);
  }), xs = nt.check((t) => {
    if (t <= 0)
      throw new In(`Expected a non-zero positive number, got ${t}`);
  }), rG = nt.check((t) => {
    if (!Number.isInteger(t))
      throw new In(`Expected an integer, got ${t}`);
  }), dw = rG.check((t) => {
    if (t < 0)
      throw new In(`Expected a positive integer, got ${t}`);
  }), xxe = rG.check((t) => {
    if (t <= 0)
      throw new In(`Expected a non-zero positive integer, got ${t}`);
  }), It = h5("boolean");
  function bs(t) {
    return new Wi((e) => {
      if (e !== t)
        throw new In(`Expected ${t}, got ${JSON.stringify(e)}`);
      return t;
    });
  }
  const bxe = new Wi((t) => {
    if (!Array.isArray(t))
      throw new In(`Expected an array, got ${Lg(t)}`);
    return t;
  });
  function so(t) {
    return new Oxe(t);
  }
  function $t(t) {
    return new mk(t);
  }
  function KA(t) {
    return t === null || typeof t == "number" || typeof t == "string" || typeof t == "boolean" ? true : Array.isArray(t) ? t.every(KA) : typeof t == "object" ? Object.values(t).every(KA) : false;
  }
  const Ll = new Wi((t) => {
    if (KA(t))
      return t;
    throw new In(`Expected json serializable value, got ${typeof t}`);
  });
  function JA(t, e) {
    return new Sxe(t, e);
  }
  function p5(t, e) {
    return new d5(t, e, (n, r) => {
      throw new In(`Expected one of ${Object.keys(e).map((i) => JSON.stringify(i)).join(" or ")}, got ${JSON.stringify(r)}`, [
        t
      ]);
    });
  }
  function nu(t, e) {
    return new Wi((n) => {
      const r = n && typeof n == "object" && "id" in n && typeof n.id == "string" ? `${t}(id = ${n.id})` : t;
      return xm(r, () => e.validate(n));
    });
  }
  function YO(t) {
    return new Wi((e) => {
      if (!t.has(e)) {
        const n = Array.from(t, (r) => JSON.stringify(r)).join(" or ");
        throw new In(`Expected ${n}, got ${e}`);
      }
      return e;
    });
  }
  function iG(t) {
    return new Wi((e) => {
      if (e !== void 0)
        return t.validate(e);
    });
  }
  function kxe(t) {
    return new Wi((e) => e === null ? null : t.validate(e));
  }
  function sG(...t) {
    return YO(new Set(t));
  }
  function Na(t) {
    return et.refine((e) => {
      if (!e.startsWith(`${t}:`))
        throw new Error(`${t} ID must start with "${t}:"`);
      return e;
    });
  }
  const CC = Na("asset");
  function g5(t, e) {
    return $t({
      id: CC,
      typeName: bs("asset"),
      type: bs(t),
      props: e,
      meta: Ll
    });
  }
  const Pxe = nu("camera", $t({
    typeName: bs("camera"),
    id: Na("camera"),
    x: nt,
    y: nt,
    z: nt,
    meta: Ll
  })), Wz = {
    AddMeta: 1
  }, Cxe = Ut({
    currentVersion: Wz.AddMeta,
    migrators: {
      [Wz.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      }
    }
  }), Nr = tu("camera", {
    validator: Pxe,
    migrations: Cxe,
    scope: "session"
  }).withDefaultProperties(() => ({
    x: 0,
    y: 0,
    z: 1,
    meta: {}
  })), zv = $t({
    x: nt,
    y: nt,
    z: nt.optional()
  }), H0 = $t({
    x: nt,
    y: nt,
    w: nt,
    h: nt
  }), _xe = /* @__PURE__ */ new Set([
    "none",
    "default",
    "pointer",
    "cross",
    "grab",
    "rotate",
    "grabbing",
    "resize-edge",
    "resize-corner",
    "text",
    "move",
    "ew-resize",
    "ns-resize",
    "nesw-resize",
    "nwse-resize",
    "nesw-rotate",
    "nwse-rotate",
    "swne-rotate",
    "senw-rotate",
    "zoom-in",
    "zoom-out"
  ]), oG = YO(_xe), Txe = $t({
    type: oG,
    rotation: nt
  }), aG = nt.check((t) => {
    if (t < 0 || t > 1)
      throw new In("Opacity must be between 0 and 1");
  }), Exe = /* @__PURE__ */ new Set([
    "accent",
    "white",
    "black",
    "selection-stroke",
    "selection-fill",
    "laser",
    "muted-1"
  ]), Ixe = YO(Exe), $xe = /* @__PURE__ */ new Set([
    "starting",
    "paused",
    "active",
    "stopping"
  ]), lG = $t({
    points: so(zv),
    size: f5,
    color: Ixe,
    opacity: nt,
    state: YO($xe),
    delay: nt
  }), Fv = Na("page"), Axe = nu("page", $t({
    typeName: bs("page"),
    id: Fv,
    name: et,
    index: et,
    meta: Ll
  })), Zz = {
    AddMeta: 1
  }, Rxe = Ut({
    currentVersion: Zz.AddMeta,
    migrators: {
      [Zz.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      }
    }
  }), Zc = tu("page", {
    validator: Axe,
    migrations: Rxe,
    scope: "document"
  }).withDefaultProperties(() => ({
    meta: {}
  }));
  function rs(t) {
    return Zc.isId(t);
  }
  Na("instance");
  function Mxe(t) {
    const e = {};
    for (const [r, i] of t)
      e[r] = iG(i);
    const n = nu("instance", $t({
      typeName: bs("instance"),
      id: Na("instance"),
      currentPageId: Fv,
      followingUserId: et.nullable(),
      brush: H0.nullable(),
      opacityForNextShape: aG,
      stylesForNextShape: $t(e),
      cursor: Txe,
      scribble: lG.nullable(),
      isFocusMode: It,
      isDebugMode: It,
      isToolLocked: It,
      exportBackground: It,
      screenBounds: H0,
      zoomBrush: H0.nullable(),
      isPenMode: It,
      isGridMode: It,
      chatMessage: et,
      isChatting: It,
      highlightedUserIds: so(et),
      canMoveCamera: It,
      isFocused: It,
      devicePixelRatio: nt,
      isCoarsePointer: It,
      isHoveringCanvas: It.nullable(),
      openMenus: so(et),
      isChangingStyle: It,
      isReadonly: It,
      meta: Ll
    }));
    return tu("instance", {
      migrations: Dxe,
      validator: n,
      scope: "session"
    }).withDefaultProperties(() => ({
      followingUserId: null,
      opacityForNextShape: 1,
      stylesForNextShape: {},
      brush: null,
      scribble: null,
      cursor: {
        type: "default",
        rotation: 0
      },
      isFocusMode: false,
      exportBackground: false,
      isDebugMode: false,
      isToolLocked: false,
      screenBounds: {
        x: 0,
        y: 0,
        w: 1080,
        h: 720
      },
      zoomBrush: null,
      isGridMode: false,
      isPenMode: false,
      chatMessage: "",
      isChatting: false,
      highlightedUserIds: [],
      canMoveCamera: true,
      isFocused: false,
      devicePixelRatio: typeof window > "u" ? 1 : window.devicePixelRatio,
      isCoarsePointer: false,
      isHoveringCanvas: null,
      openMenus: [],
      isChangingStyle: false,
      isReadonly: false,
      meta: {}
    }));
  }
  const Nn = {
    AddTransparentExportBgs: 1,
    RemoveDialog: 2,
    AddToolLockMode: 3,
    RemoveExtraPropsForNextShape: 4,
    AddLabelColor: 5,
    AddFollowingUserId: 6,
    RemoveAlignJustify: 7,
    AddZoom: 8,
    AddVerticalAlign: 9,
    AddScribbleDelay: 10,
    RemoveUserId: 11,
    AddIsPenModeAndIsGridMode: 12,
    HoistOpacity: 13,
    AddChat: 14,
    AddHighlightedUserIds: 15,
    ReplacePropsForNextShapeWithStylesForNextShape: 16,
    AddMeta: 17,
    RemoveCursorColor: 18,
    AddLonelyProperties: 19,
    ReadOnlyReadonly: 20,
    AddHoveringCanvas: 21
  }, Dxe = Ut({
    currentVersion: Nn.AddHoveringCanvas,
    migrators: {
      [Nn.AddTransparentExportBgs]: {
        up: (t) => ({
          ...t,
          exportBackground: true
        }),
        down: ({ exportBackground: t, ...e }) => e
      },
      [Nn.RemoveDialog]: {
        up: ({ dialog: t, ...e }) => e,
        down: (t) => ({
          ...t,
          dialog: null
        })
      },
      [Nn.AddToolLockMode]: {
        up: (t) => ({
          ...t,
          isToolLocked: false
        }),
        down: ({ isToolLocked: t, ...e }) => e
      },
      [Nn.RemoveExtraPropsForNextShape]: {
        up: ({ propsForNextShape: t, ...e }) => ({
          ...e,
          propsForNextShape: Object.fromEntries(Object.entries(t).filter(([n]) => [
            "color",
            "labelColor",
            "dash",
            "fill",
            "size",
            "font",
            "align",
            "verticalAlign",
            "icon",
            "geo",
            "arrowheadStart",
            "arrowheadEnd",
            "spline"
          ].includes(n)))
        }),
        down: (t) => t
      },
      [Nn.AddLabelColor]: {
        up: ({ propsForNextShape: t, ...e }) => ({
          ...e,
          propsForNextShape: {
            ...t,
            labelColor: "black"
          }
        }),
        down: (t) => {
          const { labelColor: e, ...n } = t.propsForNextShape;
          return {
            ...t,
            propsForNextShape: {
              ...n
            }
          };
        }
      },
      [Nn.AddFollowingUserId]: {
        up: (t) => ({
          ...t,
          followingUserId: null
        }),
        down: ({ followingUserId: t, ...e }) => e
      },
      [Nn.RemoveAlignJustify]: {
        up: (t) => {
          let e = t.propsForNextShape.align;
          return e === "justify" && (e = "start"), {
            ...t,
            propsForNextShape: {
              ...t.propsForNextShape,
              align: e
            }
          };
        },
        down: (t) => ({
          ...t
        })
      },
      [Nn.AddZoom]: {
        up: (t) => ({
          ...t,
          zoomBrush: null
        }),
        down: ({ zoomBrush: t, ...e }) => e
      },
      [Nn.AddVerticalAlign]: {
        up: (t) => ({
          ...t,
          propsForNextShape: {
            ...t.propsForNextShape,
            verticalAlign: "middle"
          }
        }),
        down: (t) => {
          const { verticalAlign: e, ...n } = t.propsForNextShape;
          return {
            ...t,
            propsForNextShape: n
          };
        }
      },
      [Nn.AddScribbleDelay]: {
        up: (t) => t.scribble !== null ? {
          ...t,
          scribble: {
            ...t.scribble,
            delay: 0
          }
        } : {
          ...t
        },
        down: (t) => {
          if (t.scribble !== null) {
            const { delay: e, ...n } = t.scribble;
            return {
              ...t,
              scribble: n
            };
          }
          return {
            ...t
          };
        }
      },
      [Nn.RemoveUserId]: {
        up: ({ userId: t, ...e }) => e,
        down: (t) => ({
          ...t,
          userId: "user:none"
        })
      },
      [Nn.AddIsPenModeAndIsGridMode]: {
        up: (t) => ({
          ...t,
          isPenMode: false,
          isGridMode: false
        }),
        down: ({ isPenMode: t, isGridMode: e, ...n }) => n
      },
      [Nn.HoistOpacity]: {
        up: ({ propsForNextShape: { opacity: t, ...e }, ...n }) => ({
          ...n,
          opacityForNextShape: Number(t ?? "1"),
          propsForNextShape: e
        }),
        down: ({ opacityForNextShape: t, ...e }) => ({
          ...e,
          propsForNextShape: {
            ...e.propsForNextShape,
            opacity: t < 0.175 ? "0.1" : t < 0.375 ? "0.25" : t < 0.625 ? "0.5" : t < 0.875 ? "0.75" : "1"
          }
        })
      },
      [Nn.AddChat]: {
        up: (t) => ({
          ...t,
          chatMessage: "",
          isChatting: false
        }),
        down: ({ chatMessage: t, isChatting: e, ...n }) => n
      },
      [Nn.AddHighlightedUserIds]: {
        up: (t) => ({
          ...t,
          highlightedUserIds: []
        }),
        down: ({ highlightedUserIds: t, ...e }) => e
      },
      [Nn.ReplacePropsForNextShapeWithStylesForNextShape]: {
        up: ({ propsForNextShape: t, ...e }) => ({
          ...e,
          stylesForNextShape: {}
        }),
        down: ({ stylesForNextShape: t, ...e }) => ({
          ...e,
          propsForNextShape: {
            color: "black",
            labelColor: "black",
            dash: "draw",
            fill: "none",
            size: "m",
            icon: "file",
            font: "draw",
            align: "middle",
            verticalAlign: "middle",
            geo: "rectangle",
            arrowheadStart: "none",
            arrowheadEnd: "arrow",
            spline: "line"
          }
        })
      },
      [Nn.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      },
      [Nn.RemoveCursorColor]: {
        up: (t) => {
          const { color: e, ...n } = t.cursor;
          return {
            ...t,
            cursor: n
          };
        },
        down: (t) => ({
          ...t,
          cursor: {
            ...t.cursor,
            color: "black"
          }
        })
      },
      [Nn.AddLonelyProperties]: {
        up: (t) => ({
          ...t,
          canMoveCamera: true,
          isFocused: false,
          devicePixelRatio: 1,
          isCoarsePointer: false,
          openMenus: [],
          isChangingStyle: false,
          isReadOnly: false
        }),
        down: ({ canMoveCamera: t, isFocused: e, devicePixelRatio: n, isCoarsePointer: r, openMenus: i, isChangingStyle: s, isReadOnly: o, ...a }) => ({
          ...a
        })
      },
      [Nn.ReadOnlyReadonly]: {
        up: ({ isReadOnly: t, ...e }) => ({
          ...e,
          isReadonly: t
        }),
        down: ({ isReadonly: t, ...e }) => ({
          ...e,
          isReadOnly: t
        })
      },
      [Nn.AddHoveringCanvas]: {
        up: (t) => ({
          ...t,
          isHoveringCanvas: null
        }),
        down: ({ isHoveringCanvas: t, ...e }) => ({
          ...e
        })
      }
    }
  }), gi = "instance:instance", Lxe = et.refine((t) => {
    if (!t.startsWith("page:") && !t.startsWith("shape:"))
      throw new Error('Parent ID must start with "page:" or "shape:"');
    return t;
  }), ba = Na("shape");
  function jxe(t, e, n) {
    return $t({
      id: ba,
      typeName: bs("shape"),
      x: nt,
      y: nt,
      rotation: nt,
      index: et,
      parentId: Lxe,
      type: bs(t),
      isLocked: It,
      opacity: aG,
      props: e ? $t(e) : Ll,
      meta: n ? $t(n) : Ll
    });
  }
  const Nxe = nu("instance_page_state", $t({
    typeName: bs("instance_page_state"),
    id: Na("instance_page_state"),
    pageId: Fv,
    selectedShapeIds: so(ba),
    hintingShapeIds: so(ba),
    erasingShapeIds: so(ba),
    hoveredShapeId: ba.nullable(),
    editingShapeId: ba.nullable(),
    croppingShapeId: ba.nullable(),
    focusedGroupId: ba.nullable(),
    meta: Ll
  })), dp = {
    AddCroppingId: 1,
    RemoveInstanceIdAndCameraId: 2,
    AddMeta: 3,
    RenameProperties: 4,
    RenamePropertiesAgain: 5
  }, Qxe = Ut({
    currentVersion: dp.RenamePropertiesAgain,
    migrators: {
      [dp.AddCroppingId]: {
        up(t) {
          return {
            ...t,
            croppingShapeId: null
          };
        },
        down({ croppingShapeId: t, ...e }) {
          return e;
        }
      },
      [dp.RemoveInstanceIdAndCameraId]: {
        up({ instanceId: t, cameraId: e, ...n }) {
          return n;
        },
        down(t) {
          return {
            ...t,
            instanceId: gi,
            cameraId: Nr.createId("void")
          };
        }
      },
      [dp.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      },
      [dp.RenameProperties]: {
        up: (t) => {
          const { selectedShapeIds: e, hintingShapeIds: n, erasingShapeIds: r, hoveredShapeId: i, editingShapeId: s, croppingShapeId: o, focusedGroupId: a, ...l } = t;
          return {
            selectedShapeIds: e,
            hintingShapeIds: n,
            erasingShapeIds: r,
            hoveredShapeId: i,
            editingShapeId: s,
            croppingShapeId: o,
            focusedGroupId: a,
            ...l
          };
        },
        down: (t) => {
          const { selectedShapeIds: e, hintingShapeIds: n, erasingShapeIds: r, hoveredShapeId: i, editingShapeId: s, croppingShapeId: o, focusedGroupId: a, ...l } = t;
          return {
            selectedShapeIds: e,
            hintingShapeIds: n,
            erasingShapeIds: r,
            hoveredShapeId: i,
            editingShapeId: s,
            croppingShapeId: o,
            focusedGroupId: a,
            ...l
          };
        }
      },
      [dp.RenamePropertiesAgain]: {
        up: (t) => {
          const { selectedIds: e, hintingIds: n, erasingIds: r, hoveredId: i, editingId: s, croppingId: o, focusLayerId: a, ...l } = t;
          return {
            ...l,
            selectedShapeIds: e,
            hintingShapeIds: n,
            erasingShapeIds: r,
            hoveredShapeId: i,
            editingShapeId: s,
            croppingShapeId: o,
            focusedGroupId: a
          };
        },
        down: (t) => {
          const { selectedShapeIds: e, hintingShapeIds: n, erasingShapeIds: r, hoveredShapeId: i, editingShapeId: s, croppingShapeId: o, focusedGroupId: a, ...l } = t;
          return {
            ...l,
            selectedIds: e,
            hintingIds: n,
            erasingIds: r,
            hoveredId: i,
            editingId: s,
            croppingId: o,
            focusLayerId: a
          };
        }
      }
    }
  }), Qr = tu("instance_page_state", {
    migrations: Qxe,
    validator: Nxe,
    scope: "session"
  }).withDefaultProperties(() => ({
    editingShapeId: null,
    croppingShapeId: null,
    selectedShapeIds: [],
    hoveredShapeId: null,
    erasingShapeIds: [],
    hintingShapeIds: [],
    focusedGroupId: null,
    meta: {}
  })), zxe = nu("pointer", $t({
    typeName: bs("pointer"),
    id: Na("pointer"),
    x: nt,
    y: nt,
    lastActivityTimestamp: nt,
    meta: Ll
  })), Hz = {
    AddMeta: 1
  }, Fxe = Ut({
    currentVersion: Hz.AddMeta,
    migrators: {
      [Hz.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      }
    }
  }), m5 = tu("pointer", {
    validator: zxe,
    migrations: Fxe,
    scope: "session"
  }).withDefaultProperties(() => ({
    x: 0,
    y: 0,
    lastActivityTimestamp: 0,
    meta: {}
  })), Bv = m5.createId("pointer"), Bxe = nu("instance_presence", $t({
    typeName: bs("instance_presence"),
    id: Na("instance_presence"),
    userId: et,
    userName: et,
    lastActivityTimestamp: nt,
    followingUserId: et.nullable(),
    cursor: $t({
      x: nt,
      y: nt,
      type: oG,
      rotation: nt
    }),
    color: et,
    camera: $t({
      x: nt,
      y: nt,
      z: nt
    }),
    screenBounds: H0,
    selectedShapeIds: so(Na("shape")),
    currentPageId: Na("page"),
    brush: H0.nullable(),
    scribble: lG.nullable(),
    chatMessage: et,
    meta: Ll
  })), hp = {
    AddScribbleDelay: 1,
    RemoveInstanceId: 2,
    AddChatMessage: 3,
    AddMeta: 4,
    RenameSelectedShapeIds: 5
  }, Uxe = Ut({
    currentVersion: hp.RenameSelectedShapeIds,
    migrators: {
      [hp.AddScribbleDelay]: {
        up: (t) => t.scribble !== null ? {
          ...t,
          scribble: {
            ...t.scribble,
            delay: 0
          }
        } : {
          ...t
        },
        down: (t) => {
          if (t.scribble !== null) {
            const { delay: e, ...n } = t.scribble;
            return {
              ...t,
              scribble: n
            };
          }
          return {
            ...t
          };
        }
      },
      [hp.RemoveInstanceId]: {
        up: ({ instanceId: t, ...e }) => e,
        down: (t) => ({
          ...t,
          instanceId: gi
        })
      },
      [hp.AddChatMessage]: {
        up: (t) => ({
          ...t,
          chatMessage: ""
        }),
        down: ({ chatMessage: t, ...e }) => e
      },
      [hp.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      },
      [hp.RenameSelectedShapeIds]: {
        up: (t) => {
          const { selectedShapeIds: e, ...n } = t;
          return {
            selectedShapeIds: e,
            ...n
          };
        },
        down: (t) => {
          const { selectedShapeIds: e, ...n } = t;
          return {
            selectedShapeIds: e,
            ...n
          };
        }
      }
    }
  }), yk = tu("instance_presence", {
    migrations: Uxe,
    validator: Bxe,
    scope: "presence"
  }).withDefaultProperties(() => ({
    lastActivityTimestamp: 0,
    followingUserId: null,
    color: "#FF0000",
    camera: {
      x: 0,
      y: 0,
      z: 1
    },
    cursor: {
      x: 0,
      y: 0,
      type: "default",
      rotation: 0
    },
    screenBounds: {
      x: 0,
      y: 0,
      w: 1,
      h: 1
    },
    selectedShapeIds: [],
    brush: null,
    scribble: null,
    chatMessage: "",
    meta: {}
  })), Vxe = (t, e) => (n) => ve("instancePresence", () => {
    const r = n.get(gi), i = n.get(Qr.createId(r == null ? void 0 : r.currentPageId)), s = n.get(Nr.createId(r == null ? void 0 : r.currentPageId)), o = n.get(Bv), a = t.value;
    return !i || !r || !s || !o || !a ? null : yk.create({
      id: e ?? yk.createId(n.id),
      selectedShapeIds: i.selectedShapeIds,
      brush: r.brush,
      scribble: r.scribble,
      userId: a.id,
      userName: a.name,
      followingUserId: r.followingUserId,
      camera: {
        x: s.x,
        y: s.y,
        z: s.z
      },
      color: a.color,
      currentPageId: r.currentPageId,
      cursor: {
        x: o.x,
        y: o.y,
        rotation: r.cursor.rotation,
        type: r.cursor.type
      },
      lastActivityTimestamp: o.lastActivityTimestamp,
      screenBounds: r.screenBounds,
      chatMessage: r.chatMessage,
      meta: {}
    });
  }), Xxe = nu("document", $t({
    typeName: bs("document"),
    id: bs("document:document"),
    gridSize: nt,
    name: et,
    meta: Ll
  })), mE = {
    AddName: 1,
    AddMeta: 2
  }, Wxe = Ut({
    currentVersion: mE.AddMeta,
    migrators: {
      [mE.AddName]: {
        up: (t) => ({
          ...t,
          name: ""
        }),
        down: ({ name: t, ...e }) => e
      },
      [mE.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      }
    }
  }), y5 = tu("document", {
    migrations: Wxe,
    validator: Xxe,
    scope: "document"
  }).withDefaultProperties(() => ({
    gridSize: 10,
    name: "",
    meta: {}
  })), eR = y5.createId("document");
  function Zxe(t, e) {
    return t.index < e.index ? -1 : t.index > e.index ? 1 : 0;
  }
  function Yz(t) {
    t.typeName === "asset" && ("src" in t && (t.src = "<redacted>"), "src" in t.props && (t.props.src = "<redacted>"));
  }
  const Hxe = ({ error: t, phase: e, record: n, recordBefore: r }) => {
    throw a5(t, {
      tags: {
        origin: "store.validateRecord",
        storePhase: e,
        isExistingValidationIssue: e === "initialize"
      },
      extras: {
        recordBefore: r ? Yz(Dc(r)) : void 0,
        recordAfter: Yz(Dc(n))
      }
    }), t;
  };
  function Yxe() {
    return [
      Zc.create({
        id: "page:page",
        name: "Page 1",
        index: "a1",
        meta: {}
      })
    ];
  }
  function Gxe(t) {
    const e = t.query.ids("page"), n = () => {
      if (!t.has(eR))
        return t.put([
          y5.create({
            id: eR,
            name: t.props.defaultName
          })
        ]), n();
      if (!t.has(Bv))
        return t.put([
          m5.create({
            id: Bv
          })
        ]), n();
      const r = e.value;
      if (r.size === 0)
        return t.put(Yxe()), n();
      const i = () => [
        ...r
      ].map((l) => t.get(l)).sort(Zxe)[0].id, s = t.get(gi);
      if (s) {
        if (!r.has(s.currentPageId))
          return t.put([
            {
              ...s,
              currentPageId: i()
            }
          ]), n();
      } else
        return t.put([
          t.schema.types.instance.create({
            id: gi,
            currentPageId: i(),
            exportBackground: true
          })
        ]), n();
      const o = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
      for (const l of r) {
        const c = Qr.createId(l);
        t.has(c) || o.add(c);
        const u = Nr.createId(l);
        t.has(u) || a.add(u);
      }
      o.size > 0 && t.put([
        ...o
      ].map((l) => Qr.create({
        id: l,
        pageId: Qr.parseId(l)
      }))), a.size > 0 && t.put([
        ...a
      ].map((l) => Nr.create({
        id: l
      })));
    };
    return n;
  }
  const qxe = g5("bookmark", $t({
    title: et,
    description: et,
    image: et,
    src: et.nullable()
  })), Kxe = Ut({}), Jxe = g5("image", $t({
    w: nt,
    h: nt,
    name: et,
    isAnimated: It,
    mimeType: et.nullable(),
    src: et.nullable()
  })), yE = {
    AddIsAnimated: 1,
    RenameWidthHeight: 2
  }, ebe = Ut({
    currentVersion: yE.RenameWidthHeight,
    migrators: {
      [yE.AddIsAnimated]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            isAnimated: false
          }
        }),
        down: (t) => {
          const { isAnimated: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      },
      [yE.RenameWidthHeight]: {
        up: (t) => {
          const { width: e, height: n, ...r } = t.props;
          return {
            ...t,
            props: {
              w: e,
              h: n,
              ...r
            }
          };
        },
        down: (t) => {
          const { w: e, h: n, ...r } = t.props;
          return {
            ...t,
            props: {
              width: e,
              height: n,
              ...r
            }
          };
        }
      }
    }
  }), tbe = g5("video", $t({
    w: nt,
    h: nt,
    name: et,
    isAnimated: It,
    mimeType: et.nullable(),
    src: et.nullable()
  })), vE = {
    AddIsAnimated: 1,
    RenameWidthHeight: 2
  }, nbe = Ut({
    currentVersion: vE.RenameWidthHeight,
    migrators: {
      [vE.AddIsAnimated]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            isAnimated: false
          }
        }),
        down: (t) => {
          const { isAnimated: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      },
      [vE.RenameWidthHeight]: {
        up: (t) => {
          const { width: e, height: n, ...r } = t.props;
          return {
            ...t,
            props: {
              w: e,
              h: n,
              ...r
            }
          };
        },
        down: (t) => {
          const { w: e, h: n, ...r } = t.props;
          return {
            ...t,
            props: {
              width: e,
              height: n,
              ...r
            }
          };
        }
      }
    }
  }), rbe = nu("asset", p5("type", {
    image: Jxe,
    video: tbe,
    bookmark: qxe
  })), Gz = {
    AddMeta: 1
  }, ibe = Ut({
    subTypeKey: "type",
    subTypeMigrations: {
      image: ebe,
      video: nbe,
      bookmark: Kxe
    },
    currentVersion: Gz.AddMeta,
    migrators: {
      [Gz.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      }
    }
  }), Mh = tu("asset", {
    migrations: ibe,
    validator: rbe,
    scope: "document"
  }).withDefaultProperties(() => ({
    meta: {}
  }));
  class Ci {
    constructor(e, n, r) {
      this.id = e, this.defaultValue = n, this.type = r;
    }
    static define(e, n) {
      const { defaultValue: r, type: i = wxe } = n;
      return new Ci(e, r, i);
    }
    static defineEnum(e, n) {
      const { defaultValue: r, values: i } = n;
      return new sbe(e, r, i);
    }
    validate(e) {
      return this.type.validate(e);
    }
  }
  class sbe extends Ci {
    constructor(e, n, r) {
      super(e, n, sG(...r)), this.values = r;
    }
  }
  const hw = {
    AddIsLocked: 1,
    HoistOpacity: 2,
    AddMeta: 3
  }, OE = Ut({
    currentVersion: hw.AddMeta,
    migrators: {
      [hw.AddIsLocked]: {
        up: (t) => ({
          ...t,
          isLocked: false
        }),
        down: (t) => {
          const { isLocked: e, ...n } = t;
          return {
            ...n
          };
        }
      },
      [hw.HoistOpacity]: {
        up: ({ props: { opacity: t, ...e }, ...n }) => ({
          ...n,
          opacity: Number(t ?? "1"),
          props: e
        }),
        down: ({ opacity: t, ...e }) => ({
          ...e,
          props: {
            ...e.props,
            opacity: t < 0.175 ? "0.1" : t < 0.375 ? "0.25" : t < 0.625 ? "0.5" : t < 0.875 ? "0.75" : "1"
          }
        })
      },
      [hw.AddMeta]: {
        up: (t) => ({
          ...t,
          meta: {}
        }),
        down: ({ meta: t, ...e }) => ({
          ...e
        })
      }
    }
  });
  function Dh(t) {
    return t ? t.typeName === "shape" : false;
  }
  function Ro(t) {
    return t ? t.startsWith("shape:") : false;
  }
  function bn(t) {
    return `shape:${t ?? kC()}`;
  }
  function cG(t) {
    const e = /* @__PURE__ */ new Map();
    for (const [n, r] of Object.entries(t))
      if (r instanceof Ci) {
        if (e.has(r))
          throw new Error(`Duplicate style prop ${r.id}. Each style prop can only be used once within a shape.`);
        e.set(r, n);
      }
    return e;
  }
  function obe(t) {
    return tu("shape", {
      migrations: Ut({
        currentVersion: OE.currentVersion,
        firstVersion: OE.firstVersion,
        migrators: OE.migrators,
        subTypeKey: "type",
        subTypeMigrations: Bz(t, (e, n) => n.migrations ?? Ut({}))
      }),
      scope: "document",
      validator: nu("shape", p5("type", Bz(t, (e, { props: n, meta: r }) => jxe(e, n, r))))
    }).withDefaultProperties(() => ({
      x: 0,
      y: 0,
      rotation: 0,
      isLocked: false,
      opacity: 1,
      meta: {}
    }));
  }
  const Dy = {
    RemoveCodeAndIconShapeTypes: 1,
    AddInstancePresenceType: 2,
    RemoveTLUserAndPresenceAndAddPointer: 3,
    RemoveUserDocument: 4
  }, abe = Ut({
    currentVersion: Dy.RemoveUserDocument,
    migrators: {
      [Dy.RemoveCodeAndIconShapeTypes]: {
        up: (t) => Object.fromEntries(Object.entries(t).filter(([e, n]) => n.typeName !== "shape" || n.type !== "icon" && n.type !== "code")),
        down: (t) => t
      },
      [Dy.AddInstancePresenceType]: {
        up: (t) => t,
        down: (t) => Object.fromEntries(Object.entries(t).filter(([e, n]) => n.typeName !== "instance_presence"))
      },
      [Dy.RemoveTLUserAndPresenceAndAddPointer]: {
        up: (t) => Object.fromEntries(Object.entries(t).filter(([e, n]) => !n.typeName.match(/^(user|user_presence)$/))),
        down: (t) => Object.fromEntries(Object.entries(t).filter(([e, n]) => n.typeName !== "pointer"))
      },
      [Dy.RemoveUserDocument]: {
        up: (t) => Object.fromEntries(Object.entries(t).filter(([e, n]) => !n.typeName.match("user_document"))),
        down: (t) => t
      }
    }
  });
  function lbe({ shapes: t }) {
    const e = /* @__PURE__ */ new Map();
    for (const i of Qn(t))
      for (const s of cG(i.props ?? {}).keys()) {
        if (e.has(s.id) && e.get(s.id) !== s)
          throw new Error(`Multiple StyleProp instances with the same id: ${s.id}`);
        e.set(s.id, s);
      }
    const n = obe(t), r = Mxe(e);
    return u5.create({
      asset: Mh,
      camera: Nr,
      document: y5,
      instance: r,
      instance_page_state: Qr,
      page: Zc,
      shape: n,
      instance_presence: yk,
      pointer: m5
    }, {
      snapshotMigrations: abe,
      onValidationFailure: Hxe,
      createIntegrityChecker: Gxe
    });
  }
  const uG = [
    "black",
    "grey",
    "light-violet",
    "violet",
    "blue",
    "light-blue",
    "yellow",
    "orange",
    "green",
    "light-green",
    "light-red",
    "red"
  ], vk = {
    lightMode: {
      id: "light",
      text: "#000000",
      background: "rgb(249, 250, 251)",
      solid: "#fcfffe",
      black: {
        solid: "#1d1d1d",
        semi: "#e8e8e8",
        pattern: "#494949",
        highlight: {
          srgb: "#fddd00",
          p3: "color(display-p3 0.972 0.8705 0.05)"
        }
      },
      blue: {
        solid: "#4263eb",
        semi: "#dce1f8",
        pattern: "#6681ee",
        highlight: {
          srgb: "#10acff",
          p3: "color(display-p3 0.308 0.6632 0.9996)"
        }
      },
      green: {
        solid: "#099268",
        semi: "#d3e9e3",
        pattern: "#39a785",
        highlight: {
          srgb: "#00ffc8",
          p3: "color(display-p3 0.2536 0.984 0.7981)"
        }
      },
      grey: {
        solid: "#adb5bd",
        semi: "#eceef0",
        pattern: "#bcc3c9",
        highlight: {
          srgb: "#cbe7f1",
          p3: "color(display-p3 0.8163 0.9023 0.9416)"
        }
      },
      "light-blue": {
        solid: "#4dabf7",
        semi: "#ddedfa",
        pattern: "#6fbbf8",
        highlight: {
          srgb: "#00f4ff",
          p3: "color(display-p3 0.1512 0.9414 0.9996)"
        }
      },
      "light-green": {
        solid: "#40c057",
        semi: "#dbf0e0",
        pattern: "#65cb78",
        highlight: {
          srgb: "#65f641",
          p3: "color(display-p3 0.563 0.9495 0.3857)"
        }
      },
      "light-red": {
        solid: "#ff8787",
        semi: "#f4dadb",
        pattern: "#fe9e9e",
        highlight: {
          srgb: "#ff7fa3",
          p3: "color(display-p3 0.9988 0.5301 0.6397)"
        }
      },
      "light-violet": {
        solid: "#e599f7",
        semi: "#f5eafa",
        pattern: "#e9acf8",
        highlight: {
          srgb: "#ff88ff",
          p3: "color(display-p3 0.9676 0.5652 0.9999)"
        }
      },
      orange: {
        solid: "#f76707",
        semi: "#f8e2d4",
        pattern: "#f78438",
        highlight: {
          srgb: "#ffa500",
          p3: "color(display-p3 0.9988 0.6905 0.266)"
        }
      },
      red: {
        solid: "#e03131",
        semi: "#f4dadb",
        pattern: "#e55959",
        highlight: {
          srgb: "#ff636e",
          p3: "color(display-p3 0.9992 0.4376 0.45)"
        }
      },
      violet: {
        solid: "#ae3ec9",
        semi: "#ecdcf2",
        pattern: "#bd63d3",
        highlight: {
          srgb: "#c77cff",
          p3: "color(display-p3 0.7469 0.5089 0.9995)"
        }
      },
      yellow: {
        solid: "#ffc078",
        semi: "#f9f0e6",
        pattern: "#fecb92",
        highlight: {
          srgb: "#fddd00",
          p3: "color(display-p3 0.972 0.8705 0.05)"
        }
      }
    },
    darkMode: {
      id: "dark",
      text: "#f8f9fa",
      background: "#212529",
      solid: "#28292e",
      black: {
        solid: "#e1e1e1",
        semi: "#2c3036",
        pattern: "#989898",
        highlight: {
          srgb: "#d2b700",
          p3: "color(display-p3 0.8078 0.7225 0.0312)"
        }
      },
      blue: {
        solid: "#4156be",
        semi: "#262d40",
        pattern: "#3a4b9e",
        highlight: {
          srgb: "#0079d2",
          p3: "color(display-p3 0.0032 0.4655 0.7991)"
        }
      },
      green: {
        solid: "#3b7b5e",
        semi: "#253231",
        pattern: "#366a53",
        highlight: {
          srgb: "#009774",
          p3: "color(display-p3 0.0085 0.582 0.4604)"
        }
      },
      grey: {
        solid: "#93989f",
        semi: "#33373c",
        pattern: "#7c8187",
        highlight: {
          srgb: "#9cb4cb",
          p3: "color(display-p3 0.6299 0.7012 0.7856)"
        }
      },
      "light-blue": {
        solid: "#588fc9",
        semi: "#2a3642",
        pattern: "#4d7aa9",
        highlight: {
          srgb: "#00bdc8",
          p3: "color(display-p3 0.0023 0.7259 0.7735)"
        }
      },
      "light-green": {
        solid: "#599f57",
        semi: "#2a3830",
        pattern: "#4e874e",
        highlight: {
          srgb: "#00a000",
          p3: "color(display-p3 0.2711 0.6172 0.0195)"
        }
      },
      "light-red": {
        solid: "#c67877",
        semi: "#3b3235",
        pattern: "#a56767",
        highlight: {
          srgb: "#db005b",
          p3: "color(display-p3 0.7849 0.0585 0.3589)"
        }
      },
      "light-violet": {
        solid: "#b583c9",
        semi: "#383442",
        pattern: "#9770a9",
        highlight: {
          srgb: "#c400c7",
          p3: "color(display-p3 0.7024 0.0403 0.753)"
        }
      },
      orange: {
        solid: "#bf612e",
        semi: "#3a2e2a",
        pattern: "#9f552d",
        highlight: {
          srgb: "#d07a00",
          p3: "color(display-p3 0.7699 0.4937 0.0085)"
        }
      },
      red: {
        solid: "#aa3c37",
        semi: "#36292b",
        pattern: "#8f3734",
        highlight: {
          srgb: "#de002c",
          p3: "color(display-p3 0.7978 0.0509 0.2035)"
        }
      },
      violet: {
        solid: "#873fa3",
        semi: "#31293c",
        pattern: "#763a8b",
        highlight: {
          srgb: "#9e00ee",
          p3: "color(display-p3 0.5651 0.0079 0.8986)"
        }
      },
      yellow: {
        solid: "#cba371",
        semi: "#3c3934",
        pattern: "#fecb92",
        highlight: {
          srgb: "#d2b700",
          p3: "color(display-p3 0.8078 0.7225 0.0312)"
        }
      }
    }
  };
  function ks(t) {
    return t.isDarkMode ? vk.darkMode : vk.lightMode;
  }
  const na = Ci.defineEnum("tldraw:color", {
    defaultValue: "black",
    values: uG
  }), dG = Ci.defineEnum("tldraw:labelColor", {
    defaultValue: "black",
    values: uG
  }), sf = Ci.defineEnum("tldraw:dash", {
    defaultValue: "draw",
    values: [
      "draw",
      "solid",
      "dashed",
      "dotted"
    ]
  }), jg = Ci.defineEnum("tldraw:fill", {
    defaultValue: "none",
    values: [
      "none",
      "semi",
      "solid",
      "pattern"
    ]
  }), jl = Ci.defineEnum("tldraw:font", {
    defaultValue: "draw",
    values: [
      "draw",
      "sans",
      "serif",
      "mono"
    ]
  }), GO = {
    draw: "'tldraw_draw', sans-serif",
    sans: "'tldraw_sans', sans-serif",
    serif: "'tldraw_serif', serif",
    mono: "'tldraw_mono', monospace"
  }, Nl = Ci.defineEnum("tldraw:size", {
    defaultValue: "m",
    values: [
      "s",
      "m",
      "l",
      "xl"
    ]
  }), hG = [
    "arrow",
    "triangle",
    "square",
    "dot",
    "pipe",
    "diamond",
    "inverted",
    "bar",
    "none"
  ], Ok = Ci.defineEnum("tldraw:arrowheadStart", {
    defaultValue: "none",
    values: hG
  }), Sk = Ci.defineEnum("tldraw:arrowheadEnd", {
    defaultValue: "arrow",
    values: hG
  }), qz = p5("type", {
    binding: $t({
      type: bs("binding"),
      boundShapeId: ba,
      normalizedAnchor: zv,
      isExact: It
    }),
    point: $t({
      type: bs("point"),
      x: nt,
      y: nt
    })
  }), cbe = {
    labelColor: dG,
    color: na,
    fill: jg,
    dash: sf,
    size: Nl,
    arrowheadStart: Ok,
    arrowheadEnd: Sk,
    font: jl,
    start: qz,
    end: qz,
    bend: nt,
    text: et
  }, Kz = {
    AddLabelColor: 1
  }, ube = Ut({
    currentVersion: Kz.AddLabelColor,
    migrators: {
      [Kz.AddLabelColor]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            labelColor: "black"
          }
        }),
        down: (t) => {
          const { labelColor: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      }
    }
  }), dbe = {
    w: xs,
    h: xs,
    assetId: CC.nullable(),
    url: et
  }, Jz = {
    NullAssetId: 1
  }, hbe = Ut({
    currentVersion: Jz.NullAssetId,
    migrators: {
      [Jz.NullAssetId]: {
        up: (t) => t.props.assetId === void 0 ? {
          ...t,
          props: {
            ...t.props,
            assetId: null
          }
        } : t,
        down: (t) => {
          if (t.props.assetId === null) {
            const { assetId: e, ...n } = t.props;
            return {
              ...t,
              props: n
            };
          }
          return t;
        }
      }
    }
  }), fG = $t({
    type: sG("free", "straight"),
    points: so(zv)
  }), fbe = {
    color: na,
    fill: jg,
    dash: sf,
    size: Nl,
    segments: so(fG),
    isComplete: It,
    isClosed: It,
    isPen: It
  }, e8 = {
    AddInPen: 1
  }, pbe = Ut({
    currentVersion: e8.AddInPen,
    migrators: {
      [e8.AddInPen]: {
        up: (t) => {
          const { points: e } = t.props.segments[0];
          if (e.length === 0)
            return {
              ...t,
              props: {
                ...t.props,
                isPen: false
              }
            };
          let n = !(e[0].z === 0 || e[0].z === 0.5);
          return e[1] && (n = n && !(e[1].z === 0 || e[1].z === 0.5)), {
            ...t,
            props: {
              ...t.props,
              isPen: n
            }
          };
        },
        down: (t) => {
          const { isPen: e, ...n } = t.props;
          return {
            ...t,
            props: {
              ...n
            }
          };
        }
      }
    }
  }), t8 = /(^\/r\/[^/]+\/?$)/, qt = (t) => {
    try {
      return new URL(t);
    } catch {
      return;
    }
  }, Ng = [
    {
      type: "tldraw",
      title: "tldraw",
      hostnames: [
        "beta.tldraw.com",
        "tldraw.com"
      ],
      minWidth: 300,
      minHeight: 300,
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: true,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(t8))
          return t;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(t8))
          return t;
      }
    },
    {
      type: "figma",
      title: "Figma",
      hostnames: [
        "figma.com"
      ],
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: true,
      toEmbedUrl: (t) => {
        if (t.match(/https:\/\/([\w\.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/) && !t.includes("figma.com/embed"))
          return `https://www.figma.com/embed?embed_host=share&url=${t}`;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/^\/embed\/?$/)) {
          const n = e.searchParams.get("url");
          if (n)
            return n;
        }
      }
    },
    {
      type: "google_maps",
      title: "Google Maps",
      hostnames: [
        "google.*"
      ],
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: false,
      toEmbedUrl: (t) => {
        if (t.includes("/maps/")) {
          const e = t.match(/@(.*),(.*),(.*)z/);
          let n;
          if (e) {
            const [, r, i, s] = e;
            n = `https://${new URL(t).host.replace("www.", "")}/maps/embed/v1/view?key=${{}.NEXT_PUBLIC_GC_API_KEY}&center=${r},${i}&zoom=${s}`;
          } else
            n = "";
          return n;
        }
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (!e)
          return;
        if (e.pathname.match(/^\/maps\/embed\/v1\/view\/?$/) && e.searchParams.has("center") && e.searchParams.get("zoom")) {
          const r = e.searchParams.get("zoom"), [i, s] = e.searchParams.get("center").split(",");
          return `https://www.google.com/maps/@${i},${s},${r}z`;
        }
      }
    },
    {
      type: "val_town",
      title: "Val Town",
      hostnames: [
        "val.town"
      ],
      minWidth: 260,
      minHeight: 100,
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: false,
      toEmbedUrl: (t) => {
        const e = qt(t), n = e && e.pathname.match(/\/v\/([^/]+)\/?/);
        if (n)
          return `https://www.val.town/embed/${n[1]}`;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t), n = e && e.pathname.match(/\/embed\/([^/]+)\/?/);
        if (n)
          return `https://www.val.town/v/${n[1]}`;
      }
    },
    {
      type: "codesandbox",
      title: "CodeSandbox",
      hostnames: [
        "codesandbox.io"
      ],
      minWidth: 300,
      minHeight: 300,
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: false,
      toEmbedUrl: (t) => {
        const e = qt(t), n = e && e.pathname.match(/\/s\/([^/]+)\/?/);
        if (n)
          return `https://codesandbox.io/embed/${n[1]}`;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t), n = e && e.pathname.match(/\/embed\/([^/]+)\/?/);
        if (n)
          return `https://codesandbox.io/s/${n[1]}`;
      }
    },
    {
      type: "codepen",
      title: "Codepen",
      hostnames: [
        "codepen.io"
      ],
      minWidth: 300,
      minHeight: 300,
      width: 520,
      height: 400,
      doesResize: true,
      canUnmount: false,
      toEmbedUrl: (t) => {
        const e = /https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/, n = t.match(e);
        if (n) {
          const [r, i, s] = n;
          return `https://codepen.io/${i}/embed/${s}`;
        }
      },
      fromEmbedUrl: (t) => {
        const e = /https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/, n = t.match(e);
        if (n) {
          const [r, i, s] = n;
          return `https://codepen.io/${i}/pen/${s}`;
        }
      }
    },
    {
      type: "scratch",
      title: "Scratch",
      hostnames: [
        "scratch.mit.edu"
      ],
      width: 520,
      height: 400,
      doesResize: false,
      canUnmount: false,
      toEmbedUrl: (t) => {
        const e = /https?:\/\/scratch.mit.edu\/projects\/([^/]+)/, n = t.match(e);
        if (n) {
          const [r, i] = n;
          return `https://scratch.mit.edu/projects/embed/${i}`;
        }
      },
      fromEmbedUrl: (t) => {
        const e = /https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/, n = t.match(e);
        if (n) {
          const [r, i] = n;
          return `https://scratch.mit.edu/projects/${i}`;
        }
      }
    },
    {
      type: "youtube",
      title: "YouTube",
      hostnames: [
        "*.youtube.com",
        "youtube.com",
        "youtu.be"
      ],
      width: 800,
      height: 450,
      doesResize: true,
      canUnmount: false,
      overridePermissions: {
        "allow-presentation": true
      },
      isAspectRatioLocked: true,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (!e)
          return;
        const n = e.hostname.replace(/^www./, "");
        if (n === "youtu.be")
          return `https://www.youtube.com/embed/${e.pathname.split("/").filter(Boolean)[0]}`;
        if ((n === "youtube.com" || n === "m.youtube.com") && e.pathname.match(/^\/watch/))
          return `https://www.youtube.com/embed/${e.searchParams.get("v")}`;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (!e)
          return;
        if (e.hostname.replace(/^www./, "") === "youtube.com") {
          const r = e.pathname.match(/^\/embed\/([^/]+)\/?/);
          if (r)
            return `https://www.youtube.com/watch?v=${r[1]}`;
        }
      }
    },
    {
      type: "google_calendar",
      title: "Google Calendar",
      hostnames: [
        "calendar.google.*"
      ],
      width: 720,
      height: 500,
      minWidth: 460,
      minHeight: 360,
      doesResize: true,
      canUnmount: false,
      instructionLink: "https://support.google.com/calendar/answer/41207?hl=en",
      toEmbedUrl: (t) => {
        const e = qt(t), n = e == null ? void 0 : e.searchParams.get("cid");
        if ((e == null ? void 0 : e.pathname.match(/\/calendar\/u\/0/)) && n) {
          e.pathname = "/calendar/embed";
          const r = Array.from(e.searchParams.keys());
          for (const i of r)
            e.searchParams.delete(i);
          return e.searchParams.set("src", n), e.href;
        }
      },
      fromEmbedUrl: (t) => {
        const e = qt(t), n = e == null ? void 0 : e.searchParams.get("src");
        if ((e == null ? void 0 : e.pathname.match(/\/calendar\/embed/)) && n) {
          e.pathname = "/calendar/u/0";
          const r = Array.from(e.searchParams.keys());
          for (const i of r)
            e.searchParams.delete(i);
          return e.searchParams.set("cid", n), e.href;
        }
      }
    },
    {
      type: "google_slides",
      title: "Google Slides",
      hostnames: [
        "docs.google.*"
      ],
      width: 720,
      height: 500,
      minWidth: 460,
      minHeight: 360,
      doesResize: true,
      canUnmount: false,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if ((e == null ? void 0 : e.pathname.match(/^\/presentation/)) && (e == null ? void 0 : e.pathname.match(/\/pub\/?$/))) {
          e.pathname = e.pathname.replace(/\/pub$/, "/embed");
          const n = Array.from(e.searchParams.keys());
          for (const r of n)
            e.searchParams.delete(r);
          return e.href;
        }
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if ((e == null ? void 0 : e.pathname.match(/^\/presentation/)) && (e == null ? void 0 : e.pathname.match(/\/embed\/?$/))) {
          e.pathname = e.pathname.replace(/\/embed$/, "/pub");
          const n = Array.from(e.searchParams.keys());
          for (const r of n)
            e.searchParams.delete(r);
          return e.href;
        }
      }
    },
    {
      type: "github_gist",
      title: "GitHub Gist",
      hostnames: [
        "gist.github.com"
      ],
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: true,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/\/([^/]+)\/([^/]+)/))
          return t.split("/").pop() ? t : void 0;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/\/([^/]+)\/([^/]+)/))
          return t.split("/").pop() ? t : void 0;
      }
    },
    {
      type: "replit",
      title: "Replit",
      hostnames: [
        "replit.com"
      ],
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: false,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/\/@([^/]+)\/([^/]+)/))
          return `${t}?embed=true`;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/\/@([^/]+)\/([^/]+)/) && e.searchParams.has("embed"))
          return e.searchParams.delete("embed"), e.href;
      }
    },
    {
      type: "felt",
      title: "Felt",
      hostnames: [
        "felt.com"
      ],
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: false,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/^\/map\//))
          return e.origin + "/embed" + e.pathname;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/^\/embed\/map\//))
          return e.pathname = e.pathname.replace(/^\/embed/, ""), e.href;
      }
    },
    {
      type: "spotify",
      title: "Spotify",
      hostnames: [
        "open.spotify.com"
      ],
      width: 720,
      height: 500,
      minHeight: 500,
      overrideOutlineRadius: 12,
      doesResize: true,
      canUnmount: false,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/^\/(artist|album)\//))
          return e.origin + "/embed" + e.pathname;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/^\/embed\/(artist|album)\//))
          return e.origin + e.pathname.replace(/^\/embed/, "");
      }
    },
    {
      type: "vimeo",
      title: "Vimeo",
      hostnames: [
        "vimeo.com",
        "player.vimeo.com"
      ],
      width: 640,
      height: 360,
      doesResize: true,
      canUnmount: false,
      isAspectRatioLocked: true,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.hostname === "vimeo.com" && e.pathname.match(/^\/[0-9]+/))
          return "https://player.vimeo.com/video/" + e.pathname.split("/")[1] + "?title=0&byline=0";
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.hostname === "player.vimeo.com") {
          const n = e.pathname.match(/^\/video\/([^/]+)\/?$/);
          if (n)
            return "https://vimeo.com/" + n[1];
        }
      }
    },
    {
      type: "excalidraw",
      title: "Excalidraw",
      hostnames: [
        "excalidraw.com"
      ],
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: false,
      isAspectRatioLocked: true,
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.hash.match(/#room=/))
          return t;
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.hash.match(/#room=/))
          return t;
      }
    },
    {
      type: "observable",
      title: "Observable",
      hostnames: [
        "observablehq.com"
      ],
      width: 720,
      height: 500,
      doesResize: true,
      canUnmount: false,
      isAspectRatioLocked: false,
      backgroundColor: "#fff",
      toEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))
          return `${e.origin}/embed${e.pathname}?cell=*`;
        if (e && e.pathname.match(/^\/d\/([^/]+)\/?$/)) {
          const n = e.pathname.replace(/^\/d/, "");
          return `${e.origin}/embed${n}?cell=*`;
        }
      },
      fromEmbedUrl: (t) => {
        const e = qt(t);
        if (e && e.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/))
          return `${e.origin}${e.pathname.replace("/embed", "")}#cell-*`;
        if (e && e.pathname.match(/^\/embed\/([^/]+)\/?$/))
          return `${e.origin}${e.pathname.replace("/embed", "/d")}#cell-*`;
      }
    }
  ], gbe = {
    "allow-downloads-without-user-activation": false,
    "allow-downloads": false,
    "allow-modals": false,
    "allow-orientation-lock": false,
    "allow-pointer-lock": false,
    "allow-popups": true,
    "allow-popups-to-escape-sandbox": false,
    "allow-presentation": false,
    "allow-storage-access-by-user-activation": false,
    "allow-top-navigation": false,
    "allow-top-navigation-by-user-activation": false,
    "allow-scripts": true,
    "allow-same-origin": true,
    "allow-forms": true
  }, mbe = {
    w: xs,
    h: xs,
    url: et
  }, Ly = {
    GenOriginalUrlInEmbed: 1,
    RemoveDoesResize: 2,
    RemoveTmpOldUrl: 3,
    RemovePermissionOverrides: 4
  }, ybe = Ut({
    currentVersion: Ly.RemovePermissionOverrides,
    migrators: {
      [Ly.GenOriginalUrlInEmbed]: {
        up: (t) => {
          const e = t.props.url, n = new URL(e).host.replace("www.", "");
          let r;
          for (const i of Ng)
            if (i.hostnames.includes(n))
              try {
                r = i.fromEmbedUrl(e);
              } catch (s) {
                console.warn(s);
              }
          return {
            ...t,
            props: {
              ...t.props,
              tmpOldUrl: t.props.url,
              url: r ?? ""
            }
          };
        },
        down: (t) => {
          let e = t.props.tmpOldUrl;
          if (!e || e === "") {
            const i = t.props.url, s = new URL(i).host.replace("www.", "");
            for (const o of Ng)
              if (o.hostnames.includes(s))
                try {
                  e = o.toEmbedUrl(i);
                } catch (a) {
                  console.warn(a);
                }
          }
          const { tmpOldUrl: n, ...r } = t.props;
          return {
            ...t,
            props: {
              ...r,
              url: e ?? ""
            }
          };
        }
      },
      [Ly.RemoveDoesResize]: {
        up: (t) => {
          const { doesResize: e, ...n } = t.props;
          return {
            ...t,
            props: {
              ...n
            }
          };
        },
        down: (t) => ({
          ...t,
          props: {
            ...t.props,
            doesResize: true
          }
        })
      },
      [Ly.RemoveTmpOldUrl]: {
        up: (t) => {
          const { tmpOldUrl: e, ...n } = t.props;
          return {
            ...t,
            props: {
              ...n
            }
          };
        },
        down: (t) => ({
          ...t,
          props: {
            ...t.props
          }
        })
      },
      [Ly.RemovePermissionOverrides]: {
        up: (t) => {
          const { overridePermissions: e, ...n } = t.props;
          return {
            ...t,
            props: {
              ...n
            }
          };
        },
        down: (t) => ({
          ...t,
          props: {
            ...t.props
          }
        })
      }
    }
  }), vbe = {
    w: xs,
    h: xs,
    name: et
  }, Obe = Ut({}), Uv = Ci.defineEnum("tldraw:horizontalAlign", {
    defaultValue: "middle",
    values: [
      "start",
      "middle",
      "end",
      "start-legacy",
      "end-legacy",
      "middle-legacy"
    ]
  }), wk = Ci.defineEnum("tldraw:verticalAlign", {
    defaultValue: "middle",
    values: [
      "start",
      "middle",
      "end"
    ]
  }), Al = Ci.defineEnum("tldraw:geo", {
    defaultValue: "rectangle",
    values: [
      "cloud",
      "rectangle",
      "ellipse",
      "triangle",
      "diamond",
      "pentagon",
      "hexagon",
      "octagon",
      "star",
      "rhombus",
      "rhombus-2",
      "oval",
      "trapezoid",
      "arrow-right",
      "arrow-left",
      "arrow-up",
      "arrow-down",
      "x-box",
      "check-box"
    ]
  }), Sbe = {
    geo: Al,
    labelColor: dG,
    color: na,
    fill: jg,
    dash: sf,
    size: Nl,
    font: jl,
    align: Uv,
    verticalAlign: wk,
    url: et,
    w: xs,
    h: xs,
    growY: f5,
    text: et
  }, Cu = {
    AddUrlProp: 1,
    AddLabelColor: 2,
    RemoveJustify: 3,
    AddCheckBox: 4,
    AddVerticalAlign: 5,
    MigrateLegacyAlign: 6,
    AddCloud: 7
  }, wbe = Ut({
    currentVersion: Cu.AddCloud,
    migrators: {
      [Cu.AddUrlProp]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            url: ""
          }
        }),
        down: (t) => {
          const { url: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      },
      [Cu.AddLabelColor]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            labelColor: "black"
          }
        }),
        down: (t) => {
          const { labelColor: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      },
      [Cu.RemoveJustify]: {
        up: (t) => {
          let e = t.props.align;
          return e === "justify" && (e = "start"), {
            ...t,
            props: {
              ...t.props,
              align: e
            }
          };
        },
        down: (t) => ({
          ...t
        })
      },
      [Cu.AddCheckBox]: {
        up: (t) => ({
          ...t
        }),
        down: (t) => ({
          ...t,
          props: {
            ...t.props,
            geo: t.props.geo === "check-box" ? "rectangle" : t.props.geo
          }
        })
      },
      [Cu.AddVerticalAlign]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            verticalAlign: "middle"
          }
        }),
        down: (t) => {
          const { verticalAlign: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      },
      [Cu.MigrateLegacyAlign]: {
        up: (t) => {
          let e;
          switch (t.props.align) {
            case "start":
              e = "start-legacy";
              break;
            case "end":
              e = "end-legacy";
              break;
            default:
              e = "middle-legacy";
              break;
          }
          return {
            ...t,
            props: {
              ...t.props,
              align: e
            }
          };
        },
        down: (t) => {
          let e;
          switch (t.props.align) {
            case "start-legacy":
              e = "start";
              break;
            case "end-legacy":
              e = "end";
              break;
            case "middle-legacy":
              e = "middle";
              break;
            default:
              e = t.props.align;
          }
          return {
            ...t,
            props: {
              ...t.props,
              align: e
            }
          };
        }
      },
      [Cu.AddCloud]: {
        up: (t) => t,
        down: (t) => {
          if (t.props.geo === "cloud")
            return {
              ...t,
              props: {
                ...t.props,
                geo: "rectangle"
              }
            };
        }
      }
    }
  }), xbe = {}, bbe = Ut({}), kbe = {
    color: na,
    size: Nl,
    segments: so(fG),
    isComplete: It,
    isPen: It
  }, Pbe = Ut({}), Cbe = $t({
    topLeft: zv,
    bottomRight: zv
  }), _be = {
    w: xs,
    h: xs,
    playing: It,
    url: et,
    assetId: CC.nullable(),
    crop: Cbe.nullable()
  }, SE = {
    AddUrlProp: 1,
    AddCropProp: 2
  }, Tbe = Ut({
    currentVersion: SE.AddCropProp,
    migrators: {
      [SE.AddUrlProp]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            url: ""
          }
        }),
        down: (t) => {
          const { url: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      },
      [SE.AddCropProp]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            crop: null
          }
        }),
        down: (t) => {
          const { crop: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      }
    }
  }), Ebe = /* @__PURE__ */ new Set([
    "vertex",
    "virtual",
    "create"
  ]), Ibe = $t({
    id: et,
    type: YO(Ebe),
    canBind: It.optional(),
    canSnap: It.optional(),
    index: et,
    x: nt,
    y: nt
  }), xk = Ci.defineEnum("tldraw:spline", {
    defaultValue: "line",
    values: [
      "cubic",
      "line"
    ]
  }), $be = {
    color: na,
    dash: sf,
    size: Nl,
    spline: xk,
    handles: JA(et, Ibe)
  }, n8 = {
    AddSnapHandles: 1
  }, Abe = Ut({
    currentVersion: n8.AddSnapHandles,
    migrators: {
      [n8.AddSnapHandles]: {
        up: (t) => {
          const e = wi(t.props.handles);
          for (const n in e)
            e[n].canSnap = true;
          return {
            ...t,
            props: {
              ...t.props,
              handles: e
            }
          };
        },
        down: (t) => {
          const e = wi(t.props.handles);
          for (const n in e)
            delete e[n].canSnap;
          return {
            ...t,
            props: {
              ...t.props,
              handles: e
            }
          };
        }
      }
    }
  }), Rbe = {
    color: na,
    size: Nl,
    font: jl,
    align: Uv,
    verticalAlign: wk,
    growY: f5,
    url: et,
    text: et
  }, jy = {
    AddUrlProp: 1,
    RemoveJustify: 2,
    MigrateLegacyAlign: 3,
    AddVerticalAlign: 4
  }, Mbe = Ut({
    currentVersion: jy.AddVerticalAlign,
    migrators: {
      [jy.AddUrlProp]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            url: ""
          }
        }),
        down: (t) => {
          const { url: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      },
      [jy.RemoveJustify]: {
        up: (t) => {
          let e = t.props.align;
          return e === "justify" && (e = "start"), {
            ...t,
            props: {
              ...t.props,
              align: e
            }
          };
        },
        down: (t) => ({
          ...t
        })
      },
      [jy.MigrateLegacyAlign]: {
        up: (t) => {
          let e;
          switch (t.props.align) {
            case "start":
              e = "start-legacy";
              break;
            case "end":
              e = "end-legacy";
              break;
            default:
              e = "middle-legacy";
              break;
          }
          return {
            ...t,
            props: {
              ...t.props,
              align: e
            }
          };
        },
        down: (t) => {
          let e;
          switch (t.props.align) {
            case "start-legacy":
              e = "start";
              break;
            case "end-legacy":
              e = "end";
              break;
            case "middle-legacy":
              e = "middle";
              break;
            default:
              e = t.props.align;
          }
          return {
            ...t,
            props: {
              ...t.props,
              align: e
            }
          };
        }
      },
      [jy.AddVerticalAlign]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            verticalAlign: "middle"
          }
        }),
        down: (t) => {
          const { verticalAlign: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      }
    }
  }), Dbe = {
    color: na,
    size: Nl,
    font: jl,
    align: Uv,
    w: xs,
    text: et,
    scale: xs,
    autoSize: It
  }, r8 = {
    RemoveJustify: 1
  }, Lbe = Ut({
    currentVersion: r8.RemoveJustify,
    migrators: {
      [r8.RemoveJustify]: {
        up: (t) => {
          let e = t.props.align;
          return e === "justify" && (e = "start"), {
            ...t,
            props: {
              ...t.props,
              align: e
            }
          };
        },
        down: (t) => ({
          ...t
        })
      }
    }
  }), jbe = {
    w: xs,
    h: xs,
    time: nt,
    playing: It,
    url: et,
    assetId: CC.nullable()
  }, i8 = {
    AddUrlProp: 1
  }, Nbe = Ut({
    currentVersion: i8.AddUrlProp,
    migrators: {
      [i8.AddUrlProp]: {
        up: (t) => ({
          ...t,
          props: {
            ...t.props,
            url: ""
          }
        }),
        down: (t) => {
          const { url: e, ...n } = t.props;
          return {
            ...t,
            props: n
          };
        }
      }
    }
  }), Vv = [
    {
      locale: "ar",
      label: "\u0639\u0631\u0628\u064A"
    },
    {
      locale: "ca",
      label: "Catal\xE0"
    },
    {
      locale: "da",
      label: "Danish"
    },
    {
      locale: "de",
      label: "Deutsch"
    },
    {
      locale: "en",
      label: "English"
    },
    {
      locale: "es",
      label: "Espa\xF1ol"
    },
    {
      locale: "fa",
      label: "\u0641\u0627\u0631\u0633\u06CC"
    },
    {
      locale: "fi",
      label: "Suomi"
    },
    {
      locale: "fr",
      label: "Fran\xE7ais"
    },
    {
      locale: "gl",
      label: "Galego"
    },
    {
      locale: "he",
      label: "\u05E2\u05D1\u05E8\u05D9\u05EA"
    },
    {
      locale: "it",
      label: "Italiano"
    },
    {
      locale: "ja",
      label: "\u65E5\u672C\u8A9E"
    },
    {
      locale: "ko-kr",
      label: "\uD55C\uAD6D\uC5B4"
    },
    {
      locale: "ku",
      label: "\u06A9\u0648\u0631\u062F\u06CC"
    },
    {
      locale: "hi-in",
      label: "\u0939\u093F\u0928\u094D\u0926\u0940"
    },
    {
      locale: "hu",
      label: "Magyar"
    },
    {
      locale: "my",
      label: "\u1019\u103C\u1014\u103A\u1019\u102C\u1005\u102C"
    },
    {
      locale: "ne",
      label: "\u0928\u0947\u092A\u093E\u0932\u0940"
    },
    {
      locale: "no",
      label: "Norwegian"
    },
    {
      locale: "pl",
      label: "Polski"
    },
    {
      locale: "pt-br",
      label: "Portugu\xEAs - Brasil"
    },
    {
      locale: "pt-pt",
      label: "Portugu\xEAs - Europeu"
    },
    {
      locale: "ro",
      label: "Rom\xE2n\u0103"
    },
    {
      locale: "ru",
      label: "Russian"
    },
    {
      locale: "sv",
      label: "Svenska"
    },
    {
      locale: "te",
      label: "\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41"
    },
    {
      locale: "th",
      label: "\u0E20\u0E32\u0E29\u0E32\u0E44\u0E17\u0E22"
    },
    {
      locale: "tr",
      label: "T\xFCrk\xE7e"
    },
    {
      locale: "uk",
      label: "Ukrainian"
    },
    {
      locale: "vi",
      label: "Ti\u1EBFng Vi\u1EC7t"
    },
    {
      locale: "zh-cn",
      label: "Chinese - Simplified"
    },
    {
      locale: "zh-tw",
      label: "\u7E41\u9AD4\u4E2D\u6587 (\u53F0\u7063)"
    }
  ];
  function Qbe() {
    const t = typeof window < "u" ? window.navigator.languages ?? [
      "en"
    ] : [
      "en"
    ];
    return zbe(t);
  }
  function zbe(t) {
    for (const e of t) {
      const n = Fbe(e);
      if (n)
        return n;
    }
    return "en";
  }
  const s8 = {
    zh: "zh-cn",
    pt: "pt-br",
    ko: "ko-kr",
    hi: "hi-in"
  };
  function Fbe(t) {
    const e = Vv.find((i) => i.locale === t.toLowerCase());
    if (e)
      return e.locale;
    const [n, r] = t.split(/[-_]/).map((i) => i.toLowerCase());
    if (r) {
      const i = Vv.find((s) => s.locale === n);
      if (i)
        return i.locale;
    }
    return n in s8 ? s8[n] : null;
  }
  const Bbe = {}, un = {
    preventDefaultLogging: Ms("preventDefaultLogging", {
      defaults: {
        all: false
      }
    }),
    pointerCaptureLogging: Ms("pointerCaptureLogging", {
      defaults: {
        all: false
      }
    }),
    pointerCaptureTracking: Ms("pointerCaptureTracking", {
      defaults: {
        all: false
      }
    }),
    pointerCaptureTrackingObject: Ms("pointerCaptureTrackingObject", {
      defaults: {
        all: /* @__PURE__ */ new Map()
      },
      shouldStoreForSession: false
    }),
    elementRemovalLogging: Ms("elementRemovalLogging", {
      defaults: {
        all: false
      }
    }),
    debugSvg: Ms("debugSvg", {
      defaults: {
        all: false
      }
    }),
    throwToBlob: Ms("throwToBlob", {
      defaults: {
        all: false
      }
    }),
    logMessages: Ms("uiLog", {
      defaults: {
        all: []
      }
    }),
    resetConnectionEveryPing: Ms("resetConnectionEveryPing", {
      defaults: {
        all: false
      }
    }),
    debugCursors: Ms("debugCursors", {
      defaults: {
        all: false
      }
    }),
    forceSrgb: Ms("forceSrgbColors", {
      defaults: {
        all: false
      }
    }),
    debugGeometry: Ms("debugGeometry", {
      defaults: {
        all: false
      }
    }),
    hideShapes: Ms("hideShapes", {
      defaults: {
        all: false
      }
    })
  };
  typeof window < "u" && (window.tldrawLog = (t) => {
    un.logMessages.set(un.logMessages.value.concat(t));
  });
  if (typeof Element < "u") {
    const t = Element.prototype.removeChild;
    wm("element removal logging", () => {
      un.elementRemovalLogging.value ? Element.prototype.removeChild = function(e) {
        return console.warn("[tldraw] removing child:", e), t.call(this, e);
      } : Element.prototype.removeChild = t;
    });
  }
  function Ms(t, { defaults: e, shouldStoreForSession: n = true }) {
    return Ube({
      name: t,
      defaults: e,
      shouldStoreForSession: n
    });
  }
  function Ube(t) {
    const e = Xbe(t), n = t.shouldStoreForSession ? Vbe(t.name) : null, r = fs(`debug:${t.name}`, n ?? e);
    return typeof window < "u" && (t.shouldStoreForSession && wm(`debug:${t.name}`, () => {
      const i = r.value;
      try {
        i === e ? window.sessionStorage.removeItem(`tldraw_debug:${t.name}`) : window.sessionStorage.setItem(`tldraw_debug:${t.name}`, JSON.stringify(i));
      } catch {
      }
    }), Object.defineProperty(window, `tldraw${t.name.replace(/^[a-z]/, (i) => i.toUpperCase())}`, {
      get() {
        return r.value;
      },
      set(i) {
        r.set(i);
      },
      configurable: true
    })), Object.assign(r, t);
  }
  function Vbe(t) {
    try {
      return JSON.parse((window == null ? void 0 : window.sessionStorage.getItem(`tldraw_debug:${t}`)) ?? "null");
    } catch {
      return null;
    }
  }
  function wE(t) {
    try {
      return t();
    } catch {
      return null;
    }
  }
  function Xbe(t) {
    switch (wE(() => ({}).TLDRAW_ENV) ?? wE(() => ({}).VERCEL_PUBLIC_TLDRAW_ENV) ?? wE(() => ({}).NEXT_PUBLIC_TLDRAW_ENV) ?? "production") {
      case "production":
        return t.defaults.production ?? t.defaults.all;
      case "preview":
      case "staging":
        return t.defaults.staging ?? t.defaults.all;
      default:
        return t.defaults.development ?? t.defaults.all;
    }
  }
  function bk(t) {
    if (t instanceof HTMLElement)
      return t;
    if (t.parentElement)
      return bk(t.parentElement);
    throw Error("Could not find a parent element of an HTML type!");
  }
  function Rt(t) {
    t.preventDefault(), un.preventDefaultLogging.value && console.warn("preventDefault called on event:", t);
  }
  function qO(t, e) {
    if (t.setPointerCapture(e.pointerId), un.pointerCaptureTracking.value) {
      const n = un.pointerCaptureTrackingObject.value;
      n.set(t, (n.get(t) ?? 0) + 1);
    }
    un.pointerCaptureLogging.value && console.warn("setPointerCapture called on element:", t, e);
  }
  function KO(t, e) {
    if (t.hasPointerCapture(e.pointerId)) {
      if (t.releasePointerCapture(e.pointerId), un.pointerCaptureTracking.value) {
        const n = un.pointerCaptureTrackingObject.value;
        n.get(t) === 1 ? n.delete(t) : n.has(t) ? n.set(t, n.get(t) - 1) : console.warn("Release without capture");
      }
      un.pointerCaptureLogging.value && console.warn("releasePointerCapture called on element:", t, e);
    }
  }
  const _r = (t) => t.stopPropagation();
  function ps(t) {
    return t.isKilled = true, {
      point: {
        x: t.clientX,
        y: t.clientY,
        z: t.pressure
      },
      shiftKey: t.shiftKey,
      altKey: t.altKey,
      ctrlKey: t.metaKey || t.ctrlKey,
      pointerId: t.pointerId,
      button: t.button,
      isPen: t.pointerType === "pen"
    };
  }
  const v5 = $e.createContext({}), ue = () => $e.useContext(v5);
  function Wbe() {
    const t = ue();
    return b.useMemo(function() {
      let r, i;
      function s(g) {
        if (!g.isKilled) {
          if (g.button === 2) {
            t.dispatch({
              type: "pointer",
              target: "canvas",
              name: "right_click",
              ...ps(g)
            });
            return;
          }
          g.button !== 0 && g.button !== 1 && g.button !== 5 || (qO(g.currentTarget, g), t.dispatch({
            type: "pointer",
            target: "canvas",
            name: "pointer_down",
            ...ps(g)
          }), t.openMenus.length > 0 && (document.body.click(), t.getContainer().focus()));
        }
      }
      function o(g) {
        g.isKilled || g.clientX === r && g.clientY === i || (r = g.clientX, i = g.clientY, t.dispatch({
          type: "pointer",
          target: "canvas",
          name: "pointer_move",
          ...ps(g)
        }));
      }
      function a(g) {
        g.isKilled || g.button !== 0 && g.button !== 1 && g.button !== 2 && g.button !== 5 || (r = g.clientX, i = g.clientY, KO(g.currentTarget, g), t.dispatch({
          type: "pointer",
          target: "canvas",
          name: "pointer_up",
          ...ps(g)
        }));
      }
      function l(g) {
        if (g.isKilled || t.instanceState.isPenMode && g.pointerType !== "pen")
          return;
        const O = g.pointerType === "mouse" || g.pointerType === "pen";
        t.updateInstanceState({
          isHoveringCanvas: O ? true : null
        });
      }
      function c(g) {
        if (g.isKilled || t.instanceState.isPenMode && g.pointerType !== "pen")
          return;
        const O = g.pointerType === "mouse" || g.pointerType === "pen";
        t.updateInstanceState({
          isHoveringCanvas: O ? false : null
        });
      }
      function u(g) {
        g.isKilled = true, document.body.click(), Rt(g);
      }
      function d(g) {
        g.isKilled = true, g.target.tagName !== "A" && g.target.tagName !== "TEXTAREA" && Rt(g);
      }
      function h(g) {
        Rt(g);
      }
      async function f(g) {
        var _a3, _b3;
        if (Rt(g), !((_b3 = (_a3 = g.dataTransfer) == null ? void 0 : _a3.files) == null ? void 0 : _b3.length))
          return;
        const O = Array.from(g.dataTransfer.files);
        await t.putExternalContent({
          type: "files",
          files: O,
          point: t.screenToPage({
            x: g.clientX,
            y: g.clientY
          }),
          ignoreParent: false
        });
      }
      function y(g) {
        _r(g);
      }
      return {
        onPointerDown: s,
        onPointerMove: o,
        onPointerUp: a,
        onPointerEnter: l,
        onPointerLeave: c,
        onDragOver: h,
        onDrop: f,
        onTouchStart: u,
        onTouchEnd: d,
        onClick: y
      };
    }, [
      t
    ]);
  }
  function Zbe() {
    const t = ue();
    b.useEffect(() => {
      if (t.environment.isFirefox && !t.environment.isAndroid && !t.environment.isIos) {
        t.updateInstanceState({
          isCoarsePointer: false
        });
        return;
      }
      if (window.matchMedia) {
        const e = window.matchMedia("(pointer: coarse)"), n = () => {
          t.updateInstanceState({
            isCoarsePointer: !!e.matches
          });
        };
        if (n(), e)
          return e.addEventListener("change", n), () => e.removeEventListener("change", n);
      }
    }, [
      t
    ]);
  }
  const pG = b.createContext(null);
  function Hbe({ container: t, children: e }) {
    return m.jsx(pG.Provider, {
      value: t,
      children: e
    });
  }
  function Kr() {
    return Jwe(b.useContext(pG), "useContainer used outside of <Tldraw />");
  }
  function Ybe() {
    const t = ue(), e = Kr(), n = ye("isFocused", () => t.instanceState.isFocused, [
      t
    ]);
    b.useEffect(() => {
      if (typeof matchMedia === void 0)
        return;
      let r = null;
      const i = () => {
        r == null ? void 0 : r();
        const s = `(resolution: ${window.devicePixelRatio}dppx)`, o = matchMedia(s);
        o.addEventListener("change", i), r = () => {
          o.removeEventListener("change", i);
        }, t.updateInstanceState({
          devicePixelRatio: window.devicePixelRatio
        });
      };
      return i(), () => {
        r == null ? void 0 : r();
      };
    }, [
      t
    ]), b.useEffect(() => {
      if (!n)
        return;
      const r = (a) => {
        if (a.altKey && (t.isIn("zoom") || !t.root.path.value.endsWith(".idle")) && !Ny() && Rt(a), a.isKilled)
          return;
        switch (a.isKilled = true, a.key) {
          case "=":
          case "-":
          case "0": {
            if (a.metaKey || a.ctrlKey) {
              Rt(a);
              return;
            }
            break;
          }
          case "Tab": {
            if (Ny() || t.isMenuOpen)
              return;
            break;
          }
          case ",": {
            if (!Ny() && (Rt(a), !t.inputs.keys.has("Comma"))) {
              const { x: c, y: u, z: d } = t.inputs.currentScreenPoint;
              t.inputs.keys.add("Comma");
              const h = {
                type: "pointer",
                name: "pointer_down",
                point: {
                  x: c,
                  y: u,
                  z: d
                },
                shiftKey: a.shiftKey,
                altKey: a.altKey,
                ctrlKey: a.metaKey || a.ctrlKey,
                pointerId: 0,
                button: 0,
                isPen: t.instanceState.isPenMode,
                target: "canvas"
              };
              t.dispatch(h);
              return;
            }
            break;
          }
          case "Escape": {
            if ((t.editingShape || t.selectedShapeIds.length > 0) && a.preventDefault(), t.openMenus.length > 0)
              return;
            t.inputs.keys.has("Escape") || (t.inputs.keys.add("Escape"), t.cancel(), e.focus());
            return;
          }
          default:
            if (Ny() || t.isMenuOpen)
              return;
        }
        const l = {
          type: "keyboard",
          name: a.repeat ? "key_repeat" : "key_down",
          key: a.key,
          code: a.code,
          shiftKey: a.shiftKey,
          altKey: a.altKey,
          ctrlKey: a.metaKey || a.ctrlKey
        };
        t.dispatch(l);
      }, i = (a) => {
        var _a3;
        if (a.isKilled || (a.isKilled = true, Ny() || t.isMenuOpen))
          return;
        if (a.key === "," && (((_a3 = document.activeElement) == null ? void 0 : _a3.ELEMENT_NODE) && Rt(a), t.inputs.keys.has(a.code))) {
          const { x: c, y: u, z: d } = t.inputs.currentScreenPoint;
          t.inputs.keys.delete(a.code);
          const h = {
            type: "pointer",
            name: "pointer_up",
            point: {
              x: c,
              y: u,
              z: d
            },
            shiftKey: a.shiftKey,
            altKey: a.altKey,
            ctrlKey: a.metaKey || a.ctrlKey,
            pointerId: 0,
            button: 0,
            isPen: t.instanceState.isPenMode,
            target: "canvas"
          };
          t.dispatch(h);
          return;
        }
        const l = {
          type: "keyboard",
          name: "key_up",
          key: a.key,
          code: a.code,
          shiftKey: a.shiftKey,
          altKey: a.altKey,
          ctrlKey: a.metaKey || a.ctrlKey
        };
        t.dispatch(l);
      };
      function s(a) {
        var _a3, _b3;
        if (e.contains(a.target)) {
          const l = a.touches[0].pageX, c = a.touches[0].radiusX || 0;
          (l - c < 10 || l + c > t.viewportScreenBounds.width - 10) && (((_a3 = a.target) == null ? void 0 : _a3.tagName) === "BUTTON" && ((_b3 = a.target) == null ? void 0 : _b3.click()), Rt(a));
        }
      }
      const o = (a) => {
        e.contains(a.target) && (a.ctrlKey || a.metaKey) && Rt(a);
      };
      return e.addEventListener("touchstart", s, {
        passive: false
      }), e.addEventListener("wheel", o, {
        passive: false
      }), document.addEventListener("gesturestart", Rt), document.addEventListener("gesturechange", Rt), document.addEventListener("gestureend", Rt), e.addEventListener("keydown", r), e.addEventListener("keyup", i), () => {
        e.removeEventListener("touchstart", s), e.removeEventListener("wheel", o), document.removeEventListener("gesturestart", Rt), document.removeEventListener("gesturechange", Rt), document.removeEventListener("gestureend", Rt), e.removeEventListener("keydown", r), e.removeEventListener("keyup", i);
      };
    }, [
      t,
      e,
      n
    ]);
  }
  const Gbe = [
    "input",
    "select",
    "button",
    "textarea"
  ];
  function Ny() {
    const { activeElement: t } = document;
    return !!(t && (t.getAttribute("contenteditable") || Gbe.indexOf(t.tagName.toLowerCase()) > -1));
  }
  const qbe = {
    error: null
  };
  class gG extends b.Component {
    constructor() {
      super(...arguments);
      __publicField(this, "state", qbe);
    }
    static getDerivedStateFromError(e) {
      return {
        error: e
      };
    }
    componentDidCatch(e) {
      var _a3, _b3;
      (_b3 = (_a3 = this.props).onError) == null ? void 0 : _b3.call(_a3, e);
    }
    render() {
      const { error: e } = this.state;
      if (e !== null) {
        const { fallback: n } = this.props;
        return m.jsx(n, {
          error: e
        });
      }
      return this.props.children;
    }
  }
  function Xv({ children: t, fallback: e, ...n }) {
    return e === null ? m.jsx(m.Fragment, {
      children: t
    }) : m.jsx(gG, {
      fallback: e,
      ...n,
      children: t
    });
  }
  class Kbe {
    constructor(e) {
      this.shape = e;
    }
    equals(e) {
      var _a3, _b3, _c3, _d3, _e3, _f3;
      return ((_a3 = this.shape) == null ? void 0 : _a3.isLocked) === ((_b3 = e == null ? void 0 : e.shape) == null ? void 0 : _b3.isLocked) && ((_c3 = this.shape) == null ? void 0 : _c3.props) === ((_d3 = e == null ? void 0 : e.shape) == null ? void 0 : _d3.props) && ((_e3 = this.shape) == null ? void 0 : _e3.meta) === ((_f3 = e == null ? void 0 : e.shape) == null ? void 0 : _f3.meta);
    }
  }
  const Jbe = ({ shape: t, util: e }) => wC("Indicator:" + t.type, () => e.indicator(t)), eke = ({ editor: t, id: e }) => {
    const n = ye("shape", () => new Kbe(t.store.get(e)), [
      t,
      e
    ]), { ShapeIndicatorErrorFallback: r } = _i();
    return !n.shape || n.shape.isLocked ? null : m.jsx(Xv, {
      fallback: r,
      onError: (i) => t.annotateError(i, {
        origin: "react.shapeIndicator",
        willCrashApp: false
      }),
      children: m.jsx(Jbe, {
        shape: n.shape,
        util: t.getShapeUtil(n.shape)
      }, n.shape.id)
    });
  }, tke = ({ id: t, className: e, color: n, opacity: r }) => {
    const i = ue(), s = ye("transform", () => {
      const o = i.getShapePageTransform(t);
      return o ? o.toCssString() : "";
    }, [
      i,
      t
    ]);
    return m.jsx("svg", {
      className: Ze("tl-overlays__item", e),
      children: m.jsx("g", {
        className: "tl-shape-indicator",
        transform: s,
        stroke: n ?? "var(--color-selected)",
        opacity: r,
        children: m.jsx(eke, {
          editor: i,
          id: t
        })
      })
    });
  }, JO = b.memo(tke);
  function nke() {
    return m.jsx("div", {
      className: "tl-background"
    });
  }
  function bm(t, e, n, r, i, s) {
    b.useLayoutEffect(() => {
      const o = t.current;
      if (!o || e === void 0)
        return;
      let a = `translate(${e}px, ${n}px)`;
      r !== void 0 && (a += ` scale(${r})`), i !== void 0 && (a += ` rotate(${i}rad)`), s && (a += ` translate(${s.x}px, ${s.y}px)`), o.style.transform = a;
    });
  }
  const Oi = {
    linear: (t) => t,
    easeInQuad: (t) => t * t,
    easeOutQuad: (t) => t * (2 - t),
    easeInOutQuad: (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t,
    easeInCubic: (t) => t * t * t,
    easeOutCubic: (t) => --t * t * t + 1,
    easeInOutCubic: (t) => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1,
    easeInQuart: (t) => t * t * t * t,
    easeOutQuart: (t) => 1 - --t * t * t * t,
    easeInOutQuart: (t) => t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t,
    easeInQuint: (t) => t * t * t * t * t,
    easeOutQuint: (t) => 1 + --t * t * t * t * t,
    easeInOutQuint: (t) => t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t,
    easeInSine: (t) => 1 - Math.cos(t * Math.PI / 2),
    easeOutSine: (t) => Math.sin(t * Math.PI / 2),
    easeInOutSine: (t) => -(Math.cos(Math.PI * t) - 1) / 2,
    easeInExpo: (t) => t <= 0 ? 0 : Math.pow(2, 10 * t - 10),
    easeOutExpo: (t) => t >= 1 ? 1 : 1 - Math.pow(2, -10 * t),
    easeInOutExpo: (t) => t <= 0 ? 0 : t >= 1 ? 1 : t < 0.5 ? Math.pow(2, 20 * t - 10) / 2 : (2 - Math.pow(2, -20 * t + 10)) / 2
  };
  class I {
    constructor(e = 0, n = 0, r = 1) {
      this.x = e, this.y = n, this.z = r;
    }
    get pressure() {
      return this.z;
    }
    set(e = this.x, n = this.y, r = this.z) {
      return this.x = e, this.y = n, this.z = r, this;
    }
    setTo({ x: e = 0, y: n = 0, z: r = 1 }) {
      return this.x = e, this.y = n, this.z = r, this;
    }
    rot(e) {
      if (e === 0)
        return this;
      const { x: n, y: r } = this, i = Math.sin(e), s = Math.cos(e);
      return this.x = n * s - r * i, this.y = n * i + r * s, this;
    }
    rotWith(e, n) {
      if (n === 0)
        return this;
      const r = this.x - e.x, i = this.y - e.y, s = Math.sin(n), o = Math.cos(n);
      return this.x = e.x + (r * o - i * s), this.y = e.y + (r * s + i * o), this;
    }
    clone() {
      const { x: e, y: n, z: r } = this;
      return new I(e, n, r);
    }
    sub(e) {
      return this.x -= e.x, this.y -= e.y, this;
    }
    subXY(e, n) {
      return this.x -= e, this.y -= n, this;
    }
    subScalar(e) {
      return this.x -= e, this.y -= e, this;
    }
    add(e) {
      return this.x += e.x, this.y += e.y, this;
    }
    addXY(e, n) {
      return this.x += e, this.y += n, this;
    }
    addScalar(e) {
      return this.x += e, this.y += e, this;
    }
    clamp(e, n) {
      return this.x = Math.max(this.x, e), this.y = Math.max(this.y, e), n !== void 0 && (this.x = Math.min(this.x, n), this.y = Math.min(this.y, n)), this;
    }
    div(e) {
      return this.x /= e, this.y /= e, this;
    }
    divV(e) {
      return this.x /= e.x, this.y /= e.y, this;
    }
    mul(e) {
      return this.x *= e, this.y *= e, this;
    }
    mulV(e) {
      return this.x *= e.x, this.y *= e.y, this;
    }
    abs() {
      return this.x = Math.abs(this.x), this.y = Math.abs(this.y), this;
    }
    nudge(e, n) {
      const r = I.Tan(e, this);
      return this.add(r.mul(n));
    }
    neg() {
      return this.x *= -1, this.y *= -1, this;
    }
    cross(e) {
      return this.x = this.y * e.z - this.z * e.y, this.y = this.z * e.x - this.x * e.z, this;
    }
    dpr(e) {
      return I.Dpr(this, e);
    }
    cpr(e) {
      return I.Cpr(this, e);
    }
    len2() {
      return I.Len2(this);
    }
    len() {
      return I.Len(this);
    }
    pry(e) {
      return I.Pry(this, e);
    }
    per() {
      const { x: e, y: n } = this;
      return this.x = n, this.y = -e, this;
    }
    uni() {
      return I.Uni(this);
    }
    tan(e) {
      return I.Tan(this, e);
    }
    dist(e) {
      return I.Dist(this, e);
    }
    distanceToLineSegment(e, n) {
      return I.DistanceToLineSegment(e, n, this);
    }
    slope(e) {
      return I.Slope(this, e);
    }
    snapToGrid(e) {
      return this.x = Math.round(this.x / e) * e, this.y = Math.round(this.y / e) * e, this;
    }
    angle(e) {
      return I.Angle(this, e);
    }
    toAngle() {
      return I.ToAngle(this);
    }
    lrp(e, n) {
      return this.x = this.x + (e.x - this.x) * n, this.y = this.y + (e.y - this.y) * n, this;
    }
    equals(e) {
      return I.Equals(this, e);
    }
    equalsXY(e, n) {
      return I.EqualsXY(this, e, n);
    }
    norm() {
      const e = this.len();
      return this.x = e === 0 ? 0 : this.x / e, this.y = e === 0 ? 0 : this.y / e, this;
    }
    toFixed() {
      return I.ToFixed(this);
    }
    toString() {
      return I.ToString(I.ToFixed(this));
    }
    toJson() {
      return I.ToJson(this);
    }
    toArray() {
      return I.ToArray(this);
    }
    static Add(e, n) {
      return new I(e.x + n.x, e.y + n.y);
    }
    static AddXY(e, n, r) {
      return new I(e.x + n, e.y + r);
    }
    static Sub(e, n) {
      return new I(e.x - n.x, e.y - n.y);
    }
    static SubXY(e, n, r) {
      return new I(e.x - n, e.y - r);
    }
    static AddScalar(e, n) {
      return new I(e.x + n, e.y + n);
    }
    static SubScalar(e, n) {
      return new I(e.x - n, e.y - n);
    }
    static Div(e, n) {
      return new I(e.x / n, e.y / n);
    }
    static Mul(e, n) {
      return new I(e.x * n, e.y * n);
    }
    static DivV(e, n) {
      return new I(e.x / n.x, e.y / n.y);
    }
    static MulV(e, n) {
      return new I(e.x * n.x, e.y * n.y);
    }
    static Neg(e) {
      return new I(-e.x, -e.y);
    }
    static Per(e) {
      return new I(e.y, -e.x);
    }
    static Dist2(e, n) {
      return I.Sub(e, n).len2();
    }
    static Abs(e) {
      return new I(Math.abs(e.x), Math.abs(e.y));
    }
    static Dist(e, n) {
      return Math.hypot(e.y - n.y, e.x - n.x);
    }
    static Dpr(e, n) {
      return e.x * n.x + e.y * n.y;
    }
    static Cross(e, n) {
      return new I(e.y * n.z - e.z * n.y, e.z * n.x - e.x * n.z);
    }
    static Cpr(e, n) {
      return e.x * n.y - n.x * e.y;
    }
    static Len2(e) {
      return e.x * e.x + e.y * e.y;
    }
    static Len(e) {
      return Math.hypot(e.x, e.y);
    }
    static Pry(e, n) {
      return I.Dpr(e, n) / I.Len(n);
    }
    static Uni(e) {
      return I.Div(e, I.Len(e));
    }
    static Tan(e, n) {
      return I.Uni(I.Sub(e, n));
    }
    static Min(e, n) {
      return new I(Math.min(e.x, n.x), Math.min(e.y, n.y));
    }
    static Max(e, n) {
      return new I(Math.max(e.x, n.x), Math.max(e.y, n.y));
    }
    static From({ x: e, y: n, z: r = 1 }) {
      return new I(e, n, r);
    }
    static FromArray(e) {
      return new I(e[0], e[1]);
    }
    static Rot(e, n = 0) {
      const r = Math.sin(n), i = Math.cos(n);
      return new I(e.x * i - e.y * r, e.x * r + e.y * i);
    }
    static RotWith(e, n, r) {
      const i = e.x - n.x, s = e.y - n.y, o = Math.sin(r), a = Math.cos(r);
      return new I(n.x + (i * a - s * o), n.y + (i * o + s * a));
    }
    static NearestPointOnLineThroughPoint(e, n, r) {
      return I.Mul(n, I.Sub(r, e).pry(n)).add(e);
    }
    static NearestPointOnLineSegment(e, n, r, i = true) {
      const s = I.Tan(n, e), o = I.Add(e, I.Mul(s, I.Sub(r, e).pry(s)));
      if (i) {
        if (o.x < Math.min(e.x, n.x))
          return I.Cast(e.x < n.x ? e : n);
        if (o.x > Math.max(e.x, n.x))
          return I.Cast(e.x > n.x ? e : n);
        if (o.y < Math.min(e.y, n.y))
          return I.Cast(e.y < n.y ? e : n);
        if (o.y > Math.max(e.y, n.y))
          return I.Cast(e.y > n.y ? e : n);
      }
      return o;
    }
    static DistanceToLineThroughPoint(e, n, r) {
      return I.Dist(r, I.NearestPointOnLineThroughPoint(e, n, r));
    }
    static DistanceToLineSegment(e, n, r, i = true) {
      return I.Dist(r, I.NearestPointOnLineSegment(e, n, r, i));
    }
    static Snap(e, n = 1) {
      return new I(Math.round(e.x / n) * n, Math.round(e.y / n) * n);
    }
    static Cast(e) {
      return e instanceof I ? e : I.From(e);
    }
    static Slope(e, n) {
      return e.x === n.y ? NaN : (e.y - n.y) / (e.x - n.x);
    }
    static Angle(e, n) {
      return Math.atan2(n.y - e.y, n.x - e.x);
    }
    static Lrp(e, n, r) {
      return I.Sub(n, e).mul(r).add(e);
    }
    static Med(e, n) {
      return new I((e.x + n.x) / 2, (e.y + n.y) / 2);
    }
    static Equals(e, n) {
      return Math.abs(e.x - n.x) < 1e-4 && Math.abs(e.y - n.y) < 1e-4;
    }
    static EqualsXY(e, n, r) {
      return e.x === n && e.y === r;
    }
    static Clockwise(e, n, r) {
      return (r.x - e.x) * (n.y - e.y) - (n.x - e.x) * (r.y - e.y) < 0;
    }
    static Rescale(e, n) {
      const r = I.Len(e);
      return new I(n * e.x / r, n * e.y / r);
    }
    static ScaleWithOrigin(e, n, r) {
      return I.Sub(e, r).mul(n).add(r);
    }
    static ToFixed(e, n = 2) {
      return new I(+e.x.toFixed(n), +e.y.toFixed(n), +e.z.toFixed(n));
    }
    static Nudge(e, n, r) {
      return I.Add(e, I.Tan(n, e).mul(r));
    }
    static ToString(e) {
      return `${e.x}, ${e.y}`;
    }
    static ToAngle(e) {
      let n = Math.atan2(e.y, e.x);
      return n < 0 && (n += Math.PI * 2), n;
    }
    static FromAngle(e, n = 1) {
      return new I(Math.cos(e) * n, Math.sin(e) * n);
    }
    static ToArray(e) {
      return [
        e.x,
        e.y,
        e.z
      ];
    }
    static ToJson(e) {
      const { x: n, y: r, z: i } = e;
      return {
        x: n,
        y: r,
        z: i
      };
    }
    static Average(e) {
      const n = e.length, r = new I(0, 0);
      for (let i = 0; i < n; i++)
        r.add(e[i]);
      return r.div(n);
    }
    static Clamp(e, n, r) {
      return r === void 0 ? new I(Math.min(Math.max(e.x, n)), Math.min(Math.max(e.y, n))) : new I(Math.min(Math.max(e.x, n), r), Math.min(Math.max(e.y, n), r));
    }
    static PointsBetween(e, n, r = 6) {
      const i = [];
      for (let s = 0; s < r; s++) {
        const o = Oi.easeInQuad(s / (r - 1)), a = I.Lrp(e, n, o);
        a.z = Math.min(1, 0.5 + Math.abs(0.5 - rke(o)) * 0.65), i.push(a);
      }
      return i;
    }
    static SnapToGrid(e, n = 8) {
      return new I(Math.round(e.x / n) * n, Math.round(e.y / n) * n);
    }
  }
  const rke = (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
  const _Te2 = class _Te2 {
    constructor(e = 0, n = 0, r = 0, i = 0) {
      __publicField(this, "x", 0);
      __publicField(this, "y", 0);
      __publicField(this, "w", 0);
      __publicField(this, "h", 0);
      this.x = e, this.y = n, this.w = r, this.h = i;
    }
    get point() {
      return new I(this.x, this.y);
    }
    set point(e) {
      this.x = e.x, this.y = e.y;
    }
    get minX() {
      return this.x;
    }
    set minX(e) {
      this.x = e;
    }
    get midX() {
      return this.x + this.w / 2;
    }
    get maxX() {
      return this.x + this.w;
    }
    get minY() {
      return this.y;
    }
    set minY(e) {
      this.y = e;
    }
    get midY() {
      return this.y + this.h / 2;
    }
    get maxY() {
      return this.y + this.h;
    }
    get width() {
      return this.w;
    }
    set width(e) {
      this.w = e;
    }
    get height() {
      return this.h;
    }
    set height(e) {
      this.h = e;
    }
    get aspectRatio() {
      return this.width / this.height;
    }
    get center() {
      return new I(this.midX, this.midY);
    }
    set center(e) {
      this.minX = e.x - this.width / 2, this.minY = e.y - this.height / 2;
    }
    get corners() {
      return [
        new I(this.minX, this.minY),
        new I(this.maxX, this.minY),
        new I(this.maxX, this.maxY),
        new I(this.minX, this.maxY)
      ];
    }
    get snapPoints() {
      return [
        new I(this.minX, this.minY),
        new I(this.maxX, this.minY),
        new I(this.maxX, this.maxY),
        new I(this.minX, this.maxY),
        this.center
      ];
    }
    get sides() {
      const { corners: e } = this;
      return [
        [
          e[0],
          e[1]
        ],
        [
          e[1],
          e[2]
        ],
        [
          e[2],
          e[3]
        ],
        [
          e[3],
          e[0]
        ]
      ];
    }
    get size() {
      return new I(this.w, this.h);
    }
    toFixed() {
      return this.x = fw(this.x), this.y = fw(this.y), this.w = fw(this.w), this.h = fw(this.h), this;
    }
    setTo(e) {
      return this.x = e.x, this.y = e.y, this.w = e.w, this.h = e.h, this;
    }
    set(e = 0, n = 0, r = 0, i = 0) {
      return this.x = e, this.y = n, this.w = r, this.h = i, this;
    }
    expand(e) {
      const n = Math.min(this.minX, e.minX), r = Math.min(this.minY, e.minY), i = Math.max(this.maxX, e.maxX), s = Math.max(this.maxY, e.maxY);
      return this.x = n, this.y = r, this.w = i - n, this.h = s - r, this;
    }
    expandBy(e) {
      return this.x -= e, this.y -= e, this.w += e * 2, this.h += e * 2, this;
    }
    scale(e) {
      return this.x /= e, this.y /= e, this.w /= e, this.h /= e, this;
    }
    clone() {
      const { x: e, y: n, w: r, h: i } = this;
      return new _Te2(e, n, r, i);
    }
    translate(e) {
      return this.x += e.x, this.y += e.y, this;
    }
    snapToGrid(e) {
      const n = Math.round(this.minX / e) * e, r = Math.round(this.minY / e) * e, i = Math.round(this.maxX / e) * e, s = Math.round(this.maxY / e) * e;
      this.minX = n, this.minY = r, this.width = Math.max(1, i - n), this.height = Math.max(1, s - r);
    }
    collides(e) {
      return _Te2.Collides(this, e);
    }
    contains(e) {
      return _Te2.Contains(this, e);
    }
    includes(e) {
      return _Te2.Includes(this, e);
    }
    containsPoint(e, n = 0) {
      return _Te2.ContainsPoint(this, e, n);
    }
    getHandlePoint(e) {
      switch (e) {
        case "top_left":
          return new I(this.minX, this.minY);
        case "top_right":
          return new I(this.maxX, this.minY);
        case "bottom_left":
          return new I(this.minX, this.maxY);
        case "bottom_right":
          return new I(this.maxX, this.maxY);
        case "top":
          return new I(this.midX, this.minY);
        case "right":
          return new I(this.maxX, this.midY);
        case "bottom":
          return new I(this.midX, this.maxY);
        case "left":
          return new I(this.minX, this.midY);
      }
    }
    toJson() {
      return {
        x: this.minX,
        y: this.minY,
        w: this.w,
        h: this.h
      };
    }
    resize(e, n, r) {
      const { minX: i, minY: s, maxX: o, maxY: a } = this;
      let { minX: l, minY: c, maxX: u, maxY: d } = this;
      switch (e) {
        case "left":
        case "top_left":
        case "bottom_left": {
          l += n;
          break;
        }
        case "right":
        case "top_right":
        case "bottom_right": {
          u += n;
          break;
        }
      }
      switch (e) {
        case "top":
        case "top_left":
        case "top_right": {
          c += r;
          break;
        }
        case "bottom":
        case "bottom_left":
        case "bottom_right": {
          d += r;
          break;
        }
      }
      const h = (u - l) / (o - i), f = (d - c) / (a - s), y = h < 0, g = f < 0;
      if (y) {
        const O = u;
        u = l, l = O;
      }
      if (g) {
        const O = d;
        d = c, c = O;
      }
      this.minX = l, this.minY = c, this.width = Math.abs(u - l), this.height = Math.abs(d - c);
    }
    union(e) {
      const n = Math.min(this.minX, e.x), r = Math.min(this.minY, e.y), i = Math.max(this.maxX, e.w + e.x), s = Math.max(this.maxY, e.h + e.y);
      return this.x = n, this.y = r, this.width = i - n, this.height = s - r, this;
    }
    static From(e) {
      return new _Te2(e.x, e.y, e.w, e.h);
    }
    static FromPoints(e) {
      if (e.length === 0)
        return new _Te2();
      let n = 1 / 0, r = 1 / 0, i = -1 / 0, s = -1 / 0, o;
      for (let a = 0, l = e.length; a < l; a++)
        o = e[a], n = Math.min(o.x, n), r = Math.min(o.y, r), i = Math.max(o.x, i), s = Math.max(o.y, s);
      return new _Te2(n, r, i - n, s - r);
    }
    static Expand(e, n) {
      const r = Math.min(n.minX, e.minX), i = Math.min(n.minY, e.minY), s = Math.max(n.maxX, e.maxX), o = Math.max(n.maxY, e.maxY);
      return new _Te2(r, i, s - r, o - i);
    }
    static ExpandBy(e, n) {
      return new _Te2(e.minX - n, e.minY - n, e.width + n * 2, e.height + n * 2);
    }
    static Resize(e, n, r, i, s = false) {
      const { minX: o, minY: a, maxX: l, maxY: c } = e;
      let { minX: u, minY: d, maxX: h, maxY: f } = e;
      switch (n) {
        case "left":
        case "top_left":
        case "bottom_left": {
          u += r;
          break;
        }
        case "right":
        case "top_right":
        case "bottom_right": {
          h += r;
          break;
        }
      }
      switch (n) {
        case "top":
        case "top_left":
        case "top_right": {
          d += i;
          break;
        }
        case "bottom":
        case "bottom_left":
        case "bottom_right": {
          f += i;
          break;
        }
      }
      const y = (h - u) / (l - o), g = (f - d) / (c - a), O = y < 0, S = g < 0;
      if (s) {
        const x = (l - o) / (c - a), P = Math.abs(h - u), C = Math.abs(f - d), _ = P * (g < 0 ? 1 : -1) * (1 / x), T = C * (y < 0 ? 1 : -1) * x, $ = x < P / C;
        switch (n) {
          case "top_left": {
            $ ? d = f + _ : u = h + T;
            break;
          }
          case "top_right": {
            $ ? d = f + _ : h = u - T;
            break;
          }
          case "bottom_right": {
            $ ? f = d - _ : h = u - T;
            break;
          }
          case "bottom_left": {
            $ ? f = d - _ : u = h + T;
            break;
          }
          case "bottom":
          case "top": {
            const N = (u + h) / 2, L = C * x;
            u = N - L / 2, h = N + L / 2;
            break;
          }
          case "left":
          case "right": {
            const N = (d + f) / 2, L = P / x;
            d = N - L / 2, f = N + L / 2;
            break;
          }
        }
      }
      if (O) {
        const x = h;
        h = u, u = x;
      }
      if (S) {
        const x = f;
        f = d, d = x;
      }
      const w = new _Te2(u, d, Math.abs(h - u), Math.abs(f - d));
      return {
        box: w,
        scaleX: +(w.width / e.width * (y > 0 ? 1 : -1)).toFixed(5),
        scaleY: +(w.height / e.height * (g > 0 ? 1 : -1)).toFixed(5)
      };
    }
    equals(e) {
      return _Te2.Equals(this, e);
    }
    static Equals(e, n) {
      return n.x === e.x && n.y === e.y && n.w === e.w && n.h === e.h;
    }
    zeroFix() {
      return this.w = Math.max(1, this.w), this.h = Math.max(1, this.h), this;
    }
    static ZeroFix(e) {
      return new _Te2(e.x, e.y, Math.max(1, e.w), Math.max(1, e.h));
    }
  };
  __publicField(_Te2, "Collides", (e, n) => !(e.maxX < n.minX || e.minX > n.maxX || e.maxY < n.minY || e.minY > n.maxY));
  __publicField(_Te2, "Contains", (e, n) => e.minX < n.minX && e.minY < n.minY && e.maxY > n.maxY && e.maxX > n.maxX);
  __publicField(_Te2, "Includes", (e, n) => _Te2.Collides(e, n) || _Te2.Contains(e, n));
  __publicField(_Te2, "ContainsPoint", (e, n, r = 0) => !(n.x < e.minX - r || n.y < e.minY - r || n.x > e.maxX + r || n.y > e.maxY + r));
  __publicField(_Te2, "Common", (e) => {
    let n = 1 / 0, r = 1 / 0, i = -1 / 0, s = -1 / 0;
    for (let o = 0; o < e.length; o++) {
      const a = e[o];
      n = Math.min(n, a.minX), r = Math.min(r, a.minY), i = Math.max(i, a.maxX), s = Math.max(s, a.maxY);
    }
    return new _Te2(n, r, i - n, s - r);
  });
  __publicField(_Te2, "Sides", (e, n = 0) => {
    const { corners: r } = e;
    return [
      [
        r[0],
        r[1]
      ],
      [
        r[1],
        r[2]
      ],
      [
        r[2],
        r[3]
      ],
      [
        r[3],
        r[0]
      ]
    ];
  });
  let Te = _Te2;
  function ike(t) {
    switch (t) {
      case "top":
        return "bottom";
      case "bottom":
        return "top";
      case "top_left":
        return "bottom_left";
      case "top_right":
        return "bottom_right";
      case "bottom_left":
        return "top_left";
      case "bottom_right":
        return "top_right";
      default:
        return t;
    }
  }
  function ske(t) {
    switch (t) {
      case "left":
        return "right";
      case "right":
        return "left";
      case "top_left":
        return "top_right";
      case "top_right":
        return "top_left";
      case "bottom_left":
        return "bottom_right";
      case "bottom_right":
        return "bottom_left";
      default:
        return t;
    }
  }
  function oke(t) {
    return t === "top_left" || t === "top_right" || t === "bottom_right" || t === "bottom_left";
  }
  function Qo(t) {
    return `${Y(t.x)},${Y(t.y)} `;
  }
  function zo(t, e) {
    return `${Y((t.x + e.x) / 2)},${Y((t.y + e.y) / 2)} `;
  }
  const zt = Math.PI, Ft = zt / 2, Bt = zt * 2, o8 = Math.PI / 180, ake = Math.sin;
  function _a(t, e, n) {
    return Math.max(e, typeof n < "u" ? Math.min(t, n) : t);
  }
  function fw(t, e = 1e10) {
    return t ? Math.round(t * e) / e : 0;
  }
  function Y0(t, e, n = 1e-6) {
    return Math.abs(t - e) <= n;
  }
  function Wv(t, e) {
    const n = Math.pow(t - e, 2) / Math.pow(t + e, 2);
    return zt * (t + e) * (1 + 3 * n / (10 + Math.sqrt(4 - 3 * n)));
  }
  function Qa(t) {
    return t = t % Bt, t < 0 ? t = t + Bt : t === 0 && (t = 0), t;
  }
  function _C(t, e) {
    return t = Qa(t), e = Qa(e), t > e && (e += Bt), e - t;
  }
  function lke(t, e) {
    return Bt - _C(t, e);
  }
  function Wx(t, e) {
    const n = (e - t) % Bt;
    return 2 * n % Bt - n;
  }
  function cke(t, e) {
    return Wx(t, e);
  }
  function tR(t) {
    return (Bt + t) % Bt;
  }
  function kk(t, e) {
    const n = Bt / e;
    let r = Math.floor((tR(t) + n / 2) / n) * n % Bt;
    return r < zt && (r += Bt), r > zt && (r -= Bt), r;
  }
  function mG(t, e) {
    return t === e || Y0(t % (Math.PI / 2) - e % (Math.PI / 2), 0);
  }
  function uke(t) {
    return t * zt / 180;
  }
  function dke(t) {
    return t * 180 / zt;
  }
  function yG(t, e, n, r) {
    return new I(t + n * Math.cos(r), e + n * Math.sin(r));
  }
  function xE(t, e, n) {
    const r = t / 2, i = e / 2, s = [];
    let o = 1 / 0, a = 1 / 0;
    for (let l = 0; l < n; l++) {
      const c = Bt / n, u = -Ft + l * c, d = r + r * Math.cos(u), h = i + i * Math.sin(u);
      d < o && (o = d), h < a && (a = h), s.push(new I(d, h));
    }
    if (o !== 0 || a !== 0)
      for (let l = 0; l < s.length; l++) {
        const c = s[l];
        c.x -= o, c.y -= a;
      }
    return s;
  }
  function Qy(t, e, n, r) {
    return t < r && n < e;
  }
  function ka(t, e, n, r) {
    const i = Math.max(t, n), s = Math.min(e, r);
    return i <= s ? [
      i,
      s
    ] : null;
  }
  const hke = (t, e, n) => {
    const r = Bt / t / 2, i = Math.floor(t / 4) * 2, s = t * 2 - i, o = 0, a = Math.floor(t / 2) * 2, l = Math.cos(-Ft + i * r) * e / 2, c = Math.cos(-Ft + s * r) * e / 2, u = Math.sin(-Ft + o * r) * n / 2, d = Math.sin(-Ft + a * r) * n / 2;
    return new Te(0, 0, l - c, d - u);
  };
  function a8(t, e, n) {
    return (e.x - t.x) * (n.y - t.y) - (n.x - t.x) * (e.y - t.y);
  }
  function Ql(t, e) {
    let n = 0, r, i;
    for (let s = 0; s < e.length; s++)
      r = e[s], i = e[(s + 1) % e.length], r.y <= t.y ? i.y > t.y && a8(r, i, t) > 0 && (n += 1) : i.y <= t.y && a8(r, i, t) < 0 && (n -= 1);
    return n !== 0;
  }
  function Y(t) {
    return +t.toFixed(4);
  }
  function Pk(t) {
    return +t.toFixed(2);
  }
  const l8 = (t) => Math.abs(t) < Number.MAX_SAFE_INTEGER, bE = ({ brush: t, color: e, opacity: n }) => {
    const r = b.useRef(null);
    bm(r, t.x, t.y);
    const i = Y(Math.max(1, t.w)), s = Y(Math.max(1, t.h));
    return m.jsx("svg", {
      className: "tl-overlays__item",
      ref: r,
      children: e ? m.jsxs("g", {
        className: "tl-brush",
        opacity: n,
        children: [
          m.jsx("rect", {
            width: i,
            height: s,
            fill: e,
            opacity: 0.75
          }),
          m.jsx("rect", {
            width: i,
            height: s,
            fill: "none",
            stroke: e,
            opacity: 0.1
          })
        ]
      }) : m.jsx("rect", {
        className: "tl-brush tl-brush__default",
        width: i,
        height: s
      })
    });
  }, fke = ({ className: t, zoom: e, point: n, color: r, viewport: i, opacity: s = 1 }) => {
    const o = b.useRef(null);
    return bm(o, _a(n.x, i.minX + 5 / e, i.maxX - 5 / e), _a(n.y, i.minY + 5 / e, i.maxY - 5 / e), 1 / e, I.Angle(i.center, n)), m.jsxs("svg", {
      ref: o,
      className: Ze("tl-overlays__item", t),
      children: [
        m.jsx("use", {
          href: "#cursor_hint",
          color: r,
          strokeWidth: 3,
          stroke: "var(--color-background)"
        }),
        m.jsx("use", {
          href: "#cursor_hint",
          color: r,
          opacity: s
        })
      ]
    });
  }, pke = ({ className: t, zoom: e, point: n, color: r, name: i, chatMessage: s }) => {
    const o = b.useRef(null);
    return bm(o, n == null ? void 0 : n.x, n == null ? void 0 : n.y, 1 / e), n ? m.jsxs("div", {
      ref: o,
      className: Ze("tl-overlays__item", t),
      children: [
        m.jsx("svg", {
          className: "tl-cursor",
          children: m.jsx("use", {
            href: "#cursor",
            color: r
          })
        }),
        s ? m.jsxs(m.Fragment, {
          children: [
            i && m.jsx("div", {
              className: "tl-nametag-title",
              style: {
                color: r
              },
              children: i
            }),
            m.jsx("div", {
              className: "tl-nametag-chat",
              style: {
                backgroundColor: r
              },
              children: s
            })
          ]
        }) : i && m.jsx("div", {
          className: "tl-nametag",
          style: {
            backgroundColor: r
          },
          children: i
        })
      ]
    }) : null;
  }, c8 = b.memo(pke), O5 = {
    openWindow: (t, e) => window.open(t, e, "noopener noreferrer"),
    refreshPage: () => window.location.reload(),
    hardReset: async () => {
      var _a3;
      return await ((_a3 = window.__tldraw__hardReset) == null ? void 0 : _a3.call(window));
    }
  };
  function vG() {
    O5.hardReset();
  }
  function gke() {
    O5.refreshPage();
  }
  const mke = "https://github.com/tldraw/tldraw/issues/new";
  function yke() {
  }
  const OG = ({ error: t, editor: e }) => {
    const n = b.useRef(null), [r, i] = b.useState(false), [s, o] = b.useState(false), [a, l] = b.useState(false), c = t instanceof Error ? t.message : String(t), u = t instanceof Error ? t.stack : null, d = ye("isDarkMode", () => {
      try {
        if (e)
          return e.user.isDarkMode;
      } catch {
      }
      return null;
    }, [
      e
    ]), [h, f] = b.useState(null);
    b.useLayoutEffect(() => {
      var _a3;
      d !== null && f(d);
      let w = (_a3 = n.current) == null ? void 0 : _a3.parentElement, x = false;
      for (; w; ) {
        if (w.classList.contains("tl-theme__dark") || w.classList.contains("tl-theme__light")) {
          x = true;
          break;
        }
        w = w.parentElement;
      }
      if (x) {
        f(null);
        return;
      }
      f(window.matchMedia("(prefers-color-scheme: dark)").matches);
    }, [
      d
    ]), b.useEffect(() => {
      if (s) {
        const w = setTimeout(() => {
          o(false);
        }, 2e3);
        return () => clearTimeout(w);
      }
    }, [
      s
    ]);
    const y = () => {
      const w = document.createElement("textarea");
      w.value = u ?? c, document.body.appendChild(w), w.select(), document.execCommand("copy"), w.remove(), o(true);
    }, g = () => {
      gke();
    }, O = async () => {
      vG();
    }, S = new URL(mke);
    return S.searchParams.set("title", c), S.searchParams.set("labels", "bug"), S.searchParams.set("body", `Hey, I ran into an error while using tldraw:

\`\`\`js
${u ?? c}
\`\`\`

My browser: ${navigator.userAgent}`), m.jsxs("div", {
      ref: n,
      className: Ze("tl-container tl-error-boundary", h === null ? "" : h ? "tl-theme__dark" : "tl-theme__light"),
      children: [
        m.jsx("div", {
          className: "tl-error-boundary__overlay"
        }),
        e && m.jsx(gG, {
          onError: yke,
          fallback: () => null,
          children: m.jsx(v5.Provider, {
            value: e,
            children: m.jsx("div", {
              className: "tl-overlay tl-error-boundary__canvas",
              children: m.jsx(P5, {})
            })
          })
        }),
        m.jsx("div", {
          className: Ze("tl-modal", "tl-error-boundary__content", {
            "tl-error-boundary__content__expanded": r && !a
          }),
          children: a ? m.jsxs(m.Fragment, {
            children: [
              m.jsx("h2", {
                children: "Are you sure?"
              }),
              m.jsx("p", {
                children: "Resetting your data will delete your drawing and cannot be undone."
              }),
              m.jsxs("div", {
                className: "tl-error-boundary__content__actions",
                children: [
                  m.jsx("button", {
                    onClick: () => l(false),
                    children: "Cancel"
                  }),
                  m.jsx("button", {
                    className: "tl-error-boundary__reset",
                    onClick: O,
                    children: "Reset data"
                  })
                ]
              })
            ]
          }) : m.jsxs(m.Fragment, {
            children: [
              m.jsx("h2", {
                children: "Something's gone wrong."
              }),
              m.jsxs("p", {
                children: [
                  "Sorry, we encountered an error. Please refresh the page to continue. If you keep seeing this error, you can ",
                  m.jsx("a", {
                    href: S.toString(),
                    children: "create a GitHub issue"
                  }),
                  " or",
                  " ",
                  m.jsx("a", {
                    href: "https://discord.gg/Cq6cPsTfNy",
                    children: "ask for help on Discord"
                  }),
                  "."
                ]
              }),
              r && m.jsxs("div", {
                className: "tl-error-boundary__content__error",
                children: [
                  m.jsx("pre", {
                    children: m.jsx("code", {
                      children: u ?? c
                    })
                  }),
                  m.jsx("button", {
                    onClick: y,
                    children: s ? "Copied!" : "Copy"
                  })
                ]
              }),
              m.jsxs("div", {
                className: "tl-error-boundary__content__actions",
                children: [
                  m.jsx("button", {
                    onClick: () => i(!r),
                    children: r ? "Hide details" : "Show details"
                  }),
                  m.jsxs("div", {
                    className: "tl-error-boundary__content__actions__group",
                    children: [
                      m.jsx("button", {
                        className: "tl-error-boundary__reset",
                        onClick: () => l(true),
                        children: "Reset data"
                      }),
                      m.jsx("button", {
                        className: "tl-error-boundary__refresh",
                        onClick: g,
                        children: "Refresh Page"
                      })
                    ]
                  })
                ]
              })
            ]
          })
        })
      ]
    });
  }, gc = 2e3, Ck = 40, Pc = 320, fp = [
    0.1,
    0.25,
    0.5,
    1,
    2,
    4,
    8
  ], zy = 0.1, Fu = 8, vke = 0.5, Oke = 0.1, Ske = 0.2, wke = 5e-3, xke = 0.05, bke = 450, kke = 200, nR = 6, Zv = 4, Pke = 32, _k = {};
  for (let t = 1; t <= Math.ceil(Fu); t++)
    _k[t + "_dark"] = `hash_pattern_zoom_${t}_dark`, _k[t + "_light"] = `hash_pattern_zoom_${t}_light`;
  const Cke = {
    duration: 0,
    easing: Oi.easeInOutCubic
  }, Zx = 0.09, u8 = [
    {
      min: -1,
      mid: 0.15,
      step: 64
    },
    {
      min: 0.05,
      mid: 0.375,
      step: 16
    },
    {
      min: 0.15,
      mid: 1,
      step: 4
    },
    {
      min: 0.7,
      mid: 2.5,
      step: 1
    }
  ], _ke = 6e4, SG = 3e3, Tke = 1200, d8 = {
    CAMERA_MOVE: -10
  }, Eke = 64, Ike = 620, Va = 8, $ke = ({ x: t, y: e, z: n, size: r }) => m.jsxs("svg", {
    className: "tl-grid",
    version: "1.1",
    xmlns: "http://www.w3.org/2000/svg",
    children: [
      m.jsx("defs", {
        children: u8.map(({ min: i, mid: s, step: o }, a) => {
          const l = o * r * n, c = 0.5 + t * n, u = 0.5 + e * n, d = c > 0 ? c % l : l + c % l, h = u > 0 ? u % l : l + u % l, f = n < s ? fk(n, [
            i,
            s
          ], [
            0,
            1
          ]) : 1;
          return m.jsx("pattern", {
            id: `grid-${o}`,
            width: l,
            height: l,
            patternUnits: "userSpaceOnUse",
            children: m.jsx("circle", {
              className: "tl-grid-dot",
              cx: d,
              cy: h,
              r: 1,
              opacity: f
            })
          }, `grid-pattern-${a}`);
        })
      }),
      u8.map(({ step: i }, s) => m.jsx("rect", {
        width: "100%",
        height: "100%",
        fill: `url(#grid-${i})`
      }, `grid-rect-${s}`))
    ]
  }), Ake = ({ handle: t, isCoarse: e, className: n, zoom: r }) => {
    const i = (e ? 20 : 12) / r, s = (t.type === "create" && e ? 3 : 4) / r;
    return m.jsxs("g", {
      className: Ze("tl-handle", {
        "tl-handle__virtual": t.type === "virtual",
        "tl-handle__create": t.type === "create"
      }, n),
      children: [
        m.jsx("circle", {
          className: "tl-handle__bg",
          r: i
        }),
        m.jsx("circle", {
          className: "tl-handle__fg",
          r: s
        })
      ]
    });
  }, Rke = ({ children: t }) => m.jsx("svg", {
    className: "tl-user-handles tl-overlays__item",
    children: t
  }), Mke = ({ shapeId: t }) => m.jsx(JO, {
    className: "tl-user-indicator__hovered",
    id: t
  });
  function Qg(t, e = true) {
    const n = t.length;
    if (n < 2)
      return "";
    let r = t[0], i = t[1];
    if (n === 2)
      return `M${Qo(r)}L${Qo(i)}`;
    let s = "";
    for (let o = 2, a = n - 1; o < a; o++)
      r = t[o], i = t[o + 1], s += zo(r, i);
    return e ? `M${zo(t[0], t[1])}Q${Qo(t[1])}${zo(t[1], t[2])}T${s}${zo(t[n - 1], t[0])}${zo(t[0], t[1])}Z` : `M${Qo(t[0])}Q${Qo(t[1])}${zo(t[1], t[2])}${t.length > 3 ? "T" : ""}${s}L${Qo(t[n - 1])}`;
  }
  const h8 = ({ scribble: t, zoom: e, color: n, opacity: r, className: i }) => t.points.length ? m.jsx("svg", {
    className: i && Ze("tl-overlays__item", i),
    children: m.jsx("path", {
      className: "tl-scribble",
      d: Qg(t.points, false),
      stroke: n ?? `var(--color-${t.color})`,
      fill: "none",
      strokeWidth: 8 / e,
      opacity: r ?? t.opacity
    })
  }) : null, wG = ({ bounds: t, rotation: e }) => {
    const n = b.useRef(null);
    return bm(n, t.x, t.y, 1, e), b.useLayoutEffect(() => {
      const r = n.current;
      r && (r.style.width = Y(Math.max(1, t.width)) + "px", r.style.height = Y(Math.max(1, t.height)) + "px");
    }, [
      t.width,
      t.height
    ]), m.jsx("div", {
      ref: n,
      className: "tl-selection__bg",
      draggable: false
    });
  }, Dke = ({ bounds: t, rotation: e }) => {
    const n = ue(), r = b.useRef(null), i = ye("only selected shape", () => n.onlySelectedShape, [
      n
    ]), s = i ? n.getShapeUtil(i).expandSelectionOutlinePx(i) : 0;
    return bm(r, t == null ? void 0 : t.x, t == null ? void 0 : t.y, 1, e, {
      x: -s,
      y: -s
    }), t = t.clone().expandBy(s).zeroFix(), m.jsx("svg", {
      ref: r,
      className: "tl-overlays__item tl-selection__fg",
      "data-testid": "selection-foreground",
      children: m.jsx("rect", {
        className: Ze("tl-selection__fg__outline"),
        width: Y(t.width),
        height: Y(t.height)
      })
    });
  }, Lke = () => m.jsx("div", {
    className: "tl-shape-error-boundary"
  }), jke = () => m.jsx("circle", {
    cx: 4,
    cy: 4,
    r: 8,
    strokeWidth: "1",
    stroke: "red"
  });
  function Nke({ points: t, zoom: e }) {
    const n = 2.5 / e, r = t.reduce((h, f) => Math.min(h, f.x), 1 / 0), i = t.reduce((h, f) => Math.max(h, f.x), -1 / 0), s = t.reduce((h, f) => Math.min(h, f.y), 1 / 0), o = t.reduce((h, f) => Math.max(h, f.y), -1 / 0), a = t.some((h) => h.x === r && h.y === s);
    let l, c, u, d;
    return a ? (l = r, c = s, u = i, d = o) : (l = r, c = o, u = i, d = s), m.jsxs("g", {
      className: "tl-snap-line",
      children: [
        m.jsx("line", {
          x1: l,
          y1: c,
          x2: u,
          y2: d
        }),
        t.map((h, f) => m.jsx("g", {
          transform: `translate(${h.x},${h.y})`,
          children: m.jsx("path", {
            className: "tl-snap-point",
            d: `M ${-n},${-n} L ${n},${n} M ${-n},${n} L ${n},${-n}`
          })
        }, f))
      ]
    });
  }
  function Qke({ gaps: t, direction: e, zoom: n }) {
    const r = 3.5 / n;
    let i = [
      -1 / 0,
      1 / 0
    ], s = null;
    const o = e === "horizontal";
    for (const l of t) {
      if (s = ka(i[0], i[1], o ? l.startEdge[0].y : l.startEdge[0].x, o ? l.startEdge[1].y : l.startEdge[1].x), s)
        i = s;
      else
        continue;
      if (s = ka(i[0], i[1], o ? l.endEdge[0].y : l.endEdge[0].x, o ? l.endEdge[1].y : l.endEdge[1].x), s)
        i = s;
      else
        continue;
    }
    if (i === null)
      return null;
    const a = (i[0] + i[1]) / 2;
    return m.jsx("g", {
      className: "tl-snap-line",
      children: t.map(({ startEdge: l, endEdge: c }, u) => m.jsx(b.Fragment, {
        children: o ? m.jsxs(m.Fragment, {
          children: [
            m.jsx("line", {
              x1: l[0].x,
              y1: a - 2 * r,
              x2: l[1].x,
              y2: a + 2 * r
            }),
            m.jsx("line", {
              x1: c[0].x,
              y1: a - 2 * r,
              x2: c[1].x,
              y2: a + 2 * r
            }),
            m.jsx("line", {
              x1: l[0].x,
              y1: a,
              x2: c[0].x,
              y2: a
            }),
            m.jsx("line", {
              x1: (l[0].x + c[0].x) / 2,
              y1: a - r,
              x2: (l[0].x + c[0].x) / 2,
              y2: a + r
            })
          ]
        }) : m.jsxs(m.Fragment, {
          children: [
            m.jsx("line", {
              x1: a - 2 * r,
              y1: l[0].y,
              x2: a + 2 * r,
              y2: l[1].y
            }),
            m.jsx("line", {
              x1: a - 2 * r,
              y1: c[0].y,
              x2: a + 2 * r,
              y2: c[1].y
            }),
            m.jsx("line", {
              x1: a,
              y1: l[0].y,
              x2: a,
              y2: c[0].y
            }),
            m.jsx("line", {
              x1: a - r,
              y1: (l[0].y + c[0].y) / 2,
              x2: a + r,
              y2: (l[0].y + c[0].y) / 2
            })
          ]
        })
      }, u))
    });
  }
  const zke = ({ className: t, line: e, zoom: n }) => m.jsx("svg", {
    className: Ze("tl-overlays__item", t),
    children: e.type === "points" ? m.jsx(Nke, {
      ...e,
      zoom: n
    }) : e.type === "gaps" ? m.jsx(Qke, {
      ...e,
      zoom: n
    }) : null
  }), Fke = () => m.jsx("svg", {
    width: 16,
    height: 16,
    viewBox: "0 0 16 16",
    children: m.jsxs("g", {
      strokeWidth: 2,
      fill: "none",
      fillRule: "evenodd",
      children: [
        m.jsx("circle", {
          strokeOpacity: 0.25,
          cx: 8,
          cy: 8,
          r: 7,
          stroke: "var(--color-text-1)"
        }),
        m.jsx("path", {
          strokeLinecap: "round",
          d: "M15 8c0-4.5-4.5-7-7-7",
          stroke: "var(--color-text-1)",
          children: m.jsx("animateTransform", {
            attributeName: "transform",
            type: "rotate",
            from: "0 8 8",
            to: "360 8 8",
            dur: "1s",
            repeatCount: "indefinite"
          })
        })
      ]
    })
  }), Bke = () => null, xG = b.createContext({});
  function Uke({ overrides: t, children: e }) {
    return m.jsx(xG.Provider, {
      value: b.useMemo(() => ({
        Background: nke,
        SvgDefs: Bke,
        Brush: bE,
        ZoomBrush: bE,
        CollaboratorBrush: bE,
        Cursor: c8,
        CollaboratorCursor: c8,
        CollaboratorHint: fke,
        CollaboratorShapeIndicator: JO,
        Grid: $ke,
        Scribble: h8,
        SnapLine: zke,
        Handles: Rke,
        Handle: Ake,
        CollaboratorScribble: h8,
        ErrorFallback: OG,
        ShapeErrorFallback: Lke,
        ShapeIndicatorErrorFallback: jke,
        Spinner: Fke,
        SelectionBackground: wG,
        SelectionForeground: Dke,
        HoveredShapeIndicator: Mke,
        ...t
      }), [
        t
      ]),
      children: e
    });
  }
  function _i() {
    return b.useContext(xG);
  }
  const Vke = [
    "textarea",
    "input"
  ];
  function Xke(t) {
    const e = ue();
    b.useEffect(() => {
      const n = t.current;
      if (!n)
        return;
      const r = (i) => {
        var _a3;
        if (i instanceof PointerEvent && i.pointerType === "pen") {
          i.isKilled = true;
          const { target: s } = i;
          if (Vke.includes((_a3 = s.tagName) == null ? void 0 : _a3.toLocaleLowerCase()) || e.isIn("select.editing_shape"))
            return;
          Rt(i);
        }
      };
      return n.addEventListener("touchstart", r), n.addEventListener("touchend", r), () => {
        n.removeEventListener("touchstart", r), n.addEventListener("touchend", r);
      };
    }, [
      e,
      t
    ]);
  }
  function Wke(t, e, n) {
    return Math.max(e, Math.min(t, n));
  }
  const Xr = {
    toVector(t, e) {
      return t === void 0 && (t = e), Array.isArray(t) ? t : [
        t,
        t
      ];
    },
    add(t, e) {
      return [
        t[0] + e[0],
        t[1] + e[1]
      ];
    },
    sub(t, e) {
      return [
        t[0] - e[0],
        t[1] - e[1]
      ];
    },
    addTo(t, e) {
      t[0] += e[0], t[1] += e[1];
    },
    subTo(t, e) {
      t[0] -= e[0], t[1] -= e[1];
    }
  };
  function f8(t, e, n) {
    return e === 0 || Math.abs(e) === 1 / 0 ? Math.pow(t, n * 5) : t * e * n / (e + n * t);
  }
  function p8(t, e, n, r = 0.15) {
    return r === 0 ? Wke(t, e, n) : t < e ? -f8(e - t, n - e, r) + e : t > n ? +f8(t - n, n - e, r) + n : t;
  }
  function Zke(t, [e, n], [r, i]) {
    const [[s, o], [a, l]] = t;
    return [
      p8(e, s, o, r),
      p8(n, a, l, i)
    ];
  }
  function Hke(t, e) {
    if (typeof t != "object" || t === null)
      return t;
    var n = t[Symbol.toPrimitive];
    if (n !== void 0) {
      var r = n.call(t, e || "default");
      if (typeof r != "object")
        return r;
      throw new TypeError("@@toPrimitive must return a primitive value.");
    }
    return (e === "string" ? String : Number)(t);
  }
  function Yke(t) {
    var e = Hke(t, "string");
    return typeof e == "symbol" ? e : String(e);
  }
  function li(t, e, n) {
    return e = Yke(e), e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  function g8(t, e) {
    var n = Object.keys(t);
    if (Object.getOwnPropertySymbols) {
      var r = Object.getOwnPropertySymbols(t);
      e && (r = r.filter(function(i) {
        return Object.getOwnPropertyDescriptor(t, i).enumerable;
      })), n.push.apply(n, r);
    }
    return n;
  }
  function Rn(t) {
    for (var e = 1; e < arguments.length; e++) {
      var n = arguments[e] != null ? arguments[e] : {};
      e % 2 ? g8(Object(n), true).forEach(function(r) {
        li(t, r, n[r]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : g8(Object(n)).forEach(function(r) {
        Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
      });
    }
    return t;
  }
  const bG = {
    pointer: {
      start: "down",
      change: "move",
      end: "up"
    },
    mouse: {
      start: "down",
      change: "move",
      end: "up"
    },
    touch: {
      start: "start",
      change: "move",
      end: "end"
    },
    gesture: {
      start: "start",
      change: "change",
      end: "end"
    }
  };
  function m8(t) {
    return t ? t[0].toUpperCase() + t.slice(1) : "";
  }
  const Gke = [
    "enter",
    "leave"
  ];
  function qke(t = false, e) {
    return t && !Gke.includes(e);
  }
  function Kke(t, e = "", n = false) {
    const r = bG[t], i = r && r[e] || e;
    return "on" + m8(t) + m8(i) + (qke(n, i) ? "Capture" : "");
  }
  const Jke = [
    "gotpointercapture",
    "lostpointercapture"
  ];
  function ePe(t) {
    let e = t.substring(2).toLowerCase();
    const n = !!~e.indexOf("passive");
    n && (e = e.replace("passive", ""));
    const r = Jke.includes(e) ? "capturecapture" : "capture", i = !!~e.indexOf(r);
    return i && (e = e.replace("capture", "")), {
      device: e,
      capture: i,
      passive: n
    };
  }
  function tPe(t, e = "") {
    const n = bG[t], r = n && n[e] || e;
    return t + r;
  }
  function kG(t) {
    return "touches" in t;
  }
  function nPe(t) {
    return kG(t) ? "touch" : "pointerType" in t ? t.pointerType : "mouse";
  }
  function rPe(t) {
    return Array.from(t.touches).filter((e) => {
      var n, r;
      return e.target === t.currentTarget || ((n = t.currentTarget) === null || n === void 0 || (r = n.contains) === null || r === void 0 ? void 0 : r.call(n, e.target));
    });
  }
  function rR(t, e) {
    try {
      const n = e.clientX - t.clientX, r = e.clientY - t.clientY, i = (e.clientX + t.clientX) / 2, s = (e.clientY + t.clientY) / 2, o = Math.hypot(n, r);
      return {
        angle: -(Math.atan2(n, r) * 180) / Math.PI,
        distance: o,
        origin: [
          i,
          s
        ]
      };
    } catch {
    }
    return null;
  }
  function iPe(t) {
    return rPe(t).map((e) => e.identifier);
  }
  function y8(t, e) {
    const [n, r] = Array.from(t.touches).filter((i) => e.includes(i.identifier));
    return rR(n, r);
  }
  const v8 = 40, O8 = 800;
  function PG(t) {
    let { deltaX: e, deltaY: n, deltaMode: r } = t;
    return r === 1 ? (e *= v8, n *= v8) : r === 2 && (e *= O8, n *= O8), [
      e,
      n
    ];
  }
  function sPe(t) {
    const e = {};
    if ("buttons" in t && (e.buttons = t.buttons), "shiftKey" in t) {
      const { shiftKey: n, altKey: r, metaKey: i, ctrlKey: s } = t;
      Object.assign(e, {
        shiftKey: n,
        altKey: r,
        metaKey: i,
        ctrlKey: s
      });
    }
    return e;
  }
  function Tk(t, ...e) {
    return typeof t == "function" ? t(...e) : t;
  }
  function oPe() {
  }
  function aPe(...t) {
    return t.length === 0 ? oPe : t.length === 1 ? t[0] : function() {
      let e;
      for (const n of t)
        e = n.apply(this, arguments) || e;
      return e;
    };
  }
  function S8(t, e) {
    return Object.assign({}, e, t || {});
  }
  const lPe = 32;
  class CG {
    constructor(e, n, r) {
      this.ctrl = e, this.args = n, this.key = r, this.state || (this.state = {}, this.computeValues([
        0,
        0
      ]), this.computeInitial(), this.init && this.init(), this.reset());
    }
    get state() {
      return this.ctrl.state[this.key];
    }
    set state(e) {
      this.ctrl.state[this.key] = e;
    }
    get shared() {
      return this.ctrl.state.shared;
    }
    get eventStore() {
      return this.ctrl.gestureEventStores[this.key];
    }
    get timeoutStore() {
      return this.ctrl.gestureTimeoutStores[this.key];
    }
    get config() {
      return this.ctrl.config[this.key];
    }
    get sharedConfig() {
      return this.ctrl.config.shared;
    }
    get handler() {
      return this.ctrl.handlers[this.key];
    }
    reset() {
      const { state: e, shared: n, ingKey: r, args: i } = this;
      n[r] = e._active = e.active = e._blocked = e._force = false, e._step = [
        false,
        false
      ], e.intentional = false, e._movement = [
        0,
        0
      ], e._distance = [
        0,
        0
      ], e._direction = [
        0,
        0
      ], e._delta = [
        0,
        0
      ], e._bounds = [
        [
          -1 / 0,
          1 / 0
        ],
        [
          -1 / 0,
          1 / 0
        ]
      ], e.args = i, e.axis = void 0, e.memo = void 0, e.elapsedTime = e.timeDelta = 0, e.direction = [
        0,
        0
      ], e.distance = [
        0,
        0
      ], e.overflow = [
        0,
        0
      ], e._movementBound = [
        false,
        false
      ], e.velocity = [
        0,
        0
      ], e.movement = [
        0,
        0
      ], e.delta = [
        0,
        0
      ], e.timeStamp = 0;
    }
    start(e) {
      const n = this.state, r = this.config;
      n._active || (this.reset(), this.computeInitial(), n._active = true, n.target = e.target, n.currentTarget = e.currentTarget, n.lastOffset = r.from ? Tk(r.from, n) : n.offset, n.offset = n.lastOffset, n.startTime = n.timeStamp = e.timeStamp);
    }
    computeValues(e) {
      const n = this.state;
      n._values = e, n.values = this.config.transform(e);
    }
    computeInitial() {
      const e = this.state;
      e._initial = e._values, e.initial = e.values;
    }
    compute(e) {
      const { state: n, config: r, shared: i } = this;
      n.args = this.args;
      let s = 0;
      if (e && (n.event = e, r.preventDefault && e.cancelable && n.event.preventDefault(), n.type = e.type, i.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, i.locked = !!document.pointerLockElement, Object.assign(i, sPe(e)), i.down = i.pressed = i.buttons % 2 === 1 || i.touches > 0, s = e.timeStamp - n.timeStamp, n.timeStamp = e.timeStamp, n.elapsedTime = n.timeStamp - n.startTime), n._active) {
        const _ = n._delta.map(Math.abs);
        Xr.addTo(n._distance, _);
      }
      this.axisIntent && this.axisIntent(e);
      const [o, a] = n._movement, [l, c] = r.threshold, { _step: u, values: d } = n;
      if (r.hasCustomTransform ? (u[0] === false && (u[0] = Math.abs(o) >= l && d[0]), u[1] === false && (u[1] = Math.abs(a) >= c && d[1])) : (u[0] === false && (u[0] = Math.abs(o) >= l && Math.sign(o) * l), u[1] === false && (u[1] = Math.abs(a) >= c && Math.sign(a) * c)), n.intentional = u[0] !== false || u[1] !== false, !n.intentional)
        return;
      const h = [
        0,
        0
      ];
      if (r.hasCustomTransform) {
        const [_, T] = d;
        h[0] = u[0] !== false ? _ - u[0] : 0, h[1] = u[1] !== false ? T - u[1] : 0;
      } else
        h[0] = u[0] !== false ? o - u[0] : 0, h[1] = u[1] !== false ? a - u[1] : 0;
      this.restrictToAxis && !n._blocked && this.restrictToAxis(h);
      const f = n.offset, y = n._active && !n._blocked || n.active;
      y && (n.first = n._active && !n.active, n.last = !n._active && n.active, n.active = i[this.ingKey] = n._active, e && (n.first && ("bounds" in r && (n._bounds = Tk(r.bounds, n)), this.setup && this.setup()), n.movement = h, this.computeOffset()));
      const [g, O] = n.offset, [[S, w], [x, P]] = n._bounds;
      n.overflow = [
        g < S ? -1 : g > w ? 1 : 0,
        O < x ? -1 : O > P ? 1 : 0
      ], n._movementBound[0] = n.overflow[0] ? n._movementBound[0] === false ? n._movement[0] : n._movementBound[0] : false, n._movementBound[1] = n.overflow[1] ? n._movementBound[1] === false ? n._movement[1] : n._movementBound[1] : false;
      const C = n._active ? r.rubberband || [
        0,
        0
      ] : [
        0,
        0
      ];
      if (n.offset = Zke(n._bounds, n.offset, C), n.delta = Xr.sub(n.offset, f), this.computeMovement(), y && (!n.last || s > lPe)) {
        n.delta = Xr.sub(n.offset, f);
        const _ = n.delta.map(Math.abs);
        Xr.addTo(n.distance, _), n.direction = n.delta.map(Math.sign), n._direction = n._delta.map(Math.sign), !n.first && s > 0 && (n.velocity = [
          _[0] / s,
          _[1] / s
        ], n.timeDelta = s);
      }
    }
    emit() {
      const e = this.state, n = this.shared, r = this.config;
      if (e._active || this.clean(), (e._blocked || !e.intentional) && !e._force && !r.triggerAllEvents)
        return;
      const i = this.handler(Rn(Rn(Rn({}, n), e), {}, {
        [this.aliasKey]: e.values
      }));
      i !== void 0 && (e.memo = i);
    }
    clean() {
      this.eventStore.clean(), this.timeoutStore.clean();
    }
  }
  function cPe([t, e], n) {
    const r = Math.abs(t), i = Math.abs(e);
    if (r > i && r > n)
      return "x";
    if (i > r && i > n)
      return "y";
  }
  class uPe extends CG {
    constructor(...e) {
      super(...e), li(this, "aliasKey", "xy");
    }
    reset() {
      super.reset(), this.state.axis = void 0;
    }
    init() {
      this.state.offset = [
        0,
        0
      ], this.state.lastOffset = [
        0,
        0
      ];
    }
    computeOffset() {
      this.state.offset = Xr.add(this.state.lastOffset, this.state.movement);
    }
    computeMovement() {
      this.state.movement = Xr.sub(this.state.offset, this.state.lastOffset);
    }
    axisIntent(e) {
      const n = this.state, r = this.config;
      if (!n.axis && e) {
        const i = typeof r.axisThreshold == "object" ? r.axisThreshold[nPe(e)] : r.axisThreshold;
        n.axis = cPe(n._movement, i);
      }
      n._blocked = (r.lockDirection || !!r.axis) && !n.axis || !!r.axis && r.axis !== n.axis;
    }
    restrictToAxis(e) {
      if (this.config.axis || this.config.lockDirection)
        switch (this.state.axis) {
          case "x":
            e[1] = 0;
            break;
          case "y":
            e[0] = 0;
            break;
        }
    }
  }
  const dPe = (t) => t, w8 = 0.15, _G = {
    enabled(t = true) {
      return t;
    },
    eventOptions(t, e, n) {
      return Rn(Rn({}, n.shared.eventOptions), t);
    },
    preventDefault(t = false) {
      return t;
    },
    triggerAllEvents(t = false) {
      return t;
    },
    rubberband(t = 0) {
      switch (t) {
        case true:
          return [
            w8,
            w8
          ];
        case false:
          return [
            0,
            0
          ];
        default:
          return Xr.toVector(t);
      }
    },
    from(t) {
      if (typeof t == "function")
        return t;
      if (t != null)
        return Xr.toVector(t);
    },
    transform(t, e, n) {
      const r = t || n.shared.transform;
      return this.hasCustomTransform = !!r, r || dPe;
    },
    threshold(t) {
      return Xr.toVector(t, 0);
    }
  }, hPe = 0, eS = Rn(Rn({}, _G), {}, {
    axis(t, e, { axis: n }) {
      if (this.lockDirection = n === "lock", !this.lockDirection)
        return n;
    },
    axisThreshold(t = hPe) {
      return t;
    },
    bounds(t = {}) {
      if (typeof t == "function")
        return (s) => eS.bounds(t(s));
      if ("current" in t)
        return () => t.current;
      if (typeof HTMLElement == "function" && t instanceof HTMLElement)
        return t;
      const { left: e = -1 / 0, right: n = 1 / 0, top: r = -1 / 0, bottom: i = 1 / 0 } = t;
      return [
        [
          e,
          n
        ],
        [
          r,
          i
        ]
      ];
    }
  }), tS = typeof window < "u" && window.document && window.document.createElement;
  function TG() {
    return tS && "ontouchstart" in window;
  }
  function fPe() {
    return TG() || tS && window.navigator.maxTouchPoints > 1;
  }
  function pPe() {
    return tS && "onpointerdown" in window;
  }
  function gPe() {
    return tS && "exitPointerLock" in window.document;
  }
  function mPe() {
    try {
      return "constructor" in GestureEvent;
    } catch {
      return false;
    }
  }
  const Fo = {
    isBrowser: tS,
    gesture: mPe(),
    touch: TG(),
    touchscreen: fPe(),
    pointer: pPe(),
    pointerLock: gPe()
  }, yPe = 250, vPe = 180, OPe = 0.5, SPe = 50, wPe = 250, xPe = 10, x8 = {
    mouse: 0,
    touch: 0,
    pen: 8
  };
  Rn(Rn({}, eS), {}, {
    device(t, e, { pointer: { touch: n = false, lock: r = false, mouse: i = false } = {} }) {
      return this.pointerLock = r && Fo.pointerLock, Fo.touch && n ? "touch" : this.pointerLock ? "mouse" : Fo.pointer && !i ? "pointer" : Fo.touch ? "touch" : "mouse";
    },
    preventScrollAxis(t, e, { preventScroll: n }) {
      if (this.preventScrollDelay = typeof n == "number" ? n : n || n === void 0 && t ? yPe : void 0, !(!Fo.touchscreen || n === false))
        return t || (n !== void 0 ? "y" : void 0);
    },
    pointerCapture(t, e, { pointer: { capture: n = true, buttons: r = 1, keys: i = true } = {} }) {
      return this.pointerButtons = r, this.keys = i, !this.pointerLock && this.device === "pointer" && n;
    },
    threshold(t, e, { filterTaps: n = false, tapsThreshold: r = 3, axis: i = void 0 }) {
      const s = Xr.toVector(t, n ? r : i ? 1 : 0);
      return this.filterTaps = n, this.tapsThreshold = r, s;
    },
    swipe({ velocity: t = OPe, distance: e = SPe, duration: n = wPe } = {}) {
      return {
        velocity: this.transform(Xr.toVector(t)),
        distance: this.transform(Xr.toVector(e)),
        duration: n
      };
    },
    delay(t = 0) {
      switch (t) {
        case true:
          return vPe;
        case false:
          return 0;
        default:
          return t;
      }
    },
    axisThreshold(t) {
      return t ? Rn(Rn({}, x8), t) : x8;
    },
    keyboardDisplacement(t = xPe) {
      return t;
    }
  });
  function EG(t) {
    const [e, n] = t.overflow, [r, i] = t._delta, [s, o] = t._direction;
    (e < 0 && r > 0 && s < 0 || e > 0 && r < 0 && s > 0) && (t._movement[0] = t._movementBound[0]), (n < 0 && i > 0 && o < 0 || n > 0 && i < 0 && o > 0) && (t._movement[1] = t._movementBound[1]);
  }
  const bPe = 30, kPe = 100;
  class PPe extends CG {
    constructor(...e) {
      super(...e), li(this, "ingKey", "pinching"), li(this, "aliasKey", "da");
    }
    init() {
      this.state.offset = [
        1,
        0
      ], this.state.lastOffset = [
        1,
        0
      ], this.state._pointerEvents = /* @__PURE__ */ new Map();
    }
    reset() {
      super.reset();
      const e = this.state;
      e._touchIds = [], e.canceled = false, e.cancel = this.cancel.bind(this), e.turns = 0;
    }
    computeOffset() {
      const { type: e, movement: n, lastOffset: r } = this.state;
      e === "wheel" ? this.state.offset = Xr.add(n, r) : this.state.offset = [
        (1 + n[0]) * r[0],
        n[1] + r[1]
      ];
    }
    computeMovement() {
      const { offset: e, lastOffset: n } = this.state;
      this.state.movement = [
        e[0] / n[0],
        e[1] - n[1]
      ];
    }
    axisIntent() {
      const e = this.state, [n, r] = e._movement;
      if (!e.axis) {
        const i = Math.abs(n) * bPe - Math.abs(r);
        i < 0 ? e.axis = "angle" : i > 0 && (e.axis = "scale");
      }
    }
    restrictToAxis(e) {
      this.config.lockDirection && (this.state.axis === "scale" ? e[1] = 0 : this.state.axis === "angle" && (e[0] = 0));
    }
    cancel() {
      const e = this.state;
      e.canceled || setTimeout(() => {
        e.canceled = true, e._active = false, this.compute(), this.emit();
      }, 0);
    }
    touchStart(e) {
      this.ctrl.setEventIds(e);
      const n = this.state, r = this.ctrl.touchIds;
      if (n._active && n._touchIds.every((s) => r.has(s)) || r.size < 2)
        return;
      this.start(e), n._touchIds = Array.from(r).slice(0, 2);
      const i = y8(e, n._touchIds);
      i && this.pinchStart(e, i);
    }
    pointerStart(e) {
      if (e.buttons != null && e.buttons % 2 !== 1)
        return;
      this.ctrl.setEventIds(e), e.target.setPointerCapture(e.pointerId);
      const n = this.state, r = n._pointerEvents, i = this.ctrl.pointerIds;
      if (n._active && Array.from(r.keys()).every((o) => i.has(o)) || (r.size < 2 && r.set(e.pointerId, e), n._pointerEvents.size < 2))
        return;
      this.start(e);
      const s = rR(...Array.from(r.values()));
      s && this.pinchStart(e, s);
    }
    pinchStart(e, n) {
      const r = this.state;
      r.origin = n.origin, this.computeValues([
        n.distance,
        n.angle
      ]), this.computeInitial(), this.compute(e), this.emit();
    }
    touchMove(e) {
      if (!this.state._active)
        return;
      const n = y8(e, this.state._touchIds);
      n && this.pinchMove(e, n);
    }
    pointerMove(e) {
      const n = this.state._pointerEvents;
      if (n.has(e.pointerId) && n.set(e.pointerId, e), !this.state._active)
        return;
      const r = rR(...Array.from(n.values()));
      r && this.pinchMove(e, r);
    }
    pinchMove(e, n) {
      const r = this.state, i = r._values[1], s = n.angle - i;
      let o = 0;
      Math.abs(s) > 270 && (o += Math.sign(s)), this.computeValues([
        n.distance,
        n.angle - 360 * o
      ]), r.origin = n.origin, r.turns = o, r._movement = [
        r._values[0] / r._initial[0] - 1,
        r._values[1] - r._initial[1]
      ], this.compute(e), this.emit();
    }
    touchEnd(e) {
      this.ctrl.setEventIds(e), this.state._active && this.state._touchIds.some((n) => !this.ctrl.touchIds.has(n)) && (this.state._active = false, this.compute(e), this.emit());
    }
    pointerEnd(e) {
      const n = this.state;
      this.ctrl.setEventIds(e);
      try {
        e.target.releasePointerCapture(e.pointerId);
      } catch {
      }
      n._pointerEvents.has(e.pointerId) && n._pointerEvents.delete(e.pointerId), n._active && n._pointerEvents.size < 2 && (n._active = false, this.compute(e), this.emit());
    }
    gestureStart(e) {
      e.cancelable && e.preventDefault();
      const n = this.state;
      n._active || (this.start(e), this.computeValues([
        e.scale,
        e.rotation
      ]), n.origin = [
        e.clientX,
        e.clientY
      ], this.compute(e), this.emit());
    }
    gestureMove(e) {
      if (e.cancelable && e.preventDefault(), !this.state._active)
        return;
      const n = this.state;
      this.computeValues([
        e.scale,
        e.rotation
      ]), n.origin = [
        e.clientX,
        e.clientY
      ];
      const r = n._movement;
      n._movement = [
        e.scale - 1,
        e.rotation
      ], n._delta = Xr.sub(n._movement, r), this.compute(e), this.emit();
    }
    gestureEnd(e) {
      this.state._active && (this.state._active = false, this.compute(e), this.emit());
    }
    wheel(e) {
      const n = this.config.modifierKey;
      n && (Array.isArray(n) ? !n.find((r) => e[r]) : !e[n]) || (this.state._active ? this.wheelChange(e) : this.wheelStart(e), this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this)));
    }
    wheelStart(e) {
      this.start(e), this.wheelChange(e);
    }
    wheelChange(e) {
      "uv" in e || e.cancelable && e.preventDefault();
      const r = this.state;
      r._delta = [
        -PG(e)[1] / kPe * r.offset[0],
        0
      ], Xr.addTo(r._movement, r._delta), EG(r), this.state.origin = [
        e.clientX,
        e.clientY
      ], this.compute(e), this.emit();
    }
    wheelEnd() {
      this.state._active && (this.state._active = false, this.compute(), this.emit());
    }
    bind(e) {
      const n = this.config.device;
      n && (e(n, "start", this[n + "Start"].bind(this)), e(n, "change", this[n + "Move"].bind(this)), e(n, "end", this[n + "End"].bind(this)), e(n, "cancel", this[n + "End"].bind(this)), e("lostPointerCapture", "", this[n + "End"].bind(this))), this.config.pinchOnWheel && e("wheel", "", this.wheel.bind(this), {
        passive: false
      });
    }
  }
  const CPe = Rn(Rn({}, _G), {}, {
    device(t, e, { shared: n, pointer: { touch: r = false } = {} }) {
      if (n.target && !Fo.touch && Fo.gesture)
        return "gesture";
      if (Fo.touch && r)
        return "touch";
      if (Fo.touchscreen) {
        if (Fo.pointer)
          return "pointer";
        if (Fo.touch)
          return "touch";
      }
    },
    bounds(t, e, { scaleBounds: n = {}, angleBounds: r = {} }) {
      const i = (o) => {
        const a = S8(Tk(n, o), {
          min: -1 / 0,
          max: 1 / 0
        });
        return [
          a.min,
          a.max
        ];
      }, s = (o) => {
        const a = S8(Tk(r, o), {
          min: -1 / 0,
          max: 1 / 0
        });
        return [
          a.min,
          a.max
        ];
      };
      return typeof n != "function" && typeof r != "function" ? [
        i(),
        s()
      ] : (o) => [
        i(o),
        s(o)
      ];
    },
    threshold(t, e, n) {
      return this.lockDirection = n.axis === "lock", Xr.toVector(t, this.lockDirection ? [
        0.1,
        3
      ] : 0);
    },
    modifierKey(t) {
      return t === void 0 ? "ctrlKey" : t;
    },
    pinchOnWheel(t = true) {
      return t;
    }
  });
  Rn(Rn({}, eS), {}, {
    mouseOnly: (t = true) => t
  });
  class _Pe extends uPe {
    constructor(...e) {
      super(...e), li(this, "ingKey", "wheeling");
    }
    wheel(e) {
      this.state._active || this.start(e), this.wheelChange(e), this.timeoutStore.add("wheelEnd", this.wheelEnd.bind(this));
    }
    wheelChange(e) {
      const n = this.state;
      n._delta = PG(e), Xr.addTo(n._movement, n._delta), EG(n), this.compute(e), this.emit();
    }
    wheelEnd() {
      this.state._active && (this.state._active = false, this.compute(), this.emit());
    }
    bind(e) {
      e("wheel", "", this.wheel.bind(this));
    }
  }
  const TPe = eS;
  Rn(Rn({}, eS), {}, {
    mouseOnly: (t = true) => t
  });
  const S5 = /* @__PURE__ */ new Map(), iR = /* @__PURE__ */ new Map();
  function EPe(t) {
    S5.set(t.key, t.engine), iR.set(t.key, t.resolver);
  }
  const IPe = {
    key: "pinch",
    engine: PPe,
    resolver: CPe
  }, $Pe = {
    key: "wheel",
    engine: _Pe,
    resolver: TPe
  };
  function APe(t, e) {
    if (t == null)
      return {};
    var n = {}, r = Object.keys(t), i, s;
    for (s = 0; s < r.length; s++)
      i = r[s], !(e.indexOf(i) >= 0) && (n[i] = t[i]);
    return n;
  }
  function RPe(t, e) {
    if (t == null)
      return {};
    var n = APe(t, e), r, i;
    if (Object.getOwnPropertySymbols) {
      var s = Object.getOwnPropertySymbols(t);
      for (i = 0; i < s.length; i++)
        r = s[i], !(e.indexOf(r) >= 0) && Object.prototype.propertyIsEnumerable.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }
  const MPe = {
    target(t) {
      if (t)
        return () => "current" in t ? t.current : t;
    },
    enabled(t = true) {
      return t;
    },
    window(t = Fo.isBrowser ? window : void 0) {
      return t;
    },
    eventOptions({ passive: t = true, capture: e = false } = {}) {
      return {
        passive: t,
        capture: e
      };
    },
    transform(t) {
      return t;
    }
  }, DPe = [
    "target",
    "eventOptions",
    "window",
    "enabled",
    "transform"
  ];
  function Hx(t = {}, e) {
    const n = {};
    for (const [r, i] of Object.entries(e))
      switch (typeof i) {
        case "function":
          n[r] = i.call(n, t[r], r, t);
          break;
        case "object":
          n[r] = Hx(t[r], i);
          break;
        case "boolean":
          i && (n[r] = t[r]);
          break;
      }
    return n;
  }
  function LPe(t, e, n = {}) {
    const r = t, { target: i, eventOptions: s, window: o, enabled: a, transform: l } = r, c = RPe(r, DPe);
    if (n.shared = Hx({
      target: i,
      eventOptions: s,
      window: o,
      enabled: a,
      transform: l
    }, MPe), e) {
      const u = iR.get(e);
      n[e] = Hx(Rn({
        shared: n.shared
      }, c), u);
    } else
      for (const u in c) {
        const d = iR.get(u);
        d && (n[u] = Hx(Rn({
          shared: n.shared
        }, c[u]), d));
      }
    return n;
  }
  class IG {
    constructor(e, n) {
      li(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = e, this._gestureKey = n;
    }
    add(e, n, r, i, s) {
      const o = this._listeners, a = tPe(n, r), l = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, c = Rn(Rn({}, l), s);
      e.addEventListener(a, i, c);
      const u = () => {
        e.removeEventListener(a, i, c), o.delete(u);
      };
      return o.add(u), u;
    }
    clean() {
      this._listeners.forEach((e) => e()), this._listeners.clear();
    }
  }
  class jPe {
    constructor() {
      li(this, "_timeouts", /* @__PURE__ */ new Map());
    }
    add(e, n, r = 140, ...i) {
      this.remove(e), this._timeouts.set(e, window.setTimeout(n, r, ...i));
    }
    remove(e) {
      const n = this._timeouts.get(e);
      n && window.clearTimeout(n);
    }
    clean() {
      this._timeouts.forEach((e) => void window.clearTimeout(e)), this._timeouts.clear();
    }
  }
  class NPe {
    constructor(e) {
      li(this, "gestures", /* @__PURE__ */ new Set()), li(this, "_targetEventStore", new IG(this)), li(this, "gestureEventStores", {}), li(this, "gestureTimeoutStores", {}), li(this, "handlers", {}), li(this, "config", {}), li(this, "pointerIds", /* @__PURE__ */ new Set()), li(this, "touchIds", /* @__PURE__ */ new Set()), li(this, "state", {
        shared: {
          shiftKey: false,
          metaKey: false,
          ctrlKey: false,
          altKey: false
        }
      }), QPe(this, e);
    }
    setEventIds(e) {
      if (kG(e))
        return this.touchIds = new Set(iPe(e)), this.touchIds;
      if ("pointerId" in e)
        return e.type === "pointerup" || e.type === "pointercancel" ? this.pointerIds.delete(e.pointerId) : e.type === "pointerdown" && this.pointerIds.add(e.pointerId), this.pointerIds;
    }
    applyHandlers(e, n) {
      this.handlers = e, this.nativeHandlers = n;
    }
    applyConfig(e, n) {
      this.config = LPe(e, n, this.config);
    }
    clean() {
      this._targetEventStore.clean();
      for (const e of this.gestures)
        this.gestureEventStores[e].clean(), this.gestureTimeoutStores[e].clean();
    }
    effect() {
      return this.config.shared.target && this.bind(), () => this._targetEventStore.clean();
    }
    bind(...e) {
      const n = this.config.shared, r = {};
      let i;
      if (!(n.target && (i = n.target(), !i))) {
        if (n.enabled) {
          for (const o of this.gestures) {
            const a = this.config[o], l = b8(r, a.eventOptions, !!i);
            if (a.enabled) {
              const c = S5.get(o);
              new c(this, e, o).bind(l);
            }
          }
          const s = b8(r, n.eventOptions, !!i);
          for (const o in this.nativeHandlers)
            s(o, "", (a) => this.nativeHandlers[o](Rn(Rn({}, this.state.shared), {}, {
              event: a,
              args: e
            })), void 0, true);
        }
        for (const s in r)
          r[s] = aPe(...r[s]);
        if (!i)
          return r;
        for (const s in r) {
          const { device: o, capture: a, passive: l } = ePe(s);
          this._targetEventStore.add(i, o, "", r[s], {
            capture: a,
            passive: l
          });
        }
      }
    }
  }
  function pp(t, e) {
    t.gestures.add(e), t.gestureEventStores[e] = new IG(t, e), t.gestureTimeoutStores[e] = new jPe();
  }
  function QPe(t, e) {
    e.drag && pp(t, "drag"), e.wheel && pp(t, "wheel"), e.scroll && pp(t, "scroll"), e.move && pp(t, "move"), e.pinch && pp(t, "pinch"), e.hover && pp(t, "hover");
  }
  const b8 = (t, e, n) => (r, i, s, o = {}, a = false) => {
    var l, c;
    const u = (l = o.capture) !== null && l !== void 0 ? l : e.capture, d = (c = o.passive) !== null && c !== void 0 ? c : e.passive;
    let h = a ? r : Kke(r, i, u);
    n && d && (h += "Passive"), t[h] = t[h] || [], t[h].push(s);
  }, zPe = /^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;
  function FPe(t) {
    const e = {}, n = {}, r = /* @__PURE__ */ new Set();
    for (let i in t)
      zPe.test(i) ? (r.add(RegExp.lastMatch), n[i] = t[i]) : e[i] = t[i];
    return [
      n,
      e,
      r
    ];
  }
  function gp(t, e, n, r, i, s) {
    if (!t.has(n) || !S5.has(r))
      return;
    const o = n + "Start", a = n + "End", l = (c) => {
      let u;
      return c.first && o in e && e[o](c), n in e && (u = e[n](c)), c.last && a in e && e[a](c), u;
    };
    i[r] = l, s[r] = s[r] || {};
  }
  function BPe(t, e) {
    const [n, r, i] = FPe(t), s = {};
    return gp(i, n, "onDrag", "drag", s, e), gp(i, n, "onWheel", "wheel", s, e), gp(i, n, "onScroll", "scroll", s, e), gp(i, n, "onPinch", "pinch", s, e), gp(i, n, "onMove", "move", s, e), gp(i, n, "onHover", "hover", s, e), {
      handlers: s,
      config: e,
      nativeHandlers: r
    };
  }
  function UPe(t, e = {}, n, r) {
    const i = $e.useMemo(() => new NPe(t), []);
    if (i.applyHandlers(t, r), i.applyConfig(e, n), $e.useEffect(i.effect.bind(i)), $e.useEffect(() => i.clean.bind(i), []), e.target === void 0)
      return i.bind.bind(i);
  }
  function VPe(t) {
    return t.forEach(EPe), function(n, r) {
      const { handlers: i, nativeHandlers: s, config: o } = BPe(n, r || {});
      return UPe(i, o, void 0, s);
    };
  }
  const k8 = 10, XPe = /Mac|iPod|iPhone|iPad/.test(typeof window > "u" ? "node" : window.navigator.platform);
  function $G(t) {
    let { deltaY: e, deltaX: n } = t, r = 0;
    if (t.ctrlKey || t.altKey || t.metaKey) {
      const i = Math.sign(t.deltaY), s = Math.abs(t.deltaY);
      let o = e;
      s > k8 && (o = k8 * i), r = o / 100;
    } else
      t.shiftKey && !XPe && (n = e, e = 0);
    return {
      x: -n,
      y: -e,
      z: -r
    };
  }
  const WPe = VPe([
    $Pe,
    IPe
  ]);
  let mp;
  const ZPe = (t) => mp === void 0 ? (mp = t, false) : t - mp > 120 && t - mp < 160 ? (mp = t, true) : (mp = t, false);
  function HPe(t) {
    const e = ue(), n = b.useMemo(() => {
      let r = "not sure";
      const i = ({ event: g }) => {
        var _a3;
        if (!e.instanceState.isFocused || (r = "not sure", ZPe(Date.now())))
          return;
        if (e.editingShapeId) {
          const w = e.getShape(e.editingShapeId);
          if (w && e.getShapeUtil(w).canScroll(w) && ((_a3 = e.getShapePageBounds(e.editingShapeId)) == null ? void 0 : _a3.containsPoint(e.inputs.currentPagePoint)))
            return;
        }
        Rt(g);
        const O = $G(g);
        if (O.x === 0 && O.y === 0)
          return;
        const S = {
          type: "wheel",
          name: "wheel",
          delta: O,
          shiftKey: g.shiftKey,
          altKey: g.altKey,
          ctrlKey: g.metaKey || g.ctrlKey
        };
        e.dispatch(S);
      };
      let s = 1, o = 1, a = 1, l = 0;
      const c = new I(), u = new I(), d = (g) => {
        const O = t.current;
        r = "not sure";
        const { event: S, origin: w, da: x } = g;
        S instanceof WheelEvent || (S.target === O || (O == null ? void 0 : O.contains(S.target))) && (u.x = w[0], u.y = w[1], c.x = w[0], c.y = w[1], s = x[0], o = e.zoomLevel, e.dispatch({
          type: "pinch",
          name: "pinch_start",
          point: {
            x: w[0],
            y: w[1],
            z: e.zoomLevel
          },
          delta: {
            x: 0,
            y: 0
          },
          shiftKey: S.shiftKey,
          altKey: S.altKey,
          ctrlKey: S.metaKey || S.ctrlKey
        }));
      }, h = (g) => {
        if (g && (r = "zooming"), r === "zooming")
          return;
        const O = Math.abs(l - s), S = I.Dist(c, u);
        switch (r) {
          case "not sure": {
            O > 24 ? r = "zooming" : S > 16 && (r = "panning");
            break;
          }
          case "panning": {
            O > 64 && (r = "zooming");
            break;
          }
        }
      };
      return {
        onWheel: i,
        onPinchStart: d,
        onPinchEnd: (g) => {
          const O = t.current, { event: S, origin: w, offset: x } = g;
          if (S instanceof WheelEvent || !(S.target === O || (O == null ? void 0 : O.contains(S.target))))
            return;
          const P = x[0];
          r = "not sure", requestAnimationFrame(() => {
            e.dispatch({
              type: "pinch",
              name: "pinch_end",
              point: {
                x: w[0],
                y: w[1],
                z: P
              },
              delta: {
                x: w[0],
                y: w[1]
              },
              shiftKey: S.shiftKey,
              altKey: S.altKey,
              ctrlKey: S.metaKey || S.ctrlKey
            });
          });
        },
        onPinch: (g) => {
          const O = t.current, { event: S, origin: w, offset: x, da: P } = g;
          if (S instanceof WheelEvent || !(S.target === O || (O == null ? void 0 : O.contains(S.target))))
            return;
          const C = g.type === "gesturechange" || g.type === "gestureend";
          l = P[0];
          const _ = w[0] - u.x, T = w[1] - u.y;
          switch (u.x = w[0], u.y = w[1], h(C), r) {
            case "zooming": {
              a = x[0], e.dispatch({
                type: "pinch",
                name: "pinch",
                point: {
                  x: w[0],
                  y: w[1],
                  z: a
                },
                delta: {
                  x: _,
                  y: T
                },
                shiftKey: S.shiftKey,
                altKey: S.altKey,
                ctrlKey: S.metaKey || S.ctrlKey
              });
              break;
            }
            case "panning": {
              e.dispatch({
                type: "pinch",
                name: "pinch",
                point: {
                  x: w[0],
                  y: w[1],
                  z: o
                },
                delta: {
                  x: _,
                  y: T
                },
                shiftKey: S.shiftKey,
                altKey: S.altKey,
                ctrlKey: S.metaKey || S.ctrlKey
              });
              break;
            }
          }
        }
      };
    }, [
      e,
      t
    ]);
    WPe(n, {
      target: t,
      eventOptions: {
        passive: false
      },
      pinch: {
        from: () => [
          e.zoomLevel,
          0
        ],
        scaleBounds: () => ({
          from: e.zoomLevel,
          max: 8,
          min: 0.05
        })
      }
    });
  }
  function kE(t, e, n) {
    const r = t.getShape(e), i = t.getShapeHandles(r);
    return {
      shape: r,
      handle: i.find((s) => s.id === n)
    };
  }
  function YPe(t, e) {
    const n = ue();
    return b.useMemo(() => {
      const r = (l) => {
        if (l.isKilled)
          return;
        const c = bk(l.currentTarget);
        qO(c, l);
        const { shape: u, handle: d } = kE(n, t, e);
        d && n.dispatch({
          type: "pointer",
          target: "handle",
          handle: d,
          shape: u,
          name: "pointer_down",
          ...ps(l)
        });
      };
      let i, s;
      return {
        onPointerDown: r,
        onPointerMove: (l) => {
          if (l.isKilled || l.clientX === i && l.clientY === s)
            return;
          i = l.clientX, s = l.clientY;
          const { shape: c, handle: u } = kE(n, t, e);
          u && n.dispatch({
            type: "pointer",
            target: "handle",
            handle: u,
            shape: c,
            name: "pointer_move",
            ...ps(l)
          });
        },
        onPointerUp: (l) => {
          if (l.isKilled)
            return;
          const c = bk(l.currentTarget);
          KO(c, l);
          const { shape: u, handle: d } = kE(n, t, e);
          d && n.dispatch({
            type: "pointer",
            target: "handle",
            handle: d,
            shape: u,
            name: "pointer_up",
            ...ps(l)
          });
        }
      };
    }, [
      n,
      t,
      e
    ]);
  }
  var AG = "Expected a function", P8 = 0 / 0, GPe = "[object Symbol]", qPe = /^\s+|\s+$/g, KPe = /^[-+]0x[0-9a-f]+$/i, JPe = /^0b[01]+$/i, eCe = /^0o[0-7]+$/i, tCe = parseInt, nCe = typeof Jn == "object" && Jn && Jn.Object === Object && Jn, rCe = typeof self == "object" && self && self.Object === Object && self, iCe = nCe || rCe || Function("return this")(), sCe = Object.prototype, oCe = sCe.toString, aCe = Math.max, lCe = Math.min, PE = function() {
    return iCe.Date.now();
  };
  function cCe(t, e, n) {
    var r, i, s, o, a, l, c = 0, u = false, d = false, h = true;
    if (typeof t != "function")
      throw new TypeError(AG);
    e = C8(e) || 0, Ek(n) && (u = !!n.leading, d = "maxWait" in n, s = d ? aCe(C8(n.maxWait) || 0, e) : s, h = "trailing" in n ? !!n.trailing : h);
    function f(_) {
      var T = r, $ = i;
      return r = i = void 0, c = _, o = t.apply($, T), o;
    }
    function y(_) {
      return c = _, a = setTimeout(S, e), u ? f(_) : o;
    }
    function g(_) {
      var T = _ - l, $ = _ - c, N = e - T;
      return d ? lCe(N, s - $) : N;
    }
    function O(_) {
      var T = _ - l, $ = _ - c;
      return l === void 0 || T >= e || T < 0 || d && $ >= s;
    }
    function S() {
      var _ = PE();
      if (O(_))
        return w(_);
      a = setTimeout(S, g(_));
    }
    function w(_) {
      return a = void 0, h && r ? f(_) : (r = i = void 0, o);
    }
    function x() {
      a !== void 0 && clearTimeout(a), c = 0, r = l = i = a = void 0;
    }
    function P() {
      return a === void 0 ? o : w(PE());
    }
    function C() {
      var _ = PE(), T = O(_);
      if (r = arguments, i = this, l = _, T) {
        if (a === void 0)
          return y(l);
        if (d)
          return a = setTimeout(S, e), f(l);
      }
      return a === void 0 && (a = setTimeout(S, e)), o;
    }
    return C.cancel = x, C.flush = P, C;
  }
  function uCe(t, e, n) {
    var r = true, i = true;
    if (typeof t != "function")
      throw new TypeError(AG);
    return Ek(n) && (r = "leading" in n ? !!n.leading : r, i = "trailing" in n ? !!n.trailing : i), cCe(t, e, {
      leading: r,
      maxWait: e,
      trailing: i
    });
  }
  function Ek(t) {
    var e = typeof t;
    return !!t && (e == "object" || e == "function");
  }
  function dCe(t) {
    return !!t && typeof t == "object";
  }
  function hCe(t) {
    return typeof t == "symbol" || dCe(t) && oCe.call(t) == GPe;
  }
  function C8(t) {
    if (typeof t == "number")
      return t;
    if (hCe(t))
      return P8;
    if (Ek(t)) {
      var e = typeof t.valueOf == "function" ? t.valueOf() : t;
      t = Ek(e) ? e + "" : e;
    }
    if (typeof t != "string")
      return t === 0 ? t : +t;
    t = t.replace(qPe, "");
    var n = JPe.test(t);
    return n || eCe.test(t) ? tCe(t.slice(2), n ? 2 : 8) : KPe.test(t) ? P8 : +t;
  }
  var fCe = uCe;
  const pCe = Rd(fCe);
  function gCe() {
    const t = ue();
    b.useLayoutEffect(() => {
      const e = pCe(() => {
        t.updateViewportScreenBounds();
      }, 200, {
        trailing: true
      });
      t.updateViewportScreenBounds();
      const n = setInterval(e, 1e3);
      return window.addEventListener("resize", e), window.addEventListener("scroll", e), () => {
        clearInterval(n), window.removeEventListener("resize", e), window.removeEventListener("scroll", e);
      };
    }, [
      t
    ]);
  }
  const _Se2 = class _Se2 {
    constructor(e, n, r, i, s, o) {
      __publicField(this, "a", 1);
      __publicField(this, "b", 0);
      __publicField(this, "c", 0);
      __publicField(this, "d", 1);
      __publicField(this, "e", 0);
      __publicField(this, "f", 0);
      this.a = e, this.b = n, this.c = r, this.d = i, this.e = s, this.f = o;
    }
    equals(e) {
      return this.a === e.a && this.b === e.b && this.c === e.c && this.d === e.d && this.e === e.e && this.f === e.f;
    }
    identity() {
      return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.e = 0, this.f = 0, this;
    }
    multiply(e) {
      const n = e, { a: r, b: i, c: s, d: o, e: a, f: l } = this;
      return this.a = r * n.a + s * n.b, this.c = r * n.c + s * n.d, this.e = r * n.e + s * n.f + a, this.b = i * n.a + o * n.b, this.d = i * n.c + o * n.d, this.f = i * n.e + o * n.f + l, this;
    }
    rotate(e, n, r) {
      return e === 0 ? this : n === void 0 ? this.multiply(_Se2.Rotate(e)) : this.translate(n, r).multiply(_Se2.Rotate(e)).translate(-n, -r);
    }
    translate(e, n) {
      return this.multiply(_Se2.Translate(e, n));
    }
    scale(e, n) {
      return this.multiply(_Se2.Scale(e, n));
    }
    invert() {
      const { a: e, b: n, c: r, d: i, e: s, f: o } = this, a = e * i - n * r;
      return this.a = i / a, this.b = n / -a, this.c = r / -a, this.d = e / a, this.e = (i * s - r * o) / -a, this.f = (n * s - e * o) / a, this;
    }
    applyToPoint(e) {
      return _Se2.applyToPoint(this, e);
    }
    applyToPoints(e) {
      return _Se2.applyToPoints(this, e);
    }
    rotation() {
      return _Se2.Rotation(this);
    }
    point() {
      return _Se2.Point(this);
    }
    decomposed() {
      return _Se2.Decompose(this);
    }
    toCssString() {
      return _Se2.toCssString(this);
    }
    setTo(e) {
      return Object.assign(this, e), this;
    }
    decompose() {
      return _Se2.Decompose(this);
    }
    clone() {
      return new _Se2(this.a, this.b, this.c, this.d, this.e, this.f);
    }
    static Identity() {
      return new _Se2(1, 0, 0, 1, 0, 0);
    }
    static Translate(e, n) {
      return new _Se2(1, 0, 0, 1, e, n);
    }
    static Rotate(e, n, r) {
      if (e === 0)
        return _Se2.Identity();
      const i = Math.cos(e), s = Math.sin(e), o = new _Se2(i, s, -s, i, 0, 0);
      return n === void 0 ? o : _Se2.Compose(_Se2.Translate(n, r), o, _Se2.Translate(-n, -r));
    }
    static Multiply(e, n) {
      return {
        a: e.a * n.a + e.c * n.b,
        c: e.a * n.c + e.c * n.d,
        e: e.a * n.e + e.c * n.f + e.e,
        b: e.b * n.a + e.d * n.b,
        d: e.b * n.c + e.d * n.d,
        f: e.b * n.e + e.d * n.f + e.f
      };
    }
    static Inverse(e) {
      const n = e.a * e.d - e.b * e.c;
      return {
        a: e.d / n,
        b: e.b / -n,
        c: e.c / -n,
        d: e.a / n,
        e: (e.d * e.e - e.c * e.f) / -n,
        f: (e.b * e.e - e.a * e.f) / n
      };
    }
    static Absolute(e) {
      const n = e.a * e.d - e.b * e.c;
      return {
        a: e.d / n,
        b: e.b / -n,
        c: e.c / -n,
        d: e.a / n,
        e: (e.d * e.e - e.c * e.f) / n,
        f: (e.b * e.e - e.a * e.f) / -n
      };
    }
    static Compose(...e) {
      const n = _Se2.Identity();
      for (let r = 0, i = e.length; r < i; r++)
        n.multiply(e[r]);
      return n;
    }
    static Point(e) {
      return new I(e.e, e.f);
    }
    static Rotation(e) {
      let n;
      if (e.a !== 0 || e.c !== 0) {
        const r = Math.hypot(e.a, e.c);
        n = Math.acos(e.a / r) * (e.c > 0 ? -1 : 1);
      } else if (e.b !== 0 || e.d !== 0) {
        const r = Math.hypot(e.b, e.d);
        n = Ft + Math.acos(e.b / r) * (e.d > 0 ? -1 : 1);
      } else
        n = 0;
      return tR(n);
    }
    static Decompose(e) {
      let n, r, i;
      if (e.a !== 0 || e.c !== 0) {
        const s = Math.hypot(e.a, e.c);
        n = s, r = (e.a * e.d - e.b * e.c) / s, i = Math.acos(e.a / s) * (e.c > 0 ? -1 : 1);
      } else if (e.b !== 0 || e.d !== 0) {
        const s = Math.hypot(e.b, e.d);
        n = (e.a * e.d - e.b * e.c) / s, r = s, i = Ft + Math.acos(e.b / s) * (e.d > 0 ? -1 : 1);
      } else
        n = 0, r = 0, i = 0;
      return {
        x: e.e,
        y: e.f,
        scaleX: n,
        scaleY: r,
        rotation: tR(i)
      };
    }
    static Smooth(e, n = 1e10) {
      return e.a = Math.round(e.a * n) / n, e.b = Math.round(e.b * n) / n, e.c = Math.round(e.c * n) / n, e.d = Math.round(e.d * n) / n, e.e = Math.round(e.e * n) / n, e.f = Math.round(e.f * n) / n, e;
    }
    static toCssString(e) {
      return `matrix(${Y(e.a)}, ${Y(e.b)}, ${Y(e.c)}, ${Y(e.d)}, ${Y(e.e)}, ${Y(e.f)})`;
    }
    static applyToPoint(e, n) {
      return new I(e.a * n.x + e.c * n.y + e.e, e.b * n.x + e.d * n.y + e.f, n.z);
    }
    static applyToXY(e, n, r) {
      return [
        e.a * n + e.c * r + e.e,
        e.b * n + e.d * r + e.f
      ];
    }
    static applyToPoints(e, n) {
      return n.map((r) => new I(e.a * r.x + e.c * r.y + e.e, e.b * r.x + e.d * r.y + e.f, r.z));
    }
    static applyToBounds(e, n) {
      return new Te(e.e + n.minX, e.f + n.minY, n.width, n.height);
    }
    static From(e) {
      return new _Se2(e.a, e.b, e.c, e.d, e.e, e.f);
    }
    static Cast(e) {
      return e instanceof _Se2 ? e : _Se2.From(e);
    }
  };
  __publicField(_Se2, "Scale", (e, n, r, i) => {
    const s = new _Se2(e, 0, 0, 0, n, 0);
    return r === void 0 ? s : _Se2.Compose(_Se2.Translate(r, i), s, _Se2.Translate(-r, -i));
  });
  let Se = _Se2;
  function mCe(t = true) {
    const [e, n] = b.useState(0), r = ue();
    b.useEffect(() => {
      if (!t)
        return;
      const i = () => n((s) => s + 1);
      return r.on("tick", i), () => {
        r.off("tick", i);
      };
    }, [
      r,
      t
    ]);
  }
  const yCe = Vt(function({ showStroke: e = true, showVertices: n = true, showClosestPointOnOutline: r = true }) {
    const i = ue();
    mCe(r);
    const { zoomLevel: s, renderingShapes: o, inputs: { currentPagePoint: a } } = i;
    return m.jsx("svg", {
      style: {
        position: "absolute",
        pointerEvents: "none",
        zIndex: 999999999,
        top: 0,
        left: 0,
        overflow: "visible"
      },
      children: o.map((l) => {
        const c = i.getShape(l.id);
        if (c.type === "group")
          return null;
        const u = i.getShapeGeometry(c), d = i.getShapePageTransform(c), h = i.getPointInShapeSpace(c, a), f = u.nearestPoint(h), y = u.distanceToPoint(h, true), g = Math.abs(y) * s, O = y < 0, { vertices: S } = u;
        return m.jsxs("g", {
          transform: d.toCssString(),
          strokeLinecap: "round",
          strokeLinejoin: "round",
          children: [
            e && m.jsx("path", {
              stroke: "red",
              strokeWidth: "2",
              fill: "none",
              opacity: "1",
              d: u.toSimpleSvgPath()
            }),
            n && S.map((w, x) => m.jsx("circle", {
              cx: w.x,
              cy: w.y,
              r: "2",
              fill: `hsl(${fk(x, [
                0,
                S.length - 1
              ], [
                120,
                200
              ])}, 100%, 50%)`,
              stroke: "black",
              strokeWidth: "1"
            }, `v${x}`)),
            r && g < 150 && m.jsx("line", {
              x1: f.x,
              y1: f.y,
              x2: h.x,
              y2: h.y,
              opacity: 1 - g / 150,
              stroke: O ? "goldenrod" : "dodgerblue",
              strokeWidth: "2"
            })
          ]
        }, l.id + "_outline");
      })
    });
  });
  var vCe = 200, w5 = "__lodash_hash_undefined__", OCe = 1 / 0, SCe = "[object Function]", wCe = "[object GeneratorFunction]", xCe = /[\\^$.*+?()[\]{}|]/g, bCe = /^\[object .+?Constructor\]$/, kCe = typeof Jn == "object" && Jn && Jn.Object === Object && Jn, PCe = typeof self == "object" && self && self.Object === Object && self, x5 = kCe || PCe || Function("return this")();
  function CCe(t, e) {
    var n = t ? t.length : 0;
    return !!n && ECe(t, e, 0) > -1;
  }
  function _Ce(t, e, n) {
    for (var r = -1, i = t ? t.length : 0; ++r < i; )
      if (n(e, t[r]))
        return true;
    return false;
  }
  function TCe(t, e, n, r) {
    for (var i = t.length, s = n + (r ? 1 : -1); r ? s-- : ++s < i; )
      if (e(t[s], s, t))
        return s;
    return -1;
  }
  function ECe(t, e, n) {
    if (e !== e)
      return TCe(t, ICe, n);
    for (var r = n - 1, i = t.length; ++r < i; )
      if (t[r] === e)
        return r;
    return -1;
  }
  function ICe(t) {
    return t !== t;
  }
  function $Ce(t, e) {
    return t.has(e);
  }
  function ACe(t, e) {
    return t == null ? void 0 : t[e];
  }
  function RCe(t) {
    var e = false;
    if (t != null && typeof t.toString != "function")
      try {
        e = !!(t + "");
      } catch {
      }
    return e;
  }
  function RG(t) {
    var e = -1, n = Array(t.size);
    return t.forEach(function(r) {
      n[++e] = r;
    }), n;
  }
  var MCe = Array.prototype, DCe = Function.prototype, MG = Object.prototype, CE = x5["__core-js_shared__"], _8 = function() {
    var t = /[^.]+$/.exec(CE && CE.keys && CE.keys.IE_PROTO || "");
    return t ? "Symbol(src)_1." + t : "";
  }(), DG = DCe.toString, b5 = MG.hasOwnProperty, LCe = MG.toString, jCe = RegExp("^" + DG.call(b5).replace(xCe, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), NCe = MCe.splice, QCe = k5(x5, "Map"), _E = k5(x5, "Set"), Hv = k5(Object, "create");
  function of(t) {
    var e = -1, n = t ? t.length : 0;
    for (this.clear(); ++e < n; ) {
      var r = t[e];
      this.set(r[0], r[1]);
    }
  }
  function zCe() {
    this.__data__ = Hv ? Hv(null) : {};
  }
  function FCe(t) {
    return this.has(t) && delete this.__data__[t];
  }
  function BCe(t) {
    var e = this.__data__;
    if (Hv) {
      var n = e[t];
      return n === w5 ? void 0 : n;
    }
    return b5.call(e, t) ? e[t] : void 0;
  }
  function UCe(t) {
    var e = this.__data__;
    return Hv ? e[t] !== void 0 : b5.call(e, t);
  }
  function VCe(t, e) {
    var n = this.__data__;
    return n[t] = Hv && e === void 0 ? w5 : e, this;
  }
  of.prototype.clear = zCe;
  of.prototype.delete = FCe;
  of.prototype.get = BCe;
  of.prototype.has = UCe;
  of.prototype.set = VCe;
  function km(t) {
    var e = -1, n = t ? t.length : 0;
    for (this.clear(); ++e < n; ) {
      var r = t[e];
      this.set(r[0], r[1]);
    }
  }
  function XCe() {
    this.__data__ = [];
  }
  function WCe(t) {
    var e = this.__data__, n = TC(e, t);
    if (n < 0)
      return false;
    var r = e.length - 1;
    return n == r ? e.pop() : NCe.call(e, n, 1), true;
  }
  function ZCe(t) {
    var e = this.__data__, n = TC(e, t);
    return n < 0 ? void 0 : e[n][1];
  }
  function HCe(t) {
    return TC(this.__data__, t) > -1;
  }
  function YCe(t, e) {
    var n = this.__data__, r = TC(n, t);
    return r < 0 ? n.push([
      t,
      e
    ]) : n[r][1] = e, this;
  }
  km.prototype.clear = XCe;
  km.prototype.delete = WCe;
  km.prototype.get = ZCe;
  km.prototype.has = HCe;
  km.prototype.set = YCe;
  function Pm(t) {
    var e = -1, n = t ? t.length : 0;
    for (this.clear(); ++e < n; ) {
      var r = t[e];
      this.set(r[0], r[1]);
    }
  }
  function GCe() {
    this.__data__ = {
      hash: new of(),
      map: new (QCe || km)(),
      string: new of()
    };
  }
  function qCe(t) {
    return EC(this, t).delete(t);
  }
  function KCe(t) {
    return EC(this, t).get(t);
  }
  function JCe(t) {
    return EC(this, t).has(t);
  }
  function e2e(t, e) {
    return EC(this, t).set(t, e), this;
  }
  Pm.prototype.clear = GCe;
  Pm.prototype.delete = qCe;
  Pm.prototype.get = KCe;
  Pm.prototype.has = JCe;
  Pm.prototype.set = e2e;
  function Ik(t) {
    var e = -1, n = t ? t.length : 0;
    for (this.__data__ = new Pm(); ++e < n; )
      this.add(t[e]);
  }
  function t2e(t) {
    return this.__data__.set(t, w5), this;
  }
  function n2e(t) {
    return this.__data__.has(t);
  }
  Ik.prototype.add = Ik.prototype.push = t2e;
  Ik.prototype.has = n2e;
  function TC(t, e) {
    for (var n = t.length; n--; )
      if (u2e(t[n][0], e))
        return n;
    return -1;
  }
  function r2e(t) {
    if (!LG(t) || a2e(t))
      return false;
    var e = d2e(t) || RCe(t) ? jCe : bCe;
    return e.test(l2e(t));
  }
  function i2e(t, e, n) {
    var r = -1, i = CCe, s = t.length, o = true, a = [], l = a;
    if (n)
      o = false, i = _Ce;
    else if (s >= vCe) {
      var c = e ? null : s2e(t);
      if (c)
        return RG(c);
      o = false, i = $Ce, l = new Ik();
    } else
      l = e ? [] : a;
    e:
      for (; ++r < s; ) {
        var u = t[r], d = e ? e(u) : u;
        if (u = n || u !== 0 ? u : 0, o && d === d) {
          for (var h = l.length; h--; )
            if (l[h] === d)
              continue e;
          e && l.push(d), a.push(u);
        } else
          i(l, d, n) || (l !== a && l.push(d), a.push(u));
      }
    return a;
  }
  var s2e = _E && 1 / RG(new _E([
    ,
    -0
  ]))[1] == OCe ? function(t) {
    return new _E(t);
  } : h2e;
  function EC(t, e) {
    var n = t.__data__;
    return o2e(e) ? n[typeof e == "string" ? "string" : "hash"] : n.map;
  }
  function k5(t, e) {
    var n = ACe(t, e);
    return r2e(n) ? n : void 0;
  }
  function o2e(t) {
    var e = typeof t;
    return e == "string" || e == "number" || e == "symbol" || e == "boolean" ? t !== "__proto__" : t === null;
  }
  function a2e(t) {
    return !!_8 && _8 in t;
  }
  function l2e(t) {
    if (t != null) {
      try {
        return DG.call(t);
      } catch {
      }
      try {
        return t + "";
      } catch {
      }
    }
    return "";
  }
  function c2e(t) {
    return t && t.length ? i2e(t) : [];
  }
  function u2e(t, e) {
    return t === e || t !== t && e !== e;
  }
  function d2e(t) {
    var e = LG(t) ? LCe.call(t) : "";
    return e == SCe || e == wCe;
  }
  function LG(t) {
    var e = typeof t;
    return !!t && (e == "object" || e == "function");
  }
  function h2e() {
  }
  var f2e = c2e;
  const p2e = Rd(f2e);
  function jG(t) {
    return p2e(t);
  }
  function g2e() {
    const t = ue(), e = b.useMemo(() => t.store.query.records("instance_presence", () => ({
      userId: {
        neq: t.user.id
      }
    })), [
      t
    ]), n = KY("userIds", () => jG(e.value.map((r) => r.userId)).sort(), {
      isEqual: (r, i) => {
        var _a3;
        return r.join(",") === ((_a3 = i.join) == null ? void 0 : _a3.call(i, ","));
      }
    }, [
      e
    ]);
    return ye(n);
  }
  function NG(t) {
    const e = ue(), n = b.useMemo(() => e.store.query.records("instance_presence", () => ({
      userId: {
        eq: t
      }
    })), [
      e,
      t
    ]);
    return ye(`latestPresence:${t}`, () => n.value.slice().sort((i, s) => s.lastActivityTimestamp - i.lastActivityTimestamp)[0], []) ?? null;
  }
  const m2e = Vt(function() {
    const e = g2e();
    return m.jsx(m.Fragment, {
      children: e.map((n) => m.jsx(y2e, {
        collaboratorId: n
      }, n))
    });
  }), y2e = Vt(function({ collaboratorId: e }) {
    const n = ue(), r = NG(e), i = O2e(r);
    if (!(r && r.currentPageId === n.currentPageId))
      return null;
    switch (i) {
      case "inactive": {
        const { followingUserId: s, highlightedUserIds: o } = n.instanceState;
        if (!(s === r.userId || o.includes(r.userId)))
          return null;
        break;
      }
      case "idle": {
        const { highlightedUserIds: s } = n.instanceState;
        if (r.followingUserId === n.user.id && !(r.chatMessage || s.includes(r.userId)))
          return null;
        break;
      }
    }
    return m.jsx(v2e, {
      latestPresence: r
    });
  }), v2e = Vt(function({ latestPresence: e }) {
    const n = ue(), { CollaboratorBrush: r, CollaboratorScribble: i, CollaboratorCursor: s, CollaboratorHint: o, CollaboratorShapeIndicator: a } = _i(), { viewportPageBounds: l, zoomLevel: c } = n, { userId: u, chatMessage: d, brush: h, scribble: f, selectedShapeIds: y, userName: g, cursor: O, color: S } = e, w = !(O.x < l.minX - 12 / c || O.y < l.minY - 16 / c || O.x > l.maxX - 12 / c || O.y > l.maxY - 16 / c);
    return m.jsxs(m.Fragment, {
      children: [
        h && r ? m.jsx(r, {
          className: "tl-collaborator__brush",
          brush: h,
          color: S,
          opacity: 0.1
        }, u + "_brush") : null,
        w && s ? m.jsx(s, {
          className: "tl-collaborator__cursor",
          point: O,
          color: S,
          zoom: c,
          name: g !== "New User" ? g : null,
          chatMessage: d
        }, u + "_cursor") : o ? m.jsx(o, {
          className: "tl-collaborator__cursor-hint",
          point: O,
          color: S,
          zoom: c,
          viewport: l
        }, u + "_cursor_hint") : null,
        f && i ? m.jsx(i, {
          className: "tl-collaborator__scribble",
          scribble: f,
          color: S,
          zoom: c,
          opacity: f.color === "laser" ? 0.5 : 0.1
        }, u + "_scribble") : null,
        a && y.map((x) => m.jsx(a, {
          className: "tl-collaborator__shape-indicator",
          id: x,
          color: S,
          opacity: 0.5
        }, u + "_" + x))
      ]
    });
  });
  function T8(t) {
    return t > _ke ? "inactive" : t > SG ? "idle" : "active";
  }
  function O2e(t) {
    const e = b.useRef((t == null ? void 0 : t.lastActivityTimestamp) ?? -1), [n, r] = b.useState(() => T8(Date.now() - e.current));
    return b.useEffect(() => {
      const i = setInterval(() => {
        r(T8(Date.now() - e.current));
      }, Tke);
      return () => clearInterval(i);
    }, []), t && (e.current = t.lastActivityTimestamp), n;
  }
  function QG(t, e) {
    return e === 0 ? t : QG(e, t % e);
  }
  function zG(t) {
    const e = t.toString().split(".")[1];
    if (!e)
      return 1;
    const n = Math.pow(10, e.length), r = parseInt(e, 10);
    return n / QG(r, n);
  }
  function S2e() {
    const t = ue(), e = Kr();
    b.useEffect(() => wm("useDPRMultiple", () => {
      const n = t.instanceState.devicePixelRatio;
      e.style.setProperty("--tl-dpr-multiple", zG(n).toString());
    }), [
      t,
      e
    ]);
  }
  const FG = Vt(function({ id: e, shape: n, util: r, index: i, backgroundIndex: s, opacity: o, isCulled: a }) {
    const l = ue(), { ShapeErrorFallback: c } = _i(), u = b.useRef(null), d = b.useRef(null), h = b.useCallback((y, g) => {
      var _a3, _b3;
      (_a3 = u.current) == null ? void 0 : _a3.style.setProperty(y, g), (_b3 = d.current) == null ? void 0 : _b3.style.setProperty(y, g);
    }, []);
    Vh("set shape container transform position", () => {
      if (!l.getShape(e))
        return;
      const g = l.getShapePageTransform(e), O = Se.toCssString(g);
      h("transform", O);
    }, [
      l,
      h
    ]), Vh("set shape container clip path", () => {
      if (!l.getShape(e))
        return null;
      const g = l.getShapeClipPath(e);
      h("clip-path", g ?? "none");
    }, [
      l,
      h
    ]), Vh("set shape height and width", () => {
      const y = l.getShape(e);
      if (!y)
        return null;
      const g = l.getShapeGeometry(y).bounds, O = Math.floor(l.instanceState.devicePixelRatio * 100) / 100, S = zG(O), w = g.w % S, x = w === 0 ? g.w : g.w + (S - w), P = g.h % S, C = P === 0 ? g.h : g.h + (S - P);
      h("width", Math.max(x, S) + "px"), h("height", Math.max(C, S) + "px");
    }, [
      l
    ]), b.useLayoutEffect(() => {
      var _a3, _b3;
      h("opacity", o + ""), (_a3 = u.current) == null ? void 0 : _a3.style.setProperty("z-index", i + ""), (_b3 = d.current) == null ? void 0 : _b3.style.setProperty("z-index", s + "");
    }, [
      o,
      i,
      s,
      h
    ]);
    const f = b.useCallback((y) => {
      l.annotateError(y, {
        origin: "react.shape",
        willCrashApp: false
      });
    }, [
      l
    ]);
    return n ? m.jsxs(m.Fragment, {
      children: [
        r.backgroundComponent && m.jsx("div", {
          ref: d,
          className: "tl-shape tl-shape-background",
          "data-shape-type": n.type,
          draggable: false,
          children: !a && m.jsx(Xv, {
            fallback: c,
            onError: f,
            children: m.jsx(x2e, {
              shape: n,
              util: r
            })
          })
        }),
        m.jsx("div", {
          ref: u,
          className: "tl-shape",
          "data-shape-type": n.type,
          draggable: false,
          children: a ? m.jsx(b2e, {
            shape: n
          }) : m.jsx(Xv, {
            fallback: c,
            onError: f,
            children: m.jsx(w2e, {
              shape: n,
              util: r
            })
          })
        })
      ]
    }) : null;
  }), w2e = b.memo(function({ shape: e, util: n }) {
    return wC("InnerShape:" + e.type, () => n.component(e));
  }, (t, e) => t.shape.props === e.shape.props && t.shape.meta === e.shape.meta), x2e = b.memo(function({ shape: e, util: n }) {
    return wC("InnerShape:" + e.type, () => {
      var _a3;
      return (_a3 = n.backgroundComponent) == null ? void 0 : _a3.call(n, e);
    });
  }, (t, e) => t.shape.props === e.shape.props && t.shape.meta === e.shape.meta), b2e = b.memo(function({ shape: e }) {
    const r = ue().getShapeGeometry(e).bounds;
    return m.jsx("div", {
      className: "tl-shape__culled",
      style: {
        transform: `translate(${Y(r.minX)}px, ${Y(r.minY)}px)`,
        width: Math.max(1, Y(r.width)),
        height: Math.max(1, Y(r.height))
      }
    });
  }, () => true);
  function P5({ className: t }) {
    const e = ue(), { Background: n, SvgDefs: r } = _i(), i = $e.useRef(null), s = $e.useRef(null), o = $e.useRef(null);
    gCe(), Ybe(), Zbe(), HPe(i), Xke(i), Vh("position layers", () => {
      const h = s.current;
      if (!h)
        return;
      const f = o.current;
      if (!f)
        return;
      const { x: y, y: g, z: O } = e.camera, S = O >= 1 ? fk(O, [
        1,
        8
      ], [
        0.125,
        0.5
      ], true) : fk(O, [
        0.1,
        1
      ], [
        -2,
        0.125
      ], true), w = `scale(${Y(O)}) translate(${Y(y + S)}px,${Y(g + S)}px)`;
      h.style.setProperty("transform", w), f.style.setProperty("transform", w);
    }, [
      e
    ]);
    const a = Wbe(), l = ye("shapeSvgDefs", () => {
      const h = /* @__PURE__ */ new Map();
      for (const f of Qn(e.shapeUtils)) {
        if (!f)
          return;
        const y = f.getCanvasSvgDefs();
        for (const { key: g, component: O } of y)
          h.has(g) || h.set(g, m.jsx(O, {}, g));
      }
      return [
        ...h.values()
      ];
    }, [
      e
    ]), c = ye("debug_shapes", () => un.hideShapes.value, [
      un
    ]), u = ye("debug_svg", () => un.debugSvg.value, [
      un
    ]), d = ye("debug_geometry", () => un.debugGeometry.value, [
      un
    ]);
    return m.jsxs("div", {
      ref: i,
      draggable: false,
      className: Ze("tl-canvas", t),
      "data-testid": "canvas",
      ...a,
      children: [
        n && m.jsx(n, {}),
        m.jsx(k2e, {}),
        m.jsx(F2e, {}),
        m.jsx("svg", {
          className: "tl-svg-context",
          children: m.jsxs("defs", {
            children: [
              l,
              E8 && m.jsx(E8, {}),
              m.jsx(j2e, {}),
              m.jsx(N2e, {}),
              m.jsx(Q2e, {}),
              r && m.jsx(r, {})
            ]
          })
        }),
        m.jsxs("div", {
          ref: s,
          className: "tl-html-layer tl-shapes",
          draggable: false,
          children: [
            m.jsx(U2e, {}),
            c ? null : u ? m.jsx(A2e, {}) : m.jsx(R2e, {})
          ]
        }),
        m.jsx("div", {
          className: "tl-fixed-layer tl-overlays",
          children: m.jsxs("div", {
            ref: o,
            className: "tl-html-layer",
            children: [
              d ? m.jsx(yCe, {}) : null,
              m.jsx(I2e, {}),
              m.jsx(C2e, {}),
              m.jsx(P2e, {}),
              m.jsx(_2e, {}),
              m.jsx(M2e, {}),
              m.jsx(D2e, {}),
              m.jsx(L2e, {}),
              m.jsx(T2e, {}),
              m.jsx(B2e, {}),
              m.jsx(m2e, {})
            ]
          })
        })
      ]
    });
  }
  function k2e() {
    const t = ue(), e = ye("gridSize", () => t.documentSettings.gridSize, [
      t
    ]), { x: n, y: r, z: i } = ye("camera", () => t.camera, [
      t
    ]), s = ye("isGridMode", () => t.instanceState.isGridMode, [
      t
    ]), { Grid: o } = _i();
    return o && s ? m.jsx(o, {
      x: n,
      y: r,
      z: i,
      size: e
    }) : null;
  }
  function P2e() {
    const t = ue(), e = ye("scribble", () => t.instanceState.scribble, [
      t
    ]), n = ye("zoomLevel", () => t.zoomLevel, [
      t
    ]), { Scribble: r } = _i();
    return r && e ? m.jsx(r, {
      className: "tl-user-scribble",
      scribble: e,
      zoom: n
    }) : null;
  }
  function C2e() {
    const t = ue(), e = ye("brush", () => t.instanceState.brush, [
      t
    ]), { Brush: n } = _i();
    return n && e ? m.jsx(n, {
      className: "tl-user-brush",
      brush: e
    }) : null;
  }
  function _2e() {
    const t = ue(), e = ye("zoomBrush", () => t.instanceState.zoomBrush, [
      t
    ]), { ZoomBrush: n } = _i();
    return n && e ? m.jsx(n, {
      className: "tl-user-brush",
      brush: e
    }) : null;
  }
  function T2e() {
    const t = ue(), e = ye("snapLines", () => t.snaps.lines, [
      t
    ]), n = ye("zoomLevel", () => t.zoomLevel, [
      t
    ]), { SnapLine: r } = _i();
    return r && e.length > 0 ? m.jsx(m.Fragment, {
      children: e.map((i) => m.jsx(r, {
        className: "tl-user-snapline",
        line: i,
        zoom: n
      }, i.id))
    }) : null;
  }
  const E2e = 48;
  function I2e() {
    const t = ue(), { Handles: e } = _i(), n = ye("zoomLevel", () => t.zoomLevel, [
      t
    ]), r = ye("coarse pointer", () => t.instanceState.isCoarsePointer, [
      t
    ]), i = ye("onlySelectedShape", () => t.onlySelectedShape, [
      t
    ]), s = ye("isChangingStyle", () => t.instanceState.isChangingStyle, [
      t
    ]), o = ye("isChangingStyle", () => t.instanceState.isReadonly, [
      t
    ]), a = ye("handles", () => t.onlySelectedShape ? t.getShapeHandles(t.onlySelectedShape) : void 0, [
      t
    ]), l = ye("transform", () => t.onlySelectedShape ? t.getShapePageTransform(t.onlySelectedShape) : void 0, [
      t
    ]);
    if (!e || !i || s || o || !a || !l)
      return null;
    const c = [];
    for (let u = 0, d = a[u]; u < a.length; u++, d = a[u]) {
      if (d.type !== "vertex") {
        const h = a[u - 1], f = a[u + 1];
        if (h && f && Math.hypot(h.y - f.y, h.x - f.x) < E2e / n)
          continue;
      }
      c.push(d);
    }
    return c.sort((u) => u.type === "vertex" ? 1 : -1), m.jsx(e, {
      children: m.jsx("g", {
        transform: Se.toCssString(l),
        children: c.map((u) => m.jsx($2e, {
          shapeId: i.id,
          handle: u,
          zoom: n,
          isCoarse: r
        }, u.id))
      })
    });
  }
  function $2e({ shapeId: t, handle: e, zoom: n, isCoarse: r }) {
    const i = YPe(t, e.id), { Handle: s } = _i();
    return s ? m.jsx("g", {
      "aria-label": "handle",
      transform: `translate(${e.x}, ${e.y})`,
      ...i,
      children: m.jsx(s, {
        shapeId: t,
        handle: e,
        zoom: n,
        isCoarse: r
      })
    }) : null;
  }
  function A2e() {
    const t = ue(), e = ye("rendering shapes", () => t.renderingShapes, [
      t
    ]);
    return m.jsx(m.Fragment, {
      children: e.map((n) => m.jsxs($e.Fragment, {
        children: [
          m.jsx(FG, {
            ...n
          }),
          m.jsx(z2e, {
            id: n.id
          })
        ]
      }, n.id + "_fragment"))
    });
  }
  function R2e() {
    const t = ue(), e = ye("rendering shapes", () => t.renderingShapes, [
      t
    ]);
    return m.jsx(m.Fragment, {
      children: e.map((n) => m.jsx(FG, {
        ...n
      }, n.id + "_shape"))
    });
  }
  function M2e() {
    const t = ue(), e = ye("selectedShapeIds", () => t.currentPageState.selectedShapeIds, [
      t
    ]);
    return ye("should display selected ids", () => t.isInAny("select.idle", "select.brushing", "select.scribble_brushing", "select.editing_shape", "select.pointing_shape", "select.pointing_selection", "select.pointing_handle") && !t.instanceState.isChangingStyle, [
      t
    ]) ? m.jsx(m.Fragment, {
      children: e.map((r) => m.jsx(JO, {
        className: "tl-user-indicator__selected",
        id: r
      }, r + "_indicator"))
    }) : null;
  }
  const D2e = function() {
    const e = ue(), { HoveredShapeIndicator: n } = _i(), r = ye("coarse pointer", () => e.instanceState.isCoarsePointer, [
      e
    ]), i = ye("hovering canvas", () => e.instanceState.isHoveringCanvas, [
      e
    ]), s = ye("hovered id", () => e.currentPageState.hoveredShapeId, [
      e
    ]);
    return r || !i || !s || !n ? null : m.jsx(n, {
      shapeId: s
    });
  }, L2e = Vt(function() {
    const e = ue(), n = hk(e.hintingShapeIds);
    return n.length ? m.jsx(m.Fragment, {
      children: n.map((r) => m.jsx(JO, {
        className: "tl-user-indicator__hint",
        id: r
      }, r + "_hinting"))
    }) : null;
  });
  function E8() {
    return m.jsxs("g", {
      id: "cursor",
      children: [
        m.jsxs("g", {
          fill: "rgba(0,0,0,.2)",
          transform: "translate(-11,-11)",
          children: [
            m.jsx("path", {
              d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"
            }),
            m.jsx("path", {
              d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"
            })
          ]
        }),
        m.jsxs("g", {
          fill: "white",
          transform: "translate(-12,-12)",
          children: [
            m.jsx("path", {
              d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"
            }),
            m.jsx("path", {
              d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"
            })
          ]
        }),
        m.jsxs("g", {
          fill: "currentColor",
          transform: "translate(-12,-12)",
          children: [
            m.jsx("path", {
              d: "m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"
            }),
            m.jsx("path", {
              d: "m13 10.814v11.188l2.969-2.866.428-.139h4.768z"
            })
          ]
        })
      ]
    });
  }
  function j2e() {
    return m.jsx("path", {
      id: "cursor_hint",
      fill: "currentColor",
      d: "M -2,-5 2,0 -2,5 Z"
    });
  }
  function N2e() {
    return m.jsx("marker", {
      id: "arrowhead-dot",
      className: "tl-arrow-hint",
      refX: "3.0",
      refY: "3.0",
      orient: "0",
      children: m.jsx("circle", {
        cx: "3",
        cy: "3",
        r: "2",
        strokeDasharray: "100%"
      })
    });
  }
  function Q2e() {
    return m.jsxs("marker", {
      id: "arrowhead-cross",
      className: "tl-arrow-hint",
      refX: "3.0",
      refY: "3.0",
      orient: "auto",
      children: [
        m.jsx("line", {
          x1: "1.5",
          y1: "1.5",
          x2: "4.5",
          y2: "4.5",
          strokeDasharray: "100%"
        }),
        m.jsx("line", {
          x1: "1.5",
          y1: "4.5",
          x2: "4.5",
          y2: "1.5",
          strokeDasharray: "100%"
        })
      ]
    });
  }
  const z2e = Vt(function({ id: e }) {
    const n = ue(), r = n.getShape(e), [i, s] = $e.useState(""), o = (r == null ? void 0 : r.parentId) === n.currentPageId;
    return $e.useEffect(() => {
      if (!o)
        return;
      let a = null;
      const l = wm("shape to svg", async () => {
        const c = Math.random();
        a = c;
        const u = n.getShapePageBounds(e), d = await n.getSvg([
          e
        ], {
          padding: 0
        });
        d && u && a === c && (d.style.setProperty("overflow", "visible"), d.setAttribute("preserveAspectRatio", "xMidYMin slice"), d.style.setProperty("transform", `translate(${u.x}px, ${u.y + u.h + 12}px)`), d.style.setProperty("border", "1px solid black"), s(d == null ? void 0 : d.outerHTML));
      });
      return () => {
        a = null, l();
      };
    }, [
      n,
      e,
      o
    ]), o ? m.jsx("div", {
      style: {
        paddingTop: 12,
        position: "absolute"
      },
      children: m.jsx("div", {
        style: {
          display: "flex"
        },
        dangerouslySetInnerHTML: {
          __html: i
        }
      })
    }) : null;
  });
  function F2e() {
    const t = ye("debugging ui log", () => un.logMessages.value, [
      un
    ]);
    return t.length ? m.jsx("div", {
      className: "debug__ui-logger",
      children: t.map((e, n) => {
        const r = typeof e == "string" ? e : JSON.stringify(e);
        return m.jsx("div", {
          className: "debug__ui-logger__line",
          children: r
        }, n);
      })
    }) : null;
  }
  function B2e() {
    const t = ue(), e = ye("selection rotation", () => t.selectionRotation, [
      t
    ]), n = ye("selection bounds", () => t.selectionRotatedPageBounds, [
      t
    ]), { SelectionForeground: r } = _i();
    return !n || !r ? null : m.jsx(r, {
      bounds: n,
      rotation: e
    });
  }
  function U2e() {
    const t = ue(), e = ye("selection rotation", () => t.selectionRotation, [
      t
    ]), n = ye("selection bounds", () => t.selectionRotatedPageBounds, [
      t
    ]), { SelectionBackground: r } = _i();
    return !n || !r ? null : m.jsx(r, {
      bounds: n,
      rotation: e
    });
  }
  function wn() {
    return kC();
  }
  const BG = "TLDRAW_USER_DATA_v3", UG = $t({
    id: et,
    name: et.nullable().optional(),
    locale: et.nullable().optional(),
    color: et.nullable().optional(),
    isDarkMode: It.nullable().optional(),
    animationSpeed: nt.nullable().optional(),
    isSnapMode: It.nullable().optional()
  }), pw = {
    AddAnimationSpeed: 1,
    AddIsSnapMode: 2,
    MakeFieldsNullable: 3
  }, $k = Ut({
    currentVersion: pw.MakeFieldsNullable,
    migrators: {
      [pw.AddAnimationSpeed]: {
        up: (t) => ({
          ...t,
          animationSpeed: 1
        }),
        down: ({ animationSpeed: t, ...e }) => e
      },
      [pw.AddIsSnapMode]: {
        up: (t) => ({
          ...t,
          isSnapMode: false
        }),
        down: ({ isSnapMode: t, ...e }) => e
      },
      [pw.MakeFieldsNullable]: {
        up: (t) => t,
        down: (t) => ({
          id: t.id,
          name: t.name ?? Ys.name,
          locale: t.locale ?? Ys.locale,
          color: t.color ?? Ys.color,
          isDarkMode: t.isDarkMode ?? Ys.isDarkMode,
          animationSpeed: t.animationSpeed ?? Ys.animationSpeed,
          isSnapMode: t.isSnapMode ?? Ys.isSnapMode
        })
      }
    }
  }), I8 = [
    "#FF802B",
    "#EC5E41",
    "#F2555A",
    "#F04F88",
    "#E34BA9",
    "#BD54C6",
    "#9D5BD2",
    "#7B66DC",
    "#02B1CC",
    "#11B3A3",
    "#39B178",
    "#55B467"
  ];
  function V2e() {
    return I8[Math.floor(Math.random() * I8.length)];
  }
  function X2e() {
    var _a3, _b3;
    return typeof window > "u" ? false : ((_b3 = (_a3 = window.matchMedia) == null ? void 0 : _a3.call(window, "(prefers-color-scheme: dark)")) == null ? void 0 : _b3.matches) ?? false;
  }
  function W2e() {
    var _a3, _b3;
    return typeof window > "u" ? false : ((_b3 = (_a3 = window.matchMedia) == null ? void 0 : _a3.call(window, "(prefers-reduced-motion: reduce)")) == null ? void 0 : _b3.matches) ?? false;
  }
  const Ys = Object.freeze({
    name: "New User",
    locale: Qbe(),
    color: V2e(),
    isDarkMode: false,
    animationSpeed: W2e() ? 0 : 1,
    isSnapMode: false
  });
  function gw() {
    return {
      id: wn()
    };
  }
  function VG(t) {
    if (t === null || typeof t != "object" || !("version" in t) || !("user" in t) || typeof t.version != "number")
      return gw();
    const e = c5({
      value: t.user,
      fromVersion: t.version,
      toVersion: $k.currentVersion ?? 0,
      migrations: $k
    });
    if (e.type === "error")
      return gw();
    try {
      UG.validate(e.value);
    } catch {
      return gw();
    }
    return e.value;
  }
  function Z2e() {
    var _a3;
    const t = typeof window > "u" ? null : JSON.parse(((_a3 = window == null ? void 0 : window.localStorage) == null ? void 0 : _a3.getItem(BG)) || "null") ?? null;
    return VG(t);
  }
  const nS = fs("globalUserData", Z2e());
  function H2e() {
    typeof window < "u" && window.localStorage && window.localStorage.setItem(BG, JSON.stringify({
      version: $k.currentVersion,
      user: nS.value
    }));
  }
  function XG(t) {
    UG.validate(t), nS.set(t), H2e(), G2e();
  }
  const Y2e = typeof process < "u" && false, WG = typeof BroadcastChannel < "u" && !Y2e ? new BroadcastChannel("tldraw-user-sync") : null;
  WG == null ? void 0 : WG.addEventListener("message", (t) => {
    const e = t.data;
    (e == null ? void 0 : e.type) === HG && (e == null ? void 0 : e.origin) !== ZG && nS.set(VG(e.data));
  });
  const ZG = wn(), HG = "tldraw-user-preferences-change";
  function G2e() {
    WG == null ? void 0 : WG.postMessage({
      type: HG,
      origin: ZG,
      data: {
        user: nS.value,
        version: $k.currentVersion
      }
    });
  }
  function YG() {
    return nS.value;
  }
  function GG(t = {}) {
    return {
      derivePresenceState: t.derivePresenceState ?? (() => ve("presence", () => null)),
      userPreferences: t.userPreferences ?? ve("userPreferences", () => YG()),
      setUserPreferences: t.setUserPreferences ?? XG
    };
  }
  var qG = {
    exports: {}
  };
  (function(t) {
    var e = Object.prototype.hasOwnProperty, n = "~";
    function r() {
    }
    Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (n = false));
    function i(l, c, u) {
      this.fn = l, this.context = c, this.once = u || false;
    }
    function s(l, c, u, d, h) {
      if (typeof u != "function")
        throw new TypeError("The listener must be a function");
      var f = new i(u, d || l, h), y = n ? n + c : c;
      return l._events[y] ? l._events[y].fn ? l._events[y] = [
        l._events[y],
        f
      ] : l._events[y].push(f) : (l._events[y] = f, l._eventsCount++), l;
    }
    function o(l, c) {
      --l._eventsCount === 0 ? l._events = new r() : delete l._events[c];
    }
    function a() {
      this._events = new r(), this._eventsCount = 0;
    }
    a.prototype.eventNames = function() {
      var c = [], u, d;
      if (this._eventsCount === 0)
        return c;
      for (d in u = this._events)
        e.call(u, d) && c.push(n ? d.slice(1) : d);
      return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(u)) : c;
    }, a.prototype.listeners = function(c) {
      var u = n ? n + c : c, d = this._events[u];
      if (!d)
        return [];
      if (d.fn)
        return [
          d.fn
        ];
      for (var h = 0, f = d.length, y = new Array(f); h < f; h++)
        y[h] = d[h].fn;
      return y;
    }, a.prototype.listenerCount = function(c) {
      var u = n ? n + c : c, d = this._events[u];
      return d ? d.fn ? 1 : d.length : 0;
    }, a.prototype.emit = function(c, u, d, h, f, y) {
      var g = n ? n + c : c;
      if (!this._events[g])
        return false;
      var O = this._events[g], S = arguments.length, w, x;
      if (O.fn) {
        switch (O.once && this.removeListener(c, O.fn, void 0, true), S) {
          case 1:
            return O.fn.call(O.context), true;
          case 2:
            return O.fn.call(O.context, u), true;
          case 3:
            return O.fn.call(O.context, u, d), true;
          case 4:
            return O.fn.call(O.context, u, d, h), true;
          case 5:
            return O.fn.call(O.context, u, d, h, f), true;
          case 6:
            return O.fn.call(O.context, u, d, h, f, y), true;
        }
        for (x = 1, w = new Array(S - 1); x < S; x++)
          w[x - 1] = arguments[x];
        O.fn.apply(O.context, w);
      } else {
        var P = O.length, C;
        for (x = 0; x < P; x++)
          switch (O[x].once && this.removeListener(c, O[x].fn, void 0, true), S) {
            case 1:
              O[x].fn.call(O[x].context);
              break;
            case 2:
              O[x].fn.call(O[x].context, u);
              break;
            case 3:
              O[x].fn.call(O[x].context, u, d);
              break;
            case 4:
              O[x].fn.call(O[x].context, u, d, h);
              break;
            default:
              if (!w)
                for (C = 1, w = new Array(S - 1); C < S; C++)
                  w[C - 1] = arguments[C];
              O[x].fn.apply(O[x].context, w);
          }
      }
      return true;
    }, a.prototype.on = function(c, u, d) {
      return s(this, c, u, d, false);
    }, a.prototype.once = function(c, u, d) {
      return s(this, c, u, d, true);
    }, a.prototype.removeListener = function(c, u, d, h) {
      var f = n ? n + c : c;
      if (!this._events[f])
        return this;
      if (!u)
        return o(this, f), this;
      var y = this._events[f];
      if (y.fn)
        y.fn === u && (!h || y.once) && (!d || y.context === d) && o(this, f);
      else {
        for (var g = 0, O = [], S = y.length; g < S; g++)
          (y[g].fn !== u || h && !y[g].once || d && y[g].context !== d) && O.push(y[g]);
        O.length ? this._events[f] = O.length === 1 ? O[0] : O : o(this, f);
      }
      return this;
    }, a.prototype.removeAllListeners = function(c) {
      var u;
      return c ? (u = n ? n + c : c, this._events[u] && o(this, u)) : (this._events = new r(), this._eventsCount = 0), this;
    }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, t.exports = a;
  })(qG);
  var q2e = qG.exports;
  function Gs({ children: t, className: e = "", ...n }) {
    return m.jsx("svg", {
      ...n,
      className: `tl-svg-container ${e}`,
      children: t
    });
  }
  class Of {
    constructor(e) {
      __publicField(this, "isFilled", false);
      __publicField(this, "isClosed", true);
      __publicField(this, "isLabel", false);
      __publicField(this, "isSnappable", true);
      __publicField(this, "_vertices");
      __publicField(this, "_bounds");
      __publicField(this, "_snapPoints");
      __publicField(this, "_area");
      this.isFilled = e.isFilled, this.isClosed = e.isClosed, this.isSnappable = e.isSnappable ?? false, this.isLabel = e.isLabel ?? false;
    }
    hitTestPoint(e, n = 0, r = false) {
      return this.distanceToPoint(e, r) <= n;
    }
    distanceToPoint(e, n = false) {
      const r = e.dist(this.nearestPoint(e));
      return this.isClosed && (this.isFilled || n) && Ql(e, this.vertices) ? -r : r;
    }
    distanceToLineSegment(e, n) {
      const r = this.nearestPointOnLineSegment(e, n), i = I.DistanceToLineSegment(e, n, r);
      return this.isClosed && this.isFilled && Ql(r, this.vertices) ? -i : i;
    }
    hitTestLineSegment(e, n, r = 0) {
      return this.distanceToLineSegment(e, n) <= r;
    }
    nearestPointOnLineSegment(e, n) {
      let r = 1 / 0, i;
      for (let s = 0; s < this.vertices.length; s++) {
        const o = this.vertices[s], a = I.DistanceToLineSegment(e, n, o);
        a < r && (r = a, i = o);
      }
      if (!i)
        throw Error("nearest point not found");
      return i;
    }
    isPointInBounds(e, n = 0) {
      const { bounds: r } = this;
      return !(e.x < r.minX - n || e.y < r.minY - n || e.x > r.maxX + n || e.y > r.maxY + n);
    }
    get vertices() {
      return this._vertices || (this._vertices = this.getVertices()), this._vertices;
    }
    getBounds() {
      return Te.FromPoints(this.vertices);
    }
    get bounds() {
      return this._bounds || (this._bounds = this.getBounds()), this._bounds;
    }
    get snapPoints() {
      return this._snapPoints || (this._snapPoints = this.bounds.snapPoints), this._snapPoints;
    }
    get center() {
      return this.bounds.center;
    }
    get area() {
      return this._area || (this._area = this.getArea()), this._area;
    }
    getArea() {
      if (!this.isClosed)
        return 0;
      const { vertices: e } = this;
      let n = 0;
      for (let r = 0, i = e.length; r < i; r++) {
        const s = e[r], o = e[(r + 1) % i];
        n += s.x * o.y - o.x * s.y;
      }
      return n / 2;
    }
    toSimpleSvgPath() {
      let e = "";
      const { vertices: n } = this, r = n.length;
      if (r === 0)
        return e;
      e += `M${n[0].x},${n[0].y}`;
      for (let i = 1; i < r; i++)
        e += `L${n[i].x},${n[i].y}`;
      return this.isClosed && (e += "Z"), e;
    }
  }
  class Yu extends Of {
    constructor(e) {
      super({
        ...e,
        isClosed: true,
        isFilled: false
      });
      __publicField(this, "children");
      const { children: n } = e;
      if (n.length === 0)
        throw Error("Group2d must have at least one child");
      this.children = n;
    }
    getVertices() {
      return this.children.filter((e) => !e.isLabel).flatMap((e) => e.vertices);
    }
    nearestPoint(e) {
      let n = 1 / 0, r;
      const { children: i } = this;
      if (i.length === 0)
        throw Error("no children");
      for (const s of i) {
        const o = s.nearestPoint(e), a = o.dist(e);
        a < n && (n = a, r = o);
      }
      if (!r)
        throw Error("nearest point not found");
      return r;
    }
    distanceToPoint(e, n = false) {
      return Math.min(...this.children.map((r, i) => r.distanceToPoint(e, n || i > 0)));
    }
    hitTestPoint(e, n, r) {
      return !!this.children.filter((i) => !i.isLabel).find((i) => i.hitTestPoint(e, n, r));
    }
    hitTestLineSegment(e, n, r) {
      return !!this.children.filter((i) => !i.isLabel).find((i) => i.hitTestLineSegment(e, n, r));
    }
    getArea() {
      return this.children[0].area;
    }
    toSimpleSvgPath() {
      let e = "";
      for (const r of this.children)
        e += r.toSimpleSvgPath();
      const n = Te.FromPoints(this.vertices).corners;
      for (let r = 0, i = n.length; r < i; r++) {
        const s = n[r], o = n[(r - 1 + i) % i], a = s.dist(o), l = n[(r + 1) % i], c = s.dist(l), u = s.clone().lrp(o, 4 / a), d = s, h = s.clone().lrp(l, 4 / c);
        e += `M${u.x},${u.y} L${d.x},${d.y} L${h.x},${h.y} `;
      }
      return e;
    }
  }
  function C5(t, e, n, r) {
    const i = t.x - n.x, s = t.y - n.y, o = r.x - n.x, a = r.y - n.y, l = e.x - t.x, c = e.y - t.y, u = o * s - a * i, d = l * s - c * i, h = a * l - o * c;
    if (u === 0 || d === 0 || h === 0)
      return null;
    if (h !== 0) {
      const f = u / h, y = d / h;
      if (0 <= f && f <= 1 && 0 <= y && y <= 1)
        return I.AddXY(t, f * l, f * c);
    }
    return null;
  }
  function IC(t, e, n, r) {
    const i = (e.x - t.x) * (e.x - t.x) + (e.y - t.y) * (e.y - t.y), s = 2 * ((e.x - t.x) * (t.x - n.x) + (e.y - t.y) * (t.y - n.y)), o = n.x * n.x + n.y * n.y + t.x * t.x + t.y * t.y - 2 * (n.x * t.x + n.y * t.y) - r * r, a = s * s - 4 * i * o;
    if (a < 0 || a === 0)
      return null;
    const l = Math.sqrt(a), c = (-s + l) / (2 * i), u = (-s - l) / (2 * i);
    if ((c < 0 || c > 1) && (u < 0 || u > 1))
      return null;
    const d = [];
    return 0 <= c && c <= 1 && d.push(I.Lrp(t, e, c)), 0 <= u && u <= 1 && d.push(I.Lrp(t, e, u)), d.length === 0 ? null : d;
  }
  function KG(t, e, n) {
    const r = [];
    let i;
    for (let s = 0, o = n.length - 1; s < o; s++)
      i = C5(t, e, n[s], n[s + 1]), i && r.push(i);
    return r.length === 0 ? null : r;
  }
  function K2e(t, e, n) {
    const r = [];
    let i;
    for (let s = 1, o = n.length; s < o + 1; s++)
      i = C5(t, e, n[s - 1], n[s % n.length]), i && r.push(i);
    return r.length === 0 ? null : r;
  }
  function J2e(t, e, n, r) {
    let i = n.x - t.x, s = n.y - t.y;
    const o = Math.sqrt(i * i + s * s), a = (o * o - r * r + e * e) / (2 * o), l = Math.sqrt(e * e - a * a);
    return i /= o, s /= o, [
      new I(t.x + i * a - s * l, t.y + s * a + i * l),
      new I(t.x + i * a + s * l, t.y + s * a - i * l)
    ];
  }
  function $8(t, e, n) {
    const r = [];
    let i, s, o;
    for (let a = 0, l = n.length; a < l; a++)
      i = n[a], s = n[(a + 1) % n.length], o = IC(i, s, t, e), o && r.push(...o);
    return r.length === 0 ? null : r;
  }
  function A8(t, e, n) {
    const r = [];
    let i, s, o;
    for (let a = 1, l = n.length; a < l; a++)
      i = n[a - 1], s = n[a], o = IC(i, s, t, e), o && r.push(...o);
    return r.length === 0 ? null : r;
  }
  function mw(t, e, n) {
    return (n.y - t.y) * (e.x - t.x) > (e.y - t.y) * (n.x - t.x);
  }
  function JG(t, e, n, r) {
    return mw(t, n, r) !== mw(e, n, r) && mw(t, e, n) !== mw(t, e, r);
  }
  function sR(t, e) {
    const n = [];
    let r, i, s, o;
    for (let a = 0, l = t.length; a < l; a++)
      r = t[a], Ql(r, e) && n.push(r);
    for (let a = 0, l = e.length; a < l; a++)
      r = e[a], Ql(r, t) && n.push(r);
    for (let a = 0, l = t.length; a < l; a++) {
      r = t[a], i = t[(a + 1) % t.length];
      for (let c = 0, u = e.length; c < u; c++) {
        s = e[c], o = e[(c + 1) % e.length];
        const d = C5(r, i, s, o);
        d !== null && n.push(d);
      }
    }
    return n.length === 0 ? null : e_e(n);
  }
  function e_e(t) {
    const e = I.Average(t);
    return t.sort((n, r) => I.Angle(e, n) - I.Angle(e, r));
  }
  function t_e(t, e) {
    let n, r, i, s;
    for (let o = 0, a = t.length; o < a; o++) {
      n = t[o], r = t[(o + 1) % a];
      for (let l = 0, c = e.length; l < c; l++)
        if (i = e[l], s = e[(l + 1) % c], JG(n, r, i, s))
          return true;
    }
    return false;
  }
  class Ak extends Of {
    constructor(e) {
      super({
        ...e,
        isClosed: false,
        isFilled: false
      });
      __publicField(this, "start");
      __publicField(this, "end");
      __publicField(this, "d");
      __publicField(this, "u");
      __publicField(this, "ul");
      __publicField(this, "_length");
      const { start: n, end: r } = e;
      this.start = n, this.end = r, this.d = n.clone().sub(r), this.u = this.d.clone().uni(), this.ul = this.u.len();
    }
    get length() {
      return this._length ? this._length : this.d.len();
    }
    midPoint() {
      return this.start.lrp(this.end, 0.5);
    }
    getVertices() {
      return [
        this.start,
        this.end
      ];
    }
    nearestPoint(e) {
      const { start: n, end: r, u: i, ul: s } = this;
      if (s === 0)
        return n;
      const o = I.Sub(e, n).dpr(i) / s, a = n.x + i.x * o;
      if (a < Math.min(n.x, r.x))
        return n.x < r.x ? n : r;
      if (a > Math.max(n.x, r.x))
        return n.x > r.x ? n : r;
      const l = n.y + i.y * o;
      return l < Math.min(n.y, r.y) ? n.y < r.y ? n : r : l > Math.max(n.y, r.y) ? n.y > r.y ? n : r : new I(a, l);
    }
    hitTestLineSegment(e, n, r) {
      return JG(e, n, this.start, this.end);
    }
  }
  class Sf extends Of {
    constructor(e) {
      super({
        isClosed: false,
        isFilled: false,
        ...e
      });
      __publicField(this, "points");
      __publicField(this, "_segments");
      __publicField(this, "_length");
      const { points: n } = e;
      this.points = n;
    }
    get segments() {
      if (!this._segments) {
        this._segments = [];
        const { vertices: e } = this;
        for (let n = 0, r = e.length - 1; n < r; n++) {
          const i = e[n], s = e[n + 1];
          this._segments.push(new Ak({
            start: i,
            end: s
          }));
        }
        this.isClosed && this._segments.push(new Ak({
          start: e[e.length - 1],
          end: e[0]
        }));
      }
      return this._segments;
    }
    get length() {
      return this._length || (this._length = this.segments.reduce((e, n) => e + n.length, 0)), this._length;
    }
    getVertices() {
      return this.points;
    }
    nearestPoint(e) {
      const { segments: n } = this;
      let r = this.points[0], i = 1 / 0, s, o;
      for (let a = 0; a < n.length; a++)
        s = n[a].nearestPoint(e), o = s.dist(e), o < i && (r = s, i = o);
      return r;
    }
    hitTestLineSegment(e, n, r) {
      return this.segments.some((i) => i.hitTestLineSegment(e, n, r));
    }
  }
  class xr extends Sf {
    constructor(e) {
      super({
        ...e
      }), this.isClosed = true;
    }
  }
  class wd extends xr {
    constructor(e) {
      const { x: n = 0, y: r = 0, width: i, height: s } = e;
      super({
        ...e,
        points: [
          new I(n, r),
          new I(n + i, r),
          new I(n + i, r + s),
          new I(n, r + s)
        ]
      });
      __publicField(this, "x");
      __publicField(this, "y");
      __publicField(this, "w");
      __publicField(this, "h");
      this.x = n, this.y = r, this.w = i, this.h = s;
    }
    getBounds() {
      return new Te(this.x, this.y, this.w, this.h);
    }
  }
  class Nd {
    constructor(e) {
      __publicField(this, "canSnap", () => true);
      __publicField(this, "canScroll", () => false);
      __publicField(this, "canUnmount", () => true);
      __publicField(this, "canBind", (e, n) => true);
      __publicField(this, "canEdit", () => false);
      __publicField(this, "canResize", () => true);
      __publicField(this, "canEditInReadOnly", () => false);
      __publicField(this, "canCrop", () => false);
      __publicField(this, "hideResizeHandles", () => false);
      __publicField(this, "hideRotateHandle", () => false);
      __publicField(this, "hideSelectionBoundsBg", () => false);
      __publicField(this, "hideSelectionBoundsFg", () => false);
      __publicField(this, "isAspectRatioLocked", () => false);
      __publicField(this, "onBeforeCreate");
      __publicField(this, "onBeforeUpdate");
      __publicField(this, "onDragShapesOver");
      __publicField(this, "onDragShapesOut");
      __publicField(this, "onDropShapesOver");
      __publicField(this, "onResizeStart");
      __publicField(this, "onResize");
      __publicField(this, "onResizeEnd");
      __publicField(this, "onTranslateStart");
      __publicField(this, "onTranslate");
      __publicField(this, "onTranslateEnd");
      __publicField(this, "onRotateStart");
      __publicField(this, "onRotate");
      __publicField(this, "onRotateEnd");
      __publicField(this, "onHandleChange");
      __publicField(this, "onBindingChange");
      __publicField(this, "onChildrenChange");
      __publicField(this, "onDoubleClickHandle");
      __publicField(this, "onDoubleClickEdge");
      __publicField(this, "onDoubleClick");
      __publicField(this, "onClick");
      __publicField(this, "onEditEnd");
      this.editor = e;
    }
    providesBackgroundForChildren(e) {
      return false;
    }
    getOutlineSegments(e) {
      return [
        this.editor.getShapeGeometry(e).vertices
      ];
    }
    canReceiveNewChildrenOfType(e, n) {
      return false;
    }
    canDropShapes(e, n) {
      return false;
    }
    expandSelectionOutlinePx(e) {
      return 0;
    }
    getCanvasSvgDefs() {
      return [];
    }
  }
  __publicField(Nd, "props");
  __publicField(Nd, "migrations");
  __publicField(Nd, "type");
  function n_e(t, e, n = {}) {
    const { closed: r = false, snap: i = 1, start: s = "outset", end: o = "outset", lengthRatio: a = 2, style: l = "dashed" } = n;
    let c = 0, u = 0, d = 1, h = 0, f = 0;
    switch (l) {
      case "dashed": {
        d = 1, c = Math.min(e * a, t / 4);
        break;
      }
      case "dotted": {
        d = 100, c = e / d;
        break;
      }
      default:
        return {
          strokeDasharray: "none",
          strokeDashoffset: "none"
        };
    }
    return r || (s === "outset" ? (t += c / 2, f += c / 2) : s === "skip" && (t -= c, f -= c), o === "outset" ? t += c / 2 : o === "skip" && (t -= c)), u = Math.floor(t / c / (2 * d)), u -= u % i, u < 3 && l === "dashed" ? t / e < 5 ? (c = t, u = 1, h = 0) : (c = t * 0.333, h = t * 0.333) : (u = Math.max(u, 3), c = t / u / (2 * d), r ? (f = c / 2, h = (t - u * c) / u) : h = (t - u * c) / Math.max(1, u - 1)), {
      strokeDasharray: [
        c,
        h
      ].join(" "),
      strokeDashoffset: f.toString()
    };
  }
  function R8({ bounds: t, className: e }) {
    const n = ue(), r = ye("zoom level", () => n.zoomLevel, [
      n
    ]);
    return m.jsx("g", {
      className: e,
      pointerEvents: "none",
      strokeLinecap: "round",
      strokeLinejoin: "round",
      children: t.sides.map((i, s) => {
        const { strokeDasharray: o, strokeDashoffset: a } = n_e(i[0].dist(i[1]), 1 / r, {
          style: "dashed",
          lengthRatio: 4
        });
        return m.jsx("line", {
          x1: i[0].x,
          y1: i[0].y,
          x2: i[1].x,
          y2: i[1].y,
          strokeDasharray: o,
          strokeDashoffset: a
        }, s);
      })
    });
  }
  class r_e extends Nd {
    constructor() {
      super(...arguments);
      __publicField(this, "hideSelectionBoundsFg", () => true);
      __publicField(this, "canBind", () => false);
      __publicField(this, "onChildrenChange", (e) => {
        const n = this.editor.getSortedChildIdsForParent(e.id);
        if (n.length === 0) {
          this.editor.currentPageState.focusedGroupId === e.id && this.editor.popFocusedGroupId(), this.editor.deleteShapes([
            e.id
          ]);
          return;
        } else if (n.length === 1) {
          this.editor.currentPageState.focusedGroupId === e.id && this.editor.popFocusedGroupId(), this.editor.reparentShapes(n, e.parentId), this.editor.deleteShapes([
            e.id
          ]);
          return;
        }
      });
    }
    getDefaultProps() {
      return {};
    }
    getGeometry(e) {
      const n = this.editor.getSortedChildIdsForParent(e.id);
      return n.length === 0 ? new wd({
        width: 1,
        height: 1,
        isFilled: false
      }) : new Yu({
        children: n.map((r) => {
          const i = this.editor.getShape(r), s = this.editor.getShapeGeometry(r), o = this.editor.getShapeLocalTransform(i).applyToPoints(s.vertices);
          return s.isClosed ? new xr({
            points: o,
            isFilled: true
          }) : new Sf({
            points: o
          });
        })
      });
    }
    component(e) {
      const n = this.editor.erasingShapeIds.includes(e.id), { hintingShapeIds: r } = this.editor.currentPageState, i = r.length > 0 && r.some((a) => a !== e.id && this.editor.isShapeOfType(this.editor.getShape(a), "group")), s = this.editor.currentPageState.focusedGroupId !== e.id;
      if (!n && (s || i))
        return null;
      const o = this.editor.getShapeGeometry(e).bounds;
      return m.jsx(Gs, {
        id: e.id,
        children: m.jsx(R8, {
          className: "tl-group",
          bounds: o
        })
      });
    }
    indicator(e) {
      const n = this.editor.getShapeGeometry(e).bounds;
      return m.jsx(R8, {
        className: "",
        bounds: n
      });
    }
  }
  __publicField(r_e, "type", "group");
  __publicField(r_e, "props", xbe);
  __publicField(r_e, "migrations", bbe);
  const eq = [
    r_e
  ], i_e = new Set(eq.map((t) => t.type));
  function tq(t) {
    const e = [
      ...eq
    ], n = /* @__PURE__ */ new Set();
    for (const r of t) {
      if (i_e.has(r.type))
        throw new Error(`Shape type "${r.type}" is a core shapes type and cannot be overridden`);
      if (n.has(r.type))
        throw new Error(`Shape type "${r.type}" is defined more than once`);
      e.push(r), n.add(r.type);
    }
    return e;
  }
  function M8(t, e) {
    if (!e)
      return false;
    switch (t.type) {
      case "mixed":
        return e.type === "mixed";
      case "shared":
        return e.type === "shared" && t.value === e.value;
      default:
        throw o5(t);
    }
  }
  class s_e {
    constructor(e) {
      __publicField(this, "map");
      this.map = new Map(e);
    }
    get(e) {
      return this.map.get(e);
    }
    getAsKnownValue(e) {
      const n = this.get(e);
      if (n && n.type !== "mixed")
        return n.value;
    }
    get size() {
      return this.map.size;
    }
    equals(e) {
      if (this.size !== e.size)
        return false;
      const n = /* @__PURE__ */ new Set();
      for (const [r, i] of this) {
        if (!M8(i, e.get(r)))
          return false;
        n.add(r);
      }
      for (const [r, i] of e)
        if (!n.has(r) && !M8(i, this.get(r)))
          return false;
      return true;
    }
    keys() {
      return this.map.keys();
    }
    values() {
      return this.map.values();
    }
    entries() {
      return this.map.entries();
    }
    [Symbol.iterator]() {
      return this.map[Symbol.iterator]();
    }
  }
  class oR extends s_e {
    set(e, n) {
      this.map.set(e, n);
    }
    applyValue(e, n) {
      const r = this.get(e);
      if (!r) {
        this.set(e, {
          type: "shared",
          value: n
        });
        return;
      }
      switch (r.type) {
        case "mixed":
          return;
        case "shared":
          r.value !== n && this.set(e, {
            type: "mixed"
          });
          return;
        default:
          o5(r, "type");
      }
    }
  }
  class _5 {
    constructor() {
      __publicField(this, "items", /* @__PURE__ */ new WeakMap());
    }
    get(e, n) {
      return this.items.has(e) || this.items.set(e, n(e)), this.items.get(e);
    }
    access(e) {
      return this.items.get(e);
    }
    set(e, n) {
      this.items.set(e, n);
    }
    has(e) {
      return this.items.has(e);
    }
    invalidate(e) {
      this.items.delete(e);
    }
    bust() {
      this.items = /* @__PURE__ */ new WeakMap();
    }
  }
  function o_e(t, e, n) {
    return fetch(t).then(function(r) {
      return r.arrayBuffer();
    }).then(function(r) {
      return new File([
        r
      ], e, {
        type: n
      });
    });
  }
  function a_e(t, e) {
    var _a3;
    let n = t;
    const r = new Set(e);
    for (; r.has(n); )
      n = ((_a3 = /^.*(\d+)$/.exec(n)) == null ? void 0 : _a3[1]) ? n.replace(/(\d+)(?=\D?)$/, (i) => (+i + 1).toString()) : `${n} 1`;
    return n;
  }
  const eo = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", l_e = "a0", nq = "A00000000000000000000000000";
  function rq(t) {
    if (t >= "a" && t <= "z")
      return t.charCodeAt(0) - "a".charCodeAt(0) + 2;
    if (t >= "A" && t <= "Z")
      return "Z".charCodeAt(0) - t.charCodeAt(0) + 2;
    throw new Error("Invalid index key head: " + t);
  }
  function iq(t) {
    if (t.length !== rq(t.charAt(0)))
      throw new Error("invalid integer part of index key: " + t);
  }
  function D8(t) {
    if (t === void 0)
      throw Error("n is undefined");
  }
  function L8(t) {
    iq(t);
    const [e, ...n] = t.split("");
    let r = true;
    for (let i = n.length - 1; r && i >= 0; i--) {
      const s = eo.indexOf(n[i]) + 1;
      s === eo.length ? n[i] = "0" : (n[i] = eo.charAt(s), r = false);
    }
    if (r) {
      if (e === "Z")
        return "a0";
      if (e === "z")
        return;
      const i = String.fromCharCode(e.charCodeAt(0) + 1);
      return i > "a" ? n.push("0") : n.pop(), i + n.join("");
    } else
      return e + n.join("");
  }
  function c_e(t) {
    iq(t);
    const [e, ...n] = t.split("");
    let r = true;
    for (let i = n.length - 1; r && i >= 0; i--) {
      const s = eo.indexOf(n[i]) - 1;
      s === -1 ? n[i] = eo.slice(-1) : (n[i] = eo.charAt(s), r = false);
    }
    if (r) {
      if (e === "a")
        return "Z" + eo.slice(-1);
      if (e === "A")
        return;
      const i = String.fromCharCode(e.charCodeAt(0) - 1);
      return i < "Z" ? n.push(eo.slice(-1)) : n.pop(), i + n.join("");
    } else
      return e + n.join("");
  }
  function qp(t, e) {
    if (e !== void 0 && t >= e)
      throw new Error(t + " >= " + e);
    if (t.slice(-1) === "0" || e && e.slice(-1) === "0")
      throw new Error("trailing zero");
    if (e) {
      let i = 0;
      for (; (t.charAt(i) || "0") === e.charAt(i); )
        i++;
      if (i > 0)
        return e.slice(0, i) + qp(t.slice(i), e.slice(i));
    }
    const n = t ? eo.indexOf(t.charAt(0)) : 0, r = e !== void 0 ? eo.indexOf(e.charAt(0)) : eo.length;
    if (r - n > 1) {
      const i = Math.round(0.5 * (n + r));
      return eo.charAt(i);
    } else
      return e && e.length > 1 ? e.slice(0, 1) : eo.charAt(n) + qp(t.slice(1), void 0);
  }
  function O0(t) {
    const e = rq(t.charAt(0));
    if (e > t.length)
      throw new Error("invalid index: " + t);
    return t.slice(0, e);
  }
  function j8(t) {
    if (t === nq)
      throw new Error("invalid index: " + t);
    const e = O0(t);
    if (t.slice(e.length).slice(-1) === "0")
      throw new Error("invalid index: " + t);
  }
  function yp(t, e) {
    if (t !== void 0 && j8(t), e !== void 0 && j8(e), t !== void 0 && e !== void 0 && t >= e)
      throw new Error(t + " >= " + e);
    if (t === void 0 && e === void 0)
      return l_e;
    if (t === void 0) {
      if (e === void 0)
        throw Error("b is undefined");
      const a = O0(e), l = e.slice(a.length);
      if (a === nq)
        return a + qp("", l);
      if (a < e)
        return a;
      const c = c_e(a);
      return D8(c), c;
    }
    if (e === void 0) {
      const a = O0(t), l = t.slice(a.length), c = L8(a);
      return c === void 0 ? a + qp(l, void 0) : c;
    }
    const n = O0(t), r = t.slice(n.length), i = O0(e), s = e.slice(i.length);
    if (n === i)
      return n + qp(r, s);
    const o = L8(n);
    return D8(o), o < e ? o : n + qp(r, void 0);
  }
  function xd(t, e, n) {
    if (n === 0)
      return [];
    if (n === 1)
      return [
        yp(t, e)
      ];
    if (e === void 0) {
      let s = yp(t, e);
      const o = [
        s
      ];
      for (let a = 0; a < n - 1; a++)
        s = yp(s, e), o.push(s);
      return o;
    }
    if (t === void 0) {
      let s = yp(t, e);
      const o = [
        s
      ];
      for (let a = 0; a < n - 1; a++)
        s = yp(t, s), o.push(s);
      return o.reverse(), o;
    }
    const r = Math.floor(n / 2), i = yp(t, e);
    return [
      ...xd(t, i, r),
      i,
      ...xd(i, e, n - r - 1)
    ];
  }
  function zg(t, e, n) {
    return xd(t, e, n);
  }
  function TE(t, e) {
    return xd(t, void 0, e);
  }
  function G0(t, e) {
    return xd(t, e, 1)[0];
  }
  function wc(t) {
    return xd(t, void 0, 1)[0];
  }
  function u_e(t) {
    return xd(void 0, t, 1)[0];
  }
  function sq(t, e = "a1") {
    return [
      e,
      ...xd(e, void 0, t)
    ];
  }
  function hi(t, e) {
    return t.index < e.index ? -1 : t.index > e.index ? 1 : 0;
  }
  function yw(t, e, n) {
    if (n.length === 0)
      return [];
    const r = /* @__PURE__ */ new Map();
    for (const s of Je(n.map((o) => t.getShape(o)))) {
      const { parentId: o } = s;
      r.has(o) || r.set(o, {
        children: Je(t.getSortedChildIdsForParent(o).map((a) => t.getShape(a))),
        moving: /* @__PURE__ */ new Set()
      }), r.get(o).moving.add(s);
    }
    const i = [];
    switch (e) {
      case "toBack": {
        r.forEach(({ moving: s, children: o }) => d_e(s, o, i));
        break;
      }
      case "toFront": {
        r.forEach(({ moving: s, children: o }) => h_e(s, o, i));
        break;
      }
      case "forward": {
        r.forEach(({ moving: s, children: o }) => f_e(s, o, i));
        break;
      }
      case "backward": {
        r.forEach(({ moving: s, children: o }) => p_e(s, o, i));
        break;
      }
    }
    return i;
  }
  function d_e(t, e, n) {
    const r = e.length;
    if (t.size === r)
      return;
    let i, s;
    for (let o = 0; o < r; o++) {
      const a = e[o];
      if (t.has(a))
        i = a.index, t.delete(a);
      else {
        s = a.index;
        break;
      }
    }
    if (t.size !== 0) {
      const o = zg(i, s, t.size);
      n.push(...Array.from(t.values()).sort(hi).map((a, l) => ({
        ...a,
        index: o[l]
      })));
    }
  }
  function h_e(t, e, n) {
    const r = e.length;
    if (t.size === r)
      return;
    let i, s;
    for (let o = r - 1; o > -1; o--) {
      const a = e[o];
      if (t.has(a))
        s = a.index, t.delete(a);
      else {
        i = a.index;
        break;
      }
    }
    if (t.size !== 0) {
      const o = zg(i, s, t.size);
      n.push(...Array.from(t.values()).sort(hi).map((a, l) => ({
        ...a,
        index: o[l]
      })));
    }
  }
  function f_e(t, e, n) {
    var _a3;
    const r = e.length;
    if (t.size === r)
      return;
    let i = {
      name: "skipping"
    };
    for (let s = 0; s < r; s++) {
      const o = t.has(e[s]);
      switch (i.name) {
        case "skipping": {
          if (!o)
            continue;
          i = {
            name: "selecting",
            selectIndex: s
          };
          break;
        }
        case "selecting": {
          if (o)
            continue;
          const { selectIndex: a } = i;
          zg(e[s].index, (_a3 = e[s + 1]) == null ? void 0 : _a3.index, s - a).forEach((l, c) => n.push({
            ...e[a + c],
            index: l
          })), i = {
            name: "skipping"
          };
          break;
        }
      }
    }
  }
  function p_e(t, e, n) {
    var _a3;
    const r = e.length;
    if (t.size === r)
      return;
    let i = {
      name: "skipping"
    };
    for (let s = r - 1; s > -1; s--) {
      const o = t.has(e[s]);
      switch (i.name) {
        case "skipping": {
          if (!o)
            continue;
          i = {
            name: "selecting",
            selectIndex: s
          };
          break;
        }
        case "selecting": {
          if (o)
            continue;
          zg((_a3 = e[s - 1]) == null ? void 0 : _a3.index, e[s].index, i.selectIndex - s).forEach((a, l) => {
            n.push({
              ...e[s + l + 1],
              index: a
            });
          }), i = {
            name: "skipping"
          };
          break;
        }
      }
    }
  }
  function oq({ editor: t }) {
    const { selectionRotation: e, selectionRotatedPageBounds: n, inputs: { originPagePoint: r }, selectedShapes: i } = t;
    if (!n)
      return null;
    const s = n.center.clone().rotWith(n.point, e);
    return {
      selectionPageCenter: s,
      initialCursorAngle: s.angle(r),
      initialSelectionRotation: e,
      shapeSnapshots: i.map((o) => ({
        shape: Dc(o),
        initialPagePoint: t.getShapePageTransform(o.id).point()
      }))
    };
  }
  function Yx({ delta: t, editor: e, snapshot: n, stage: r }) {
    const { selectionPageCenter: i, shapeSnapshots: s } = n;
    e.updateShapes(s.map(({ shape: a, initialPagePoint: l }) => {
      const c = Ro(a.parentId) ? e.getShapePageTransform(a.parentId) : Se.Identity(), u = I.RotWith(l, i, t), d = Se.applyToPoint(Se.Inverse(c), u), h = Qa(a.rotation + t);
      return {
        id: a.id,
        type: a.type,
        x: d.x,
        y: d.y,
        rotation: h
      };
    }));
    const o = [];
    s.forEach(({ shape: a }) => {
      var _a3, _b3, _c3;
      const l = e.getShape(a.id);
      if (!l)
        return;
      const c = e.getShapeUtil(a);
      if (r === "start" || r === "one-off") {
        const d = (_a3 = c.onRotateStart) == null ? void 0 : _a3.call(c, a);
        d && o.push(d);
      }
      const u = (_b3 = c.onRotate) == null ? void 0 : _b3.call(c, a, l);
      if (u && o.push(u), r === "end" || r === "one-off") {
        const d = (_c3 = c.onRotateEnd) == null ? void 0 : _c3.call(c, a, l);
        d && o.push(d);
      }
    }), o.length > 0 && e.updateShapes(o);
  }
  const g_e = (t) => {
    const { store: e } = t, n = e.query.filterHistory("shape"), r = e.query.records("shape", () => ({
      type: {
        eq: "arrow"
      }
    }));
    function i() {
      const s = r.value, o = {};
      for (const a of s) {
        const { start: l, end: c } = a.props;
        if (l.type === "binding") {
          const u = o[l.boundShapeId];
          u ? u.push({
            arrowId: a.id,
            handleId: "start"
          }) : o[l.boundShapeId] = [
            {
              arrowId: a.id,
              handleId: "start"
            }
          ];
        }
        if (c.type === "binding") {
          const u = o[c.boundShapeId];
          u ? u.push({
            arrowId: a.id,
            handleId: "end"
          }) : o[c.boundShapeId] = [
            {
              arrowId: a.id,
              handleId: "end"
            }
          ];
        }
      }
      return o;
    }
    return ve("arrowBindingsIndex", (s, o) => {
      if (pg(s))
        return i();
      const a = s, l = n.getDiffSince(o);
      if (l === io)
        return i();
      let c;
      function u(f) {
        c || (c = {
          ...a
        }), c[f] ? c[f] === a[f] && (c[f] = [
          ...c[f]
        ]) : c[f] = [];
      }
      function d(f, y, g) {
        u(f), c[f] = c[f].filter((O) => O.arrowId !== y || O.handleId !== g), c[f].length === 0 && delete c[f];
      }
      function h(f, y, g) {
        u(f), c[f].push({
          arrowId: y,
          handleId: g
        });
      }
      for (const f of l) {
        for (const y of Object.values(f.added))
          if (t.isShapeOfType(y, "arrow")) {
            const { start: g, end: O } = y.props;
            g.type === "binding" && h(g.boundShapeId, y.id, "start"), O.type === "binding" && h(O.boundShapeId, y.id, "end");
          }
        for (const [y, g] of Object.values(f.updated))
          if (!(!t.isShapeOfType(y, "arrow") || !t.isShapeOfType(g, "arrow")))
            for (const O of [
              "start",
              "end"
            ]) {
              const S = y.props[O], w = g.props[O];
              S.type === "binding" && w.type === "point" ? d(S.boundShapeId, y.id, O) : S.type === "point" && w.type === "binding" ? h(w.boundShapeId, g.id, O) : S.type === "binding" && w.type === "binding" && S.boundShapeId !== w.boundShapeId && (d(S.boundShapeId, y.id, O), h(w.boundShapeId, g.id, O));
            }
        for (const y of Object.values(f.removed))
          if (t.isShapeOfType(y, "arrow")) {
            const { start: g, end: O } = y.props;
            g.type === "binding" && d(g.boundShapeId, y.id, "start"), O.type === "binding" && d(O.boundShapeId, y.id, "end");
          }
      }
      return c ?? a;
    });
  }, m_e = (t) => {
    const e = t.query.ids("shape");
    function n() {
      const r = {}, i = e.value, s = Array(i.size);
      return i.forEach((o) => s.push(t.get(o))), s.sort(hi), s.forEach((o) => {
        r[o.parentId] || (r[o.parentId] = []), r[o.parentId].push(o.id);
      }), r;
    }
    return ve("parentsToChildrenWithIndexes", (r, i) => {
      if (pg(r))
        return n();
      const s = t.history.getDiffSince(i);
      if (s === io)
        return n();
      if (s.length === 0)
        return r;
      let o = null;
      const a = (u) => {
        o || (o = {
          ...r
        }), o[u] ? o[u] === r[u] && (o[u] = [
          ...o[u]
        ]) : o[u] = [];
      }, l = /* @__PURE__ */ new Set();
      let c;
      for (let u = 0, d = s.length; u < d; u++) {
        c = s[u];
        for (const h of Object.values(c.added))
          Dh(h) && (a(h.parentId), o[h.parentId].push(h.id), l.add(o[h.parentId]));
        for (const [h, f] of Object.values(c.updated))
          if (Dh(f) && Dh(h)) {
            if (h.parentId !== f.parentId)
              a(h.parentId), a(f.parentId), o[h.parentId].splice(o[h.parentId].indexOf(f.id), 1), o[f.parentId].push(f.id), l.add(o[f.parentId]);
            else if (h.index !== f.index) {
              a(f.parentId);
              const y = o[f.parentId].indexOf(f.id);
              o[f.parentId][y] = f.id, l.add(o[f.parentId]);
            }
          }
        for (const h of Object.values(c.removed))
          Dh(h) && (a(h.parentId), o[h.parentId].splice(o[h.parentId].indexOf(h.id), 1));
      }
      for (const u of l) {
        const d = Je(u.map((h) => t.get(h)));
        d.sort(hi), u.splice(0, u.length, ...d.map((h) => h.id));
      }
      return o ?? r;
    });
  }, EE = (t, e, n) => {
    for (; !rs(n.parentId); ) {
      const r = t.get(n.parentId);
      if (!r)
        return false;
      n = r;
    }
    return n.parentId === e;
  }, y_e = (t, e) => {
    const n = t.query.ids("shape");
    let r = null;
    function i() {
      const s = e();
      return r = s, new Set([
        ...n.value
      ].filter((o) => EE(t, s, t.get(o))));
    }
    return ve("_shapeIdsInCurrentPage", (s, o) => {
      if (pg(s))
        return i();
      const a = e();
      if (a !== r)
        return i();
      const l = t.history.getDiffSince(o);
      if (l === io)
        return i();
      const c = new Vx(s);
      for (const d of l) {
        for (const h of Object.values(d.added))
          Dh(h) && EE(t, a, h) && c.add(h.id);
        for (const [h, f] of Object.values(d.updated))
          Dh(f) && (EE(t, a, f) ? c.add(f.id) : c.remove(f.id));
        for (const h of Object.keys(d.removed))
          Ro(h) && c.remove(h);
      }
      const u = c.get();
      return u ? y0(u.value, u.diff) : s;
    });
  }, v_e = 40;
  class O_e {
    constructor(e) {
      __publicField(this, "_clickId", "");
      __publicField(this, "_clickTimeout");
      __publicField(this, "_clickScreenPoint");
      __publicField(this, "_previousScreenPoint");
      __publicField(this, "_getClickTimeout", (e, n = wn()) => {
        this._clickId = n, clearTimeout(this._clickTimeout), this._clickTimeout = setTimeout(() => {
          if (this._clickState === e && this._clickId === n) {
            switch (this._clickState) {
              case "pendingTriple": {
                this.editor.dispatch({
                  ...this.lastPointerInfo,
                  type: "click",
                  name: "double_click",
                  phase: "settle"
                });
                break;
              }
              case "pendingQuadruple": {
                this.editor.dispatch({
                  ...this.lastPointerInfo,
                  type: "click",
                  name: "triple_click",
                  phase: "settle"
                });
                break;
              }
              case "pendingOverflow": {
                this.editor.dispatch({
                  ...this.lastPointerInfo,
                  type: "click",
                  name: "quadruple_click",
                  phase: "settle"
                });
                break;
              }
            }
            this._clickState = "idle";
          }
        }, e === "idle" || e === "pendingDouble" ? bke : kke);
      });
      __publicField(this, "_clickState", "idle");
      __publicField(this, "lastPointerInfo", {});
      __publicField(this, "transformPointerDownEvent", (e) => {
        if (!this._clickState)
          return e;
        switch (this._clickScreenPoint = I.From(e.point), this._previousScreenPoint && this._previousScreenPoint.dist(this._clickScreenPoint) > v_e && (this._clickState = "idle"), this._previousScreenPoint = this._clickScreenPoint, this.lastPointerInfo = e, this._clickState) {
          case "idle":
            return this._clickState = "pendingDouble", this._clickTimeout = this._getClickTimeout(this._clickState), e;
          case "pendingDouble":
            return this._clickState = "pendingTriple", this._clickTimeout = this._getClickTimeout(this._clickState), {
              ...e,
              type: "click",
              name: "double_click",
              phase: "down"
            };
          case "pendingTriple":
            return this._clickState = "pendingQuadruple", this._clickTimeout = this._getClickTimeout(this._clickState), {
              ...e,
              type: "click",
              name: "triple_click",
              phase: "down"
            };
          case "pendingQuadruple":
            return this._clickState = "pendingOverflow", this._clickTimeout = this._getClickTimeout(this._clickState), {
              ...e,
              type: "click",
              name: "quadruple_click",
              phase: "down"
            };
          case "pendingOverflow":
            return this._clickState = "overflow", this._clickTimeout = this._getClickTimeout(this._clickState), e;
          default:
            return this._clickTimeout = this._getClickTimeout(this._clickState), e;
        }
      });
      __publicField(this, "transformPointerUpEvent", (e) => {
        if (!this._clickState)
          return e;
        switch (this._clickScreenPoint = I.From(e.point), this._clickState) {
          case "pendingTriple":
            return {
              ...this.lastPointerInfo,
              type: "click",
              name: "double_click",
              phase: "up"
            };
          case "pendingQuadruple":
            return {
              ...this.lastPointerInfo,
              type: "click",
              name: "triple_click",
              phase: "up"
            };
          case "pendingOverflow":
            return {
              ...this.lastPointerInfo,
              type: "click",
              name: "quadruple_click",
              phase: "up"
            };
          default:
            return e;
        }
      });
      __publicField(this, "cancelDoubleClickTimeout", () => {
        this._clickTimeout = clearTimeout(this._clickTimeout), this._clickState = "idle";
      });
      __publicField(this, "handleMove", () => {
        this._clickState !== "idle" && this._clickScreenPoint && this._clickScreenPoint.dist(this.editor.inputs.currentScreenPoint) > (this.editor.instanceState.isCoarsePointer ? nR : Zv) && this.cancelDoubleClickTimeout();
      });
      this.editor = e;
    }
    get clickState() {
      return this._clickState;
    }
  }
  class S_e {
    constructor(e) {
      __publicField(this, "isSafari");
      __publicField(this, "isIos");
      __publicField(this, "isChromeForIos");
      __publicField(this, "isFirefox");
      __publicField(this, "isAndroid");
      this.editor = e, typeof window < "u" && "navigator" in window ? (this.isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent), this.isIos = !!navigator.userAgent.match(/iPad/i) || !!navigator.userAgent.match(/iPhone/i), this.isChromeForIos = /crios.*safari/i.test(navigator.userAgent), this.isFirefox = /firefox/i.test(navigator.userAgent), this.isAndroid = /android/i.test(navigator.userAgent)) : (this.isSafari = false, this.isIos = false, this.isChromeForIos = false, this.isFirefox = false, this.isAndroid = false);
    }
  }
  function uh(t) {
    if (t) {
      let e = N8;
      for (; t.length; )
        e = e.push(t.pop());
      return e;
    }
    return N8;
  }
  class w_e {
    constructor() {
      __publicField(this, "length", 0);
      __publicField(this, "head", null);
      __publicField(this, "tail", this);
    }
    push(e) {
      return new T5(e, this);
    }
    toArray() {
      return Rc;
    }
    [Symbol.iterator]() {
      return {
        next() {
          return {
            value: void 0,
            done: true
          };
        }
      };
    }
  }
  const N8 = new w_e();
  class T5 {
    constructor(e, n) {
      __publicField(this, "length");
      this.head = e, this.tail = n, this.length = n.length + 1;
    }
    push(e) {
      return new T5(e, this);
    }
    toArray() {
      return Array.from(this);
    }
    [Symbol.iterator]() {
      let e = this;
      return {
        next() {
          if (e.length) {
            const n = e.head;
            return e = e.tail, {
              value: n,
              done: false
            };
          } else
            return {
              value: void 0,
              done: true
            };
        }
      };
    }
  }
  class x_e {
    constructor(e, n) {
      __publicField(this, "_undos", fs("HistoryManager.undos", uh()));
      __publicField(this, "_redos", fs("HistoryManager.redos", uh()));
      __publicField(this, "_batchDepth", 0);
      __publicField(this, "onBatchComplete", () => {
      });
      __publicField(this, "_commands", {});
      __publicField(this, "createCommand", (e, n, r) => {
        if (this._commands[e])
          throw new Error(`Duplicate command: ${e}`);
        this._commands[e] = r;
        const i = (...s) => {
          if (!this._batchDepth)
            return this.batch(() => i(...s)), this.ctx;
          const o = n(...s);
          if (!o)
            return this.ctx;
          const { data: a, ephemeral: l, squashing: c, preservesRedoStack: u } = o;
          if (this.ignoringUpdates((d, h) => (r.do(a), {
            undos: d,
            redos: h
          })), !l) {
            const d = this._undos.value.head;
            c && d && d.type === "command" && d.name === e && d.preservesRedoStack === u ? this._undos.update((h) => h.tail.push({
              ...d,
              id: wn(),
              data: r.squash(d.data, a)
            })) : this._undos.update((h) => h.push({
              type: "command",
              name: e,
              data: a,
              id: wn(),
              preservesRedoStack: u
            })), o.preservesRedoStack || this._redos.set(uh()), this.ctx.emit("change-history", {
              reason: "push"
            });
          }
          return this.ctx;
        };
        return i;
      });
      __publicField(this, "batch", (e) => {
        try {
          this._batchDepth++, this._batchDepth === 1 ? Ca(() => {
            var _a3, _b3;
            const n = (_a3 = this._undos.value.head) == null ? void 0 : _a3.id;
            e(), n !== ((_b3 = this._undos.value.head) == null ? void 0 : _b3.id) && this.onBatchComplete();
          }) : e();
        } catch (n) {
          throw this.annotateError(n), n;
        } finally {
          this._batchDepth--;
        }
        return this;
      });
      __publicField(this, "ignoringUpdates", (e) => {
        let n = this._undos.value, r = this._redos.value;
        this._undos.set(uh()), this._redos.set(uh());
        try {
          ({ undos: n, redos: r } = Ca(() => e(n, r)));
        } finally {
          this._undos.set(n), this._redos.set(r);
        }
      });
      __publicField(this, "_undo", ({ pushToRedoStack: e, toMark: n = void 0 }) => (this.ignoringUpdates((r, i) => {
        var _a3;
        if (r.length === 0)
          return {
            undos: r,
            redos: i
          };
        for (; ((_a3 = r.head) == null ? void 0 : _a3.type) === "STOP"; ) {
          const s = r.head;
          if (r = r.tail, e && (i = i.push(s)), s.id === n)
            return this.ctx.emit("change-history", e ? {
              reason: "undo"
            } : {
              reason: "bail",
              markId: n
            }), {
              undos: r,
              redos: i
            };
        }
        if (r.length === 0)
          return this.ctx.emit("change-history", e ? {
            reason: "undo"
          } : {
            reason: "bail",
            markId: n
          }), {
            undos: r,
            redos: i
          };
        for (; r.head; ) {
          const s = r.head;
          if (r = r.tail, e && (i = i.push(s)), s.type === "STOP") {
            if (s.onUndo && (!n || s.id === n))
              return this.ctx.emit("change-history", e ? {
                reason: "undo"
              } : {
                reason: "bail",
                markId: n
              }), {
                undos: r,
                redos: i
              };
          } else
            this._commands[s.name].undo(s.data);
        }
        return this.ctx.emit("change-history", e ? {
          reason: "undo"
        } : {
          reason: "bail",
          markId: n
        }), {
          undos: r,
          redos: i
        };
      }), this));
      __publicField(this, "undo", () => (this._undo({
        pushToRedoStack: true
      }), this));
      __publicField(this, "redo", () => (this.ignoringUpdates((e, n) => {
        var _a3;
        if (n.length === 0)
          return {
            undos: e,
            redos: n
          };
        for (; ((_a3 = n.head) == null ? void 0 : _a3.type) === "STOP"; )
          e = e.push(n.head), n = n.tail;
        if (n.length === 0)
          return this.ctx.emit("change-history", {
            reason: "redo"
          }), {
            undos: e,
            redos: n
          };
        for (; n.head; ) {
          const r = n.head;
          if (e = e.push(n.head), n = n.tail, r.type === "STOP") {
            if (r.onRedo)
              break;
          } else {
            const i = this._commands[r.name];
            i.redo ? i.redo(r.data) : i.do(r.data);
          }
        }
        return this.ctx.emit("change-history", {
          reason: "redo"
        }), {
          undos: e,
          redos: n
        };
      }), this));
      __publicField(this, "bail", () => (this._undo({
        pushToRedoStack: false
      }), this));
      __publicField(this, "bailToMark", (e) => (this._undo({
        pushToRedoStack: false,
        toMark: e
      }), this));
      __publicField(this, "mark", (e = wn(), n = true, r = true) => {
        const i = this._undos.value.head;
        return i && i.type === "STOP" && i.id === e && i.onUndo === n && i.onRedo === r ? i.id : (this._undos.update((s) => s.push({
          type: "STOP",
          id: e,
          onUndo: n,
          onRedo: r
        })), this.ctx.emit("mark-history", {
          id: e
        }), e);
      });
      this.ctx = e, this.annotateError = n;
    }
    get numUndos() {
      return this._undos.value.length;
    }
    get numRedos() {
      return this._redos.value.length;
    }
    clear() {
      this._undos.set(uh()), this._redos.set(uh());
    }
  }
  class b_e {
    constructor(e) {
      __publicField(this, "_beforeCreateHandlers", {});
      __publicField(this, "_afterCreateHandlers", {});
      __publicField(this, "_beforeChangeHandlers", {});
      __publicField(this, "_afterChangeHandlers", {});
      __publicField(this, "_beforeDeleteHandlers", {});
      __publicField(this, "_afterDeleteHandlers", {});
      __publicField(this, "_batchCompleteHandlers", []);
      this.editor = e, e.store.onBeforeCreate = (r, i) => {
        const s = this._beforeCreateHandlers[r.typeName];
        if (s) {
          let o = r;
          for (const a of s)
            o = a(o, i);
          return o;
        }
        return r;
      }, e.store.onAfterCreate = (r, i) => {
        const s = this._afterCreateHandlers[r.typeName];
        if (s)
          for (const o of s)
            o(r, i);
      }, e.store.onBeforeChange = (r, i, s) => {
        const o = this._beforeChangeHandlers[i.typeName];
        if (o) {
          let a = i;
          for (const l of o)
            a = l(r, a, s);
          return a;
        }
        return i;
      };
      let n = 0;
      e.store.onAfterChange = (r, i, s) => {
        if (n++, n > 1e3)
          console.error("[CleanupManager.onAfterChange] Maximum update depth exceeded, bailing out.");
        else {
          const o = this._afterChangeHandlers[i.typeName];
          if (o)
            for (const a of o)
              a(r, i, s);
        }
        n--;
      }, e.store.onBeforeDelete = (r, i) => {
        const s = this._beforeDeleteHandlers[r.typeName];
        if (s) {
          for (const o of s)
            if (o(r, i) === false)
              return false;
        }
      }, e.store.onAfterDelete = (r, i) => {
        const s = this._afterDeleteHandlers[r.typeName];
        if (s)
          for (const o of s)
            o(r, i);
      }, e.history.onBatchComplete = () => {
        this._batchCompleteHandlers.forEach((r) => r());
      };
    }
    registerBeforeCreateHandler(e, n) {
      return this._beforeCreateHandlers[e] || (this._beforeCreateHandlers[e] = []), this._beforeCreateHandlers[e].push(n), () => dh(this._beforeCreateHandlers[e], n);
    }
    registerAfterCreateHandler(e, n) {
      return this._afterCreateHandlers[e] || (this._afterCreateHandlers[e] = []), this._afterCreateHandlers[e].push(n), () => dh(this._afterCreateHandlers[e], n);
    }
    registerBeforeChangeHandler(e, n) {
      return this._beforeChangeHandlers[e] || (this._beforeChangeHandlers[e] = []), this._beforeChangeHandlers[e].push(n), () => dh(this._beforeChangeHandlers[e], n);
    }
    registerAfterChangeHandler(e, n) {
      return this._afterChangeHandlers[e] || (this._afterChangeHandlers[e] = []), this._afterChangeHandlers[e].push(n), () => dh(this._afterChangeHandlers[e], n);
    }
    registerBeforeDeleteHandler(e, n) {
      return this._beforeDeleteHandlers[e] || (this._beforeDeleteHandlers[e] = []), this._beforeDeleteHandlers[e].push(n), () => dh(this._beforeDeleteHandlers[e], n);
    }
    registerAfterDeleteHandler(e, n) {
      return this._afterDeleteHandlers[e] || (this._afterDeleteHandlers[e] = []), this._afterDeleteHandlers[e].push(n), () => dh(this._afterDeleteHandlers[e], n);
    }
    registerBatchCompleteHandler(e) {
      return this._batchCompleteHandlers.push(e), () => dh(this._batchCompleteHandlers, e);
    }
  }
  function dh(t, e) {
    const n = t.indexOf(e);
    n >= 0 && t.splice(n, 1);
  }
  var k_e = Object.defineProperty, P_e = Object.getOwnPropertyDescriptor, wf = (t, e, n, r) => {
    for (var i = r > 1 ? void 0 : r ? P_e(e, n) : e, s = t.length - 1, o; s >= 0; s--)
      (o = t[s]) && (i = (r ? o(e, n, i) : o(i)) || i);
    return r && i && k_e(e, n, i), i;
  };
  const We = (t) => Math.round(t * 10 ** 8) / 10 ** 8;
  function mc(t, e, n, r, i) {
    const s = t.filter((a) => (r === "forward" ? a.startNode.id === e : a.endNode.id === e) && We(a.length) === We(n) && ka(a.breadthIntersection[0], a.breadthIntersection[1], i[0], i[1]));
    if (s.length === 0)
      return [];
    const o = /* @__PURE__ */ new Set();
    return s.forEach((a) => {
      const l = r === "forward" ? a.endNode.id : a.startNode.id;
      if (!o.has(l)) {
        o.add(l);
        const c = mc(t, l, n, r, ka(a.breadthIntersection[0], a.breadthIntersection[1], i[0], i[1]));
        s.push(...c);
      }
    }), s;
  }
  function C_e(t) {
    t.sort((e, n) => n.gaps.length - e.gaps.length);
    for (let e = t.length - 1; e > 0; e--) {
      const n = t[e];
      for (let r = e - 1; r >= 0; r--) {
        const i = t[r];
        if (i.direction === n.direction && n.gaps.every((s) => i.gaps.some((o) => We(s.startEdge[0].x) === We(o.startEdge[0].x) && We(s.startEdge[0].y) === We(o.startEdge[0].y) && We(s.startEdge[1].x) === We(o.startEdge[1].x) && We(s.startEdge[1].y) === We(o.startEdge[1].y)) && i.gaps.some((o) => We(s.endEdge[0].x) === We(o.endEdge[0].x) && We(s.endEdge[0].y) === We(o.endEdge[0].y) && We(s.endEdge[1].x) === We(o.endEdge[1].x) && We(s.endEdge[1].y) === We(o.endEdge[1].y)))) {
          t.splice(e, 1);
          break;
        }
      }
    }
  }
  class Qd {
    constructor(e) {
      __publicField(this, "_snapLines", fs("snapLines", void 0));
      this.editor = e;
    }
    get lines() {
      return this._snapLines.value ?? Rc;
    }
    clear() {
      this.lines.length && this._snapLines.set(void 0);
    }
    setLines(e) {
      this._snapLines.set(e);
    }
    get snapPointsCache() {
      const { editor: e } = this;
      return e.store.createComputedCache("snapPoints", (n) => {
        const r = e.getShapePageTransform(n.id);
        return r ? this.editor.getShapeGeometry(n).snapPoints.map((s, o) => {
          const { x: a, y: l } = Se.applyToPoint(r, s);
          return {
            x: a,
            y: l,
            id: `${n.id}:${o}`
          };
        }) : void 0;
      });
    }
    get snapThreshold() {
      return 8 / this.editor.zoomLevel;
    }
    get snappableShapes() {
      const { editor: e } = this, { selectedShapeIds: n, renderingBounds: r } = e, i = [], s = (o) => {
        const a = e.getSortedChildIdsForParent(o);
        for (const l of a) {
          if (n.includes(l))
            continue;
          const c = e.getShape(l);
          if (!c || !e.getShapeUtil(c).canSnap(c))
            continue;
          const d = e.getShapePageBounds(l);
          if (d && r.includes(d)) {
            if (e.isShapeOfType(c, "group")) {
              s(l);
              continue;
            }
            i.push({
              id: l,
              pageBounds: d,
              isClosed: e.getShapeGeometry(c).isClosed
            });
          }
        }
      };
      return s(this.currentCommonAncestor ?? e.currentPageId), i;
    }
    get currentCommonAncestor() {
      return this.editor.findCommonAncestor(this.editor.selectedShapes);
    }
    get snappablePoints() {
      const { snappableShapes: e, snapPointsCache: n } = this, r = [];
      return e.forEach((i) => {
        const s = n.get(i.id);
        s && r.push(...s);
      }), r;
    }
    get visibleGaps() {
      const e = [], n = [];
      let r, i;
      const s = this.snappableShapes.sort((a, l) => a.pageBounds.minX - l.pageBounds.minX);
      for (let a = 0; a < s.length; a++) {
        r = s[a];
        for (let l = a + 1; l < s.length; l++)
          i = s[l], r.pageBounds.maxX < i.pageBounds.minX && Qy(r.pageBounds.minY, r.pageBounds.maxY, i.pageBounds.minY, i.pageBounds.maxY) && e.push({
            startNode: r,
            endNode: i,
            startEdge: [
              new I(r.pageBounds.maxX, r.pageBounds.minY),
              new I(r.pageBounds.maxX, r.pageBounds.maxY)
            ],
            endEdge: [
              new I(i.pageBounds.minX, i.pageBounds.minY),
              new I(i.pageBounds.minX, i.pageBounds.maxY)
            ],
            length: i.pageBounds.minX - r.pageBounds.maxX,
            breadthIntersection: ka(r.pageBounds.minY, r.pageBounds.maxY, i.pageBounds.minY, i.pageBounds.maxY)
          });
      }
      const o = s.sort((a, l) => a.pageBounds.minY - l.pageBounds.minY);
      for (let a = 0; a < o.length; a++) {
        r = o[a];
        for (let l = a + 1; l < o.length; l++)
          i = o[l], r.pageBounds.maxY < i.pageBounds.minY && Qy(r.pageBounds.minX, r.pageBounds.maxX, i.pageBounds.minX, i.pageBounds.maxX) && n.push({
            startNode: r,
            endNode: i,
            startEdge: [
              new I(r.pageBounds.minX, r.pageBounds.maxY),
              new I(r.pageBounds.maxX, r.pageBounds.maxY)
            ],
            endEdge: [
              new I(i.pageBounds.minX, i.pageBounds.minY),
              new I(i.pageBounds.maxX, i.pageBounds.minY)
            ],
            length: i.pageBounds.minY - r.pageBounds.maxY,
            breadthIntersection: ka(r.pageBounds.minX, r.pageBounds.maxX, i.pageBounds.minX, i.pageBounds.maxX)
          });
      }
      return {
        horizontal: e,
        vertical: n
      };
    }
    snapTranslate({ lockedAxis: e, initialSelectionPageBounds: n, initialSelectionSnapPoints: r, dragDelta: i }) {
      var _a3, _b3;
      const { snappablePoints: s, snapThreshold: o } = this, a = n.clone().translate(i), l = r.map(({ x: O, y: S }, w) => ({
        id: "selection:" + w,
        x: O + i.x,
        y: S + i.y
      })), c = s, u = [], d = [], h = new I(o, o);
      this.collectPointSnaps({
        minOffset: h,
        nearestSnapsX: u,
        nearestSnapsY: d,
        otherNodeSnapPoints: c,
        selectionSnapPoints: l
      }), this.collectGapSnaps({
        selectionPageBounds: a,
        nearestSnapsX: u,
        nearestSnapsY: d,
        minOffset: h
      });
      const f = new I(e === "x" ? 0 : ((_a3 = u[0]) == null ? void 0 : _a3.nudge) ?? 0, e === "y" ? 0 : ((_b3 = d[0]) == null ? void 0 : _b3.nudge) ?? 0);
      h.x = 0, h.y = 0, u.length = 0, d.length = 0, l.forEach((O) => {
        O.x += f.x, O.y += f.y;
      }), a.translate(f), this.collectPointSnaps({
        minOffset: h,
        nearestSnapsX: u,
        nearestSnapsY: d,
        otherNodeSnapPoints: c,
        selectionSnapPoints: l
      }), this.collectGapSnaps({
        selectionPageBounds: a,
        nearestSnapsX: u,
        nearestSnapsY: d,
        minOffset: h
      });
      const y = this.getPointSnapLines({
        nearestSnapsX: u,
        nearestSnapsY: d
      }), g = this.getGapSnapLines({
        selectionPageBounds: a,
        nearestSnapsX: u,
        nearestSnapsY: d
      });
      return this._snapLines.set([
        ...g,
        ...y
      ]), {
        nudge: f
      };
    }
    get outlinesInPageSpace() {
      return this.snappableShapes.map(({ id: e, isClosed: n }) => {
        const r = wi(this.editor.getShapeGeometry(e).vertices);
        n && r.push(r[0]);
        const i = this.editor.getShapePageTransform(e);
        if (!i)
          throw Error("No page transform");
        return Se.applyToPoints(i, r);
      });
    }
    getSnappingHandleDelta({ handlePoint: e, additionalSegments: n }) {
      const { outlinesInPageSpace: r, snapThreshold: i } = this;
      let s = i, o = null, a, l, c, u;
      const d = [
        ...r,
        ...n
      ];
      for (const h of d)
        for (let f = 0; f < h.length - 1; f++)
          a = h[f], l = h[f + 1], c = I.NearestPointOnLineSegment(a, l, e), u = I.Dist(e, c), !isNaN(u) && u < s && (s = u, o = c);
      return o ? (this._snapLines.set([
        {
          id: wn(),
          type: "points",
          points: [
            o
          ]
        }
      ]), I.Sub(o, e)) : null;
    }
    snapResize({ initialSelectionPageBounds: e, dragDelta: n, handle: r, isAspectRatioLocked: i, isResizingFromCenter: s }) {
      var _a3, _b3;
      const { snapThreshold: o } = this, { box: a, scaleX: l, scaleY: c } = Te.Resize(e, r, s ? n.x * 2 : n.x, s ? n.y * 2 : n.y, i);
      let u = r;
      l < 0 && (u = ske(u)), c < 0 && (u = ike(u)), s && (a.center = e.center);
      const d = u === "top" || u === "bottom", h = u === "left" || u === "right", f = Q8(u, a), y = this.snappablePoints, g = [], O = [], S = new I(o, o);
      this.collectPointSnaps({
        minOffset: S,
        nearestSnapsX: g,
        nearestSnapsY: O,
        otherNodeSnapPoints: y,
        selectionSnapPoints: f
      });
      const w = new I(d ? 0 : ((_a3 = g[0]) == null ? void 0 : _a3.nudge) ?? 0, h ? 0 : ((_b3 = O[0]) == null ? void 0 : _b3.nudge) ?? 0);
      if (i && oke(u) && w.len() !== 0) {
        const T = g.length && O.length ? Math.abs(w.x) < Math.abs(w.y) ? "x" : "y" : g.length ? "x" : "y", $ = e.aspectRatio;
        T === "x" ? (O.length = 0, w.y = w.x / $, (u === "bottom_left" || u === "top_right") && (w.y = -w.y)) : (g.length = 0, w.x = w.y * $, (u === "bottom_left" || u === "top_right") && (w.x = -w.x));
      }
      const x = I.Add(n, w), { box: P } = Te.Resize(e, r, s ? x.x * 2 : x.x, s ? x.y * 2 : x.y, i);
      s && (P.center = e.center);
      const C = Q8("any", P);
      g.length = 0, O.length = 0, S.x = 0, S.y = 0, this.collectPointSnaps({
        minOffset: S,
        nearestSnapsX: g,
        nearestSnapsY: O,
        otherNodeSnapPoints: y,
        selectionSnapPoints: C
      });
      const _ = this.getPointSnapLines({
        nearestSnapsX: g,
        nearestSnapsY: O
      });
      return this._snapLines.set([
        ..._
      ]), {
        nudge: w
      };
    }
    collectPointSnaps({ selectionSnapPoints: e, otherNodeSnapPoints: n, minOffset: r, nearestSnapsX: i, nearestSnapsY: s }) {
      for (const o of e)
        for (const a of n) {
          const l = I.Sub(o, a), c = Math.abs(l.x), u = Math.abs(l.y);
          We(c) <= We(r.x) && (We(c) < We(r.x) && (i.length = 0), i.push({
            type: "points",
            points: {
              thisPoint: o,
              otherPoint: a
            },
            nudge: a.x - o.x
          }), r.x = c), We(u) <= We(r.y) && (We(u) < We(r.y) && (s.length = 0), s.push({
            type: "points",
            points: {
              thisPoint: o,
              otherPoint: a
            },
            nudge: a.y - o.y
          }), r.y = u);
        }
    }
    collectGapSnaps({ selectionPageBounds: e, minOffset: n, nearestSnapsX: r, nearestSnapsY: i }) {
      const { horizontal: s, vertical: o } = this.visibleGaps;
      for (const a of s) {
        if (!Qy(a.breadthIntersection[0], a.breadthIntersection[1], e.minY, e.maxY))
          continue;
        const c = a.startEdge[0].x + a.length / 2 - e.center.x;
        if (a.length > e.width && We(Math.abs(c)) <= We(n.x)) {
          We(Math.abs(c)) < We(n.x) && (r.length = 0), n.x = Math.abs(c);
          const S = {
            type: "gap_center",
            gap: a,
            nudge: c
          }, w = r.find(({ type: P }) => P === "gap_center"), x = w && ka(a.breadthIntersection[0], a.breadthIntersection[1], w.gap.breadthIntersection[0], w.gap.breadthIntersection[1]);
          w && w.gap.length > a.length && x ? r[r.indexOf(w)] = S : (!w || !x) && r.push(S);
        }
        const d = a.startNode.pageBounds.minX - a.length, h = e.maxX, f = d - h;
        We(Math.abs(f)) <= We(n.x) && (We(Math.abs(f)) < We(n.x) && (r.length = 0), n.x = Math.abs(f), r.push({
          type: "gap_duplicate",
          gap: a,
          protrusionDirection: "left",
          nudge: f
        }));
        const y = a.endNode.pageBounds.maxX + a.length, g = e.minX, O = y - g;
        We(Math.abs(O)) <= We(n.x) && (We(Math.abs(O)) < We(n.x) && (r.length = 0), n.x = Math.abs(O), r.push({
          type: "gap_duplicate",
          gap: a,
          protrusionDirection: "right",
          nudge: O
        }));
      }
      for (const a of o) {
        if (!Qy(a.breadthIntersection[0], a.breadthIntersection[1], e.minX, e.maxX))
          continue;
        const c = a.startEdge[0].y + a.length / 2 - e.center.y;
        if (a.length > e.height && We(Math.abs(c)) <= We(n.y)) {
          We(Math.abs(c)) < We(n.y) && (i.length = 0), n.y = Math.abs(c);
          const S = {
            type: "gap_center",
            gap: a,
            nudge: c
          }, w = i.find(({ type: P }) => P === "gap_center"), x = w && Qy(w.gap.breadthIntersection[0], w.gap.breadthIntersection[1], a.breadthIntersection[0], a.breadthIntersection[1]);
          w && w.gap.length > a.length && x ? i[i.indexOf(w)] = S : (!w || !x) && i.push(S);
          continue;
        }
        const d = a.startNode.pageBounds.minY - a.length, h = e.maxY, f = d - h;
        We(Math.abs(f)) <= We(n.y) && (We(Math.abs(f)) < We(n.y) && (i.length = 0), n.y = Math.abs(f), i.push({
          type: "gap_duplicate",
          gap: a,
          protrusionDirection: "top",
          nudge: f
        }));
        const y = a.endNode.pageBounds.maxY + a.length, g = e.minY, O = y - g;
        We(Math.abs(O)) <= We(n.y) && (We(Math.abs(O)) < We(n.y) && (i.length = 0), n.y = Math.abs(O), i.push({
          type: "gap_duplicate",
          gap: a,
          protrusionDirection: "bottom",
          nudge: O
        }));
      }
    }
    getPointSnapLines({ nearestSnapsX: e, nearestSnapsY: n }) {
      const r = {}, i = {};
      if (e.length > 0) {
        for (const s of e)
          if (s.type === "points") {
            const o = We(s.points.otherPoint.x);
            r[o] || (r[o] = []), r[o].push(s.points);
          }
      }
      if (n.length > 0) {
        for (const s of n)
          if (s.type === "points") {
            const o = We(s.points.otherPoint.y);
            i[o] || (i[o] = []), i[o].push(s.points);
          }
      }
      return Object.values(r).concat(Object.values(i)).map((s) => ({
        id: wn(),
        type: "points",
        points: hk(s.map((o) => I.From(o.otherPoint)).concat(s.map((o) => I.From(o.thisPoint))), (o, a) => o.equals(a))
      }));
    }
    getGapSnapLines({ selectionPageBounds: e, nearestSnapsX: n, nearestSnapsY: r }) {
      const { vertical: i, horizontal: s } = this.visibleGaps, o = {
        top: e.sides[0],
        right: e.sides[1],
        bottom: [
          e.corners[3],
          e.corners[2]
        ],
        left: [
          e.corners[0],
          e.corners[3]
        ]
      }, a = [];
      if (n.length > 0)
        for (const l of n) {
          if (l.type === "points")
            continue;
          const { gap: { breadthIntersection: c, startEdge: u, startNode: d, endNode: h, length: f, endEdge: y } } = l;
          switch (l.type) {
            case "gap_center": {
              const g = (f - e.width) / 2, O = ka(c[0], c[1], e.minY, e.maxY);
              a.push({
                type: "gaps",
                direction: "horizontal",
                id: wn(),
                gaps: [
                  ...mc(s, d.id, g, "backward", O),
                  {
                    startEdge: u,
                    endEdge: o.left
                  },
                  {
                    startEdge: o.right,
                    endEdge: y
                  },
                  ...mc(s, h.id, g, "forward", O)
                ]
              });
              break;
            }
            case "gap_duplicate": {
              const g = ka(c[0], c[1], e.minY, e.maxY);
              a.push({
                type: "gaps",
                direction: "horizontal",
                id: wn(),
                gaps: l.protrusionDirection === "left" ? [
                  {
                    startEdge: o.right,
                    endEdge: u.map((O) => O.clone().addXY(-d.pageBounds.width, 0))
                  },
                  {
                    startEdge: u,
                    endEdge: y
                  },
                  ...mc(s, h.id, f, "forward", g)
                ] : [
                  ...mc(s, d.id, f, "backward", g),
                  {
                    startEdge: u,
                    endEdge: y
                  },
                  {
                    startEdge: y.map((O) => O.clone().addXY(l.gap.endNode.pageBounds.width, 0)),
                    endEdge: o.left
                  }
                ]
              });
              break;
            }
          }
        }
      if (r.length > 0)
        for (const l of r) {
          if (l.type === "points")
            continue;
          const { gap: { breadthIntersection: c, startEdge: u, startNode: d, endNode: h, length: f, endEdge: y } } = l;
          switch (l.type) {
            case "gap_center": {
              const g = (f - e.height) / 2, O = ka(c[0], c[1], e.minX, e.maxX);
              a.push({
                type: "gaps",
                direction: "vertical",
                id: wn(),
                gaps: [
                  ...mc(i, d.id, g, "backward", O),
                  {
                    startEdge: u,
                    endEdge: o.top
                  },
                  {
                    startEdge: o.bottom,
                    endEdge: y
                  },
                  ...mc(i, l.gap.endNode.id, g, "forward", O)
                ]
              });
              break;
            }
            case "gap_duplicate":
              {
                const g = ka(c[0], c[1], e.minX, e.maxX);
                a.push({
                  type: "gaps",
                  direction: "vertical",
                  id: wn(),
                  gaps: l.protrusionDirection === "top" ? [
                    {
                      startEdge: o.bottom,
                      endEdge: u.map((O) => O.clone().addXY(0, -d.pageBounds.height))
                    },
                    {
                      startEdge: u,
                      endEdge: y
                    },
                    ...mc(i, h.id, f, "forward", g)
                  ] : [
                    ...mc(i, d.id, f, "backward", g),
                    {
                      startEdge: u,
                      endEdge: y
                    },
                    {
                      startEdge: y.map((O) => O.clone().addXY(0, h.pageBounds.height)),
                      endEdge: o.top
                    }
                  ]
                });
              }
              break;
          }
        }
      return C_e(a), a;
    }
  }
  wf([
    ve
  ], Qd.prototype, "snapPointsCache", 1);
  wf([
    ve
  ], Qd.prototype, "snapThreshold", 1);
  wf([
    ve
  ], Qd.prototype, "snappableShapes", 1);
  wf([
    ve
  ], Qd.prototype, "currentCommonAncestor", 1);
  wf([
    ve
  ], Qd.prototype, "snappablePoints", 1);
  wf([
    ve
  ], Qd.prototype, "visibleGaps", 1);
  wf([
    ve
  ], Qd.prototype, "outlinesInPageSpace", 1);
  function Q8(t, e) {
    const { minX: n, maxX: r, minY: i, maxY: s } = e, o = [];
    switch (t) {
      case "top":
      case "left":
      case "top_left":
      case "any":
        o.push({
          id: "top_left",
          handle: "top_left",
          x: n,
          y: i
        });
    }
    switch (t) {
      case "top":
      case "right":
      case "top_right":
      case "any":
        o.push({
          id: "top_right",
          handle: "top_right",
          x: r,
          y: i
        });
    }
    switch (t) {
      case "bottom":
      case "right":
      case "bottom_right":
      case "any":
        o.push({
          id: "bottom_right",
          handle: "bottom_right",
          x: r,
          y: s
        });
    }
    switch (t) {
      case "bottom":
      case "left":
      case "bottom_left":
      case "any":
        o.push({
          id: "bottom_left",
          handle: "bottom_left",
          x: n,
          y: s
        });
    }
    return o;
  }
  const __e = /\r?\n|\r/g;
  function z8(t) {
    return t.replace(__e, `
`).split(`
`).map((e) => e || " ").join(`
`);
  }
  const T_e = {
    start: "left",
    "start-legacy": "left",
    middle: "center",
    "middle-legacy": "center",
    end: "right",
    "end-legacy": "right"
  }, E_e = /\s/;
  class I_e {
    constructor(e) {
      __publicField(this, "measureText", (e, n) => {
        const r = this.getTextElement();
        r.setAttribute("dir", "ltr"), r.style.setProperty("font-family", n.fontFamily), r.style.setProperty("font-style", n.fontStyle), r.style.setProperty("font-weight", n.fontWeight), r.style.setProperty("font-size", n.fontSize + "px"), r.style.setProperty("line-height", n.lineHeight * n.fontSize + "px"), r.style.setProperty("max-width", n.maxWidth === null ? null : n.maxWidth + "px"), r.style.setProperty("min-width", n.minWidth ?? null), r.style.setProperty("padding", n.padding), r.textContent = z8(e);
        const i = r.getBoundingClientRect();
        return {
          x: 0,
          y: 0,
          w: i.width,
          h: i.height
        };
      });
      this.editor = e;
    }
    getTextElement() {
      var _a3;
      (_a3 = document.querySelector(".tl-text-measure")) == null ? void 0 : _a3.remove();
      const n = document.createElement("div");
      return this.editor.getContainer().appendChild(n), n.id = `__textMeasure_${wn()}`, n.classList.add("tl-text"), n.classList.add("tl-text-measure"), n.tabIndex = -1, n;
    }
    measureElementTextNodeSpans(e, { shouldTruncateToFirstLine: n = false } = {}) {
      const r = [], i = e.getBoundingClientRect(), s = -i.left, o = -i.top, a = new Range(), l = e.childNodes[0];
      let c = 0, u = null, d = null, h = 0, f = false;
      for (const y of e.childNodes)
        if (y.nodeType === Node.TEXT_NODE)
          for (const g of y.textContent ?? "") {
            a.setStart(l, c), a.setEnd(l, c + g.length);
            const O = a.getClientRects(), S = O[O.length - 1], w = S.top + o, x = S.left + s, P = S.right + s, C = E_e.test(g);
            if (C !== d || w !== h || !u) {
              if (u) {
                if (n && w !== h) {
                  f = true;
                  break;
                }
                r.push(u);
              }
              u = {
                box: {
                  x,
                  y: w,
                  w: S.width,
                  h: S.height
                },
                text: g
              };
            } else
              u.box.w = P - u.box.x, u.text += g;
            d = C, h = w, c += g.length;
          }
      return u && r.push(u), {
        spans: r,
        didTruncate: f
      };
    }
    measureTextSpans(e, n) {
      if (e === "")
        return [];
      const r = n.overflow === "truncate-ellipsis" || n.overflow === "truncate-clip", i = this.getTextElement(), s = Math.ceil(n.width - n.padding * 2);
      i.style.setProperty("width", `${s}px`), i.style.setProperty("height", "min-content"), i.style.setProperty("dir", "ltr"), i.style.setProperty("font-size", `${n.fontSize}px`), i.style.setProperty("font-family", n.fontFamily), i.style.setProperty("font-weight", n.fontWeight), i.style.setProperty("line-height", `${n.lineHeight * n.fontSize}px`), i.style.setProperty("text-align", T_e[n.textAlign]), r && (i.style.setProperty("overflow-wrap", "anywhere"), i.style.setProperty("word-break", "break-all")), e = z8(e), i.textContent = e;
      const { spans: o, didTruncate: a } = this.measureElementTextNodeSpans(i, {
        shouldTruncateToFirstLine: r
      });
      if (n.overflow === "truncate-ellipsis" && a) {
        i.textContent = "\u2026";
        const l = Math.ceil(this.measureElementTextNodeSpans(i).spans[0].box.w);
        i.style.setProperty("width", `${s - l}px`), i.textContent = e;
        const c = this.measureElementTextNodeSpans(i, {
          shouldTruncateToFirstLine: true
        }).spans, u = c[c.length - 1];
        return c.push({
          text: "\u2026",
          box: {
            x: Math.min(u.box.x + u.box.w, n.width - n.padding - l),
            y: u.box.y,
            w: l,
            h: u.box.h
          }
        }), c;
      }
      return i.remove(), o;
    }
  }
  class $_e {
    constructor(e) {
      __publicField(this, "raf");
      __publicField(this, "isPaused", true);
      __publicField(this, "last", 0);
      __publicField(this, "t", 0);
      __publicField(this, "start", () => {
        this.isPaused = false, cancelAnimationFrame(this.raf), this.raf = requestAnimationFrame(this.tick), this.last = Date.now();
      });
      __publicField(this, "tick", () => {
        if (this.isPaused)
          return;
        const e = Date.now(), n = e - this.last;
        if (this.last = e, this.t += n, this.editor.emit("frame", n), this.t < 16) {
          this.raf = requestAnimationFrame(this.tick);
          return;
        }
        this.t -= 16, this.updatePointerVelocity(n), this.editor.emit("tick", n), this.raf = requestAnimationFrame(this.tick);
      });
      __publicField(this, "dispose", () => {
        this.isPaused = true, cancelAnimationFrame(this.raf);
      });
      __publicField(this, "prevPoint", new I());
      __publicField(this, "updatePointerVelocity", (e) => {
        const { prevPoint: n, editor: { inputs: { currentScreenPoint: r, pointerVelocity: i } } } = this;
        if (e === 0)
          return;
        const s = I.Sub(r, n);
        this.prevPoint = r.clone();
        const o = s.len(), a = o ? s.div(o) : new I(0, 0), l = i.clone().lrp(a.mul(o / e), 0.5);
        Math.abs(l.x) < 0.01 && (l.x = 0), Math.abs(l.y) < 0.01 && (l.y = 0), i.equals(l) || (this.editor.inputs.pointerVelocity = l);
      });
      this.editor = e, this.editor.disposables.add(this.dispose), this.start();
    }
  }
  var A_e = Object.defineProperty, R_e = Object.getOwnPropertyDescriptor, zd = (t, e, n, r) => {
    for (var i = r > 1 ? void 0 : r ? R_e(e, n) : e, s = t.length - 1, o; s >= 0; s--)
      (o = t[s]) && (i = (r ? o(e, n, i) : o(i)) || i);
    return r && i && A_e(e, n, i), i;
  };
  class ru {
    constructor(e, n) {
      __publicField(this, "updateUserPreferences", (e) => {
        this.user.setUserPreferences({
          ...this.user.userPreferences.value,
          ...e
        });
      });
      this.user = e, this.inferDarkMode = n;
    }
    get userPreferences() {
      return {
        id: this.id,
        name: this.name,
        locale: this.locale,
        color: this.color,
        isDarkMode: this.isDarkMode,
        animationSpeed: this.animationSpeed,
        isSnapMode: this.isSnapMode
      };
    }
    get isDarkMode() {
      return this.user.userPreferences.value.isDarkMode ?? (this.inferDarkMode ? X2e() : false);
    }
    get animationSpeed() {
      return this.user.userPreferences.value.animationSpeed ?? Ys.animationSpeed;
    }
    get id() {
      return this.user.userPreferences.value.id;
    }
    get name() {
      return this.user.userPreferences.value.name ?? Ys.name;
    }
    get locale() {
      return this.user.userPreferences.value.locale ?? Ys.locale;
    }
    get color() {
      return this.user.userPreferences.value.color ?? Ys.color;
    }
    get isSnapMode() {
      return this.user.userPreferences.value.isSnapMode ?? Ys.isSnapMode;
    }
  }
  zd([
    ve
  ], ru.prototype, "userPreferences", 1);
  zd([
    ve
  ], ru.prototype, "isDarkMode", 1);
  zd([
    ve
  ], ru.prototype, "animationSpeed", 1);
  zd([
    ve
  ], ru.prototype, "id", 1);
  zd([
    ve
  ], ru.prototype, "name", 1);
  zd([
    ve
  ], ru.prototype, "locale", 1);
  zd([
    ve
  ], ru.prototype, "color", 1);
  zd([
    ve
  ], ru.prototype, "isSnapMode", 1);
  function Fy(t) {
    return Math.abs(t.props.bend) < 8;
  }
  function Rk(t, e) {
    if (e.type === "point")
      return;
    const n = t.getShape(e.boundShapeId), r = t.getShapePageTransform(n), i = t.getShapeGeometry(n), s = i instanceof Yu ? i.children[0].vertices : i.vertices;
    return {
      shape: n,
      transform: r,
      isClosed: i.isClosed,
      isExact: e.isExact,
      didIntersect: false,
      outline: s
    };
  }
  function F8(t, e, n) {
    if (n.type === "point")
      return I.From(n);
    const r = t.getShape(n.boundShapeId);
    if (r) {
      const { point: i, size: s } = t.getShapeGeometry(r).bounds, o = I.Add(i, I.MulV(n.normalizedAnchor, s)), a = Se.applyToPoint(t.getShapePageTransform(r), o);
      return Se.applyToPoint(Se.Inverse(e), a);
    } else
      return new I(0, 0);
  }
  function Ia(t, e) {
    const n = t.getShapePageTransform(e), r = F8(t, n, e.props.start), i = F8(t, n, e.props.end);
    return {
      start: r,
      end: i
    };
  }
  const Kp = 32, Mk = 10, M_e = 10, Gu = {
    s: 2,
    m: 3.5,
    l: 5,
    xl: 10
  };
  function q0(t, e) {
    const { start: n, end: r, arrowheadStart: i, arrowheadEnd: s } = e.props, o = Ia(t, e), a = o.start.clone(), l = o.end.clone(), c = I.Med(a, l), u = I.Sub(l, a).uni(), d = Rk(t, n), h = Rk(t, r), f = t.getShapePageTransform(e);
    B8(l, o.start, f, h), B8(a, o.end, f, d);
    let y = 0, g = 0;
    const O = d && h && d.shape === h.shape;
    d && h && !O && !d.isExact && !h.isExact && (h.didIntersect && !d.didIntersect ? d.isClosed && a.setTo(l.clone().add(u.clone().mul(Kp))) : h.didIntersect || h.isClosed && l.setTo(a.clone().sub(u.clone().mul(Kp))));
    const S = I.Sub(l, a).uni(), w = !I.Equals(S, u);
    O || (d && i !== "none" && !d.isExact && (y = Mk + Gu[e.props.size] / 2 + ("size" in d.shape.props ? Gu[d.shape.props.size] / 2 : 0)), h && s !== "none" && !h.isExact && (g = Mk + Gu[e.props.size] / 2 + ("size" in h.shape.props ? Gu[h.shape.props.size] / 2 : 0)));
    const x = a.clone().add(S.clone().mul(y * (w ? -1 : 1))), P = l.clone().sub(S.clone().mul(g * (w ? -1 : 1))), C = I.Dist(x, P);
    C < Kp && (y !== 0 && g !== 0 ? (y *= -1.5, g *= -1.5) : y !== 0 ? y *= -2 : g !== 0 ? g *= -2 : C < 10 && (d ? y = -(10 - C) : h && (g = -(10 - C)))), a.add(S.clone().mul(y * (w ? -1 : 1))), l.sub(S.clone().mul(g * (w ? -1 : 1))), w ? (d && h && l.setTo(I.Add(a, S.clone().mul(-Kp))), c.setTo(I.Med(o.start, o.end))) : c.setTo(I.Med(a, l));
    const _ = I.Dist(a, l);
    return {
      isStraight: true,
      start: {
        handle: o.start,
        point: a,
        arrowhead: e.props.arrowheadStart
      },
      end: {
        handle: o.end,
        point: l,
        arrowhead: e.props.arrowheadEnd
      },
      middle: c,
      isValid: _ > 0,
      length: _
    };
  }
  function B8(t, e, n, r) {
    if (r === void 0 || r.isExact)
      return;
    const i = Se.applyToPoint(n, e), s = Se.applyToPoint(n, t), o = Se.applyToPoint(Se.Inverse(r.transform), i), a = Se.applyToPoint(Se.Inverse(r.transform), s), l = r.isClosed, u = (l ? K2e : KG)(o, a, r.outline);
    let d;
    if (u !== null && (d = u.sort((y, g) => I.Dist(y, o) - I.Dist(g, o))[0] ?? (l ? void 0 : a)), d === void 0)
      return;
    const h = Se.applyToPoint(r.transform, d), f = Se.applyToPoint(Se.Inverse(n), h);
    t.setTo(f), r.didIntersect = true;
  }
  function D_e(t) {
    return aq(t.start.handle, t.end.handle);
  }
  function IE(t) {
    return aq(t.start.point, t.end.point);
  }
  function aq(t, e) {
    return `M${t.x},${t.y}L${e.x},${e.y}`;
  }
  function $E(t, e, n = 0) {
    const { arrowheadEnd: r, arrowheadStart: i } = e.props, s = e.props.bend + n;
    if (Math.abs(s) > Math.abs(e.props.bend * M_e))
      return q0(t, e);
    const o = Ia(t, e), a = I.Med(o.start, o.end), l = I.Sub(o.end, o.start).uni(), c = I.Add(a, l.per().mul(-s)), u = Rk(t, e.props.start), d = Rk(t, e.props.end), h = o.start.clone(), f = o.end.clone(), y = c.clone(), g = e.props.bend < 0, O = g ? _C : lke, S = U8(h, f, y), w = I.Angle(S.center, h), x = I.Angle(S.center, f), P = O(w, x);
    if (S.length === 0 || S.size === 0 || !l8(S.length) || !l8(S.size))
      return q0(t, e);
    const C = h.clone(), _ = f.clone(), T = y.clone(), $ = t.getShapePageTransform(e);
    let N = 0, L = 0;
    if (u && !u.isExact) {
      const H = Se.applyToPoint($, C), te = Se.applyToPoint($, S.center), se = Se.applyToPoint($, _), ae = Se.Inverse(u.transform), _e3 = Se.applyToPoint(ae, H), Me = Se.applyToPoint(ae, te), ke = Se.applyToPoint(ae, se), { isClosed: tt } = u, it = tt ? $8 : A8;
      let pt, kt = it(Me, S.radius, u.outline);
      if (kt) {
        const Yt = Me.angle(_e3), Ar = Me.angle(ke), Cn = O(Yt, Ar);
        kt = kt.filter((Lt) => O(Yt, Me.angle(Lt)) <= Cn);
        const Vn = Cn * 0.25;
        kt.sort(tt ? (Lt, tr) => Math.abs(O(Yt, Me.angle(Lt)) - Vn) < Math.abs(O(Yt, Me.angle(tr)) - Vn) ? -1 : 1 : (Lt, tr) => O(Yt, Me.angle(Lt)) < O(Yt, Me.angle(tr)) ? -1 : 1), pt = kt[0] ?? (tt ? void 0 : _e3);
      } else
        pt = tt ? void 0 : _e3;
      pt && (C.setTo(t.getPointInShapeSpace(e, Se.applyToPoint(u.transform, pt))), u.didIntersect = true, i !== "none" && (N = Mk + Gu[e.props.size] / 2 + ("size" in u.shape.props ? Gu[u.shape.props.size] / 2 : 0)));
    }
    if (d && !d.isExact) {
      const H = Se.applyToPoint($, C), te = Se.applyToPoint($, _), se = Se.applyToPoint($, S.center), ae = Se.Inverse(d.transform), _e3 = Se.applyToPoint(ae, H), Me = Se.applyToPoint(ae, se), ke = Se.applyToPoint(ae, te), tt = d.isClosed, it = tt ? $8 : A8;
      let pt, kt = it(Me, S.radius, d.outline);
      if (kt) {
        const Yt = Me.angle(_e3), Ar = Me.angle(ke), Cn = O(Yt, Ar), Vn = Cn * 0.75;
        kt = kt.filter((Lt) => O(Yt, Me.angle(Lt)) <= Cn), kt.sort(tt ? (Lt, tr) => Math.abs(O(Yt, Me.angle(Lt)) - Vn) < Math.abs(O(Yt, Me.angle(tr)) - Vn) ? -1 : 1 : (Lt, tr) => O(Yt, Me.angle(Lt)) < O(Yt, Me.angle(tr)) ? -1 : 1), kt[0] ? pt = kt[0] : pt = tt ? void 0 : ke;
      } else
        pt = tt ? void 0 : ke;
      pt && (_.setTo(t.getPointInShapeSpace(e, Se.applyToPoint(d.transform, pt))), d.didIntersect = true, r !== "none" && (L = Mk + Gu[e.props.size] / 2 + ("size" in d.shape.props ? Gu[d.shape.props.size] / 2 : 0)));
    }
    let z = I.Angle(S.center, C), M = I.Angle(S.center, _), R = O(z, M), F = R * S.radius;
    const Q = C.clone(), X = _.clone();
    if (N !== 0) {
      const H = N / F * (g ? 1 : -1), te = I.FromAngle(z + R * H);
      Q.setTo(S.center).add(te.mul(S.radius));
    }
    if (L !== 0) {
      const H = L / F * (g ? -1 : 1), te = I.FromAngle(M + R * H);
      X.setTo(S.center).add(te.mul(S.radius));
    }
    const Z = I.Dist(Q, X);
    if (Z < Kp && (N !== 0 && L !== 0 ? (N *= -1.5, L *= -1.5) : N !== 0 ? N *= -2 : L !== 0 ? L *= -2 : Z < 10 && (u ? N = -(10 - Z) : d && (L = -(10 - Z)))), N !== 0) {
      const H = N / F * (g ? 1 : -1), te = I.FromAngle(z + R * H);
      C.setTo(S.center).add(te.mul(S.radius));
    }
    if (L !== 0) {
      const H = L / F * (g ? -1 : 1), te = I.FromAngle(M + R * H);
      _.setTo(S.center).add(te.mul(S.radius));
    }
    if (u && d && !u.isExact && !d.isExact) {
      if (z = I.Angle(S.center, C), M = I.Angle(S.center, _), R = O(z, M), F = R * S.radius, u.shape === d.shape)
        F < 100 && (C.setTo(h), _.setTo(f), T.setTo(y));
      else if (u && !u.didIntersect && C.setTo(h), d && !d.didIntersect || O(w, z) > O(w, M)) {
        const H = Math.min(0.9, Kp / F) * (g ? 1 : -1), te = I.FromAngle(z + R * H);
        _.setTo(S.center).add(te.mul(S.radius));
      }
    }
    j_e(S.center, S.radius, C, _, T, P, g), C.equals(_) && (C.setTo(T.clone().addXY(1, 1)), _.setTo(T.clone().subXY(1, 1))), h.setTo(C), f.setTo(_), y.setTo(T);
    const U = U8(h, f, y);
    return {
      isStraight: false,
      start: {
        point: h,
        handle: o.start,
        arrowhead: e.props.arrowheadStart
      },
      end: {
        point: f,
        handle: o.end,
        arrowhead: e.props.arrowheadEnd
      },
      middle: y,
      handleArc: S,
      bodyArc: U,
      isValid: U.length !== 0 && isFinite(U.center.x) && isFinite(U.center.y)
    };
  }
  function L_e(t) {
    const { start: e, end: n, handleArc: { radius: r, largeArcFlag: i, sweepFlag: s } } = t;
    return `M${e.handle.x},${e.handle.y} A${r} ${r} 0 ${i} ${s} ${n.handle.x},${n.handle.y}`;
  }
  function AE(t) {
    const { start: e, end: n, bodyArc: { radius: r, largeArcFlag: i, sweepFlag: s } } = t;
    return `M${e.point.x},${e.point.y} A${r} ${r} 0 ${i} ${s} ${n.point.x},${n.point.y}`;
  }
  function U8(t, e, n) {
    const r = -2 * (t.x * (e.y - n.y) - t.y * (e.x - n.x) + e.x * n.y - n.x * e.y), i = {
      x: ((t.x * t.x + t.y * t.y) * (n.y - e.y) + (e.x * e.x + e.y * e.y) * (t.y - n.y) + (n.x * n.x + n.y * n.y) * (e.y - t.y)) / r,
      y: ((t.x * t.x + t.y * t.y) * (e.x - n.x) + (e.x * e.x + e.y * e.y) * (n.x - t.x) + (n.x * n.x + n.y * n.y) * (t.x - e.x)) / r
    }, s = I.Dist(i, t), o = +I.Clockwise(t, n, e), a = Math.hypot(t.y - e.y, t.x - e.x), l = Math.hypot(e.y - n.y, e.x - n.x), c = Math.hypot(n.y - t.y, n.x - t.x), u = Math.acos((l * l + c * c - a * a) / (2 * l * c)) * 2, d = +(zt > u), h = (Bt - u) * (o ? 1 : -1), f = h * s;
    return {
      center: i,
      radius: s,
      size: h,
      length: f,
      largeArcFlag: d,
      sweepFlag: o
    };
  }
  function j_e(t, e, n, r, i, s, o) {
    const a = I.Angle(t, n), l = I.Angle(t, r);
    let c = _C(a, l);
    o || (c = Bt - c);
    const u = 0.5 * (o ? 1 : -1), d = I.FromAngle(a + c * u);
    if (i.setTo(t).add(d.mul(e)), c > s) {
      i.rotWith(t, zt);
      const h = r.clone();
      r.setTo(n), n.setTo(h);
    }
  }
  const N_e = {
    wheel: "onWheel",
    pointer_down: "onPointerDown",
    pointer_move: "onPointerMove",
    pointer_up: "onPointerUp",
    right_click: "onRightClick",
    middle_click: "onMiddleClick",
    key_down: "onKeyDown",
    key_up: "onKeyUp",
    key_repeat: "onKeyRepeat",
    cancel: "onCancel",
    complete: "onComplete",
    interrupt: "onInterrupt",
    double_click: "onDoubleClick",
    triple_click: "onTripleClick",
    quadruple_click: "onQuadrupleClick"
  };
  var Q_e = Object.defineProperty, z_e = Object.getOwnPropertyDescriptor, F_e = (t, e, n, r) => {
    for (var i = r > 1 ? void 0 : r ? z_e(e, n) : e, s = t.length - 1, o; s >= 0; s--)
      (o = t[s]) && (i = (r ? o(e, n, i) : o(i)) || i);
    return r && i && Q_e(e, n, i), i;
  };
  class ze {
    constructor(e, n) {
      __publicField(this, "path");
      __publicField(this, "id");
      __publicField(this, "current");
      __publicField(this, "type");
      __publicField(this, "shapeType");
      __publicField(this, "initial");
      __publicField(this, "children");
      __publicField(this, "parent");
      __publicField(this, "isActive", false);
      __publicField(this, "transition", (e, n) => {
        var _a3;
        const r = e.split(".");
        let i = this;
        for (let s = 0; s < r.length; s++) {
          const o = r[s], a = i.current.value, l = (_a3 = i.children) == null ? void 0 : _a3[o];
          if (!l)
            throw Error(`${i.id} - no child state exists with the id ${o}.`);
          if ((a == null ? void 0 : a.id) !== l.id && (a == null ? void 0 : a.exit(n, o), i.current.set(l), l.enter(n, (a == null ? void 0 : a.id) || "initial"), !l.isActive))
            break;
          i = l;
        }
        return this;
      });
      __publicField(this, "handleEvent", (e) => {
        var _a3;
        const n = N_e[e.name], r = this.current.value;
        (_a3 = this[n]) == null ? void 0 : _a3.call(this, e), this.current.value === r && this.isActive && (r == null ? void 0 : r.handleEvent(e));
      });
      __publicField(this, "enter", (e, n) => {
        var _a3;
        if (this.isActive = true, (_a3 = this.onEnter) == null ? void 0 : _a3.call(this, e, n), this.children && this.initial && this.isActive) {
          const r = this.children[this.initial];
          this.current.set(r), r.enter(e, n);
        }
      });
      __publicField(this, "exit", (e, n) => {
        var _a3, _b3;
        this.isActive = false, (_a3 = this.onExit) == null ? void 0 : _a3.call(this, e, n), this.isActive || ((_b3 = this.current.value) == null ? void 0 : _b3.exit(e, n));
      });
      __publicField(this, "_currentToolIdMask", fs("curent tool id mask", void 0));
      __publicField(this, "onWheel");
      __publicField(this, "onPointerDown");
      __publicField(this, "onPointerMove");
      __publicField(this, "onPointerUp");
      __publicField(this, "onDoubleClick");
      __publicField(this, "onTripleClick");
      __publicField(this, "onQuadrupleClick");
      __publicField(this, "onRightClick");
      __publicField(this, "onMiddleClick");
      __publicField(this, "onKeyDown");
      __publicField(this, "onKeyUp");
      __publicField(this, "onKeyRepeat");
      __publicField(this, "onCancel");
      __publicField(this, "onComplete");
      __publicField(this, "onInterrupt");
      __publicField(this, "onEnter");
      __publicField(this, "onExit");
      this.editor = e;
      const { id: r, children: i, initial: s } = this.constructor;
      this.id = r, this.current = fs("toolState" + this.id, void 0), this.path = ve("toolPath" + this.id, () => {
        const o = this.current.value;
        return this.id + (o ? `.${o.path.value}` : "");
      }), this.parent = n ?? {}, this.parent ? i && s ? (this.type = "branch", this.initial = s, this.children = Object.fromEntries(i().map((o) => [
        o.id,
        new o(this.editor, this)
      ])), this.current.set(this.children[this.initial])) : this.type = "leaf" : (this.type = "root", i && s && (this.initial = s, this.children = Object.fromEntries(i().map((o) => [
        o.id,
        new o(this.editor, this)
      ])), this.current.set(this.children[this.initial])));
    }
    get currentToolIdMask() {
      return this._currentToolIdMask.value;
    }
    set currentToolIdMask(e) {
      this._currentToolIdMask.set(e);
    }
  }
  __publicField(ze, "id");
  __publicField(ze, "initial");
  __publicField(ze, "children");
  F_e([
    ve
  ], ze.prototype, "currentToolIdMask", 1);
  class B_e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onKeyDown", (e) => {
        var _a3;
        switch (e.code) {
          case "KeyZ": {
            if (!(e.shiftKey || e.ctrlKey)) {
              const n = this.current.value;
              n && ((_a3 = n.current.value) == null ? void 0 : _a3.id) === "idle" && this.children.zoom && this.editor.setCurrentTool("zoom", {
                ...e,
                onInteractionEnd: n.id
              });
            }
            break;
          }
        }
      });
    }
  }
  __publicField(B_e, "id", "root");
  __publicField(B_e, "initial", "");
  __publicField(B_e, "children", () => []);
  var U_e = Object.defineProperty, V_e = Object.getOwnPropertyDescriptor, Xe = (t, e, n, r) => {
    for (var i = r > 1 ? void 0 : r ? V_e(e, n) : e, s = t.length - 1, o; s >= 0; s--)
      (o = t[s]) && (i = (r ? o(e, n, i) : o(i)) || i);
    return r && i && U_e(e, n, i), i;
  };
  class Ue extends q2e.EventEmitter {
    constructor({ store: e, user: n, shapeUtils: r, tools: i, getContainer: s, initialState: o, inferDarkMode: a }) {
      super();
      __publicField(this, "store");
      __publicField(this, "root");
      __publicField(this, "disposables", /* @__PURE__ */ new Set());
      __publicField(this, "_tickManager", new $_e(this));
      __publicField(this, "snaps");
      __publicField(this, "user");
      __publicField(this, "textMeasure");
      __publicField(this, "environment");
      __publicField(this, "getContainer");
      __publicField(this, "sideEffects");
      __publicField(this, "shapeUtils");
      __publicField(this, "styleProps");
      __publicField(this, "history", new x_e(this, (e) => {
        this.annotateError(e, {
          origin: "history.batch",
          willCrashApp: true
        }), this.crash(e);
      }));
      __publicField(this, "_crashingError", null);
      __publicField(this, "_updateInstanceState", this.history.createCommand("updateInstanceState", (e, n) => {
        const r = this.store.get(this.instanceState.id), i = {
          ...r,
          ...e
        };
        return {
          data: {
            prev: r,
            next: i
          },
          ephemeral: false,
          squashing: false,
          ...n
        };
      }, {
        do: ({ next: e }) => {
          this.store.put([
            e
          ]);
        },
        undo: ({ prev: e }) => {
          this.store.put([
            e
          ]);
        },
        squash({ prev: e }, { next: n }) {
          return {
            prev: e,
            next: n
          };
        }
      }));
      __publicField(this, "_isChangingStyleTimeout", -1);
      __publicField(this, "setCursor", (e) => (this.updateInstanceState({
        cursor: {
          ...this.instanceState.cursor,
          ...e
        }
      }, {
        ephemeral: true
      }), this));
      __publicField(this, "_setInstancePageState", this.history.createCommand("setInstancePageState", (e, n) => ({
        data: {
          prev: this.store.get(e.id ?? this.currentPageState.id),
          partial: e
        },
        ...n
      }), {
        do: ({ prev: e, partial: n }) => {
          this.store.update(e.id, (r) => ({
            ...r,
            ...n
          }));
        },
        undo: ({ prev: e }) => {
          this.store.update(e.id, () => e);
        }
      }));
      __publicField(this, "_setSelectedShapes", this.history.createCommand("setSelectedShapes", (e, n) => {
        const { selectedShapeIds: r } = this.currentPageState, i = new Set(r);
        return e.length === i.size && e.every((s) => i.has(s)) ? null : {
          data: {
            selectedShapeIds: e,
            prevSelectedShapeIds: r
          },
          preservesRedoStack: true,
          ...n
        };
      }, {
        do: ({ selectedShapeIds: e }) => {
          this.store.put([
            {
              ...this.currentPageState,
              selectedShapeIds: e
            }
          ]);
        },
        undo: ({ prevSelectedShapeIds: e }) => {
          this.store.put([
            {
              ...this.currentPageState,
              selectedShapeIds: e
            }
          ]);
        },
        squash({ prevSelectedShapeIds: e }, { selectedShapeIds: n }) {
          return {
            selectedShapeIds: n,
            prevSelectedShapeIds: e
          };
        }
      }));
      __publicField(this, "_setFocusedGroupId", this.history.createCommand("setFocusedGroupId", (e) => {
        const n = this.currentPageState.focusedGroupId;
        if (n !== e)
          return {
            data: {
              prev: n,
              next: e
            },
            preservesRedoStack: true,
            squashing: true
          };
      }, {
        do: ({ next: e }) => {
          this.store.update(this.currentPageState.id, (n) => ({
            ...n,
            focusedGroupId: e
          }));
        },
        undo: ({ prev: e }) => {
          this.store.update(this.currentPageState.id, (n) => ({
            ...n,
            focusedGroupId: e
          }));
        },
        squash({ prev: e }, { next: n }) {
          return {
            prev: e,
            next: n
          };
        }
      }));
      __publicField(this, "_viewportAnimation", null);
      __publicField(this, "_willSetInitialBounds", true);
      __publicField(this, "_cameraState", fs("camera state", "idle"));
      __publicField(this, "_cameraStateTimeoutRemaining", 0);
      __publicField(this, "_lastUpdateRenderingBoundsTimestamp", Date.now());
      __publicField(this, "_decayCameraStateTimeout", (e) => {
        this._cameraStateTimeoutRemaining -= e, this._cameraStateTimeoutRemaining <= 0 && (this.off("tick", this._decayCameraStateTimeout), this._cameraState.set("idle"), this.updateRenderingBounds());
      });
      __publicField(this, "_tickCameraState", () => {
        this._cameraStateTimeoutRemaining = Eke;
        const e = Date.now();
        this._cameraState.__unsafe__getWithoutCapture() === "idle" ? (this._lastUpdateRenderingBoundsTimestamp = e, this._cameraState.set("moving"), this.on("tick", this._decayCameraStateTimeout)) : e - this._lastUpdateRenderingBoundsTimestamp > Ike && this.updateRenderingBounds();
      });
      __publicField(this, "_renderingBounds", fs("rendering viewport", new Te()));
      __publicField(this, "_renderingBoundsExpanded", fs("rendering viewport expanded", new Te()));
      __publicField(this, "renderingBoundsMargin", 100);
      __publicField(this, "_currentPageShapeIds");
      __publicField(this, "_setCurrentPageId", this.history.createCommand("setCurrentPage", (e, n) => {
        if (!this.store.has(e)) {
          console.error("Tried to set the current page id to a page that doesn't exist.");
          return;
        }
        return this.stopFollowingUser(), {
          data: {
            toId: e,
            fromId: this.currentPageId
          },
          squashing: true,
          preservesRedoStack: true,
          ...n
        };
      }, {
        do: ({ toId: e }) => {
          if (this.store.has(e)) {
            if (!this.pageStates.find((n) => n.pageId === e)) {
              const n = Nr.create({
                id: Nr.createId(e)
              });
              this.store.put([
                n,
                Qr.create({
                  id: Qr.createId(e),
                  pageId: e
                })
              ]);
            }
            this.store.put([
              {
                ...this.instanceState,
                currentPageId: e
              }
            ]), this.updateRenderingBounds();
          }
        },
        undo: ({ fromId: e }) => {
          this.store.has(e) && (this.store.put([
            {
              ...this.instanceState,
              currentPageId: e
            }
          ]), this.updateRenderingBounds());
        },
        squash: ({ fromId: e }, { toId: n }) => ({
          toId: n,
          fromId: e
        })
      }));
      __publicField(this, "_updatePage", this.history.createCommand("updatePage", (e, n) => {
        if (this.instanceState.isReadonly)
          return null;
        const r = this.getPage(e.id);
        return r ? {
          data: {
            prev: r,
            partial: e
          },
          ...n
        } : null;
      }, {
        do: ({ partial: e }) => {
          this.store.update(e.id, (n) => ({
            ...n,
            ...e
          }));
        },
        undo: ({ prev: e, partial: n }) => {
          this.store.update(n.id, () => e);
        },
        squash(e, n) {
          return {
            prev: {
              ...e.prev,
              ...n.prev
            },
            partial: n.partial
          };
        }
      }));
      __publicField(this, "_createPage", this.history.createCommand("createPage", (e) => {
        if (this.instanceState.isReadonly || this.pages.length >= Ck)
          return null;
        const { pages: n } = this, r = a_e(e.name ?? "Page", n.map((l) => l.name));
        let i = e.index;
        (!i || n.some((l) => l.index === i)) && (i = wc(n[n.length - 1].index));
        const s = Zc.create({
          meta: {},
          ...e,
          name: r,
          index: i
        }), o = Nr.create({
          id: Nr.createId(s.id)
        }), a = Qr.create({
          id: Qr.createId(s.id),
          pageId: s.id
        });
        return {
          data: {
            newPage: s,
            newTabPageState: a,
            newCamera: o
          }
        };
      }, {
        do: ({ newPage: e, newTabPageState: n, newCamera: r }) => {
          this.store.put([
            e,
            r,
            n
          ]);
        },
        undo: ({ newPage: e, newTabPageState: n, newCamera: r }) => {
          this.pages.length !== 1 && this.store.remove([
            n.id,
            e.id,
            r.id
          ]);
        }
      }));
      __publicField(this, "_deletePage", this.history.createCommand("delete_page", (e) => {
        if (this.instanceState.isReadonly)
          return null;
        const { pages: n } = this;
        if (n.length === 1)
          return null;
        const r = this.getPage(e), i = this.pageStates.filter((s) => s.pageId === e);
        if (!r)
          return null;
        if (e === this.currentPageId) {
          const s = n.findIndex((a) => a.id === e), o = n[s - 1] ?? n[s + 1];
          this.setCurrentPage(o.id);
        }
        return {
          data: {
            id: e,
            deletedPage: r,
            deletedPageStates: i
          }
        };
      }, {
        do: ({ deletedPage: e, deletedPageStates: n }) => {
          const { pages: r } = this;
          if (r.length !== 1) {
            if (e.id === this.currentPageId) {
              const i = r.findIndex((o) => o.id === e.id), s = r[i - 1] ?? r[i + 1];
              this.setCurrentPage(s.id);
            }
            this.store.remove(n.map((i) => i.id)), this.store.remove([
              e.id
            ]), this.updateRenderingBounds();
          }
        },
        undo: ({ deletedPage: e, deletedPageStates: n }) => {
          this.store.put([
            e
          ]), this.store.put(n), this.updateRenderingBounds();
        }
      }));
      __publicField(this, "_createAssets", this.history.createCommand("createAssets", (e) => this.instanceState.isReadonly || e.length <= 0 ? null : {
        data: {
          assets: e
        }
      }, {
        do: ({ assets: e }) => {
          this.store.put(e);
        },
        undo: ({ assets: e }) => {
          this.store.remove(e.map((n) => n.id));
        }
      }));
      __publicField(this, "_updateAssets", this.history.createCommand("updateAssets", (e) => this.instanceState.isReadonly || e.length <= 0 ? void 0 : {
        data: {
          snapshots: {},
          assets: e
        }
      }, {
        do: ({ assets: e, snapshots: n }) => {
          this.store.put(e.map((r) => {
            const i = this.store.get(r.id);
            return n[r.id] = i, {
              ...i,
              ...r
            };
          }));
        },
        undo: ({ snapshots: e }) => {
          this.store.put(Object.values(e));
        }
      }));
      __publicField(this, "_deleteAssets", this.history.createCommand("deleteAssets", (e) => {
        if (this.instanceState.isReadonly || e.length <= 0)
          return;
        const n = Je(e.map((r) => this.store.get(r)));
        return {
          data: {
            ids: e,
            prev: n
          }
        };
      }, {
        do: ({ ids: e }) => {
          this.store.remove(e);
        },
        undo: ({ prev: e }) => {
          this.store.put(e);
        }
      }));
      __publicField(this, "_parentIdsToChildIds");
      __publicField(this, "_childIdsCache", new _5());
      __publicField(this, "_createShapes", this.history.createCommand("createShapes", (e) => {
        if (this.instanceState.isReadonly || e.length <= 0)
          return null;
        const { currentPageShapeIds: n } = this;
        if (e.length + n.size > gc) {
          vw(this);
          return;
        }
        return e.length === 0 ? null : {
          data: {
            currentPageId: this.currentPageId,
            partials: e.map((i) => i.id ? i : {
              ...i,
              id: bn()
            })
          }
        };
      }, {
        do: ({ partials: e }) => {
          var _a3, _b3;
          const { focusedGroupId: n } = this, { currentPageShapesSorted: r } = this;
          e = e.map((o) => {
            if (!o.parentId || !(this.store.has(o.parentId) || e.some((a) => a.id === o.parentId))) {
              let a = this.focusedGroupId;
              for (let c = r.length - 1; c >= 0; c--) {
                const u = r[c];
                if (this.getShapeUtil(u).canReceiveNewChildrenOfType(u, o.type) && this.isPointInShape(u, {
                  x: o.x ?? 0,
                  y: o.y ?? 0
                }, {
                  margin: 0,
                  hitInside: true
                })) {
                  a = u.id;
                  break;
                }
              }
              const l = o.parentId;
              if (a === o.id && (a = n), a !== l && (o = {
                ...o
              }, o.parentId = a, Ro(a))) {
                const c = this.getPointInShapeSpace(this.getShape(a), {
                  x: o.x ?? 0,
                  y: o.y ?? 0
                });
                o.x = c.x, o.y = c.y, o.rotation = -this.getShapePageTransform(a).rotation() + (o.rotation ?? 0);
              }
            }
            return o;
          });
          const i = /* @__PURE__ */ new Map(), s = [];
          for (const o of e) {
            const a = this.getShapeUtil(o);
            let l = o.index;
            if (!l) {
              const h = o.parentId ?? n;
              i.has(h) || i.set(h, this.getHighestIndexForParent(h)), l = i.get(h), i.set(h, wc(l));
            }
            const c = a.getDefaultProps();
            for (const [h, f] of this.styleProps[o.type])
              c[f] = this.getStyleForNextShape(h);
            let u = this.store.schema.types.shape.create({
              ...o,
              index: l,
              opacity: o.opacity ?? this.instanceState.opacityForNextShape,
              parentId: o.parentId ?? n,
              props: "props" in o ? {
                ...c,
                ...o.props
              } : c
            });
            if (u.index === void 0)
              throw Error("no index!");
            const d = (_b3 = (_a3 = this.getShapeUtil(u)).onBeforeCreate) == null ? void 0 : _b3.call(_a3, u);
            d && (u = d), s.push(u);
          }
          s.forEach((o) => {
            o.meta = {
              ...this.getInitialMetaForShape(o),
              ...o.meta
            };
          }), this.store.put(s);
        },
        undo: ({ partials: e }) => {
          this.store.remove(e.map((n) => n.id));
        }
      }));
      __publicField(this, "animatingShapes", /* @__PURE__ */ new Map());
      __publicField(this, "_updateShapes", this.history.createCommand("updateShapes", (e, n) => {
        if (this.instanceState.isReadonly)
          return null;
        const r = Je(e), i = Object.fromEntries(Je(r.map(({ id: a }) => this.getShape(a))).map((a) => [
          a.id,
          a
        ]));
        if (r.length <= 0)
          return null;
        const s = Je(r.map((a) => {
          const l = i[a.id];
          if (!l)
            return null;
          let c = null;
          for (const [u, d] of Object.entries(a))
            if (d !== void 0)
              switch (u) {
                case "id":
                case "type":
                  continue;
                default:
                  if (d !== l[u])
                    if (c || (c = {
                      ...l
                    }), u === "props") {
                      const h = {
                        ...l.props
                      };
                      for (const [f, y] of Object.entries(d))
                        y !== void 0 && (h[f] = y);
                      c.props = h;
                    } else if (u === "meta") {
                      const h = {
                        ...l.meta
                      };
                      for (const [f, y] of Object.entries(d))
                        y !== void 0 && (h[f] = y);
                      c.meta = h;
                    } else
                      c[u] = d;
              }
          return c ?? l;
        })), o = Object.fromEntries(s.map((a) => [
          a.id,
          a
        ]));
        return {
          data: {
            snapshots: i,
            updates: o
          },
          ...n
        };
      }, {
        do: ({ updates: e }) => {
          var _a3, _b3;
          const n = Object.values(e);
          for (let r = 0; r < n.length; r++) {
            const i = n[r], s = this.store.get(i.id);
            if (!s)
              continue;
            const o = (_b3 = (_a3 = this.getShapeUtil(i)).onBeforeUpdate) == null ? void 0 : _b3.call(_a3, s, i);
            o && (n[r] = o);
          }
          this.store.put(n);
        },
        undo: ({ snapshots: e }) => {
          this.store.put(Object.values(e));
        },
        squash(e, n) {
          return {
            snapshots: {
              ...n.snapshots,
              ...e.snapshots
            },
            updates: {
              ...e.updates,
              ...n.updates
            }
          };
        }
      }));
      __publicField(this, "_deleteShapes", this.history.createCommand("delete_shapes", (e) => {
        if (this.instanceState.isReadonly || e.length === 0)
          return null;
        const n = [
          ...this.currentPageState.selectedShapeIds
        ], r = new Set(e);
        for (const l of e)
          this.visitDescendants(l, (c) => {
            r.add(c);
          });
        const i = [
          ...r
        ], s = this._arrowBindingsIndex.value, o = Je(i.flatMap((l) => {
          const c = this.getShape(l), u = s[l];
          return u && u.length > 0 ? u.map(({ arrowId: d }) => this.getShape(d)).concat(c) : c;
        })), a = n.filter((l) => !r.has(l));
        return {
          data: {
            deletedIds: i,
            snapshots: o,
            prevSelectedShapeIds: n,
            postSelectedShapeIds: a
          }
        };
      }, {
        do: ({ deletedIds: e, postSelectedShapeIds: n }) => {
          this.store.remove(e), this.store.update(this.currentPageState.id, (r) => ({
            ...r,
            selectedShapeIds: n
          }));
        },
        undo: ({ snapshots: e, prevSelectedShapeIds: n }) => {
          this.store.put(e), this.store.update(this.currentPageState.id, (r) => ({
            ...r,
            selectedShapeIds: n
          }));
        }
      }));
      __publicField(this, "_selectionSharedStyles", ve("_selectionSharedStyles", () => {
        const { selectedShapes: e } = this, n = new oR();
        for (const r of e)
          this._extractSharedStyles(r, n);
        return n;
      }));
      __publicField(this, "externalAssetContentHandlers", {
        file: null,
        url: null
      });
      __publicField(this, "externalContentHandlers", {
        text: null,
        files: null,
        embed: null,
        "svg-text": null,
        url: null
      });
      __publicField(this, "inputs", {
        originPagePoint: new I(),
        originScreenPoint: new I(),
        previousPagePoint: new I(),
        previousScreenPoint: new I(),
        currentPagePoint: new I(),
        currentScreenPoint: new I(),
        keys: /* @__PURE__ */ new Set(),
        buttons: /* @__PURE__ */ new Set(),
        isPen: false,
        shiftKey: false,
        ctrlKey: false,
        altKey: false,
        isDragging: false,
        isPointing: false,
        isPinching: false,
        isEditing: false,
        isPanning: false,
        pointerVelocity: new I()
      });
      __publicField(this, "_clickManager", new O_e(this));
      __publicField(this, "_prevCursor", "default");
      __publicField(this, "_shiftKeyTimeout", -1);
      __publicField(this, "_setShiftKeyTimeout", () => {
        this.inputs.shiftKey = false, this.dispatch({
          type: "keyboard",
          name: "key_up",
          key: "Shift",
          shiftKey: this.inputs.shiftKey,
          ctrlKey: this.inputs.ctrlKey,
          altKey: this.inputs.altKey,
          code: "ShiftLeft"
        });
      });
      __publicField(this, "_altKeyTimeout", -1);
      __publicField(this, "_setAltKeyTimeout", () => {
        this.inputs.altKey = false, this.dispatch({
          type: "keyboard",
          name: "key_up",
          key: "Alt",
          shiftKey: this.inputs.shiftKey,
          ctrlKey: this.inputs.ctrlKey,
          altKey: this.inputs.altKey,
          code: "AltLeft"
        });
      });
      __publicField(this, "_ctrlKeyTimeout", -1);
      __publicField(this, "_setCtrlKeyTimeout", () => {
        this.inputs.ctrlKey = false, this.dispatch({
          type: "keyboard",
          name: "key_up",
          key: "Ctrl",
          shiftKey: this.inputs.shiftKey,
          ctrlKey: this.inputs.ctrlKey,
          altKey: this.inputs.altKey,
          code: "ControlLeft"
        });
      });
      __publicField(this, "_restoreToolId", "select");
      __publicField(this, "_pinchStart", 1);
      __publicField(this, "_didPinch", false);
      __publicField(this, "_selectedShapeIdsAtPointerDown", []);
      __publicField(this, "capturedPointerId", null);
      __publicField(this, "dispatch", (e) => {
        if (this.crashingError)
          return this;
        const { inputs: n } = this, { type: r } = e;
        return this.batch(() => {
          if (e.type === "misc") {
            (e.name === "cancel" || e.name === "complete") && (this.inputs.isDragging = false, this.inputs.isPanning && (this.inputs.isPanning = false, this.updateInstanceState({
              cursor: {
                type: this._prevCursor,
                rotation: 0
              }
            }))), this.root.handleEvent(e);
            return;
          }
          e.shiftKey ? (clearInterval(this._shiftKeyTimeout), this._shiftKeyTimeout = -1, n.shiftKey = true) : !e.shiftKey && n.shiftKey && this._shiftKeyTimeout === -1 && (this._shiftKeyTimeout = setTimeout(this._setShiftKeyTimeout, 150)), e.altKey ? (clearInterval(this._altKeyTimeout), this._altKeyTimeout = -1, n.altKey = true) : !e.altKey && n.altKey && this._altKeyTimeout === -1 && (this._altKeyTimeout = setTimeout(this._setAltKeyTimeout, 150)), e.ctrlKey ? (clearInterval(this._ctrlKeyTimeout), this._ctrlKeyTimeout = -1, n.ctrlKey = true) : !e.ctrlKey && n.ctrlKey && this._ctrlKeyTimeout === -1 && (this._ctrlKeyTimeout = setTimeout(this._setCtrlKeyTimeout, 150));
          const { originPagePoint: i, originScreenPoint: s, currentPagePoint: o, currentScreenPoint: a } = n;
          switch (n.isPointing || (n.isDragging = false), r) {
            case "pinch": {
              if (!this.instanceState.canMoveCamera)
                return;
              switch (this._updateInputsFromEvent(e), e.name) {
                case "pinch_start": {
                  if (n.isPinching)
                    return;
                  n.isEditing || (this._pinchStart = this.camera.z, this._selectedShapeIdsAtPointerDown.length || (this._selectedShapeIdsAtPointerDown = this.selectedShapeIds), this._didPinch = true, n.isPinching = true, this.interrupt());
                  return;
                }
                case "pinch": {
                  if (!n.isPinching)
                    return;
                  const { point: { x: l, y: c, z: u = 1 }, delta: { x: d, y: h } } = e, { camera: { x: f, y, z: g } } = this, O = Math.min(Fu, Math.max(zy, u));
                  this.setCamera({
                    x: f + d / g - l / g + l / O,
                    y: y + h / g - c / g + c / O,
                    z: O
                  });
                  return;
                }
                case "pinch_end": {
                  if (!n.isPinching)
                    return this;
                  n.isPinching = false;
                  const { _selectedShapeIdsAtPointerDown: l } = this;
                  this.setSelectedShapes(this._selectedShapeIdsAtPointerDown, {
                    squashing: true
                  }), this._selectedShapeIdsAtPointerDown = [], this._didPinch && (this._didPinch = false, requestAnimationFrame(() => {
                    this._didPinch || this.setSelectedShapes(l, {
                      squashing: true
                    });
                  }));
                  return;
                }
              }
            }
            case "wheel": {
              if (!this.instanceState.canMoveCamera)
                return;
              if (!this.isMenuOpen) {
                if (n.ctrlKey) {
                  const { x: l, y: c } = this.inputs.currentScreenPoint, { x: u, y: d, z: h } = this.camera, f = Math.min(Fu, Math.max(zy, h + (e.delta.z ?? 0) * h));
                  this.setCamera({
                    x: u + (l / f - l) - (l / h - l),
                    y: d + (c / f - c) - (c / h - c),
                    z: f
                  });
                  return;
                }
                this.pan(e.delta), !n.isDragging && n.isPointing && i.dist(o) > (this.instanceState.isCoarsePointer ? nR : Zv) / this.zoomLevel && (n.isDragging = true);
              }
              break;
            }
            case "pointer": {
              if (n.isPinching)
                return;
              this._updateInputsFromEvent(e);
              const { isPen: l } = e;
              switch (e.name) {
                case "pointer_down": {
                  if (this._selectedShapeIdsAtPointerDown = this.selectedShapeIds, e.button === 0 && (this.capturedPointerId = e.pointerId), n.buttons.add(e.button), n.isPointing = true, n.isDragging = false, this.instanceState.isPenMode) {
                    if (!l)
                      return;
                  } else
                    l && this.updateInstanceState({
                      isPenMode: true
                    });
                  if (e.button === 5 ? (this._restoreToolId = this.currentToolId, this.complete(), this.setCurrentTool("eraser")) : e.button === 1 && (this.inputs.isPanning || (this._prevCursor = this.instanceState.cursor.type), this.inputs.isPanning = true), this.inputs.isPanning)
                    return this.stopCameraAnimation(), this.updateInstanceState({
                      cursor: {
                        type: "grabbing",
                        rotation: 0
                      }
                    }), this;
                  s.setTo(a), i.setTo(o);
                  break;
                }
                case "pointer_move": {
                  if (!l && this.instanceState.isPenMode)
                    return;
                  if (this.inputs.isPanning && this.inputs.isPointing) {
                    const { currentScreenPoint: c, previousScreenPoint: u } = this.inputs;
                    this.pan(I.Sub(c, u));
                    return;
                  }
                  !n.isDragging && n.isPointing && i.dist(o) > (this.instanceState.isCoarsePointer ? nR : Zv) / this.zoomLevel && (n.isDragging = true);
                  break;
                }
                case "pointer_up": {
                  if (n.buttons.delete(e.button), n.isPointing = false, n.isDragging = false, this.isMenuOpen || !l && this.instanceState.isPenMode)
                    return;
                  this.capturedPointerId === e.pointerId && (this.capturedPointerId = null, e.button = 0), n.isPanning ? e.button === 1 ? this.inputs.keys.has(" ") ? (this.slideCamera({
                    speed: Math.min(2, this.inputs.pointerVelocity.len()),
                    direction: this.inputs.pointerVelocity,
                    friction: Zx
                  }), this.updateInstanceState({
                    cursor: {
                      type: "grab",
                      rotation: 0
                    }
                  })) : (n.isPanning = false, this.slideCamera({
                    speed: Math.min(2, this.inputs.pointerVelocity.len()),
                    direction: this.inputs.pointerVelocity,
                    friction: Zx
                  }), this.updateInstanceState({
                    cursor: {
                      type: this._prevCursor,
                      rotation: 0
                    }
                  })) : e.button === 0 && (this.slideCamera({
                    speed: Math.min(2, this.inputs.pointerVelocity.len()),
                    direction: this.inputs.pointerVelocity,
                    friction: Zx
                  }), this.updateInstanceState({
                    cursor: {
                      type: "grab",
                      rotation: 0
                    }
                  })) : e.button === 5 && (this.complete(), this.setCurrentTool(this._restoreToolId));
                  break;
                }
              }
              break;
            }
            case "keyboard": {
              switch (e.key === "ShiftRight" && (e.key = "ShiftLeft"), e.key === "AltRight" && (e.key = "AltLeft"), e.code === "ControlRight" && (e.code = "ControlLeft"), e.name) {
                case "key_down": {
                  n.keys.add(e.code), !e.ctrlKey && e.code === "Space" && (this.inputs.isPanning || (this._prevCursor = this.instanceState.cursor.type), this.inputs.isPanning = true, this.updateInstanceState({
                    cursor: {
                      type: this.inputs.isPointing ? "grabbing" : "grab",
                      rotation: 0
                    }
                  }));
                  break;
                }
                case "key_up": {
                  n.keys.delete(e.code), e.code === "Space" && !this.inputs.buttons.has(1) && (this.inputs.isPanning = false, this.updateInstanceState({
                    cursor: {
                      type: this._prevCursor,
                      rotation: 0
                    }
                  }));
                  break;
                }
              }
              break;
            }
          }
          if (e.type === "pointer" && (e.button === 1 ? e.name = "middle_click" : e.button === 2 && (e.name = "right_click"), e.isPen === this.instanceState.isPenMode))
            switch (e.name) {
              case "pointer_down": {
                const l = this._clickManager.transformPointerDownEvent(e);
                if (e.name !== l.name) {
                  this.root.handleEvent(e), this.emit("event", e), this.root.handleEvent(l), this.emit("event", l);
                  return;
                }
                break;
              }
              case "pointer_up": {
                const l = this._clickManager.transformPointerUpEvent(e);
                if (e.name !== l.name) {
                  this.root.handleEvent(e), this.emit("event", e), this.root.handleEvent(l), this.emit("event", l);
                  return;
                }
                break;
              }
              case "pointer_move": {
                this._clickManager.handleMove();
                break;
              }
            }
          this.root.handleEvent(e), this.emit("event", e);
        }), this;
      });
      this.store = e, this.snaps = new Qd(this), this.user = new ru(n ?? GG(), a ?? false), this.getContainer = s ?? (() => document.body), this.textMeasure = new I_e(this);
      class l extends B_e {
      }
      __publicField(l, "initial", o ?? "");
      this.root = new l(this), this.root.children = {};
      const c = tq(r), u = new Set(Object.keys(e.schema.types.shape.migrations.subTypeMigrations));
      for (const x of c) {
        if (!u.has(x.type))
          throw Error(`Editor and store have different shapes: "${x.type}" was passed into the editor but not the schema`);
        u.delete(x.type);
      }
      if (u.size > 0)
        throw Error(`Editor and store have different shapes: "${[
          ...u
        ][0]}" is present in the store schema but not provided to the editor`);
      const d = {}, h = {}, f = /* @__PURE__ */ new Map();
      for (const x of c) {
        const P = new x(this);
        d[x.type] = P;
        const C = cG(x.props ?? {});
        h[x.type] = C;
        for (const _ of C.keys())
          if (!f.has(_.id))
            f.set(_.id, _);
          else if (f.get(_.id) !== _)
            throw Error(`Multiple style props with id "${_.id}" in use. Style prop IDs must be unique.`);
      }
      this.shapeUtils = d, this.styleProps = h;
      for (const x of [
        ...i
      ]) {
        if (bC(this.root.children, x.id))
          throw Error(`Can't override tool with id "${x.id}"`);
        this.root.children[x.id] = new x(this, this.root);
      }
      this.environment = new S_e(this);
      const y = /* @__PURE__ */ new Set(), g = (x) => {
        const P = this.getShape(x);
        if (!P)
          return;
        const { start: C, end: _ } = P.props, T = C.type === "binding" ? this.getShape(C.boundShapeId) : void 0, $ = _.type === "binding" ? this.getShape(_.boundShapeId) : void 0, N = this.getAncestorPageId(P);
        if (!N)
          return;
        let L;
        if (T && $)
          L = this.findCommonAncestor([
            T,
            $
          ]) ?? N;
        else if (T || $)
          L = N;
        else
          return;
        L && L !== P.parentId && this.reparentShapes([
          x
        ], L);
        const z = this.getShape(x);
        if (!z)
          throw Error("no reparented arrow");
        const M = this.getShapeNearestSibling(z, T), R = this.getShapeNearestSibling(z, $);
        let F;
        if (M && R)
          F = M.index > R.index ? M : R;
        else if (M && !R)
          F = M;
        else if (R && !M)
          F = R;
        else
          return;
        let Q;
        const X = this.getSortedChildIdsForParent(F.parentId).map((Z) => this.getShape(Z)).filter((Z) => Z.index > F.index);
        if (X.length) {
          const Z = X.find((U) => U.type !== "arrow");
          if (z.index > F.index && (!Z || z.index < Z.index))
            return;
          Q = G0(F.index, X[0].index);
        } else
          Q = wc(F.index);
        Q !== z.index && this.updateShapes([
          {
            id: x,
            type: "arrow",
            index: Q
          }
        ]);
      }, O = (x, P) => {
        const { x: C, y: _ } = Ia(this, x)[P];
        this.store.put([
          {
            ...x,
            props: {
              ...x.props,
              [P]: {
                type: "point",
                x: C,
                y: _
              }
            }
          }
        ]);
      }, S = (x) => {
        for (const P of [
          "start",
          "end"
        ]) {
          const C = x.props[P];
          if (C.type !== "binding")
            continue;
          const _ = this.getShape(C.boundShapeId), T = this.getAncestorPageId(x) === this.getAncestorPageId(_);
          (!_ || !T) && O(x, P);
        }
        g(x.id);
      }, w = (x, P) => {
        let C = null;
        const _ = x.selectedShapeIds.filter((N) => !P.has(N));
        _.length !== x.selectedShapeIds.length && (C || (C = {
          ...x
        }), C.selectedShapeIds = _);
        const T = x.erasingShapeIds.filter((N) => !P.has(N));
        T.length !== x.erasingShapeIds.length && (C || (C = {
          ...x
        }), C.erasingShapeIds = T), x.hoveredShapeId && P.has(x.hoveredShapeId) && (C || (C = {
          ...x
        }), C.hoveredShapeId = null), x.editingShapeId && P.has(x.editingShapeId) && (C || (C = {
          ...x
        }), C.editingShapeId = null);
        const $ = x.hintingShapeIds.filter((N) => !P.has(N));
        return $.length !== x.hintingShapeIds.length && (C || (C = {
          ...x
        }), C.hintingShapeIds = $), x.focusedGroupId && P.has(x.focusedGroupId) && (C || (C = {
          ...x
        }), C.focusedGroupId = null), C;
      };
      if (this.sideEffects = new b_e(this), this.sideEffects.registerBatchCompleteHandler(() => {
        var _a3, _b3;
        for (const x of y) {
          y.delete(x);
          const P = this.getShape(x);
          if (!P)
            continue;
          const _ = (_b3 = (_a3 = this.getShapeUtil(P)).onChildrenChange) == null ? void 0 : _b3.call(_a3, P);
          (_ == null ? void 0 : _.length) && this.updateShapes(_, {
            squashing: true
          });
        }
        this.emit("update");
      }), this.sideEffects.registerBeforeDeleteHandler("shape", (x) => {
        x.parentId && Ro(x.parentId) && y.add(x.parentId);
        const P = this._arrowBindingsIndex.value[x.id];
        if (P == null ? void 0 : P.length)
          for (const { arrowId: T, handleId: $ } of P) {
            const N = this.getShape(T);
            N && O(N, $);
          }
        const C = /* @__PURE__ */ new Set([
          x.id
        ]), _ = Je(this.pageStates.map((T) => w(T, C)));
        _.length && this.store.put(_);
      }), this.sideEffects.registerBeforeDeleteHandler("page", (x) => {
        var _a3;
        if (this.instanceState.currentPageId !== x.id)
          return;
        const P = (_a3 = this.pages.find((T) => T.id !== x.id)) == null ? void 0 : _a3.id;
        if (!P)
          return;
        this.store.put([
          {
            ...this.instanceState,
            currentPageId: P
          }
        ]);
        const C = Nr.createId(x.id), _ = Qr.createId(x.id);
        this.store.remove([
          C,
          _
        ]);
      }), this.sideEffects.registerAfterChangeHandler("shape", (x, P) => {
        if (this.isShapeOfType(P, "arrow") && S(P), x.parentId !== P.parentId) {
          const C = (_) => {
            const T = this._arrowBindingsIndex.value[_];
            if (T == null ? void 0 : T.length)
              for (const $ of T)
                g($.arrowId);
          };
          C(P.id), this.visitDescendants(P.id, C);
        }
        if (x.parentId !== P.parentId && rs(P.parentId)) {
          const C = /* @__PURE__ */ new Set([
            x.id
          ]);
          this.visitDescendants(x.id, (_) => {
            C.add(_);
          });
          for (const _ of this.pageStates) {
            if (_.pageId === P.parentId)
              continue;
            const T = w(_, C);
            T && this.store.put([
              T
            ]);
          }
        }
        x.parentId && Ro(x.parentId) && y.add(x.parentId), P.parentId !== x.parentId && Ro(P.parentId) && y.add(P.parentId);
      }), this.sideEffects.registerAfterChangeHandler("instance_page_state", (x, P) => {
        if ((x == null ? void 0 : x.selectedShapeIds) !== (P == null ? void 0 : P.selectedShapeIds)) {
          const C = P.selectedShapeIds.filter((T) => {
            var _a3, _b3;
            let $ = (_a3 = this.getShape(T)) == null ? void 0 : _a3.parentId;
            for (; Ro($); ) {
              if (P.selectedShapeIds.includes($))
                return false;
              $ = (_b3 = this.getShape($)) == null ? void 0 : _b3.parentId;
            }
            return true;
          });
          let _ = null;
          if (C.length > 0) {
            const T = this.findCommonAncestor(Je(C.map(($) => this.getShape($))), ($) => this.isShapeOfType($, "group"));
            T && (_ = T);
          } else
            (P == null ? void 0 : P.focusedGroupId) && (_ = P.focusedGroupId);
          (C.length !== P.selectedShapeIds.length || _ !== P.focusedGroupId) && this.store.put([
            {
              ...P,
              selectedShapeIds: C,
              focusedGroupId: _ ?? null
            }
          ]);
        }
      }), this.sideEffects.registerAfterCreateHandler("shape", (x) => {
        this.isShapeOfType(x, "arrow") && S(x);
      }), this.sideEffects.registerAfterCreateHandler("page", (x) => {
        const P = Nr.createId(x.id), C = Qr.createId(x.id);
        this.store.has(P) || this.store.put([
          Nr.create({
            id: P
          })
        ]), this.store.has(C) || this.store.put([
          Qr.create({
            id: C,
            pageId: x.id
          })
        ]);
      }), this._currentPageShapeIds = y_e(this.store, () => this.currentPageId), this._parentIdsToChildIds = m_e(this.store), this.disposables.add(this.store.listen((x) => {
        this.emit("change", x);
      })), this.store.ensureStoreIsUsable(), this._setInstancePageState({
        editingShapeId: null,
        hoveredShapeId: null,
        erasingShapeIds: []
      }, {
        ephemeral: true
      }), o && this.root.children[o] === void 0)
        throw Error(`No state found for initialState "${o}".`);
      this.root.enter(void 0, "initial"), this.instanceState.followingUserId && this.stopFollowingUser(), this.updateRenderingBounds(), requestAnimationFrame(() => {
        this._tickManager.start();
      });
    }
    dispose() {
      this.disposables.forEach((e) => e()), this.disposables.clear();
    }
    getShapeUtil(e) {
      const n = typeof e == "string" ? e : e.type, r = Xh(this.shapeUtils, n);
      return xC(r, `No shape util found for type "${n}"`), r;
    }
    undo() {
      return this.history.undo(), this;
    }
    get canUndo() {
      return this.history.numUndos > 0;
    }
    redo() {
      return this.history.redo(), this;
    }
    get canRedo() {
      return this.history.numRedos > 0;
    }
    mark(e, n, r) {
      return this.history.mark(e, n, r), this;
    }
    bail() {
      return this.history.bail(), this;
    }
    bailToMark(e) {
      return this.history.bailToMark(e), this;
    }
    batch(e) {
      return this.history.batch(e), this;
    }
    get _arrowBindingsIndex() {
      return g_e(this);
    }
    getArrowsBoundTo(e) {
      return this._arrowBindingsIndex.value[e] || Rc;
    }
    get arrowInfoCache() {
      return this.store.createComputedCache("arrow infoCache", (e) => Fy(e) ? q0(this, e) : $E(this, e));
    }
    getArrowInfo(e) {
      const n = typeof e == "string" ? e : e.id;
      return this.arrowInfoCache.get(n);
    }
    annotateError(e, { origin: n, willCrashApp: r, tags: i, extras: s }) {
      const o = this.createErrorAnnotations(n, r);
      return a5(e, {
        tags: {
          ...o.tags,
          ...i
        },
        extras: {
          ...o.extras,
          ...s
        }
      }), r && this.store.markAsPossiblyCorrupted(), this;
    }
    createErrorAnnotations(e, n) {
      try {
        return {
          tags: {
            origin: e,
            willCrashApp: n
          },
          extras: {
            activeStateNode: this.root.path.value,
            selectedShapes: this.selectedShapes,
            editingShape: this.editingShapeId ? this.getShape(this.editingShapeId) : void 0,
            inputs: this.inputs
          }
        };
      } catch {
        return {
          tags: {
            origin: e,
            willCrashApp: n
          },
          extras: {}
        };
      }
    }
    get crashingError() {
      return this._crashingError;
    }
    crash(e) {
      return this._crashingError = e, this.store.markAsPossiblyCorrupted(), this.emit("crash", {
        error: e
      }), this;
    }
    isIn(e) {
      const n = e.split(".").reverse();
      let r = this.root;
      for (; n.length > 0; ) {
        const i = n.pop();
        if (!i)
          return true;
        const s = r.current.value;
        if ((s == null ? void 0 : s.id) === i) {
          if (n.length === 0)
            return true;
          r = s;
          continue;
        } else
          return false;
      }
      return false;
    }
    isInAny(...e) {
      return e.some((n) => this.isIn(n));
    }
    setCurrentTool(e, n = {}) {
      return this.root.transition(e, n), this;
    }
    get currentTool() {
      return this.root.current.value;
    }
    get currentToolId() {
      const { currentTool: e } = this;
      return e ? e.currentToolIdMask ?? e.id : "";
    }
    getStateDescendant(e) {
      var _a3;
      const n = e.split(".").reverse();
      let r = this.root;
      for (; n.length > 0; ) {
        const i = n.pop();
        if (!i)
          return r;
        const s = (_a3 = r.children) == null ? void 0 : _a3[i];
        if (!s)
          return;
        r = s;
      }
      return r;
    }
    get documentSettings() {
      return this.store.get(eR);
    }
    updateDocumentSettings(e) {
      return this.store.put([
        {
          ...this.documentSettings,
          ...e
        }
      ]), this;
    }
    get instanceState() {
      return this.store.get(gi);
    }
    updateInstanceState(e, n) {
      return this._updateInstanceState(e, {
        ephemeral: true,
        squashing: true,
        ...n
      }), e.isChangingStyle !== void 0 && (clearTimeout(this._isChangingStyleTimeout), e.isChangingStyle === true && (this._isChangingStyleTimeout = setTimeout(() => {
        this.updateInstanceState({
          isChangingStyle: false
        });
      }, 2e3))), this;
    }
    get openMenus() {
      return this.instanceState.openMenus;
    }
    addOpenMenu(e) {
      const n = new Set(this.openMenus);
      return n.has(e) || (n.add(e), this.updateInstanceState({
        openMenus: [
          ...n
        ]
      })), this;
    }
    deleteOpenMenu(e) {
      const n = new Set(this.openMenus);
      return n.has(e) && (n.delete(e), this.updateInstanceState({
        openMenus: [
          ...n
        ]
      })), this;
    }
    get isMenuOpen() {
      return this.openMenus.length > 0;
    }
    get pageStates() {
      return this._pageStates.value;
    }
    get _pageStates() {
      return this.store.query.records("instance_page_state");
    }
    get currentPageState() {
      return this.store.get(this._currentPageStateId);
    }
    get _currentPageStateId() {
      return Qr.createId(this.currentPageId);
    }
    updateCurrentPageState(e, n) {
      return this._setInstancePageState(e, n), this;
    }
    get selectedShapeIds() {
      return this.currentPageState.selectedShapeIds;
    }
    get selectedShapes() {
      const { selectedShapeIds: e } = this.currentPageState;
      return Je(e.map((n) => this.store.get(n)));
    }
    setSelectedShapes(e, n) {
      const r = e.map((i) => typeof i == "string" ? i : i.id);
      return this._setSelectedShapes(r, n), this;
    }
    isAncestorSelected(e) {
      const n = typeof e == "string" ? e : (e == null ? void 0 : e.id) ?? null, r = this.getShape(n);
      if (!r)
        return false;
      const { selectedShapeIds: i } = this;
      return !!this.findShapeAncestor(r, (s) => i.includes(s.id));
    }
    select(...e) {
      const n = typeof e[0] == "string" ? e : e.map((r) => r.id);
      return this.setSelectedShapes(n), this;
    }
    deselect(...e) {
      const n = typeof e[0] == "string" ? e : e.map((i) => i.id), { selectedShapeIds: r } = this;
      return r.length > 0 && n.length > 0 && this.setSelectedShapes(r.filter((i) => !n.includes(i))), this;
    }
    selectAll() {
      const e = this.getSortedChildIdsForParent(this.currentPageId);
      return e.length <= 0 ? this : (this.setSelectedShapes(this._getUnlockedShapeIds(e)), this);
    }
    selectNone() {
      return this.selectedShapeIds.length > 0 && this.setSelectedShapes([]), this;
    }
    get onlySelectedShape() {
      const { selectedShapes: e } = this;
      return e.length === 1 ? e[0] : null;
    }
    get selectionPageBounds() {
      const { currentPageState: { selectedShapeIds: e } } = this;
      return e.length === 0 ? null : Te.Common(Je(e.map((n) => this.getShapePageBounds(n))));
    }
    get selectionRotation() {
      const { selectedShapeIds: e } = this;
      if (e.length === 0)
        return 0;
      if (e.length === 1)
        return this.getShapePageTransform(this.selectedShapeIds[0]).rotation();
      const n = e.map((r) => this.getShapePageTransform(r).rotation());
      return n.every((r) => Math.abs(r - n[0]) < Math.PI / 180) ? this.getShapePageTransform(e[0]).rotation() : 0;
    }
    get selectionRotatedPageBounds() {
      const { selectedShapeIds: e } = this;
      if (e.length === 0)
        return;
      const { selectionRotation: n } = this;
      if (n === 0)
        return this.selectionPageBounds;
      if (e.length === 1) {
        const i = this.getShapeGeometry(e[0]).bounds.clone(), s = this.getShapePageTransform(e[0]);
        return i.point = s.applyToPoint(i.point), i;
      }
      const r = Te.FromPoints(this.selectedShapeIds.flatMap((i) => {
        const s = this.getShapePageTransform(i);
        return s ? s.applyToPoints(this.getShapeGeometry(i).vertices) : [];
      }).map((i) => I.Rot(i, -n)));
      return r.point = r.point.rot(n), r;
    }
    get focusedGroupId() {
      return this.currentPageState.focusedGroupId ?? this.currentPageId;
    }
    get focusedGroup() {
      const { focusedGroupId: e } = this;
      return e ? this.getShape(e) : void 0;
    }
    setFocusedGroup(e) {
      const n = typeof e == "string" ? e : (e == null ? void 0 : e.id) ?? null;
      if (n !== null) {
        const r = this.getShape(n);
        if (!r)
          throw Error(`Editor.setFocusedGroup: Shape with id ${n} does not exist`);
        if (!this.isShapeOfType(r, "group"))
          throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${r.type}`);
      }
      return n === this.focusedGroupId ? this : (this._setFocusedGroupId(n), this);
    }
    popFocusedGroupId() {
      const { focusedGroup: e } = this;
      if (e) {
        const n = this.findShapeAncestor(e, (r) => this.isShapeOfType(r, "group"));
        this.setFocusedGroup((n == null ? void 0 : n.id) ?? null), this.select(e.id);
      } else
        this.setFocusedGroup(null), this.selectNone();
      return this;
    }
    get editingShapeId() {
      return this.currentPageState.editingShapeId;
    }
    get editingShape() {
      const { editingShapeId: e } = this;
      return e ? this.getShape(e) : void 0;
    }
    setEditingShape(e) {
      const n = typeof e == "string" ? e : (e == null ? void 0 : e.id) ?? null;
      if (n !== this.editingShapeId) {
        if (n) {
          const r = this.getShape(n);
          if (r && this.getShapeUtil(r).canEdit(r))
            return this._setInstancePageState({
              editingShapeId: n
            }), this;
        }
        this._setInstancePageState({
          editingShapeId: null
        });
      }
      return this;
    }
    get hoveredShapeId() {
      return this.currentPageState.hoveredShapeId;
    }
    get hoveredShape() {
      const { hoveredShapeId: e } = this;
      return e ? this.getShape(e) : void 0;
    }
    setHoveredShape(e) {
      const n = typeof e == "string" ? e : (e == null ? void 0 : e.id) ?? null;
      return n === this.hoveredShapeId ? this : (this.updateCurrentPageState({
        hoveredShapeId: n
      }, {
        ephemeral: true
      }), this);
    }
    get hintingShapeIds() {
      return this.currentPageState.hintingShapeIds;
    }
    get hintingShapes() {
      const { hintingShapeIds: e } = this;
      return Je(e.map((n) => this.getShape(n)));
    }
    setHintingShapes(e) {
      const n = typeof e[0] == "string" ? e : e.map((r) => r.id);
      return this.updateCurrentPageState({
        hintingShapeIds: hk(n)
      }, {
        ephemeral: true
      }), this;
    }
    get erasingShapeIds() {
      return this.currentPageState.erasingShapeIds;
    }
    get erasingShapes() {
      const { erasingShapeIds: e } = this;
      return Je(e.map((n) => this.getShape(n)));
    }
    setErasingShapes(e) {
      const n = typeof e[0] == "string" ? e : e.map((i) => i.id);
      n.sort();
      const { erasingShapeIds: r } = this;
      if (n.length === r.length) {
        for (let i = 0; i < n.length; i++)
          if (n[i] !== r[i]) {
            this._setInstancePageState({
              erasingShapeIds: n
            }, {
              ephemeral: true
            });
            break;
          }
      } else
        this._setInstancePageState({
          erasingShapeIds: n
        }, {
          ephemeral: true
        });
      return this;
    }
    get croppingShapeId() {
      return this.currentPageState.croppingShapeId;
    }
    setCroppingShape(e) {
      const n = typeof e == "string" ? e : (e == null ? void 0 : e.id) ?? null;
      if (n !== this.croppingShapeId)
        if (!n)
          this.updateCurrentPageState({
            croppingShapeId: null
          });
        else {
          const r = this.getShape(n), i = this.getShapeUtil(r);
          r && i.canCrop(r) && this.updateCurrentPageState({
            croppingShapeId: n
          });
        }
      return this;
    }
    get cameraId() {
      return Nr.createId(this.currentPageId);
    }
    get camera() {
      return this.store.get(this.cameraId);
    }
    get zoomLevel() {
      return this.camera.z;
    }
    _setCamera(e) {
      const n = this.camera;
      return n.x === e.x && n.y === e.y && n.z === e.z ? this : (this.batch(() => {
        this.store.put([
          {
            ...n,
            ...e
          }
        ]);
        const { currentScreenPoint: r } = this.inputs;
        this.dispatch({
          type: "pointer",
          target: "canvas",
          name: "pointer_move",
          point: r,
          pointerId: d8.CAMERA_MOVE,
          ctrlKey: this.inputs.ctrlKey,
          altKey: this.inputs.altKey,
          shiftKey: this.inputs.shiftKey,
          button: 0,
          isPen: this.instanceState.isPenMode ?? false
        }), this._tickCameraState();
      }), this);
    }
    setCamera(e, n) {
      const r = Number.isFinite(e.x) ? e.x : 0, i = Number.isFinite(e.y) ? e.y : 0, s = Number.isFinite(e.z) ? e.z : this.zoomLevel;
      if (this.stopCameraAnimation(), this.instanceState.followingUserId && this.stopFollowingUser(), n) {
        const { width: o, height: a } = this.viewportScreenBounds;
        return this._animateToViewport(new Te(-r, -i, o / s, a / s), n);
      } else
        this._setCamera({
          x: r,
          y: i,
          z: s
        });
      return this;
    }
    centerOnPoint(e, n) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const { viewportPageBounds: { width: r, height: i }, camera: s } = this;
      return this.setCamera({
        x: -(e.x - r / 2),
        y: -(e.y - i / 2),
        z: s.z
      }, n), this;
    }
    zoomToContent() {
      const e = this.selectionPageBounds ?? this.currentPageBounds;
      return e && this.zoomToBounds(e, Math.min(1, this.zoomLevel), {
        duration: 220
      }), this;
    }
    zoomToFit(e) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const n = [
        ...this.currentPageShapeIds
      ];
      if (n.length <= 0)
        return this;
      const r = Te.Common(Je(n.map((i) => this.getShapePageBounds(i))));
      return this.zoomToBounds(r, void 0, e), this;
    }
    resetZoom(e = this.viewportScreenCenter, n) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const { x: r, y: i, z: s } = this.camera, { x: o, y: a } = e;
      return this.setCamera({
        x: r + (o / 1 - o) - (o / s - o),
        y: i + (a / 1 - a) - (a / s - a),
        z: 1
      }, n), this;
    }
    zoomIn(e = this.viewportScreenCenter, n) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const { x: r, y: i, z: s } = this.camera;
      let o = Fu;
      for (let c = 1; c < fp.length; c++) {
        const u = fp[c - 1], d = fp[c];
        if (!(d - s <= (d - u) / 2)) {
          o = d;
          break;
        }
      }
      const { x: a, y: l } = e;
      return this.setCamera({
        x: r + (a / o - a) - (a / s - a),
        y: i + (l / o - l) - (l / s - l),
        z: o
      }, n), this;
    }
    zoomOut(e = this.viewportScreenCenter, n) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const { x: r, y: i, z: s } = this.camera;
      let o = zy;
      for (let c = fp.length - 1; c > 0; c--) {
        const u = fp[c - 1], d = fp[c];
        if (!(d - s >= (d - u) / 2)) {
          o = u;
          break;
        }
      }
      const { x: a, y: l } = e;
      return this.setCamera({
        x: r + (a / o - a) - (a / s - a),
        y: i + (l / o - l) - (l / s - l),
        z: o
      }, n), this;
    }
    zoomToSelection(e) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const { selectionPageBounds: n } = this;
      return n ? (this.zoomToBounds(n, Math.max(1, this.zoomLevel), e), this) : this;
    }
    panZoomIntoView(e, n) {
      if (!this.instanceState.canMoveCamera)
        return this;
      if (e.length <= 0)
        return this;
      const r = Te.Common(Je(e.map((s) => this.getShapePageBounds(s)))), { viewportPageBounds: i } = this;
      if (i.h < r.h || i.w < r.w)
        return this.zoomToBounds(r, this.camera.z, n), this;
      {
        const s = this.viewportPageBounds.clone().expandBy(-32 / this.zoomLevel);
        let o = 0, a = 0;
        s.maxY < r.maxY ? a = s.maxY - r.maxY : s.minY > r.minY && (a = s.minY - r.minY), s.maxX < r.maxX ? o = s.maxX - r.maxX : s.minX > r.minX && (o = s.minX - r.minX);
        const { camera: l } = this;
        this.setCamera({
          x: l.x + o,
          y: l.y + a,
          z: l.z
        }, n);
      }
      return this;
    }
    zoomToBounds(e, n, r) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const { viewportScreenBounds: i } = this, s = Math.min(256, i.width * 0.28);
      let o = _a(Math.min((i.width - s) / e.width, (i.height - s) / e.height), zy, Fu);
      return n !== void 0 && (o = Math.min(n, o)), this.setCamera({
        x: -e.minX + (i.width - e.width * o) / 2 / o,
        y: -e.minY + (i.height - e.height * o) / 2 / o,
        z: o
      }, r), this;
    }
    pan(e, n) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const { x: r, y: i, z: s } = this.camera;
      return this.setCamera({
        x: r + e.x / s,
        y: i + e.y / s,
        z: s
      }, n), this;
    }
    stopCameraAnimation() {
      return this.emit("stop-camera-animation"), this;
    }
    _animateViewport(e) {
      if (!this._viewportAnimation)
        return;
      const n = () => {
        this.removeListener("tick", this._animateViewport), this.removeListener("stop-camera-animation", n), this._viewportAnimation = null;
      };
      this.once("stop-camera-animation", n), this._viewportAnimation.elapsed += e;
      const { elapsed: r, easing: i, duration: s, start: o, end: a } = this._viewportAnimation;
      if (r > s) {
        this._setCamera({
          x: -a.x,
          y: -a.y,
          z: this.viewportScreenBounds.width / a.width
        }), n();
        return;
      }
      const l = s - r, c = i(1 - l / s), u = o.minX + (a.minX - o.minX) * c, d = o.minY + (a.minY - o.minY) * c, h = o.maxX + (a.maxX - o.maxX) * c;
      this._setCamera({
        x: -u,
        y: -d,
        z: this.viewportScreenBounds.width / (h - u)
      });
    }
    _animateToViewport(e, n = {}) {
      const { duration: r = 0, easing: i = Oi.easeInOutCubic } = n, { user: { animationSpeed: s }, viewportPageBounds: o } = this;
      return this.stopCameraAnimation(), this.instanceState.followingUserId && this.stopFollowingUser(), r === 0 || s === 0 ? this._setCamera({
        x: -e.x,
        y: -e.y,
        z: this.viewportScreenBounds.width / e.width
      }) : (this._viewportAnimation = {
        elapsed: 0,
        duration: r / s,
        easing: i,
        start: o.clone(),
        end: e.clone()
      }, this.addListener("tick", this._animateViewport), this);
    }
    slideCamera(e = {}) {
      if (!this.instanceState.canMoveCamera)
        return this;
      this.stopCameraAnimation();
      const { animationSpeed: n } = this.user;
      if (n === 0)
        return this;
      const { speed: r, friction: i, direction: s, speedThreshold: o = 0.01 } = e;
      let a = Math.min(r, 1);
      const l = () => {
        this.removeListener("tick", c), this.removeListener("stop-camera-animation", l);
      };
      this.once("stop-camera-animation", l);
      const c = (u) => {
        const { x: d, y: h, z: f } = this.camera, y = I.Mul(s, a * u / f);
        a *= 1 - i, a < o ? l() : this._setCamera({
          x: d + y.x,
          y: h + y.y,
          z: f
        });
      };
      return this.addListener("tick", c), this;
    }
    animateToUser(e) {
      const r = [
        ...this.store.query.records("instance_presence", () => ({
          userId: {
            eq: e
          }
        })).value
      ].sort((i, s) => i.lastActivityTimestamp - s.lastActivityTimestamp).pop();
      return r ? (this.batch(() => {
        this.instanceState.followingUserId !== null && this.stopFollowingUser();
        const i = r.currentPageId === this.currentPageId;
        i || this.setCurrentPage(r.currentPageId);
        const s = i ? {
          duration: 500
        } : void 0;
        this.centerOnPoint(r.cursor, s);
        const { highlightedUserIds: o } = this.instanceState;
        this.updateInstanceState({
          highlightedUserIds: [
            ...o,
            e
          ]
        }), setTimeout(() => {
          const a = [
            ...this.instanceState.highlightedUserIds
          ], l = a.indexOf(e);
          l < 0 || (a.splice(l, 1), this.updateInstanceState({
            highlightedUserIds: a
          }));
        }, SG);
      }), this) : this;
    }
    animateToShape(e, n = Cke) {
      if (!this.instanceState.canMoveCamera)
        return this;
      const r = this.viewportScreenBounds.clone().expandBy(-32), i = r.width / r.height, s = this.getShapePageBounds(e);
      if (!s)
        return this;
      const o = s.width / s.height, a = s.clone(), l = s.width / r.width;
      return a.width += (r.minX + r.maxX) * l, a.height += (r.minY + r.maxY) * l, a.x -= r.minX * l, a.y -= r.minY * l, o > i ? (a.height = s.width / i, a.y -= (a.height - s.height) / 2) : (a.width = s.height * i, a.x -= (a.width - s.width) / 2), this._animateToViewport(a, n);
    }
    updateViewportScreenBounds(e = false) {
      const n = this.getContainer();
      if (!n)
        return this;
      const r = n.getBoundingClientRect(), i = new Te(r.left || r.x, r.top || r.y, Math.max(r.width, 1), Math.max(r.height, 1)), s = i.equals(this.viewportScreenBounds), { _willSetInitialBounds: o } = this;
      if (s)
        this._willSetInitialBounds = false;
      else if (o)
        this._willSetInitialBounds = false, this.updateInstanceState({
          screenBounds: i.toJson()
        }, {
          squashing: true,
          ephemeral: true
        });
      else if (e && !this.instanceState.followingUserId) {
        const a = this.viewportPageCenter;
        this.updateInstanceState({
          screenBounds: i.toJson()
        }, {
          squashing: true,
          ephemeral: true
        }), this.centerOnPoint(a);
      } else
        this.updateInstanceState({
          screenBounds: i.toJson()
        }, {
          squashing: true,
          ephemeral: true
        });
      return this._tickCameraState(), this.updateRenderingBounds(), this;
    }
    get viewportScreenBounds() {
      const { x: e, y: n, w: r, h: i } = this.instanceState.screenBounds;
      return new Te(e, n, r, i);
    }
    get viewportScreenCenter() {
      return this.viewportScreenBounds.center;
    }
    get viewportPageBounds() {
      const { w: e, h: n } = this.viewportScreenBounds, { x: r, y: i, z: s } = this.camera;
      return new Te(-r, -i, e / s, n / s);
    }
    get viewportPageCenter() {
      return this.viewportPageBounds.center;
    }
    screenToPage(e) {
      const { screenBounds: n } = this.store.unsafeGetWithoutCapture(gi), { x: r, y: i, z: s = 1 } = this.camera;
      return {
        x: (e.x - n.x) / s - r,
        y: (e.y - n.y) / s - i,
        z: e.z ?? 0.5
      };
    }
    pageToScreen(e) {
      const { screenBounds: n } = this.store.unsafeGetWithoutCapture(gi), { x: r, y: i, z: s = 1 } = this.camera;
      return {
        x: (e.x + r) * s + n.x,
        y: (e.y + i) * s + n.y,
        z: e.z ?? 0.5
      };
    }
    startFollowingUser(e) {
      const n = this.store.query.records("instance_presence", () => ({
        userId: {
          eq: e
        }
      })), r = this.user.id;
      if (r || console.warn("You should set the userId for the current instance before following a user"), n.value.some((a) => a.followingUserId === r))
        return this;
      Ca(() => {
        this.stopFollowingUser(), this.updateInstanceState({
          followingUserId: e
        }, {
          ephemeral: true
        });
      });
      const i = () => {
        this.removeListener("frame", o), this.removeListener("stop-following", i);
      };
      let s = false;
      const o = () => {
        const a = [
          ...n.value
        ].sort((M, R) => M.lastActivityTimestamp - R.lastActivityTimestamp).pop();
        if (!a) {
          this.stopFollowingUser();
          return;
        }
        const l = a.currentPageId === this.currentPageId, c = l ? vke : 1;
        if (!l) {
          this.stopFollowingUser(), this.setCurrentPage(a.currentPageId), this.startFollowingUser(e);
          return;
        }
        const { center: u, width: d, height: h } = this.viewportPageBounds, f = Te.From(a.screenBounds), y = f.width / a.camera.z, g = f.height / a.camera.z, O = new I(y / 2 - a.camera.x, g / 2 - a.camera.y), S = a.followingUserId === r, w = d + (y - d) * c, x = h + (g - h) * c, P = S ? h / x : Math.min(d / w, h / x), C = _a(this.camera.z * P, zy, Fu), _ = this.viewportScreenBounds.w / C, T = this.viewportScreenBounds.h / C, $ = O.sub(u), N = I.Add(u, I.Mul($, c)), L = I.Sub(N, u).len(), z = Math.abs(C - this.camera.z);
        if (L < Oke && z < wke) {
          s = true;
          return;
        }
        s && L < Ske && z < xke || (s = false, this.stopCameraAnimation(), this._setCamera({
          x: -(N.x - _ / 2),
          y: -(N.y - T / 2),
          z: C
        }));
      };
      return this.once("stop-following", i), this.addListener("frame", o), this;
    }
    stopFollowingUser() {
      return this.updateInstanceState({
        followingUserId: null
      }, {
        ephemeral: true
      }), this.emit("stop-following"), this;
    }
    get cameraState() {
      return this._cameraState.value;
    }
    getUnorderedRenderingShapes(e) {
      const n = [];
      let r = gc * 2, i = gc;
      const s = this.editingShapeId, o = this.selectedShapeIds, a = this.erasingShapeIds, l = this.renderingBoundsExpanded, c = Number.isFinite(this.renderingBoundsMargin), u = (d, h, f) => {
        const y = this.getShape(d);
        if (!y)
          return;
        h *= y.opacity;
        let g = false, O = false;
        const S = this.getShapeUtil(y), w = this.getShapeMaskedPageBounds(d);
        e && (O = !f && a.includes(d), O && (h *= 0.32), g = c && S.canUnmount(y) && s !== d && (w === void 0 || !l.includes(w) && !o.includes(d))), n.push({
          id: d,
          shape: y,
          util: S,
          index: r,
          backgroundIndex: i,
          opacity: h,
          isCulled: g,
          maskedPageBounds: w
        }), r += 1, i += 1;
        const x = this.getSortedChildIdsForParent(d);
        if (!x.length)
          return;
        let P = null;
        S.providesBackgroundForChildren(y) && (P = i, i = r, r += gc);
        for (const C of x)
          u(C, h, f || O);
        P !== null && (i = P);
      };
      for (const d of this.getSortedChildIdsForParent(this.currentPageId))
        u(d, 1, false);
      return n;
    }
    get renderingShapes() {
      return this.getUnorderedRenderingShapes(true).sort(oxe);
    }
    get renderingBounds() {
      return this._renderingBounds.value;
    }
    get renderingBoundsExpanded() {
      return this._renderingBoundsExpanded.value;
    }
    updateRenderingBounds() {
      const { viewportPageBounds: e } = this;
      return e.equals(this._renderingBounds.__unsafe__getWithoutCapture()) ? this : (this._renderingBounds.set(e.clone()), Number.isFinite(this.renderingBoundsMargin) ? this._renderingBoundsExpanded.set(e.clone().expandBy(this.renderingBoundsMargin / this.zoomLevel)) : this._renderingBoundsExpanded.set(e), this);
    }
    get _pages() {
      return this.store.query.records("page");
    }
    get pages() {
      return this._pages.value.sort(hi);
    }
    get currentPage() {
      return this.getPage(this.currentPageId);
    }
    get currentPageId() {
      return this.instanceState.currentPageId;
    }
    getPage(e) {
      return this.store.get(typeof e == "string" ? e : e.id);
    }
    get currentPageShapeIds() {
      return this._currentPageShapeIds.value;
    }
    getPageShapeIds(e) {
      const n = typeof e == "string" ? e : e.id, r = this.store.query.exec("shape", {
        parentId: {
          eq: n
        }
      });
      return this.getShapeAndDescendantIds(r.map((i) => i.id));
    }
    setCurrentPage(e, n) {
      const r = typeof e == "string" ? e : e.id;
      return this._setCurrentPageId(r, n), this;
    }
    updatePage(e, n) {
      return this._updatePage(e, n), this;
    }
    createPage(e) {
      return this._createPage(e), this;
    }
    deletePage(e) {
      const n = typeof e == "string" ? e : e.id;
      return this._deletePage(n), this;
    }
    duplicatePage(e, n = Zc.createId()) {
      if (this.pages.length >= Ck)
        return this;
      const r = typeof e == "string" ? e : e.id, i = this.getPage(r);
      if (!i)
        return this;
      const s = {
        ...this.camera
      }, o = this.getContentFromCurrentPage(this.getSortedChildIdsForParent(i.id));
      return this.batch(() => {
        var _a3;
        const { pages: a } = this, l = G0(i.index, (_a3 = a[a.indexOf(i) + 1]) == null ? void 0 : _a3.index);
        if (this.createPage({
          name: i.name + " Copy",
          id: n,
          index: l
        }), this.setCurrentPage(n), this.setCamera(s), o)
          return this.putContentOntoCurrentPage(o);
      }), this;
    }
    renamePage(e, n, r) {
      const i = typeof e == "string" ? e : e.id;
      return this.instanceState.isReadonly ? this : (this.updatePage({
        id: i,
        name: n
      }, r), this);
    }
    get _assets() {
      return this.store.query.records("asset");
    }
    get assets() {
      return this._assets.value;
    }
    createAssets(e) {
      return this._createAssets(e), this;
    }
    updateAssets(e) {
      return this._updateAssets(e), this;
    }
    deleteAssets(e) {
      const n = typeof e[0] == "string" ? e : e.map((r) => r.id);
      return this._deleteAssets(n), this;
    }
    getAsset(e) {
      return this.store.get(typeof e == "string" ? e : e.id);
    }
    get _shapeGeometryCache() {
      return this.store.createComputedCache("bounds", (e) => this.getShapeUtil(e).getGeometry(e), (e, n) => e.props === n.props);
    }
    getShapeGeometry(e) {
      return this._shapeGeometryCache.get(typeof e == "string" ? e : e.id);
    }
    get _shapeOutlineSegmentsCache() {
      return this.store.createComputedCache("outline-segments", (e) => this.getShapeUtil(e).getOutlineSegments(e));
    }
    getShapeOutlineSegments(e) {
      return this._shapeOutlineSegmentsCache.get(typeof e == "string" ? e : e.id) ?? Rc;
    }
    get _shapeHandlesCache() {
      return this.store.createComputedCache("handles", (e) => {
        var _a3, _b3;
        return (_b3 = (_a3 = this.getShapeUtil(e)).getHandles) == null ? void 0 : _b3.call(_a3, e);
      });
    }
    getShapeHandles(e) {
      return this._shapeHandlesCache.get(typeof e == "string" ? e : e.id);
    }
    getShapeLocalTransform(e) {
      const n = typeof e == "string" ? e : e.id, r = this.getShape(n);
      if (!r)
        throw Error("Editor.getTransform: shape not found");
      return Se.Identity().translate(r.x, r.y).rotate(r.rotation);
    }
    get _shapePageTransformCache() {
      return this.store.createComputedCache("pageTransformCache", (e) => {
        if (rs(e.parentId))
          return this.getShapeLocalTransform(e);
        const n = this._shapePageTransformCache.get(e.parentId) ?? Se.Identity();
        return Se.Compose(n, this.getShapeLocalTransform(e));
      });
    }
    getShapeParentTransform(e) {
      const n = typeof e == "string" ? e : e.id, r = this.getShape(n);
      return !r || rs(r.parentId) ? Se.Identity() : this._shapePageTransformCache.get(r.parentId) ?? Se.Identity();
    }
    getShapePageTransform(e) {
      const n = typeof e == "string" ? e : this.getShape(e).id;
      return this._shapePageTransformCache.get(n) ?? Se.Identity();
    }
    get _shapePageBoundsCache() {
      return this.store.createComputedCache("pageBoundsCache", (e) => {
        const n = this._shapePageTransformCache.get(e.id);
        return n ? Te.FromPoints(Se.applyToPoints(n, this.getShapeGeometry(e).vertices)) : new Te();
      });
    }
    getShapePageBounds(e) {
      return this._shapePageBoundsCache.get(typeof e == "string" ? e : e.id);
    }
    get _shapeClipPathCache() {
      return this.store.createComputedCache("clipPathCache", (e) => {
        const n = this._shapeMaskCache.get(e.id);
        if (!n)
          return;
        const r = this._shapePageTransformCache.get(e.id);
        return r ? n.length === 0 ? "polygon(0px 0px, 0px 0px, 0px 0px)" : `polygon(${Se.applyToPoints(Se.Inverse(r), n).map((s) => `${s.x}px ${s.y}px`).join(",")})` : void 0;
      });
    }
    getShapeClipPath(e) {
      return this._shapeClipPathCache.get(typeof e == "string" ? e : e.id);
    }
    get _shapeMaskCache() {
      return this.store.createComputedCache("pageMaskCache", (e) => {
        if (rs(e.parentId))
          return;
        const n = this.getShapeAncestors(e.id).filter((i) => this.isShapeOfType(i, "frame"));
        return n.length === 0 ? void 0 : n.map((i) => this._shapePageTransformCache.get(i.id).applyToPoints(this.getShapeGeometry(i).vertices)).reduce((i, s) => {
          if (!(s && i))
            return;
          const o = sR(i, s);
          return o ? o.map(I.Cast) : [];
        });
      });
    }
    getShapeMask(e) {
      return this._shapeMaskCache.get(typeof e == "string" ? e : e.id);
    }
    getShapeMaskedPageBounds(e) {
      typeof e != "string" && (e = e.id);
      const n = this._shapePageBoundsCache.get(e);
      if (!n)
        return;
      const r = this._shapeMaskCache.get(e);
      if (r) {
        const i = sR(r, n.corners);
        return i ? Te.FromPoints(i) : void 0;
      }
      return n;
    }
    getShapeAncestors(e, n = []) {
      const r = typeof e == "string" ? e : e.id, i = this.getShape(r);
      if (!i)
        return n;
      const s = i.parentId;
      if (rs(s))
        return n.reverse(), n;
      const o = this.store.get(s);
      return o ? (n.push(o), this.getShapeAncestors(o, n)) : n;
    }
    findShapeAncestor(e, n) {
      const r = typeof e == "string" ? e : e.id, i = this.getShape(r);
      if (!i)
        return;
      const s = i.parentId;
      if (rs(s))
        return;
      const o = this.getShape(s);
      if (o)
        return n(o) ? o : this.findShapeAncestor(o, n);
    }
    hasAncestor(e, n) {
      const r = typeof e == "string" ? e : e == null ? void 0 : e.id, i = r && this.getShape(r);
      return i ? i.parentId === n ? true : this.hasAncestor(this.getShapeParent(i), n) : false;
    }
    findCommonAncestor(e, n) {
      var _a3;
      if (e.length === 0)
        return;
      const r = typeof e[0] == "string" ? e : e.map((l) => l.id), i = Je(r.map((l) => this.getShape(l)));
      if (i.length === 1) {
        const l = i[0].parentId;
        return rs(l) ? void 0 : n ? (_a3 = this.findShapeAncestor(i[0], n)) == null ? void 0 : _a3.id : l;
      }
      const [s, ...o] = i;
      let a = this.getShapeParent(s);
      for (; a; ) {
        if (n && !n(a)) {
          a = this.getShapeParent(a);
          continue;
        }
        if (o.every((l) => this.hasAncestor(l, a.id)))
          return a.id;
        a = this.getShapeParent(a);
      }
    }
    isShapeOrAncestorLocked(e) {
      const n = typeof e == "string" ? this.getShape(e) : e;
      return n === void 0 ? false : n.isLocked ? true : this.isShapeOrAncestorLocked(this.getShapeParent(n));
    }
    get currentPageBounds() {
      let e;
      return this.currentPageShapeIds.forEach((n) => {
        const r = this.getShapeMaskedPageBounds(n);
        r && (e ? e = e.expand(r) : e = r.clone());
      }), e;
    }
    getSelectedShapeAtPoint(e) {
      const { selectedShapeIds: n } = this;
      return this.currentPageShapesSorted.filter((r) => r.type !== "group" && n.includes(r.id)).reverse().find((r) => this.isPointInShape(r, e, {
        hitInside: true,
        margin: 0
      }));
    }
    getShapeAtPoint(e, n = {}) {
      const { viewportPageBounds: r, zoomLevel: i } = this, { filter: s, margin: o = 0, hitLabels: a = false, hitInside: l = false, hitFrameInside: c = false } = n;
      let u = 1 / 0, d = null, h = 1 / 0, f = null;
      const y = (n.renderingOnly ? this.currentPageRenderingShapesSorted : this.currentPageShapesSorted).filter((g) => {
        if (this.isShapeOfType(g, "group"))
          return false;
        const O = this.getShapeMask(g);
        return O && !Ql(e, O) ? false : s ? s(g) : true;
      });
      for (let g = y.length - 1; g >= 0; g--) {
        const O = y[g], S = this.getShapeGeometry(O), w = S instanceof Yu, x = this.getPointInShapeSpace(O, e);
        if ((this.isShapeOfType(O, "arrow") || this.isShapeOfType(O, "geo") && O.props.fill === "none") && O.props.text.trim()) {
          for (const C of S.children)
            if (C.isLabel && C.isPointInBounds(x))
              return O;
        }
        if (this.isShapeOfType(O, "frame")) {
          const C = S.distanceToPoint(x, l);
          if (Math.abs(C) <= o)
            return f || O;
          if (S.hitTestPoint(x, 0, true))
            return f || d || (c ? O : void 0);
          continue;
        }
        let P;
        if (w) {
          let C = 1 / 0;
          for (const _ of S.children) {
            if (_.isLabel && !a)
              continue;
            const T = _.distanceToPoint(x, l);
            T < C && (C = T);
          }
          P = C;
        } else
          o === 0 && (S.bounds.w < 1 || S.bounds.h < 1) || S.bounds.containsPoint(x, o) ? P = S.distanceToPoint(x, l) : P = 1 / 0;
        if (S.isClosed) {
          if (P <= o) {
            if (S.isFilled || w && S.children[0].isFilled)
              return f || O;
            if (this.getShapePageBounds(O).contains(r))
              continue;
            if (Math.abs(P) < o)
              Math.abs(P) < h && (h = Math.abs(P), f = O);
            else if (!f) {
              const { area: C } = S;
              C < u && (u = C, d = O);
            }
          }
        } else if (P < Va / i)
          return O;
      }
      return f || d || void 0;
    }
    getShapesAtPoint(e, n = {}) {
      return this.currentPageShapes.filter((r) => this.isPointInShape(r, e, n));
    }
    isPointInShape(e, n, r = {}) {
      const { hitInside: i = false, margin: s = 0 } = r, o = typeof e == "string" ? e : e.id, a = this.getShapeMask(o);
      return a && !Ql(n, a) ? false : this.getShapeGeometry(o).hitTestPoint(this.getPointInShapeSpace(e, n), s, i);
    }
    getPointInShapeSpace(e, n) {
      const r = typeof e == "string" ? e : e.id;
      return this._shapePageTransformCache.get(r).clone().invert().applyToPoint(n);
    }
    getPointInParentSpace(e, n) {
      const r = typeof e == "string" ? e : e.id, i = this.getShape(r);
      if (!i)
        return new I(0, 0);
      if (rs(i.parentId))
        return I.From(n);
      const s = this.getShapePageTransform(i.parentId);
      return s ? s.clone().invert().applyToPoint(n) : I.From(n);
    }
    get currentPageShapes() {
      return Array.from(this.currentPageShapeIds, (e) => this.store.get(e));
    }
    get currentPageShapesSorted() {
      const e = new Set(this.currentPageShapes.sort(hi)), n = [];
      function r(i) {
        n.push(i), e.delete(i), e.forEach((s) => {
          s.parentId === i.id && r(s);
        });
      }
      return e.forEach((i) => {
        const s = this.getShape(i.parentId);
        Dh(s) || r(i);
      }), n;
    }
    get currentPageRenderingShapesSorted() {
      return this.renderingShapes.filter(({ isCulled: e }) => !e).sort((e, n) => e.index - n.index).map(({ shape: e }) => e);
    }
    isShapeOfType(e, n) {
      return (typeof e == "string" ? this.getShape(e) : e).type === n;
    }
    getShape(e) {
      const n = typeof e == "string" ? e : e.id;
      if (Ro(n))
        return this.store.get(n);
    }
    getShapeParent(e) {
      const n = typeof e == "string" ? e : e == null ? void 0 : e.id;
      if (!n)
        return;
      const r = this.getShape(n);
      if (!(r === void 0 || !Ro(r.parentId)))
        return this.store.get(r.parentId);
    }
    getShapeNearestSibling(e, n) {
      return n ? n.parentId === e.parentId ? n : this.findShapeAncestor(n, (i) => i.parentId === e.parentId) : void 0;
    }
    isShapeInPage(e, n = this.currentPageId) {
      const r = typeof e == "string" ? e : e.id, i = this.getShape(r);
      if (!i)
        return false;
      let s = false;
      if (i.parentId === n)
        s = true;
      else {
        let o = this.getShape(i.parentId);
        e:
          for (; o; ) {
            if (o.parentId === n) {
              s = true;
              break e;
            }
            o = this.getShape(o.parentId);
          }
      }
      return s;
    }
    getAncestorPageId(e) {
      const n = typeof e == "string" ? e : e == null ? void 0 : e.id, r = n && this.getShape(n);
      if (r)
        return rs(r.parentId) ? r.parentId : this.getAncestorPageId(this.getShape(r.parentId));
    }
    reparentShapes(e, n, r) {
      const i = typeof e[0] == "string" ? e : e.map((f) => f.id), s = [], o = rs(n) ? Se.Identity() : this.getShapePageTransform(n), a = o.rotation();
      let l = [];
      const c = Je(this.getSortedChildIdsForParent(n).map((f) => this.getShape(f)));
      if (r) {
        const f = c.find((y) => y.index === r);
        if (f) {
          const y = c[c.indexOf(f) + 1];
          y ? l = zg(r, y.index, i.length) : l = TE(r, i.length);
        } else {
          const y = c.sort(hi).find((g) => g.index > r);
          y ? l = zg(r, y.index, i.length) : l = TE(r, i.length);
        }
      } else {
        const f = c.length && c[c.length - 1];
        l = f ? TE(f.index, i.length) : sq(i.length);
      }
      const u = o.clone().invert(), d = Je(i.map((f) => this.getShape(f))), h = d.filter((f) => f.isLocked);
      h.length && this.updateShapes(h.map(({ id: f, type: y }) => ({
        id: f,
        type: y,
        isLocked: false
      })));
      for (let f = 0; f < d.length; f++) {
        const y = d[f], g = this.getShapePageTransform(y);
        if (!g)
          continue;
        const O = g.point();
        if (!O)
          continue;
        const S = u.applyToPoint(O), w = g.rotation() - a;
        s.push({
          id: y.id,
          type: y.type,
          parentId: n,
          x: S.x,
          y: S.y,
          rotation: w,
          index: l[f],
          isLocked: y.isLocked
        });
      }
      return this.updateShapes(s), this;
    }
    getHighestIndexForParent(e) {
      const n = typeof e == "string" ? e : e.id, r = this._parentIdsToChildIds.value[n];
      if (!r || r.length === 0)
        return "a1";
      const i = this.getShape(r[r.length - 1]);
      return wc(i.index);
    }
    getSortedChildIdsForParent(e) {
      const n = typeof e == "string" ? e : e.id, r = this._parentIdsToChildIds.value[n];
      return r ? this._childIdsCache.get(r, () => r) : Rc;
    }
    visitDescendants(e, n) {
      const r = typeof e == "string" ? e : e.id, i = this.getSortedChildIdsForParent(r);
      for (const s of i)
        n(s) !== false && this.visitDescendants(s, n);
      return this;
    }
    getShapeAndDescendantIds(e) {
      const n = /* @__PURE__ */ new Set(), r = [
        ...e
      ];
      for (; r.length > 0; ) {
        const i = r.pop();
        if (!i)
          break;
        if (!n.has(i)) {
          n.add(i);
          for (const s of this.getSortedChildIdsForParent(i))
            r.push(s);
        }
      }
      return n;
    }
    getDroppingOverShape(e, n = []) {
      const { currentPageShapesSorted: r } = this;
      for (let i = r.length - 1; i >= 0; i--) {
        const s = r[i];
        if (!this.getShapeUtil(s).canDropShapes(s, n) || n.find((a) => a.id === s.id || this.hasAncestor(s, a.id)))
          continue;
        const o = this.getShapeMaskedPageBounds(s.id);
        if (o && o.containsPoint(e) && this.getShapeGeometry(s).hitTestPoint(this.getPointInShapeSpace(s, e), 0, true))
          return s;
      }
    }
    getOutermostSelectableShape(e, n) {
      const r = typeof e == "string" ? e : e.id, i = this.getShape(r);
      let s = i, o = i;
      const { focusedGroup: a } = this;
      for (; o; ) {
        if (this.isShapeOfType(o, "group") && (a == null ? void 0 : a.id) !== o.id && !this.hasAncestor(a, o.id) && ((n == null ? void 0 : n(o)) ?? true))
          s = o;
        else if ((a == null ? void 0 : a.id) === o.id)
          break;
        o = this.getShapeParent(o);
      }
      return s;
    }
    rotateShapesBy(e, n) {
      if ((typeof e[0] == "string" ? e : e.map((s) => s.id)).length <= 0)
        return this;
      const i = oq({
        editor: this
      });
      return i ? (Yx({
        delta: n,
        snapshot: i,
        editor: this,
        stage: "one-off"
      }), this) : this;
    }
    nudgeShapes(e, n, r) {
      var _a3, _b3;
      const i = typeof e[0] == "string" ? e : e.map((o) => o.id);
      if (i.length <= 0)
        return this;
      const s = [];
      for (const o of i) {
        const a = this.getShape(o);
        if (!a)
          throw Error(`Could not find a shape with the id ${o}.`);
        const l = I.Cast(n), c = this.getShapeParentTransform(a);
        c && l.rot(-c.rotation());
        const u = (_b3 = (_a3 = this.getShapeUtil(a)).onTranslateStart) == null ? void 0 : _b3.call(_a3, a);
        s.push(u ? {
          ...u,
          x: a.x + l.x,
          y: a.y + l.y
        } : {
          id: o,
          x: a.x + l.x,
          y: a.y + l.y,
          type: a.type
        });
      }
      return this.updateShapes(s, {
        squashing: true,
        ...r
      }), this;
    }
    duplicateShapes(e, n) {
      const r = typeof e[0] == "string" ? e : e.map((c) => c.id);
      if (r.length <= 0)
        return this;
      const i = new Set(r), s = [], o = [
        ...r
      ];
      for (; o.length > 0; ) {
        const c = o.pop();
        if (!c)
          break;
        s.push(c), this.getSortedChildIdsForParent(c).forEach((u) => o.push(u));
      }
      s.reverse();
      const a = new Map(s.map((c) => [
        c,
        bn()
      ])), l = Je(s.map((c) => {
        const u = this.getShape(c);
        if (!u)
          return null;
        const d = a.get(c);
        let h = 0, f = 0;
        if (n && i.has(c)) {
          const C = this.getShapeParentTransform(u), _ = new I(n.x, n.y).rot(-C.rotation());
          h = _.x, f = _.y;
        }
        const y = u.parentId ?? this.currentPageId, g = this.getSortedChildIdsForParent(y), O = g.indexOf(u.id), S = g[O + 1], w = S ? this.getShape(S) : null, x = w ? G0(u.index, w.index) : wc(u.index);
        let P = wi(u);
        if (this.isShapeOfType(u, "arrow") && this.isShapeOfType(P, "arrow")) {
          const C = this.getArrowInfo(u);
          let _, T;
          if (u.props.start.type === "binding" && (_ = a.get(u.props.start.boundShapeId), !_))
            if (C == null ? void 0 : C.isValid) {
              const { x: N, y: L } = C.start.point;
              P.props.start = {
                type: "point",
                x: N,
                y: L
              };
            } else {
              const { start: N } = Ia(this, u);
              P.props.start = {
                type: "point",
                x: N.x,
                y: N.y
              };
            }
          if (u.props.end.type === "binding" && (T = a.get(u.props.end.boundShapeId), !T))
            if (C == null ? void 0 : C.isValid) {
              const { x: N, y: L } = C.end.point;
              P.props.end = {
                type: "point",
                x: N,
                y: L
              };
            } else {
              const { end: N } = Ia(this, u);
              P.props.start = {
                type: "point",
                x: N.x,
                y: N.y
              };
            }
          const $ = Fy(P) ? q0(this, P) : $E(this, P);
          if ((C == null ? void 0 : C.isValid) && ($ == null ? void 0 : $.isValid) && !Fy(u)) {
            const N = I.Med(C.start.handle, C.end.handle), L = I.Dist(C.middle, N), z = I.Dist($.middle, N);
            P.props.bend < 0 ? P.props.bend += z - L : P.props.bend -= z - L;
          }
          P.props.start.type === "binding" && _ && (P.props.start.boundShapeId = _), P.props.end.type === "binding" && T && (P.props.end.boundShapeId = T);
        }
        return P = {
          ...P,
          id: d,
          x: u.x + h,
          y: u.y + f,
          index: x
        }, P;
      }));
      return l.forEach((c) => {
        Ro(c.parentId) && a.has(c.parentId) && (c.parentId = a.get(c.parentId));
      }), this.history.batch(() => {
        const c = l.length + this.currentPageShapeIds.size > gc;
        c && vw(this);
        const u = c ? l.slice(0, gc - this.currentPageShapeIds.size) : l, d = u.map((h) => h.id);
        if (this.createShapes(u), this.setSelectedShapes(d), n !== void 0) {
          const { viewportPageBounds: h, selectionPageBounds: f } = this;
          f && !h.contains(f) && this.centerOnPoint(f.center, {
            duration: Pc
          });
        }
      }), this;
    }
    moveShapesToPage(e, n) {
      const r = typeof e[0] == "string" ? e : e.map((a) => a.id);
      if (r.length === 0)
        return this;
      if (this.instanceState.isReadonly)
        return this;
      const { currentPageId: i } = this;
      if (n === i)
        return this;
      if (!this.store.has(n))
        return this;
      const s = this.getContentFromCurrentPage(r);
      if (!s)
        return this;
      if (this.getPageShapeIds(n).size + s.shapes.length > gc)
        return vw(this, n), this;
      const o = this.camera.z;
      return this.history.batch(() => {
        this.deleteShapes(r), this.setCurrentPage(n), this.setFocusedGroup(null), this.selectNone(), this.putContentOntoCurrentPage(s, {
          select: true,
          preserveIds: true,
          preservePosition: true
        }), this.setCamera({
          ...this.camera,
          z: o
        }), this.centerOnPoint(this.selectionRotatedPageBounds.center);
      }), this;
    }
    toggleLock(e) {
      const n = typeof e[0] == "string" ? e : e.map((o) => o.id);
      if (this.instanceState.isReadonly || n.length === 0)
        return this;
      let r = true, i = true;
      const s = [];
      for (const o of n) {
        const a = this.getShape(o);
        a && (s.push(a), a.isLocked ? i = false : r = false);
      }
      return this.batch(() => {
        i ? (this.updateShapes(s.map((o) => ({
          id: o.id,
          type: o.type,
          isLocked: true
        }))), this.setSelectedShapes([])) : r ? this.updateShapes(s.map((o) => ({
          id: o.id,
          type: o.type,
          isLocked: false
        }))) : this.updateShapes(s.map((o) => ({
          id: o.id,
          type: o.type,
          isLocked: true
        })));
      }), this;
    }
    sendToBack(e) {
      const n = typeof e[0] == "string" ? e : e.map((i) => i.id), r = yw(this, "toBack", n);
      return r && this.updateShapes(r), this;
    }
    sendBackward(e) {
      const n = typeof e[0] == "string" ? e : e.map((i) => i.id), r = yw(this, "backward", n);
      return r && this.updateShapes(r), this;
    }
    bringForward(e) {
      const n = typeof e[0] == "string" ? e : e.map((i) => i.id), r = yw(this, "forward", n);
      return r && this.updateShapes(r), this;
    }
    bringToFront(e) {
      const n = typeof e[0] == "string" ? e : e.map((i) => i.id), r = yw(this, "toFront", n);
      return r && this.updateShapes(r), this;
    }
    flipShapes(e, n) {
      const r = typeof e[0] == "string" ? e : e.map((o) => o.id);
      if (this.instanceState.isReadonly)
        return this;
      let i = Je(r.map((o) => this.getShape(o)));
      if (!i.length)
        return this;
      i = Je(i.map((o) => this.isShapeOfType(o, "group") ? this.getSortedChildIdsForParent(o.id).map((a) => this.getShape(a)) : o).flat());
      const s = Te.Common(Je(i.map((o) => this.getShapePageBounds(o)))).center;
      return this.batch(() => {
        for (const o of i) {
          const a = this.getShapeGeometry(o).bounds, l = this.getShapePageTransform(o.id);
          l && this.resizeShape(o.id, {
            x: n === "horizontal" ? -1 : 1,
            y: n === "vertical" ? -1 : 1
          }, {
            initialBounds: a,
            initialPageTransform: l,
            initialShape: o,
            mode: "scale_shape",
            scaleOrigin: s,
            scaleAxisRotation: 0
          });
        }
      }), this;
    }
    stackShapes(e, n, r) {
      const i = typeof e[0] == "string" ? e : e.map((g) => g.id);
      if (this.instanceState.isReadonly)
        return this;
      const s = Je(i.map((g) => this.getShape(g)).filter((g) => !(!g || this.isShapeOfType(g, "arrow") && (g.props.start.type === "binding" || g.props.end.type === "binding")))), o = s.length;
      if (r === 0 && o < 3 || o < 2)
        return this;
      const a = Object.fromEntries(s.map((g) => [
        g.id,
        this.getShapePageBounds(g)
      ]));
      let l, c, u, d;
      n === "horizontal" ? (l = "x", c = "minX", u = "maxX", d = "width") : (l = "y", c = "minY", u = "maxY", d = "height");
      let h;
      if (r === 0) {
        const g = [];
        s.sort((S, w) => a[S.id][c] - a[w.id][c]);
        for (let S = 0; S < o - 1; S++) {
          const w = s[S], x = s[S + 1], P = a[w.id], _ = a[x.id][c] - P[u], T = g.find(($) => $.gap === _);
          T ? T.count++ : g.push({
            gap: _,
            count: 1
          });
        }
        let O = 0;
        g.forEach((S) => {
          S.count > O && (O = S.count, h = S.gap);
        }), O === 1 && (h = Math.max(0, g.reduce((S, w) => S + w.gap * w.count, 0) / (o - 1)));
      } else
        h = r;
      const f = [];
      let y = a[s[0].id][u];
      return s.forEach((g, O) => {
        var _a3, _b3;
        if (O === 0)
          return;
        const S = {
          x: 0,
          y: 0
        };
        S[l] = y + h - a[g.id][l];
        const w = this.getShapeParent(g), x = w ? I.Rot(S, -this.getShapePageTransform(w).decompose().rotation) : S, P = (_b3 = (_a3 = this.getShapeUtil(g)).onTranslateStart) == null ? void 0 : _b3.call(_a3, g);
        f.push(P ? {
          ...P,
          [l]: g[l] + x[l]
        } : {
          id: g.id,
          type: g.type,
          [l]: g[l] + x[l]
        }), y += a[g.id][d] + h;
      }), this.updateShapes(f), this;
    }
    packShapes(e, n) {
      var _a3, _b3;
      const r = typeof e[0] == "string" ? e : e.map((_) => _.id);
      if (this.instanceState.isReadonly)
        return this;
      if (r.length < 2)
        return this;
      const i = Je(r.map((_) => this.getShape(_)).filter((_) => !(!_ || this.isShapeOfType(_, "arrow") && (_.props.start.type === "binding" || _.props.end.type === "binding")))), s = {}, o = {};
      let a, l, c = 0;
      for (let _ = 0; _ < i.length; _++)
        a = i[_], l = this.getShapePageBounds(a), s[a.id] = l, o[a.id] = l.clone(), c += l.width * l.height;
      const u = Te.Common(Je(Object.values(s))), d = u.width;
      i.sort((_, T) => s[T.id].height - s[_.id].height);
      const h = Math.max(Math.ceil(Math.sqrt(c / 0.95)), d), f = [
        new Te(u.x, u.y, h, 1 / 0)
      ];
      let y = 0, g = 0, O, S;
      for (let _ = 0; _ < i.length; _++) {
        a = i[_], l = o[a.id];
        for (let T = f.length - 1; T >= 0; T--)
          if (O = f[T], !(l.width > O.width || l.height > O.height)) {
            l.x = O.x, l.y = O.y, g = Math.max(g, l.maxY), y = Math.max(y, l.maxX), l.width === O.width && l.height === O.height ? (S = f.pop(), T < f.length && (f[T] = S)) : l.height === O.height ? (O.x += l.width + n, O.width -= l.width + n) : l.width === O.width ? (O.y += l.height + n, O.height -= l.height + n) : (f.push(new Te(O.x + (l.width + n), O.y, O.width - (l.width + n), l.height)), O.y += l.height + n, O.height -= l.height + n);
            break;
          }
      }
      const w = Te.Common(Object.values(o)), x = I.Sub(u.center, w.center);
      let P;
      const C = [];
      for (let _ = 0; _ < i.length; _++) {
        a = i[_], l = s[a.id], P = o[a.id];
        const T = I.Sub(P.point, l.point).add(x), $ = this.getShapeParentTransform(a);
        $ && T.rot(-$.rotation());
        const N = {
          id: a.id,
          type: a.type,
          x: a.x + T.x,
          y: a.y + T.y
        }, L = (_b3 = (_a3 = this.getShapeUtil(a)).onTranslateStart) == null ? void 0 : _b3.call(_a3, {
          ...a,
          ...N
        });
        L ? C.push({
          ...N,
          ...L
        }) : C.push(N);
      }
      return C.length && this.updateShapes(C), this;
    }
    alignShapes(e, n) {
      const r = typeof e[0] == "string" ? e : e.map((l) => l.id);
      if (this.instanceState.isReadonly)
        return this;
      if (r.length < 2)
        return this;
      const i = Je(r.map((l) => this.getShape(l))), s = Object.fromEntries(i.map((l) => [
        l.id,
        this.getShapePageBounds(l)
      ])), o = Te.Common(Je(Object.values(s))), a = [];
      return i.forEach((l) => {
        var _a3, _b3;
        const c = s[l.id];
        if (!c)
          return;
        const u = {
          x: 0,
          y: 0
        };
        switch (n) {
          case "top": {
            u.y = o.minY - c.minY;
            break;
          }
          case "center-vertical": {
            u.y = o.midY - c.minY - c.height / 2;
            break;
          }
          case "bottom": {
            u.y = o.maxY - c.minY - c.height;
            break;
          }
          case "left": {
            u.x = o.minX - c.minX;
            break;
          }
          case "center-horizontal": {
            u.x = o.midX - c.minX - c.width / 2;
            break;
          }
          case "right": {
            u.x = o.maxX - c.minX - c.width;
            break;
          }
        }
        const d = this.getShapeParent(l), h = d ? I.Rot(u, -this.getShapePageTransform(d).decompose().rotation) : u, f = (_b3 = (_a3 = this.getShapeUtil(l)).onTranslateStart) == null ? void 0 : _b3.call(_a3, l);
        a.push(f ? {
          ...f,
          x: l.x + h.x,
          y: l.y + h.y
        } : {
          id: l.id,
          type: l.type,
          x: l.x + h.x,
          y: l.y + h.y
        });
      }), this.updateShapes(a), this;
    }
    distributeShapes(e, n) {
      const r = typeof e[0] == "string" ? e : e.map((w) => w.id);
      if (this.instanceState.isReadonly)
        return this;
      if (r.length < 3)
        return this;
      const i = r.length, s = Je(r.map((w) => this.getShape(w))), o = Object.fromEntries(s.map((w) => [
        w.id,
        this.getShapePageBounds(w)
      ]));
      let a, l, c, u, d;
      n === "horizontal" ? (a = "x", l = "minX", c = "maxX", u = "midX", d = "width") : (a = "y", l = "minY", c = "maxY", u = "midY", d = "height");
      const h = [], f = s.sort((w, x) => o[w.id][l] - o[x.id][l])[0], y = s.sort((w, x) => o[x.id][c] - o[w.id][c])[0], g = o[f.id][u], O = (o[y.id][u] - g) / (i - 1), S = g + O;
      return s.filter((w) => w !== f && w !== y).sort((w, x) => o[w.id][u] - o[x.id][u]).forEach((w, x) => {
        var _a3, _b3;
        const P = {
          x: 0,
          y: 0
        };
        P[a] = S + O * x - o[w.id][d] / 2 - o[w.id][a];
        const C = this.getShapeParent(w), _ = C ? I.Rot(P, -this.getShapePageTransform(C).rotation()) : P, T = (_b3 = (_a3 = this.getShapeUtil(w)).onTranslateStart) == null ? void 0 : _b3.call(_a3, w);
        h.push(T ? {
          ...T,
          [a]: w[a] + _[a]
        } : {
          id: w.id,
          type: w.type,
          [a]: w[a] + _[a]
        });
      }), this.updateShapes(h), this;
    }
    stretchShapes(e, n) {
      const r = typeof e[0] == "string" ? e : e.map((l) => l.id);
      if (this.instanceState.isReadonly)
        return this;
      if (r.length < 2)
        return this;
      const i = Je(r.map((l) => this.getShape(l))), s = Object.fromEntries(r.map((l) => [
        l,
        this.getShapeGeometry(l).bounds
      ])), o = Object.fromEntries(r.map((l) => [
        l,
        this.getShapePageBounds(l)
      ])), a = Te.Common(Je(Object.values(o)));
      switch (n) {
        case "vertical": {
          this.batch(() => {
            for (const l of i) {
              if (this.getShapePageTransform(l).rotation() % Bt)
                continue;
              const u = s[l.id], d = o[l.id], h = new I(0, a.minY - d.minY), f = this.getShapeParentTransform(l);
              f && h.rot(-f.rotation());
              const { x: y, y: g } = I.Add(h, l);
              this.updateShapes([
                {
                  id: l.id,
                  type: l.type,
                  x: y,
                  y: g
                }
              ], {
                squashing: true
              });
              const O = new I(1, a.height / d.height);
              this.resizeShape(l.id, O, {
                initialBounds: u,
                scaleOrigin: new I(d.center.x, a.minY),
                scaleAxisRotation: 0
              });
            }
          });
          break;
        }
        case "horizontal": {
          this.batch(() => {
            for (const l of i) {
              const c = s[l.id], u = o[l.id];
              if (this.getShapePageTransform(l).rotation() % Bt)
                continue;
              const h = new I(a.minX - u.minX, 0), f = this.getShapeParentTransform(l);
              f && h.rot(-f.rotation());
              const { x: y, y: g } = I.Add(h, l);
              this.updateShapes([
                {
                  id: l.id,
                  type: l.type,
                  x: y,
                  y: g
                }
              ], {
                squashing: true
              });
              const O = new I(a.width / u.width, 1);
              this.resizeShape(l.id, O, {
                initialBounds: c,
                scaleOrigin: new I(a.minX, u.center.y),
                scaleAxisRotation: 0
              });
            }
          });
          break;
        }
      }
      return this;
    }
    resizeShape(e, n, r = {}) {
      var _a3;
      const i = typeof e == "string" ? e : e.id;
      if (this.instanceState.isReadonly)
        return this;
      Number.isFinite(n.x) || (n = new I(1, n.y)), Number.isFinite(n.y) || (n = new I(n.x, 1));
      const s = r.initialShape ?? this.getShape(i);
      if (!s)
        return this;
      const o = r.scaleOrigin ?? ((_a3 = this.getShapePageBounds(i)) == null ? void 0 : _a3.center);
      if (!o)
        return this;
      const a = r.initialPageTransform ? Se.Cast(r.initialPageTransform) : this.getShapePageTransform(i);
      if (!a)
        return this;
      const l = a.rotation();
      if (l == null)
        return this;
      const c = r.scaleAxisRotation ?? l, u = r.initialBounds ?? this.getShapeGeometry(i).bounds;
      if (!u)
        return this;
      if (!mG(l, c))
        return this._resizeUnalignedShape(i, n, {
          ...r,
          initialBounds: u,
          scaleOrigin: o,
          scaleAxisRotation: c,
          initialPageTransform: a,
          initialShape: s
        });
      const d = this.getShapeUtil(s);
      if (d.isAspectRatioLocked(s) && (Math.abs(n.x) > Math.abs(n.y) ? n = new I(n.x, Math.sign(n.y) * Math.abs(n.x)) : n = new I(Math.sign(n.x) * Math.abs(n.y), n.y)), d.onResize && d.canResize(s)) {
        const h = this._scalePagePoint(Se.applyToPoint(a, new I(0, 0)), o, n, c), f = this.getPointInParentSpace(s.id, h), y = new I(n.x, n.y), g = Y0((l - c) % Math.PI, 0);
        y.x = g ? n.x : n.y, y.y = g ? n.y : n.x;
        const O = Se.applyToPoint(a, new I()), { x: S, y: w } = this.getPointInParentSpace(s.id, O);
        this.updateShapes([
          {
            id: i,
            type: s.type,
            x: f.x,
            y: f.y,
            ...d.onResize({
              ...s,
              x: S,
              y: w
            }, {
              newPoint: f,
              handle: r.dragHandle ?? "bottom_right",
              mode: r.mode ?? "scale_shape",
              scaleX: y.x,
              scaleY: y.y,
              initialBounds: u,
              initialShape: s
            })
          }
        ], {
          squashing: true
        });
      } else {
        const h = Se.applyToPoint(a, u.center), f = this._scalePagePoint(h, o, n, c), y = this.getPointInParentSpace(s.id, h), g = this.getPointInParentSpace(s.id, f), O = I.Sub(g, y);
        this.updateShapes([
          {
            id: i,
            type: s.type,
            x: s.x + O.x,
            y: s.y + O.y
          }
        ], {
          squashing: true
        });
      }
      return this;
    }
    _scalePagePoint(e, n, r, i) {
      const s = I.RotWith(e, n, -i).sub(n), o = I.MulV(s, r);
      return I.Add(o, n).rotWith(n, i);
    }
    _resizeUnalignedShape(e, n, r) {
      const { type: i } = r.initialShape, s = new I(n.x, n.y);
      if (Math.abs(n.x) > Math.abs(n.y) ? s.x = Math.sign(n.x) * Math.abs(n.y) : s.y = Math.sign(n.y) * Math.abs(n.x), this.resizeShape(e, s, {
        initialShape: r.initialShape,
        initialBounds: r.initialBounds
      }), Math.sign(n.x) * Math.sign(n.y) < 0) {
        let { rotation: O } = Se.Decompose(r.initialPageTransform);
        O -= 2 * O, this.updateShapes([
          {
            id: e,
            type: i,
            rotation: O
          }
        ], {
          squashing: true
        });
      }
      const o = Se.applyToPoint(r.initialPageTransform, r.initialBounds.center), a = this._scalePagePoint(o, r.scaleOrigin, n, r.scaleAxisRotation), l = this.getShapePageBounds(e), c = this.getShapePageTransform(e), u = l.center, d = c.point();
      if (!u || !d)
        return this;
      const h = I.Sub(a, u), f = I.Add(d, h), { x: y, y: g } = this.getPointInParentSpace(e, f);
      return this.updateShapes([
        {
          id: e,
          type: i,
          x: y,
          y: g
        }
      ], {
        squashing: true
      }), this;
    }
    getInitialMetaForShape(e) {
      return {};
    }
    createShape(e) {
      return this._createShapes([
        e
      ]), this;
    }
    createShapes(e) {
      if (!Array.isArray(e))
        throw Error("Editor.createShapes: must provide an array of shapes or shape partials");
      return this._createShapes(e), this;
    }
    animateShape(e, n) {
      return this.animateShapes([
        e
      ], n);
    }
    animateShapes(e, n = {}) {
      const { duration: r = 500, easing: i = Oi.linear } = n, s = wn();
      let o = r, a;
      const l = [];
      e.forEach((d) => {
        if (!d)
          return;
        const h = {
          partial: d,
          values: []
        }, f = this.getShape(d.id);
        if (f) {
          for (const y of [
            "x",
            "y",
            "rotation"
          ])
            d[y] !== void 0 && f[y] !== d[y] && h.values.push({
              prop: y,
              from: f[y],
              to: d[y]
            });
          l.push(h), this.animatingShapes.set(f.id, s);
        }
      });
      let c;
      const u = (d) => {
        if (o -= d, o < 0) {
          const { animatingShapes: f } = this, y = e.filter((g) => g && f.get(g.id) === s);
          y.length && this.updateShapes(y, {
            squashing: false
          }), this.removeListener("tick", u);
          return;
        }
        a = i(1 - o / r);
        const { animatingShapes: h } = this;
        try {
          const f = [];
          for (let y = 0; y < l.length; y++)
            c = l[y], h.get(c.partial.id) === s && f.push({
              id: c.partial.id,
              type: c.partial.type,
              ...c.values.reduce((g, { prop: O, from: S, to: w }) => (g[O] = S + (w - S) * a, g), {})
            });
          this._updateShapes(f, {
            squashing: true
          });
        } catch {
        }
      };
      return this.addListener("tick", u), this;
    }
    groupShapes(e, n = bn()) {
      var _a3;
      if (!Array.isArray(e))
        throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");
      if (this.instanceState.isReadonly)
        return this;
      const r = typeof e[0] == "string" ? e : e.map((h) => h.id);
      if (r.length <= 1)
        return this;
      const i = Je(this._getUnlockedShapeIds(r).map((h) => this.getShape(h))), s = i.sort(hi).map((h) => h.id), o = Te.Common(Je(i.map((h) => this.getShapePageBounds(h)))), { x: a, y: l } = o.point, c = this.findCommonAncestor(i) ?? this.currentPageId;
      if (this.currentToolId !== "select")
        return this;
      this.isIn("select.idle") || this.cancel();
      const u = i.filter((h) => h.parentId === c).sort(hi), d = (_a3 = u[u.length - 1]) == null ? void 0 : _a3.index;
      return this.batch(() => {
        this.createShapes([
          {
            id: n,
            type: "group",
            parentId: c,
            index: d,
            x: a,
            y: l,
            opacity: 1,
            props: {}
          }
        ]), this.reparentShapes(s, n), this.select(n);
      }), this;
    }
    ungroupShapes(e) {
      const n = typeof e[0] == "string" ? e : e.map((o) => o.id);
      if (this.instanceState.isReadonly)
        return this;
      if (n.length === 0)
        return this;
      if (this.currentToolId !== "select")
        return this;
      this.isIn("select.idle") || this.cancel();
      const r = /* @__PURE__ */ new Set(), i = Je(n.map((o) => this.getShape(o))), s = [];
      return i.forEach((o) => {
        this.isShapeOfType(o, "group") ? s.push(o) : r.add(o.id);
      }), s.length === 0 ? this : (this.batch(() => {
        let o;
        for (let a = 0, l = s.length; a < l; a++) {
          o = s[a];
          const c = this.getSortedChildIdsForParent(o.id);
          for (let u = 0, d = c.length; u < d; u++)
            r.add(c[u]);
          this.reparentShapes(c, o.parentId, o.index);
        }
        this.deleteShapes(s.map((a) => a.id)), this.select(...r);
      }), this);
    }
    updateShape(e, n) {
      return this.updateShapes([
        e
      ], n), this;
    }
    updateShapes(e, n) {
      let r = Je(e);
      return this.animatingShapes.size > 0 && r.forEach((i) => this.animatingShapes.delete(i.id)), r = r.filter((i) => {
        const s = this.getShape(i.id);
        return !(!s || this.isShapeOrAncestorLocked(s) && !Object.hasOwn(i, "isLocked"));
      }), this._updateShapes(r, n), this;
    }
    _getUnlockedShapeIds(e) {
      return e.filter((n) => {
        var _a3;
        return !((_a3 = this.getShape(n)) == null ? void 0 : _a3.isLocked);
      });
    }
    deleteShapes(e) {
      if (!Array.isArray(e))
        throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");
      return this._deleteShapes(this._getUnlockedShapeIds(typeof e[0] == "string" ? e : e.map((n) => n.id))), this;
    }
    deleteShape(e) {
      return this.deleteShapes([
        typeof e == "string" ? e : e.id
      ]), this;
    }
    _extractSharedStyles(e, n) {
      if (this.isShapeOfType(e, "group")) {
        const r = this._parentIdsToChildIds.value[e.id];
        if (!r)
          return;
        for (let i = 0, s = r.length; i < s; i++)
          this._extractSharedStyles(this.getShape(r[i]), n);
      } else
        for (const [r, i] of this.styleProps[e.type])
          n.applyValue(r, Xh(e.props, i));
    }
    getStyleForNextShape(e) {
      const n = this.instanceState.stylesForNextShape[e.id];
      return n === void 0 ? e.defaultValue : n;
    }
    getShapeStyleIfExists(e, n) {
      const r = this.styleProps[e.type].get(n);
      if (r !== void 0)
        return Xh(e.props, r);
    }
    get sharedStyles() {
      if (this.isIn("select") && this.selectedShapeIds.length > 0)
        return this._selectionSharedStyles.value;
      const e = this.root.current.value, n = new oR();
      if (e.shapeType)
        for (const r of this.styleProps[e.shapeType].keys())
          n.applyValue(r, this.getStyleForNextShape(r));
      return n;
    }
    get sharedOpacity() {
      if (this.isIn("select") && this.selectedShapeIds.length > 0) {
        const e = [], n = (i) => {
          const s = this.getShape(i);
          if (s)
            if (this.isShapeOfType(s, "group"))
              for (const o of this.getSortedChildIdsForParent(s.id))
                n(o);
            else
              e.push(s);
        };
        for (const i of this.selectedShapeIds)
          n(i);
        let r = null;
        for (const i of e)
          if (r === null)
            r = i.opacity;
          else if (r !== i.opacity)
            return {
              type: "mixed"
            };
        if (r !== null)
          return {
            type: "shared",
            value: r
          };
      }
      return {
        type: "shared",
        value: this.instanceState.opacityForNextShape
      };
    }
    setOpacityForNextShapes(e, n) {
      return this.updateInstanceState({
        opacityForNextShape: e
      }, n), this;
    }
    setOpacityForSelectedShapes(e, n) {
      const { selectedShapes: r } = this;
      if (r.length > 0) {
        const i = [], s = (o) => {
          if (this.isShapeOfType(o, "group")) {
            const a = this.getSortedChildIdsForParent(o);
            for (const l of a)
              s(this.getShape(l));
          } else
            i.push(o);
        };
        for (const o of r)
          s(o);
        this.updateShapes(i.map((o) => ({
          id: o.id,
          type: o.type,
          opacity: e
        })), n);
      }
      return this;
    }
    setStyleForNextShapes(e, n, r) {
      const { instanceState: { stylesForNextShape: i } } = this;
      return this.updateInstanceState({
        stylesForNextShape: {
          ...i,
          [e.id]: n
        }
      }, r), this;
    }
    setStyleForSelectedShapes(e, n, r) {
      const { selectedShapes: i } = this;
      if (i.length > 0) {
        const s = [], o = (a) => {
          if (this.isShapeOfType(a, "group")) {
            const l = this.getSortedChildIdsForParent(a.id);
            for (const c of l)
              o(this.getShape(c));
          } else {
            const l = this.getShapeUtil(a), c = this.styleProps[a.type].get(e);
            if (c) {
              const u = {
                id: a.id,
                type: a.type,
                props: {
                  [c]: n
                }
              };
              s.push({
                util: l,
                originalShape: a,
                updatePartial: u
              });
            }
          }
        };
        for (const a of i)
          o(a);
        this.updateShapes(s.map(({ updatePartial: a }) => a), r);
      }
      return this;
    }
    registerExternalAssetHandler(e, n) {
      return this.externalAssetContentHandlers[e] = n, this;
    }
    async getAssetForExternalContent(e) {
      var _a3, _b3;
      return await ((_b3 = (_a3 = this.externalAssetContentHandlers)[e.type]) == null ? void 0 : _b3.call(_a3, e));
    }
    registerExternalContentHandler(e, n) {
      return this.externalContentHandlers[e] = n, this;
    }
    async putExternalContent(e) {
      var _a3, _b3;
      return (_b3 = (_a3 = this.externalContentHandlers)[e.type]) == null ? void 0 : _b3.call(_a3, e);
    }
    getContentFromCurrentPage(e) {
      const n = typeof e[0] == "string" ? e : e.map((a) => a.id);
      if (!n || n.length === 0)
        return;
      const r = {};
      let i = hk(n.map((a) => this.getShape(a)).sort(hi).flatMap((a) => {
        const l = [
          a
        ];
        return this.visitDescendants(a.id, (c) => {
          l.push(this.getShape(c));
        }), l;
      }));
      i = i.map((a) => {
        if (r[a.id] = this.getShapePageTransform(a.id), a = Dc(a), this.isShapeOfType(a, "arrow")) {
          const l = a.props.start.type === "binding" ? a.props.start.boundShapeId : void 0, c = a.props.end.type === "binding" ? a.props.end.boundShapeId : void 0, u = this.getArrowInfo(a);
          if (a.props.start.type === "binding" && !i.some((h) => h.id === l))
            if (u == null ? void 0 : u.isValid) {
              const { x: h, y: f } = u.start.point;
              a.props.start = {
                type: "point",
                x: h,
                y: f
              };
            } else {
              const { start: h } = Ia(this, a);
              a.props.start = {
                type: "point",
                x: h.x,
                y: h.y
              };
            }
          if (a.props.end.type === "binding" && !i.some((h) => h.id === c))
            if (u == null ? void 0 : u.isValid) {
              const { x: h, y: f } = u.end.point;
              a.props.end = {
                type: "point",
                x: h,
                y: f
              };
            } else {
              const { end: h } = Ia(this, a);
              a.props.end = {
                type: "point",
                x: h.x,
                y: h.y
              };
            }
          const d = Fy(a) ? q0(this, a) : $E(this, a);
          if ((u == null ? void 0 : u.isValid) && (d == null ? void 0 : d.isValid) && !Fy(a)) {
            const h = I.Med(u.start.handle, u.end.handle), f = I.Dist(u.middle, h), y = I.Dist(d.middle, h);
            a.props.bend < 0 ? a.props.bend += y - f : a.props.bend -= y - f;
          }
          return a;
        }
        return a;
      });
      const s = [];
      i.forEach((a) => {
        if (i.find((l) => l.id === a.parentId) === void 0) {
          const l = this.getShapePageTransform(a.id), c = l.point(), u = l.rotation();
          a.x = c.x, a.y = c.y, a.rotation = u, a.parentId = this.currentPageId, s.push(a.id);
        }
      });
      const o = /* @__PURE__ */ new Set();
      return i.forEach((a) => {
        "assetId" in a.props && a.props.assetId !== null && o.add(a.props.assetId);
      }), {
        shapes: i,
        rootShapeIds: s,
        schema: this.store.schema.serialize(),
        assets: Je(Array.from(o).map((a) => this.getAsset(a)))
      };
    }
    putContentOntoCurrentPage(e, n = {}) {
      if (this.instanceState.isReadonly)
        return this;
      if (!e.schema)
        throw Error(`Could not put content:
content is missing a schema.`);
      const { select: r = false, preserveIds: i = false, preservePosition: s = false } = n;
      let { point: o = void 0 } = n;
      const { currentPageId: a } = this, { assets: l, shapes: c, rootShapeIds: u } = e, d = new Map(c.map((P) => [
        P.id,
        bn()
      ]));
      let h = this.currentPageId, f = 1 / 0, y = [];
      for (const P of this.selectedShapes) {
        if (f === 0)
          break;
        const C = this.isShapeOfType(P, "frame"), _ = this.getShapeAncestors(P);
        C && _.push(P);
        const T = C ? _.length + 1 : _.length;
        if (T < f)
          f = T, y = _, h = C ? P.id : P.parentId;
        else if (T === f) {
          if (y.length !== _.length)
            throw Error(`Ancestors: ${y.length} !== ${_.length}`);
          if (y.length === 0) {
            h = a;
            break;
          } else {
            h = a;
            for (let $ = 0; $ < y.length && _[$] === y[$]; $++)
              h = _[$].id;
          }
        }
      }
      let g = false;
      if (!rs(h)) {
        const P = this.getShape(h);
        if (P) {
          if (!this.viewportPageBounds.includes(this.getShapePageBounds(P)))
            h = a;
          else if (u.length === 1) {
            const C = c.find((_) => _.id === u[0]);
            this.isShapeOfType(P, "frame") && this.isShapeOfType(C, "frame") && C.props.w === (P == null ? void 0 : P.props.w) && C.props.h === (P == null ? void 0 : P.props.h) && (g = true);
          }
        } else
          h = a;
      }
      g || (g = d.has(h)), g && (h = this.getShape(h).parentId);
      let O = this.getHighestIndexForParent(h);
      const S = [], w = c.map((P) => {
        let C;
        if (i)
          C = wi(P), d.set(P.id, P.id);
        else {
          const _ = d.get(P.id);
          C = wi({
            ...P,
            id: _
          });
        }
        if (u.includes(P.id) && (C.parentId = a, S.push(C)), d.has(C.parentId) ? C.parentId = d.get(P.parentId) : (u.push(C.id), C.index = O, O = wc(O)), this.isShapeOfType(C, "arrow")) {
          if (C.props.start.type === "binding") {
            const _ = d.get(C.props.start.boundShapeId);
            C.props.start = _ ? {
              ...C.props.start,
              boundShapeId: _
            } : {
              type: "point",
              x: 0,
              y: 0
            };
          }
          if (C.props.end.type === "binding") {
            const _ = d.get(C.props.end.boundShapeId);
            C.props.end = _ ? {
              ...C.props.end,
              boundShapeId: _
            } : {
              type: "point",
              x: 0,
              y: 0
            };
          }
        }
        return C;
      });
      if (w.length + this.currentPageShapeIds.size > gc)
        return vw(this), this;
      let x = [];
      if (l) {
        for (let C = 0; C < l.length; C++) {
          const _ = l[C], T = this.store.schema.migratePersistedRecord(_, e.schema);
          if (T.type === "success")
            l[C] = T.value;
          else
            throw Error(`Could not put content:
could not migrate content for asset:
${_.id}
${_.type}
reason:${T.reason}`);
        }
        const P = [];
        x = l.filter((C) => !this.store.has(C.id)).map((C) => {
          var _a3;
          return (C.type === "image" || C.type === "video") && (C.props.src && ((_a3 = C.props.src) == null ? void 0 : _a3.startsWith("data:image")) ? (P.push(Dc(C)), C.props.src = null) : P.push(Dc(C))), C;
        }), Promise.allSettled(P.map(async (C) => {
          const _ = await o_e(C.props.src, C.props.name, C.props.mimeType ?? "image/png"), T = await this.getAssetForExternalContent({
            type: "file",
            file: _
          });
          return T ? [
            C,
            T
          ] : null;
        })).then((C) => {
          this.updateAssets(Je(C.map((_) => _.status === "fulfilled" && _.value ? {
            ..._.value[1],
            id: _.value[0].id
          } : void 0)));
        });
      }
      for (let P = 0; P < w.length; P++) {
        const C = w[P], _ = this.store.schema.migratePersistedRecord(C, e.schema);
        if (_.type === "success")
          w[P] = _.value;
        else
          throw Error(`Could not put content:
could not migrate content for shape:
${C.id}, ${C.type}
reason:${_.reason}`);
      }
      return this.batch(() => {
        x.length > 0 && this.createAssets(x), this.createShapes(w), r && this.select(...S.map(($) => $.id)), h !== a && this.reparentShapes(S.map(($) => $.id), h);
        const P = w.map(($) => this.getShape($.id)), C = Te.Common(P.map(($) => this.getShapePageBounds($)));
        if (o === void 0)
          if (rs(h)) {
            const { viewportPageBounds: $ } = this;
            s || $.includes(Te.From(C)) ? o = C.center : o = $.center;
          } else {
            const $ = this.getShape(h);
            o = Se.applyToPoint(this.getShapePageTransform($), this.getShapeGeometry($).bounds.center);
          }
        if (S.length === 1) {
          const $ = S[0];
          if (this.isShapeOfType($, "frame"))
            for (; this.getShapesAtPoint(o).some((N) => this.isShapeOfType(N, "frame") && N.props.w === $.props.w && N.props.h === $.props.h); )
              o.x += C.w + 16;
        }
        const _ = Te.Common(Je(S.map(({ id: $ }) => this.getShapePageBounds($)))).center, T = I.Sub(o, _);
        this.updateShapes(S.map(({ id: $ }) => {
          const N = this.getShape($), L = this.getShapeParentTransform($).decompose().rotation, z = I.Rot(T, -L);
          return {
            id: N.id,
            type: N.type,
            x: N.x + z.x,
            y: N.y + z.y
          };
        }));
      }), this;
    }
    async getSvg(e, n = {}) {
      var _a3, _b3;
      const r = typeof e[0] == "string" ? e : e.map((P) => P.id);
      if (r.length === 0)
        return;
      if (!window.document)
        throw Error("No document");
      const { scale: i = 1, background: s = false, padding: o = Pke, preserveAspectRatio: a = false } = n, l = ks({
        isDarkMode: this.user.isDarkMode
      }), c = this.getShapeAndDescendantIds(r), u = this.getUnorderedRenderingShapes(false).filter(({ id: P }) => c.has(P));
      let d = null;
      for (const { maskedPageBounds: P } of u)
        P && (d ? d.union(P) : d = P.clone());
      if (!d)
        return;
      const h = r.length === 1 && this.isShapeOfType(this.getShape(r[0]), "frame") ? r[0] : null;
      h || d.expandBy(o);
      const f = d.width * i, y = d.height * i, g = window.document.createElementNS("http://www.w3.org/2000/svg", "svg");
      a && g.setAttribute("preserveAspectRatio", a), g.setAttribute("direction", "ltr"), g.setAttribute("width", f + ""), g.setAttribute("height", y + ""), g.setAttribute("viewBox", `${d.minX} ${d.minY} ${d.width} ${d.height}`), g.setAttribute("stroke-linecap", "round"), g.setAttribute("stroke-linejoin", "round"), s ? h ? g.style.setProperty("background", l.solid) : g.style.setProperty("background-color", l.background) : g.style.setProperty("background-color", "transparent");
      try {
        (_b3 = (_a3 = document.body).focus) == null ? void 0 : _b3.call(_a3);
      } catch {
      }
      const O = window.document.createElementNS("http://www.w3.org/2000/svg", "defs");
      g.append(O);
      const S = /* @__PURE__ */ new Map(), w = {
        addExportDef: (P) => {
          if (S.has(P.key))
            return;
          const C = (async () => {
            const _ = await P.getElement();
            if (!_)
              return;
            const T = document.createComment(`def: ${P.key}`);
            O.appendChild(T);
            for (const $ of Array.isArray(_) ? _ : [
              _
            ])
              O.appendChild($);
          })();
          S.set(P.key, C);
        }
      }, x = (await Promise.all(u.map(async ({ id: P, opacity: C, index: _, backgroundIndex: T }) => {
        var _a4, _b4;
        if (P === h)
          return [];
        const $ = this.getShape(P);
        if (this.isShapeOfType($, "group"))
          return [];
        const N = this.getShapeUtil($);
        let L = await ((_a4 = N.toSvg) == null ? void 0 : _a4.call(N, $, w)), z = await ((_b4 = N.toBackgroundSvg) == null ? void 0 : _b4.call(N, $, w));
        if (L) {
          const Q = document.createElementNS("http://www.w3.org/2000/svg", "g");
          Q.appendChild(L), L = Q;
        }
        if (z) {
          const Q = document.createElementNS("http://www.w3.org/2000/svg", "g");
          Q.appendChild(z), z = Q;
        }
        if (!L && !z) {
          const Q = this.getShapePageBounds($), X = window.document.createElementNS("http://www.w3.org/2000/svg", "rect");
          X.setAttribute("width", Q.width + ""), X.setAttribute("height", Q.height + ""), X.setAttribute("fill", l.solid), X.setAttribute("stroke", l.grey.pattern), X.setAttribute("stroke-width", "1"), L = X;
        }
        let M = this.getShapePageTransform($).toCssString();
        "scale" in $.props && $.props.scale !== 1 && (M = `${M} scale(${$.props.scale}, ${$.props.scale})`), L == null ? void 0 : L.setAttribute("transform", M), z == null ? void 0 : z.setAttribute("transform", M), L == null ? void 0 : L.setAttribute("opacity", C + ""), z == null ? void 0 : z.setAttribute("opacity", C + "");
        const R = this.getShapeMask($.id);
        if (R) {
          const Q = document.createElementNS("http://www.w3.org/2000/svg", "clipPath");
          O.appendChild(Q);
          const X = wn();
          Q.id = X;
          const Z = document.createElementNS("http://www.w3.org/2000/svg", "path");
          if (Z.setAttribute("d", `M${R.map(({ x: U, y: H }) => `${U},${H}`).join("L")}Z`), Q.appendChild(Z), L) {
            const U = document.createElementNS("http://www.w3.org/2000/svg", "g");
            U.setAttribute("clip-path", `url(#${X})`), U.appendChild(L), L = U;
          }
          if (z) {
            const U = document.createElementNS("http://www.w3.org/2000/svg", "g");
            U.setAttribute("clip-path", `url(#${X})`), U.appendChild(z), z = U;
          }
        }
        const F = [];
        return L && F.push({
          zIndex: _,
          element: L
        }), z && F.push({
          zIndex: T,
          element: z
        }), F;
      }))).flat();
      await Promise.all(S.values());
      for (const { element: P } of x.sort((C, _) => C.zIndex - _.zIndex))
        g.appendChild(P);
      return g;
    }
    _updateInputsFromEvent(e) {
      var _a3;
      const { previousScreenPoint: n, previousPagePoint: r, currentScreenPoint: i, currentPagePoint: s } = this.inputs, { screenBounds: o } = this.store.unsafeGetWithoutCapture(gi), { x: a, y: l, z: c } = e.point, { x: u, y: d, z: h } = this.camera;
      n.setTo(i), r.setTo(s), i.set(a, l), s.set((a - o.x) / h - u, (l - o.y) / h - d, c ?? 0.5), this.inputs.isPen = e.type === "pointer" && e.isPen, e.name === "pointer_down" && this.inputs.pointerVelocity.set(0, 0), this.store.put([
        {
          id: Bv,
          typeName: "pointer",
          x: s.x,
          y: s.y,
          lastActivityTimestamp: e.type === "pointer" && e.pointerId === d8.CAMERA_MOVE ? ((_a3 = this.store.get(Bv)) == null ? void 0 : _a3.lastActivityTimestamp) ?? Date.now() : Date.now(),
          meta: {}
        }
      ]);
    }
    cancel() {
      return this.dispatch({
        type: "misc",
        name: "cancel"
      }), this;
    }
    interrupt() {
      return this.dispatch({
        type: "misc",
        name: "interrupt"
      }), this;
    }
    complete() {
      return this.dispatch({
        type: "misc",
        name: "complete"
      }), this;
    }
    cancelDoubleClick() {
      this._clickManager.cancelDoubleClickTimeout();
    }
  }
  Xe([
    ve
  ], Ue.prototype, "canUndo", 1);
  Xe([
    ve
  ], Ue.prototype, "canRedo", 1);
  Xe([
    ve
  ], Ue.prototype, "_arrowBindingsIndex", 1);
  Xe([
    ve
  ], Ue.prototype, "arrowInfoCache", 1);
  Xe([
    ve
  ], Ue.prototype, "currentTool", 1);
  Xe([
    ve
  ], Ue.prototype, "currentToolId", 1);
  Xe([
    ve
  ], Ue.prototype, "documentSettings", 1);
  Xe([
    ve
  ], Ue.prototype, "instanceState", 1);
  Xe([
    ve
  ], Ue.prototype, "openMenus", 1);
  Xe([
    ve
  ], Ue.prototype, "isMenuOpen", 1);
  Xe([
    ve
  ], Ue.prototype, "pageStates", 1);
  Xe([
    ve
  ], Ue.prototype, "_pageStates", 1);
  Xe([
    ve
  ], Ue.prototype, "currentPageState", 1);
  Xe([
    ve
  ], Ue.prototype, "_currentPageStateId", 1);
  Xe([
    ve
  ], Ue.prototype, "selectedShapeIds", 1);
  Xe([
    ve
  ], Ue.prototype, "selectedShapes", 1);
  Xe([
    ve
  ], Ue.prototype, "onlySelectedShape", 1);
  Xe([
    ve
  ], Ue.prototype, "selectionPageBounds", 1);
  Xe([
    ve
  ], Ue.prototype, "selectionRotation", 1);
  Xe([
    ve
  ], Ue.prototype, "selectionRotatedPageBounds", 1);
  Xe([
    ve
  ], Ue.prototype, "focusedGroupId", 1);
  Xe([
    ve
  ], Ue.prototype, "focusedGroup", 1);
  Xe([
    ve
  ], Ue.prototype, "editingShapeId", 1);
  Xe([
    ve
  ], Ue.prototype, "editingShape", 1);
  Xe([
    ve
  ], Ue.prototype, "hoveredShapeId", 1);
  Xe([
    ve
  ], Ue.prototype, "hoveredShape", 1);
  Xe([
    ve
  ], Ue.prototype, "hintingShapeIds", 1);
  Xe([
    ve
  ], Ue.prototype, "hintingShapes", 1);
  Xe([
    ve
  ], Ue.prototype, "erasingShapeIds", 1);
  Xe([
    ve
  ], Ue.prototype, "erasingShapes", 1);
  Xe([
    ve
  ], Ue.prototype, "cameraId", 1);
  Xe([
    ve
  ], Ue.prototype, "camera", 1);
  Xe([
    ve
  ], Ue.prototype, "zoomLevel", 1);
  Xe([
    ve
  ], Ue.prototype, "viewportScreenBounds", 1);
  Xe([
    ve
  ], Ue.prototype, "viewportScreenCenter", 1);
  Xe([
    ve
  ], Ue.prototype, "viewportPageBounds", 1);
  Xe([
    ve
  ], Ue.prototype, "viewportPageCenter", 1);
  Xe([
    ve
  ], Ue.prototype, "cameraState", 1);
  Xe([
    ve
  ], Ue.prototype, "renderingShapes", 1);
  Xe([
    ve
  ], Ue.prototype, "renderingBounds", 1);
  Xe([
    ve
  ], Ue.prototype, "renderingBoundsExpanded", 1);
  Xe([
    ve
  ], Ue.prototype, "_pages", 1);
  Xe([
    ve
  ], Ue.prototype, "pages", 1);
  Xe([
    ve
  ], Ue.prototype, "_assets", 1);
  Xe([
    ve
  ], Ue.prototype, "_shapeGeometryCache", 1);
  Xe([
    ve
  ], Ue.prototype, "_shapeOutlineSegmentsCache", 1);
  Xe([
    ve
  ], Ue.prototype, "_shapeHandlesCache", 1);
  Xe([
    ve
  ], Ue.prototype, "_shapePageTransformCache", 1);
  Xe([
    ve
  ], Ue.prototype, "_shapePageBoundsCache", 1);
  Xe([
    ve
  ], Ue.prototype, "_shapeClipPathCache", 1);
  Xe([
    ve
  ], Ue.prototype, "_shapeMaskCache", 1);
  Xe([
    ve
  ], Ue.prototype, "currentPageBounds", 1);
  Xe([
    ve
  ], Ue.prototype, "currentPageShapes", 1);
  Xe([
    ve
  ], Ue.prototype, "currentPageShapesSorted", 1);
  Xe([
    ve
  ], Ue.prototype, "currentPageRenderingShapesSorted", 1);
  Xe([
    ve({
      isEqual: (t, e) => t.equals(e)
    })
  ], Ue.prototype, "sharedStyles", 1);
  Xe([
    ve
  ], Ue.prototype, "sharedOpacity", 1);
  function vw(t, e = t.currentPageId) {
    const n = t.getPage(e).name;
    t.emit("max-shapes", {
      name: n,
      pageId: e,
      count: gc
    });
  }
  function $C() {
    const t = ue();
    return ye("isDarkMode", () => t.user.isDarkMode, [
      t
    ]);
  }
  const X_e = '<path d="m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" fill="white"/><path d="m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" fill="white"/><path d="m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z" fill="black"/><path d="m13 10.814v11.188l2.969-2.866.428-.139h4.768z" fill="black"/>', W_e = '<path d="m13.3315 21.3799c-.284-.359-.629-1.093-1.243-1.984-.348-.504-1.211-1.453-1.468-1.935-.223-.426-.199-.617-.146-.97.094-.628.738-1.117 1.425-1.051.519.049.959.392 1.355.716.239.195.533.574.71.788.163.196.203.277.377.509.23.307.302.459.214.121-.071-.496-.187-1.343-.355-2.092-.128-.568-.159-.657-.281-1.093-.129-.464-.195-.789-.316-1.281-.084-.348-.235-1.059-.276-1.459-.057-.547-.087-1.439.264-1.849.275-.321.906-.418 1.297-.22.512.259.803 1.003.936 1.3.239.534.387 1.151.516 1.961.164 1.031.466 2.462.476 2.763.024-.369-.068-1.146-.004-1.5.058-.321.328-.694.666-.795.286-.085.621-.116.916-.055.313.064.643.288.766.499.362.624.369 1.899.384 1.831.086-.376.071-1.229.284-1.584.14-.234.497-.445.687-.479.294-.052.655-.068.964-.008.249.049.586.345.677.487.218.344.342 1.317.379 1.658.015.141.074-.392.293-.736.406-.639 1.843-.763 1.898.639.025.654.02.624.02 1.064 0 .517-.012.828-.04 1.202-.031.4-.117 1.304-.242 1.742-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.191 1.813-.118.562-.079.566-.102.965-.023.398.121.922.121.922s-.802.104-1.234.035c-.391-.063-.875-.841-1-1.079-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.031-3.139.02 0 0 .185-1.011-.227-1.358-.305-.259-.83-.784-1.144-1.06z" fill="white"/><g stroke="black" stroke-linecap="round" stroke-width=".75"><path d="m13.3315 21.3799c-.284-.359-.629-1.093-1.243-1.984-.348-.504-1.211-1.453-1.468-1.935-.223-.426-.199-.617-.146-.97.094-.628.738-1.117 1.425-1.051.519.049.959.392 1.355.716.239.195.533.574.71.788.163.196.203.277.377.509.23.307.302.459.214.121-.071-.496-.187-1.343-.355-2.092-.128-.568-.159-.657-.281-1.093-.129-.464-.195-.789-.316-1.281-.084-.348-.235-1.059-.276-1.459-.057-.547-.087-1.439.264-1.849.275-.321.906-.418 1.297-.22.512.259.803 1.003.936 1.3.239.534.387 1.151.516 1.961.164 1.031.466 2.462.476 2.763.024-.369-.068-1.146-.004-1.5.058-.321.328-.694.666-.795.286-.085.621-.116.916-.055.313.064.643.288.766.499.362.624.369 1.899.384 1.831.086-.376.071-1.229.284-1.584.14-.234.497-.445.687-.479.294-.052.655-.068.964-.008.249.049.586.345.677.487.218.344.342 1.317.379 1.658.015.141.074-.392.293-.736.406-.639 1.843-.763 1.898.639.025.654.02.624.02 1.064 0 .517-.012.828-.04 1.202-.031.4-.117 1.304-.242 1.742-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.191 1.813-.118.562-.079.566-.102.965-.023.398.121.922.121.922s-.802.104-1.234.035c-.391-.063-.875-.841-1-1.079-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.031-3.139.02 0 0 .185-1.011-.227-1.358-.305-.259-.83-.784-1.144-1.06z" stroke-linejoin="round"/><path d="m21.5664 21.7344v-3.459"/><path d="m19.5508 21.7461-.016-3.473"/><path d="m17.5547 18.3047.021 3.426"/></g>', Z_e = '<path d="m25 16h-6.01v-6h-2.98v6h-6.01v3h6.01v6h2.98v-6h6.01z" fill="white"/><path d="m23.9902 17.0103h-6v-6.01h-.98v6.01h-6v.98h6v6.01h.98v-6.01h6z" fill="%23231f1f"/>', H_e = '<path d="m19 14h1v1h-1zm1 6h-1v-1h1zm-5-5h-1v-1h1zm0 5h-1v-1h1zm2-10.987-7.985 7.988 5.222 5.221 2.763 2.763 7.984-7.985z" fill="white"/><g fill="black"><path d="m23.5664 16.9971-2.557-2.809v1.829h-4.009-4.001v-1.829l-2.571 2.809 2.572 2.808-.001-1.808h4.001 4.009l-.001 1.808z"/><path d="m17.9873 17h.013v-4.001l1.807.001-2.807-2.571-2.809 2.57h1.809v4.001h.008v4.002l-1.828-.001 2.807 2.577 2.805-2.576h-1.805z"/></g>', V8 = "<path d='m19.7432 17.0869-4.072 4.068 2.829 2.828-8.473-.013-.013-8.47 2.841 2.842 4.075-4.068 1.414-1.415-2.844-2.842h8.486v8.484l-2.83-2.827z' fill='%23fff'/><path d='m18.6826 16.7334-4.427 4.424 1.828 1.828-5.056-.016-.014-5.054 1.842 1.841 4.428-4.422 2.474-2.475-1.844-1.843h5.073v5.071l-1.83-1.828z' fill='%23000'/>", X8 = "<path d='m9 17.9907v.005l5.997 5.996.001-3.999h1.999 2.02v4l5.98-6.001-5.98-5.999.001 4.019-2.021.002h-2l.001-4.022zm1.411.003 3.587-3.588-.001 2.587h3.5 2.521v-2.585l3.565 3.586-3.564 3.585-.001-2.585h-2.521l-3.499-.001-.001 2.586z' fill='%23fff'/><path d='m17.4971 18.9932h2.521v2.586l3.565-3.586-3.565-3.585v2.605h-2.521-3.5v-2.607l-3.586 3.587 3.586 3.586v-2.587z' fill='%23000'/>", Ow = '<path d="M22.4789 9.45728L25.9935 12.9942L22.4789 16.5283V14.1032C18.126 14.1502 14.6071 17.6737 14.5675 22.0283H17.05L13.513 25.543L9.97889 22.0283H12.5674C12.6071 16.5691 17.0214 12.1503 22.4789 12.1031L22.4789 9.45728Z" fill="black"/><path fill-rule="evenodd" clip-rule="evenodd" d="M21.4789 7.03223L27.4035 12.9945L21.4789 18.9521V15.1868C18.4798 15.6549 16.1113 18.0273 15.649 21.0284H19.475L13.5128 26.953L7.55519 21.0284H11.6189C12.1243 15.8155 16.2679 11.6677 21.4789 11.1559L21.4789 7.03223ZM22.4789 12.1031C17.0214 12.1503 12.6071 16.5691 12.5674 22.0284H9.97889L13.513 25.543L17.05 22.0284H14.5675C14.5705 21.6896 14.5947 21.3558 14.6386 21.0284C15.1157 17.4741 17.9266 14.6592 21.4789 14.1761C21.8063 14.1316 22.1401 14.1069 22.4789 14.1032V16.5284L25.9935 12.9942L22.4789 9.45729L22.4789 12.1031Z" fill="white"/>', Y_e = '<path fill="white" d="M7.94 0a5.25 5.25 0 0 0-3.47 1.17A5.27 5.27 0 0 0 1 0H0v3h1c1.41 0 1.85.7 2 1v3.94H2v3h1v3c-.13.3-.57 1-2 1H0v3h1a5.27 5.27 0 0 0 3.47-1.17c.98.8 2.21 1.21 3.47 1.17h1v-3h-1c-1.41 0-1.85-.7-2-1v-3H7v-3H6V4c.13-.3.57-1 2-1h1V0H7.94z"/><path fill="black" d="M7.94 2V1a4 4 0 0 0-3.47 1.64A4 4 0 0 0 1 1v1c1.3-.17 2.56.6 3 1.84v5.1H3v1h1v4.16c-.45 1.24-1.7 2-3 1.84v1a4.05 4.05 0 0 0 3.47-1.63 4.05 4.05 0 0 0 3.47 1.63v-1A2.82 2.82 0 0 1 5 14.1V9.93h1v-1H5V3.85A2.81 2.81 0 0 1 7.94 2z"/>', G_e = "<path d='m13.5732 12.0361c.48-.178 1.427-.069 1.677.473.213.462.396 1.241.406 1.075.024-.369-.024-1.167.137-1.584.117-.304.347-.59.686-.691.285-.086.62-.116.916-.055.313.064.642.287.765.499.362.623.368 1.899.385 1.831.064-.272.07-1.229.283-1.584.141-.235.497-.445.687-.479.294-.052.656-.068.964-.008.249.049.586.344.677.487.219.344.342 1.316.379 1.658.016.141.074-.393.293-.736.406-.639 1.844-.763 1.898.639.026.654.02.624.02 1.064 0 .516-.012.828-.04 1.202-.03.399-.116 1.304-.241 1.742-.086.301-.371.978-.653 1.384 0 0-1.074 1.25-1.191 1.812-.117.563-.078.567-.102.965-.023.399.121.923.121.923s-.801.104-1.234.034c-.391-.062-.875-.84-1-1.078-.172-.328-.539-.265-.682-.023-.224.383-.709 1.07-1.05 1.113-.669.084-2.055.03-3.14.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.283-.36-1.002-.929-1.243-1.985-.213-.936-.192-1.395.037-1.77.232-.381.67-.589.854-.625.208-.042.692-.039.875.062.223.123.313.159.488.391.23.307.312.456.213.121-.076-.262-.322-.595-.434-.97-.109-.361-.401-.943-.38-1.526.008-.221.103-.771.832-1.042' fill='white'/><g stroke='black' stroke-width='.75'><path d='m13.5732 12.0361c.48-.178 1.427-.069 1.677.473.213.462.396 1.241.406 1.075.024-.369-.024-1.167.137-1.584.117-.304.347-.59.686-.691.285-.086.62-.116.916-.055.313.064.642.287.765.499.362.623.368 1.899.385 1.831.064-.272.07-1.229.283-1.584.141-.235.497-.445.687-.479.294-.052.656-.068.964-.008.249.049.586.344.677.487.219.344.342 1.316.379 1.658.016.141.074-.393.293-.736.406-.639 1.844-.763 1.898.639.026.654.02.624.02 1.064 0 .516-.012.828-.04 1.202-.03.399-.116 1.304-.241 1.742-.086.301-.371.978-.653 1.384 0 0-1.074 1.25-1.191 1.812-.117.563-.078.567-.102.965-.023.399.121.923.121.923s-.801.104-1.234.034c-.391-.062-.875-.84-1-1.078-.172-.328-.539-.265-.682-.023-.224.383-.709 1.07-1.05 1.113-.669.084-2.055.03-3.14.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.283-.36-1.002-.929-1.243-1.985-.213-.936-.192-1.395.037-1.77.232-.381.67-.589.854-.625.208-.042.692-.039.875.062.223.123.313.159.488.391.23.307.312.456.213.121-.076-.262-.322-.595-.434-.97-.109-.361-.401-.943-.38-1.526.008-.221.103-.771.832-1.042z' stroke-linejoin='round'/><path d='m20.5664 19.7344v-3.459' stroke-linecap='round'/><path d='m18.5508 19.7461-.016-3.473' stroke-linecap='round'/><path d='m16.5547 16.3047.021 3.426' stroke-linecap='round'/></g>", q_e = '<path d="m13.5557 17.5742c-.098-.375-.196-.847-.406-1.552-.167-.557-.342-.859-.47-1.233-.155-.455-.303-.721-.496-1.181-.139-.329-.364-1.048-.457-1.44-.119-.509.033-.924.244-1.206.253-.339.962-.49 1.357-.351.371.13.744.512.916.788.288.46.357.632.717 1.542.393.992.564 1.918.611 2.231l.085.452c-.001-.04-.043-1.122-.044-1.162-.035-1.029-.06-1.823-.038-2.939.002-.126.064-.587.084-.715.078-.5.305-.8.673-.979.412-.201.926-.215 1.401-.017.423.173.626.55.687 1.022.014.109.094.987.093 1.107-.013 1.025.006 1.641.015 2.174.004.231.003 1.625.017 1.469.061-.656.094-3.189.344-3.942.144-.433.405-.746.794-.929.431-.203 1.113-.07 1.404.243.285.305.446.692.482 1.153.032.405-.019.897-.02 1.245 0 .867-.021 1.324-.037 2.121-.001.038-.015.298.023.182.094-.28.188-.542.266-.745.049-.125.241-.614.359-.859.114-.234.211-.369.415-.688.2-.313.415-.448.668-.561.54-.235 1.109.112 1.301.591.086.215.009.713-.028 1.105-.061.647-.254 1.306-.352 1.648-.128.447-.274 1.235-.34 1.601-.072.394-.234 1.382-.359 1.82-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.192 1.812-.117.563-.078.567-.101.965-.024.399.121.923.121.923s-.802.104-1.234.034c-.391-.062-.875-.841-1-1.078-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.03-3.139.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.284-.36-.629-1.093-1.243-1.985-.348-.504-1.027-1.085-1.284-1.579-.223-.425-.331-.954-.19-1.325.225-.594.675-.897 1.362-.832.519.05.848.206 1.238.537.225.19.573.534.75.748.163.195.203.276.377.509.23.307.302.459.214.121" fill="white"/><g stroke="black" stroke-linecap="round" stroke-width=".75"><path d="m13.5557 17.5742c-.098-.375-.196-.847-.406-1.552-.167-.557-.342-.859-.47-1.233-.155-.455-.303-.721-.496-1.181-.139-.329-.364-1.048-.457-1.44-.119-.509.033-.924.244-1.206.253-.339.962-.49 1.357-.351.371.13.744.512.916.788.288.46.357.632.717 1.542.393.992.564 1.918.611 2.231l.085.452c-.001-.04-.043-1.122-.044-1.162-.035-1.029-.06-1.823-.038-2.939.002-.126.064-.587.084-.715.078-.5.305-.8.673-.979.412-.201.926-.215 1.401-.017.423.173.626.55.687 1.022.014.109.094.987.093 1.107-.013 1.025.006 1.641.015 2.174.004.231.003 1.625.017 1.469.061-.656.094-3.189.344-3.942.144-.433.405-.746.794-.929.431-.203 1.113-.07 1.404.243.285.305.446.692.482 1.153.032.405-.019.897-.02 1.245 0 .867-.021 1.324-.037 2.121-.001.038-.015.298.023.182.094-.28.188-.542.266-.745.049-.125.241-.614.359-.859.114-.234.211-.369.415-.688.2-.313.415-.448.668-.561.54-.235 1.109.112 1.301.591.086.215.009.713-.028 1.105-.061.647-.254 1.306-.352 1.648-.128.447-.274 1.235-.34 1.601-.072.394-.234 1.382-.359 1.82-.086.301-.371.978-.652 1.384 0 0-1.074 1.25-1.192 1.812-.117.563-.078.567-.101.965-.024.399.121.923.121.923s-.802.104-1.234.034c-.391-.062-.875-.841-1-1.078-.172-.328-.539-.265-.682-.023-.225.383-.709 1.07-1.051 1.113-.668.084-2.054.03-3.139.02 0 0 .185-1.011-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.921c-.284-.36-.629-1.093-1.243-1.985-.348-.504-1.027-1.085-1.284-1.579-.223-.425-.331-.954-.19-1.325.225-.594.675-.897 1.362-.832.519.05.848.206 1.238.537.225.19.573.534.75.748.163.195.203.276.377.509.23.307.302.459.214.121" stroke-linejoin="round"/><path d="m20.5664 21.7344v-3.459"/><path d="m18.5508 21.7461-.016-3.473"/><path d="m16.5547 18.3047.021 3.426"/></g>', K_e = '<path d="m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5" fill="white"/><path d="m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5z" stroke="black"/><g fill="black"><path d="m18 14h-2v-2h-2v2h-2v1.98h2v2.02h2v-2.02h2z"/><path d="m23.5859 25 1.414-1.414-5.449-5.449-1.414 1.414z"/></g>', J_e = '<path d="m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5" fill="white"/><path d="m20.5 15c0 3.038-2.462 5.5-5.5 5.5s-5.5-2.462-5.5-5.5 2.462-5.5 5.5-5.5 5.5 2.462 5.5 5.5z" stroke="black"/><g fill="black"><path d="m18 16h-5.98v-1.98h5.98z"/><path d="m23.5859 25 1.414-1.414-5.449-5.449-1.414 1.414z"/></g>';
  function Mr(t, e, n, r, i, s = 16, o = 16) {
    const a = (-n - e) * (zt / 180), l = Math.sin(a), c = Math.cos(a), u = 1 * c - 1 * l, d = 1 * l + 1 * c;
    return `url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: ${i};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${u}' dy='${d}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${e + n} 16 16)${r ? " scale(-1,-1) translate(0, -32)" : ""}' filter='url(%23shadow)'>` + t.replaceAll('"', "'") + `</g></svg>") ${s} ${o}, pointer`;
  }
  const eTe = {
    none: () => "none",
    default: (t, e, n) => Mr(X_e, t, 0, e, n, 12, 8),
    pointer: (t, e, n) => Mr(W_e, t, 0, e, n, 14, 10),
    cross: (t, e, n) => Mr(Z_e, t, 0, e, n),
    move: (t, e, n) => Mr(H_e, t, 0, e, n),
    grab: (t, e, n) => Mr(q_e, t, 0, e, n),
    grabbing: (t, e, n) => Mr(G_e, t, 0, e, n),
    text: (t, e, n) => Mr(Y_e, t, 0, e, n, 4, 10),
    "ew-resize": (t, e, n) => Mr(X8, t, 0, e, n),
    "ns-resize": (t, e, n) => Mr(X8, t, 90, e, n),
    "nesw-resize": (t, e, n) => Mr(V8, t, 0, e, n),
    "nwse-resize": (t, e, n) => Mr(V8, t, 90, e, n),
    "nwse-rotate": (t, e, n) => Mr(Ow, t, 0, e, n),
    "nesw-rotate": (t, e, n) => Mr(Ow, t, 90, e, n),
    "senw-rotate": (t, e, n) => Mr(Ow, t, 180, e, n),
    "swne-rotate": (t, e, n) => Mr(Ow, t, 270, e, n),
    "zoom-in": (t, e, n) => Mr(K_e, t, 0, e, n),
    "zoom-out": (t, e, n) => Mr(J_e, t, 0, e, n)
  };
  function Ns(t, e = 0, n = "black") {
    return eTe[t](dke(e), false, n);
  }
  const tTe = [
    "default",
    "pointer",
    "cross",
    "move",
    "grab",
    "grabbing",
    "text"
  ];
  function nTe() {
    const t = ue(), e = Kr(), n = $C();
    Vh("useCursor", () => {
      const { type: r, rotation: i } = t.instanceState.cursor;
      if (tTe.includes(r)) {
        e.style.setProperty("--tl-cursor", `var(--tl-cursor-${r})`);
        return;
      }
      e.style.setProperty("--tl-cursor", Ns(r, i, n ? "white" : "black"));
    }, [
      t,
      e,
      n
    ]);
  }
  function rTe() {
    const t = ue(), e = Kr(), n = $C(), r = ye(un.forceSrgb);
    $e.useEffect(() => {
      n ? (e.setAttribute("data-color-mode", "dark"), e.classList.remove("tl-theme__light"), e.classList.add("tl-theme__dark")) : (e.setAttribute("data-color-mode", "light"), e.classList.remove("tl-theme__dark"), e.classList.add("tl-theme__light")), r ? e.classList.add("tl-theme__force-sRGB") : e.classList.remove("tl-theme__force-sRGB");
    }, [
      t,
      e,
      r,
      n
    ]);
  }
  function iTe(t) {
    const e = b.useRef();
    return b.useLayoutEffect(() => {
      e.current = t;
    }), b.useDebugValue(t), b.useCallback((...n) => {
      const r = e.current;
      return xC(r, "fn does not exist"), r(...n);
    }, []);
  }
  function sTe(t) {
    const e = ue(), n = Kr();
    b.useLayoutEffect(() => {
      t ? (e.instanceState.isFocused || e.updateInstanceState({
        isFocused: true
      }), e.getContainer().focus()) : e.instanceState.isFocused && e.updateInstanceState({
        isFocused: false
      });
    }, [
      e,
      n,
      t
    ]);
  }
  function oTe() {
    const [t, e] = b.useState(0);
    b.useEffect(() => e((n) => n + 1), []);
  }
  const gg = "TLDRAW_TAB_ID_v2", $a = globalThis.window;
  function aTe() {
    return $a ? [
      "iPad Simulator",
      "iPhone Simulator",
      "iPod Simulator",
      "iPad",
      "iPhone",
      "iPod"
    ].includes($a.navigator.platform) || $a.navigator.userAgent.includes("Mac") && "ontouchend" in document : false;
  }
  const Dk = ($a == null ? void 0 : $a[gg]) ?? ($a == null ? void 0 : $a.sessionStorage[gg]) ?? "TLDRAW_INSTANCE_STATE_V1_" + wn();
  $a && ($a[gg] = Dk, aTe() ? $a.sessionStorage[gg] = Dk : delete $a.sessionStorage[gg]);
  $a == null ? void 0 : $a.addEventListener("beforeunload", () => {
    $a.sessionStorage[gg] = Dk;
  });
  const lTe = {
    Initial: 0
  }, Yv = lTe.Initial, lq = $t({
    version: nt,
    currentPageId: Fv,
    isFocusMode: It,
    exportBackground: It,
    isDebugMode: It,
    isToolLocked: It,
    isGridMode: It,
    pageStates: so($t({
      pageId: Fv,
      camera: $t({
        x: nt,
        y: nt,
        z: nt
      }),
      selectedShapeIds: so(ba),
      focusedGroupId: ba.nullable()
    }))
  }), cTe = Ut({
    currentVersion: Yv
  });
  function uTe(t) {
    if (!t || typeof t != "object")
      return console.warn("Invalid instance state"), null;
    if (!("version" in t) || typeof t.version != "number")
      return console.warn("No version in instance state"), null;
    const e = c5({
      value: t,
      fromVersion: t.version,
      toVersion: Yv,
      migrations: cTe
    });
    if (e.type === "error")
      return console.warn(e.reason), null;
    const n = {
      ...e.value,
      version: Yv
    };
    try {
      lq.validate(n);
    } catch (r) {
      return console.warn(r), null;
    }
    return n;
  }
  function dTe(t) {
    const e = t.query.ids("page");
    return ve("sessionStateSnapshot", () => {
      const n = t.get(gi);
      if (!n)
        return null;
      const r = [
        ...e.value
      ];
      return {
        version: Yv,
        currentPageId: n.currentPageId,
        exportBackground: n.exportBackground,
        isFocusMode: n.isFocusMode,
        isDebugMode: n.isDebugMode,
        isToolLocked: n.isToolLocked,
        isGridMode: n.isGridMode,
        pageStates: r.map((i) => {
          const s = t.get(Qr.createId(i)), o = t.get(Nr.createId(i));
          return {
            pageId: i,
            camera: {
              x: (o == null ? void 0 : o.x) ?? 0,
              y: (o == null ? void 0 : o.y) ?? 0,
              z: (o == null ? void 0 : o.z) ?? 1
            },
            selectedShapeIds: (s == null ? void 0 : s.selectedShapeIds) ?? [],
            focusedGroupId: (s == null ? void 0 : s.focusedGroupId) ?? null
          };
        })
      };
    });
  }
  function hTe(t, e) {
    const n = uTe(e);
    if (!n)
      return;
    const r = t.allRecords().filter((o) => o.typeName === "instance_page_state" || o.typeName === "camera"), i = {
      added: {},
      updated: {},
      removed: {
        ...tG(r.map((o) => [
          o.id,
          o
        ]))
      }
    };
    t.has(gi) && (i.removed[gi] = t.get(gi));
    const s = {
      removed: {},
      updated: {},
      added: {
        [gi]: t.schema.types.instance.create({
          id: gi,
          currentPageId: n.currentPageId,
          isDebugMode: n.isDebugMode,
          isFocusMode: n.isFocusMode,
          isToolLocked: n.isToolLocked,
          isGridMode: n.isGridMode,
          exportBackground: n.exportBackground
        })
      }
    };
    for (const o of n.pageStates) {
      const a = Nr.createId(o.pageId), l = Qr.createId(o.pageId);
      s.added[a] = Nr.create({
        id: Nr.createId(o.pageId),
        x: o.camera.x,
        y: o.camera.y,
        z: o.camera.z
      }), s.added[l] = Qr.create({
        id: Qr.createId(o.pageId),
        pageId: o.pageId,
        selectedShapeIds: o.selectedShapeIds,
        focusedGroupId: o.focusedGroupId
      });
    }
    Ca(() => {
      t.applyDiff(PC([
        i,
        s
      ])), t.ensureStoreIsUsable();
    });
  }
  function fTe(t) {
    var _a3;
    const e = [];
    for (const i of Object.values(t))
      ((_a3 = i.typeName) == null ? void 0 : _a3.match(/^(instance.*|pointer|camera)$/)) && e.push(i);
    const n = e.filter((i) => i.typeName === "instance" && i.id !== gi)[0];
    if (!n)
      return null;
    const r = {
      version: Yv,
      currentPageId: n.currentPageId,
      exportBackground: !!n.exportBackground,
      isFocusMode: !!n.isFocusMode,
      isDebugMode: !!n.isDebugMode,
      isToolLocked: !!n.isToolLocked,
      isGridMode: false,
      pageStates: e.filter((i) => i.typeName === "instance_page_state" && i.instanceId === n.id).map((i) => {
        const s = t[i.cameraId] ?? {
          x: 0,
          y: 0,
          z: 1
        };
        return {
          pageId: i.pageId,
          camera: {
            x: s.x,
            y: s.y,
            z: s.z
          },
          selectedShapeIds: i.selectedShapeIds,
          focusedGroupId: i.focusedGroupId
        };
      })
    };
    try {
      return lq.validate(r), r;
    } catch {
      return null;
    }
  }
  function pTe() {
    window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.

Keep seeing this message?
\u2022 If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
\u2022 If your hard disk is full, try clearing up some space and then reload the page.`);
  }
  function gTe() {
    window.alert(`Oops! We could not access your browser's storage\u2014and the app won't work correctly without that. We now need to reload the page and try again.

Keep seeing this message?
\u2022 If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`);
  }
  const mTe = (t, e) => e.some((n) => t instanceof n);
  let W8, Z8;
  function yTe() {
    return W8 || (W8 = [
      IDBDatabase,
      IDBObjectStore,
      IDBIndex,
      IDBCursor,
      IDBTransaction
    ]);
  }
  function vTe() {
    return Z8 || (Z8 = [
      IDBCursor.prototype.advance,
      IDBCursor.prototype.continue,
      IDBCursor.prototype.continuePrimaryKey
    ]);
  }
  const cq = /* @__PURE__ */ new WeakMap(), aR = /* @__PURE__ */ new WeakMap(), uq = /* @__PURE__ */ new WeakMap(), RE = /* @__PURE__ */ new WeakMap(), E5 = /* @__PURE__ */ new WeakMap();
  function OTe(t) {
    const e = new Promise((n, r) => {
      const i = () => {
        t.removeEventListener("success", s), t.removeEventListener("error", o);
      }, s = () => {
        n(Lc(t.result)), i();
      }, o = () => {
        r(t.error), i();
      };
      t.addEventListener("success", s), t.addEventListener("error", o);
    });
    return e.then((n) => {
      n instanceof IDBCursor && cq.set(n, t);
    }).catch(() => {
    }), E5.set(e, t), e;
  }
  function STe(t) {
    if (aR.has(t))
      return;
    const e = new Promise((n, r) => {
      const i = () => {
        t.removeEventListener("complete", s), t.removeEventListener("error", o), t.removeEventListener("abort", o);
      }, s = () => {
        n(), i();
      }, o = () => {
        r(t.error || new DOMException("AbortError", "AbortError")), i();
      };
      t.addEventListener("complete", s), t.addEventListener("error", o), t.addEventListener("abort", o);
    });
    aR.set(t, e);
  }
  let lR = {
    get(t, e, n) {
      if (t instanceof IDBTransaction) {
        if (e === "done")
          return aR.get(t);
        if (e === "objectStoreNames")
          return t.objectStoreNames || uq.get(t);
        if (e === "store")
          return n.objectStoreNames[1] ? void 0 : n.objectStore(n.objectStoreNames[0]);
      }
      return Lc(t[e]);
    },
    set(t, e, n) {
      return t[e] = n, true;
    },
    has(t, e) {
      return t instanceof IDBTransaction && (e === "done" || e === "store") ? true : e in t;
    }
  };
  function wTe(t) {
    lR = t(lR);
  }
  function xTe(t) {
    return t === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype) ? function(e, ...n) {
      const r = t.call(ME(this), e, ...n);
      return uq.set(r, e.sort ? e.sort() : [
        e
      ]), Lc(r);
    } : vTe().includes(t) ? function(...e) {
      return t.apply(ME(this), e), Lc(cq.get(this));
    } : function(...e) {
      return Lc(t.apply(ME(this), e));
    };
  }
  function bTe(t) {
    return typeof t == "function" ? xTe(t) : (t instanceof IDBTransaction && STe(t), mTe(t, yTe()) ? new Proxy(t, lR) : t);
  }
  function Lc(t) {
    if (t instanceof IDBRequest)
      return OTe(t);
    if (RE.has(t))
      return RE.get(t);
    const e = bTe(t);
    return e !== t && (RE.set(t, e), E5.set(e, t)), e;
  }
  const ME = (t) => E5.get(t);
  function kTe(t, e, { blocked: n, upgrade: r, blocking: i, terminated: s } = {}) {
    const o = indexedDB.open(t, e), a = Lc(o);
    return r && o.addEventListener("upgradeneeded", (l) => {
      r(Lc(o.result), l.oldVersion, l.newVersion, Lc(o.transaction), l);
    }), n && o.addEventListener("blocked", (l) => n(l.oldVersion, l.newVersion, l)), a.then((l) => {
      s && l.addEventListener("close", () => s()), i && l.addEventListener("versionchange", (c) => i(c.oldVersion, c.newVersion, c));
    }).catch(() => {
    }), a;
  }
  function PTe(t, { blocked: e } = {}) {
    const n = indexedDB.deleteDatabase(t);
    return e && n.addEventListener("blocked", (r) => e(r.oldVersion, r)), Lc(n).then(() => {
    });
  }
  const CTe = [
    "get",
    "getKey",
    "getAll",
    "getAllKeys",
    "count"
  ], _Te = [
    "put",
    "add",
    "delete",
    "clear"
  ], DE = /* @__PURE__ */ new Map();
  function H8(t, e) {
    if (!(t instanceof IDBDatabase && !(e in t) && typeof e == "string"))
      return;
    if (DE.get(e))
      return DE.get(e);
    const n = e.replace(/FromIndex$/, ""), r = e !== n, i = _Te.includes(n);
    if (!(n in (r ? IDBIndex : IDBObjectStore).prototype) || !(i || CTe.includes(n)))
      return;
    const s = async function(o, ...a) {
      const l = this.transaction(o, i ? "readwrite" : "readonly");
      let c = l.store;
      return r && (c = c.index(a.shift())), (await Promise.all([
        c[n](...a),
        i && l.done
      ]))[0];
    };
    return DE.set(e, s), s;
  }
  wTe((t) => ({
    ...t,
    get: (e, n, r) => H8(e, n) || t.get(e, n, r),
    has: (e, n) => !!H8(e, n) || t.has(e, n)
  }));
  const AC = "TLDRAW_DOCUMENT_v2", dq = "TLDRAW_DB_NAME_INDEX_v2", Wt = {
    Records: "records",
    Schema: "schema",
    SessionState: "session_state"
  };
  async function RC(t, e) {
    ATe(t);
    const n = await kTe(t, 3, {
      upgrade(r) {
        r.objectStoreNames.contains(Wt.Records) || r.createObjectStore(Wt.Records), r.objectStoreNames.contains(Wt.Schema) || r.createObjectStore(Wt.Schema), r.objectStoreNames.contains(Wt.SessionState) || r.createObjectStore(Wt.SessionState);
      }
    });
    try {
      return await e(n);
    } finally {
      n.close();
    }
  }
  async function TTe({ persistenceKey: t, sessionId: e, didCancel: n }) {
    const r = AC + t;
    if (I5().includes(r))
      return await $Te({
        persistenceKey: t,
        didCancel: n
      }), await RC(r, async (i) => {
        var _a3, _b3;
        if (n == null ? void 0 : n())
          return;
        const s = i.transaction([
          Wt.Records,
          Wt.Schema,
          Wt.SessionState
        ], "readonly"), o = s.objectStore(Wt.Records), a = s.objectStore(Wt.Schema), l = s.objectStore(Wt.SessionState);
        let c = e ? (_a3 = await l.get(e)) == null ? void 0 : _a3.snapshot : null;
        c || (c = (_b3 = (await l.getAll()).sort((h, f) => h.updatedAt - f.updatedAt).pop()) == null ? void 0 : _b3.snapshot);
        const u = {
          records: await o.getAll(),
          schema: await a.get(Wt.Schema),
          sessionStateSnapshot: c
        };
        if (n == null ? void 0 : n()) {
          s.abort();
          return;
        }
        return await s.done, u;
      });
  }
  async function ETe({ persistenceKey: t, schema: e, changes: n, sessionId: r, sessionStateSnapshot: i, didCancel: s }) {
    const o = AC + t;
    await RC(o, async (a) => {
      const l = a.transaction([
        Wt.Records,
        Wt.Schema,
        Wt.SessionState
      ], "readwrite"), c = l.objectStore(Wt.Records), u = l.objectStore(Wt.Schema), d = l.objectStore(Wt.SessionState);
      for (const [h, f] of Object.entries(n.added))
        await c.put(f, h);
      for (const [h, f] of Object.values(n.updated))
        await c.put(f, f.id);
      for (const h of Object.keys(n.removed))
        await c.delete(h);
      if (u.put(e.serialize(), Wt.Schema), i && r ? d.put({
        snapshot: i,
        updatedAt: Date.now(),
        id: r
      }, r) : (i || r) && console.error("sessionStateSnapshot and instanceId must be provided together"), s == null ? void 0 : s())
        return l.abort();
      await l.done;
    });
  }
  async function ITe({ persistenceKey: t, schema: e, snapshot: n, sessionId: r, sessionStateSnapshot: i, didCancel: s }) {
    const o = AC + t;
    await RC(o, async (a) => {
      const l = a.transaction([
        Wt.Records,
        Wt.Schema,
        Wt.SessionState
      ], "readwrite"), c = l.objectStore(Wt.Records), u = l.objectStore(Wt.Schema), d = l.objectStore(Wt.SessionState);
      await c.clear();
      for (const [h, f] of Object.entries(n))
        await c.put(f, h);
      if (u.put(e.serialize(), Wt.Schema), i && r ? d.put({
        snapshot: i,
        updatedAt: Date.now(),
        id: r
      }, r) : (i || r) && console.error("sessionStateSnapshot and instanceId must be provided together"), s == null ? void 0 : s())
        return l.abort();
      await l.done;
    });
  }
  async function $Te({ persistenceKey: t, didCancel: e }) {
    await RC(AC + t, async (n) => {
      const r = n.transaction([
        Wt.SessionState
      ], "readwrite"), i = r.objectStore(Wt.SessionState), s = (await i.getAll()).sort((a, l) => a.updatedAt - l.updatedAt);
      if (s.length < 10) {
        await r.done;
        return;
      }
      const o = s.slice(0, s.length - 10);
      for (const { id: a } of o)
        await i.delete(a);
      if (e == null ? void 0 : e())
        return r.abort();
      await r.done;
    });
  }
  function I5() {
    const t = JSON.parse((window == null ? void 0 : window.localStorage.getItem(dq)) || "[]") ?? [];
    return Array.isArray(t) ? t : [];
  }
  function ATe(t) {
    const e = new Set(I5());
    e.add(t), window == null ? void 0 : window.localStorage.setItem(dq, JSON.stringify([
      ...e
    ]));
  }
  const RTe = 350, MTe = 1e4, Y8 = Symbol("UPDATE_INSTANCE_STATE"), DTe = (t) => t;
  class LTe {
    constructor(e) {
      __publicField(this, "onmessage");
    }
    postMessage(e) {
    }
    close() {
    }
  }
  const jTe = typeof BroadcastChannel > "u" ? LTe : BroadcastChannel;
  class NTe {
    constructor(e, { persistenceKey: n, sessionId: r = Dk, onLoad: i, onLoadError: s }, o = new jTe(`tldraw-tab-sync-${n}`)) {
      __publicField(this, "disposables", /* @__PURE__ */ new Set());
      __publicField(this, "diffQueue", []);
      __publicField(this, "didDispose", false);
      __publicField(this, "shouldDoFullDBWrite", true);
      __publicField(this, "isReloading", false);
      __publicField(this, "persistenceKey");
      __publicField(this, "sessionId");
      __publicField(this, "serializedSchema");
      __publicField(this, "isDebugging", false);
      __publicField(this, "documentTypes");
      __publicField(this, "$sessionStateSnapshot");
      __publicField(this, "initTime", Date.now());
      __publicField(this, "isPersisting", false);
      __publicField(this, "didLastWriteError", false);
      __publicField(this, "scheduledPersistTimeout", null);
      this.store = e, this.channel = o, typeof window < "u" && (window.tlsync = this), this.persistenceKey = n, this.sessionId = r, this.serializedSchema = this.store.schema.serialize(), this.$sessionStateSnapshot = dTe(this.store), this.disposables.add(e.listen(({ changes: a }) => {
        this.diffQueue.push(a), this.channel.postMessage(DTe({
          type: "diff",
          storeId: this.store.id,
          changes: a,
          schema: this.serializedSchema
        })), this.schedulePersist();
      }, {
        source: "user",
        scope: "document"
      })), this.disposables.add(e.listen(() => {
        this.diffQueue.push(Y8), this.schedulePersist();
      }, {
        scope: "session"
      })), this.connect(i, s), this.documentTypes = new Set(Object.values(this.store.schema.types).filter((a) => a.scope === "document").map((a) => a.typeName));
    }
    debug(...e) {
      this.isDebugging && console.debug(...e);
    }
    async connect(e, n) {
      this.debug("connecting");
      let r;
      try {
        r = await TTe({
          persistenceKey: this.persistenceKey,
          sessionId: this.sessionId,
          didCancel: () => this.didDispose
        });
      } catch (i) {
        n(i), gTe(), typeof window < "u" && window.location.reload();
        return;
      }
      if (this.debug("loaded data from store", r, "didDispose", this.didDispose), !this.didDispose)
        try {
          if (r) {
            const i = Object.fromEntries(r.records.map((a) => [
              a.id,
              a
            ])), s = r.sessionStateSnapshot ?? fTe(i), o = this.store.schema.migrateStoreSnapshot({
              store: i,
              schema: r.schema ?? this.store.schema.serializeEarliestVersion()
            });
            if (o.type === "error") {
              console.error("failed to migrate store", o), n(new Error(`Failed to migrate store: ${o.reason}`));
              return;
            }
            this.store.mergeRemoteChanges(() => {
              this.store.put(Object.values(o.value).filter((a) => this.documentTypes.has(a.typeName)), "initialize");
            }), s && hTe(this.store, s);
          }
          this.channel.onmessage = ({ data: i }) => {
            var _a3, _b3;
            this.debug("got message", i);
            const s = i, o = yxe(this.serializedSchema, s.schema ?? this.store.schema.serializeEarliestVersion());
            if (o === -1) {
              if (Date.now() - this.initTime < 5e3) {
                n(new Error("Schema mismatch, please close other tabs and reload the page"));
                return;
              }
              this.debug("reloading"), this.isReloading = true, (_b3 = (_a3 = window == null ? void 0 : window.location) == null ? void 0 : _a3.reload) == null ? void 0 : _b3.call(_a3);
              return;
            } else if (o === 1) {
              this.debug("telling them to reload"), this.channel.postMessage({
                type: "announce",
                schema: this.serializedSchema
              }), this.shouldDoFullDBWrite = true, this.persistIfNeeded();
              return;
            }
            s.type === "diff" && (this.debug("applying diff"), Ca(() => {
              this.store.mergeRemoteChanges(() => {
                this.store.applyDiff(s.changes), this.store.ensureStoreIsUsable();
              });
            }));
          }, this.channel.postMessage({
            type: "announce",
            schema: this.serializedSchema
          }), this.disposables.add(() => {
            this.channel.close();
          }), e(this);
        } catch (i) {
          if (this.debug("error loading data from store", i), this.didDispose)
            return;
          n(i);
          return;
        }
    }
    close() {
      this.debug("closing"), this.didDispose = true, this.disposables.forEach((e) => e());
    }
    schedulePersist() {
      this.debug("schedulePersist", this.scheduledPersistTimeout), !this.scheduledPersistTimeout && (this.scheduledPersistTimeout = setTimeout(() => {
        this.scheduledPersistTimeout = null, this.persistIfNeeded();
      }, this.didLastWriteError ? MTe : RTe));
    }
    persistIfNeeded() {
      this.debug("persistIfNeeded", {
        isPersisting: this.isPersisting,
        isReloading: this.isReloading,
        shouldDoFullDBWrite: this.shouldDoFullDBWrite,
        diffQueueLength: this.diffQueue.length,
        storeIsPossiblyCorrupt: this.store.isPossiblyCorrupted()
      }), this.scheduledPersistTimeout && (clearTimeout(this.scheduledPersistTimeout), this.scheduledPersistTimeout = null), !this.isPersisting && (this.isReloading || this.store.isPossiblyCorrupted() || (this.shouldDoFullDBWrite || this.diffQueue.length > 0) && this.doPersist());
    }
    async doPersist() {
      xC(!this.isPersisting, "persist already in progress"), this.isPersisting = true, this.debug("doPersist start");
      const e = this.diffQueue;
      this.diffQueue = [];
      try {
        if (this.shouldDoFullDBWrite)
          this.shouldDoFullDBWrite = false, await ITe({
            persistenceKey: this.persistenceKey,
            schema: this.store.schema,
            snapshot: this.store.serialize(),
            didCancel: () => this.didDispose,
            sessionId: this.sessionId,
            sessionStateSnapshot: this.$sessionStateSnapshot.value
          });
        else {
          const n = PC(e.filter((r) => r !== Y8));
          await ETe({
            persistenceKey: this.persistenceKey,
            changes: n,
            schema: this.store.schema,
            didCancel: () => this.didDispose,
            sessionId: this.sessionId,
            sessionStateSnapshot: this.$sessionStateSnapshot.value
          });
        }
        this.didLastWriteError = false;
      } catch (n) {
        this.shouldDoFullDBWrite = true, this.didLastWriteError = true, console.error("failed to store changes in indexed db", n), pTe(), typeof window < "u" && window.location.reload();
      }
      this.isPersisting = false, this.debug("doPersist end"), this.schedulePersist();
    }
  }
  function cR({ initialData: t, defaultName: e = "", ...n }) {
    const r = "schema" in n && n.schema ? n.schema : lbe({
      shapes: QTe(tq("shapeUtils" in n && n.shapeUtils ? n.shapeUtils : []))
    });
    return new nG({
      schema: r,
      initialData: t,
      props: {
        defaultName: e
      }
    });
  }
  function QTe(t) {
    return Object.fromEntries(t.map((e) => [
      e.type,
      {
        props: e.props,
        migrations: e.migrations
      }
    ]));
  }
  function zTe(t) {
    const [e, n] = b.useState(() => {
      const i = cR(t);
      return t.snapshot && i.loadSnapshot(t.snapshot), i;
    }), r = b.useRef(t);
    if (b.useEffect(() => void (r.current = t)), Object.keys(r.current).some((i) => r.current[i] !== t[i])) {
      const i = cR(t);
      return t.snapshot && i.loadSnapshot(t.snapshot), n(i), i;
    }
    return e;
  }
  function FTe({ persistenceKey: t, sessionId: e, ...n }) {
    const [r, i] = b.useState(null), s = zTe(n);
    return b.useEffect(() => {
      const o = wn();
      if (!t) {
        i({
          id: o,
          storeWithStatus: {
            status: "not-synced",
            store: s
          }
        });
        return;
      }
      i({
        id: o,
        storeWithStatus: {
          status: "loading"
        }
      });
      const a = (c) => {
        i((u) => (u == null ? void 0 : u.id) === o ? {
          id: o,
          storeWithStatus: c
        } : u);
      }, l = new NTe(s, {
        sessionId: e,
        persistenceKey: t,
        onLoad() {
          a({
            store: s,
            status: "synced-local"
          });
        },
        onLoadError(c) {
          a({
            status: "error",
            error: c
          });
        }
      });
      return () => {
        i((c) => (c == null ? void 0 : c.id) === o ? null : c), l.close();
      };
    }, [
      t,
      s,
      e
    ]), (r == null ? void 0 : r.storeWithStatus) ?? {
      status: "loading"
    };
  }
  let hq = false;
  if (typeof window < "u") {
    const t = window.navigator.userAgent, e = !!t.match(/iPad/i) || !!t.match(/iPhone/i), n = !!t.match(/WebKit/i);
    hq = e && n && !t.match(/CriOS/i);
  }
  function BTe() {
    const t = ue();
    b.useEffect(() => {
      if (!hq)
        return;
      function e(n) {
        (n.target instanceof HTMLInputElement && n.target.type === "text" || n.target instanceof HTMLTextAreaElement) && t.complete();
      }
      return document.addEventListener("focusout", e), () => document.removeEventListener("focusout", e);
    }, [
      t
    ]);
  }
  function UTe() {
    const t = ue(), e = Kr();
    b.useEffect(() => {
      const n = (s) => e.style.setProperty("--tl-zoom", s.toString()), r = eG(n, 100), i = new HO("useZoomCss", () => {
        t.currentPageShapeIds.size < 300 ? n(t.zoomLevel) : r(t.zoomLevel);
      });
      return i.attach(), i.execute(), () => {
        i.detach();
      };
    }, [
      t,
      e
    ]);
  }
  const VTe = [], XTe = [], WTe = b.memo(function({ store: e, components: n, className: r, user: i, ...s }) {
    const [o, a] = $e.useState(null), l = b.useMemo(() => i ?? GG(), [
      i
    ]), c = (n == null ? void 0 : n.ErrorFallback) === void 0 ? OG : n == null ? void 0 : n.ErrorFallback, u = {
      ...s,
      shapeUtils: s.shapeUtils ?? VTe,
      tools: s.tools ?? XTe
    };
    return m.jsx("div", {
      ref: a,
      draggable: false,
      className: Ze("tl-container tl-theme__light", r),
      onPointerDown: _r,
      tabIndex: -1,
      children: m.jsx(Xv, {
        fallback: c,
        onError: (d) => a5(d, {
          tags: {
            origin: "react.tldraw-before-app"
          }
        }),
        children: o && m.jsx(Hbe, {
          container: o,
          children: m.jsx(Uke, {
            overrides: n,
            children: e ? e instanceof nG ? m.jsx(pq, {
              ...u,
              store: e,
              user: l
            }) : m.jsx(fq, {
              ...u,
              store: e,
              user: l
            }) : m.jsx(ZTe, {
              ...u,
              store: e,
              user: l
            })
          })
        })
      })
    });
  });
  function ZTe(t) {
    const { defaultName: e, snapshot: n, initialData: r, shapeUtils: i, persistenceKey: s, sessionId: o, user: a } = t, l = FTe({
      shapeUtils: i,
      initialData: r,
      persistenceKey: s,
      sessionId: o,
      defaultName: e,
      snapshot: n
    });
    return m.jsx(fq, {
      ...t,
      store: l,
      user: a
    });
  }
  const fq = b.memo(function({ store: e, user: n, ...r }) {
    const i = Kr();
    switch (b.useLayoutEffect(() => {
      n.userPreferences.value.isDarkMode && (i.classList.remove("tl-theme__light"), i.classList.add("tl-theme__dark"));
    }, [
      i,
      n.userPreferences.value.isDarkMode
    ]), e.status) {
      case "error":
        throw e.error;
      case "loading":
        return m.jsx(gq, {
          children: "Connecting..."
        });
    }
    return m.jsx(pq, {
      ...r,
      store: e.store,
      user: n
    });
  });
  function pq({ onMount: t, children: e, store: n, tools: r, shapeUtils: i, user: s, initialState: o, autoFocus: a = true, inferDarkMode: l }) {
    const { ErrorFallback: c } = _i(), u = Kr(), [d, h] = b.useState(null);
    b.useLayoutEffect(() => {
      const y = new Ue({
        store: n,
        shapeUtils: i,
        tools: r,
        getContainer: () => u,
        user: s,
        initialState: o,
        inferDarkMode: l
      });
      return window.app = y, window.editor = y, h(y), () => {
        y.dispose();
      };
    }, [
      u,
      i,
      r,
      n,
      s,
      o,
      l
    ]);
    const f = b.useSyncExternalStore(b.useCallback((y) => d ? (d.on("crash", y), () => d.off("crash", y)) : () => {
    }, [
      d
    ]), () => (d == null ? void 0 : d.crashingError) ?? null);
    return d ? m.jsx(Xv, {
      fallback: c,
      onError: (y) => d.annotateError(y, {
        origin: "react.tldraw",
        willCrashApp: true
      }),
      children: f ? m.jsx(YTe, {
        crashingError: f
      }) : m.jsx(v5.Provider, {
        value: d,
        children: m.jsx(HTe, {
          autoFocus: a,
          onMount: t,
          children: e
        })
      })
    }) : null;
  }
  function HTe({ children: t, onMount: e, autoFocus: n }) {
    return UTe(), nTe(), rTe(), BTe(), oTe(), sTe(n), qTe(e), S2e(), ue().updateViewportScreenBounds(), t ?? m.jsx(P5, {});
  }
  function YTe({ crashingError: t }) {
    throw t;
  }
  function gq({ children: t }) {
    const { Spinner: e } = _i();
    return m.jsxs("div", {
      className: "tl-loading",
      children: [
        e ? m.jsx(e, {}) : null,
        t
      ]
    });
  }
  function GTe({ children: t }) {
    return m.jsx("div", {
      className: "tl-loading",
      children: t
    });
  }
  function qTe(t) {
    const e = ue(), n = iTe((r) => {
      const i = t == null ? void 0 : t(r);
      return r.emit("mount"), window.tldrawReady = true, i;
    });
    $e.useLayoutEffect(() => {
      if (e)
        return n == null ? void 0 : n(e);
    }, [
      e,
      n
    ]);
  }
  function Fg({ children: t, className: e = "", ...n }) {
    return m.jsx("div", {
      ...n,
      className: `tl-html-container ${e}`,
      children: t
    });
  }
  Vt(function({ x: e = 0, y: n = 0, rotation: r = 0, ...i }) {
    const s = ue(), o = b.useRef(null);
    return b.useLayoutEffect(() => {
      const { x: a, y: l, z: c } = s.camera, u = o.current;
      u && a !== void 0 && (u.style.transform = `translate(${a}px, ${l}px) scale(${c}) rotate(${r}rad) translate(${e}px, ${n}px)`);
    }, [
      s.camera,
      e,
      n,
      r
    ]), m.jsx("div", {
      ref: o,
      ...i,
      className: Ze("tl-positioned", i.className)
    });
  });
  function KTe(t, e, n = {}) {
    const { newPoint: r, handle: i, scaleX: s, scaleY: o } = e, { minWidth: a = 1, maxWidth: l = 1 / 0, minHeight: c = 1, maxHeight: u = 1 / 0 } = n;
    let d = t.props.w * s, h = t.props.h * o;
    const f = new I(0, 0);
    if (d > 0) {
      if (d < a) {
        switch (i) {
          case "top_left":
          case "left":
          case "bottom_left": {
            f.x = d - a;
            break;
          }
          case "top":
          case "bottom": {
            f.x = (d - a) / 2;
            break;
          }
          default:
            f.x = 0;
        }
        d = a;
      }
    } else if (f.x = d, d = -d, d < a) {
      switch (i) {
        case "top_left":
        case "left":
        case "bottom_left": {
          f.x = -d;
          break;
        }
        default:
          f.x = -a;
      }
      d = a;
    }
    if (h > 0) {
      if (h < c) {
        switch (i) {
          case "top_left":
          case "top":
          case "top_right": {
            f.y = h - c;
            break;
          }
          case "right":
          case "left": {
            f.y = (h - c) / 2;
            break;
          }
          default:
            f.y = 0;
        }
        h = c;
      }
    } else if (f.y = h, h = -h, h < c) {
      switch (i) {
        case "top_left":
        case "top":
        case "top_right": {
          f.y = -h;
          break;
        }
        default:
          f.y = -c;
      }
      h = c;
    }
    const { x: y, y: g } = f.rot(t.rotation).add(r);
    return {
      x: y,
      y: g,
      props: {
        w: Math.min(l, d),
        h: Math.min(u, h)
      }
    };
  }
  class Cm extends Nd {
    constructor() {
      super(...arguments);
      __publicField(this, "onResize", (e, n) => KTe(e, n));
    }
    getGeometry(e) {
      return new wd({
        width: e.props.w,
        height: e.props.h,
        isFilled: true
      });
    }
  }
  function JTe(t, e, n) {
    const r = e === "end" ? t.end.point : t.start.point, i = e === "end" ? t.start.point : t.end.point, s = t.isStraight ? I.Dist(i, r) : Math.abs(t.bodyArc.length), o = Math.max(Math.min(s / 5, n * 3), n);
    let a;
    if (t.isStraight)
      a = I.Nudge(r, i, o);
    else {
      const l = J2e(r, o, t.handleArc.center, t.handleArc.radius);
      a = e === "end" ? t.handleArc.sweepFlag ? l[0] : l[1] : t.handleArc.sweepFlag ? l[1] : l[0];
    }
    return {
      point: r,
      int: a
    };
  }
  function eEe({ point: t, int: e }) {
    const n = I.RotWith(e, t, zt / 6), r = I.RotWith(e, t, -zt / 6);
    return `M ${n.x} ${n.y} L ${t.x} ${t.y} L ${r.x} ${r.y}`;
  }
  function tEe({ point: t, int: e }) {
    const n = I.RotWith(e, t, zt / 6), r = I.RotWith(e, t, -zt / 6);
    return `M ${n.x} ${n.y} L ${t.x} ${t.y} L ${r.x} ${r.y} Z`;
  }
  function nEe({ point: t, int: e }) {
    const n = I.Sub(e, t).div(2), r = I.Add(t, I.Rot(n, Ft)), i = I.Sub(t, I.Rot(n, Ft));
    return `M ${r.x} ${r.y} L ${e.x} ${e.y} L ${i.x} ${i.y} Z`;
  }
  function rEe({ point: t, int: e }) {
    const n = I.Lrp(t, e, 0.45), r = I.Dist(n, t);
    return `M ${n.x - r},${n.y}
  a ${r},${r} 0 1,0 ${r * 2},0
  a ${r},${r} 0 1,0 -${r * 2},0 `;
  }
  function iEe({ point: t, int: e }) {
    const n = I.Lrp(t, e, 0.75), r = I.RotWith(n, t, zt / 4), i = I.RotWith(n, t, -zt / 4), s = I.Lrp(r, i, 0.5);
    return s.add(I.Sub(s, t)), `M ${s.x} ${s.y} L ${r.x} ${r.y} ${t.x} ${t.y} L ${i.x} ${i.y} Z`;
  }
  function sEe({ int: t, point: e }) {
    const n = I.Lrp(e, t, 0.85), r = I.Sub(n, e).div(2), i = I.Add(e, I.Rot(r, Ft)), s = I.Sub(e, I.Rot(r, Ft)), o = I.Add(n, I.Rot(r, Ft)), a = I.Sub(n, I.Rot(r, Ft));
    return `M ${i.x} ${i.y} L ${o.x} ${o.y} L ${a.x} ${a.y} L ${s.x} ${s.y} Z`;
  }
  function oEe({ int: t, point: e }) {
    const n = I.Sub(t, e).div(2), r = I.Add(e, I.Rot(n, Ft)), i = I.Sub(e, I.Rot(n, Ft));
    return `M ${r.x} ${r.y} L ${i.x} ${i.y}`;
  }
  function vp(t, e, n) {
    const r = e === "end" ? t.end.arrowhead : t.start.arrowhead;
    if (r === "none")
      return;
    const i = JTe(t, e, n);
    if (i) {
      switch (r) {
        case "bar":
          return oEe(i);
        case "square":
          return sEe(i);
        case "diamond":
          return iEe(i);
        case "dot":
          return rEe(i);
        case "inverted":
          return nEe(i);
        case "arrow":
          return eEe(i);
        case "triangle":
          return tEe(i);
      }
      return "";
    }
  }
  let aEe = (_a2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("pointing", e);
      });
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
    }
  }, __publicField(_a2, "id", "idle"), _a2), lEe = (_b2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "markId", "");
      __publicField(this, "wasFocusedOnEnter", false);
      __publicField(this, "onEnter", () => {
        const { isMenuOpen: e } = this.editor;
        this.wasFocusedOnEnter = !e;
      });
      __publicField(this, "onPointerMove", (e) => {
        if (this.editor.inputs.isDragging) {
          const { originPagePoint: n } = this.editor.inputs, r = this.parent.shapeType, i = bn();
          this.markId = `creating:${i}`, this.editor.mark(this.markId), this.editor.createShapes([
            {
              id: i,
              type: r,
              x: n.x,
              y: n.y,
              props: {
                w: 1,
                h: 1
              }
            }
          ]).select(i), this.editor.setCurrentTool("select.resizing", {
            ...e,
            target: "selection",
            handle: "bottom_right",
            isCreating: true,
            creationCursorOffset: {
              x: 1,
              y: 1
            },
            onInteractionEnd: this.parent.id
          });
        }
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    complete() {
      const { originPagePoint: e } = this.editor.inputs;
      if (!this.wasFocusedOnEnter)
        return;
      this.editor.mark(this.markId);
      const n = this.parent.shapeType, r = bn();
      this.editor.mark(this.markId), this.editor.createShapes([
        {
          id: r,
          type: n,
          x: e.x,
          y: e.y
        }
      ]);
      const i = this.editor.getShape(r), { w: s, h: o } = this.editor.getShapeUtil(i).getDefaultProps(), a = new I(s / 2, o / 2), l = this.editor.getShapeParentTransform(i);
      l && a.rot(-l.rotation()), this.editor.updateShapes([
        {
          id: r,
          type: n,
          x: i.x - a.x,
          y: i.y - a.y
        }
      ]), this.editor.setSelectedShapes([
        r
      ]), this.editor.instanceState.isToolLocked ? this.parent.transition("idle", {}) : this.editor.setCurrentTool("select.idle");
    }
    cancel() {
      this.parent.transition("idle", {});
    }
  }, __publicField(_b2, "id", "pointing"), _b2);
  class cEe extends ze {
  }
  __publicField(cEe, "id", "box");
  __publicField(cEe, "initial", "idle");
  __publicField(cEe, "children", () => [
    aEe,
    lEe
  ]);
  function G8(t) {
    const e = ue();
    return ye("isCropping", () => e.croppingShapeId === t, [
      e,
      t
    ]);
  }
  function MC(t) {
    const e = ue();
    return ye("isEditing", () => e.editingShapeId === t, [
      e,
      t
    ]);
  }
  function yl(t) {
    const e = ue();
    return b.useMemo(function() {
      const i = (c) => {
        if (c.isKilled)
          return;
        if (c.button === 2) {
          e.dispatch({
            type: "pointer",
            target: "selection",
            handle: t,
            name: "right_click",
            ...ps(c)
          });
          return;
        }
        if (c.button !== 0)
          return;
        const u = bk(c.currentTarget);
        function d() {
          u.removeEventListener("pointerup", d), KO(u, c);
        }
        qO(u, c), u.addEventListener("pointerup", d), e.dispatch({
          name: "pointer_down",
          type: "pointer",
          target: "selection",
          handle: t,
          ...ps(c)
        }), _r(c);
      };
      let s, o;
      function a(c) {
        c.isKilled || c.button === 0 && (c.clientX === s && c.clientY === o || (s = c.clientX, o = c.clientY, e.dispatch({
          name: "pointer_move",
          type: "pointer",
          target: "selection",
          handle: t,
          ...ps(c)
        })));
      }
      return {
        onPointerDown: i,
        onPointerMove: a,
        onPointerUp: (c) => {
          c.isKilled || c.button === 0 && e.dispatch({
            name: "pointer_up",
            type: "pointer",
            target: "selection",
            handle: t,
            ...ps(c)
          });
        }
      };
    }, [
      e,
      t
    ]);
  }
  const uEe = 20, dEe = 8;
  function $5(t, e = uEe) {
    return Math.max(dEe, Math.ceil(t / e));
  }
  class hEe extends Of {
    constructor(e) {
      super({
        ...e,
        isFilled: false,
        isClosed: false
      });
      __publicField(this, "_center");
      __publicField(this, "radius");
      __publicField(this, "start");
      __publicField(this, "end");
      __publicField(this, "measure");
      __publicField(this, "length");
      __publicField(this, "angleStart");
      __publicField(this, "angleEnd");
      const { center: n, radius: r, sweepFlag: i, largeArcFlag: s, start: o, end: a } = e;
      if (o.equals(a))
        throw Error("Arc must have different start and end points.");
      this.angleStart = I.Angle(n, o), this.angleEnd = I.Angle(n, a), this.measure = fEe(this.angleStart, this.angleEnd, i, s), this.length = this.measure * r, this.start = o, this.end = a, this._center = n, this.radius = r;
    }
    nearestPoint(e) {
      const { _center: n, measure: r, radius: i, angleEnd: s, angleStart: o, start: a, end: l } = this, c = q8(r, o, s, n.angle(e));
      if (c <= 0)
        return a;
      if (c >= 1)
        return l;
      const u = n.clone().add(e.clone().sub(n).uni().mul(i));
      let d = 1 / 0, h;
      for (const f of [
        a,
        l,
        u
      ])
        e.dist(f) < d && (h = f, d = e.dist(f));
      if (!h)
        throw Error("nearest point not found");
      return h;
    }
    hitTestLineSegment(e, n, r) {
      const { _center: i, radius: s, measure: o, angleStart: a, angleEnd: l } = this, c = IC(e, n, i, s);
      return c === null ? false : c.some((u) => {
        const d = q8(o, a, l, i.angle(u));
        return d >= 0 && d <= 1;
      });
    }
    getVertices() {
      const { _center: e, measure: n, length: r, radius: i, angleStart: s } = this, o = [];
      for (let a = 0, l = $5(Math.abs(r)); a < l + 1; a++) {
        const c = a / l * n, u = s + c;
        o.push(e.clone().add(new I(Math.cos(u), Math.sin(u)).mul(i)));
      }
      return o;
    }
  }
  function q8(t, e, n, r) {
    let i;
    if (Math.abs(t) > zt) {
      i = Wx(e, r);
      const s = Wx(r, n);
      return Math.abs(i) < Math.abs(s) ? i / t : (t - s) / t;
    } else
      return i = Wx(e, r), i / t;
  }
  function fEe(t, e, n, r) {
    const i = 2 * ((e - t) % Bt) % Bt - (e - t) % Bt;
    return r ? (Bt - Math.abs(i)) * (n ? 1 : -1) : i;
  }
  class mq extends Of {
    constructor(e) {
      super({
        isClosed: true,
        ...e
      });
      __publicField(this, "_center");
      __publicField(this, "radius");
      __publicField(this, "x");
      __publicField(this, "y");
      this.config = e;
      const { x: n = 0, y: r = 0, radius: i } = e;
      this.x = n, this.y = r, this._center = new I(i + n, i + r), this.radius = i;
    }
    getBounds() {
      return new Te(this.x, this.y, this.radius * 2, this.radius * 2);
    }
    getVertices() {
      const { _center: e, radius: n } = this, r = Bt * n, i = [];
      for (let s = 0, o = $5(r); s < o; s++) {
        const a = s / o * Bt;
        i.push(e.clone().add(I.FromAngle(a).mul(n)));
      }
      return i;
    }
    nearestPoint(e) {
      const { _center: n, radius: r } = this;
      return n.equals(e) ? I.AddXY(n, r, 0) : n.clone().add(e.clone().sub(n).uni().mul(r));
    }
    hitTestLineSegment(e, n, r) {
      const { _center: i, radius: s } = this;
      return IC(e, n, i, s) !== null;
    }
  }
  class pEe extends Sf {
    constructor(e) {
      const { start: n, cp1: r, cp2: i, end: s } = e;
      super({
        ...e,
        points: [
          n,
          s
        ]
      });
      __publicField(this, "a");
      __publicField(this, "b");
      __publicField(this, "c");
      __publicField(this, "d");
      this.a = n, this.b = r, this.c = i, this.d = s;
    }
    getVertices() {
      const e = [], { a: n, b: r, c: i, d: s } = this;
      for (let o = 0, a = 10; o <= a; o++) {
        const l = o / a;
        e.push(new I((1 - l) * (1 - l) * (1 - l) * n.x + 3 * ((1 - l) * (1 - l)) * l * r.x + 3 * (1 - l) * (l * l) * i.x + l * l * l * s.x, (1 - l) * (1 - l) * (1 - l) * n.y + 3 * ((1 - l) * (1 - l)) * l * r.y + 3 * (1 - l) * (l * l) * i.y + l * l * l * s.y));
      }
      return e;
    }
    midPoint() {
      return gEe(this, 0.5);
    }
    nearestPoint(e) {
      let n, r = 1 / 0;
      for (const i of this.segments) {
        const s = i.nearestPoint(e), o = s.dist(e);
        o < r && (n = s, r = o);
      }
      if (!n)
        throw Error("nearest point not found");
      return n;
    }
  }
  function gEe(t, e) {
    const { a: n, b: r, c: i, d: s } = t;
    return new I((1 - e) * (1 - e) * (1 - e) * n.x + 3 * ((1 - e) * (1 - e)) * e * r.x + 3 * (1 - e) * (e * e) * i.x + e * e * e * s.x, (1 - e) * (1 - e) * (1 - e) * n.y + 3 * ((1 - e) * (1 - e)) * e * r.y + 3 * (1 - e) * (e * e) * i.y + e * e * e * s.y);
  }
  class Gx extends Of {
    constructor(e) {
      super({
        ...e,
        isClosed: false,
        isFilled: false
      });
      __publicField(this, "points");
      __publicField(this, "_segments");
      __publicField(this, "_length");
      const { points: n } = e;
      this.points = n;
    }
    get segments() {
      if (!this._segments) {
        this._segments = [];
        const { points: e } = this, n = e.length, r = n - 2, i = 1.25;
        for (let s = 0; s < n - 1; s++) {
          const o = s === 0 ? e[0] : e[s - 1], a = e[s], l = e[s + 1], c = s === r ? l : e[s + 2], u = a, d = s === 0 ? o : new I(a.x + (l.x - o.x) / 6 * i, a.y + (l.y - o.y) / 6 * i), h = s === r ? l : new I(l.x - (c.x - a.x) / 6 * i, l.y - (c.y - a.y) / 6 * i), f = l;
          this._segments.push(new pEe({
            start: u,
            cp1: d,
            cp2: h,
            end: f
          }));
        }
      }
      return this._segments;
    }
    get length() {
      return this._length || (this._length = this.segments.reduce((e, n) => e + n.length, 0)), this._length;
    }
    getVertices() {
      const e = this.segments.reduce((n, r) => n.concat(r.vertices), []);
      return e.push(this.points[this.points.length - 1]), e;
    }
    nearestPoint(e) {
      let n, r = 1 / 0;
      for (const i of this.segments) {
        const s = i.nearestPoint(e), o = s.dist(e);
        o < r && (n = s, r = o);
      }
      if (!n)
        throw Error("nearest point not found");
      return n;
    }
    hitTestLineSegment(e, n, r) {
      return this.segments.some((i) => i.hitTestLineSegment(e, n, r));
    }
  }
  class yq extends Of {
    constructor(e) {
      super({
        ...e,
        isClosed: true
      });
      __publicField(this, "w");
      __publicField(this, "h");
      __publicField(this, "_edges");
      this.config = e;
      const { width: n, height: r } = e;
      this.w = n, this.h = r;
    }
    get edges() {
      if (!this._edges) {
        const { vertices: e } = this;
        this._edges = [];
        for (let n = 0, r = e.length; n < r; n++) {
          const i = e[n], s = e[(n + 1) % r];
          this._edges.push(new Ak({
            start: i,
            end: s
          }));
        }
      }
      return this._edges;
    }
    getVertices() {
      const e = Math.max(1, this.w), n = Math.max(1, this.h), r = e / 2, i = n / 2, s = Math.pow(r - i, 2) / Math.pow(r + i, 2), o = zt * (r + i) * (1 + 3 * s / (10 + Math.sqrt(4 - 3 * s))), a = $5(o), l = Bt / a, c = Math.cos(l), u = Math.sin(l);
      let d = 0, h = 1, f = 0, y = 1;
      const g = Array(a);
      for (let O = 0; O < a; O++)
        g[O] = new I(r + r * h, i + i * d), f = u * h + c * d, y = c * h - u * d, d = f, h = y;
      return g;
    }
    nearestPoint(e) {
      let n, r = 1 / 0;
      for (const i of this.edges) {
        const s = i.nearestPoint(e), o = s.dist(e);
        o < r && (n = s, r = o);
      }
      if (!n)
        throw Error("nearest point not found");
      return n;
    }
    hitTestLineSegment(e, n, r) {
      return this.edges.some((i) => i.hitTestLineSegment(e, n, r));
    }
    getBounds() {
      return new Te(0, 0, this.w, this.h);
    }
  }
  class mEe extends yq {
    constructor(e) {
      super({
        ...e
      }), this.config = e;
    }
    getVertices() {
      const e = Math.max(1, this.w), n = Math.max(1, this.h), r = e / 2, i = n / 2, s = 10, o = Array(s * 2 - 2);
      if (n > e)
        for (let a = 0; a < s - 1; a++) {
          const l = -zt + zt * a / (s - 2), c = zt * a / (s - 2);
          o[a] = new I(r + r * Math.cos(l), r + r * Math.sin(l)), o[a + (s - 1)] = new I(r + r * Math.cos(c), n - r + r * Math.sin(c));
        }
      else
        for (let a = 0; a < s - 1; a++) {
          const l = -Ft + zt * a / (s - 2), c = Ft + zt * -a / (s - 2);
          o[a] = new I(e - i + i * Math.cos(l), n - i + i * Math.sin(l)), o[a + (s - 1)] = new I(i - i * Math.cos(c), n - i + i * Math.sin(c));
        }
      return o;
    }
  }
  async function yEe({ shouldReload: t = true } = {}) {
    sessionStorage.clear(), await Promise.all(I5().map((e) => PTe(e))), localStorage.clear(), t && window.location.reload();
  }
  typeof window < "u" && (window.__tldraw__hardReset = yEe);
  function vEe(t, e = "_blank") {
    O5.openWindow(t, e);
  }
  var By = function(t) {
    return t && t.Math === Math && t;
  }, Ti = By(typeof globalThis == "object" && globalThis) || By(typeof window == "object" && window) || By(typeof self == "object" && self) || By(typeof Jn == "object" && Jn) || By(typeof Jn == "object" && Jn) || function() {
    return this;
  }() || Function("return this")(), A5 = {}, Ei = function(t) {
    try {
      return !!t();
    } catch {
      return true;
    }
  }, OEe = Ei, Fd = !OEe(function() {
    return Object.defineProperty({}, 1, {
      get: function() {
        return 7;
      }
    })[1] !== 7;
  }), SEe = Ei, DC = !SEe(function() {
    var t = (function() {
    }).bind();
    return typeof t != "function" || t.hasOwnProperty("prototype");
  }), wEe = DC, Sw = Function.prototype.call, iu = wEe ? Sw.bind(Sw) : function() {
    return Sw.apply(Sw, arguments);
  }, vq = {}, Oq = {}.propertyIsEnumerable, Sq = Object.getOwnPropertyDescriptor, xEe = Sq && !Oq.call({
    1: 2
  }, 1);
  vq.f = xEe ? function(e) {
    var n = Sq(this, e);
    return !!n && n.enumerable;
  } : Oq;
  var wq = function(t, e) {
    return {
      enumerable: !(t & 1),
      configurable: !(t & 2),
      writable: !(t & 4),
      value: e
    };
  }, xq = DC, bq = Function.prototype, uR = bq.call, bEe = xq && bq.bind.bind(uR, uR), Er = xq ? bEe : function(t) {
    return function() {
      return uR.apply(t, arguments);
    };
  }, kq = Er, kEe = kq({}.toString), PEe = kq("".slice), _m = function(t) {
    return PEe(kEe(t), 8, -1);
  }, CEe = Er, _Ee = Ei, TEe = _m, LE = Object, EEe = CEe("".split), IEe = _Ee(function() {
    return !LE("z").propertyIsEnumerable(0);
  }) ? function(t) {
    return TEe(t) === "String" ? EEe(t, "") : LE(t);
  } : LE, Pq = function(t) {
    return t == null;
  }, $Ee = Pq, AEe = TypeError, Tm = function(t) {
    if ($Ee(t))
      throw new AEe("Can't call method on " + t);
    return t;
  }, REe = IEe, MEe = Tm, LC = function(t) {
    return REe(MEe(t));
  }, jE = typeof document == "object" && document.all, Zi = typeof jE > "u" && jE !== void 0 ? function(t) {
    return typeof t == "function" || t === jE;
  } : function(t) {
    return typeof t == "function";
  }, DEe = Zi, su = function(t) {
    return typeof t == "object" ? t !== null : DEe(t);
  }, NE = Ti, LEe = Zi, jEe = function(t) {
    return LEe(t) ? t : void 0;
  }, jC = function(t, e) {
    return arguments.length < 2 ? jEe(NE[t]) : NE[t] && NE[t][e];
  }, NEe = Er, Cq = NEe({}.isPrototypeOf), QEe = Ti, K8 = QEe.navigator, J8 = K8 && K8.userAgent, zEe = J8 ? String(J8) : "", _q = Ti, QE = zEe, eF = _q.process, tF = _q.Deno, nF = eF && eF.versions || tF && tF.version, rF = nF && nF.v8, Ta, Lk;
  rF && (Ta = rF.split("."), Lk = Ta[0] > 0 && Ta[0] < 4 ? 1 : +(Ta[0] + Ta[1]));
  !Lk && QE && (Ta = QE.match(/Edge\/(\d+)/), (!Ta || Ta[1] >= 74) && (Ta = QE.match(/Chrome\/(\d+)/), Ta && (Lk = +Ta[1])));
  var FEe = Lk, iF = FEe, BEe = Ei, UEe = Ti, VEe = UEe.String, Tq = !!Object.getOwnPropertySymbols && !BEe(function() {
    var t = Symbol("symbol detection");
    return !VEe(t) || !(Object(t) instanceof Symbol) || !Symbol.sham && iF && iF < 41;
  }), XEe = Tq, Eq = XEe && !Symbol.sham && typeof Symbol.iterator == "symbol", WEe = jC, ZEe = Zi, HEe = Cq, YEe = Eq, GEe = Object, Iq = YEe ? function(t) {
    return typeof t == "symbol";
  } : function(t) {
    var e = WEe("Symbol");
    return ZEe(e) && HEe(e.prototype, GEe(t));
  }, qEe = String, KEe = function(t) {
    try {
      return qEe(t);
    } catch {
      return "Object";
    }
  }, JEe = Zi, eIe = KEe, tIe = TypeError, R5 = function(t) {
    if (JEe(t))
      return t;
    throw new tIe(eIe(t) + " is not a function");
  }, nIe = R5, rIe = Pq, M5 = function(t, e) {
    var n = t[e];
    return rIe(n) ? void 0 : nIe(n);
  }, zE = iu, FE = Zi, BE = su, iIe = TypeError, sIe = function(t, e) {
    var n, r;
    if (e === "string" && FE(n = t.toString) && !BE(r = zE(n, t)) || FE(n = t.valueOf) && !BE(r = zE(n, t)) || e !== "string" && FE(n = t.toString) && !BE(r = zE(n, t)))
      return r;
    throw new iIe("Can't convert object to primitive value");
  }, $q = {
    exports: {}
  }, sF = Ti, oIe = Object.defineProperty, D5 = function(t, e) {
    try {
      oIe(sF, t, {
        value: e,
        configurable: true,
        writable: true
      });
    } catch {
      sF[t] = e;
    }
    return e;
  }, aIe = Ti, lIe = D5, oF = "__core-js_shared__", aF = $q.exports = aIe[oF] || lIe(oF, {});
  (aF.versions || (aF.versions = [])).push({
    version: "3.45.1",
    mode: "global",
    copyright: "\xA9 2014-2025 Denis Pushkarev (zloirock.ru)",
    license: "https://github.com/zloirock/core-js/blob/v3.45.1/LICENSE",
    source: "https://github.com/zloirock/core-js"
  });
  var L5 = $q.exports, lF = L5, j5 = function(t, e) {
    return lF[t] || (lF[t] = e || {});
  }, cIe = Tm, uIe = Object, rS = function(t) {
    return uIe(cIe(t));
  }, dIe = Er, hIe = rS, fIe = dIe({}.hasOwnProperty), Bd = Object.hasOwn || function(e, n) {
    return fIe(hIe(e), n);
  }, pIe = Er, gIe = 0, mIe = Math.random(), yIe = pIe(1.1.toString), Aq = function(t) {
    return "Symbol(" + (t === void 0 ? "" : t) + ")_" + yIe(++gIe + mIe, 36);
  }, vIe = Ti, OIe = j5, cF = Bd, SIe = Aq, wIe = Tq, xIe = Eq, Jp = vIe.Symbol, UE = OIe("wks"), bIe = xIe ? Jp.for || Jp : Jp && Jp.withoutSetter || SIe, ou = function(t) {
    return cF(UE, t) || (UE[t] = wIe && cF(Jp, t) ? Jp[t] : bIe("Symbol." + t)), UE[t];
  }, kIe = iu, uF = su, dF = Iq, PIe = M5, CIe = sIe, _Ie = ou, TIe = TypeError, EIe = _Ie("toPrimitive"), IIe = function(t, e) {
    if (!uF(t) || dF(t))
      return t;
    var n = PIe(t, EIe), r;
    if (n) {
      if (e === void 0 && (e = "default"), r = kIe(n, t, e), !uF(r) || dF(r))
        return r;
      throw new TIe("Can't convert object to primitive value");
    }
    return e === void 0 && (e = "number"), CIe(t, e);
  }, $Ie = IIe, AIe = Iq, Rq = function(t) {
    var e = $Ie(t, "string");
    return AIe(e) ? e : e + "";
  }, RIe = Ti, hF = su, dR = RIe.document, MIe = hF(dR) && hF(dR.createElement), Mq = function(t) {
    return MIe ? dR.createElement(t) : {};
  }, DIe = Fd, LIe = Ei, jIe = Mq, Dq = !DIe && !LIe(function() {
    return Object.defineProperty(jIe("div"), "a", {
      get: function() {
        return 7;
      }
    }).a !== 7;
  }), NIe = Fd, QIe = iu, zIe = vq, FIe = wq, BIe = LC, UIe = Rq, VIe = Bd, XIe = Dq, fF = Object.getOwnPropertyDescriptor;
  A5.f = NIe ? fF : function(e, n) {
    if (e = BIe(e), n = UIe(n), XIe)
      try {
        return fF(e, n);
      } catch {
      }
    if (VIe(e, n))
      return FIe(!QIe(zIe.f, e, n), e[n]);
  };
  var Em = {}, WIe = Fd, ZIe = Ei, Lq = WIe && ZIe(function() {
    return Object.defineProperty(function() {
    }, "prototype", {
      value: 42,
      writable: false
    }).prototype !== 42;
  }), HIe = su, YIe = String, GIe = TypeError, xf = function(t) {
    if (HIe(t))
      return t;
    throw new GIe(YIe(t) + " is not an object");
  }, qIe = Fd, KIe = Dq, JIe = Lq, ww = xf, pF = Rq, e$e = TypeError, VE = Object.defineProperty, t$e = Object.getOwnPropertyDescriptor, XE = "enumerable", WE = "configurable", ZE = "writable";
  Em.f = qIe ? JIe ? function(e, n, r) {
    if (ww(e), n = pF(n), ww(r), typeof e == "function" && n === "prototype" && "value" in r && ZE in r && !r[ZE]) {
      var i = t$e(e, n);
      i && i[ZE] && (e[n] = r.value, r = {
        configurable: WE in r ? r[WE] : i[WE],
        enumerable: XE in r ? r[XE] : i[XE],
        writable: false
      });
    }
    return VE(e, n, r);
  } : VE : function(e, n, r) {
    if (ww(e), n = pF(n), ww(r), KIe)
      try {
        return VE(e, n, r);
      } catch {
      }
    if ("get" in r || "set" in r)
      throw new e$e("Accessors not supported");
    return "value" in r && (e[n] = r.value), e;
  };
  var n$e = Fd, r$e = Em, i$e = wq, N5 = n$e ? function(t, e, n) {
    return r$e.f(t, e, i$e(1, n));
  } : function(t, e, n) {
    return t[e] = n, t;
  }, jq = {
    exports: {}
  }, hR = Fd, s$e = Bd, Nq = Function.prototype, o$e = hR && Object.getOwnPropertyDescriptor, Q5 = s$e(Nq, "name"), a$e = Q5 && (function() {
  }).name === "something", l$e = Q5 && (!hR || hR && o$e(Nq, "name").configurable), c$e = {
    EXISTS: Q5,
    PROPER: a$e,
    CONFIGURABLE: l$e
  }, u$e = Er, d$e = Zi, fR = L5, h$e = u$e(Function.toString);
  d$e(fR.inspectSource) || (fR.inspectSource = function(t) {
    return h$e(t);
  });
  var Qq = fR.inspectSource, f$e = Ti, p$e = Zi, gF = f$e.WeakMap, g$e = p$e(gF) && /native code/.test(String(gF)), m$e = j5, y$e = Aq, mF = m$e("keys"), zq = function(t) {
    return mF[t] || (mF[t] = y$e(t));
  }, z5 = {}, v$e = g$e, Fq = Ti, O$e = su, S$e = N5, HE = Bd, YE = L5, w$e = zq, x$e = z5, yF = "Object already initialized", pR = Fq.TypeError, b$e = Fq.WeakMap, jk, Gv, Nk, k$e = function(t) {
    return Nk(t) ? Gv(t) : jk(t, {});
  }, P$e = function(t) {
    return function(e) {
      var n;
      if (!O$e(e) || (n = Gv(e)).type !== t)
        throw new pR("Incompatible receiver, " + t + " required");
      return n;
    };
  };
  if (v$e || YE.state) {
    var sl = YE.state || (YE.state = new b$e());
    sl.get = sl.get, sl.has = sl.has, sl.set = sl.set, jk = function(t, e) {
      if (sl.has(t))
        throw new pR(yF);
      return e.facade = t, sl.set(t, e), e;
    }, Gv = function(t) {
      return sl.get(t) || {};
    }, Nk = function(t) {
      return sl.has(t);
    };
  } else {
    var Op = w$e("state");
    x$e[Op] = true, jk = function(t, e) {
      if (HE(t, Op))
        throw new pR(yF);
      return e.facade = t, S$e(t, Op, e), e;
    }, Gv = function(t) {
      return HE(t, Op) ? t[Op] : {};
    }, Nk = function(t) {
      return HE(t, Op);
    };
  }
  var Bq = {
    set: jk,
    get: Gv,
    has: Nk,
    enforce: k$e,
    getterFor: P$e
  }, F5 = Er, C$e = Ei, _$e = Zi, xw = Bd, gR = Fd, T$e = c$e.CONFIGURABLE, E$e = Qq, Uq = Bq, I$e = Uq.enforce, $$e = Uq.get, vF = String, qx = Object.defineProperty, A$e = F5("".slice), R$e = F5("".replace), M$e = F5([].join), D$e = gR && !C$e(function() {
    return qx(function() {
    }, "length", {
      value: 8
    }).length !== 8;
  }), L$e = String(String).split("String"), j$e = jq.exports = function(t, e, n) {
    A$e(vF(e), 0, 7) === "Symbol(" && (e = "[" + R$e(vF(e), /^Symbol\(([^)]*)\).*$/, "$1") + "]"), n && n.getter && (e = "get " + e), n && n.setter && (e = "set " + e), (!xw(t, "name") || T$e && t.name !== e) && (gR ? qx(t, "name", {
      value: e,
      configurable: true
    }) : t.name = e), D$e && n && xw(n, "arity") && t.length !== n.arity && qx(t, "length", {
      value: n.arity
    });
    try {
      n && xw(n, "constructor") && n.constructor ? gR && qx(t, "prototype", {
        writable: false
      }) : t.prototype && (t.prototype = void 0);
    } catch {
    }
    var r = I$e(t);
    return xw(r, "source") || (r.source = M$e(L$e, typeof e == "string" ? e : "")), t;
  };
  Function.prototype.toString = j$e(function() {
    return _$e(this) && $$e(this).source || E$e(this);
  }, "toString");
  var N$e = jq.exports, Q$e = Zi, z$e = Em, F$e = N$e, B$e = D5, Vq = function(t, e, n, r) {
    r || (r = {});
    var i = r.enumerable, s = r.name !== void 0 ? r.name : e;
    if (Q$e(n) && F$e(n, s, r), r.global)
      i ? t[e] = n : B$e(e, n);
    else {
      try {
        r.unsafe ? t[e] && (i = true) : delete t[e];
      } catch {
      }
      i ? t[e] = n : z$e.f(t, e, {
        value: n,
        enumerable: false,
        configurable: !r.nonConfigurable,
        writable: !r.nonWritable
      });
    }
    return t;
  }, Xq = {}, U$e = Math.ceil, V$e = Math.floor, X$e = Math.trunc || function(e) {
    var n = +e;
    return (n > 0 ? V$e : U$e)(n);
  }, W$e = X$e, bf = function(t) {
    var e = +t;
    return e !== e || e === 0 ? 0 : W$e(e);
  }, Z$e = bf, H$e = Math.max, Y$e = Math.min, G$e = function(t, e) {
    var n = Z$e(t);
    return n < 0 ? H$e(n + e, 0) : Y$e(n, e);
  }, q$e = bf, K$e = Math.min, Wq = function(t) {
    var e = q$e(t);
    return e > 0 ? K$e(e, 9007199254740991) : 0;
  }, J$e = Wq, iS = function(t) {
    return J$e(t.length);
  }, eAe = LC, tAe = G$e, nAe = iS, OF = function(t) {
    return function(e, n, r) {
      var i = eAe(e), s = nAe(i);
      if (s === 0)
        return !t && -1;
      var o = tAe(r, s), a;
      if (t && n !== n) {
        for (; s > o; )
          if (a = i[o++], a !== a)
            return true;
      } else
        for (; s > o; o++)
          if ((t || o in i) && i[o] === n)
            return t || o || 0;
      return !t && -1;
    };
  }, rAe = {
    includes: OF(true),
    indexOf: OF(false)
  }, iAe = Er, GE = Bd, sAe = LC, oAe = rAe.indexOf, aAe = z5, SF = iAe([].push), Zq = function(t, e) {
    var n = sAe(t), r = 0, i = [], s;
    for (s in n)
      !GE(aAe, s) && GE(n, s) && SF(i, s);
    for (; e.length > r; )
      GE(n, s = e[r++]) && (~oAe(i, s) || SF(i, s));
    return i;
  }, B5 = [
    "constructor",
    "hasOwnProperty",
    "isPrototypeOf",
    "propertyIsEnumerable",
    "toLocaleString",
    "toString",
    "valueOf"
  ], lAe = Zq, cAe = B5, uAe = cAe.concat("length", "prototype");
  Xq.f = Object.getOwnPropertyNames || function(e) {
    return lAe(e, uAe);
  };
  var Hq = {};
  Hq.f = Object.getOwnPropertySymbols;
  var dAe = jC, hAe = Er, fAe = Xq, pAe = Hq, gAe = xf, mAe = hAe([].concat), yAe = dAe("Reflect", "ownKeys") || function(e) {
    var n = fAe.f(gAe(e)), r = pAe.f;
    return r ? mAe(n, r(e)) : n;
  }, wF = Bd, vAe = yAe, OAe = A5, SAe = Em, wAe = function(t, e, n) {
    for (var r = vAe(e), i = SAe.f, s = OAe.f, o = 0; o < r.length; o++) {
      var a = r[o];
      !wF(t, a) && !(n && wF(n, a)) && i(t, a, s(e, a));
    }
  }, xAe = Ei, bAe = Zi, kAe = /#|\.prototype\./, sS = function(t, e) {
    var n = CAe[PAe(t)];
    return n === TAe ? true : n === _Ae ? false : bAe(e) ? xAe(e) : !!e;
  }, PAe = sS.normalize = function(t) {
    return String(t).replace(kAe, ".").toLowerCase();
  }, CAe = sS.data = {}, _Ae = sS.NATIVE = "N", TAe = sS.POLYFILL = "P", EAe = sS, bw = Ti, IAe = A5.f, $Ae = N5, AAe = Vq, RAe = D5, MAe = wAe, DAe = EAe, Im = function(t, e) {
    var n = t.target, r = t.global, i = t.stat, s, o, a, l, c, u;
    if (r ? o = bw : i ? o = bw[n] || RAe(n, {}) : o = bw[n] && bw[n].prototype, o)
      for (a in e) {
        if (c = e[a], t.dontCallGetSet ? (u = IAe(o, a), l = u && u.value) : l = o[a], s = DAe(r ? a : n + (i ? "." : "#") + a, t.forced), !s && l !== void 0) {
          if (typeof c == typeof l)
            continue;
          MAe(c, l);
        }
        (t.sham || l && l.sham) && $Ae(c, "sham", true), AAe(o, a, c, t);
      }
  }, Yq = {}, LAe = Zq, jAe = B5, NAe = Object.keys || function(e) {
    return LAe(e, jAe);
  }, QAe = Fd, zAe = Lq, FAe = Em, BAe = xf, UAe = LC, VAe = NAe;
  Yq.f = QAe && !zAe ? Object.defineProperties : function(e, n) {
    BAe(e);
    for (var r = UAe(n), i = VAe(n), s = i.length, o = 0, a; s > o; )
      FAe.f(e, a = i[o++], r[a]);
    return e;
  };
  var XAe = jC, WAe = XAe("document", "documentElement"), ZAe = xf, HAe = Yq, xF = B5, YAe = z5, GAe = WAe, qAe = Mq, KAe = zq, bF = ">", kF = "<", mR = "prototype", yR = "script", Gq = KAe("IE_PROTO"), qE = function() {
  }, qq = function(t) {
    return kF + yR + bF + t + kF + "/" + yR + bF;
  }, PF = function(t) {
    t.write(qq("")), t.close();
    var e = t.parentWindow.Object;
    return t = null, e;
  }, JAe = function() {
    var t = qAe("iframe"), e = "java" + yR + ":", n;
    return t.style.display = "none", GAe.appendChild(t), t.src = String(e), n = t.contentWindow.document, n.open(), n.write(qq("document.F=Object")), n.close(), n.F;
  }, kw, Kx = function() {
    try {
      kw = new ActiveXObject("htmlfile");
    } catch {
    }
    Kx = typeof document < "u" ? document.domain && kw ? PF(kw) : JAe() : PF(kw);
    for (var t = xF.length; t--; )
      delete Kx[mR][xF[t]];
    return Kx();
  };
  YAe[Gq] = true;
  var Kq = Object.create || function(e, n) {
    var r;
    return e !== null ? (qE[mR] = ZAe(e), r = new qE(), qE[mR] = null, r[Gq] = e) : r = Kx(), n === void 0 ? r : HAe.f(r, n);
  }, eRe = ou, tRe = Kq, nRe = Em.f, vR = eRe("unscopables"), OR = Array.prototype;
  OR[vR] === void 0 && nRe(OR, vR, {
    configurable: true,
    value: tRe(null)
  });
  var U5 = function(t) {
    OR[vR][t] = true;
  }, rRe = Im, iRe = rS, sRe = iS, oRe = bf, aRe = U5;
  rRe({
    target: "Array",
    proto: true
  }, {
    at: function(e) {
      var n = iRe(this), r = sRe(n), i = oRe(e), s = i >= 0 ? i : r + i;
      return s < 0 || s >= r ? void 0 : n[s];
    }
  });
  aRe("at");
  var lRe = Ti, cRe = Er, oS = function(t, e) {
    return cRe(lRe[t].prototype[e]);
  }, uRe = oS;
  uRe("Array", "at");
  var dRe = _m, Jq = Array.isArray || function(e) {
    return dRe(e) === "Array";
  }, hRe = TypeError, fRe = 9007199254740991, pRe = function(t) {
    if (t > fRe)
      throw hRe("Maximum allowed index exceeded");
    return t;
  }, gRe = _m, mRe = Er, yRe = function(t) {
    if (gRe(t) === "Function")
      return mRe(t);
  }, CF = yRe, vRe = R5, ORe = DC, SRe = CF(CF.bind), wRe = function(t, e) {
    return vRe(t), e === void 0 ? t : ORe ? SRe(t, e) : function() {
      return t.apply(e, arguments);
    };
  }, xRe = Jq, bRe = iS, kRe = pRe, PRe = wRe, eK = function(t, e, n, r, i, s, o, a) {
    for (var l = i, c = 0, u = o ? PRe(o, a) : false, d, h; c < r; )
      c in n && (d = u ? u(n[c], c, e) : n[c], s > 0 && xRe(d) ? (h = bRe(d), l = eK(t, e, d, h, l, s - 1) - 1) : (kRe(l + 1), t[l] = d), l++), c++;
    return l;
  }, tK = eK, CRe = ou, _Re = CRe("toStringTag"), nK = {};
  nK[_Re] = "z";
  var TRe = String(nK) === "[object z]", ERe = TRe, IRe = Zi, Jx = _m, $Re = ou, ARe = $Re("toStringTag"), RRe = Object, MRe = Jx(function() {
    return arguments;
  }()) === "Arguments", DRe = function(t, e) {
    try {
      return t[e];
    } catch {
    }
  }, rK = ERe ? Jx : function(t) {
    var e, n, r;
    return t === void 0 ? "Undefined" : t === null ? "Null" : typeof (n = DRe(e = RRe(t), ARe)) == "string" ? n : MRe ? Jx(e) : (r = Jx(e)) === "Object" && IRe(e.callee) ? "Arguments" : r;
  }, LRe = Er, jRe = Ei, iK = Zi, NRe = rK, QRe = jC, zRe = Qq, sK = function() {
  }, oK = QRe("Reflect", "construct"), V5 = /^\s*(?:class|function)\b/, FRe = LRe(V5.exec), BRe = !V5.test(sK), Uy = function(e) {
    if (!iK(e))
      return false;
    try {
      return oK(sK, [], e), true;
    } catch {
      return false;
    }
  }, aK = function(e) {
    if (!iK(e))
      return false;
    switch (NRe(e)) {
      case "AsyncFunction":
      case "GeneratorFunction":
      case "AsyncGeneratorFunction":
        return false;
    }
    try {
      return BRe || !!FRe(V5, zRe(e));
    } catch {
      return true;
    }
  };
  aK.sham = true;
  var URe = !oK || jRe(function() {
    var t;
    return Uy(Uy.call) || !Uy(Object) || !Uy(function() {
      t = true;
    }) || t;
  }) ? aK : Uy, _F = Jq, VRe = URe, XRe = su, WRe = ou, ZRe = WRe("species"), TF = Array, HRe = function(t) {
    var e;
    return _F(t) && (e = t.constructor, VRe(e) && (e === TF || _F(e.prototype)) ? e = void 0 : XRe(e) && (e = e[ZRe], e === null && (e = void 0))), e === void 0 ? TF : e;
  }, YRe = HRe, lK = function(t, e) {
    return new (YRe(t))(e === 0 ? 0 : e);
  }, GRe = Im, qRe = tK, KRe = rS, JRe = iS, eMe = bf, tMe = lK;
  GRe({
    target: "Array",
    proto: true
  }, {
    flat: function() {
      var e = arguments.length ? arguments[0] : void 0, n = KRe(this), r = JRe(n), i = tMe(n, 0);
      return i.length = qRe(i, n, n, r, 0, e === void 0 ? 1 : eMe(e)), i;
    }
  });
  var nMe = U5;
  nMe("flat");
  var rMe = oS;
  rMe("Array", "flat");
  var iMe = Im, sMe = tK, oMe = R5, aMe = rS, lMe = iS, cMe = lK;
  iMe({
    target: "Array",
    proto: true
  }, {
    flatMap: function(e) {
      var n = aMe(this), r = lMe(n), i;
      return oMe(e), i = cMe(n, 0), i.length = sMe(i, n, n, r, 0, 1, e, arguments.length > 1 ? arguments[1] : void 0), i;
    }
  });
  var uMe = U5;
  uMe("flatMap");
  var dMe = oS;
  dMe("Array", "flatMap");
  var hMe = rK, fMe = String, aS = function(t) {
    if (hMe(t) === "Symbol")
      throw new TypeError("Cannot convert a Symbol value to a string");
    return fMe(t);
  }, pMe = Im, gMe = Er, mMe = Tm, yMe = bf, vMe = aS, OMe = Ei, SMe = gMe("".charAt), wMe = OMe(function() {
    return "\u{20BB7}".at(-2) !== "\uD842";
  });
  pMe({
    target: "String",
    proto: true,
    forced: wMe
  }, {
    at: function(e) {
      var n = vMe(mMe(this)), r = n.length, i = yMe(e), s = i >= 0 ? i : r + i;
      return s < 0 || s >= r ? void 0 : SMe(n, s);
    }
  });
  var xMe = oS;
  xMe("String", "at");
  var bMe = xf, cK = function() {
    var t = bMe(this), e = "";
    return t.hasIndices && (e += "d"), t.global && (e += "g"), t.ignoreCase && (e += "i"), t.multiline && (e += "m"), t.dotAll && (e += "s"), t.unicode && (e += "u"), t.unicodeSets && (e += "v"), t.sticky && (e += "y"), e;
  }, X5 = Ei, kMe = Ti, W5 = kMe.RegExp, Z5 = X5(function() {
    var t = W5("a", "y");
    return t.lastIndex = 2, t.exec("abcd") !== null;
  }), PMe = Z5 || X5(function() {
    return !W5("a", "y").sticky;
  }), CMe = Z5 || X5(function() {
    var t = W5("^r", "gy");
    return t.lastIndex = 2, t.exec("str") !== null;
  }), _Me = {
    BROKEN_CARET: CMe,
    MISSED_STICKY: PMe,
    UNSUPPORTED_Y: Z5
  }, TMe = Ei, EMe = Ti, IMe = EMe.RegExp, $Me = TMe(function() {
    var t = IMe(".", "s");
    return !(t.dotAll && t.test(`
`) && t.flags === "s");
  }), AMe = Ei, RMe = Ti, MMe = RMe.RegExp, DMe = AMe(function() {
    var t = MMe("(?<a>b)", "g");
    return t.exec("b").groups.a !== "b" || "b".replace(t, "$<a>c") !== "bc";
  }), eg = iu, NC = Er, LMe = aS, jMe = cK, NMe = _Me, QMe = j5, zMe = Kq, FMe = Bq.get, BMe = $Me, UMe = DMe, VMe = QMe("native-string-replace", String.prototype.replace), Qk = RegExp.prototype.exec, SR = Qk, XMe = NC("".charAt), WMe = NC("".indexOf), ZMe = NC("".replace), KE = NC("".slice), wR = function() {
    var t = /a/, e = /b*/g;
    return eg(Qk, t, "a"), eg(Qk, e, "a"), t.lastIndex !== 0 || e.lastIndex !== 0;
  }(), uK = NMe.BROKEN_CARET, xR = /()??/.exec("")[1] !== void 0, HMe = wR || xR || uK || BMe || UMe;
  HMe && (SR = function(e) {
    var n = this, r = FMe(n), i = LMe(e), s = r.raw, o, a, l, c, u, d, h;
    if (s)
      return s.lastIndex = n.lastIndex, o = eg(SR, s, i), n.lastIndex = s.lastIndex, o;
    var f = r.groups, y = uK && n.sticky, g = eg(jMe, n), O = n.source, S = 0, w = i;
    if (y && (g = ZMe(g, "y", ""), WMe(g, "g") === -1 && (g += "g"), w = KE(i, n.lastIndex), n.lastIndex > 0 && (!n.multiline || n.multiline && XMe(i, n.lastIndex - 1) !== `
`) && (O = "(?: " + O + ")", w = " " + w, S++), a = new RegExp("^(?:" + O + ")", g)), xR && (a = new RegExp("^" + O + "$(?!\\s)", g)), wR && (l = n.lastIndex), c = eg(Qk, y ? a : n, w), y ? c ? (c.input = KE(c.input, S), c[0] = KE(c[0], S), c.index = n.lastIndex, n.lastIndex += c[0].length) : n.lastIndex = 0 : wR && c && (n.lastIndex = n.global ? c.index + c[0].length : l), xR && c && c.length > 1 && eg(VMe, c[0], a, function() {
      for (u = 1; u < arguments.length - 2; u++)
        arguments[u] === void 0 && (c[u] = void 0);
    }), c && f)
      for (c.groups = d = zMe(null), u = 0; u < f.length; u++)
        h = f[u], d[h[0]] = c[h[1]];
    return c;
  });
  var H5 = SR, YMe = Im, EF = H5;
  YMe({
    target: "RegExp",
    proto: true,
    forced: /./.exec !== EF
  }, {
    exec: EF
  });
  var GMe = DC, dK = Function.prototype, IF = dK.apply, $F = dK.call, qMe = typeof Reflect == "object" && Reflect.apply || (GMe ? $F.bind(IF) : function() {
    return $F.apply(IF, arguments);
  }), AF = iu, RF = Vq, KMe = H5, MF = Ei, hK = ou, JMe = N5, eDe = hK("species"), JE = RegExp.prototype, tDe = function(t, e, n, r) {
    var i = hK(t), s = !MF(function() {
      var c = {};
      return c[i] = function() {
        return 7;
      }, ""[t](c) !== 7;
    }), o = s && !MF(function() {
      var c = false, u = /a/;
      return t === "split" && (u = {}, u.constructor = {}, u.constructor[eDe] = function() {
        return u;
      }, u.flags = "", u[i] = /./[i]), u.exec = function() {
        return c = true, null;
      }, u[i](""), !c;
    });
    if (!s || !o || n) {
      var a = /./[i], l = e(i, ""[t], function(c, u, d, h, f) {
        var y = u.exec;
        return y === KMe || y === JE.exec ? s && !f ? {
          done: true,
          value: AF(a, u, d, h)
        } : {
          done: true,
          value: AF(c, d, u, h)
        } : {
          done: false
        };
      });
      RF(String.prototype, t, l[0]), RF(JE, i, l[1]);
    }
    r && JMe(JE[i], "sham", true);
  }, Y5 = Er, nDe = bf, rDe = aS, iDe = Tm, sDe = Y5("".charAt), DF = Y5("".charCodeAt), oDe = Y5("".slice), LF = function(t) {
    return function(e, n) {
      var r = rDe(iDe(e)), i = nDe(n), s = r.length, o, a;
      return i < 0 || i >= s ? t ? "" : void 0 : (o = DF(r, i), o < 55296 || o > 56319 || i + 1 === s || (a = DF(r, i + 1)) < 56320 || a > 57343 ? t ? sDe(r, i) : o : t ? oDe(r, i, i + 2) : (o - 55296 << 10) + (a - 56320) + 65536);
    };
  }, aDe = {
    codeAt: LF(false),
    charAt: LF(true)
  }, lDe = aDe.charAt, cDe = function(t, e, n) {
    return e + (n ? lDe(t, e).length : 1);
  }, G5 = Er, uDe = rS, dDe = Math.floor, eI = G5("".charAt), hDe = G5("".replace), tI = G5("".slice), fDe = /\$([$&'`]|\d{1,2}|<[^>]*>)/g, pDe = /\$([$&'`]|\d{1,2})/g, fK = function(t, e, n, r, i, s) {
    var o = n + t.length, a = r.length, l = pDe;
    return i !== void 0 && (i = uDe(i), l = fDe), hDe(s, l, function(c, u) {
      var d;
      switch (eI(u, 0)) {
        case "$":
          return "$";
        case "&":
          return t;
        case "`":
          return tI(e, 0, n);
        case "'":
          return tI(e, o);
        case "<":
          d = i[tI(u, 1, -1)];
          break;
        default:
          var h = +u;
          if (h === 0)
            return c;
          if (h > a) {
            var f = dDe(h / 10);
            return f === 0 ? c : f <= a ? r[f - 1] === void 0 ? eI(u, 1) : r[f - 1] + eI(u, 1) : c;
          }
          d = r[h - 1];
      }
      return d === void 0 ? "" : d;
    });
  }, gDe = Ti, mDe = Ei, jF = gDe.RegExp, yDe = !mDe(function() {
    var t = true;
    try {
      jF(".", "d");
    } catch {
      t = false;
    }
    var e = {}, n = "", r = t ? "dgimsy" : "gimsy", i = function(l, c) {
      Object.defineProperty(e, l, {
        get: function() {
          return n += c, true;
        }
      });
    }, s = {
      dotAll: "s",
      global: "g",
      ignoreCase: "i",
      multiline: "m",
      sticky: "y"
    };
    t && (s.hasIndices = "d");
    for (var o in s)
      i(o, s[o]);
    var a = Object.getOwnPropertyDescriptor(jF.prototype, "flags").get.call(e);
    return a !== r || n !== r;
  }), vDe = {
    correct: yDe
  }, ODe = iu, SDe = Bd, wDe = Cq, NF = vDe, xDe = cK, bDe = RegExp.prototype, pK = NF.correct ? function(t) {
    return t.flags;
  } : function(t) {
    return !NF.correct && wDe(bDe, t) && !SDe(t, "flags") ? ODe(xDe, t) : t.flags;
  }, QF = iu, kDe = xf, PDe = Zi, CDe = _m, _De = H5, TDe = TypeError, EDe = function(t, e) {
    var n = t.exec;
    if (PDe(n)) {
      var r = QF(n, t, e);
      return r !== null && kDe(r), r;
    }
    if (CDe(t) === "RegExp")
      return QF(_De, t, e);
    throw new TDe("RegExp#exec called on incompatible receiver");
  }, IDe = qMe, zF = iu, QC = Er, $De = tDe, ADe = Ei, RDe = xf, MDe = Zi, DDe = su, LDe = bf, jDe = Wq, hh = aS, NDe = Tm, QDe = cDe, zDe = M5, FDe = fK, BDe = pK, UDe = EDe, VDe = ou, bR = VDe("replace"), XDe = Math.max, WDe = Math.min, ZDe = QC([].concat), nI = QC([].push), Pw = QC("".indexOf), FF = QC("".slice), HDe = function(t) {
    return t === void 0 ? t : String(t);
  }, YDe = function() {
    return "a".replace(/./, "$0") === "$0";
  }(), BF = function() {
    return /./[bR] ? /./[bR]("a", "$0") === "" : false;
  }(), GDe = !ADe(function() {
    var t = /./;
    return t.exec = function() {
      var e = [];
      return e.groups = {
        a: "7"
      }, e;
    }, "".replace(t, "$<a>") !== "7";
  });
  $De("replace", function(t, e, n) {
    var r = BF ? "$" : "$0";
    return [
      function(s, o) {
        var a = NDe(this), l = DDe(s) ? zDe(s, bR) : void 0;
        return l ? zF(l, s, a, o) : zF(e, hh(a), s, o);
      },
      function(i, s) {
        var o = RDe(this), a = hh(i);
        if (typeof s == "string" && Pw(s, r) === -1 && Pw(s, "$<") === -1) {
          var l = n(e, o, a, s);
          if (l.done)
            return l.value;
        }
        var c = MDe(s);
        c || (s = hh(s));
        var u = hh(BDe(o)), d = Pw(u, "g") !== -1, h;
        d && (h = Pw(u, "u") !== -1, o.lastIndex = 0);
        for (var f = [], y; y = UDe(o, a), !(y === null || (nI(f, y), !d)); ) {
          var g = hh(y[0]);
          g === "" && (o.lastIndex = QDe(a, jDe(o.lastIndex), h));
        }
        for (var O = "", S = 0, w = 0; w < f.length; w++) {
          y = f[w];
          for (var x = hh(y[0]), P = XDe(WDe(LDe(y.index), a.length), 0), C = [], _, T = 1; T < y.length; T++)
            nI(C, HDe(y[T]));
          var $ = y.groups;
          if (c) {
            var N = ZDe([
              x
            ], C, P, a);
            $ !== void 0 && nI(N, $), _ = hh(IDe(s, void 0, N));
          } else
            _ = FDe(x, a, P, C, $, s);
          P >= S && (O += FF(a, S, P) + _, S = P + x.length);
        }
        return O + FF(a, S);
      }
    ];
  }, !GDe || !YDe || BF);
  var qDe = su, KDe = _m, JDe = ou, e3e = JDe("match"), t3e = function(t) {
    var e;
    return qDe(t) && ((e = t[e3e]) !== void 0 ? !!e : KDe(t) === "RegExp");
  }, n3e = Im, r3e = iu, q5 = Er, UF = Tm, i3e = Zi, s3e = su, o3e = t3e, Vy = aS, a3e = M5, l3e = pK, c3e = fK, u3e = ou, d3e = u3e("replace"), h3e = TypeError, rI = q5("".indexOf);
  q5("".replace);
  var VF = q5("".slice), f3e = Math.max;
  n3e({
    target: "String",
    proto: true
  }, {
    replaceAll: function(e, n) {
      var r = UF(this), i, s, o, a, l, c, u, d, h, f, y = 0, g = "";
      if (s3e(e)) {
        if (i = o3e(e), i && (s = Vy(UF(l3e(e))), !~rI(s, "g")))
          throw new h3e("`.replaceAll` does not allow non-global regexes");
        if (o = a3e(e, d3e), o)
          return r3e(o, e, r, n);
      }
      for (a = Vy(r), l = Vy(e), c = i3e(n), c || (n = Vy(n)), u = l.length, d = f3e(1, u), h = rI(a, l); h !== -1; )
        f = c ? Vy(n(l, h, a)) : c3e(l, a, h, [], void 0, n), g += VF(a, y, h) + f, y = h + u, h = h + d > a.length ? -1 : rI(a, l, h + d);
      return y < a.length && (g += VF(a, y)), g;
    }
  });
  var p3e = oS;
  p3e("String", "replaceAll");
  const gK = b.createContext(null);
  function g3e({ assetUrls: t, children: e }) {
    return m.jsx(gK.Provider, {
      value: t,
      children: e
    });
  }
  function K5() {
    const t = b.useContext(gK);
    if (!t)
      throw new Error("useAssetUrls must be used within an AssetUrlsProvider");
    return t;
  }
  const kR = {
    "action.convert-to-bookmark": "Convert to Bookmark",
    "action.convert-to-embed": "Convert to Embed",
    "action.open-embed-link": "Open link",
    "action.align-bottom": "Align bottom",
    "action.align-center-horizontal": "Align horizontally",
    "action.align-center-vertical": "Align vertically",
    "action.align-center-horizontal.short": "Align H",
    "action.align-center-vertical.short": "Align V",
    "action.align-left": "Align left",
    "action.align-right": "Align right",
    "action.align-top": "Align top",
    "action.back-to-content": "Back to content",
    "action.bring-forward": "Bring forward",
    "action.bring-to-front": "Bring to front",
    "action.copy-as-json.short": "JSON",
    "action.copy-as-json": "Copy as JSON",
    "action.copy-as-png.short": "PNG",
    "action.copy-as-png": "Copy as PNG",
    "action.copy-as-svg.short": "SVG",
    "action.copy-as-svg": "Copy as SVG",
    "action.copy": "Copy",
    "action.cut": "Cut",
    "action.delete": "Delete",
    "action.unlock-all": "Unlock all",
    "action.distribute-horizontal": "Distribute horizontally",
    "action.distribute-vertical": "Distribute vertically",
    "action.distribute-horizontal.short": "Distribute H",
    "action.distribute-vertical.short": "Distribute V",
    "action.duplicate": "Duplicate",
    "action.edit-link": "Edit link",
    "action.exit-pen-mode": "Exit pen mode",
    "action.export-as-json.short": "JSON",
    "action.export-as-json": "Export as JSON",
    "action.export-as-png.short": "PNG",
    "action.export-as-png": "Export as PNG",
    "action.export-as-svg.short": "SVG",
    "action.export-as-svg": "Export as SVG",
    "action.flip-horizontal": "Flip horizontally",
    "action.flip-vertical": "Flip vertically",
    "action.flip-horizontal.short": "Flip H",
    "action.flip-vertical.short": "Flip V",
    "action.fork-project": "Fork this project",
    "action.group": "Group",
    "action.insert-embed": "Insert embed",
    "action.insert-media": "Upload media",
    "action.leave-shared-project": "Leave shared project",
    "action.new-project": "New project",
    "action.new-shared-project": "New shared project",
    "action.open-cursor-chat": "Cursor chat",
    "action.open-file": "Open file",
    "action.pack": "Pack",
    "action.paste": "Paste",
    "action.print": "Print",
    "action.redo": "Redo",
    "action.rotate-ccw": "Rotate counterclockwise",
    "action.rotate-cw": "Rotate clockwise",
    "action.save-copy": "Save a copy",
    "action.select-all": "Select all",
    "action.select-none": "Select none",
    "action.send-backward": "Send backward",
    "action.send-to-back": "Send to back",
    "action.share-project": "Share this project",
    "action.stack-horizontal": "Stack horizontally",
    "action.stack-vertical": "Stack vertically",
    "action.stack-horizontal.short": "Stack H",
    "action.stack-vertical.short": "Stack V",
    "action.stop-following": "Stop following",
    "action.stretch-horizontal": "Stretch horizontally",
    "action.stretch-vertical": "Stretch vertically",
    "action.stretch-horizontal.short": "Stretch H",
    "action.stretch-vertical.short": "Stretch V",
    "action.toggle-auto-size": "Toggle auto size",
    "action.toggle-dark-mode.menu": "Dark mode",
    "action.toggle-dark-mode": "Toggle dark mode",
    "action.toggle-reduce-motion.menu": "Reduce motion",
    "action.toggle-reduce-motion": "Toggle reduce motion",
    "action.toggle-debug-mode.menu": "Debug mode",
    "action.toggle-debug-mode": "Toggle debug mode",
    "action.toggle-focus-mode.menu": "Focus mode",
    "action.toggle-focus-mode": "Toggle focus mode",
    "action.toggle-grid.menu": "Show grid",
    "action.toggle-grid": "Toggle grid",
    "action.toggle-lock": "Toggle locked",
    "action.toggle-snap-mode.menu": "Always snap",
    "action.toggle-snap-mode": "Toggle always snap",
    "action.toggle-tool-lock.menu": "Tool lock",
    "action.toggle-tool-lock": "Toggle tool lock",
    "action.toggle-transparent.context-menu": "Transparent",
    "action.toggle-transparent.menu": "Transparent",
    "action.toggle-transparent": "Toggle transparent background",
    "action.undo": "Undo",
    "action.ungroup": "Ungroup",
    "action.zoom-in": "Zoom in",
    "action.zoom-out": "Zoom out",
    "action.zoom-to-100": "Zoom to 100%",
    "action.zoom-to-fit": "Zoom to fit",
    "action.zoom-to-selection": "Zoom to selection",
    "color-style.black": "Black",
    "color-style.blue": "Blue",
    "color-style.green": "Green",
    "color-style.grey": "Grey",
    "color-style.light-blue": "Light blue",
    "color-style.light-green": "Light green",
    "color-style.light-red": "Light red",
    "color-style.light-violet": "Light violet",
    "color-style.orange": "Orange",
    "color-style.red": "Red",
    "color-style.violet": "Violet",
    "color-style.yellow": "Yellow",
    "fill-style.none": "None",
    "fill-style.semi": "Semi",
    "fill-style.solid": "Solid",
    "fill-style.pattern": "Pattern",
    "dash-style.dashed": "Dashed",
    "dash-style.dotted": "Dotted",
    "dash-style.draw": "Draw",
    "dash-style.solid": "Solid",
    "size-style.s": "Small",
    "size-style.m": "Medium",
    "size-style.l": "Large",
    "size-style.xl": "Extra large",
    "opacity-style.0.1": "10%",
    "opacity-style.0.25": "25%",
    "opacity-style.0.5": "50%",
    "opacity-style.0.75": "75%",
    "opacity-style.1": "100%",
    "font-style.draw": "Draw",
    "font-style.sans": "Sans",
    "font-style.serif": "Serif",
    "font-style.mono": "Mono",
    "align-style.start": "Start",
    "align-style.middle": "Middle",
    "align-style.end": "End",
    "align-style.justify": "Justify",
    "geo-style.arrow-down": "Arrow down",
    "geo-style.arrow-left": "Arrow left",
    "geo-style.arrow-right": "Arrow right",
    "geo-style.arrow-up": "Arrow up",
    "geo-style.diamond": "Diamond",
    "geo-style.ellipse": "Ellipse",
    "geo-style.hexagon": "Hexagon",
    "geo-style.octagon": "Octagon",
    "geo-style.oval": "Oval",
    "geo-style.cloud": "Cloud",
    "geo-style.pentagon": "Pentagon",
    "geo-style.rectangle": "Rectangle",
    "geo-style.rhombus-2": "Rhombus 2",
    "geo-style.rhombus": "Rhombus",
    "geo-style.star": "Star",
    "geo-style.trapezoid": "Trapezoid",
    "geo-style.triangle": "Triangle",
    "geo-style.x-box": "X box",
    "geo-style.check-box": "Check box",
    "arrowheadStart-style.none": "None",
    "arrowheadStart-style.arrow": "Arrow",
    "arrowheadStart-style.bar": "Bar",
    "arrowheadStart-style.diamond": "Diamond",
    "arrowheadStart-style.dot": "Dot",
    "arrowheadStart-style.inverted": "Inverted",
    "arrowheadStart-style.pipe": "Pipe",
    "arrowheadStart-style.square": "Square",
    "arrowheadStart-style.triangle": "Triangle",
    "arrowheadEnd-style.none": "None",
    "arrowheadEnd-style.arrow": "Arrow",
    "arrowheadEnd-style.bar": "Bar",
    "arrowheadEnd-style.diamond": "Diamond",
    "arrowheadEnd-style.dot": "Dot",
    "arrowheadEnd-style.inverted": "Inverted",
    "arrowheadEnd-style.pipe": "Pipe",
    "arrowheadEnd-style.square": "Square",
    "arrowheadEnd-style.triangle": "Triangle",
    "spline-style.line": "Line",
    "spline-style.cubic": "Cubic",
    "tool.select": "Select",
    "tool.hand": "Hand",
    "tool.draw": "Draw",
    "tool.eraser": "Eraser",
    "tool.arrow-down": "Arrow down",
    "tool.arrow-left": "Arrow left",
    "tool.arrow-right": "Arrow right",
    "tool.arrow-up": "Arrow up",
    "tool.arrow": "Arrow",
    "tool.cloud": "Cloud",
    "tool.diamond": "Diamond",
    "tool.ellipse": "Ellipse",
    "tool.hexagon": "Hexagon",
    "tool.highlight": "Highlight",
    "tool.line": "Line",
    "tool.octagon": "Octagon",
    "tool.oval": "Oval",
    "tool.pentagon": "Pentagon",
    "tool.rectangle": "Rectangle",
    "tool.rhombus": "Rhombus",
    "tool.star": "Star",
    "tool.trapezoid": "Trapezoid",
    "tool.triangle": "Triangle",
    "tool.x-box": "X box",
    "tool.check-box": "Check box",
    "tool.asset": "Asset",
    "tool.frame": "Frame",
    "tool.note": "Note",
    "tool.laser": "Laser",
    "tool.embed": "Embed",
    "tool.text": "Text",
    "menu.title": "Menu",
    "menu.copy-as": "Copy as",
    "menu.edit": "Edit",
    "menu.export-as": "Export as",
    "menu.file": "File",
    "menu.language": "Language",
    "menu.preferences": "Preferences",
    "menu.view": "View",
    "context-menu.arrange": "Arrange",
    "context-menu.copy-as": "Copy as",
    "context-menu.export-as": "Export as",
    "context-menu.move-to-page": "Move to page",
    "context-menu.reorder": "Reorder",
    "page-menu.title": "Pages",
    "page-menu.create-new-page": "Create new page",
    "page-menu.max-page-count-reached": "Max pages reached",
    "page-menu.new-page-initial-name": "Page 1",
    "page-menu.edit-start": "Edit",
    "page-menu.edit-done": "Done",
    "page-menu.go-to-page": "Go to page",
    "page-menu.submenu.rename": "Rename",
    "page-menu.submenu.duplicate-page": "Duplicate",
    "page-menu.submenu.title": "Menu",
    "page-menu.submenu.move-down": "Move down",
    "page-menu.submenu.move-up": "Move up",
    "page-menu.submenu.delete": "Delete",
    "share-menu.title": "Share",
    "share-menu.save-note": "Download this project to your computer as a .tldr file.",
    "share-menu.fork-note": "Create a new shared project based on this snapshot.",
    "share-menu.share-project": "Share this project",
    "share-menu.default-project-name": "Shared Project",
    "share-menu.copy-link": "Copy share link",
    "share-menu.readonly-link": "Read-only",
    "share-menu.create-snapshot-link": "Copy snapshot link",
    "share-menu.snapshot-link-note": "Capture and share this project as a read-only snapshot link.",
    "share-menu.copy-readonly-link": "Copy read-only link",
    "share-menu.offline-note": "Create a new shared project based on your current project.",
    "share-menu.copy-link-note": "Anyone with the link will be able to view and edit this project.",
    "share-menu.copy-readonly-link-note": "Anyone with the link will be able to view (but not edit) this project.",
    "share-menu.project-too-large": "Sorry, this project can't be shared because it's too large. We're working on it!",
    "share-menu.upload-failed": "Sorry, we couldn't upload your project at the moment. Please try again or let us know if the problem persists.",
    "status.offline": "Offline",
    "status.online": "Online",
    "people-menu.title": "People",
    "people-menu.change-name": "Change name",
    "people-menu.change-color": "Change color",
    "people-menu.follow": "Following",
    "people-menu.following": "Following",
    "people-menu.leading": "Following You",
    "people-menu.user": "(You)",
    "people-menu.invite": "Invite others",
    "help-menu.title": "Help and resources",
    "help-menu.about": "About",
    "help-menu.discord": "Discord",
    "help-menu.github": "GitHub",
    "help-menu.keyboard-shortcuts": "Keyboard shortcuts",
    "help-menu.twitter": "Twitter",
    "actions-menu.title": "Actions",
    "edit-link-dialog.title": "Edit link",
    "edit-link-dialog.invalid-url": "A link must be a valid URL.",
    "edit-link-dialog.detail": "Links will open in a new tab.",
    "edit-link-dialog.url": "URL",
    "edit-link-dialog.clear": "Clear",
    "edit-link-dialog.save": "Continue",
    "edit-link-dialog.cancel": "Cancel",
    "embed-dialog.title": "Insert embed",
    "embed-dialog.back": "Back",
    "embed-dialog.create": "Create",
    "embed-dialog.cancel": "Cancel",
    "embed-dialog.url": "URL",
    "embed-dialog.instruction": "Paste in the site's URL to create the embed.",
    "embed-dialog.invalid-url": "We could not create an embed from that URL.",
    "edit-pages-dialog.move-down": "Move down",
    "edit-pages-dialog.move-up": "Move up",
    "shortcuts-dialog.title": "Keyboard shortcuts",
    "shortcuts-dialog.edit": "Edit",
    "shortcuts-dialog.file": "File",
    "shortcuts-dialog.preferences": "Preferences",
    "shortcuts-dialog.tools": "Tools",
    "shortcuts-dialog.transform": "Transform",
    "shortcuts-dialog.view": "View",
    "shortcuts-dialog.collaboration": "Collaboration",
    "home-project-dialog.title": "Home project",
    "home-project-dialog.description": "This is your local home project. It's just for you!",
    "rename-project-dialog.title": "Rename project",
    "rename-project-dialog.cancel": "Cancel",
    "rename-project-dialog.rename": "Rename",
    "home-project-dialog.ok": "Ok",
    "style-panel.title": "Styles",
    "style-panel.align": "Align",
    "style-panel.vertical-align": "Vertical align",
    "style-panel.position": "Position",
    "style-panel.arrowheads": "Arrowheads",
    "style-panel.arrowhead-start": "Start",
    "style-panel.arrowhead-end": "End",
    "style-panel.color": "Color",
    "style-panel.dash": "Dash",
    "style-panel.fill": "Fill",
    "style-panel.font": "Font",
    "style-panel.geo": "Shape",
    "style-panel.mixed": "Mixed",
    "style-panel.opacity": "Opacity",
    "style-panel.size": "Size",
    "style-panel.spline": "Spline",
    "tool-panel.drawing": "Drawing",
    "tool-panel.shapes": "Shapes",
    "tool-panel.more": "More",
    "debug-panel.more": "More",
    "navigation-zone.toggle-minimap": "Toggle minimap",
    "navigation-zone.zoom": "Zoom",
    "focus-mode.toggle-focus-mode": "Toggle focus mode",
    "toast.close": "Close",
    "file-system.file-open-error.title": "Could not open file",
    "file-system.file-open-error.not-a-tldraw-file": "The file you tried to open doesn't look like a tldraw file.",
    "file-system.file-open-error.file-format-version-too-new": "The file you tried to open is from a newer version of tldraw. Please reload the page and try again.",
    "file-system.file-open-error.generic-corrupted-file": "The file you tried to open is corrupted.",
    "file-system.confirm-open.title": "Overwrite current project?",
    "file-system.confirm-open.description": "Opening a file will replace your current project and any unsaved changes will be lost. Are you sure you want to continue?",
    "file-system.confirm-open.cancel": "Cancel",
    "file-system.confirm-open.open": "Open file",
    "file-system.confirm-open.dont-show-again": "Don't ask again",
    "file-system.confirm-clear.title": "Clear current project?",
    "file-system.confirm-clear.description": "Creating a new project will clear your current project and any unsaved changes will be lost. Are you sure you want to continue?",
    "file-system.confirm-clear.cancel": "Cancel",
    "file-system.confirm-clear.continue": "Continue",
    "file-system.confirm-clear.dont-show-again": "Don't ask again",
    "file-system.shared-document-file-open-error.title": "Could not open file",
    "file-system.shared-document-file-open-error.description": "Opening files from shared projects is not supported.",
    "sharing.confirm-leave.title": "Leave current project?",
    "sharing.confirm-leave.description": "Are you sure you want to leave this shared project? You can return to it by navigating to its URL.",
    "sharing.confirm-leave.cancel": "Cancel",
    "sharing.confirm-leave.leave": "Leave",
    "sharing.confirm-leave.dont-show-again": "Don't ask again",
    "toast.error.export-fail.title": "Failed export",
    "toast.error.export-fail.desc": "Failed to export image",
    "toast.error.copy-fail.title": "Failed copy",
    "toast.error.copy-fail.desc": "Failed to copy image",
    "context.pages.new-page": "New page",
    "vscode.file-open.desc": "We've updated this document to work with the current version of tldraw. If you'd like to keep the original version (which will work on old.tldraw.com), click below to create a backup.",
    "vscode.file-open.open": "Continue",
    "vscode.file-open.backup": "Backup",
    "vscode.file-open.backup-saved": "Backup saved",
    "vscode.file-open.backup-failed": "Backup failed: this is not a .tldr file.",
    "vscode.file-open.dont-show-again": "Don't ask again",
    "cursor-chat.type-to-chat": "Type to chat..."
  }, Sp = {
    locale: "en",
    label: "English",
    messages: kR
  };
  async function m3e(t, e) {
    if (!(await fetch(e.translations.en)).ok)
      return console.warn("No main translations found."), Sp;
    if (t === "en")
      return Sp;
    const r = Vv.find((a) => a.locale === t);
    if (!r)
      return console.warn(`No translation found for locale ${t}`), Sp;
    const s = await (await fetch(e.translations[r.locale])).json();
    if (!s)
      return console.warn(`No messages found for locale ${t}`), Sp;
    const o = [];
    for (const a in Sp.messages)
      s[a] || o.push(a);
    return o.length > 0, {
      locale: t,
      label: r.label,
      messages: {
        ...Sp.messages,
        ...s
      }
    };
  }
  const mK = b.createContext({}), y3e = () => b.useContext(mK), v3e = Vt(function({ overrides: e, children: n }) {
    const i = ue().user.locale, s = K5(), [o, a] = b.useState(() => e && e.en ? {
      locale: "en",
      label: "English",
      messages: {
        ...kR,
        ...e.en
      }
    } : {
      locale: "en",
      label: "English",
      messages: kR
    });
    return b.useEffect(() => {
      let l = false;
      async function c() {
        const u = await m3e(i, s);
        u && !l && (e && e[i] ? a({
          ...u,
          messages: {
            ...u.messages,
            ...e[i]
          }
        }) : a(u));
      }
      return c(), () => {
        l = true;
      };
    }, [
      s,
      i,
      e
    ]), m.jsx(mK.Provider, {
      value: o,
      children: n
    });
  });
  function Tt() {
    const t = y3e();
    return b.useCallback(function(n) {
      return t.messages[n] ?? n;
    }, [
      t
    ]);
  }
  function O3e(t) {
    return m.jsx("svg", {
      width: 16,
      height: 16,
      viewBox: "0 0 16 16",
      ...t,
      children: m.jsxs("g", {
        strokeWidth: 2,
        fill: "none",
        fillRule: "evenodd",
        children: [
          m.jsx("circle", {
            strokeOpacity: 0.25,
            cx: 8,
            cy: 8,
            r: 7,
            stroke: "currentColor"
          }),
          m.jsx("path", {
            strokeLinecap: "round",
            d: "M15 8c0-4.5-4.5-7-7-7",
            stroke: "currentColor",
            children: m.jsx("animateTransform", {
              attributeName: "transform",
              type: "rotate",
              from: "0 8 8",
              to: "360 8 8",
              dur: "1s",
              repeatCount: "indefinite"
            })
          })
        ]
      })
    });
  }
  const Ss = b.memo(function({ small: e, invertIcon: n, icon: r, color: i, className: s, ...o }) {
    const l = K5().icons[r], c = b.useRef(null);
    return b.useLayoutEffect(() => {
      (c == null ? void 0 : c.current) && (c.current.style.webkitMask = `url(${l}) center 100% / 100% no-repeat`);
    }, [
      c,
      l
    ]), m.jsx("div", {
      ...o,
      ref: c,
      className: Ze("tlui-icon", {
        "tlui-icon__small": e
      }, s),
      style: {
        color: i,
        mask: `url(${l}) center 100% / 100% no-repeat`,
        transform: n ? "scale(-1, 1)" : void 0
      }
    });
  }), yK = typeof window > "u" ? false : window.navigator.userAgent.toLowerCase().indexOf("mac") > -1, vK = yK ? "\u2318" : "Ctrl", OK = yK ? "\u2325" : "Alt";
  function S3e(t) {
    return t.split(",")[0].split("").map((e) => {
      const n = e.replace(/\$/g, vK).replace(/\?/g, OK).replace(/!/g, "\u21E7");
      return n[0].toUpperCase() + n.slice(1);
    });
  }
  function zl(t) {
    return "\u2014 " + t.split(",")[0].split("").map((e) => {
      const n = e.replace(/\$/g, vK).replace(/\?/g, OK).replace(/!/g, "\u21E7");
      return n[0].toUpperCase() + n.slice(1);
    }).join("\u2009");
  }
  function zC({ children: t }) {
    return m.jsx("kbd", {
      className: "tlui-kbd",
      children: S3e(t).map((e, n) => m.jsx("span", {
        children: e
      }, n))
    });
  }
  const Be = b.forwardRef(function({ label: e, icon: n, invertIcon: r, iconLeft: i, smallIcon: s, kbd: o, isChecked: a = false, type: l = "normal", children: c, spinner: u, ...d }, h) {
    const f = Tt(), y = e ? f(e) : "";
    return m.jsxs("button", {
      ref: h,
      draggable: false,
      type: "button",
      ...d,
      title: d.title ?? y,
      className: Ze("tlui-button", `tlui-button__${l}`, d.className),
      children: [
        i && m.jsx(Ss, {
          icon: i,
          className: "tlui-icon-left",
          small: true
        }),
        c,
        e && m.jsxs("span", {
          draggable: false,
          children: [
            y,
            a && m.jsx(Ss, {
              icon: "check"
            })
          ]
        }),
        o && m.jsx(zC, {
          children: o
        }),
        n && !u && m.jsx(Ss, {
          icon: n,
          small: !!e || s,
          invertIcon: r
        }),
        u && m.jsx(O3e, {})
      ]
    });
  });
  function FC({ className: t, children: e }) {
    return m.jsx("div", {
      className: Ze("tlui-dialog__header", t),
      children: e
    });
  }
  function BC({ className: t, children: e }) {
    return m.jsx(e5, {
      dir: "ltr",
      className: Ze("tlui-dialog__header__title", t),
      children: e
    });
  }
  function UC() {
    return m.jsx("div", {
      className: "tlui-dialog__header__close",
      children: m.jsx(t5, {
        "data-testid": "dialog.close",
        dir: "ltr",
        asChild: true,
        children: m.jsx(Be, {
          "aria-label": "Close",
          onTouchEnd: (t) => t.target.click(),
          children: m.jsx(Ss, {
            small: true,
            icon: "cross-2"
          })
        })
      })
    });
  }
  function qv({ className: t, children: e, style: n }) {
    return m.jsx("div", {
      className: Ze("tlui-dialog__body", t),
      style: n,
      children: e
    });
  }
  function J5({ className: t, children: e }) {
    return m.jsx("div", {
      className: Ze("tlui-dialog__footer", t),
      children: e
    });
  }
  function VC(t) {
    const e = t + "CollectionProvider", [n, r] = Ps(e), [i, s] = n(e, {
      collectionRef: {
        current: null
      },
      itemMap: /* @__PURE__ */ new Map()
    }), o = (g) => {
      const { scope: O, children: S } = g, w = $e.useRef(null), x = $e.useRef(/* @__PURE__ */ new Map()).current;
      return m.jsx(i, {
        scope: O,
        itemMap: x,
        collectionRef: w,
        children: S
      });
    };
    o.displayName = e;
    const a = t + "CollectionSlot", l = nf(a), c = $e.forwardRef((g, O) => {
      const { scope: S, children: w } = g, x = s(a, S), P = Ht(O, x.collectionRef);
      return m.jsx(l, {
        ref: P,
        children: w
      });
    });
    c.displayName = a;
    const u = t + "CollectionItemSlot", d = "data-radix-collection-item", h = nf(u), f = $e.forwardRef((g, O) => {
      const { scope: S, children: w, ...x } = g, P = $e.useRef(null), C = Ht(O, P), _ = s(u, S);
      return $e.useEffect(() => (_.itemMap.set(P, {
        ref: P,
        ...x
      }), () => void _.itemMap.delete(P))), m.jsx(h, {
        [d]: "",
        ref: C,
        children: w
      });
    });
    f.displayName = u;
    function y(g) {
      const O = s(t + "CollectionConsumer", g);
      return $e.useCallback(() => {
        const w = O.collectionRef.current;
        if (!w)
          return [];
        const x = Array.from(w.querySelectorAll(`[${d}]`));
        return Array.from(O.itemMap.values()).sort((_, T) => x.indexOf(_.ref.current) - x.indexOf(T.ref.current));
      }, [
        O.collectionRef,
        O.itemMap
      ]);
    }
    return [
      {
        Provider: o,
        Slot: c,
        ItemSlot: f
      },
      y,
      r
    ];
  }
  var w3e = b.createContext(void 0);
  function XC(t) {
    const e = b.useContext(w3e);
    return t || e || "ltr";
  }
  const x3e = [
    "top",
    "right",
    "bottom",
    "left"
  ], bd = Math.min, qs = Math.max, zk = Math.round, Cw = Math.floor, Rl = (t) => ({
    x: t,
    y: t
  }), b3e = {
    left: "right",
    right: "left",
    bottom: "top",
    top: "bottom"
  }, k3e = {
    start: "end",
    end: "start"
  };
  function PR(t, e, n) {
    return qs(t, bd(e, n));
  }
  function Hc(t, e) {
    return typeof t == "function" ? t(e) : t;
  }
  function Yc(t) {
    return t.split("-")[0];
  }
  function $m(t) {
    return t.split("-")[1];
  }
  function eL(t) {
    return t === "x" ? "y" : "x";
  }
  function tL(t) {
    return t === "y" ? "height" : "width";
  }
  const P3e = /* @__PURE__ */ new Set([
    "top",
    "bottom"
  ]);
  function _l(t) {
    return P3e.has(Yc(t)) ? "y" : "x";
  }
  function nL(t) {
    return eL(_l(t));
  }
  function C3e(t, e, n) {
    n === void 0 && (n = false);
    const r = $m(t), i = nL(t), s = tL(i);
    let o = i === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
    return e.reference[s] > e.floating[s] && (o = Fk(o)), [
      o,
      Fk(o)
    ];
  }
  function _3e(t) {
    const e = Fk(t);
    return [
      CR(t),
      e,
      CR(e)
    ];
  }
  function CR(t) {
    return t.replace(/start|end/g, (e) => k3e[e]);
  }
  const XF = [
    "left",
    "right"
  ], WF = [
    "right",
    "left"
  ], T3e = [
    "top",
    "bottom"
  ], E3e = [
    "bottom",
    "top"
  ];
  function I3e(t, e, n) {
    switch (t) {
      case "top":
      case "bottom":
        return n ? e ? WF : XF : e ? XF : WF;
      case "left":
      case "right":
        return e ? T3e : E3e;
      default:
        return [];
    }
  }
  function $3e(t, e, n, r) {
    const i = $m(t);
    let s = I3e(Yc(t), n === "start", r);
    return i && (s = s.map((o) => o + "-" + i), e && (s = s.concat(s.map(CR)))), s;
  }
  function Fk(t) {
    return t.replace(/left|right|bottom|top/g, (e) => b3e[e]);
  }
  function A3e(t) {
    return {
      top: 0,
      right: 0,
      bottom: 0,
      left: 0,
      ...t
    };
  }
  function SK(t) {
    return typeof t != "number" ? A3e(t) : {
      top: t,
      right: t,
      bottom: t,
      left: t
    };
  }
  function Bk(t) {
    const { x: e, y: n, width: r, height: i } = t;
    return {
      width: r,
      height: i,
      top: n,
      left: e,
      right: e + r,
      bottom: n + i,
      x: e,
      y: n
    };
  }
  function ZF(t, e, n) {
    let { reference: r, floating: i } = t;
    const s = _l(e), o = nL(e), a = tL(o), l = Yc(e), c = s === "y", u = r.x + r.width / 2 - i.width / 2, d = r.y + r.height / 2 - i.height / 2, h = r[a] / 2 - i[a] / 2;
    let f;
    switch (l) {
      case "top":
        f = {
          x: u,
          y: r.y - i.height
        };
        break;
      case "bottom":
        f = {
          x: u,
          y: r.y + r.height
        };
        break;
      case "right":
        f = {
          x: r.x + r.width,
          y: d
        };
        break;
      case "left":
        f = {
          x: r.x - i.width,
          y: d
        };
        break;
      default:
        f = {
          x: r.x,
          y: r.y
        };
    }
    switch ($m(e)) {
      case "start":
        f[o] -= h * (n && c ? -1 : 1);
        break;
      case "end":
        f[o] += h * (n && c ? -1 : 1);
        break;
    }
    return f;
  }
  const R3e = async (t, e, n) => {
    const { placement: r = "bottom", strategy: i = "absolute", middleware: s = [], platform: o } = n, a = s.filter(Boolean), l = await (o.isRTL == null ? void 0 : o.isRTL(e));
    let c = await o.getElementRects({
      reference: t,
      floating: e,
      strategy: i
    }), { x: u, y: d } = ZF(c, r, l), h = r, f = {}, y = 0;
    for (let g = 0; g < a.length; g++) {
      const { name: O, fn: S } = a[g], { x: w, y: x, data: P, reset: C } = await S({
        x: u,
        y: d,
        initialPlacement: r,
        placement: h,
        strategy: i,
        middlewareData: f,
        rects: c,
        platform: o,
        elements: {
          reference: t,
          floating: e
        }
      });
      u = w ?? u, d = x ?? d, f = {
        ...f,
        [O]: {
          ...f[O],
          ...P
        }
      }, C && y <= 50 && (y++, typeof C == "object" && (C.placement && (h = C.placement), C.rects && (c = C.rects === true ? await o.getElementRects({
        reference: t,
        floating: e,
        strategy: i
      }) : C.rects), { x: u, y: d } = ZF(c, h, l)), g = -1);
    }
    return {
      x: u,
      y: d,
      placement: h,
      strategy: i,
      middlewareData: f
    };
  };
  async function Kv(t, e) {
    var n;
    e === void 0 && (e = {});
    const { x: r, y: i, platform: s, rects: o, elements: a, strategy: l } = t, { boundary: c = "clippingAncestors", rootBoundary: u = "viewport", elementContext: d = "floating", altBoundary: h = false, padding: f = 0 } = Hc(e, t), y = SK(f), O = a[h ? d === "floating" ? "reference" : "floating" : d], S = Bk(await s.getClippingRect({
      element: (n = await (s.isElement == null ? void 0 : s.isElement(O))) == null || n ? O : O.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(a.floating)),
      boundary: c,
      rootBoundary: u,
      strategy: l
    })), w = d === "floating" ? {
      x: r,
      y: i,
      width: o.floating.width,
      height: o.floating.height
    } : o.reference, x = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(a.floating)), P = await (s.isElement == null ? void 0 : s.isElement(x)) ? await (s.getScale == null ? void 0 : s.getScale(x)) || {
      x: 1,
      y: 1
    } : {
      x: 1,
      y: 1
    }, C = Bk(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
      elements: a,
      rect: w,
      offsetParent: x,
      strategy: l
    }) : w);
    return {
      top: (S.top - C.top + y.top) / P.y,
      bottom: (C.bottom - S.bottom + y.bottom) / P.y,
      left: (S.left - C.left + y.left) / P.x,
      right: (C.right - S.right + y.right) / P.x
    };
  }
  const M3e = (t) => ({
    name: "arrow",
    options: t,
    async fn(e) {
      const { x: n, y: r, placement: i, rects: s, platform: o, elements: a, middlewareData: l } = e, { element: c, padding: u = 0 } = Hc(t, e) || {};
      if (c == null)
        return {};
      const d = SK(u), h = {
        x: n,
        y: r
      }, f = nL(i), y = tL(f), g = await o.getDimensions(c), O = f === "y", S = O ? "top" : "left", w = O ? "bottom" : "right", x = O ? "clientHeight" : "clientWidth", P = s.reference[y] + s.reference[f] - h[f] - s.floating[y], C = h[f] - s.reference[f], _ = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(c));
      let T = _ ? _[x] : 0;
      (!T || !await (o.isElement == null ? void 0 : o.isElement(_))) && (T = a.floating[x] || s.floating[y]);
      const $ = P / 2 - C / 2, N = T / 2 - g[y] / 2 - 1, L = bd(d[S], N), z = bd(d[w], N), M = L, R = T - g[y] - z, F = T / 2 - g[y] / 2 + $, Q = PR(M, F, R), X = !l.arrow && $m(i) != null && F !== Q && s.reference[y] / 2 - (F < M ? L : z) - g[y] / 2 < 0, Z = X ? F < M ? F - M : F - R : 0;
      return {
        [f]: h[f] + Z,
        data: {
          [f]: Q,
          centerOffset: F - Q - Z,
          ...X && {
            alignmentOffset: Z
          }
        },
        reset: X
      };
    }
  }), D3e = function(t) {
    return t === void 0 && (t = {}), {
      name: "flip",
      options: t,
      async fn(e) {
        var n, r;
        const { placement: i, middlewareData: s, rects: o, initialPlacement: a, platform: l, elements: c } = e, { mainAxis: u = true, crossAxis: d = true, fallbackPlacements: h, fallbackStrategy: f = "bestFit", fallbackAxisSideDirection: y = "none", flipAlignment: g = true, ...O } = Hc(t, e);
        if ((n = s.arrow) != null && n.alignmentOffset)
          return {};
        const S = Yc(i), w = _l(a), x = Yc(a) === a, P = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), C = h || (x || !g ? [
          Fk(a)
        ] : _3e(a)), _ = y !== "none";
        !h && _ && C.push(...$3e(a, g, y, P));
        const T = [
          a,
          ...C
        ], $ = await Kv(e, O), N = [];
        let L = ((r = s.flip) == null ? void 0 : r.overflows) || [];
        if (u && N.push($[S]), d) {
          const F = C3e(i, o, P);
          N.push($[F[0]], $[F[1]]);
        }
        if (L = [
          ...L,
          {
            placement: i,
            overflows: N
          }
        ], !N.every((F) => F <= 0)) {
          var z, M;
          const F = (((z = s.flip) == null ? void 0 : z.index) || 0) + 1, Q = T[F];
          if (Q && (!(d === "alignment" ? w !== _l(Q) : false) || L.every((U) => _l(U.placement) === w ? U.overflows[0] > 0 : true)))
            return {
              data: {
                index: F,
                overflows: L
              },
              reset: {
                placement: Q
              }
            };
          let X = (M = L.filter((Z) => Z.overflows[0] <= 0).sort((Z, U) => Z.overflows[1] - U.overflows[1])[0]) == null ? void 0 : M.placement;
          if (!X)
            switch (f) {
              case "bestFit": {
                var R;
                const Z = (R = L.filter((U) => {
                  if (_) {
                    const H = _l(U.placement);
                    return H === w || H === "y";
                  }
                  return true;
                }).map((U) => [
                  U.placement,
                  U.overflows.filter((H) => H > 0).reduce((H, te) => H + te, 0)
                ]).sort((U, H) => U[1] - H[1])[0]) == null ? void 0 : R[0];
                Z && (X = Z);
                break;
              }
              case "initialPlacement":
                X = a;
                break;
            }
          if (i !== X)
            return {
              reset: {
                placement: X
              }
            };
        }
        return {};
      }
    };
  };
  function HF(t, e) {
    return {
      top: t.top - e.height,
      right: t.right - e.width,
      bottom: t.bottom - e.height,
      left: t.left - e.width
    };
  }
  function YF(t) {
    return x3e.some((e) => t[e] >= 0);
  }
  const L3e = function(t) {
    return t === void 0 && (t = {}), {
      name: "hide",
      options: t,
      async fn(e) {
        const { rects: n } = e, { strategy: r = "referenceHidden", ...i } = Hc(t, e);
        switch (r) {
          case "referenceHidden": {
            const s = await Kv(e, {
              ...i,
              elementContext: "reference"
            }), o = HF(s, n.reference);
            return {
              data: {
                referenceHiddenOffsets: o,
                referenceHidden: YF(o)
              }
            };
          }
          case "escaped": {
            const s = await Kv(e, {
              ...i,
              altBoundary: true
            }), o = HF(s, n.floating);
            return {
              data: {
                escapedOffsets: o,
                escaped: YF(o)
              }
            };
          }
          default:
            return {};
        }
      }
    };
  }, wK = /* @__PURE__ */ new Set([
    "left",
    "top"
  ]);
  async function j3e(t, e) {
    const { placement: n, platform: r, elements: i } = t, s = await (r.isRTL == null ? void 0 : r.isRTL(i.floating)), o = Yc(n), a = $m(n), l = _l(n) === "y", c = wK.has(o) ? -1 : 1, u = s && l ? -1 : 1, d = Hc(e, t);
    let { mainAxis: h, crossAxis: f, alignmentAxis: y } = typeof d == "number" ? {
      mainAxis: d,
      crossAxis: 0,
      alignmentAxis: null
    } : {
      mainAxis: d.mainAxis || 0,
      crossAxis: d.crossAxis || 0,
      alignmentAxis: d.alignmentAxis
    };
    return a && typeof y == "number" && (f = a === "end" ? y * -1 : y), l ? {
      x: f * u,
      y: h * c
    } : {
      x: h * c,
      y: f * u
    };
  }
  const N3e = function(t) {
    return t === void 0 && (t = 0), {
      name: "offset",
      options: t,
      async fn(e) {
        var n, r;
        const { x: i, y: s, placement: o, middlewareData: a } = e, l = await j3e(e, t);
        return o === ((n = a.offset) == null ? void 0 : n.placement) && (r = a.arrow) != null && r.alignmentOffset ? {} : {
          x: i + l.x,
          y: s + l.y,
          data: {
            ...l,
            placement: o
          }
        };
      }
    };
  }, Q3e = function(t) {
    return t === void 0 && (t = {}), {
      name: "shift",
      options: t,
      async fn(e) {
        const { x: n, y: r, placement: i } = e, { mainAxis: s = true, crossAxis: o = false, limiter: a = {
          fn: (O) => {
            let { x: S, y: w } = O;
            return {
              x: S,
              y: w
            };
          }
        }, ...l } = Hc(t, e), c = {
          x: n,
          y: r
        }, u = await Kv(e, l), d = _l(Yc(i)), h = eL(d);
        let f = c[h], y = c[d];
        if (s) {
          const O = h === "y" ? "top" : "left", S = h === "y" ? "bottom" : "right", w = f + u[O], x = f - u[S];
          f = PR(w, f, x);
        }
        if (o) {
          const O = d === "y" ? "top" : "left", S = d === "y" ? "bottom" : "right", w = y + u[O], x = y - u[S];
          y = PR(w, y, x);
        }
        const g = a.fn({
          ...e,
          [h]: f,
          [d]: y
        });
        return {
          ...g,
          data: {
            x: g.x - n,
            y: g.y - r,
            enabled: {
              [h]: s,
              [d]: o
            }
          }
        };
      }
    };
  }, z3e = function(t) {
    return t === void 0 && (t = {}), {
      options: t,
      fn(e) {
        const { x: n, y: r, placement: i, rects: s, middlewareData: o } = e, { offset: a = 0, mainAxis: l = true, crossAxis: c = true } = Hc(t, e), u = {
          x: n,
          y: r
        }, d = _l(i), h = eL(d);
        let f = u[h], y = u[d];
        const g = Hc(a, e), O = typeof g == "number" ? {
          mainAxis: g,
          crossAxis: 0
        } : {
          mainAxis: 0,
          crossAxis: 0,
          ...g
        };
        if (l) {
          const x = h === "y" ? "height" : "width", P = s.reference[h] - s.floating[x] + O.mainAxis, C = s.reference[h] + s.reference[x] - O.mainAxis;
          f < P ? f = P : f > C && (f = C);
        }
        if (c) {
          var S, w;
          const x = h === "y" ? "width" : "height", P = wK.has(Yc(i)), C = s.reference[d] - s.floating[x] + (P && ((S = o.offset) == null ? void 0 : S[d]) || 0) + (P ? 0 : O.crossAxis), _ = s.reference[d] + s.reference[x] + (P ? 0 : ((w = o.offset) == null ? void 0 : w[d]) || 0) - (P ? O.crossAxis : 0);
          y < C ? y = C : y > _ && (y = _);
        }
        return {
          [h]: f,
          [d]: y
        };
      }
    };
  }, F3e = function(t) {
    return t === void 0 && (t = {}), {
      name: "size",
      options: t,
      async fn(e) {
        var n, r;
        const { placement: i, rects: s, platform: o, elements: a } = e, { apply: l = () => {
        }, ...c } = Hc(t, e), u = await Kv(e, c), d = Yc(i), h = $m(i), f = _l(i) === "y", { width: y, height: g } = s.floating;
        let O, S;
        d === "top" || d === "bottom" ? (O = d, S = h === (await (o.isRTL == null ? void 0 : o.isRTL(a.floating)) ? "start" : "end") ? "left" : "right") : (S = d, O = h === "end" ? "top" : "bottom");
        const w = g - u.top - u.bottom, x = y - u.left - u.right, P = bd(g - u[O], w), C = bd(y - u[S], x), _ = !e.middlewareData.shift;
        let T = P, $ = C;
        if ((n = e.middlewareData.shift) != null && n.enabled.x && ($ = x), (r = e.middlewareData.shift) != null && r.enabled.y && (T = w), _ && !h) {
          const L = qs(u.left, 0), z = qs(u.right, 0), M = qs(u.top, 0), R = qs(u.bottom, 0);
          f ? $ = y - 2 * (L !== 0 || z !== 0 ? L + z : qs(u.left, u.right)) : T = g - 2 * (M !== 0 || R !== 0 ? M + R : qs(u.top, u.bottom));
        }
        await l({
          ...e,
          availableWidth: $,
          availableHeight: T
        });
        const N = await o.getDimensions(a.floating);
        return y !== N.width || g !== N.height ? {
          reset: {
            rects: true
          }
        } : {};
      }
    };
  };
  function WC() {
    return typeof window < "u";
  }
  function Am(t) {
    return xK(t) ? (t.nodeName || "").toLowerCase() : "#document";
  }
  function oo(t) {
    var e;
    return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
  }
  function Zl(t) {
    var e;
    return (e = (xK(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
  }
  function xK(t) {
    return WC() ? t instanceof Node || t instanceof oo(t).Node : false;
  }
  function Xa(t) {
    return WC() ? t instanceof Element || t instanceof oo(t).Element : false;
  }
  function Fl(t) {
    return WC() ? t instanceof HTMLElement || t instanceof oo(t).HTMLElement : false;
  }
  function GF(t) {
    return !WC() || typeof ShadowRoot > "u" ? false : t instanceof ShadowRoot || t instanceof oo(t).ShadowRoot;
  }
  const B3e = /* @__PURE__ */ new Set([
    "inline",
    "contents"
  ]);
  function lS(t) {
    const { overflow: e, overflowX: n, overflowY: r, display: i } = Wa(t);
    return /auto|scroll|overlay|hidden|clip/.test(e + r + n) && !B3e.has(i);
  }
  const U3e = /* @__PURE__ */ new Set([
    "table",
    "td",
    "th"
  ]);
  function V3e(t) {
    return U3e.has(Am(t));
  }
  const X3e = [
    ":popover-open",
    ":modal"
  ];
  function ZC(t) {
    return X3e.some((e) => {
      try {
        return t.matches(e);
      } catch {
        return false;
      }
    });
  }
  const W3e = [
    "transform",
    "translate",
    "scale",
    "rotate",
    "perspective"
  ], Z3e = [
    "transform",
    "translate",
    "scale",
    "rotate",
    "perspective",
    "filter"
  ], H3e = [
    "paint",
    "layout",
    "strict",
    "content"
  ];
  function rL(t) {
    const e = iL(), n = Xa(t) ? Wa(t) : t;
    return W3e.some((r) => n[r] ? n[r] !== "none" : false) || (n.containerType ? n.containerType !== "normal" : false) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : false) || !e && (n.filter ? n.filter !== "none" : false) || Z3e.some((r) => (n.willChange || "").includes(r)) || H3e.some((r) => (n.contain || "").includes(r));
  }
  function Y3e(t) {
    let e = kd(t);
    for (; Fl(e) && !Bg(e); ) {
      if (rL(e))
        return e;
      if (ZC(e))
        return null;
      e = kd(e);
    }
    return null;
  }
  function iL() {
    return typeof CSS > "u" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter", "none");
  }
  const G3e = /* @__PURE__ */ new Set([
    "html",
    "body",
    "#document"
  ]);
  function Bg(t) {
    return G3e.has(Am(t));
  }
  function Wa(t) {
    return oo(t).getComputedStyle(t);
  }
  function HC(t) {
    return Xa(t) ? {
      scrollLeft: t.scrollLeft,
      scrollTop: t.scrollTop
    } : {
      scrollLeft: t.scrollX,
      scrollTop: t.scrollY
    };
  }
  function kd(t) {
    if (Am(t) === "html")
      return t;
    const e = t.assignedSlot || t.parentNode || GF(t) && t.host || Zl(t);
    return GF(e) ? e.host : e;
  }
  function bK(t) {
    const e = kd(t);
    return Bg(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : Fl(e) && lS(e) ? e : bK(e);
  }
  function Jv(t, e, n) {
    var r;
    e === void 0 && (e = []), n === void 0 && (n = true);
    const i = bK(t), s = i === ((r = t.ownerDocument) == null ? void 0 : r.body), o = oo(i);
    if (s) {
      const a = _R(o);
      return e.concat(o, o.visualViewport || [], lS(i) ? i : [], a && n ? Jv(a) : []);
    }
    return e.concat(i, Jv(i, [], n));
  }
  function _R(t) {
    return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
  }
  function kK(t) {
    const e = Wa(t);
    let n = parseFloat(e.width) || 0, r = parseFloat(e.height) || 0;
    const i = Fl(t), s = i ? t.offsetWidth : n, o = i ? t.offsetHeight : r, a = zk(n) !== s || zk(r) !== o;
    return a && (n = s, r = o), {
      width: n,
      height: r,
      $: a
    };
  }
  function sL(t) {
    return Xa(t) ? t : t.contextElement;
  }
  function mg(t) {
    const e = sL(t);
    if (!Fl(e))
      return Rl(1);
    const n = e.getBoundingClientRect(), { width: r, height: i, $: s } = kK(e);
    let o = (s ? zk(n.width) : n.width) / r, a = (s ? zk(n.height) : n.height) / i;
    return (!o || !Number.isFinite(o)) && (o = 1), (!a || !Number.isFinite(a)) && (a = 1), {
      x: o,
      y: a
    };
  }
  const q3e = Rl(0);
  function PK(t) {
    const e = oo(t);
    return !iL() || !e.visualViewport ? q3e : {
      x: e.visualViewport.offsetLeft,
      y: e.visualViewport.offsetTop
    };
  }
  function K3e(t, e, n) {
    return e === void 0 && (e = false), !n || e && n !== oo(t) ? false : e;
  }
  function af(t, e, n, r) {
    e === void 0 && (e = false), n === void 0 && (n = false);
    const i = t.getBoundingClientRect(), s = sL(t);
    let o = Rl(1);
    e && (r ? Xa(r) && (o = mg(r)) : o = mg(t));
    const a = K3e(s, n, r) ? PK(s) : Rl(0);
    let l = (i.left + a.x) / o.x, c = (i.top + a.y) / o.y, u = i.width / o.x, d = i.height / o.y;
    if (s) {
      const h = oo(s), f = r && Xa(r) ? oo(r) : r;
      let y = h, g = _R(y);
      for (; g && r && f !== y; ) {
        const O = mg(g), S = g.getBoundingClientRect(), w = Wa(g), x = S.left + (g.clientLeft + parseFloat(w.paddingLeft)) * O.x, P = S.top + (g.clientTop + parseFloat(w.paddingTop)) * O.y;
        l *= O.x, c *= O.y, u *= O.x, d *= O.y, l += x, c += P, y = oo(g), g = _R(y);
      }
    }
    return Bk({
      width: u,
      height: d,
      x: l,
      y: c
    });
  }
  function YC(t, e) {
    const n = HC(t).scrollLeft;
    return e ? e.left + n : af(Zl(t)).left + n;
  }
  function CK(t, e) {
    const n = t.getBoundingClientRect(), r = n.left + e.scrollLeft - YC(t, n), i = n.top + e.scrollTop;
    return {
      x: r,
      y: i
    };
  }
  function J3e(t) {
    let { elements: e, rect: n, offsetParent: r, strategy: i } = t;
    const s = i === "fixed", o = Zl(r), a = e ? ZC(e.floating) : false;
    if (r === o || a && s)
      return n;
    let l = {
      scrollLeft: 0,
      scrollTop: 0
    }, c = Rl(1);
    const u = Rl(0), d = Fl(r);
    if ((d || !d && !s) && ((Am(r) !== "body" || lS(o)) && (l = HC(r)), Fl(r))) {
      const f = af(r);
      c = mg(r), u.x = f.x + r.clientLeft, u.y = f.y + r.clientTop;
    }
    const h = o && !d && !s ? CK(o, l) : Rl(0);
    return {
      width: n.width * c.x,
      height: n.height * c.y,
      x: n.x * c.x - l.scrollLeft * c.x + u.x + h.x,
      y: n.y * c.y - l.scrollTop * c.y + u.y + h.y
    };
  }
  function e5e(t) {
    return Array.from(t.getClientRects());
  }
  function t5e(t) {
    const e = Zl(t), n = HC(t), r = t.ownerDocument.body, i = qs(e.scrollWidth, e.clientWidth, r.scrollWidth, r.clientWidth), s = qs(e.scrollHeight, e.clientHeight, r.scrollHeight, r.clientHeight);
    let o = -n.scrollLeft + YC(t);
    const a = -n.scrollTop;
    return Wa(r).direction === "rtl" && (o += qs(e.clientWidth, r.clientWidth) - i), {
      width: i,
      height: s,
      x: o,
      y: a
    };
  }
  const qF = 25;
  function n5e(t, e) {
    const n = oo(t), r = Zl(t), i = n.visualViewport;
    let s = r.clientWidth, o = r.clientHeight, a = 0, l = 0;
    if (i) {
      s = i.width, o = i.height;
      const u = iL();
      (!u || u && e === "fixed") && (a = i.offsetLeft, l = i.offsetTop);
    }
    const c = YC(r);
    if (c <= 0) {
      const u = r.ownerDocument, d = u.body, h = getComputedStyle(d), f = u.compatMode === "CSS1Compat" && parseFloat(h.marginLeft) + parseFloat(h.marginRight) || 0, y = Math.abs(r.clientWidth - d.clientWidth - f);
      y <= qF && (s -= y);
    } else
      c <= qF && (s += c);
    return {
      width: s,
      height: o,
      x: a,
      y: l
    };
  }
  const r5e = /* @__PURE__ */ new Set([
    "absolute",
    "fixed"
  ]);
  function i5e(t, e) {
    const n = af(t, true, e === "fixed"), r = n.top + t.clientTop, i = n.left + t.clientLeft, s = Fl(t) ? mg(t) : Rl(1), o = t.clientWidth * s.x, a = t.clientHeight * s.y, l = i * s.x, c = r * s.y;
    return {
      width: o,
      height: a,
      x: l,
      y: c
    };
  }
  function KF(t, e, n) {
    let r;
    if (e === "viewport")
      r = n5e(t, n);
    else if (e === "document")
      r = t5e(Zl(t));
    else if (Xa(e))
      r = i5e(e, n);
    else {
      const i = PK(t);
      r = {
        x: e.x - i.x,
        y: e.y - i.y,
        width: e.width,
        height: e.height
      };
    }
    return Bk(r);
  }
  function _K(t, e) {
    const n = kd(t);
    return n === e || !Xa(n) || Bg(n) ? false : Wa(n).position === "fixed" || _K(n, e);
  }
  function s5e(t, e) {
    const n = e.get(t);
    if (n)
      return n;
    let r = Jv(t, [], false).filter((a) => Xa(a) && Am(a) !== "body"), i = null;
    const s = Wa(t).position === "fixed";
    let o = s ? kd(t) : t;
    for (; Xa(o) && !Bg(o); ) {
      const a = Wa(o), l = rL(o);
      !l && a.position === "fixed" && (i = null), (s ? !l && !i : !l && a.position === "static" && !!i && r5e.has(i.position) || lS(o) && !l && _K(t, o)) ? r = r.filter((u) => u !== o) : i = a, o = kd(o);
    }
    return e.set(t, r), r;
  }
  function o5e(t) {
    let { element: e, boundary: n, rootBoundary: r, strategy: i } = t;
    const o = [
      ...n === "clippingAncestors" ? ZC(e) ? [] : s5e(e, this._c) : [].concat(n),
      r
    ], a = o[0], l = o.reduce((c, u) => {
      const d = KF(e, u, i);
      return c.top = qs(d.top, c.top), c.right = bd(d.right, c.right), c.bottom = bd(d.bottom, c.bottom), c.left = qs(d.left, c.left), c;
    }, KF(e, a, i));
    return {
      width: l.right - l.left,
      height: l.bottom - l.top,
      x: l.left,
      y: l.top
    };
  }
  function a5e(t) {
    const { width: e, height: n } = kK(t);
    return {
      width: e,
      height: n
    };
  }
  function l5e(t, e, n) {
    const r = Fl(e), i = Zl(e), s = n === "fixed", o = af(t, true, s, e);
    let a = {
      scrollLeft: 0,
      scrollTop: 0
    };
    const l = Rl(0);
    function c() {
      l.x = YC(i);
    }
    if (r || !r && !s)
      if ((Am(e) !== "body" || lS(i)) && (a = HC(e)), r) {
        const f = af(e, true, s, e);
        l.x = f.x + e.clientLeft, l.y = f.y + e.clientTop;
      } else
        i && c();
    s && !r && i && c();
    const u = i && !r && !s ? CK(i, a) : Rl(0), d = o.left + a.scrollLeft - l.x - u.x, h = o.top + a.scrollTop - l.y - u.y;
    return {
      x: d,
      y: h,
      width: o.width,
      height: o.height
    };
  }
  function iI(t) {
    return Wa(t).position === "static";
  }
  function JF(t, e) {
    if (!Fl(t) || Wa(t).position === "fixed")
      return null;
    if (e)
      return e(t);
    let n = t.offsetParent;
    return Zl(t) === n && (n = n.ownerDocument.body), n;
  }
  function TK(t, e) {
    const n = oo(t);
    if (ZC(t))
      return n;
    if (!Fl(t)) {
      let i = kd(t);
      for (; i && !Bg(i); ) {
        if (Xa(i) && !iI(i))
          return i;
        i = kd(i);
      }
      return n;
    }
    let r = JF(t, e);
    for (; r && V3e(r) && iI(r); )
      r = JF(r, e);
    return r && Bg(r) && iI(r) && !rL(r) ? n : r || Y3e(t) || n;
  }
  const c5e = async function(t) {
    const e = this.getOffsetParent || TK, n = this.getDimensions, r = await n(t.floating);
    return {
      reference: l5e(t.reference, await e(t.floating), t.strategy),
      floating: {
        x: 0,
        y: 0,
        width: r.width,
        height: r.height
      }
    };
  };
  function u5e(t) {
    return Wa(t).direction === "rtl";
  }
  const d5e = {
    convertOffsetParentRelativeRectToViewportRelativeRect: J3e,
    getDocumentElement: Zl,
    getClippingRect: o5e,
    getOffsetParent: TK,
    getElementRects: c5e,
    getClientRects: e5e,
    getDimensions: a5e,
    getScale: mg,
    isElement: Xa,
    isRTL: u5e
  };
  function EK(t, e) {
    return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
  }
  function h5e(t, e) {
    let n = null, r;
    const i = Zl(t);
    function s() {
      var a;
      clearTimeout(r), (a = n) == null || a.disconnect(), n = null;
    }
    function o(a, l) {
      a === void 0 && (a = false), l === void 0 && (l = 1), s();
      const c = t.getBoundingClientRect(), { left: u, top: d, width: h, height: f } = c;
      if (a || e(), !h || !f)
        return;
      const y = Cw(d), g = Cw(i.clientWidth - (u + h)), O = Cw(i.clientHeight - (d + f)), S = Cw(u), x = {
        rootMargin: -y + "px " + -g + "px " + -O + "px " + -S + "px",
        threshold: qs(0, bd(1, l)) || 1
      };
      let P = true;
      function C(_) {
        const T = _[0].intersectionRatio;
        if (T !== l) {
          if (!P)
            return o();
          T ? o(false, T) : r = setTimeout(() => {
            o(false, 1e-7);
          }, 1e3);
        }
        T === 1 && !EK(c, t.getBoundingClientRect()) && o(), P = false;
      }
      try {
        n = new IntersectionObserver(C, {
          ...x,
          root: i.ownerDocument
        });
      } catch {
        n = new IntersectionObserver(C, x);
      }
      n.observe(t);
    }
    return o(true), s;
  }
  function f5e(t, e, n, r) {
    r === void 0 && (r = {});
    const { ancestorScroll: i = true, ancestorResize: s = true, elementResize: o = typeof ResizeObserver == "function", layoutShift: a = typeof IntersectionObserver == "function", animationFrame: l = false } = r, c = sL(t), u = i || s ? [
      ...c ? Jv(c) : [],
      ...Jv(e)
    ] : [];
    u.forEach((S) => {
      i && S.addEventListener("scroll", n, {
        passive: true
      }), s && S.addEventListener("resize", n);
    });
    const d = c && a ? h5e(c, n) : null;
    let h = -1, f = null;
    o && (f = new ResizeObserver((S) => {
      let [w] = S;
      w && w.target === c && f && (f.unobserve(e), cancelAnimationFrame(h), h = requestAnimationFrame(() => {
        var x;
        (x = f) == null || x.observe(e);
      })), n();
    }), c && !l && f.observe(c), f.observe(e));
    let y, g = l ? af(t) : null;
    l && O();
    function O() {
      const S = af(t);
      g && !EK(g, S) && n(), g = S, y = requestAnimationFrame(O);
    }
    return n(), () => {
      var S;
      u.forEach((w) => {
        i && w.removeEventListener("scroll", n), s && w.removeEventListener("resize", n);
      }), d == null ? void 0 : d(), (S = f) == null || S.disconnect(), f = null, l && cancelAnimationFrame(y);
    };
  }
  const p5e = N3e, g5e = Q3e, m5e = D3e, y5e = F3e, v5e = L3e, e7 = M3e, O5e = z3e, S5e = (t, e, n) => {
    const r = /* @__PURE__ */ new Map(), i = {
      platform: d5e,
      ...n
    }, s = {
      ...i.platform,
      _c: r
    };
    return R3e(t, e, {
      ...i,
      platform: s
    });
  };
  var w5e = typeof document < "u", x5e = function() {
  }, eb = w5e ? b.useLayoutEffect : x5e;
  function Uk(t, e) {
    if (t === e)
      return true;
    if (typeof t != typeof e)
      return false;
    if (typeof t == "function" && t.toString() === e.toString())
      return true;
    let n, r, i;
    if (t && e && typeof t == "object") {
      if (Array.isArray(t)) {
        if (n = t.length, n !== e.length)
          return false;
        for (r = n; r-- !== 0; )
          if (!Uk(t[r], e[r]))
            return false;
        return true;
      }
      if (i = Object.keys(t), n = i.length, n !== Object.keys(e).length)
        return false;
      for (r = n; r-- !== 0; )
        if (!{}.hasOwnProperty.call(e, i[r]))
          return false;
      for (r = n; r-- !== 0; ) {
        const s = i[r];
        if (!(s === "_owner" && t.$$typeof) && !Uk(t[s], e[s]))
          return false;
      }
      return true;
    }
    return t !== t && e !== e;
  }
  function IK(t) {
    return typeof window > "u" ? 1 : (t.ownerDocument.defaultView || window).devicePixelRatio || 1;
  }
  function t7(t, e) {
    const n = IK(t);
    return Math.round(e * n) / n;
  }
  function sI(t) {
    const e = b.useRef(t);
    return eb(() => {
      e.current = t;
    }), e;
  }
  function b5e(t) {
    t === void 0 && (t = {});
    const { placement: e = "bottom", strategy: n = "absolute", middleware: r = [], platform: i, elements: { reference: s, floating: o } = {}, transform: a = true, whileElementsMounted: l, open: c } = t, [u, d] = b.useState({
      x: 0,
      y: 0,
      strategy: n,
      placement: e,
      middlewareData: {},
      isPositioned: false
    }), [h, f] = b.useState(r);
    Uk(h, r) || f(r);
    const [y, g] = b.useState(null), [O, S] = b.useState(null), w = b.useCallback((U) => {
      U !== _.current && (_.current = U, g(U));
    }, []), x = b.useCallback((U) => {
      U !== T.current && (T.current = U, S(U));
    }, []), P = s || y, C = o || O, _ = b.useRef(null), T = b.useRef(null), $ = b.useRef(u), N = l != null, L = sI(l), z = sI(i), M = sI(c), R = b.useCallback(() => {
      if (!_.current || !T.current)
        return;
      const U = {
        placement: e,
        strategy: n,
        middleware: h
      };
      z.current && (U.platform = z.current), S5e(_.current, T.current, U).then((H) => {
        const te = {
          ...H,
          isPositioned: M.current !== false
        };
        F.current && !Uk($.current, te) && ($.current = te, jd.flushSync(() => {
          d(te);
        }));
      });
    }, [
      h,
      e,
      n,
      z,
      M
    ]);
    eb(() => {
      c === false && $.current.isPositioned && ($.current.isPositioned = false, d((U) => ({
        ...U,
        isPositioned: false
      })));
    }, [
      c
    ]);
    const F = b.useRef(false);
    eb(() => (F.current = true, () => {
      F.current = false;
    }), []), eb(() => {
      if (P && (_.current = P), C && (T.current = C), P && C) {
        if (L.current)
          return L.current(P, C, R);
        R();
      }
    }, [
      P,
      C,
      R,
      L,
      N
    ]);
    const Q = b.useMemo(() => ({
      reference: _,
      floating: T,
      setReference: w,
      setFloating: x
    }), [
      w,
      x
    ]), X = b.useMemo(() => ({
      reference: P,
      floating: C
    }), [
      P,
      C
    ]), Z = b.useMemo(() => {
      const U = {
        position: n,
        left: 0,
        top: 0
      };
      if (!X.floating)
        return U;
      const H = t7(X.floating, u.x), te = t7(X.floating, u.y);
      return a ? {
        ...U,
        transform: "translate(" + H + "px, " + te + "px)",
        ...IK(X.floating) >= 1.5 && {
          willChange: "transform"
        }
      } : {
        position: n,
        left: H,
        top: te
      };
    }, [
      n,
      a,
      X.floating,
      u.x,
      u.y
    ]);
    return b.useMemo(() => ({
      ...u,
      update: R,
      refs: Q,
      elements: X,
      floatingStyles: Z
    }), [
      u,
      R,
      Q,
      X,
      Z
    ]);
  }
  const k5e = (t) => {
    function e(n) {
      return {}.hasOwnProperty.call(n, "current");
    }
    return {
      name: "arrow",
      options: t,
      fn(n) {
        const { element: r, padding: i } = typeof t == "function" ? t(n) : t;
        return r && e(r) ? r.current != null ? e7({
          element: r.current,
          padding: i
        }).fn(n) : {} : r ? e7({
          element: r,
          padding: i
        }).fn(n) : {};
      }
    };
  }, P5e = (t, e) => ({
    ...p5e(t),
    options: [
      t,
      e
    ]
  }), C5e = (t, e) => ({
    ...g5e(t),
    options: [
      t,
      e
    ]
  }), _5e = (t, e) => ({
    ...O5e(t),
    options: [
      t,
      e
    ]
  }), T5e = (t, e) => ({
    ...m5e(t),
    options: [
      t,
      e
    ]
  }), E5e = (t, e) => ({
    ...y5e(t),
    options: [
      t,
      e
    ]
  }), I5e = (t, e) => ({
    ...v5e(t),
    options: [
      t,
      e
    ]
  }), $5e = (t, e) => ({
    ...k5e(t),
    options: [
      t,
      e
    ]
  });
  var A5e = "Arrow", $K = b.forwardRef((t, e) => {
    const { children: n, width: r = 10, height: i = 5, ...s } = t;
    return m.jsx(rt.svg, {
      ...s,
      ref: e,
      width: r,
      height: i,
      viewBox: "0 0 30 10",
      preserveAspectRatio: "none",
      children: t.asChild ? n : m.jsx("polygon", {
        points: "0,0 30,0 15,10"
      })
    });
  });
  $K.displayName = A5e;
  var R5e = $K;
  function AK(t) {
    const [e, n] = b.useState(void 0);
    return ta(() => {
      if (t) {
        n({
          width: t.offsetWidth,
          height: t.offsetHeight
        });
        const r = new ResizeObserver((i) => {
          if (!Array.isArray(i) || !i.length)
            return;
          const s = i[0];
          let o, a;
          if ("borderBoxSize" in s) {
            const l = s.borderBoxSize, c = Array.isArray(l) ? l[0] : l;
            o = c.inlineSize, a = c.blockSize;
          } else
            o = t.offsetWidth, a = t.offsetHeight;
          n({
            width: o,
            height: a
          });
        });
        return r.observe(t, {
          box: "border-box"
        }), () => r.unobserve(t);
      } else
        n(void 0);
    }, [
      t
    ]), e;
  }
  var oL = "Popper", [RK, Rm] = Ps(oL), [M5e, MK] = RK(oL), DK = (t) => {
    const { __scopePopper: e, children: n } = t, [r, i] = b.useState(null);
    return m.jsx(M5e, {
      scope: e,
      anchor: r,
      onAnchorChange: i,
      children: n
    });
  };
  DK.displayName = oL;
  var LK = "PopperAnchor", jK = b.forwardRef((t, e) => {
    const { __scopePopper: n, virtualRef: r, ...i } = t, s = MK(LK, n), o = b.useRef(null), a = Ht(e, o), l = b.useRef(null);
    return b.useEffect(() => {
      const c = l.current;
      l.current = (r == null ? void 0 : r.current) || o.current, c !== l.current && s.onAnchorChange(l.current);
    }), r ? null : m.jsx(rt.div, {
      ...i,
      ref: a
    });
  });
  jK.displayName = LK;
  var aL = "PopperContent", [D5e, L5e] = RK(aL), NK = b.forwardRef((t, e) => {
    var _a3, _b3, _c3, _d3, _e4, _f3;
    const { __scopePopper: n, side: r = "bottom", sideOffset: i = 0, align: s = "center", alignOffset: o = 0, arrowPadding: a = 0, avoidCollisions: l = true, collisionBoundary: c = [], collisionPadding: u = 0, sticky: d = "partial", hideWhenDetached: h = false, updatePositionStrategy: f = "optimized", onPlaced: y, ...g } = t, O = MK(aL, n), [S, w] = b.useState(null), x = Ht(e, (it) => w(it)), [P, C] = b.useState(null), _ = AK(P), T = (_ == null ? void 0 : _.width) ?? 0, $ = (_ == null ? void 0 : _.height) ?? 0, N = r + (s !== "center" ? "-" + s : ""), L = typeof u == "number" ? u : {
      top: 0,
      right: 0,
      bottom: 0,
      left: 0,
      ...u
    }, z = Array.isArray(c) ? c : [
      c
    ], M = z.length > 0, R = {
      padding: L,
      boundary: z.filter(N5e),
      altBoundary: M
    }, { refs: F, floatingStyles: Q, placement: X, isPositioned: Z, middlewareData: U } = b5e({
      strategy: "fixed",
      placement: N,
      whileElementsMounted: (...it) => f5e(...it, {
        animationFrame: f === "always"
      }),
      elements: {
        reference: O.anchor
      },
      middleware: [
        P5e({
          mainAxis: i + $,
          alignmentAxis: o
        }),
        l && C5e({
          mainAxis: true,
          crossAxis: false,
          limiter: d === "partial" ? _5e() : void 0,
          ...R
        }),
        l && T5e({
          ...R
        }),
        E5e({
          ...R,
          apply: ({ elements: it, rects: pt, availableWidth: kt, availableHeight: Yt }) => {
            const { width: Ar, height: Cn } = pt.reference, Vn = it.floating.style;
            Vn.setProperty("--radix-popper-available-width", `${kt}px`), Vn.setProperty("--radix-popper-available-height", `${Yt}px`), Vn.setProperty("--radix-popper-anchor-width", `${Ar}px`), Vn.setProperty("--radix-popper-anchor-height", `${Cn}px`);
          }
        }),
        P && $5e({
          element: P,
          padding: a
        }),
        Q5e({
          arrowWidth: T,
          arrowHeight: $
        }),
        h && I5e({
          strategy: "referenceHidden",
          ...R
        })
      ]
    }), [H, te] = FK(X), se = ki(y);
    ta(() => {
      Z && (se == null ? void 0 : se());
    }, [
      Z,
      se
    ]);
    const ae = (_a3 = U.arrow) == null ? void 0 : _a3.x, _e3 = (_b3 = U.arrow) == null ? void 0 : _b3.y, Me = ((_c3 = U.arrow) == null ? void 0 : _c3.centerOffset) !== 0, [ke, tt] = b.useState();
    return ta(() => {
      S && tt(window.getComputedStyle(S).zIndex);
    }, [
      S
    ]), m.jsx("div", {
      ref: F.setFloating,
      "data-radix-popper-content-wrapper": "",
      style: {
        ...Q,
        transform: Z ? Q.transform : "translate(0, -200%)",
        minWidth: "max-content",
        zIndex: ke,
        "--radix-popper-transform-origin": [
          (_d3 = U.transformOrigin) == null ? void 0 : _d3.x,
          (_e4 = U.transformOrigin) == null ? void 0 : _e4.y
        ].join(" "),
        ...((_f3 = U.hide) == null ? void 0 : _f3.referenceHidden) && {
          visibility: "hidden",
          pointerEvents: "none"
        }
      },
      dir: t.dir,
      children: m.jsx(D5e, {
        scope: n,
        placedSide: H,
        onArrowChange: C,
        arrowX: ae,
        arrowY: _e3,
        shouldHideArrow: Me,
        children: m.jsx(rt.div, {
          "data-side": H,
          "data-align": te,
          ...g,
          ref: x,
          style: {
            ...g.style,
            animation: Z ? void 0 : "none"
          }
        })
      })
    });
  });
  NK.displayName = aL;
  var QK = "PopperArrow", j5e = {
    top: "bottom",
    right: "left",
    bottom: "top",
    left: "right"
  }, zK = b.forwardRef(function(e, n) {
    const { __scopePopper: r, ...i } = e, s = L5e(QK, r), o = j5e[s.placedSide];
    return m.jsx("span", {
      ref: s.onArrowChange,
      style: {
        position: "absolute",
        left: s.arrowX,
        top: s.arrowY,
        [o]: 0,
        transformOrigin: {
          top: "",
          right: "0 0",
          bottom: "center 0",
          left: "100% 0"
        }[s.placedSide],
        transform: {
          top: "translateY(100%)",
          right: "translateY(50%) rotate(90deg) translateX(-50%)",
          bottom: "rotate(180deg)",
          left: "translateY(50%) rotate(-90deg) translateX(50%)"
        }[s.placedSide],
        visibility: s.shouldHideArrow ? "hidden" : void 0
      },
      children: m.jsx(R5e, {
        ...i,
        ref: n,
        style: {
          ...i.style,
          display: "block"
        }
      })
    });
  });
  zK.displayName = QK;
  function N5e(t) {
    return t !== null;
  }
  var Q5e = (t) => ({
    name: "transformOrigin",
    options: t,
    fn(e) {
      var _a3, _b3, _c3;
      const { placement: n, rects: r, middlewareData: i } = e, o = ((_a3 = i.arrow) == null ? void 0 : _a3.centerOffset) !== 0, a = o ? 0 : t.arrowWidth, l = o ? 0 : t.arrowHeight, [c, u] = FK(n), d = {
        start: "0%",
        center: "50%",
        end: "100%"
      }[u], h = (((_b3 = i.arrow) == null ? void 0 : _b3.x) ?? 0) + a / 2, f = (((_c3 = i.arrow) == null ? void 0 : _c3.y) ?? 0) + l / 2;
      let y = "", g = "";
      return c === "bottom" ? (y = o ? d : `${h}px`, g = `${-l}px`) : c === "top" ? (y = o ? d : `${h}px`, g = `${r.floating.height + l}px`) : c === "right" ? (y = `${-l}px`, g = o ? d : `${f}px`) : c === "left" && (y = `${r.floating.width + l}px`, g = o ? d : `${f}px`), {
        data: {
          x: y,
          y: g
        }
      };
    }
  });
  function FK(t) {
    const [e, n = "center"] = t.split("-");
    return [
      e,
      n
    ];
  }
  var GC = DK, qC = jK, lL = NK, cL = zK, oI = "rovingFocusGroup.onEntryFocus", z5e = {
    bubbles: false,
    cancelable: true
  }, cS = "RovingFocusGroup", [TR, BK, F5e] = VC(cS), [B5e, KC] = Ps(cS, [
    F5e
  ]), [U5e, V5e] = B5e(cS), UK = b.forwardRef((t, e) => m.jsx(TR.Provider, {
    scope: t.__scopeRovingFocusGroup,
    children: m.jsx(TR.Slot, {
      scope: t.__scopeRovingFocusGroup,
      children: m.jsx(X5e, {
        ...t,
        ref: e
      })
    })
  }));
  UK.displayName = cS;
  var X5e = b.forwardRef((t, e) => {
    const { __scopeRovingFocusGroup: n, orientation: r, loop: i = false, dir: s, currentTabStopId: o, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: l, onEntryFocus: c, preventScrollOnEntryFocus: u = false, ...d } = t, h = b.useRef(null), f = Ht(e, h), y = XC(s), [g, O] = Wl({
      prop: o,
      defaultProp: a ?? null,
      onChange: l,
      caller: cS
    }), [S, w] = b.useState(false), x = ki(c), P = BK(n), C = b.useRef(false), [_, T] = b.useState(0);
    return b.useEffect(() => {
      const $ = h.current;
      if ($)
        return $.addEventListener(oI, x), () => $.removeEventListener(oI, x);
    }, [
      x
    ]), m.jsx(U5e, {
      scope: n,
      orientation: r,
      dir: y,
      loop: i,
      currentTabStopId: g,
      onItemFocus: b.useCallback(($) => O($), [
        O
      ]),
      onItemShiftTab: b.useCallback(() => w(true), []),
      onFocusableItemAdd: b.useCallback(() => T(($) => $ + 1), []),
      onFocusableItemRemove: b.useCallback(() => T(($) => $ - 1), []),
      children: m.jsx(rt.div, {
        tabIndex: S || _ === 0 ? -1 : 0,
        "data-orientation": r,
        ...d,
        ref: f,
        style: {
          outline: "none",
          ...t.style
        },
        onMouseDown: Pe(t.onMouseDown, () => {
          C.current = true;
        }),
        onFocus: Pe(t.onFocus, ($) => {
          const N = !C.current;
          if ($.target === $.currentTarget && N && !S) {
            const L = new CustomEvent(oI, z5e);
            if ($.currentTarget.dispatchEvent(L), !L.defaultPrevented) {
              const z = P().filter((X) => X.focusable), M = z.find((X) => X.active), R = z.find((X) => X.id === g), Q = [
                M,
                R,
                ...z
              ].filter(Boolean).map((X) => X.ref.current);
              WK(Q, u);
            }
          }
          C.current = false;
        }),
        onBlur: Pe(t.onBlur, () => w(false))
      })
    });
  }), VK = "RovingFocusGroupItem", XK = b.forwardRef((t, e) => {
    const { __scopeRovingFocusGroup: n, focusable: r = true, active: i = false, tabStopId: s, children: o, ...a } = t, l = ja(), c = s || l, u = V5e(VK, n), d = u.currentTabStopId === c, h = BK(n), { onFocusableItemAdd: f, onFocusableItemRemove: y, currentTabStopId: g } = u;
    return b.useEffect(() => {
      if (r)
        return f(), () => y();
    }, [
      r,
      f,
      y
    ]), m.jsx(TR.ItemSlot, {
      scope: n,
      id: c,
      focusable: r,
      active: i,
      children: m.jsx(rt.span, {
        tabIndex: d ? 0 : -1,
        "data-orientation": u.orientation,
        ...a,
        ref: e,
        onMouseDown: Pe(t.onMouseDown, (O) => {
          r ? u.onItemFocus(c) : O.preventDefault();
        }),
        onFocus: Pe(t.onFocus, () => u.onItemFocus(c)),
        onKeyDown: Pe(t.onKeyDown, (O) => {
          if (O.key === "Tab" && O.shiftKey) {
            u.onItemShiftTab();
            return;
          }
          if (O.target !== O.currentTarget)
            return;
          const S = H5e(O, u.orientation, u.dir);
          if (S !== void 0) {
            if (O.metaKey || O.ctrlKey || O.altKey || O.shiftKey)
              return;
            O.preventDefault();
            let x = h().filter((P) => P.focusable).map((P) => P.ref.current);
            if (S === "last")
              x.reverse();
            else if (S === "prev" || S === "next") {
              S === "prev" && x.reverse();
              const P = x.indexOf(O.currentTarget);
              x = u.loop ? Y5e(x, P + 1) : x.slice(P + 1);
            }
            setTimeout(() => WK(x));
          }
        }),
        children: typeof o == "function" ? o({
          isCurrentTabStop: d,
          hasTabStop: g != null
        }) : o
      })
    });
  });
  XK.displayName = VK;
  var W5e = {
    ArrowLeft: "prev",
    ArrowUp: "prev",
    ArrowRight: "next",
    ArrowDown: "next",
    PageUp: "first",
    Home: "first",
    PageDown: "last",
    End: "last"
  };
  function Z5e(t, e) {
    return e !== "rtl" ? t : t === "ArrowLeft" ? "ArrowRight" : t === "ArrowRight" ? "ArrowLeft" : t;
  }
  function H5e(t, e, n) {
    const r = Z5e(t.key, n);
    if (!(e === "vertical" && [
      "ArrowLeft",
      "ArrowRight"
    ].includes(r)) && !(e === "horizontal" && [
      "ArrowUp",
      "ArrowDown"
    ].includes(r)))
      return W5e[r];
  }
  function WK(t, e = false) {
    const n = document.activeElement;
    for (const r of t)
      if (r === n || (r.focus({
        preventScroll: e
      }), document.activeElement !== n))
        return;
  }
  function Y5e(t, e) {
    return t.map((n, r) => t[(e + r) % t.length]);
  }
  var ZK = UK, HK = XK, ER = [
    "Enter",
    " "
  ], G5e = [
    "ArrowDown",
    "PageUp",
    "Home"
  ], YK = [
    "ArrowUp",
    "PageDown",
    "End"
  ], q5e = [
    ...G5e,
    ...YK
  ], K5e = {
    ltr: [
      ...ER,
      "ArrowRight"
    ],
    rtl: [
      ...ER,
      "ArrowLeft"
    ]
  }, J5e = {
    ltr: [
      "ArrowLeft"
    ],
    rtl: [
      "ArrowRight"
    ]
  }, uS = "Menu", [eO, eLe, tLe] = VC(uS), [kf, JC] = Ps(uS, [
    tLe,
    Rm,
    KC
  ]), dS = Rm(), GK = KC(), [qK, Ud] = kf(uS), [nLe, hS] = kf(uS), KK = (t) => {
    const { __scopeMenu: e, open: n = false, children: r, dir: i, onOpenChange: s, modal: o = true } = t, a = dS(e), [l, c] = b.useState(null), u = b.useRef(false), d = ki(s), h = XC(i);
    return b.useEffect(() => {
      const f = () => {
        u.current = true, document.addEventListener("pointerdown", y, {
          capture: true,
          once: true
        }), document.addEventListener("pointermove", y, {
          capture: true,
          once: true
        });
      }, y = () => u.current = false;
      return document.addEventListener("keydown", f, {
        capture: true
      }), () => {
        document.removeEventListener("keydown", f, {
          capture: true
        }), document.removeEventListener("pointerdown", y, {
          capture: true
        }), document.removeEventListener("pointermove", y, {
          capture: true
        });
      };
    }, []), m.jsx(GC, {
      ...a,
      children: m.jsx(qK, {
        scope: e,
        open: n,
        onOpenChange: d,
        content: l,
        onContentChange: c,
        children: m.jsx(nLe, {
          scope: e,
          onClose: b.useCallback(() => d(false), [
            d
          ]),
          isUsingKeyboardRef: u,
          dir: h,
          modal: o,
          children: r
        })
      })
    });
  };
  KK.displayName = uS;
  var rLe = "MenuAnchor", uL = b.forwardRef((t, e) => {
    const { __scopeMenu: n, ...r } = t, i = dS(n);
    return m.jsx(qC, {
      ...i,
      ...r,
      ref: e
    });
  });
  uL.displayName = rLe;
  var dL = "MenuPortal", [iLe, JK] = kf(dL, {
    forceMount: void 0
  }), eJ = (t) => {
    const { __scopeMenu: e, forceMount: n, children: r, container: i } = t, s = Ud(dL, e);
    return m.jsx(iLe, {
      scope: e,
      forceMount: n,
      children: m.jsx(uo, {
        present: n || s.open,
        children: m.jsx(ZO, {
          asChild: true,
          container: i,
          children: r
        })
      })
    });
  };
  eJ.displayName = dL;
  var Ho = "MenuContent", [sLe, hL] = kf(Ho), tJ = b.forwardRef((t, e) => {
    const n = JK(Ho, t.__scopeMenu), { forceMount: r = n.forceMount, ...i } = t, s = Ud(Ho, t.__scopeMenu), o = hS(Ho, t.__scopeMenu);
    return m.jsx(eO.Provider, {
      scope: t.__scopeMenu,
      children: m.jsx(uo, {
        present: r || s.open,
        children: m.jsx(eO.Slot, {
          scope: t.__scopeMenu,
          children: o.modal ? m.jsx(oLe, {
            ...i,
            ref: e
          }) : m.jsx(aLe, {
            ...i,
            ref: e
          })
        })
      })
    });
  }), oLe = b.forwardRef((t, e) => {
    const n = Ud(Ho, t.__scopeMenu), r = b.useRef(null), i = Ht(e, r);
    return b.useEffect(() => {
      const s = r.current;
      if (s)
        return OC(s);
    }, []), m.jsx(fL, {
      ...t,
      ref: i,
      trapFocus: n.open,
      disableOutsidePointerEvents: n.open,
      disableOutsideScroll: true,
      onFocusOutside: Pe(t.onFocusOutside, (s) => s.preventDefault(), {
        checkForDefaultPrevented: false
      }),
      onDismiss: () => n.onOpenChange(false)
    });
  }), aLe = b.forwardRef((t, e) => {
    const n = Ud(Ho, t.__scopeMenu);
    return m.jsx(fL, {
      ...t,
      ref: e,
      trapFocus: false,
      disableOutsidePointerEvents: false,
      disableOutsideScroll: false,
      onDismiss: () => n.onOpenChange(false)
    });
  }), lLe = nf("MenuContent.ScrollLock"), fL = b.forwardRef((t, e) => {
    const { __scopeMenu: n, loop: r = false, trapFocus: i, onOpenAutoFocus: s, onCloseAutoFocus: o, disableOutsidePointerEvents: a, onEntryFocus: l, onEscapeKeyDown: c, onPointerDownOutside: u, onFocusOutside: d, onInteractOutside: h, onDismiss: f, disableOutsideScroll: y, ...g } = t, O = Ud(Ho, n), S = hS(Ho, n), w = dS(n), x = GK(n), P = eLe(n), [C, _] = b.useState(null), T = b.useRef(null), $ = Ht(e, T, O.onContentChange), N = b.useRef(0), L = b.useRef(""), z = b.useRef(0), M = b.useRef(null), R = b.useRef("right"), F = b.useRef(0), Q = y ? q3 : b.Fragment, X = y ? {
      as: lLe,
      allowPinchZoom: true
    } : void 0, Z = (H) => {
      var _a3, _b3;
      const te = L.current + H, se = P().filter((it) => !it.disabled), ae = document.activeElement, _e3 = (_a3 = se.find((it) => it.ref.current === ae)) == null ? void 0 : _a3.textValue, Me = se.map((it) => it.textValue), ke = SLe(Me, te, _e3), tt = (_b3 = se.find((it) => it.textValue === ke)) == null ? void 0 : _b3.ref.current;
      (function it(pt) {
        L.current = pt, window.clearTimeout(N.current), pt !== "" && (N.current = window.setTimeout(() => it(""), 1e3));
      })(te), tt && setTimeout(() => tt.focus());
    };
    b.useEffect(() => () => window.clearTimeout(N.current), []), H3();
    const U = b.useCallback((H) => {
      var _a3, _b3;
      return R.current === ((_a3 = M.current) == null ? void 0 : _a3.side) && xLe(H, (_b3 = M.current) == null ? void 0 : _b3.area);
    }, []);
    return m.jsx(sLe, {
      scope: n,
      searchRef: L,
      onItemEnter: b.useCallback((H) => {
        U(H) && H.preventDefault();
      }, [
        U
      ]),
      onItemLeave: b.useCallback((H) => {
        var _a3;
        U(H) || ((_a3 = T.current) == null ? void 0 : _a3.focus(), _(null));
      }, [
        U
      ]),
      onTriggerLeave: b.useCallback((H) => {
        U(H) && H.preventDefault();
      }, [
        U
      ]),
      pointerGraceTimerRef: z,
      onPointerGraceIntentChange: b.useCallback((H) => {
        M.current = H;
      }, []),
      children: m.jsx(Q, {
        ...X,
        children: m.jsx(yC, {
          asChild: true,
          trapped: i,
          onMountAutoFocus: Pe(s, (H) => {
            var _a3;
            H.preventDefault(), (_a3 = T.current) == null ? void 0 : _a3.focus({
              preventScroll: true
            });
          }),
          onUnmountAutoFocus: o,
          children: m.jsx(Sm, {
            asChild: true,
            disableOutsidePointerEvents: a,
            onEscapeKeyDown: c,
            onPointerDownOutside: u,
            onFocusOutside: d,
            onInteractOutside: h,
            onDismiss: f,
            children: m.jsx(ZK, {
              asChild: true,
              ...x,
              dir: S.dir,
              orientation: "vertical",
              loop: r,
              currentTabStopId: C,
              onCurrentTabStopIdChange: _,
              onEntryFocus: Pe(l, (H) => {
                S.isUsingKeyboardRef.current || H.preventDefault();
              }),
              preventScrollOnEntryFocus: true,
              children: m.jsx(lL, {
                role: "menu",
                "aria-orientation": "vertical",
                "data-state": vJ(O.open),
                "data-radix-menu-content": "",
                dir: S.dir,
                ...w,
                ...g,
                ref: $,
                style: {
                  outline: "none",
                  ...g.style
                },
                onKeyDown: Pe(g.onKeyDown, (H) => {
                  const se = H.target.closest("[data-radix-menu-content]") === H.currentTarget, ae = H.ctrlKey || H.altKey || H.metaKey, _e3 = H.key.length === 1;
                  se && (H.key === "Tab" && H.preventDefault(), !ae && _e3 && Z(H.key));
                  const Me = T.current;
                  if (H.target !== Me || !q5e.includes(H.key))
                    return;
                  H.preventDefault();
                  const tt = P().filter((it) => !it.disabled).map((it) => it.ref.current);
                  YK.includes(H.key) && tt.reverse(), vLe(tt);
                }),
                onBlur: Pe(t.onBlur, (H) => {
                  H.currentTarget.contains(H.target) || (window.clearTimeout(N.current), L.current = "");
                }),
                onPointerMove: Pe(t.onPointerMove, tO((H) => {
                  const te = H.target, se = F.current !== H.clientX;
                  if (H.currentTarget.contains(te) && se) {
                    const ae = H.clientX > F.current ? "right" : "left";
                    R.current = ae, F.current = H.clientX;
                  }
                }))
              })
            })
          })
        })
      })
    });
  });
  tJ.displayName = Ho;
  var cLe = "MenuGroup", pL = b.forwardRef((t, e) => {
    const { __scopeMenu: n, ...r } = t;
    return m.jsx(rt.div, {
      role: "group",
      ...r,
      ref: e
    });
  });
  pL.displayName = cLe;
  var uLe = "MenuLabel", nJ = b.forwardRef((t, e) => {
    const { __scopeMenu: n, ...r } = t;
    return m.jsx(rt.div, {
      ...r,
      ref: e
    });
  });
  nJ.displayName = uLe;
  var Vk = "MenuItem", n7 = "menu.itemSelect", e2 = b.forwardRef((t, e) => {
    const { disabled: n = false, onSelect: r, ...i } = t, s = b.useRef(null), o = hS(Vk, t.__scopeMenu), a = hL(Vk, t.__scopeMenu), l = Ht(e, s), c = b.useRef(false), u = () => {
      const d = s.current;
      if (!n && d) {
        const h = new CustomEvent(n7, {
          bubbles: true,
          cancelable: true
        });
        d.addEventListener(n7, (f) => r == null ? void 0 : r(f), {
          once: true
        }), Z3(d, h), h.defaultPrevented ? c.current = false : o.onClose();
      }
    };
    return m.jsx(rJ, {
      ...i,
      ref: l,
      disabled: n,
      onClick: Pe(t.onClick, u),
      onPointerDown: (d) => {
        var _a3;
        (_a3 = t.onPointerDown) == null ? void 0 : _a3.call(t, d), c.current = true;
      },
      onPointerUp: Pe(t.onPointerUp, (d) => {
        var _a3;
        c.current || ((_a3 = d.currentTarget) == null ? void 0 : _a3.click());
      }),
      onKeyDown: Pe(t.onKeyDown, (d) => {
        const h = a.searchRef.current !== "";
        n || h && d.key === " " || ER.includes(d.key) && (d.currentTarget.click(), d.preventDefault());
      })
    });
  });
  e2.displayName = Vk;
  var rJ = b.forwardRef((t, e) => {
    const { __scopeMenu: n, disabled: r = false, textValue: i, ...s } = t, o = hL(Vk, n), a = GK(n), l = b.useRef(null), c = Ht(e, l), [u, d] = b.useState(false), [h, f] = b.useState("");
    return b.useEffect(() => {
      const y = l.current;
      y && f((y.textContent ?? "").trim());
    }, [
      s.children
    ]), m.jsx(eO.ItemSlot, {
      scope: n,
      disabled: r,
      textValue: i ?? h,
      children: m.jsx(HK, {
        asChild: true,
        ...a,
        focusable: !r,
        children: m.jsx(rt.div, {
          role: "menuitem",
          "data-highlighted": u ? "" : void 0,
          "aria-disabled": r || void 0,
          "data-disabled": r ? "" : void 0,
          ...s,
          ref: c,
          onPointerMove: Pe(t.onPointerMove, tO((y) => {
            r ? o.onItemLeave(y) : (o.onItemEnter(y), y.defaultPrevented || y.currentTarget.focus({
              preventScroll: true
            }));
          })),
          onPointerLeave: Pe(t.onPointerLeave, tO((y) => o.onItemLeave(y))),
          onFocus: Pe(t.onFocus, () => d(true)),
          onBlur: Pe(t.onBlur, () => d(false))
        })
      })
    });
  }), dLe = "MenuCheckboxItem", iJ = b.forwardRef((t, e) => {
    const { checked: n = false, onCheckedChange: r, ...i } = t;
    return m.jsx(cJ, {
      scope: t.__scopeMenu,
      checked: n,
      children: m.jsx(e2, {
        role: "menuitemcheckbox",
        "aria-checked": Xk(n) ? "mixed" : n,
        ...i,
        ref: e,
        "data-state": yL(n),
        onSelect: Pe(i.onSelect, () => r == null ? void 0 : r(Xk(n) ? true : !n), {
          checkForDefaultPrevented: false
        })
      })
    });
  });
  iJ.displayName = dLe;
  var sJ = "MenuRadioGroup", [hLe, fLe] = kf(sJ, {
    value: void 0,
    onValueChange: () => {
    }
  }), oJ = b.forwardRef((t, e) => {
    const { value: n, onValueChange: r, ...i } = t, s = ki(r);
    return m.jsx(hLe, {
      scope: t.__scopeMenu,
      value: n,
      onValueChange: s,
      children: m.jsx(pL, {
        ...i,
        ref: e
      })
    });
  });
  oJ.displayName = sJ;
  var aJ = "MenuRadioItem", lJ = b.forwardRef((t, e) => {
    const { value: n, ...r } = t, i = fLe(aJ, t.__scopeMenu), s = n === i.value;
    return m.jsx(cJ, {
      scope: t.__scopeMenu,
      checked: s,
      children: m.jsx(e2, {
        role: "menuitemradio",
        "aria-checked": s,
        ...r,
        ref: e,
        "data-state": yL(s),
        onSelect: Pe(r.onSelect, () => {
          var _a3;
          return (_a3 = i.onValueChange) == null ? void 0 : _a3.call(i, n);
        }, {
          checkForDefaultPrevented: false
        })
      })
    });
  });
  lJ.displayName = aJ;
  var gL = "MenuItemIndicator", [cJ, pLe] = kf(gL, {
    checked: false
  }), uJ = b.forwardRef((t, e) => {
    const { __scopeMenu: n, forceMount: r, ...i } = t, s = pLe(gL, n);
    return m.jsx(uo, {
      present: r || Xk(s.checked) || s.checked === true,
      children: m.jsx(rt.span, {
        ...i,
        ref: e,
        "data-state": yL(s.checked)
      })
    });
  });
  uJ.displayName = gL;
  var gLe = "MenuSeparator", dJ = b.forwardRef((t, e) => {
    const { __scopeMenu: n, ...r } = t;
    return m.jsx(rt.div, {
      role: "separator",
      "aria-orientation": "horizontal",
      ...r,
      ref: e
    });
  });
  dJ.displayName = gLe;
  var mLe = "MenuArrow", hJ = b.forwardRef((t, e) => {
    const { __scopeMenu: n, ...r } = t, i = dS(n);
    return m.jsx(cL, {
      ...i,
      ...r,
      ref: e
    });
  });
  hJ.displayName = mLe;
  var mL = "MenuSub", [yLe, fJ] = kf(mL), pJ = (t) => {
    const { __scopeMenu: e, children: n, open: r = false, onOpenChange: i } = t, s = Ud(mL, e), o = dS(e), [a, l] = b.useState(null), [c, u] = b.useState(null), d = ki(i);
    return b.useEffect(() => (s.open === false && d(false), () => d(false)), [
      s.open,
      d
    ]), m.jsx(GC, {
      ...o,
      children: m.jsx(qK, {
        scope: e,
        open: r,
        onOpenChange: d,
        content: c,
        onContentChange: u,
        children: m.jsx(yLe, {
          scope: e,
          contentId: ja(),
          triggerId: ja(),
          trigger: a,
          onTriggerChange: l,
          children: n
        })
      })
    });
  };
  pJ.displayName = mL;
  var S0 = "MenuSubTrigger", gJ = b.forwardRef((t, e) => {
    const n = Ud(S0, t.__scopeMenu), r = hS(S0, t.__scopeMenu), i = fJ(S0, t.__scopeMenu), s = hL(S0, t.__scopeMenu), o = b.useRef(null), { pointerGraceTimerRef: a, onPointerGraceIntentChange: l } = s, c = {
      __scopeMenu: t.__scopeMenu
    }, u = b.useCallback(() => {
      o.current && window.clearTimeout(o.current), o.current = null;
    }, []);
    return b.useEffect(() => u, [
      u
    ]), b.useEffect(() => {
      const d = a.current;
      return () => {
        window.clearTimeout(d), l(null);
      };
    }, [
      a,
      l
    ]), m.jsx(uL, {
      asChild: true,
      ...c,
      children: m.jsx(rJ, {
        id: i.triggerId,
        "aria-haspopup": "menu",
        "aria-expanded": n.open,
        "aria-controls": i.contentId,
        "data-state": vJ(n.open),
        ...t,
        ref: mC(e, i.onTriggerChange),
        onClick: (d) => {
          var _a3;
          (_a3 = t.onClick) == null ? void 0 : _a3.call(t, d), !(t.disabled || d.defaultPrevented) && (d.currentTarget.focus(), n.open || n.onOpenChange(true));
        },
        onPointerMove: Pe(t.onPointerMove, tO((d) => {
          s.onItemEnter(d), !d.defaultPrevented && !t.disabled && !n.open && !o.current && (s.onPointerGraceIntentChange(null), o.current = window.setTimeout(() => {
            n.onOpenChange(true), u();
          }, 100));
        })),
        onPointerLeave: Pe(t.onPointerLeave, tO((d) => {
          var _a3, _b3;
          u();
          const h = (_a3 = n.content) == null ? void 0 : _a3.getBoundingClientRect();
          if (h) {
            const f = (_b3 = n.content) == null ? void 0 : _b3.dataset.side, y = f === "right", g = y ? -5 : 5, O = h[y ? "left" : "right"], S = h[y ? "right" : "left"];
            s.onPointerGraceIntentChange({
              area: [
                {
                  x: d.clientX + g,
                  y: d.clientY
                },
                {
                  x: O,
                  y: h.top
                },
                {
                  x: S,
                  y: h.top
                },
                {
                  x: S,
                  y: h.bottom
                },
                {
                  x: O,
                  y: h.bottom
                }
              ],
              side: f
            }), window.clearTimeout(a.current), a.current = window.setTimeout(() => s.onPointerGraceIntentChange(null), 300);
          } else {
            if (s.onTriggerLeave(d), d.defaultPrevented)
              return;
            s.onPointerGraceIntentChange(null);
          }
        })),
        onKeyDown: Pe(t.onKeyDown, (d) => {
          var _a3;
          const h = s.searchRef.current !== "";
          t.disabled || h && d.key === " " || K5e[r.dir].includes(d.key) && (n.onOpenChange(true), (_a3 = n.content) == null ? void 0 : _a3.focus(), d.preventDefault());
        })
      })
    });
  });
  gJ.displayName = S0;
  var mJ = "MenuSubContent", yJ = b.forwardRef((t, e) => {
    const n = JK(Ho, t.__scopeMenu), { forceMount: r = n.forceMount, ...i } = t, s = Ud(Ho, t.__scopeMenu), o = hS(Ho, t.__scopeMenu), a = fJ(mJ, t.__scopeMenu), l = b.useRef(null), c = Ht(e, l);
    return m.jsx(eO.Provider, {
      scope: t.__scopeMenu,
      children: m.jsx(uo, {
        present: r || s.open,
        children: m.jsx(eO.Slot, {
          scope: t.__scopeMenu,
          children: m.jsx(fL, {
            id: a.contentId,
            "aria-labelledby": a.triggerId,
            ...i,
            ref: c,
            align: "start",
            side: o.dir === "rtl" ? "left" : "right",
            disableOutsidePointerEvents: false,
            disableOutsideScroll: false,
            trapFocus: false,
            onOpenAutoFocus: (u) => {
              var _a3;
              o.isUsingKeyboardRef.current && ((_a3 = l.current) == null ? void 0 : _a3.focus()), u.preventDefault();
            },
            onCloseAutoFocus: (u) => u.preventDefault(),
            onFocusOutside: Pe(t.onFocusOutside, (u) => {
              u.target !== a.trigger && s.onOpenChange(false);
            }),
            onEscapeKeyDown: Pe(t.onEscapeKeyDown, (u) => {
              o.onClose(), u.preventDefault();
            }),
            onKeyDown: Pe(t.onKeyDown, (u) => {
              var _a3;
              const d = u.currentTarget.contains(u.target), h = J5e[o.dir].includes(u.key);
              d && h && (s.onOpenChange(false), (_a3 = a.trigger) == null ? void 0 : _a3.focus(), u.preventDefault());
            })
          })
        })
      })
    });
  });
  yJ.displayName = mJ;
  function vJ(t) {
    return t ? "open" : "closed";
  }
  function Xk(t) {
    return t === "indeterminate";
  }
  function yL(t) {
    return Xk(t) ? "indeterminate" : t ? "checked" : "unchecked";
  }
  function vLe(t) {
    const e = document.activeElement;
    for (const n of t)
      if (n === e || (n.focus(), document.activeElement !== e))
        return;
  }
  function OLe(t, e) {
    return t.map((n, r) => t[(e + r) % t.length]);
  }
  function SLe(t, e, n) {
    const i = e.length > 1 && Array.from(e).every((c) => c === e[0]) ? e[0] : e, s = n ? t.indexOf(n) : -1;
    let o = OLe(t, Math.max(s, 0));
    i.length === 1 && (o = o.filter((c) => c !== n));
    const l = o.find((c) => c.toLowerCase().startsWith(i.toLowerCase()));
    return l !== n ? l : void 0;
  }
  function wLe(t, e) {
    const { x: n, y: r } = t;
    let i = false;
    for (let s = 0, o = e.length - 1; s < e.length; o = s++) {
      const a = e[s], l = e[o], c = a.x, u = a.y, d = l.x, h = l.y;
      u > r != h > r && n < (d - c) * (r - u) / (h - u) + c && (i = !i);
    }
    return i;
  }
  function xLe(t, e) {
    if (!e)
      return false;
    const n = {
      x: t.clientX,
      y: t.clientY
    };
    return wLe(n, e);
  }
  function tO(t) {
    return (e) => e.pointerType === "mouse" ? t(e) : void 0;
  }
  var OJ = KK, SJ = uL, wJ = eJ, xJ = tJ, bJ = pL, kJ = nJ, PJ = e2, CJ = iJ, _J = oJ, TJ = lJ, EJ = uJ, IJ = dJ, $J = hJ, AJ = pJ, RJ = gJ, MJ = yJ, t2 = "DropdownMenu", [bLe, Dot] = Ps(t2, [
    JC
  ]), Ii = JC(), [kLe, DJ] = bLe(t2), LJ = (t) => {
    const { __scopeDropdownMenu: e, children: n, dir: r, open: i, defaultOpen: s, onOpenChange: o, modal: a = true } = t, l = Ii(e), c = b.useRef(null), [u, d] = Wl({
      prop: i,
      defaultProp: s ?? false,
      onChange: o,
      caller: t2
    });
    return m.jsx(kLe, {
      scope: e,
      triggerId: ja(),
      triggerRef: c,
      contentId: ja(),
      open: u,
      onOpenChange: d,
      onOpenToggle: b.useCallback(() => d((h) => !h), [
        d
      ]),
      modal: a,
      children: m.jsx(OJ, {
        ...l,
        open: u,
        onOpenChange: d,
        dir: r,
        modal: a,
        children: n
      })
    });
  };
  LJ.displayName = t2;
  var jJ = "DropdownMenuTrigger", NJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, disabled: r = false, ...i } = t, s = DJ(jJ, n), o = Ii(n);
    return m.jsx(SJ, {
      asChild: true,
      ...o,
      children: m.jsx(rt.button, {
        type: "button",
        id: s.triggerId,
        "aria-haspopup": "menu",
        "aria-expanded": s.open,
        "aria-controls": s.open ? s.contentId : void 0,
        "data-state": s.open ? "open" : "closed",
        "data-disabled": r ? "" : void 0,
        disabled: r,
        ...i,
        ref: mC(e, s.triggerRef),
        onPointerDown: Pe(t.onPointerDown, (a) => {
          !r && a.button === 0 && a.ctrlKey === false && (s.onOpenToggle(), s.open || a.preventDefault());
        }),
        onKeyDown: Pe(t.onKeyDown, (a) => {
          r || ([
            "Enter",
            " "
          ].includes(a.key) && s.onOpenToggle(), a.key === "ArrowDown" && s.onOpenChange(true), [
            "Enter",
            " ",
            "ArrowDown"
          ].includes(a.key) && a.preventDefault());
        })
      })
    });
  });
  NJ.displayName = jJ;
  var PLe = "DropdownMenuPortal", QJ = (t) => {
    const { __scopeDropdownMenu: e, ...n } = t, r = Ii(e);
    return m.jsx(wJ, {
      ...r,
      ...n
    });
  };
  QJ.displayName = PLe;
  var zJ = "DropdownMenuContent", FJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = DJ(zJ, n), s = Ii(n), o = b.useRef(false);
    return m.jsx(xJ, {
      id: i.contentId,
      "aria-labelledby": i.triggerId,
      ...s,
      ...r,
      ref: e,
      onCloseAutoFocus: Pe(t.onCloseAutoFocus, (a) => {
        var _a3;
        o.current || ((_a3 = i.triggerRef.current) == null ? void 0 : _a3.focus()), o.current = false, a.preventDefault();
      }),
      onInteractOutside: Pe(t.onInteractOutside, (a) => {
        const l = a.detail.originalEvent, c = l.button === 0 && l.ctrlKey === true, u = l.button === 2 || c;
        (!i.modal || u) && (o.current = true);
      }),
      style: {
        ...t.style,
        "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
      }
    });
  });
  FJ.displayName = zJ;
  var CLe = "DropdownMenuGroup", BJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(bJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  BJ.displayName = CLe;
  var _Le = "DropdownMenuLabel", UJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(kJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  UJ.displayName = _Le;
  var TLe = "DropdownMenuItem", VJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(PJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  VJ.displayName = TLe;
  var ELe = "DropdownMenuCheckboxItem", XJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(CJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  XJ.displayName = ELe;
  var ILe = "DropdownMenuRadioGroup", $Le = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(_J, {
      ...i,
      ...r,
      ref: e
    });
  });
  $Le.displayName = ILe;
  var ALe = "DropdownMenuRadioItem", WJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(TJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  WJ.displayName = ALe;
  var RLe = "DropdownMenuItemIndicator", ZJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(EJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  ZJ.displayName = RLe;
  var MLe = "DropdownMenuSeparator", HJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(IJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  HJ.displayName = MLe;
  var DLe = "DropdownMenuArrow", LLe = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx($J, {
      ...i,
      ...r,
      ref: e
    });
  });
  LLe.displayName = DLe;
  var jLe = (t) => {
    const { __scopeDropdownMenu: e, children: n, open: r, onOpenChange: i, defaultOpen: s } = t, o = Ii(e), [a, l] = Wl({
      prop: r,
      defaultProp: s ?? false,
      onChange: i,
      caller: "DropdownMenuSub"
    });
    return m.jsx(AJ, {
      ...o,
      open: a,
      onOpenChange: l,
      children: n
    });
  }, NLe = "DropdownMenuSubTrigger", YJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(RJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  YJ.displayName = NLe;
  var QLe = "DropdownMenuSubContent", GJ = b.forwardRef((t, e) => {
    const { __scopeDropdownMenu: n, ...r } = t, i = Ii(n);
    return m.jsx(MJ, {
      ...i,
      ...r,
      ref: e,
      style: {
        ...t.style,
        "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
      }
    });
  });
  GJ.displayName = QLe;
  var vL = LJ, Ug = NJ, n2 = QJ, r2 = FJ, zLe = BJ, qJ = UJ, Bu = VJ, i2 = XJ, KJ = WJ, OL = ZJ, JJ = HJ, FLe = jLe, SL = YJ, wL = GJ;
  const eee = () => {
  }, tee = b.createContext({});
  function BLe({ onEvent: t, children: e }) {
    return m.jsx(tee.Provider, {
      value: t ?? eee,
      children: e
    });
  }
  function Mm() {
    return b.useContext(tee) ?? eee;
  }
  function Pf(t, e) {
    const n = ue(), r = b.useRef(false), i = Mm(), s = b.useCallback((a) => {
      r.current = a, n.batch(() => {
        a ? (n.complete(), n.addOpenMenu(t)) : n.updateInstanceState({
          openMenus: n.openMenus.filter((l) => !l.startsWith(t))
        }), e == null ? void 0 : e(a);
      });
    }, [
      n,
      t,
      e
    ]);
    return b.useEffect(() => (r.current && (i("open-menu", {
      source: "unknown",
      id: t
    }), n.addOpenMenu(t)), () => {
      r.current && (n.deleteOpenMenu(t), n.openMenus.forEach((a) => {
        a.startsWith(t) && (i("close-menu", {
          source: "unknown",
          id: t
        }), n.deleteOpenMenu(a));
      }), r.current = false);
    }), [
      n,
      t,
      i
    ]), [
      ye("is menu open", () => n.openMenus.includes(t), [
        n,
        t
      ]),
      s
    ];
  }
  function Pd({ id: t, children: e, modal: n = false }) {
    const [r, i] = Pf(t);
    return m.jsx(vL, {
      open: r,
      dir: "ltr",
      modal: n,
      onOpenChange: i,
      children: e
    });
  }
  function fS({ children: t, "data-testid": e }) {
    return m.jsx(Ug, {
      dir: "ltr",
      "data-testid": e,
      asChild: true,
      onTouchEnd: (n) => Rt(n),
      children: t
    });
  }
  function Cd({ side: t = "bottom", align: e = "start", sideOffset: n = 8, alignOffset: r = 8, children: i }) {
    const s = Kr();
    return m.jsx(n2, {
      dir: "ltr",
      container: s,
      children: m.jsx(r2, {
        className: "tlui-menu",
        align: e,
        sideOffset: n,
        side: t,
        alignOffset: r,
        collisionPadding: 4,
        children: i
      })
    });
  }
  function xL({ id: t, children: e }) {
    const [n, r] = Pf(t);
    return m.jsx(FLe, {
      open: n,
      onOpenChange: r,
      children: e
    });
  }
  function bL({ label: t, "data-testid": e, "data-direction": n }) {
    return m.jsx(SL, {
      dir: "ltr",
      "data-direction": n,
      "data-testid": e,
      asChild: true,
      children: m.jsx(Be, {
        className: "tlui-menu__button tlui-menu__submenu__trigger",
        label: t,
        icon: "chevron-right"
      })
    });
  }
  function kL({ alignOffset: t = 0, sideOffset: e = 5, children: n }) {
    const r = Kr();
    return m.jsx(n2, {
      container: r,
      dir: "ltr",
      children: m.jsx(wL, {
        className: "tlui-menu tlui-menu__submenu__content",
        alignOffset: t,
        sideOffset: e,
        collisionPadding: 4,
        children: n
      })
    });
  }
  function jc({ children: t, size: e = "medium" }) {
    return m.jsx(zLe, {
      dir: "ltr",
      className: "tlui-menu__group",
      "data-size": e,
      children: t
    });
  }
  function Ks({ noClose: t, ...e }) {
    return m.jsx(Bu, {
      dir: "ltr",
      asChild: true,
      onClick: t || e.isChecked !== void 0 ? Rt : void 0,
      children: m.jsx(Be, {
        className: "tlui-menu__button",
        ...e
      })
    });
  }
  function nee({ children: t, onSelect: e, ...n }) {
    return m.jsxs(i2, {
      dir: "ltr",
      className: "tlui-button tlui-menu__button tlui-menu__checkbox-item",
      onSelect: (r) => {
        e == null ? void 0 : e(r), Rt(r);
      },
      ...n,
      children: [
        m.jsx("div", {
          className: "tlui-menu__checkbox-item__check",
          style: {
            transformOrigin: "75% center",
            transform: `scale(${n.checked ? 1 : 0.5})`,
            opacity: n.checked ? 1 : 0.5
          },
          children: m.jsx(Ss, {
            small: true,
            icon: n.checked ? "check" : "checkbox-empty"
          })
        }),
        t
      ]
    });
  }
  function ULe({ children: t, onSelect: e, ...n }) {
    return m.jsxs(i2, {
      dir: "ltr",
      className: "tlui-button tlui-menu__button tlui-menu__checkbox-item",
      onSelect: (r) => {
        e == null ? void 0 : e(r), Rt(r);
      },
      ...n,
      children: [
        m.jsx(OL, {
          dir: "ltr",
          className: "tlui-menu__checkbox-item__check",
          children: m.jsx(Ss, {
            icon: "check"
          })
        }),
        t
      ]
    });
  }
  const VLe = ({ children: t }) => {
    const e = ue();
    return ye("shouldDisplayHandles", () => e.isInAny("select.idle", "select.pointing_handle"), [
      e
    ]) ? m.jsx("svg", {
      className: "tl-user-handles tl-overlays__item",
      children: t
    }) : null;
  }, XLe = ({ shapeId: t }) => {
    const e = ue();
    return ye("show hovered", () => e.isIn("select.editing_shape") ? e.hoveredShapeId !== e.editingShapeId : e.isInAny("select.idle"), [
      e
    ]) ? m.jsx(JO, {
      className: "tl-user-indicator__hovered",
      id: t
    }) : null;
  }, { PI: WLe } = Math, wp = WLe + 1e-4;
  function Vg(t, e = {}) {
    const { size: n = 16, smoothing: r = 0.5, start: i = {}, end: s = {}, last: o = false } = e, { cap: a = true } = i, { cap: l = true } = s;
    if (t.length === 0 || n <= 0)
      return [];
    const c = t[0], u = t[t.length - 1], d = u.runningLength, h = i.taper === false ? 0 : i.taper === true ? Math.max(n, d) : i.taper, f = s.taper === false ? 0 : s.taper === true ? Math.max(n, d) : s.taper, y = Math.pow(n * r, 2), g = [], O = [];
    let S = t[0].vector, w = t[0].point, x = w, P = w, C = x, _ = false, T;
    for (let R = 0; R < t.length; R++) {
      T = t[R];
      const { point: F, vector: Q } = t[R], X = T.vector.dpr(S), Z = (R < t.length - 1 ? t[R + 1] : t[R]).vector, U = R < t.length - 1 ? Z.dpr(T.vector) : 1, H = X < 0 && !_, te = U !== null && U < 0.2;
      if (H || te) {
        if (U > -0.62 && d - T.runningLength > T.radius) {
          const ae = S.clone().mul(T.radius);
          S.clone().cpr(Z) < 0 ? (P = I.Add(F, ae), C = I.Sub(F, ae)) : (P = I.Sub(F, ae), C = I.Add(F, ae)), g.push(P), O.push(C);
        } else {
          const ae = S.clone().mul(T.radius).per(), _e3 = I.Sub(T.input, ae);
          for (let Me = 1 / 13, ke = 0; ke < 1; ke += Me)
            P = I.RotWith(_e3, T.input, wp * ke), g.push(P), C = I.RotWith(_e3, T.input, wp + wp * -ke), O.push(C);
        }
        w = P, x = C, te && (_ = true);
        continue;
      }
      if (_ = false, T === c || T === u) {
        const ae = I.Per(Q).mul(T.radius);
        g.push(I.Sub(F, ae)), O.push(I.Add(F, ae));
        continue;
      }
      const se = I.Lrp(Z, Q, U).per().mul(T.radius);
      P = I.Sub(F, se), (R <= 1 || I.Dist2(w, P) > y) && (g.push(P), w = P), C = I.Add(F, se), (R <= 1 || I.Dist2(x, C) > y) && (O.push(C), x = C), S = Q;
    }
    const $ = c.point, N = t.length > 1 ? t[t.length - 1].point : I.AddXY(c.point, 1, 1);
    if (t.length === 1 && (!(h || f) || o)) {
      const R = I.Add($, I.Sub($, N).uni().per().mul(-c.radius)), F = [];
      for (let Q = 1 / 13, X = Q; X <= 1; X += Q)
        F.push(I.RotWith(R, $, wp * 2 * X));
      return F;
    }
    const L = [];
    if (!(h || f && t.length === 1))
      if (a)
        for (let R = 1 / 8, F = R; F <= 1; F += R) {
          const Q = I.RotWith(O[0], $, wp * F);
          L.push(Q);
        }
      else {
        const R = I.Sub(g[0], O[0]), F = I.Mul(R, 0.5), Q = I.Mul(R, 0.51);
        L.push(I.Sub($, F), I.Sub($, Q), I.Add($, Q), I.Add($, F));
      }
    const z = [], M = u.vector.clone().per().neg();
    if (f || h && t.length === 1)
      z.push(N);
    else if (l) {
      const R = I.Add(N, I.Mul(M, u.radius));
      for (let F = 1 / 29, Q = F; Q < 1; Q += F)
        z.push(I.RotWith(R, N, wp * 3 * Q));
    } else
      z.push(I.Add(N, I.Mul(M, u.radius)), I.Add(N, I.Mul(M, u.radius * 0.99)), I.Sub(N, I.Mul(M, u.radius * 0.99)), I.Sub(N, I.Mul(M, u.radius)));
    return g.concat(z, O.reverse(), L);
  }
  const ZLe = 0.025, HLe = 0.01;
  function Ic(t, e = {}) {
    var _a3;
    const { streamline: n = 0.5, size: r = 16, simulatePressure: i = false } = e;
    if (t.length === 0)
      return [];
    const s = 0.15 + (1 - n) * 0.85;
    let o = t.map(I.From), a = 0;
    if (!i) {
      let O = o[0];
      for (; O && !(O.z >= ZLe); )
        o.shift(), O = o[0];
    }
    if (!i) {
      let O = o[o.length - 1];
      for (; O && !(O.z >= HLe); )
        o.pop(), O = o[o.length - 1];
    }
    if (o.length === 0)
      return [
        {
          point: I.From(t[0]),
          input: I.From(t[0]),
          pressure: i ? 0.5 : 0.15,
          vector: new I(1, 1),
          distance: 0,
          runningLength: 0,
          radius: 1
        }
      ];
    let l = o[1];
    for (; l && !(I.Dist(l, o[0]) > r / 3); )
      o[0].z = Math.max(o[0].z, l.z), o.splice(1, 1), l = o[1];
    const c = o.pop();
    for (l = o[o.length - 1]; l && !(I.Dist(l, c) > r / 3); )
      o.pop(), l = o[o.length - 1], a++;
    o.push(c);
    const u = e.last || !e.simulatePressure || o.length > 1 && I.Dist(o[o.length - 1], o[o.length - 2]) < r || a > 0;
    if (o.length === 2 && e.simulatePressure) {
      const O = o[1];
      o = o.slice(0, -1);
      for (let S = 1; S < 5; S++) {
        const w = I.Lrp(o[0], O, S / 4);
        w.z = (o[0].z + (O.z - o[0].z)) * S / 4, o.push(w);
      }
    }
    const d = [
      {
        point: o[0],
        input: o[0],
        pressure: i ? 0.5 : o[0].z,
        vector: new I(1, 1),
        distance: 0,
        runningLength: 0,
        radius: 1
      }
    ];
    let h = 0, f = d[0], y, g;
    u && n > 0 && o.push(o[o.length - 1].clone());
    for (let O = 1, S = o.length; O < S; O++)
      y = !s || e.last && O === S - 1 ? o[O].clone() : o[O].clone().lrp(f.point, 1 - s), !f.point.equals(y) && (g = I.Dist(y, f.point), h += g, !(O < 4 && h < r) && (f = {
        input: o[O],
        point: y,
        pressure: i ? 0.5 : o[O].z,
        vector: I.Sub(f.point, y).uni(),
        distance: g,
        runningLength: h,
        radius: 1
      }, d.push(f)));
    if (((_a3 = d[1]) == null ? void 0 : _a3.vector) && (d[0].vector = d[1].vector.clone()), h < 1) {
      const O = Math.max(0.5, ...d.map((S) => S.pressure));
      d.forEach((S) => S.pressure = O);
    }
    return d;
  }
  const { min: _u } = Math, aI = 0.275;
  function Xg(t, e) {
    const { size: n = 16, thinning: r = 0.5, simulatePressure: i = true, easing: s = (O) => O, start: o = {}, end: a = {} } = e, { easing: l = Oi.easeOutQuad } = o, { easing: c = Oi.easeOutCubic } = a, u = t[t.length - 1].runningLength;
    let d, h = t[0].pressure, f;
    if (!i && u < n) {
      const O = t.reduce((S, w) => Math.max(S, w.pressure), 0.5);
      return t.forEach((S) => {
        S.pressure = O, S.radius = n * s(0.5 - r * (0.5 - S.pressure));
      }), t;
    } else {
      let O;
      for (let S = 0, w = t.length; S < w && (f = t[S], !(f.runningLength > n * 5)); S++) {
        const x = _u(1, f.distance / n);
        if (i) {
          const P = _u(1, 1 - x);
          O = _u(1, h + (P - h) * (x * aI));
        } else
          O = _u(1, h + (f.pressure - h) * 0.5);
        h = h + (O - h) * 0.5;
      }
      for (let S = 0; S < t.length; S++) {
        if (f = t[S], r) {
          let { pressure: w } = f;
          const x = _u(1, f.distance / n);
          if (i) {
            const P = _u(1, 1 - x);
            w = _u(1, h + (P - h) * (x * aI));
          } else
            w = _u(1, h + (w - h) * (x * aI));
          f.radius = n * s(0.5 - r * (0.5 - w)), h = w;
        } else
          f.radius = n / 2;
        d === void 0 && (d = f.radius);
      }
    }
    const y = o.taper === false ? 0 : o.taper === true ? Math.max(n, u) : o.taper, g = a.taper === false ? 0 : a.taper === true ? Math.max(n, u) : a.taper;
    if (y || g)
      for (let O = 0; O < t.length; O++) {
        f = t[O];
        const { runningLength: S } = f, w = S < y ? l(S / y) : 1, x = u - S < g ? c((u - S) / g) : 1;
        f.radius = Math.max(0.01, f.radius * Math.min(w, x));
      }
    return t;
  }
  function YLe(t, e = {}) {
    return Vg(Xg(Ic(t, e), e), e);
  }
  const r7 = ({ scribble: t, zoom: e, color: n, opacity: r, className: i }) => {
    if (!t.points.length)
      return null;
    const s = YLe(t.points, {
      size: t.size / e,
      start: {
        taper: true,
        easing: Oi.linear
      },
      last: t.state === "stopping",
      simulatePressure: false,
      streamline: 0.32
    });
    let o;
    if (s.length < 4) {
      const a = t.size / e / 2, { x: l, y: c } = t.points[t.points.length - 1];
      o = `M ${l - a},${c} a ${a},${a} 0 1,0 ${a * 2},0 a ${a},${a} 0 1,0 ${-a * 2},0`;
    } else
      o = Qg(s);
    return m.jsx("svg", {
      className: i && Ze("tl-overlays__item", i),
      children: m.jsx("path", {
        className: "tl-scribble",
        d: o,
        fill: n ?? `var(--color-${t.color})`,
        opacity: r ?? t.opacity
      })
    });
  }, GLe = ({ bounds: t, rotation: e }) => {
    const n = ue();
    return ye("should display", () => n.isInAny("select.idle", "select.brushing", "select.scribble_brushing", "select.pointing_shape", "select.pointing_selection", "text.resizing"), [
      n
    ]) ? m.jsx(wG, {
      bounds: t,
      rotation: e
    }) : null;
  };
  function sa() {
    const t = ue();
    return ye("isReadonlyMode", () => t.instanceState.isReadonly, [
      t
    ]);
  }
  function qLe({ size: t, width: e, height: n, hideAlternateHandles: r }) {
    const i = Y(t / 3), s = i / 2;
    return m.jsxs("svg", {
      className: "tl-overlays__item",
      children: [
        m.jsx("polyline", {
          className: "tl-corner-crop-handle",
          points: `
						${Y(0 - s)},${Y(t)} 
						${Y(0 - s)},${Y(0 - s)} 
						${Y(t)},${Y(0 - s)}`,
          strokeWidth: i,
          "data-testid": "selection.crop.top_left",
          "aria-label": "top_left handle"
        }),
        m.jsx("line", {
          className: Ze("tl-corner-crop-edge-handle", {
            "tl-hidden": r
          }),
          x1: Y(e / 2 - t),
          y1: Y(0 - s),
          x2: Y(e / 2 + t),
          y2: Y(0 - s),
          strokeWidth: i,
          "data-testid": "selection.crop.top",
          "aria-label": "top handle"
        }),
        m.jsx("polyline", {
          className: Ze("tl-corner-crop-handle", {
            "tl-hidden": r
          }),
          points: `
						${Y(e - t)},${Y(0 - s)} 
						${Y(e + s)},${Y(0 - s)} 
						${Y(e + s)},${Y(t)}`,
          strokeWidth: i,
          "data-testid": "selection.crop.top_right",
          "aria-label": "top_right handle"
        }),
        m.jsx("line", {
          className: Ze("tl-corner-crop-edge-handle", {
            "tl-hidden": r
          }),
          x1: Y(e + s),
          y1: Y(n / 2 - t),
          x2: Y(e + s),
          y2: Y(n / 2 + t),
          strokeWidth: i,
          "data-testid": "selection.crop.right",
          "aria-label": "right handle"
        }),
        m.jsx("polyline", {
          className: "tl-corner-crop-handle",
          points: `
						${Y(e + s)},${Y(n - t)} 
						${Y(e + s)},${Y(n + s)}
						${Y(e - t)},${Y(n + s)}`,
          strokeWidth: i,
          "data-testid": "selection.crop.bottom_right",
          "aria-label": "bottom_right handle"
        }),
        m.jsx("line", {
          className: Ze("tl-corner-crop-edge-handle", {
            "tl-hidden": r
          }),
          x1: Y(e / 2 - t),
          y1: Y(n + s),
          x2: Y(e / 2 + t),
          y2: Y(n + s),
          strokeWidth: i,
          "data-testid": "selection.crop.bottom",
          "aria-label": "bottom handle"
        }),
        m.jsx("polyline", {
          className: Ze("tl-corner-crop-handle", {
            "tl-hidden": r
          }),
          points: `
						${Y(0 + t)},${Y(n + s)} 
						${Y(0 - s)},${Y(n + s)}
						${Y(0 - s)},${Y(n - t)}`,
          strokeWidth: i,
          "data-testid": "selection.crop.bottom_left",
          "aria-label": "bottom_left handle"
        }),
        m.jsx("line", {
          className: Ze("tl-corner-crop-edge-handle", {
            "tl-hidden": r
          }),
          x1: Y(0 - s),
          y1: Y(n / 2 - t),
          x2: Y(0 - s),
          y2: Y(n / 2 + t),
          strokeWidth: i,
          "data-testid": "selection.crop.left",
          "aria-label": "left handle"
        })
      ]
    });
  }
  const KLe = typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf("firefox") > -1, JLe = Vt(function({ bounds: e, rotation: n }) {
    const r = ue(), i = b.useRef(null), s = sa(), o = yl("top"), a = yl("right"), l = yl("bottom"), c = yl("left"), u = yl("top_left"), d = yl("top_right"), h = yl("bottom_right"), f = yl("bottom_left"), y = !r.isMenuOpen && r.instanceState.cursor.type === "default", g = r.instanceState.isCoarsePointer, O = r.selectedShapes, S = r.onlySelectedShape, w = S && r.isShapeOrAncestorLocked(S), x = S ? r.getShapeUtil(S).expandSelectionOutlinePx(S) : 0;
    if (bm(i, e == null ? void 0 : e.x, e == null ? void 0 : e.y, 1, r.selectionRotation, {
      x: -x,
      y: -x
    }), !e)
      return null;
    e = e.clone().expandBy(x).zeroFix();
    const P = r.zoomLevel, C = r.instanceState.isChangingStyle, _ = e.width, T = e.height, $ = 8 / P, N = _ < $ * 2, L = T < $ * 2, z = _ < $ * 4, M = T < $ * 4, R = _ < $ * 5, F = T < $ * 5, Q = g ? 1.75 : 1, X = 6 / P * Q, Z = (z ? X / 2 : X) * (Q * 0.75), U = (M ? X / 2 : X) * (Q * 0.75), H = (S ? !r.getShapeUtil(S).hideSelectionBoundsFg(S) : true) && !C;
    let te = H && r.isInAny("select.idle", "select.brushing", "select.scribble_brushing", "select.pointing_canvas", "select.pointing_selection", "select.pointing_shape", "select.crop.idle", "select.crop.pointing_crop", "select.pointing_resize_handle", "select.pointing_crop_handle") || H && r.isIn("select.resizing") && S && r.isShapeOfType(S, "text");
    S && te && KLe && r.isShapeOfType(S, "embed") && (te = false);
    const se = r.isInAny("select.pointing_crop_handle", "select.crop.idle", "select.crop.pointing_crop") && !C && !s, ae = r.isInAny("select.idle", "select.pointing_selection", "select.pointing_shape", "select.crop.idle") && !C && !s, _e3 = !g && !(N || L) && (ae || se) && (S ? !r.getShapeUtil(S).hideRotateHandle(S) : true) && !w, Me = g && (!z || !M) && (ae || se) && (S ? !r.getShapeUtil(S).hideRotateHandle(S) : true) && !w, ke = ae && (S ? r.getShapeUtil(S).canResize(S) && !r.getShapeUtil(S).hideResizeHandles(S) : true) && !se && !w, tt = N || L, it = N && L, pt = R || F, kt = ke || se, Yt = !_e3, Ar = !ae || !Me, Cn = !ae || !kt, Vn = !ae || !kt || tt, Lt = !ae || !kt || tt, tr = !ae || !kt || it && !se;
    let ql = g;
    ql && O.every((Jr) => r.getShapeUtil(Jr).isAspectRatioLocked(Jr)) && (ql = false);
    let nr = true;
    se ? nr = pt : ke && (nr = tt || it || ql);
    const go = Math.min(24 / P, T - U * 3), mo = ae && g && S && r.isShapeOfType(S, "text") && go * P >= 4;
    return m.jsxs("svg", {
      ref: i,
      className: "tl-overlays__item tl-selection__fg",
      "data-testid": "selection-foreground",
      children: [
        te && m.jsx("rect", {
          className: Ze("tl-selection__fg__outline"),
          width: Y(_),
          height: Y(T)
        }),
        m.jsx(_w, {
          "data-testid": "selection.rotate.top-left",
          cx: 0,
          cy: 0,
          targetSize: X,
          corner: "top_left_rotate",
          cursor: y ? Ns("nwse-rotate", n) : void 0,
          isHidden: Yt
        }),
        m.jsx(_w, {
          "data-testid": "selection.rotate.top-right",
          cx: _ + X * 3,
          cy: 0,
          targetSize: X,
          corner: "top_right_rotate",
          cursor: y ? Ns("nesw-rotate", n) : void 0,
          isHidden: Yt
        }),
        m.jsx(_w, {
          "data-testid": "selection.rotate.bottom-left",
          cx: 0,
          cy: T + X * 3,
          targetSize: X,
          corner: "bottom_left_rotate",
          cursor: y ? Ns("swne-rotate", n) : void 0,
          isHidden: Yt
        }),
        m.jsx(_w, {
          "data-testid": "selection.rotate.bottom-right",
          cx: _ + X * 3,
          cy: T + X * 3,
          targetSize: X,
          corner: "bottom_right_rotate",
          cursor: y ? Ns("senw-rotate", n) : void 0,
          isHidden: Yt
        }),
        m.jsx(tje, {
          "data-testid": "selection.rotate.mobile",
          cx: z ? -X * 1.5 : _ / 2,
          cy: z ? T / 2 : -X * 1.5,
          size: $,
          isHidden: Ar
        }),
        m.jsx("rect", {
          className: Ze("tl-transparent", {
            "tl-hidden": nr
          }),
          "data-testid": "selection.resize.top",
          "aria-label": "top target",
          pointerEvents: "all",
          x: 0,
          y: Y(0 - (M ? U * 2 : U)),
          width: Y(_),
          height: Y(Math.max(1, U * 2)),
          style: y ? {
            cursor: Ns("ns-resize", n)
          } : void 0,
          ...o
        }),
        m.jsx("rect", {
          className: Ze("tl-transparent", {
            "tl-hidden": nr
          }),
          "data-testid": "selection.resize.right",
          "aria-label": "right target",
          pointerEvents: "all",
          x: Y(_ - (z ? 0 : Z)),
          y: 0,
          height: Y(T),
          width: Y(Math.max(1, Z * 2)),
          style: y ? {
            cursor: Ns("ew-resize", n)
          } : void 0,
          ...a
        }),
        m.jsx("rect", {
          className: Ze("tl-transparent", {
            "tl-hidden": nr
          }),
          "data-testid": "selection.resize.bottom",
          "aria-label": "bottom target",
          pointerEvents: "all",
          x: 0,
          y: Y(T - (M ? 0 : U)),
          width: Y(_),
          height: Y(Math.max(1, U * 2)),
          style: y ? {
            cursor: Ns("ns-resize", n)
          } : void 0,
          ...l
        }),
        m.jsx("rect", {
          className: Ze("tl-transparent", {
            "tl-hidden": nr
          }),
          "data-testid": "selection.resize.left",
          "aria-label": "left target",
          pointerEvents: "all",
          x: Y(0 - (z ? Z * 2 : Z)),
          y: 0,
          height: Y(T),
          width: Y(Math.max(1, Z * 2)),
          style: y ? {
            cursor: Ns("ew-resize", n)
          } : void 0,
          ...c
        }),
        m.jsx("rect", {
          className: Ze("tl-transparent", {
            "tl-hidden": Cn
          }),
          "data-testid": "selection.target.top-left",
          "aria-label": "top-left target",
          pointerEvents: "all",
          x: Y(0 - (z ? Z * 2 : Z * 1.5)),
          y: Y(0 - (M ? U * 2 : U * 1.5)),
          width: Y(Z * 3),
          height: Y(U * 3),
          style: y ? {
            cursor: Ns("nwse-resize", n)
          } : void 0,
          ...u
        }),
        m.jsx("rect", {
          className: Ze("tl-transparent", {
            "tl-hidden": Vn
          }),
          "data-testid": "selection.target.top-right",
          "aria-label": "top-right target",
          pointerEvents: "all",
          x: Y(_ - (z ? 0 : Z * 1.5)),
          y: Y(0 - (M ? U * 2 : U * 1.5)),
          width: Y(Z * 3),
          height: Y(U * 3),
          style: y ? {
            cursor: Ns("nesw-resize", n)
          } : void 0,
          ...d
        }),
        m.jsx("rect", {
          className: Ze("tl-transparent", {
            "tl-hidden": tr
          }),
          "data-testid": "selection.target.bottom-right",
          "aria-label": "bottom-right target",
          pointerEvents: "all",
          x: Y(_ - (z ? Z : Z * 1.5)),
          y: Y(T - (M ? U : U * 1.5)),
          width: Y(Z * 3),
          height: Y(U * 3),
          style: y ? {
            cursor: Ns("nwse-resize", n)
          } : void 0,
          ...h
        }),
        m.jsx("rect", {
          className: Ze("tl-transparent", {
            "tl-hidden": Lt
          }),
          "data-testid": "selection.target.bottom-left",
          "aria-label": "bottom-left target",
          pointerEvents: "all",
          x: Y(0 - (z ? Z * 3 : Z * 1.5)),
          y: Y(T - (M ? 0 : U * 1.5)),
          width: Y(Z * 3),
          height: Y(U * 3),
          style: y ? {
            cursor: Ns("nesw-resize", n)
          } : void 0,
          ...f
        }),
        ke && m.jsxs(m.Fragment, {
          children: [
            m.jsx("rect", {
              "data-testid": "selection.resize.top-left",
              className: Ze("tl-corner-handle", {
                "tl-hidden": Cn
              }),
              "aria-label": "top_left handle",
              x: Y(0 - $ / 2),
              y: Y(0 - $ / 2),
              width: Y($),
              height: Y($)
            }),
            m.jsx("rect", {
              "data-testid": "selection.resize.top-right",
              className: Ze("tl-corner-handle", {
                "tl-hidden": Vn
              }),
              "aria-label": "top_right handle",
              x: Y(_ - $ / 2),
              y: Y(0 - $ / 2),
              width: Y($),
              height: Y($)
            }),
            m.jsx("rect", {
              "data-testid": "selection.resize.bottom-right",
              className: Ze("tl-corner-handle", {
                "tl-hidden": tr
              }),
              "aria-label": "bottom_right handle",
              x: Y(_ - $ / 2),
              y: Y(T - $ / 2),
              width: Y($),
              height: Y($)
            }),
            m.jsx("rect", {
              "data-testid": "selection.resize.bottom-left",
              className: Ze("tl-corner-handle", {
                "tl-hidden": Lt
              }),
              "aria-label": "bottom_left handle",
              x: Y(0 - $ / 2),
              y: Y(T - $ / 2),
              width: Y($),
              height: Y($)
            })
          ]
        }),
        mo && m.jsxs(m.Fragment, {
          children: [
            m.jsx("rect", {
              "data-testid": "selection.text-resize.left.handle",
              className: "tl-text-handle",
              "aria-label": "bottom_left handle",
              x: Y(0 - $ / 4),
              y: Y(T / 2 - go / 2),
              rx: $ / 4,
              width: Y($ / 2),
              height: Y(go)
            }),
            m.jsx("rect", {
              "data-testid": "selection.text-resize.right.handle",
              className: "tl-text-handle",
              "aria-label": "bottom_left handle",
              rx: $ / 4,
              x: Y(_ - $ / 4),
              y: Y(T / 2 - go / 2),
              width: Y($ / 2),
              height: Y(go)
            })
          ]
        }),
        se && m.jsx(qLe, {
          size: $,
          width: _,
          height: T,
          hideAlternateHandles: pt
        })
      ]
    });
  }), _w = function({ cx: e, cy: n, targetSize: r, corner: i, cursor: s, isHidden: o, "data-testid": a }) {
    const l = yl(i);
    return m.jsx("rect", {
      className: Ze("tl-transparent", "tl-rotate-corner", {
        "tl-hidden": o
      }),
      "data-testid": a,
      "aria-label": `${i} target`,
      pointerEvents: "all",
      x: Y(e - r * 3),
      y: Y(n - r * 3),
      width: Y(Math.max(1, r * 3)),
      height: Y(Math.max(1, r * 3)),
      cursor: s,
      ...l
    });
  }, eje = Math.sqrt(Math.PI), tje = function({ cx: e, cy: n, size: r, isHidden: i, "data-testid": s }) {
    const o = yl("mobile_rotate"), a = ue(), l = ye("zoom level", () => a.zoomLevel, [
      a
    ]), c = Math.max(14 * (1 / l), 20 / Math.max(1, l));
    return m.jsxs("g", {
      children: [
        m.jsx("circle", {
          "data-testid": s,
          pointerEvents: "all",
          className: Ze("tl-transparent", "tl-mobile-rotate__bg", {
            "tl-hidden": i
          }),
          cx: e,
          cy: n,
          r: c,
          ...o
        }),
        m.jsx("circle", {
          className: Ze("tl-mobile-rotate__fg", {
            "tl-hidden": i
          }),
          cx: e,
          cy: n,
          r: r / eje
        })
      ]
    });
  }, Wr = {
    lineHeight: 1.35,
    fontWeight: "normal",
    fontVariant: "normal",
    fontStyle: "normal",
    padding: "0px"
  }, mi = {
    s: 2,
    m: 3.5,
    l: 5,
    xl: 10
  }, qu = {
    s: 18,
    m: 24,
    l: 36,
    xl: 44
  }, Wg = {
    s: 18,
    m: 22,
    l: 26,
    xl: 32
  }, Du = {
    s: 18,
    m: 20,
    l: 24,
    xl: 28
  }, Nc = {
    draw: "var(--tl-font-draw)",
    sans: "var(--tl-font-sans)",
    serif: "var(--tl-font-serif)",
    mono: "var(--tl-font-mono)"
  };
  function nje(t, e) {
    var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
    if (n != null) {
      var r, i, s, o, a = [], l = true, c = false;
      try {
        if (s = (n = n.call(t)).next, e === 0) {
          if (Object(n) !== n)
            return;
          l = false;
        } else
          for (; !(l = (r = s.call(n)).done) && (a.push(r.value), a.length !== e); l = true)
            ;
      } catch (u) {
        c = true, i = u;
      } finally {
        try {
          if (!l && n.return != null && (o = n.return(), Object(o) !== o))
            return;
        } finally {
          if (c)
            throw i;
        }
      }
      return a;
    }
  }
  function i7(t, e) {
    var n = Object.keys(t);
    if (Object.getOwnPropertySymbols) {
      var r = Object.getOwnPropertySymbols(t);
      e && (r = r.filter(function(i) {
        return Object.getOwnPropertyDescriptor(t, i).enumerable;
      })), n.push.apply(n, r);
    }
    return n;
  }
  function Bs(t) {
    for (var e = 1; e < arguments.length; e++) {
      var n = arguments[e] != null ? arguments[e] : {};
      e % 2 ? i7(Object(n), true).forEach(function(r) {
        rje(t, r, n[r]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : i7(Object(n)).forEach(function(r) {
        Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
      });
    }
    return t;
  }
  function rje(t, e, n) {
    return e = hje(e), e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  function ije(t, e) {
    if (t == null)
      return {};
    var n = {}, r = Object.keys(t), i, s;
    for (s = 0; s < r.length; s++)
      i = r[s], !(e.indexOf(i) >= 0) && (n[i] = t[i]);
    return n;
  }
  function sje(t, e) {
    if (t == null)
      return {};
    var n = ije(t, e), r, i;
    if (Object.getOwnPropertySymbols) {
      var s = Object.getOwnPropertySymbols(t);
      for (i = 0; i < s.length; i++)
        r = s[i], !(e.indexOf(r) >= 0) && Object.prototype.propertyIsEnumerable.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }
  function s7(t, e) {
    return aje(t) || nje(t, e) || ree(t, e) || uje();
  }
  function Tw(t) {
    return oje(t) || lje(t) || ree(t) || cje();
  }
  function oje(t) {
    if (Array.isArray(t))
      return IR(t);
  }
  function aje(t) {
    if (Array.isArray(t))
      return t;
  }
  function lje(t) {
    if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null)
      return Array.from(t);
  }
  function ree(t, e) {
    if (t) {
      if (typeof t == "string")
        return IR(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return IR(t, e);
    }
  }
  function IR(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function cje() {
    throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function uje() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function dje(t, e) {
    if (typeof t != "object" || t === null)
      return t;
    var n = t[Symbol.toPrimitive];
    if (n !== void 0) {
      var r = n.call(t, e || "default");
      if (typeof r != "object")
        return r;
      throw new TypeError("@@toPrimitive must return a primitive value.");
    }
    return (e === "string" ? String : Number)(t);
  }
  function hje(t) {
    var e = dje(t, "string");
    return typeof e == "symbol" ? e : String(e);
  }
  function K0(t) {
    var e = t.sizes.shift(), n = Math.max(Math.ceil(e[0]), 1), r = Math.max(Math.ceil(e[1]), 1), i = [
      n - 1,
      r - 1,
      1,
      1
    ], s = Date.now(), o = typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope, a, l;
    o ? (a = new OffscreenCanvas(1, 1), l = new OffscreenCanvas(n, r)) : (a = document.createElement("canvas"), a.width = 1, a.height = 1, l = document.createElement("canvas"), l.width = n, l.height = r);
    var c = a.getContext("2d"), u = l.getContext("2d");
    u && (u.fillRect.apply(u, i), c.drawImage(l, n - 1, r - 1, 1, 1, 0, 0, 1, 1));
    var d = c && c.getImageData(0, 0, 1, 1).data[3] !== 0, h = Date.now() - s;
    return [
      a,
      l
    ].forEach(function(f) {
      f.height = 0, f.width = 0;
    }), o ? (postMessage({
      width: n,
      height: r,
      benchmark: h,
      isTestPass: d
    }), !d && t.sizes.length && K0(t)) : d ? t.onSuccess(n, r, h) : (t.onError(n, r, h), t.sizes.length && K0(t)), d;
  }
  var lI = {
    area: [
      16384,
      14188,
      11402,
      11180,
      10836,
      8192,
      4096,
      1
    ],
    height: [
      8388607,
      65535,
      32767,
      16384,
      8192,
      4096,
      1
    ],
    width: [
      4194303,
      65535,
      32767,
      16384,
      8192,
      4096,
      1
    ]
  }, fje = [
    "onError",
    "onSuccess"
  ], tg = {
    max: null,
    min: 1,
    sizes: [],
    step: 1024,
    usePromise: false,
    useWorker: false,
    onError: Function.prototype,
    onSuccess: Function.prototype
  }, Xy = {};
  function cI(t) {
    var e = t.width === t.height, n = t.height === 1, r = t.width === 1, i = [];
    if (!t.width || !t.height)
      t.sizes.forEach(function(u) {
        var d = e || n ? u : 1, h = e || r ? u : 1;
        i.push([
          d,
          h
        ]);
      });
    else
      for (var s = t.min || tg.min, o = t.step || tg.step, a = Math.max(t.width, t.height); a >= s; ) {
        var l = e || n ? a : 1, c = e || r ? a : 1;
        i.push([
          l,
          c
        ]), a -= o;
      }
    return i;
  }
  function Ew(t) {
    var e = window && "HTMLCanvasElement" in window, n = window && "OffscreenCanvas" in window, r = Date.now(), i = t.onError, s = t.onSuccess, o = sje(t, fje), a = null;
    if (!e)
      return false;
    if (t.useWorker && n) {
      var l = `
            var canvasTest = `.concat(K0.toString(), `;
            onmessage = function(e) {
                canvasTest(e.data);
            };
        `), c = new Blob([
        l
      ], {
        type: "application/javascript"
      }), u = URL.createObjectURL(c);
      a = new Worker(u), URL.revokeObjectURL(u), a.onmessage = function(d) {
        var h = d.data, f = h.width, y = h.height, g = h.benchmark, O = h.isTestPass;
        O ? (Xy[r].onSuccess(f, y, g), delete Xy[r]) : Xy[r].onError(f, y, g);
      };
    }
    if (t.usePromise)
      return new Promise(function(d, h) {
        var f = Bs(Bs({}, t), {}, {
          onError: function(S, w, x) {
            var P;
            if (t.sizes.length === 0)
              P = true;
            else {
              var C = t.sizes.slice(-1), _ = s7(C, 1), T = s7(_[0], 2), $ = T[0], N = T[1];
              P = S === $ && w === N;
            }
            i(S, w, x), P && h({
              width: S,
              height: w,
              benchmark: x
            });
          },
          onSuccess: function(S, w, x) {
            s(S, w, x), d({
              width: S,
              height: w,
              benchmark: x
            });
          }
        });
        if (a) {
          var y = f.onError, g = f.onSuccess;
          Xy[r] = {
            onError: y,
            onSuccess: g
          }, a.postMessage(o);
        } else
          K0(f);
      });
    if (a)
      Xy[r] = {
        onError: i,
        onSuccess: s
      }, a.postMessage(o);
    else
      return K0(t);
  }
  var uI = {
    maxArea: function() {
      var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = cI({
        width: e.max,
        height: e.max,
        min: e.min,
        step: e.step,
        sizes: Tw(lI.area)
      }), r = Bs(Bs(Bs({}, tg), e), {}, {
        sizes: n
      });
      return Ew(r);
    },
    maxHeight: function() {
      var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = cI({
        width: 1,
        height: e.max,
        min: e.min,
        step: e.step,
        sizes: Tw(lI.height)
      }), r = Bs(Bs(Bs({}, tg), e), {}, {
        sizes: n
      });
      return Ew(r);
    },
    maxWidth: function() {
      var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = cI({
        width: e.max,
        height: 1,
        min: e.min,
        step: e.step,
        sizes: Tw(lI.width)
      }), r = Bs(Bs(Bs({}, tg), e), {}, {
        sizes: n
      });
      return Ew(r);
    },
    test: function() {
      var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = Bs(Bs({}, tg), e);
      return n.sizes = Tw(n.sizes), n.width && n.height && (n.sizes = [
        [
          n.width,
          n.height
        ]
      ]), Ew(n);
    }
  };
  let dI = null;
  function iee() {
    return dI || (dI = pje()), dI;
  }
  async function pje() {
    const t = await uI.maxWidth({
      usePromise: true
    }), e = await uI.maxHeight({
      usePromise: true
    }), n = await uI.maxArea({
      usePromise: true
    });
    return {
      maxWidth: t.width,
      maxHeight: e.height,
      maxArea: n.width * n.height
    };
  }
  function o7(t, e) {
    let n = 0;
    for (; t[e + n]; )
      n += t[e + n] + 1;
    return n + 1;
  }
  function gje(t) {
    return new TextDecoder("ascii").decode(t.slice(0, 3)) === "GIF";
  }
  function mje(t) {
    const e = new Uint8Array(t);
    let n, r, i = 0, s = 0;
    if (!gje(t))
      return false;
    for (n = e[10] & 128, r = e[10] & 7, i += 6, i += 7, i += n ? 3 * Math.pow(2, r + 1) : 0; s < 2 && i < e.length; )
      switch (e[i]) {
        case 44:
          s += 1, n = e[i + 9] & 128, r = e[i + 9] & 7, i += 10, i += n ? 3 * Math.pow(2, r + 1) : 0, i += o7(e, i + 1) + 1;
          break;
        case 33:
          i += 2, i += o7(e, i);
          break;
        case 59:
          i = e.length;
          break;
        default:
          i = e.length;
          break;
      }
    return s > 1;
  }
  function yje(t, e) {
    const n = t.w / e.w, r = t.h / e.h;
    return n <= 1 && r <= 1 ? t : n > r ? {
      w: t.w / n,
      h: t.h / n
    } : {
      w: t.w / r,
      h: t.h / r
    };
  }
  async function vje(t, e, n) {
    return await new Promise((r) => {
      const i = new Image();
      i.onload = async () => {
        const s = document.createElement("canvas"), o = s.getContext("2d");
        if (!o)
          return;
        const a = await iee();
        let l = e * 2, c = n * 2;
        const u = i.width / i.height;
        if (l > a.maxWidth && (l = a.maxWidth, c = l / u), c > a.maxHeight && (c = a.maxHeight, l = c * u), l * c > a.maxArea) {
          const h = Math.sqrt(a.maxArea / (l * c));
          l *= h, c *= h;
        }
        s.width = l, s.height = c, o.drawImage(i, 0, 0, s.width, s.height);
        const d = s.toDataURL();
        r(d);
      }, i.crossOrigin = "anonymous", i.src = t;
    });
  }
  async function Oje(t) {
    return await new Promise((e, n) => {
      const r = new FileReader();
      r.onerror = () => n(r.error), r.onload = () => {
        e(r.result ? mje(r.result) : false);
      }, r.readAsArrayBuffer(t);
    });
  }
  function Sje(t) {
    if (typeof t != "string")
      throw new TypeError("Expected a string");
    return t.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
  }
  function wje(t) {
    const e = new URL(t).host.replace("www.", "");
    for (const n of Ng)
      if (see(n.hostnames, e)) {
        const r = n.fromEmbedUrl(t);
        if (r)
          return {
            definition: n,
            url: r,
            embedUrl: t
          };
      }
  }
  const xje = (t) => t.split("*").map((e) => Sje(e)).join(".+"), see = (t, e) => !!t.find((n) => {
    const r = new RegExp(xje(n));
    return e.match(r);
  });
  function bje(t) {
    const e = new URL(t).host.replace("www.", "");
    for (const n of Ng)
      if (see(n.hostnames, e)) {
        const r = n.toEmbedUrl(t);
        if (r)
          return {
            definition: n,
            embedUrl: r,
            url: t
          };
      }
  }
  function oee(t) {
    return bje(t) ?? wje(t);
  }
  function Cc(t) {
    try {
      return oee(t);
    } catch (e) {
      console.error(e);
    }
  }
  const ng = "  ";
  const _pr = class _pr {
    static insertTextFirefox(e, n) {
      e.setRangeText(n, e.selectionStart || 0, e.selectionEnd || 0, "end"), e.dispatchEvent(new InputEvent("input", {
        data: n,
        inputType: "insertText",
        isComposing: false
      }));
    }
    static insert(e, n) {
      const r = e.ownerDocument, i = r.activeElement;
      i !== e && e.focus(), r.execCommand("insertText", false, n) || _pr.insertTextFirefox(e, n), i === r.body ? e.blur() : i instanceof HTMLElement && i !== e && i.focus();
    }
    static set(e, n) {
      e.select(), _pr.insert(e, n);
    }
    static getSelection(e) {
      const { selectionStart: n, selectionEnd: r } = e;
      return e.value.slice(n || void 0, r || void 0);
    }
    static wrapSelection(e, n, r) {
      const { selectionStart: i, selectionEnd: s } = e, o = _pr.getSelection(e);
      _pr.insert(e, n + o + (r ?? n)), e.selectionStart = (i || 0) + n.length, e.selectionEnd = (s || 0) + n.length;
    }
    static replace(e, n, r) {
      let i = 0;
      e.value.replace(n, (...s) => {
        const o = i + s[s.length - 2], a = s[0].length;
        e.selectionStart = o, e.selectionEnd = o + a;
        const l = typeof r == "string" ? r : r(...s);
        return _pr.insert(e, l), e.selectionStart = o, i += l.length - a, l;
      });
    }
    static findLineEnd(e, n) {
      const r = e.lastIndexOf(`
`, n - 1) + 1;
      return e.charAt(r) !== "	" ? n : r + 1;
    }
    static indent(e) {
      var _a3;
      const { selectionStart: n, selectionEnd: r, value: i } = e, s = i.slice(n, r), o = (_a3 = /\n/g.exec(s)) == null ? void 0 : _a3.length;
      if (o && o > 0) {
        const a = i.lastIndexOf(`
`, n - 1) + 1, l = e.value.slice(a, r - 1), c = l.replace(/^|\n/g, `$&${ng}`), u = c.length - l.length;
        e.setSelectionRange(a, r - 1), _pr.insert(e, c), e.setSelectionRange(n + 1, r + u);
      } else
        _pr.insert(e, ng);
    }
    static unindent(e) {
      const { selectionStart: n, selectionEnd: r, value: i } = e, s = i.lastIndexOf(`
`, n - 1) + 1, o = _pr.findLineEnd(i, r), a = e.value.slice(s, o), l = a.replace(/(^|\n)(\t| {1,2})/g, "$1"), c = a.length - l.length;
      e.setSelectionRange(s, o), _pr.insert(e, l);
      const u = /\t| {1,2}/.exec(i.slice(s, n)), d = u ? u[0].length : 0, h = n - d;
      e.setSelectionRange(n - d, Math.max(h, r - c));
    }
    static indentCE(e) {
      var _a3;
      const n = window.getSelection(), r = e.innerText, i = Iw(e) ?? 0, s = Iw(e) ?? 0, o = r.slice(i, s), a = (_a3 = /\n/g.exec(o)) == null ? void 0 : _a3.length;
      if (a && a > 0) {
        const l = r.lastIndexOf(`
`, i - 1) + 1, c = r.slice(l, s - 1), d = c.replace(/^|\n/g, `$&${ng}`).length - c.length;
        n && n.setBaseAndExtent(e, i + 1, e, s + d);
      } else {
        const l = window.getSelection();
        e.innerText = r.slice(0, i) + ng + r.slice(i), l == null ? void 0 : l.setBaseAndExtent(e, i + 1, e, i + 2);
      }
    }
    static unindentCE(e) {
      const n = window.getSelection(), r = e.innerText, i = Iw(e) ?? 0, s = Iw(e) ?? 0, o = r.lastIndexOf(`
`, i - 1) + 1, a = _pr.findLineEnd(r, s), l = r.slice(o, a), c = l.replace(/(^|\n)(\t| {1,2})/g, "$1"), u = l.length - c.length;
      if (n) {
        n.setBaseAndExtent(e, o, e, a);
        const d = /\t| {1,2}/.exec(r.slice(o, i)), h = d ? d[0].length : 0, f = i - h;
        n.setBaseAndExtent(e, i - h, e, Math.max(f, s - u));
      }
    }
    static normalizeText(e) {
      return e.replace(_pr.fixNewLines, `
`);
    }
    static normalizeTextForDom(e) {
      return e.replace(_pr.fixNewLines, `
`).split(`
`).map((n) => n || " ").join(`
`);
    }
  };
  __publicField(_pr, "fixNewLines", /\r?\n|\r/g);
  let pr = _pr;
  function Iw(t) {
    if (typeof window.getSelection > "u")
      return;
    const e = window.getSelection();
    if (!e)
      return;
    let n = 0;
    if (e.rangeCount !== 0) {
      const r = e.getRangeAt(0), i = r.cloneRange();
      i.selectNodeContents(t), i.setEnd(r.endContainer, r.endOffset), n = i.toString().length;
    }
    return n;
  }
  const kje = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
  function Pje(t) {
    return kje.test(t);
  }
  function Cje(t) {
    return t.replace(/\t/g, ng);
  }
  function _je(t) {
    const e = t.split(`
`);
    for (; e[0].trim().length === 0; )
      e.shift();
    let n = 1 / 0;
    for (const r of e)
      if (r.trim().length > 0) {
        const i = r.length - r.trimStart().length;
        n = Math.min(n, i);
      }
    return e.map((r) => r.slice(n)).join(`
`);
  }
  function Tje(t) {
    return t.replace(/[ \t]+$/gm, "").replace(/\n+$/, "");
  }
  function Eje(t) {
    return Tje(_je(Cje(t)));
  }
  const J0 = (t, e) => t.length <= e ? t : t.substring(0, e - 3) + "...";
  function Ije(t, { maxImageDimension: e, maxAssetSize: n, acceptedImageMimeTypes: r, acceptedVideoMimeTypes: i }) {
    t.registerExternalAssetHandler("file", async ({ file: s }) => await new Promise((o, a) => {
      !r.includes(s.type) && !i.includes(s.type) && (console.warn(`File type not allowed: ${s.type}`), a()), s.size > n && (console.warn(`File size too big: ${(s.size / 1024).toFixed()}kb > ${(n / 1024).toFixed()}kb`), a());
      const l = new FileReader();
      l.onerror = () => a(l.error), l.onload = async () => {
        let c = l.result;
        s.type === "video/quicktime" && c.includes("video/quicktime") && (c = c.replace("video/quicktime", "video/mp4"));
        const u = r.includes(s.type);
        let d, h;
        if (u ? (d = await zz.getImageSizeFromSrc(c), h = s.type === "image/gif" && await Oje(s)) : (h = true, d = await zz.getVideoSizeFromSrc(c)), isFinite(e)) {
          const g = yje(d, {
            w: e,
            h: e
          });
          d !== g && (s.type === "image/jpeg" || s.type === "image/png") && (c = await vje(c, d.w, d.h)), d = g;
        }
        const f = Mh.createId(Xx(c)), y = Mh.create({
          id: f,
          type: u ? "image" : "video",
          typeName: "asset",
          props: {
            name: s.name,
            src: c,
            w: d.w,
            h: d.h,
            mimeType: s.type,
            isAnimated: h
          }
        });
        o(y);
      }, l.readAsDataURL(s);
    })), t.registerExternalAssetHandler("url", async ({ url: s }) => {
      var _a3, _b3, _c3;
      let o;
      try {
        const l = await (await fetch(s, {
          method: "GET",
          mode: "no-cors"
        })).text(), c = new DOMParser().parseFromString(l, "text/html");
        o = {
          image: ((_a3 = c.head.querySelector('meta[property="og:image"]')) == null ? void 0 : _a3.getAttribute("content")) ?? "",
          title: ((_b3 = c.head.querySelector('meta[property="og:title"]')) == null ? void 0 : _b3.getAttribute("content")) ?? J0(s, 32),
          description: ((_c3 = c.head.querySelector('meta[property="og:description"]')) == null ? void 0 : _c3.getAttribute("content")) ?? ""
        };
      } catch (a) {
        console.error(a), o = {
          image: "",
          title: J0(s, 32),
          description: ""
        };
      }
      return {
        id: Mh.createId(Xx(s)),
        typeName: "asset",
        type: "bookmark",
        props: {
          src: s,
          description: o.description,
          image: o.image,
          title: o.title
        },
        meta: {}
      };
    }), t.registerExternalContentHandler("svg-text", async ({ point: s, text: o }) => {
      const a = s ?? (t.inputs.shiftKey ? t.inputs.currentPagePoint : t.viewportPageCenter), l = new DOMParser().parseFromString(o, "image/svg+xml").querySelector("svg");
      if (!l)
        throw new Error("No <svg/> element present");
      let c = parseFloat(l.getAttribute("width") || "0"), u = parseFloat(l.getAttribute("height") || "0");
      if (!(c && u)) {
        document.body.appendChild(l);
        const h = l.getBoundingClientRect();
        document.body.removeChild(l), c = h.width, u = h.height;
      }
      const d = await t.getAssetForExternalContent({
        type: "file",
        file: new File([
          o
        ], "asset.svg", {
          type: "image/svg+xml"
        })
      });
      if (!d)
        throw Error("Could not create an asset");
      hI(t, [
        d
      ], a);
    }), t.registerExternalContentHandler("embed", ({ point: s, url: o, embed: a }) => {
      const l = s ?? (t.inputs.shiftKey ? t.inputs.currentPagePoint : t.viewportPageCenter), { width: c, height: u } = a, d = bn(), h = {
        id: d,
        type: "embed",
        x: l.x - (c || 450) / 2,
        y: l.y - (u || 450) / 2,
        props: {
          w: c,
          h: u,
          url: o
        }
      };
      t.createShapes([
        h
      ]).select(d);
    }), t.registerExternalContentHandler("files", async ({ point: s, files: o }) => {
      const a = s ?? (t.inputs.shiftKey ? t.inputs.currentPagePoint : t.viewportPageCenter), l = new I(a.x, a.y), c = [];
      await Promise.all(o.map(async (u, d) => {
        if (u.size > n)
          return console.warn(`File size too big: ${(u.size / 1024).toFixed()}kb > ${(n / 1024).toFixed()}kb`), null;
        if (!u.type)
          throw new Error("No mime type");
        if (!r.concat(i).includes(u.type))
          return console.warn(`${u.name} not loaded - Extension not allowed.`), null;
        try {
          const h = await t.getAssetForExternalContent({
            type: "file",
            file: u
          });
          if (!h)
            throw Error("Could not create an asset");
          c[d] = h;
        } catch (h) {
          return console.error(h), null;
        }
      })), hI(t, Je(c), l);
    }), t.registerExternalContentHandler("text", async ({ point: s, text: o }) => {
      const a = s ?? (t.inputs.shiftKey ? t.inputs.currentPagePoint : t.viewportPageCenter), l = t.getShapeUtil("text").getDefaultProps(), c = Eje(o);
      let u, d, h, f = "middle";
      const y = c.split(`
`).length > 1, g = Pje(c);
      y && (f = y ? g ? "end" : "start" : "middle");
      const O = t.textMeasure.measureText(c, {
        ...Wr,
        fontFamily: Nc[l.font],
        fontSize: qu[l.size],
        maxWidth: null
      }), S = Math.min(y ? t.viewportPageBounds.width * 0.9 : 920, Math.max(200, t.viewportPageBounds.width * 0.9));
      if (O.w > S) {
        const w = t.textMeasure.measureText(c, {
          ...Wr,
          fontFamily: Nc[l.font],
          fontSize: qu[l.size],
          maxWidth: S
        });
        u = w.w, d = w.h, h = false, f = g ? "end" : "start";
      } else
        u = O.w, d = O.h, h = true;
      a.y - d / 2 < t.viewportPageBounds.minY + 40 && (a.y = t.viewportPageBounds.minY + 40 + d / 2), t.createShapes([
        {
          id: bn(),
          type: "text",
          x: a.x - u / 2,
          y: a.y - d / 2,
          props: {
            text: c,
            align: f,
            autoSize: h,
            w: u
          }
        }
      ]);
    }), t.registerExternalContentHandler("url", async ({ point: s, url: o }) => {
      const a = Cc(o);
      if (a)
        return t.putExternalContent({
          type: "embed",
          url: a.url,
          point: s,
          embed: a.definition
        });
      const l = s ?? (t.inputs.shiftKey ? t.inputs.currentPagePoint : t.viewportPageCenter), c = Mh.createId(Xx(o));
      let u = t.getAsset(c), d = false;
      if (!u) {
        d = true;
        const h = await t.getAssetForExternalContent({
          type: "url",
          url: o
        });
        if (!h)
          throw Error("Could not create an asset");
        u = h;
      }
      t.batch(() => {
        d && t.createAssets([
          u
        ]), hI(t, [
          u
        ], l);
      });
    });
  }
  async function hI(t, e, n) {
    if (!e.length)
      return;
    const r = I.From(n), i = [];
    for (const s of e)
      switch (s.type) {
        case "bookmark": {
          i.push({
            id: bn(),
            type: "bookmark",
            x: r.x - 150,
            y: r.y - 160,
            opacity: 1,
            props: {
              assetId: s.id,
              url: s.props.src
            }
          }), r.x += 300;
          break;
        }
        case "image": {
          i.push({
            id: bn(),
            type: "image",
            x: r.x - s.props.w / 2,
            y: r.y - s.props.h / 2,
            opacity: 1,
            props: {
              assetId: s.id,
              w: s.props.w,
              h: s.props.h
            }
          }), r.x += s.props.w;
          break;
        }
        case "video":
          i.push({
            id: bn(),
            type: "video",
            x: r.x - s.props.w / 2,
            y: r.y - s.props.h / 2,
            opacity: 1,
            props: {
              assetId: s.id,
              w: s.props.w,
              h: s.props.h
            }
          }), r.x += s.props.w;
      }
    t.batch(() => {
      const s = e.filter((l) => !t.getAsset(l.id));
      s.length && t.createAssets(s), t.createShapes(i).select(...i.map((l) => l.id));
      const { viewportPageBounds: o } = t;
      let { selectionPageBounds: a } = t;
      if (a) {
        const l = a.center.sub(n);
        t.updateShapes(t.selectedShapes.map((c) => {
          const u = t.getShapeParentTransform(c).decompose().rotation, d = I.Rot(l, -u);
          return {
            id: c.id,
            type: c.type,
            x: c.x - d.x,
            y: c.y - d.y
          };
        }));
      }
      a = t.selectionPageBounds, a && !o.contains(a) && t.zoomToSelection();
    });
  }
  let $je = (_c2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("pointing", e);
      });
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
      __publicField(this, "onKeyUp", (e) => {
        if (e.key === "Enter") {
          if (this.editor.instanceState.isReadonly)
            return null;
          const { onlySelectedShape: n } = this.editor;
          n && this.editor.getShapeUtil(n).canEdit(n) && (this.editor.setCurrentTool("select"), this.editor.setEditingShape(n.id), this.editor.root.current.value.transition("editing_shape", {
            ...e,
            target: "shape",
            shape: n
          }));
        }
      });
    }
  }, __publicField(_c2, "id", "idle"), _c2), Aje = (_d2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shape");
      __publicField(this, "markId", "");
      __publicField(this, "onEnter", () => {
        this.didTimeout = false;
        const e = this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
          filter: (n) => !n.isLocked && this.editor.getShapeUtil(n).canBind(n),
          margin: 0,
          hitInside: true,
          renderingOnly: true
        });
        e ? this.editor.setHintingShapes([
          e.id
        ]) : this.createArrowShape(), this.startPreciseTimeout();
      });
      __publicField(this, "onExit", () => {
        this.shape = void 0, this.editor.setHintingShapes([]), this.clearPreciseTimeout();
      });
      __publicField(this, "onPointerMove", () => {
        if (this.editor.inputs.isDragging) {
          if (this.shape || this.createArrowShape(), !this.shape)
            throw Error("expected shape");
          this.updateArrowShapeEndHandle(), this.editor.setCurrentTool("select.dragging_handle", {
            shape: this.shape,
            handle: this.editor.getShapeHandles(this.shape).find((e) => e.id === "end"),
            isCreating: true,
            onInteractionEnd: "arrow"
          });
        }
      });
      __publicField(this, "onPointerUp", () => {
        this.cancel();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.cancel();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
      __publicField(this, "preciseTimeout", -1);
      __publicField(this, "didTimeout", false);
    }
    cancel() {
      this.shape && this.editor.bailToMark(this.markId), this.editor.setHintingShapes([]), this.parent.transition("idle", {});
    }
    createArrowShape() {
      var _a3, _b3;
      const { originPagePoint: e } = this.editor.inputs, n = bn();
      this.markId = `creating:${n}`, this.editor.mark(this.markId), this.editor.createShapes([
        {
          id: n,
          type: "arrow",
          x: e.x,
          y: e.y
        }
      ]);
      const r = this.editor.getShape(n);
      if (!r)
        throw Error("expected shape");
      const i = this.editor.getShapeHandles(r);
      if (!i)
        throw Error("expected handles for arrow");
      const s = this.editor.getShapeUtil("arrow"), o = i.find((l) => l.id === "start"), a = (_a3 = s.onHandleChange) == null ? void 0 : _a3.call(s, r, {
        handle: {
          ...o,
          x: 0,
          y: 0
        },
        isPrecise: true
      });
      if (a) {
        const l = (_b3 = a.props) == null ? void 0 : _b3.start;
        (l == null ? void 0 : l.type) === "binding" && this.editor.setHintingShapes([
          l.boundShapeId
        ]), this.editor.updateShapes([
          a
        ], {
          squashing: true
        });
      }
      this.shape = this.editor.getShape(n), this.editor.select(n);
    }
    updateArrowShapeEndHandle() {
      var _a3, _b3, _c3;
      const e = this.shape;
      if (!e)
        throw Error("expected shape");
      const n = this.editor.getShapeHandles(e);
      if (!n)
        throw Error("expected handles for arrow");
      const r = {
        ...e,
        props: {
          ...e.props,
          end: {
            ...e.props.end,
            x: 0,
            y: 0
          }
        }
      };
      {
        const i = this.editor.getShapeUtil("arrow"), s = this.editor.getPointInShapeSpace(e, this.editor.inputs.currentPagePoint), o = n.find((l) => l.id === "end"), a = (_a3 = i.onHandleChange) == null ? void 0 : _a3.call(i, r, {
          handle: {
            ...o,
            x: s.x,
            y: s.y
          },
          isPrecise: false
        });
        if (a) {
          const l = (_b3 = a.props) == null ? void 0 : _b3.end;
          (l == null ? void 0 : l.type) === "binding" && this.editor.setHintingShapes([
            l.boundShapeId
          ]), this.editor.updateShapes([
            a
          ], {
            squashing: true
          });
        }
      }
      {
        const i = this.editor.getShapeUtil("arrow"), s = n.find((a) => a.id === "start"), o = (_c3 = i.onHandleChange) == null ? void 0 : _c3.call(i, r, {
          handle: {
            ...s,
            x: 0,
            y: 0
          },
          isPrecise: this.didTimeout
        });
        o && this.editor.updateShapes([
          o
        ], {
          squashing: true
        });
      }
      this.shape = this.editor.getShape(e.id);
    }
    startPreciseTimeout() {
      this.preciseTimeout = window.setTimeout(() => {
        this.isActive && (this.didTimeout = true);
      }, 320);
    }
    clearPreciseTimeout() {
      clearTimeout(this.preciseTimeout);
    }
  }, __publicField(_d2, "id", "pointing"), _d2);
  class Rje extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeType", "arrow");
    }
  }
  __publicField(Rje, "id", "arrow");
  __publicField(Rje, "initial", "idle");
  __publicField(Rje, "children", () => [
    $je,
    Aje
  ]);
  class aee extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "initialShape");
      __publicField(this, "shapeType", this.parent.id === "highlight" ? "highlight" : "draw");
      __publicField(this, "util", this.editor.getShapeUtil(this.shapeType));
      __publicField(this, "isPen", false);
      __publicField(this, "segmentMode", "free");
      __publicField(this, "didJustShiftClickToExtendPreviousShapeLine", false);
      __publicField(this, "pagePointWhereCurrentSegmentChanged", {});
      __publicField(this, "pagePointWhereNextSegmentChanged", null);
      __publicField(this, "lastRecordedPoint", {});
      __publicField(this, "mergeNextPoint", false);
      __publicField(this, "currentLineLength", 0);
      __publicField(this, "canDraw", false);
      __publicField(this, "markId", null);
      __publicField(this, "onEnter", (e) => {
        this.markId = null, this.info = e, this.canDraw = !this.editor.isMenuOpen, this.lastRecordedPoint = this.editor.inputs.currentPagePoint.clone(), this.canDraw && this.startShape();
      });
      __publicField(this, "onPointerMove", () => {
        const { editor: { inputs: e } } = this;
        if (this.isPen !== e.isPen) {
          if (this.markId) {
            this.editor.bailToMark(this.markId), this.startShape();
            return;
          }
        } else
          !this.canDraw && e.isDragging && (this.startShape(), this.canDraw = true);
        this.canDraw && (e.isPen ? I.Dist(e.currentPagePoint, this.lastRecordedPoint) >= 1 / this.editor.zoomLevel ? (this.lastRecordedPoint = e.currentPagePoint.clone(), this.mergeNextPoint = false) : this.mergeNextPoint = true : this.mergeNextPoint = false, this.updateShapes());
      });
      __publicField(this, "onKeyDown", (e) => {
        if (e.key === "Shift")
          switch (this.segmentMode) {
            case "free": {
              this.segmentMode = "starting_straight", this.pagePointWhereNextSegmentChanged = this.editor.inputs.currentPagePoint.clone();
              break;
            }
            case "starting_free":
              this.segmentMode = "starting_straight";
          }
        this.updateShapes();
      });
      __publicField(this, "onKeyUp", (e) => {
        if (e.key === "Shift")
          switch (this.editor.snaps.clear(), this.segmentMode) {
            case "straight": {
              this.segmentMode = "starting_free", this.pagePointWhereNextSegmentChanged = this.editor.inputs.currentPagePoint.clone();
              break;
            }
            case "starting_straight": {
              this.pagePointWhereNextSegmentChanged = null, this.segmentMode = "free";
              break;
            }
          }
        this.updateShapes();
      });
      __publicField(this, "onExit", () => {
        this.editor.snaps.clear(), this.pagePointWhereCurrentSegmentChanged = this.editor.inputs.currentPagePoint.clone();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.editor.inputs.isDragging || (this.markId && this.editor.bailToMark(this.markId), this.cancel());
      });
    }
    canClose() {
      return this.shapeType !== "highlight";
    }
    getIsClosed(e, n) {
      if (!this.canClose())
        return false;
      const r = mi[n], i = e[0].points[0], s = e[e.length - 1], o = s.points[s.points.length - 1];
      return i !== o && this.currentLineLength > r * 4 && I.Dist(i, o) < r * 2;
    }
    startShape() {
      const { inputs: { originPagePoint: e, isPen: n } } = this.editor;
      this.markId = "draw start " + wn(), this.editor.mark(this.markId), this.isPen = n;
      const r = this.isPen ? this.info.point.z * 1.25 : 0.5;
      if (this.segmentMode = this.editor.inputs.shiftKey ? "straight" : "free", this.didJustShiftClickToExtendPreviousShapeLine = false, this.lastRecordedPoint = e.clone(), this.initialShape) {
        const s = this.editor.getShape(this.initialShape.id);
        if (s && this.segmentMode === "straight") {
          this.didJustShiftClickToExtendPreviousShapeLine = true;
          const o = as(s.props.segments);
          if (!o)
            throw Error("Expected a previous segment!");
          const a = as(o.points);
          if (!a)
            throw Error("Expected a previous point!");
          const { x: l, y: c } = this.editor.getPointInShapeSpace(s, e).toFixed(), u = this.isPen ? this.info.point.z * 1.25 : 0.5, d = {
            type: this.segmentMode,
            points: [
              {
                x: a.x,
                y: a.y,
                z: +u.toFixed(2)
              },
              {
                x: l,
                y: c,
                z: +u.toFixed(2)
              }
            ]
          }, h = Se.applyToPoint(this.editor.getShapePageTransform(s.id), a);
          this.pagePointWhereCurrentSegmentChanged = h, this.pagePointWhereNextSegmentChanged = null;
          const f = [
            ...s.props.segments,
            d
          ];
          this.currentLineLength = this.getLineLength(f);
          const y = {
            id: s.id,
            type: this.shapeType,
            props: {
              segments: f
            }
          };
          this.canClose() && (y.props.isClosed = this.getIsClosed(f, s.props.size)), this.editor.updateShapes([
            y
          ]);
          return;
        }
      }
      this.pagePointWhereCurrentSegmentChanged = e.clone();
      const i = bn();
      this.editor.createShapes([
        {
          id: i,
          type: this.shapeType,
          x: e.x,
          y: e.y,
          props: {
            isPen: this.isPen,
            segments: [
              {
                type: this.segmentMode,
                points: [
                  {
                    x: 0,
                    y: 0,
                    z: +r.toFixed(2)
                  }
                ]
              }
            ]
          }
        }
      ]), this.currentLineLength = 0, this.initialShape = this.editor.getShape(i);
    }
    updateShapes() {
      const { inputs: e } = this.editor, { initialShape: n } = this;
      if (!n)
        return;
      const { id: r, props: { size: i } } = n, s = this.editor.getShape(r);
      if (!s)
        return;
      const { segments: o } = s.props, { x: a, y: l, z: c } = this.editor.getPointInShapeSpace(s, e.currentPagePoint).toFixed(), u = {
        x: a,
        y: l,
        z: this.isPen ? +(c * 1.25).toFixed(2) : 0.5
      };
      switch (this.segmentMode) {
        case "starting_straight": {
          const { pagePointWhereNextSegmentChanged: d } = this;
          if (d === null)
            throw Error("We should have a point where the segment changed");
          if (I.Dist(d, e.currentPagePoint) > Zv) {
            this.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged.clone(), this.pagePointWhereNextSegmentChanged = null, this.segmentMode = "straight";
            const f = as(o);
            if (!f)
              throw Error("Expected a previous segment!");
            const y = as(f.points);
            if (!y)
              throw Error("Expected a previous last point!");
            let g;
            const O = this.editor.getPointInShapeSpace(s, this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();
            if (f.type === "straight") {
              this.currentLineLength += I.Dist(y, O), g = {
                type: "straight",
                points: [
                  {
                    ...y
                  },
                  O
                ]
              };
              const w = this.editor.getShapePageTransform(s);
              this.pagePointWhereCurrentSegmentChanged = Se.applyToPoint(w, y);
            } else
              g = {
                type: "straight",
                points: [
                  O,
                  u
                ]
              };
            const S = {
              id: r,
              type: this.shapeType,
              props: {
                segments: [
                  ...o,
                  g
                ]
              }
            };
            this.canClose() && (S.props.isClosed = this.getIsClosed(o, i)), this.editor.updateShapes([
              S
            ], {
              squashing: true
            });
          }
          break;
        }
        case "starting_free": {
          const { pagePointWhereNextSegmentChanged: d } = this;
          if (d === null)
            throw Error("We should have a point where the segment changed");
          if (I.Dist(d, e.currentPagePoint) > Zv) {
            this.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged.clone(), this.pagePointWhereNextSegmentChanged = null, this.segmentMode = "free";
            const f = o.slice(), y = f[f.length - 1], g = as(y.points);
            if (!g)
              throw Error("No previous point!");
            const O = {
              type: "free",
              points: [
                ...I.PointsBetween(g, u, 6).map((x) => x.toFixed().toJson())
              ]
            }, S = [
              ...f,
              O
            ];
            this.currentLineLength = this.getLineLength(S);
            const w = {
              id: r,
              type: this.shapeType,
              props: {
                segments: S
              }
            };
            this.canClose() && (w.props.isClosed = this.getIsClosed(S, i)), this.editor.updateShapes([
              w
            ], {
              squashing: true
            });
          }
          break;
        }
        case "straight": {
          const d = o.slice(), h = d[d.length - 1], { pagePointWhereCurrentSegmentChanged: f } = this, { currentPagePoint: y, ctrlKey: g } = this.editor.inputs;
          if (!f)
            throw Error("We should have a point where the segment changed");
          let O, S = false;
          this.didJustShiftClickToExtendPreviousShapeLine ? this.editor.inputs.isDragging && (S = !g, this.didJustShiftClickToExtendPreviousShapeLine = false) : S = !g;
          let w = this.editor.getPointInShapeSpace(s, y).toFixed().toJson(), x = false, P;
          if ((this.editor.user.isSnapMode ? !g : g) && d.length > 2) {
            let T, $ = 8 / this.editor.zoomLevel;
            for (let N = 0, L = o.length - 2; N < L; N++) {
              const z = o[N];
              if (!z)
                break;
              if (z.type === "free")
                continue;
              const M = z.points[0], R = as(z.points);
              if (!(M && R))
                continue;
              const F = I.NearestPointOnLineSegment(M, R, w), Q = I.Dist(F, w);
              if (Q < $) {
                T = F.toFixed().toJson(), $ = Q, P = z;
                break;
              }
            }
            T && (x = true, w = T);
          }
          if (x && P) {
            const T = this.editor.getShapePageTransform(s), $ = P.points[0], N = as(P.points);
            if (!N)
              throw Error("Expected a last point!");
            const L = Se.applyToPoint(T, $), z = Se.applyToPoint(T, N), M = Se.applyToPoint(T, w);
            this.editor.snaps.setLines([
              {
                id: wn(),
                type: "points",
                points: [
                  L,
                  M,
                  z
                ]
              }
            ]);
          } else {
            if (this.editor.snaps.clear(), S) {
              const T = I.Angle(f, y), N = kk(T, 24) - T;
              O = I.RotWith(y, f, N);
            } else
              O = y;
            w = this.editor.getPointInShapeSpace(s, O).toFixed().toJson();
          }
          this.currentLineLength += I.Dist(h.points[0], w), d[d.length - 1] = {
            ...h,
            type: "straight",
            points: [
              h.points[0],
              w
            ]
          };
          const _ = {
            id: r,
            type: this.shapeType,
            props: {
              segments: d
            }
          };
          this.canClose() && (_.props.isClosed = this.getIsClosed(o, i)), this.editor.updateShapes([
            _
          ], {
            squashing: true
          });
          break;
        }
        case "free": {
          const d = o.slice(), h = d[d.length - 1], f = [
            ...h.points
          ];
          if (f.length && this.mergeNextPoint) {
            const { z: g } = f[f.length - 1];
            f[f.length - 1] = {
              x: u.x,
              y: u.y,
              z: g ? Math.max(g, u.z) : u.z
            };
          } else
            this.currentLineLength += I.Dist(f[f.length - 1], u), f.push(u);
          d[d.length - 1] = {
            ...h,
            points: f
          }, this.currentLineLength = this.getLineLength(d);
          const y = {
            id: r,
            type: this.shapeType,
            props: {
              segments: d
            }
          };
          if (this.canClose() && (y.props.isClosed = this.getIsClosed(d, i)), this.editor.updateShapes([
            y
          ], {
            squashing: true
          }), f.length > 500) {
            this.editor.updateShapes([
              {
                id: r,
                type: this.shapeType,
                props: {
                  isComplete: true
                }
              }
            ]);
            const { currentPagePoint: g } = this.editor.inputs, O = bn();
            this.editor.createShapes([
              {
                id: O,
                type: this.shapeType,
                x: Pk(g.x),
                y: Pk(g.y),
                props: {
                  isPen: this.isPen,
                  segments: [
                    {
                      type: "free",
                      points: [
                        {
                          x: 0,
                          y: 0,
                          z: this.isPen ? +(c * 1.25).toFixed() : 0.5
                        }
                      ]
                    }
                  ]
                }
              }
            ]), this.initialShape = structuredClone(this.editor.getShape(O)), this.mergeNextPoint = false, this.lastRecordedPoint = this.editor.inputs.currentPagePoint.clone(), this.currentLineLength = 0;
          }
          break;
        }
      }
    }
    getLineLength(e) {
      let n = 0;
      for (const r of e)
        for (let i = 0; i < r.points.length - 1; i++) {
          const s = r.points[i], o = r.points[i + 1];
          n += I.Sub(o, s).len2();
        }
      return Math.sqrt(n);
    }
    complete() {
      if (!this.canDraw) {
        this.cancel();
        return;
      }
      const { initialShape: e } = this;
      e && (this.editor.updateShapes([
        {
          id: e.id,
          type: e.type,
          props: {
            isComplete: true
          }
        }
      ]), this.parent.transition("idle", {}));
    }
    cancel() {
      this.parent.transition("idle", this.info);
    }
  }
  __publicField(aee, "id", "drawing");
  let lee = (_e2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("drawing", e);
      });
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
    }
  }, __publicField(_e2, "id", "idle"), _e2);
  class Mje extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeType", "draw");
      __publicField(this, "onExit", () => {
        const e = this.children.drawing;
        e.initialShape = void 0;
      });
    }
  }
  __publicField(Mje, "id", "draw");
  __publicField(Mje, "initial", "idle");
  __publicField(Mje, "children", () => [
    lee,
    aee
  ]);
  class Dje extends cEe {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeType", "frame");
    }
  }
  __publicField(Dje, "id", "frame");
  __publicField(Dje, "initial", "idle");
  let Lje = (_f2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("pointing", e);
      });
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
      __publicField(this, "onKeyUp", (e) => {
        if (e.key === "Enter") {
          if (this.editor.instanceState.isReadonly)
            return null;
          const { onlySelectedShape: n } = this.editor;
          n && this.editor.getShapeUtil(n).canEdit(n) && (this.editor.setCurrentTool("select"), this.editor.setEditingShape(n.id), this.editor.root.current.value.transition("editing_shape", {
            ...e,
            target: "shape",
            shape: n
          }));
        }
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
    }
  }, __publicField(_f2, "id", "idle"), _f2), jje = (_g2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "markId", "");
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onPointerMove", (e) => {
        if (this.editor.inputs.isDragging) {
          const { originPagePoint: n } = this.editor.inputs, r = bn();
          this.markId = `creating:${r}`, this.editor.mark(this.markId), this.editor.createShapes([
            {
              id: r,
              type: "geo",
              x: n.x,
              y: n.y,
              props: {
                w: 1,
                h: 1,
                geo: this.editor.getStyleForNextShape(Al)
              }
            }
          ]).select(r).setCurrentTool("select.resizing", {
            ...e,
            target: "selection",
            handle: "bottom_right",
            isCreating: true,
            creationCursorOffset: {
              x: 1,
              y: 1
            },
            onInteractionEnd: "geo"
          });
        }
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    complete() {
      const { originPagePoint: e } = this.editor.inputs, n = bn();
      this.markId = `creating:${n}`, this.editor.mark(this.markId), this.editor.createShapes([
        {
          id: n,
          type: "geo",
          x: e.x,
          y: e.y,
          props: {
            geo: this.editor.getStyleForNextShape(Al),
            w: 1,
            h: 1
          }
        }
      ]);
      const r = this.editor.getShape(n);
      if (!r)
        return;
      const i = r.props.geo === "star" ? hke(5, 200, 200) : r.props.geo === "cloud" ? new Te(0, 0, 300, 180) : new Te(0, 0, 200, 200), s = i.center, o = this.editor.getShapeParentTransform(r);
      o && s.rot(-o.rotation()), this.editor.select(n), this.editor.updateShapes([
        {
          id: r.id,
          type: "geo",
          x: r.x - s.x,
          y: r.y - s.y,
          props: {
            geo: this.editor.getStyleForNextShape(Al),
            w: i.width,
            h: i.height
          }
        }
      ]), this.editor.instanceState.isToolLocked ? this.parent.transition("idle", {}) : this.editor.setCurrentTool("select", {});
    }
    cancel() {
      this.parent.transition("idle", {});
    }
  }, __publicField(_g2, "id", "pointing"), _g2);
  class Nje extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeType", "geo");
    }
  }
  __publicField(Nje, "id", "geo");
  __publicField(Nje, "initial", "idle");
  __publicField(Nje, "children", () => [
    Lje,
    jje
  ]);
  class Qje extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeType", "highlight");
      __publicField(this, "onExit", () => {
        const e = this.children.drawing;
        e.initialShape = void 0;
      });
    }
  }
  __publicField(Qje, "id", "highlight");
  __publicField(Qje, "initial", "idle");
  __publicField(Qje, "children", () => [
    lee,
    aee
  ]);
  let zje = (_h2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeId", "");
      __publicField(this, "onEnter", (e) => {
        this.shapeId = e.shapeId, this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
      __publicField(this, "onPointerDown", () => {
        this.parent.transition("pointing", {
          shapeId: this.shapeId
        });
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
    }
  }, __publicField(_h2, "id", "idle"), _h2);
  const a7 = 2;
  let Fje = (_i2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shape", {});
      __publicField(this, "markId");
      __publicField(this, "onEnter", (e) => {
        const { inputs: n } = this.editor, { currentPagePoint: r } = n;
        this.markId = void 0;
        const i = e.shapeId && this.editor.getShape(e.shapeId);
        if (i && n.shiftKey) {
          this.markId = `creating:${i.id}`, this.editor.mark(this.markId), this.shape = i;
          const s = this.editor.getShapeHandles(this.shape);
          if (!s)
            return;
          const o = s.filter((g) => g.type === "vertex").sort(hi), a = o[o.length - 1], l = o[o.length - 2], c = Se.applyToPoint(this.editor.getShapeParentTransform(this.shape), new I(this.shape.x, this.shape.y));
          let u, d, h;
          const f = I.Sub(r, c);
          I.Dist(a, l) < a7 || I.Dist(f, a) < a7 ? (u = a.index, d = a.id, h = {
            ...a,
            x: f.x + 0.1,
            y: f.y + 0.1
          }) : (u = wc(a.index), d = "handle:" + u, h = {
            id: d,
            type: "vertex",
            index: u,
            x: f.x + 0.1,
            y: f.y + 0.1,
            canBind: false
          });
          const y = Dc(this.shape.props.handles);
          y[h.id] = h, this.editor.updateShapes([
            {
              id: this.shape.id,
              type: this.shape.type,
              props: {
                handles: y
              }
            }
          ]);
        } else {
          const s = bn();
          this.markId = `creating:${s}`, this.editor.mark(this.markId), this.editor.createShapes([
            {
              id: s,
              type: "line",
              x: r.x,
              y: r.y
            }
          ]), this.editor.select(s), this.shape = this.editor.getShape(s);
        }
      });
      __publicField(this, "onPointerMove", () => {
        if (this.shape && this.editor.inputs.isDragging) {
          const e = this.editor.getShapeHandles(this.shape);
          if (!e)
            throw this.markId && this.editor.bailToMark(this.markId), Error("No handles found");
          const n = as(e);
          this.editor.setCurrentTool("select.dragging_handle", {
            shape: this.shape,
            isCreating: true,
            handle: {
              ...n,
              x: n.x - 0.1,
              y: n.y - 0.1
            },
            onInteractionEnd: "line"
          });
        }
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.parent.transition("idle", {}), this.markId && this.editor.bailToMark(this.markId), this.editor.snaps.clear();
      });
    }
    complete() {
      this.parent.transition("idle", {
        shapeId: this.shape.id
      }), this.editor.snaps.clear();
    }
    cancel() {
      this.markId && this.editor.bailToMark(this.markId), this.parent.transition("idle", {
        shapeId: this.shape.id
      }), this.editor.snaps.clear();
    }
  }, __publicField(_i2, "id", "pointing"), _i2);
  class Bje extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeType", "line");
    }
  }
  __publicField(Bje, "id", "line");
  __publicField(Bje, "initial", "idle");
  __publicField(Bje, "children", () => [
    zje,
    Fje
  ]);
  let Uje = (_j2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("pointing", e);
      });
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
    }
  }, __publicField(_j2, "id", "idle"), _j2), Vje = (_k2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "dragged", false);
      __publicField(this, "info", {});
      __publicField(this, "wasFocusedOnEnter", false);
      __publicField(this, "markId", "");
      __publicField(this, "shape", {});
      __publicField(this, "onEnter", () => {
        this.wasFocusedOnEnter = !this.editor.isMenuOpen, this.wasFocusedOnEnter && (this.shape = this.createShape());
      });
      __publicField(this, "onPointerMove", (e) => {
        this.editor.inputs.isDragging && (this.wasFocusedOnEnter || (this.shape = this.createShape()), this.editor.setCurrentTool("select.translating", {
          ...e,
          target: "shape",
          shape: this.shape,
          isCreating: true,
          editAfterComplete: true,
          onInteractionEnd: "note"
        }));
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
    }
    complete() {
      this.wasFocusedOnEnter && (this.editor.instanceState.isToolLocked ? this.parent.transition("idle", {}) : (this.editor.setEditingShape(this.shape.id), this.editor.setCurrentTool("select.editing_shape", {
        ...this.info,
        target: "shape",
        shape: this.shape
      })));
    }
    cancel() {
      this.editor.bailToMark(this.markId), this.parent.transition("idle", this.info);
    }
    createShape() {
      const { inputs: { originPagePoint: e } } = this.editor, n = bn();
      this.markId = `creating:${n}`, this.editor.mark(this.markId), this.editor.createShapes([
        {
          id: n,
          type: "note",
          x: e.x,
          y: e.y
        }
      ]).select(n);
      const r = this.editor.getShape(n), i = this.editor.getShapeGeometry(r).bounds;
      return this.editor.updateShapes([
        {
          id: n,
          type: "note",
          x: r.x - i.width / 2,
          y: r.y - i.height / 2
        }
      ]), this.editor.getShape(n);
    }
  }, __publicField(_k2, "id", "pointing"), _k2);
  class Xje extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeType", "note");
    }
  }
  __publicField(Xje, "id", "note");
  __publicField(Xje, "initial", "idle");
  __publicField(Xje, "children", () => [
    Uje,
    Vje
  ]);
  function nO(t) {
    const e = t.getShapeAtPoint(t.inputs.currentPagePoint, {
      hitInside: false,
      hitLabels: false,
      margin: Va / t.zoomLevel,
      renderingOnly: true
    });
    if (!e)
      return t.setHoveredShape(null);
    let n;
    const r = t.getOutermostSelectableShape(e);
    return r === e || r.id === t.focusedGroupId || t.selectedShapeIds.includes(r.id) ? n = e : n = r, t.setHoveredShape(n.id);
  }
  let Wje = (_l2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onPointerMove", (e) => {
        switch (e.target) {
          case "shape":
          case "canvas":
            nO(this.editor);
        }
      });
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("pointing", e);
      });
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
      __publicField(this, "onKeyDown", (e) => {
        if (e.key === "Enter") {
          if (this.editor.instanceState.isReadonly)
            return null;
          const { onlySelectedShape: n } = this.editor;
          n && this.editor.getShapeUtil(n).canEdit(n) && (this.editor.setCurrentTool("select"), this.editor.setEditingShape(n.id), this.editor.root.current.value.transition("editing_shape", {
            ...e,
            target: "shape",
            shape: n
          }));
        }
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
    }
  }, __publicField(_l2, "id", "idle"), _l2), Zje = (_m2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shape");
      __publicField(this, "markId", "");
      __publicField(this, "onExit", () => {
        this.editor.setHintingShapes([]);
      });
      __publicField(this, "onPointerMove", (e) => {
        if (this.editor.inputs.isDragging) {
          const { inputs: { originPagePoint: n } } = this.editor, r = bn();
          if (this.markId = `creating:${r}`, this.editor.mark(this.markId), this.editor.createShapes([
            {
              id: r,
              type: "text",
              x: n.x,
              y: n.y,
              props: {
                text: "",
                autoSize: false,
                w: 20
              }
            }
          ]), this.editor.select(r), this.shape = this.editor.getShape(r), !this.shape)
            return;
          this.editor.setCurrentTool("select.resizing", {
            ...e,
            target: "selection",
            handle: "right",
            isCreating: true,
            creationCursorOffset: {
              x: 1,
              y: 1
            },
            editAfterComplete: true,
            onInteractionEnd: "text"
          });
        }
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.cancel();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    complete() {
      var _a3;
      this.editor.mark("creating text shape");
      const e = bn(), { x: n, y: r } = this.editor.inputs.currentPagePoint;
      this.editor.createShapes([
        {
          id: e,
          type: "text",
          x: n,
          y: r,
          props: {
            text: "",
            autoSize: true
          }
        }
      ]).select(e), this.editor.setEditingShape(e), this.editor.setCurrentTool("select"), (_a3 = this.editor.root.current.value) == null ? void 0 : _a3.transition("editing_shape", {});
    }
    cancel() {
      this.parent.transition("idle", {}), this.editor.bailToMark(this.markId);
    }
  }, __publicField(_m2, "id", "pointing"), _m2);
  class Hje extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeType", "text");
    }
  }
  __publicField(Hje, "id", "text");
  __publicField(Hje, "initial", "idle");
  __publicField(Hje, "children", () => [
    Wje,
    Zje
  ]);
  const Yje = [
    Hje,
    Mje,
    Nje,
    Xje,
    Bje,
    Dje,
    Rje,
    Qje
  ];
  function Ir() {
    return ks({
      isDarkMode: $C()
    });
  }
  const qn = $e.memo(function({ theme: e, d: n, color: r, fill: i }) {
    switch (i) {
      case "none":
        return null;
      case "solid":
        return m.jsx("path", {
          fill: e[r].semi,
          d: n
        });
      case "semi":
        return m.jsx("path", {
          fill: e.solid,
          d: n
        });
      case "pattern":
        return m.jsx(Gje, {
          theme: e,
          color: r,
          fill: i,
          d: n
        });
    }
  }), Gje = function({ d: e, color: n, theme: r }) {
    const i = ue(), s = ye("zoomLevel", () => i.zoomLevel, [
      i
    ]), o = Math.ceil(s), a = i.zoomLevel <= 0.18;
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx("path", {
          fill: r[n].pattern,
          d: e
        }),
        m.jsx("path", {
          fill: a ? r[n].semi : `url(#${_k[`${o}_${r.id}`]})`,
          d: e
        })
      ]
    });
  };
  function ho({ d: t, color: e, fill: n, theme: r }) {
    if (n === "none")
      return;
    if (n === "pattern") {
      const s = document.createElementNS("http://www.w3.org/2000/svg", "g"), o = document.createElementNS("http://www.w3.org/2000/svg", "path");
      o.setAttribute("d", t), o.setAttribute("fill", r[e].pattern);
      const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
      return a.setAttribute("d", t), a.setAttribute("fill", "url(#hash_pattern)"), s.appendChild(o), s.appendChild(a), s;
    }
    const i = document.createElementNS("http://www.w3.org/2000/svg", "path");
    switch (i.setAttribute("d", t), n) {
      case "semi": {
        i.setAttribute("fill", r.solid);
        break;
      }
      case "solid": {
        i.setAttribute("fill", r[e].semi);
        break;
      }
    }
    return i;
  }
  function qa(t, e) {
    if (e) {
      const n = document.createElementNS("http://www.w3.org/2000/svg", "g");
      return n.appendChild(e), n.appendChild(t), n;
    } else
      return t;
  }
  function qje(t) {
    return t.replace(/\s/g, "\xA0");
  }
  function s2(t, e, n) {
    const { padding: r = 0 } = n, i = document.createElementNS("http://www.w3.org/2000/svg", "text");
    if (i.setAttribute("font-size", n.fontSize + "px"), i.setAttribute("font-family", n.fontFamily), i.setAttribute("font-style", n.fontStyle), i.setAttribute("font-weight", n.fontWeight), i.setAttribute("line-height", n.lineHeight * n.fontSize + "px"), i.setAttribute("dominant-baseline", "mathematical"), i.setAttribute("alignment-baseline", "mathematical"), e.length === 0)
      return i;
    const s = Te.From(e[0].box);
    for (const { box: c } of e)
      s.union(c);
    const o = r + (n.offsetX ?? 0), a = (n.offsetY ?? 0) + n.fontSize / 2 + (n.verticalTextAlign === "start" ? r : n.verticalTextAlign === "end" ? n.height - r - s.height : (Math.ceil(n.height) - s.height) / 2);
    let l = null;
    for (const { text: c, box: u } of e) {
      if (l !== null && u.y > l) {
        const y = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
        y.setAttribute("alignment-baseline", "mathematical"), y.setAttribute("x", o + "px"), y.setAttribute("y", u.y + a + "px"), y.textContent = `
`, i.appendChild(y);
      }
      const h = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
      h.setAttribute("alignment-baseline", "mathematical"), h.setAttribute("x", u.x + o + "px"), h.setAttribute("y", u.y + a + "px");
      const f = qje(c);
      h.textContent = f, i.appendChild(h), l = u.y;
    }
    return n.stroke && n.strokeWidth && (i.setAttribute("stroke", n.stroke), i.setAttribute("stroke-width", n.strokeWidth + "px")), n.fill && i.setAttribute("fill", n.fill), i;
  }
  function o2(t) {
    return {
      key: `${jl.id}:${t}`,
      getElement: async () => {
        const e = Kje(t);
        if (!e)
          return null;
        const n = e.$$_url, r = e.$$_fontface;
        if (!n || !r)
          return null;
        const i = await (await fetch(n)).blob(), s = await new Promise((l, c) => {
          const u = new FileReader();
          u.onload = () => l(u.result), u.onerror = c, u.readAsDataURL(i);
        }), o = r.replace(n, s), a = document.createElementNS("http://www.w3.org/2000/svg", "style");
        return a.textContent = o, a;
      }
    };
  }
  function Kje(t) {
    const e = GO[t];
    for (const n of document.fonts)
      if (e.includes(n.family))
        return n;
    return null;
  }
  function PL(t, e) {
    return {
      key: `${jl.id}:${t}`,
      getElement: async () => {
        if (t !== "pattern")
          return null;
        const n = 8 / 12, r = document.createElement("div");
        return r.innerHTML = `
				<svg>
					<defs>
						<mask id="hash_pattern_mask">
							<rect x="0" y="0" width="8" height="8" fill="white" />
							<g
								strokeLinecap="round"
								stroke="black"
							>
								<line x1="${n * 1}" y1="${n * 3}" x2="${n * 3}" y2="${n * 1}" />
								<line x1="${n * 5}" y1="${n * 7}" x2="${n * 7}" y2="${n * 5}" />
								<line x1="${n * 9}" y1="${n * 11}" x2="${n * 11}" y2="${n * 9}" />
							</g>
						</mask>
						<pattern
							id="hash_pattern"
							width="8"
							height="8"
							patternUnits="userSpaceOnUse"
						>
							<rect x="0" y="0" width="8" height="8" fill="${e.solid}" mask="url(#hash_pattern_mask)" />
						</pattern>
					</defs>
				</svg>
			`, Array.from(r.querySelectorAll("defs > *"));
      }
    };
  }
  function CL() {
    return {
      key: `${jl.id}:pattern`,
      component: tNe
    };
  }
  const w0 = 8, l7 = (t, e, n) => new Promise((r, i) => {
    const s = w0 * e * t, o = document.createElement("canvas");
    o.width = s, o.height = s;
    const a = o.getContext("2d");
    if (!a)
      return;
    a.fillStyle = n ? "#212529" : "#f8f9fa", a.fillRect(0, 0, s, s), a.globalCompositeOperation = "destination-out", a.lineCap = "round", a.lineWidth = 1.25 * e * t;
    const l = 8 / 12, c = (u) => u * e * t;
    a.beginPath(), a.moveTo(c(l * 1), c(l * 3)), a.lineTo(c(l * 3), c(l * 1)), a.moveTo(c(l * 5), c(l * 7)), a.lineTo(c(l * 7), c(l * 5)), a.moveTo(c(l * 9), c(l * 11)), a.lineTo(c(l * 11), c(l * 9)), a.stroke(), o.toBlob((u) => {
      !u || un.throwToBlob.value ? i() : r(u);
    });
  }), c7 = (t, e) => {
    const n = document.createElement("canvas");
    n.width = t[0], n.height = t[1];
    const r = n.getContext("2d");
    return r ? (e(r), n.toDataURL()) : "";
  }, Jje = () => {
    const t = [];
    for (let e = 1; e <= Math.ceil(Fu); e++) {
      const n = c7([
        1,
        1
      ], (i) => {
        i.fillStyle = vk.lightMode.black.semi, i.fillRect(0, 0, 1, 1);
      }), r = c7([
        1,
        1
      ], (i) => {
        i.fillStyle = vk.darkMode.black.semi, i.fillRect(0, 0, 1, 1);
      });
      t.push({
        zoom: e,
        url: n,
        darkMode: false
      }), t.push({
        zoom: e,
        url: r,
        darkMode: true
      });
    }
    return t;
  };
  function eNe() {
    const e = ue().instanceState.devicePixelRatio, [n, r] = b.useState(false), i = b.useMemo(() => Jje(), []), [s, o] = b.useState(i);
    return b.useEffect(() => {
      const l = [];
      for (let u = 1; u <= Math.ceil(Fu); u++)
        l.push(l7(e, u, false).then((d) => ({
          zoom: u,
          url: URL.createObjectURL(d),
          darkMode: false
        }))), l.push(l7(e, u, true).then((d) => ({
          zoom: u,
          url: URL.createObjectURL(d),
          darkMode: true
        })));
      let c = false;
      return Promise.all(l).then((u) => {
        c || (o(u), r(true));
      }), () => {
        c = true, r(false);
      };
    }, [
      e
    ]), {
      defs: m.jsx(m.Fragment, {
        children: s.map((l) => {
          const c = l.zoom + (l.darkMode ? "_dark" : "_light");
          return m.jsx("pattern", {
            id: _k[c],
            width: w0,
            height: w0,
            patternUnits: "userSpaceOnUse",
            children: m.jsx("image", {
              href: l.url,
              width: w0,
              height: w0
            })
          }, c);
        })
      }),
      isReady: n
    };
  }
  function tNe() {
    const t = ue(), e = b.useRef(null), { defs: n, isReady: r } = eNe();
    return b.useEffect(() => {
      if (r && t.environment.isSafari) {
        const i = cee(e.current);
        i && requestAnimationFrame(() => {
          i.style.display = "none", requestAnimationFrame(() => {
            i.style.display = "";
          });
        });
      }
    }, [
      t,
      r
    ]), m.jsx("g", {
      ref: e,
      children: n
    });
  }
  function cee(t) {
    return t.classList.contains("tl-html-layer") ? t : t.parentElement ? cee(t.parentElement) : null;
  }
  function xi(t, e, n = {}) {
    const { closed: r = false, snap: i = 1, start: s = "outset", end: o = "outset", lengthRatio: a = 2, style: l = "dashed" } = n;
    let c = 0, u = 0, d = 1, h = 0, f = 0;
    switch (l) {
      case "dashed": {
        d = 1, c = Math.min(e * a, t / 4);
        break;
      }
      case "dotted": {
        d = 100, c = e / d;
        break;
      }
      default:
        return {
          strokeDasharray: "none",
          strokeDashoffset: "none"
        };
    }
    return r || (s === "outset" ? (t += c / 2, f += c / 2) : s === "skip" && (t -= c, f -= c), o === "outset" ? t += c / 2 : o === "skip" && (t -= c)), u = Math.floor(t / c / (2 * d)), u -= u % i, u < 3 && l === "dashed" ? t / e < 5 ? (c = t, u = 1, h = 0) : (c = t * 0.333, h = t * 0.333) : (u = Math.max(u, 3), c = t / u / (2 * d), r ? (f = c / 2, h = (t - u * c) / u) : h = (t - u * c) / Math.max(1, u - 1)), {
      strokeDasharray: [
        c,
        h
      ].join(" "),
      strokeDashoffset: f.toString()
    };
  }
  function _L(t, e, n) {
    const r = ue(), i = b.useRef(null), s = b.useRef(false), o = b.useRef(), a = ye("isEditing", () => r.editingShapeId === t, [
      r,
      t
    ]);
    b.useEffect(() => {
      const g = i.current;
      g && a && document.activeElement !== g && g.focus();
    }, [
      a
    ]);
    const l = b.useCallback(() => {
      const g = s.current;
      s.current = false, requestAnimationFrame(() => {
        const O = i.current;
        if (!O)
          return;
        const S = r.getShape(t);
        S && (O.value = S.props.text, O.value.length && !g && O.select());
      });
    }, [
      r,
      t
    ]), c = b.useCallback(() => {
      const g = o.current;
      requestAnimationFrame(() => {
        var _a3;
        const O = i.current, { editingShapeId: S } = r;
        if (O && S) {
          if (S === t)
            if (g)
              if (!g.length)
                O.focus();
              else {
                s.current = true, O.focus();
                const w = window.getSelection();
                w && g.forEach((x) => w.addRange(x));
              }
            else
              O.focus();
        } else
          (_a3 = window.getSelection()) == null ? void 0 : _a3.removeAllRanges(), r.complete();
      });
    }, [
      r,
      t
    ]), u = b.useCallback((g) => {
      if (a)
        switch ((g.ctrlKey || g.metaKey) && _r(g), g.key) {
          case "Enter": {
            (g.ctrlKey || g.metaKey) && r.complete();
            break;
          }
          case "Tab": {
            Rt(g), g.shiftKey ? pr.unindent(g.currentTarget) : pr.indent(g.currentTarget);
            break;
          }
        }
    }, [
      r,
      a
    ]), d = b.useCallback((g) => {
      if (!a)
        return;
      let O = pr.normalizeText(g.currentTarget.value);
      const S = O.replace(/\t/g, ng);
      if (S !== O) {
        const w = g.currentTarget.selectionStart;
        g.currentTarget.value = S, g.currentTarget.selectionStart = w + (S.length - O.length), g.currentTarget.selectionEnd = w + (S.length - O.length), O = S;
      }
      r.updateShapes([
        {
          id: t,
          type: e,
          props: {
            text: O
          }
        }
      ]);
    }, [
      r,
      t,
      e,
      a
    ]), h = n.trim().length === 0;
    b.useEffect(() => {
      if (!a)
        return;
      if (i.current) {
        let O = function() {
          var _a3, _b3;
          const S = (_a3 = window.getSelection) == null ? void 0 : _a3.call(window);
          if (S && S.type !== "None") {
            const w = [];
            if (S)
              for (let x = 0; x < S.rangeCount; x++)
                w.push((_b3 = S.getRangeAt) == null ? void 0 : _b3.call(S, x));
            o.current = w;
          }
        };
        return document.addEventListener("selectionchange", O), () => {
          document.removeEventListener("selectionchange", O);
        };
      }
    }, [
      a
    ]);
    const f = b.useCallback((g) => {
      r.dispatch({
        ...ps(g),
        type: "pointer",
        name: "pointer_down",
        target: "shape",
        shape: r.getShape(t)
      }), _r(g);
    }, [
      r,
      t
    ]);
    return {
      rInput: i,
      isEditing: a,
      handleFocus: l,
      handleBlur: c,
      handleKeyDown: u,
      handleChange: d,
      handleInputPointerDown: f,
      handleDoubleClick: _r,
      isEmpty: h
    };
  }
  const nNe = b.memo(function({ id: e, text: n, size: r, font: i, position: s, width: o, labelColor: a }) {
    const { rInput: l, isEditing: c, handleFocus: u, handleBlur: d, handleKeyDown: h, handleChange: f, isEmpty: y, handleInputPointerDown: g, handleDoubleClick: O } = _L(e, "arrow", n), w = pr.normalizeTextForDom(n).trim().length > 0;
    return !c && !w ? null : m.jsx("div", {
      className: "tl-arrow-label",
      "data-font": i,
      "data-align": "center",
      "data-hastext": !y,
      "data-isediting": c,
      style: {
        textAlign: "center",
        fontSize: Du[r],
        lineHeight: Du[r] * Wr.lineHeight + "px",
        transform: `translate(${s.x}px, ${s.y}px)`,
        color: a
      },
      children: m.jsxs("div", {
        className: "tl-arrow-label__inner",
        children: [
          m.jsx("p", {
            style: {
              width: o || "9px"
            },
            children: n ? pr.normalizeTextForDom(n) : " "
          }),
          c && m.jsx("textarea", {
            ref: l,
            className: "tl-text tl-text-input",
            name: "text",
            tabIndex: -1,
            autoComplete: "false",
            autoCapitalize: "false",
            autoCorrect: "false",
            autoSave: "false",
            autoFocus: true,
            placeholder: "",
            spellCheck: "true",
            wrap: "off",
            dir: "auto",
            datatype: "wysiwyg",
            defaultValue: n,
            onFocus: u,
            onChange: f,
            onKeyDown: h,
            onBlur: d,
            onContextMenu: _r,
            onPointerDown: g,
            onDoubleClick: O
          })
        ]
      })
    });
  });
  let rNe = 0;
  class iNe extends Nd {
    constructor() {
      super(...arguments);
      __publicField(this, "canEdit", () => true);
      __publicField(this, "canBind", () => false);
      __publicField(this, "canSnap", () => false);
      __publicField(this, "hideResizeHandles", () => true);
      __publicField(this, "hideRotateHandle", () => true);
      __publicField(this, "hideSelectionBoundsBg", () => true);
      __publicField(this, "hideSelectionBoundsFg", () => true);
      __publicField(this, "onHandleChange", (e, { handle: n, isPrecise: r }) => {
        const i = n.id;
        if (i === "middle") {
          const { start: y, end: g } = Ia(this.editor, e), O = I.Sub(g, y), S = I.Per(O), w = I.Med(g, y), x = I.Sub(w, S), P = I.Add(w, S), C = I.NearestPointOnLineSegment(x, P, n, false);
          let _ = I.Dist(C, w);
          return I.Clockwise(C, g, w) && (_ *= -1), {
            id: e.id,
            type: e.type,
            props: {
              bend: _
            }
          };
        }
        const s = wi(e), a = this.editor.getShapePageTransform(s.id).applyToPoint(n);
        if (this.editor.inputs.ctrlKey)
          return s.props[i] = {
            type: "point",
            x: n.x,
            y: n.y
          }, s;
        const l = this.editor.getShapePageTransform(e.id).applyToPoint(n), c = this.editor.getShapeAtPoint(l, {
          hitInside: true,
          hitFrameInside: true,
          margin: 0,
          filter: (y) => !y.isLocked && this.editor.getShapeUtil(y).canBind(y)
        });
        if (!c)
          return s.props[i] = {
            type: "point",
            x: n.x,
            y: n.y
          }, s;
        const u = this.editor.getShapeGeometry(c), d = Te.ZeroFix(u.bounds), h = this.editor.getPointInShapeSpace(c, a);
        let f = r;
        if (!f) {
          const y = s.props[i];
          (y.type === "point" || y.type === "binding" && c.id !== y.boundShapeId) && (f = this.editor.inputs.pointerVelocity.len() < 0.5);
        }
        if (f && (f = I.Dist(h, d.center) > Math.max(4, Math.min(Math.min(d.width, d.height) * 0.15, 16)) / this.editor.zoomLevel), !r) {
          u.isClosed || (f = true);
          const y = s.props[i === "start" ? "end" : "start"];
          y.type === "binding" && c.id === y.boundShapeId && I.Equals(y.normalizedAnchor, {
            x: 0.5,
            y: 0.5
          }) && (f = true);
        }
        return s.props[i] = {
          type: "binding",
          boundShapeId: c.id,
          normalizedAnchor: f ? {
            x: (h.x - d.minX) / d.width,
            y: (h.y - d.minY) / d.height
          } : {
            x: 0.5,
            y: 0.5
          },
          isExact: this.editor.inputs.altKey
        }, s.props.start.type === "binding" && s.props.end.type === "binding" && s.props.start.boundShapeId === s.props.end.boundShapeId && I.Equals(s.props.start.normalizedAnchor, s.props.end.normalizedAnchor) && (s.props.end.normalizedAnchor.x += 0.05), s;
      });
      __publicField(this, "onTranslateStart", (e) => {
        const n = e.props.start.type === "binding" ? e.props.start.boundShapeId : null, r = e.props.end.type === "binding" ? e.props.end.boundShapeId : null, { selectedShapeIds: i } = this.editor;
        if (n && (i.includes(n) || this.editor.isAncestorSelected(n)) || r && (i.includes(r) || this.editor.isAncestorSelected(r)))
          return;
        const { start: s, end: o } = Ia(this.editor, e);
        return {
          id: e.id,
          type: e.type,
          props: {
            ...e.props,
            start: {
              type: "point",
              x: s.x,
              y: s.y
            },
            end: {
              type: "point",
              x: o.x,
              y: o.y
            }
          }
        };
      });
      __publicField(this, "onResize", (e, n) => {
        const { scaleX: r, scaleY: i } = n, s = Ia(this.editor, e), { start: o, end: a } = wi(e.props);
        let { bend: l } = e.props;
        o.type === "point" && (o.x = s.start.x * r, o.y = s.start.y * i), a.type === "point" && (a.x = s.end.x * r, a.y = s.end.y * i);
        const c = Math.abs(r), u = Math.abs(i);
        return r < 0 && i >= 0 ? (l !== 0 && (l *= -1, l *= Math.max(c, u)), o.type === "binding" && (o.normalizedAnchor.x = 1 - o.normalizedAnchor.x), a.type === "binding" && (a.normalizedAnchor.x = 1 - a.normalizedAnchor.x)) : r >= 0 && i < 0 ? (l !== 0 && (l *= -1, l *= Math.max(c, u)), o.type === "binding" && (o.normalizedAnchor.y = 1 - o.normalizedAnchor.y), a.type === "binding" && (a.normalizedAnchor.y = 1 - a.normalizedAnchor.y)) : r >= 0 && i >= 0 ? l !== 0 && (l *= Math.max(c, u)) : r < 0 && i < 0 && (l !== 0 && (l *= Math.max(c, u)), o.type === "binding" && (o.normalizedAnchor.x = 1 - o.normalizedAnchor.x, o.normalizedAnchor.y = 1 - o.normalizedAnchor.y), a.type === "binding" && (a.normalizedAnchor.x = 1 - a.normalizedAnchor.x, a.normalizedAnchor.y = 1 - a.normalizedAnchor.y)), {
          props: {
            start: o,
            end: a,
            bend: l
          }
        };
      });
      __publicField(this, "onDoubleClickHandle", (e, n) => {
        switch (n.id) {
          case "start":
            return {
              id: e.id,
              type: e.type,
              props: {
                ...e.props,
                arrowheadStart: e.props.arrowheadStart === "none" ? "arrow" : "none"
              }
            };
          case "end":
            return {
              id: e.id,
              type: e.type,
              props: {
                ...e.props,
                arrowheadEnd: e.props.arrowheadEnd === "none" ? "arrow" : "none"
              }
            };
        }
      });
      __publicField(this, "onEditEnd", (e) => {
        const { id: n, type: r, props: { text: i } } = e;
        i.trimEnd() !== e.props.text && this.editor.updateShapes([
          {
            id: n,
            type: r,
            props: {
              text: i.trimEnd()
            }
          }
        ]);
      });
    }
    getDefaultProps() {
      return {
        dash: "draw",
        size: "m",
        fill: "none",
        color: "black",
        labelColor: "black",
        bend: 0,
        start: {
          type: "point",
          x: 0,
          y: 0
        },
        end: {
          type: "point",
          x: 2,
          y: 0
        },
        arrowheadStart: "none",
        arrowheadEnd: "arrow",
        text: "",
        font: "draw"
      };
    }
    getGeometry(e) {
      const n = this.editor.getArrowInfo(e), r = n.isStraight ? new Ak({
        start: I.From(n.start.point),
        end: I.From(n.end.point)
      }) : new hEe({
        center: I.Cast(n.handleArc.center),
        radius: n.handleArc.radius,
        start: I.Cast(n.start.point),
        end: I.Cast(n.end.point),
        sweepFlag: n.bodyArc.sweepFlag,
        largeArcFlag: n.bodyArc.largeArcFlag
      });
      let i;
      if (e.props.text.trim()) {
        const s = r.bounds, { w: o, h: a } = this.editor.textMeasure.measureText(e.props.text, {
          ...Wr,
          fontFamily: Nc[e.props.font],
          fontSize: Du[e.props.size],
          maxWidth: null
        });
        let l = o, c = a;
        if (s.width > s.height) {
          l = Math.max(Math.min(o, 64), Math.min(s.width - 64, o));
          const { w: u, h: d } = this.editor.textMeasure.measureText(e.props.text, {
            ...Wr,
            fontFamily: Nc[e.props.font],
            fontSize: Du[e.props.size],
            maxWidth: l
          });
          l = u, c = d;
        }
        if (l > 16 * Du[e.props.size]) {
          l = 16 * Du[e.props.size];
          const { w: u, h: d } = this.editor.textMeasure.measureText(e.props.text, {
            ...Wr,
            fontFamily: Nc[e.props.font],
            fontSize: Du[e.props.size],
            maxWidth: l
          });
          l = u, c = d;
        }
        i = new wd({
          x: n.middle.x - l / 2 - 4.25,
          y: n.middle.y - c / 2 - 4.25,
          width: l + 8.5,
          height: c + 8.5,
          isFilled: true,
          isLabel: true
        });
      }
      return new Yu({
        children: i ? [
          r,
          i
        ] : [
          r
        ],
        isSnappable: false
      });
    }
    getHandles(e) {
      const n = this.editor.getArrowInfo(e);
      return [
        {
          id: "start",
          type: "vertex",
          index: "a0",
          x: n.start.handle.x,
          y: n.start.handle.y,
          canBind: true
        },
        {
          id: "middle",
          type: "virtual",
          index: "a2",
          x: n.middle.x,
          y: n.middle.y,
          canBind: false
        },
        {
          id: "end",
          type: "vertex",
          index: "a3",
          x: n.end.handle.x,
          y: n.end.handle.y,
          canBind: true
        }
      ];
    }
    component(e) {
      const n = Ir(), r = this.editor.onlySelectedShape, i = this.editor.isInAny("select.idle", "select.pointing_handle", "select.dragging_handle", "arrow.dragging") && !this.editor.instanceState.isReadonly, s = this.editor.getArrowInfo(e), o = Te.ZeroFix(this.editor.getShapeGeometry(e).bounds), a = $e.useMemo(() => this.editor.environment.isSafari ? rNe += 1 : 0, [
        e
      ]);
      if (!(s == null ? void 0 : s.isValid))
        return null;
      const l = mi[e.props.size], c = s.start.arrowhead && vp(s, "start", l), u = s.end.arrowhead && vp(s, "end", l), d = s.isStraight ? IE(s) : AE(s);
      let h = null;
      if (r === e && i) {
        const { strokeDasharray: P, strokeDashoffset: C } = xi(s.isStraight ? I.Dist(s.start.handle, s.end.handle) : Math.abs(s.handleArc.length), 2, {
          end: "skip",
          start: "skip",
          lengthRatio: 2.5
        });
        h = e.props.start.type === "binding" || e.props.end.type === "binding" ? m.jsx("path", {
          className: "tl-arrow-hint",
          d: s.isStraight ? D_e(s) : L_e(s),
          strokeDasharray: P,
          strokeDashoffset: C,
          strokeWidth: 2,
          markerStart: e.props.start.type === "binding" ? e.props.start.isExact ? "" : h7(e.props.start.normalizedAnchor) ? "url(#arrowhead-cross)" : "url(#arrowhead-dot)" : "",
          markerEnd: e.props.end.type === "binding" ? e.props.end.isExact ? "" : h7(e.props.end.normalizedAnchor) ? "url(#arrowhead-cross)" : "url(#arrowhead-dot)" : "",
          opacity: 0.16
        }) : null;
      }
      const { strokeDasharray: f, strokeDashoffset: y } = xi(s.isStraight ? s.length : Math.abs(s.bodyArc.length), l, {
        style: e.props.dash
      }), g = e.props.text.trim() ? this.editor.getShapeGeometry(e).children[1] : null, O = !(s.start.arrowhead === "none" || s.start.arrowhead === "arrow"), S = !(s.end.arrowhead === "none" || s.end.arrowhead === "arrow"), w = (e.id + "_clip_" + a).replace(":", "_");
      return m.jsxs(m.Fragment, {
        children: [
          m.jsxs(Gs, {
            id: e.id,
            style: {
              minWidth: 50,
              minHeight: 50
            },
            children: [
              m.jsx("defs", {
                children: m.jsxs("mask", {
                  id: w,
                  children: [
                    m.jsx("rect", {
                      x: Y(-100 + o.minX),
                      y: Y(-100 + o.minY),
                      width: Y(o.width + 200),
                      height: Y(o.height + 200),
                      fill: "white"
                    }),
                    g && m.jsx("rect", {
                      x: g.x,
                      y: g.y,
                      width: g.w,
                      height: g.h,
                      fill: "black",
                      rx: 4,
                      ry: 4
                    }),
                    c && O && m.jsx("path", {
                      d: c,
                      fill: s.start.arrowhead === "arrow" ? "none" : "black",
                      stroke: "none"
                    }),
                    u && S && m.jsx("path", {
                      d: u,
                      fill: s.end.arrowhead === "arrow" ? "none" : "black",
                      stroke: "none"
                    })
                  ]
                })
              }),
              m.jsxs("g", {
                fill: "none",
                stroke: n[e.props.color].solid,
                strokeWidth: l,
                strokeLinejoin: "round",
                strokeLinecap: "round",
                pointerEvents: "none",
                children: [
                  h,
                  m.jsxs("g", {
                    mask: `url(#${w})`,
                    children: [
                      m.jsx("rect", {
                        x: Y(o.minX - 100),
                        y: Y(o.minY - 100),
                        width: Y(o.width + 200),
                        height: Y(o.height + 200),
                        opacity: 0
                      }),
                      m.jsx("path", {
                        d,
                        strokeDasharray: f,
                        strokeDashoffset: y
                      })
                    ]
                  }),
                  c && O && e.props.fill !== "none" && m.jsx(qn, {
                    theme: n,
                    d: c,
                    color: e.props.color,
                    fill: e.props.fill
                  }),
                  u && S && e.props.fill !== "none" && m.jsx(qn, {
                    theme: n,
                    d: u,
                    color: e.props.color,
                    fill: e.props.fill
                  }),
                  c && m.jsx("path", {
                    d: c
                  }),
                  u && m.jsx("path", {
                    d: u
                  })
                ]
              })
            ]
          }),
          m.jsx(nNe, {
            id: e.id,
            text: e.props.text,
            font: e.props.font,
            size: e.props.size,
            position: s.middle,
            width: (g == null ? void 0 : g.w) ?? 0,
            labelColor: n[e.props.labelColor].solid
          })
        ]
      });
    }
    indicator(e) {
      const { start: n, end: r } = Ia(this.editor, e), i = this.editor.getArrowInfo(e), s = this.editor.getShapeGeometry(e), o = s.bounds, a = e.props.text.trim() ? s.children[1] : null, l = MC(e.id);
      if (!i || I.Equals(n, r))
        return null;
      const c = mi[e.props.size], u = i.start.arrowhead && vp(i, "start", c), d = i.end.arrowhead && vp(i, "end", c), h = i.isStraight ? IE(i) : AE(i), f = u && i.start.arrowhead !== "arrow" || d && i.end.arrowhead !== "arrow" || !!a, y = (e.id + "_clip").replace(":", "_");
      return l && a ? m.jsx("rect", {
        x: Y(a.x),
        y: Y(a.y),
        width: a.w,
        height: a.h,
        rx: 3.5,
        ry: 3.5
      }) : m.jsxs("g", {
        children: [
          f && m.jsx("defs", {
            children: m.jsxs("mask", {
              id: y,
              children: [
                m.jsx("rect", {
                  x: o.minX - 100,
                  y: o.minY - 100,
                  width: o.w + 200,
                  height: o.h + 200,
                  fill: "white"
                }),
                a && m.jsx("rect", {
                  x: Y(a.x),
                  y: Y(a.y),
                  width: a.w,
                  height: a.h,
                  fill: "black",
                  rx: 3.5,
                  ry: 3.5
                }),
                u && m.jsx("path", {
                  d: u,
                  fill: i.start.arrowhead === "arrow" ? "none" : "black",
                  stroke: "none"
                }),
                d && m.jsx("path", {
                  d,
                  fill: i.end.arrowhead === "arrow" ? "none" : "black",
                  stroke: "none"
                })
              ]
            })
          }),
          m.jsxs("g", {
            ...f ? {
              mask: `url(#${y})`
            } : void 0,
            children: [
              f && m.jsx("rect", {
                x: o.minX - 100,
                y: o.minY - 100,
                width: o.width + 200,
                height: o.height + 200,
                opacity: 0
              }),
              m.jsx("path", {
                d: h
              })
            ]
          }),
          u && m.jsx("path", {
            d: u
          }),
          d && m.jsx("path", {
            d
          }),
          a && m.jsx("rect", {
            x: Y(a.x),
            y: Y(a.y),
            width: a.w,
            height: a.h,
            rx: 3.5,
            ry: 3.5
          })
        ]
      });
    }
    toSvg(e, n) {
      const r = ks({
        isDarkMode: this.editor.user.isDarkMode
      });
      n.addExportDef(PL(e.props.fill, r));
      const i = r[e.props.color].solid, s = this.editor.getArrowInfo(e), o = mi[e.props.size], a = document.createElementNS("http://www.w3.org/2000/svg", "g");
      if (!s)
        return a;
      const l = s.start.arrowhead && vp(s, "start", o), c = s.end.arrowhead && vp(s, "end", o), u = this.editor.getShapeGeometry(e), d = u.bounds, h = e.props.text.trim() ? u.children[1] : null, f = (e.id + "_clip").replace(":", "_");
      if (l || c || h) {
        const x = document.createElementNS("http://www.w3.org/2000/svg", "defs"), P = document.createElementNS("http://www.w3.org/2000/svg", "mask");
        P.id = f;
        const C = document.createElementNS("http://www.w3.org/2000/svg", "rect");
        if (C.setAttribute("x", d.minX - 100 + ""), C.setAttribute("y", d.minY - 100 + ""), C.setAttribute("width", d.width + 200 + ""), C.setAttribute("height", d.height + 200 + ""), C.setAttribute("fill", "white"), P.appendChild(C), l && P.appendChild(u7(l, s.start.arrowhead)), c && P.appendChild(u7(c, s.end.arrowhead)), h) {
          const _ = document.createElementNS("http://www.w3.org/2000/svg", "rect");
          _.setAttribute("x", h.x + ""), _.setAttribute("y", h.y + ""), _.setAttribute("width", h.w + ""), _.setAttribute("height", h.h + ""), _.setAttribute("fill", "black"), P.appendChild(_);
        }
        x.appendChild(P), a.appendChild(x);
      }
      const y = document.createElementNS("http://www.w3.org/2000/svg", "g");
      y.setAttribute("mask", `url(#${f})`), a.appendChild(y);
      const g = document.createElementNS("http://www.w3.org/2000/svg", "rect");
      g.setAttribute("x", "-100"), g.setAttribute("y", "-100"), g.setAttribute("width", d.width + 200 + ""), g.setAttribute("height", d.height + 200 + ""), g.setAttribute("fill", "transparent"), g.setAttribute("stroke", "none"), y.appendChild(g);
      const O = sNe(s.isStraight ? IE(s) : AE(s), i, o), { strokeDasharray: S, strokeDashoffset: w } = xi(s.isStraight ? s.length : Math.abs(s.bodyArc.length), o, {
        style: e.props.dash
      });
      if (O.setAttribute("stroke-dasharray", S), O.setAttribute("stroke-dashoffset", w), y.appendChild(O), l && a.appendChild(d7(l, e.props.color, o, e.props.arrowheadStart === "arrow" ? "none" : e.props.fill, r)), c && a.appendChild(d7(c, e.props.color, o, e.props.arrowheadEnd === "arrow" ? "none" : e.props.fill, r)), h) {
        n.addExportDef(o2(e.props.font));
        const x = {
          fontSize: Du[e.props.size],
          lineHeight: Wr.lineHeight,
          fontFamily: GO[e.props.font],
          padding: 0,
          textAlign: "middle",
          width: h.w - 8,
          verticalTextAlign: "middle",
          height: h.h,
          fontStyle: "normal",
          fontWeight: "normal",
          overflow: "wrap"
        }, P = s2(this.editor, this.editor.textMeasure.measureTextSpans(e.props.text, x), x);
        P.setAttribute("fill", r[e.props.labelColor].solid), Array.from(P.children).forEach((T) => {
          const $ = parseFloat(T.getAttribute("x") || "0"), N = parseFloat(T.getAttribute("y") || "0");
          T.setAttribute("x", $ + 4 + h.x + "px"), T.setAttribute("y", N + h.y + "px");
        });
        const _ = P.cloneNode(true);
        _.setAttribute("stroke-width", "2"), _.setAttribute("fill", r.background), _.setAttribute("stroke", r.background), a.appendChild(_), a.appendChild(P);
      }
      return a;
    }
    getCanvasSvgDefs() {
      return [
        CL()
      ];
    }
  }
  __publicField(iNe, "type", "arrow");
  __publicField(iNe, "props", cbe);
  __publicField(iNe, "migrations", ube);
  function u7(t, e) {
    const n = document.createElementNS("http://www.w3.org/2000/svg", "path");
    return n.setAttribute("d", t), n.setAttribute("fill", e === "arrow" ? "none" : "black"), n.setAttribute("stroke", "none"), n;
  }
  function sNe(t, e, n) {
    const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
    return r.setAttribute("d", t), r.setAttribute("fill", "none"), r.setAttribute("stroke", e), r.setAttribute("stroke-width", n + ""), r;
  }
  function d7(t, e, n, r, i) {
    const s = document.createElementNS("http://www.w3.org/2000/svg", "path");
    s.setAttribute("d", t), s.setAttribute("fill", "none"), s.setAttribute("stroke", i[e].solid), s.setAttribute("stroke-width", n + "");
    const o = ho({
      d: t,
      fill: r,
      color: e,
      theme: i
    });
    if (o) {
      const a = document.createElementNS("http://www.w3.org/2000/svg", "g");
      return a.appendChild(o), a.appendChild(s), a;
    } else
      return s;
  }
  function h7(t) {
    return t.x !== 0.5 || t.y !== 0.5;
  }
  const oNe = [
    {
      offsetX: 0,
      offsetY: 2,
      blur: 4,
      spread: 0,
      color: "#00000029"
    },
    {
      offsetX: 0,
      offsetY: 3,
      blur: 6,
      spread: 0,
      color: "#0000001f"
    }
  ];
  function TL(t) {
    return oNe.map((n) => {
      const { offsetX: r, offsetY: i, blur: s, spread: o, color: a } = n, l = new I(r, i), { x: c, y: u } = l.rot(-t);
      return `${c}px ${u}px ${s}px ${o}px ${a}`;
    }).join(", ");
  }
  const f7 = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' fill='none'%3E%3Cpath stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 5H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6M19 5h6m0 0v6m0-6L13 17'/%3E%3C/svg%3E";
  function pS({ url: t, zoomLevel: e }) {
    return m.jsx("a", {
      className: Ze("tl-hyperlink-button", {
        "tl-hyperlink-button__hidden": e < 0.32
      }),
      href: t,
      target: "_blank",
      rel: "noopener noreferrer",
      onPointerDown: _r,
      onPointerUp: _r,
      title: t,
      draggable: false,
      children: m.jsx("div", {
        className: "tl-hyperlink-button__icon",
        style: {
          mask: `url("${f7}") center 100% / 100% no-repeat`,
          WebkitMask: `url("${f7}") center 100% / 100% no-repeat`
        }
      })
    });
  }
  class aNe extends Cm {
    constructor() {
      super(...arguments);
      __publicField(this, "canResize", () => false);
      __publicField(this, "hideSelectionBoundsFg", () => true);
      __publicField(this, "onBeforeCreate", (e) => {
        p7(this.editor, e);
      });
      __publicField(this, "onBeforeUpdate", (e, n) => {
        if (e.props.url !== n.props.url)
          if (qA(n.props.url))
            p7(this.editor, n);
          else
            return {
              ...n,
              props: {
                ...n.props,
                url: e.props.url
              }
            };
      });
    }
    getDefaultProps() {
      return {
        url: "",
        w: 300,
        h: 320,
        assetId: null
      };
    }
    component(e) {
      const n = e.props.assetId ? this.editor.getAsset(e.props.assetId) : null, r = this.editor.getShapePageTransform(e).rotation(), i = lNe(e);
      return m.jsx(Fg, {
        children: m.jsxs("div", {
          className: "tl-bookmark__container",
          style: {
            boxShadow: TL(r)
          },
          children: [
            m.jsxs("div", {
              className: "tl-bookmark__image_container",
              children: [
                (n == null ? void 0 : n.props.image) ? m.jsx("img", {
                  className: "tl-bookmark__image",
                  draggable: false,
                  src: n == null ? void 0 : n.props.image,
                  alt: (n == null ? void 0 : n.props.title) || ""
                }) : m.jsx("div", {
                  className: "tl-bookmark__placeholder"
                }),
                m.jsx(pS, {
                  url: e.props.url,
                  zoomLevel: this.editor.zoomLevel
                })
              ]
            }),
            m.jsxs("div", {
              className: "tl-bookmark__copy_container",
              children: [
                (n == null ? void 0 : n.props.title) && m.jsx("h2", {
                  className: "tl-bookmark__heading",
                  children: J0((n == null ? void 0 : n.props.title) || "", 54)
                }),
                (n == null ? void 0 : n.props.description) && m.jsx("p", {
                  className: "tl-bookmark__description",
                  children: J0((n == null ? void 0 : n.props.description) || "", 128)
                }),
                m.jsx("a", {
                  className: "tl-bookmark__link",
                  href: e.props.url || "",
                  target: "_blank",
                  rel: "noopener noreferrer",
                  onPointerDown: _r,
                  onPointerUp: _r,
                  onClick: _r,
                  children: J0(i, 45)
                })
              ]
            })
          ]
        })
      });
    }
    indicator(e) {
      return m.jsx("rect", {
        width: Y(e.props.w),
        height: Y(e.props.h),
        rx: "8",
        ry: "8"
      });
    }
  }
  __publicField(aNe, "type", "bookmark");
  __publicField(aNe, "props", dbe);
  __publicField(aNe, "migrations", hbe);
  const lNe = (t) => {
    try {
      const e = new URL(t.props.url), n = e.pathname.replace(/\/*$/, "");
      return `${e.hostname}${n}`;
    } catch {
      return t.props.url;
    }
  };
  function p7(t, e) {
    const { url: n } = e.props, r = Mh.createId(Xx(n));
    t.getAsset(r) ? e.props.assetId !== r && t.updateShapes([
      {
        id: e.id,
        type: e.type,
        props: {
          assetId: r
        }
      }
    ]) : (t.updateShapes([
      {
        id: e.id,
        type: e.type,
        props: {
          assetId: null
        }
      }
    ]), cNe(t, e));
  }
  const cNe = eG(async (t, e) => {
    const { url: n } = e.props, r = await t.getAssetForExternalContent({
      type: "url",
      url: n
    });
    r && t.batch(() => {
      t.createAssets([
        r
      ]), t.updateShapes([
        {
          id: e.id,
          type: e.type,
          props: {
            assetId: r.id
          }
        }
      ]);
    });
  }, 500);
  function Wh(t, e = false) {
    const n = t.length;
    if (n < 2)
      return "";
    let r = t[0].point, i = t[1].point;
    if (n === 2)
      return `M${Qo(r)}L${Qo(i)}`;
    let s = "";
    for (let o = 2, a = n - 1; o < a; o++)
      r = t[o].point, i = t[o + 1].point, s += zo(r, i);
    return e ? `M${zo(t[0].point, t[1].point)}Q${Qo(t[1].point)}${zo(t[1].point, t[2].point)}T${s}${zo(t[n - 1].point, t[0].point)}${zo(t[0].point, t[1].point)}Z` : `M${Qo(t[0].point)}Q${Qo(t[1].point)}${zo(t[1].point, t[2].point)}${t.length > 3 ? "T" : ""}${s}L${Qo(t[n - 1].point)}`;
  }
  function Wk() {
    const t = ue();
    return ye("zoom", () => t.zoomLevel < 0.35, [
      t
    ]);
  }
  const uNe = (t) => t * 0.65 + ake(t * zt / 2) * 0.35, dNe = (t) => ({
    size: 1 + t,
    thinning: 0.5,
    streamline: 0.62 + (1 + t) / 8 * 0.06,
    smoothing: 0.62,
    easing: Oi.easeOutSine,
    simulatePressure: true
  }), hNe = (t) => ({
    size: 1 + t * 1.2,
    thinning: 0.62,
    streamline: 0.62,
    smoothing: 0.62,
    simulatePressure: false,
    easing: uNe
  }), g7 = (t) => ({
    size: 1 + t,
    thinning: 0,
    streamline: 0.62 + (1 + t) / 8 * 0.06,
    smoothing: 0.62,
    simulatePressure: false,
    easing: Oi.linear
  });
  function $R({ strokeWidth: t, showAsComplete: e }) {
    return {
      size: 1 + t,
      thinning: 0,
      streamline: 0.5,
      smoothing: 0.5,
      simulatePressure: false,
      easing: Oi.easeOutSine,
      last: e
    };
  }
  function $w(t, e, n, r) {
    return {
      ...r ? g7(e) : t.dash === "draw" ? t.isPen ? hNe(e) : dNe(e) : g7(e),
      last: t.isComplete || n
    };
  }
  function rg(t) {
    const e = [];
    for (const n of t)
      if (n.type === "free" || n.points.length < 2)
        e.push(...n.points.map(I.Cast));
      else {
        const r = Math.max(4, Math.floor(I.Dist(n.points[0], n.points[1]) / 16));
        e.push(...I.PointsBetween(n.points[0], n.points[1], r));
      }
    return e;
  }
  function m7(t, e) {
    return {
      draw: "none",
      solid: "none",
      dotted: `0.1 ${e * 2}`,
      dashed: `${e * 2} ${e * 2}`
    }[t.props.dash];
  }
  class fNe extends Nd {
    constructor() {
      super(...arguments);
      __publicField(this, "hideResizeHandles", (e) => pI(e));
      __publicField(this, "hideRotateHandle", (e) => pI(e));
      __publicField(this, "hideSelectionBoundsFg", (e) => pI(e));
      __publicField(this, "onResize", (e, n) => {
        const { scaleX: r, scaleY: i } = n, s = [];
        for (const o of e.props.segments)
          s.push({
            ...o,
            points: o.points.map(({ x: a, y: l, z: c }) => ({
              x: Pk(r * a),
              y: Pk(i * l),
              z: c
            }))
          });
        return {
          props: {
            segments: s
          }
        };
      });
    }
    getDefaultProps() {
      return {
        segments: [],
        color: "black",
        fill: "none",
        dash: "draw",
        size: "m",
        isComplete: false,
        isClosed: false,
        isPen: false
      };
    }
    getGeometry(e) {
      const n = rg(e.props.segments), r = mi[e.props.size];
      if (e.props.segments.length === 1) {
        const s = Te.FromPoints(n);
        if (s.width < r * 2 && s.height < r * 2)
          return new mq({
            x: -r,
            y: -r,
            radius: r,
            isFilled: true
          });
      }
      const i = Ic(n, $w(e.props, r, true, true)).map((s) => s.point);
      return e.props.isClosed ? new xr({
        points: i,
        isFilled: e.props.fill !== "none"
      }) : new Sf({
        points: i
      });
    }
    component(e) {
      var _a3;
      const n = Ir(), r = Wk(), i = mi[e.props.size], s = rg(e.props.segments), o = e.props.isComplete || ((_a3 = as(e.props.segments)) == null ? void 0 : _a3.type) === "straight";
      let a = i;
      !r && !e.props.isPen && e.props.dash === "draw" && s.length === 1 && (a += md(e.id)() * (i / 6));
      const l = $w(e.props, a, o, r), c = Ic(s, l), u = c.length > 1 ? Wh(c, e.props.isClosed) : fI(s[0], a);
      if (!r && e.props.dash === "draw" || c.length < 2) {
        Xg(c, l);
        const d = Vg(c, l);
        return m.jsxs(Gs, {
          id: e.id,
          children: [
            m.jsx(qn, {
              theme: n,
              fill: e.props.isClosed ? e.props.fill : "none",
              color: e.props.color,
              d: u
            }),
            m.jsx("path", {
              d: Qg(d, true),
              strokeLinecap: "round",
              fill: n[e.props.color].solid
            })
          ]
        });
      }
      return m.jsxs(Gs, {
        id: e.id,
        children: [
          m.jsx(qn, {
            theme: n,
            color: e.props.color,
            fill: e.props.isClosed ? e.props.fill : "none",
            d: u
          }),
          m.jsx("path", {
            d: u,
            strokeLinecap: "round",
            fill: "none",
            stroke: n[e.props.color].solid,
            strokeWidth: i,
            strokeDasharray: m7(e, i),
            strokeDashoffset: "0"
          })
        ]
      });
    }
    indicator(e) {
      var _a3;
      const n = Wk(), r = mi[e.props.size], i = rg(e.props.segments);
      let s = r;
      !n && !e.props.isPen && e.props.dash === "draw" && i.length === 1 && (s += md(e.id)() * (r / 6));
      const o = e.props.isComplete || ((_a3 = as(e.props.segments)) == null ? void 0 : _a3.type) === "straight", a = $w(e.props, s, o, true), l = Ic(i, a), c = l.length > 1 ? Wh(l, e.props.isClosed) : fI(i[0], s);
      return m.jsx("path", {
        d: c
      });
    }
    toSvg(e, n) {
      var _a3;
      const r = ks({
        isDarkMode: this.editor.user.isDarkMode
      });
      n.addExportDef(PL(e.props.fill, r));
      const { color: i } = e.props, s = mi[e.props.size], o = rg(e.props.segments), a = e.props.isComplete || ((_a3 = as(e.props.segments)) == null ? void 0 : _a3.type) === "straight";
      let l = s;
      !e.props.isPen && e.props.dash === "draw" && o.length === 1 && (l += md(e.id)() * (s / 6));
      const c = $w(e.props, l, a, false), u = Ic(o, c), d = u.length > 1 ? Wh(u, e.props.isClosed) : fI(o[0], l);
      let h;
      if (e.props.dash === "draw" || u.length < 2) {
        Xg(u, c);
        const y = Vg(u, c), g = document.createElementNS("http://www.w3.org/2000/svg", "path");
        g.setAttribute("d", Qg(y, true)), g.setAttribute("fill", r[i].solid), g.setAttribute("stroke-linecap", "round"), h = g;
      } else {
        const y = document.createElementNS("http://www.w3.org/2000/svg", "path");
        y.setAttribute("d", d), y.setAttribute("stroke", r[i].solid), y.setAttribute("fill", "none"), y.setAttribute("stroke-linecap", "round"), y.setAttribute("stroke-width", s.toString()), y.setAttribute("stroke-dasharray", m7(e, s)), y.setAttribute("stroke-dashoffset", "0"), h = y;
      }
      const f = ho({
        fill: e.props.isClosed ? e.props.fill : "none",
        d,
        color: e.props.color,
        theme: r
      });
      if (f) {
        const y = document.createElementNS("http://www.w3.org/2000/svg", "g");
        return y.appendChild(f), y.appendChild(h), y;
      }
      return h;
    }
    getCanvasSvgDefs() {
      return [
        CL()
      ];
    }
    expandSelectionOutlinePx(e) {
      const n = e.props.dash === "draw" ? 1.6 : 1;
      return mi[e.props.size] * n / 2;
    }
  }
  __publicField(fNe, "type", "draw");
  __publicField(fNe, "props", fbe);
  __publicField(fNe, "migrations", pbe);
  function fI(t, e) {
    const n = (e + 1) * 0.5;
    return `M ${t.x} ${t.y} m -${n}, 0 a ${n},${n} 0 1,0 ${n * 2},0 a ${n},${n} 0 1,0 -${n * 2},0`;
  }
  function pI(t) {
    return t.props.segments.length === 1 && t.props.segments[0].points.length < 2;
  }
  function pNe(t, e, n = {}) {
    const { newPoint: r, handle: i, scaleX: s, scaleY: o } = e, { minWidth: a = 1, maxWidth: l = 1 / 0, minHeight: c = 1, maxHeight: u = 1 / 0 } = n;
    let d = t.props.w * s, h = t.props.h * o;
    const f = new I(0, 0);
    if (d > 0) {
      if (d < a) {
        switch (i) {
          case "top_left":
          case "left":
          case "bottom_left": {
            f.x = d - a;
            break;
          }
          case "top":
          case "bottom": {
            f.x = (d - a) / 2;
            break;
          }
          default:
            f.x = 0;
        }
        d = a;
      }
    } else if (f.x = d, d = -d, d < a) {
      switch (i) {
        case "top_left":
        case "left":
        case "bottom_left": {
          f.x = -d;
          break;
        }
        default:
          f.x = -a;
      }
      d = a;
    }
    if (h > 0) {
      if (h < c) {
        switch (i) {
          case "top_left":
          case "top":
          case "top_right": {
            f.y = h - c;
            break;
          }
          case "right":
          case "left": {
            f.y = (h - c) / 2;
            break;
          }
          default:
            f.y = 0;
        }
        h = c;
      }
    } else if (f.y = h, h = -h, h < c) {
      switch (i) {
        case "top_left":
        case "top":
        case "top_right": {
          f.y = -h;
          break;
        }
        default:
          f.y = -c;
      }
      h = c;
    }
    const { x: y, y: g } = f.rot(t.rotation).add(r);
    return {
      x: y,
      y: g,
      props: {
        w: Math.min(l, d),
        h: Math.min(u, h)
      }
    };
  }
  const gNe = (t) => Object.entries(t).filter(([e, n]) => n).map(([e]) => e).join(" ");
  class mNe extends Cm {
    constructor() {
      super(...arguments);
      __publicField(this, "hideSelectionBoundsFg", (e) => !this.canResize(e));
      __publicField(this, "canEdit", () => true);
      __publicField(this, "canUnmount", (e) => {
        var _a3, _b3;
        return !!((_b3 = (_a3 = Cc(e.props.url)) == null ? void 0 : _a3.definition) == null ? void 0 : _b3.canUnmount);
      });
      __publicField(this, "canResize", (e) => {
        var _a3, _b3;
        return !!((_b3 = (_a3 = Cc(e.props.url)) == null ? void 0 : _a3.definition) == null ? void 0 : _b3.doesResize);
      });
      __publicField(this, "canEditInReadOnly", () => true);
      __publicField(this, "isAspectRatioLocked", (e) => {
        var _a3;
        return ((_a3 = Cc(e.props.url)) == null ? void 0 : _a3.definition.isAspectRatioLocked) ?? false;
      });
      __publicField(this, "onResize", (e, n) => {
        const r = this.isAspectRatioLocked(e), i = Cc(e.props.url);
        let s = (i == null ? void 0 : i.definition.minWidth) ?? 200, o = (i == null ? void 0 : i.definition.minHeight) ?? 200;
        if (r) {
          const a = e.props.w / e.props.h;
          a > 1 ? s *= a : o /= a;
        }
        return pNe(e, n, {
          minWidth: s,
          minHeight: o
        });
      });
    }
    getDefaultProps() {
      return {
        w: 300,
        h: 300,
        url: ""
      };
    }
    component(e) {
      const { w: n, h: r, url: i } = e.props, s = MC(e.id), o = b.useMemo(() => oee(i), [
        i
      ]), a = ye("is hovering", () => {
        const { editingShapeId: d, hoveredShapeId: h } = this.editor.currentPageState;
        if (d && h !== d) {
          const f = this.editor.getShape(d);
          if (f && this.editor.isShapeOfType(f, "embed"))
            return true;
        }
        return false;
      }, []), l = this.editor.getShapePageTransform(e).rotation(), c = s || a;
      if ((o == null ? void 0 : o.definition.type) === "github_gist") {
        const d = o.url.split("/").pop();
        if (!d)
          throw Error("No gist id!");
        return m.jsx(Fg, {
          className: "tl-embed-container",
          id: e.id,
          children: m.jsx(yNe, {
            id: d,
            width: Y(n),
            height: Y(r),
            isInteractive: c,
            pageRotation: l
          })
        });
      }
      const u = gNe({
        ...gbe,
        ...(o == null ? void 0 : o.definition.overridePermissions) ?? {}
      });
      return m.jsx(Fg, {
        className: "tl-embed-container",
        id: e.id,
        children: (o == null ? void 0 : o.definition) ? m.jsx("iframe", {
          className: "tl-embed",
          sandbox: u,
          src: o.embedUrl,
          width: Y(n),
          height: Y(r),
          draggable: false,
          frameBorder: "0",
          referrerPolicy: "no-referrer-when-downgrade",
          style: {
            border: 0,
            pointerEvents: c ? "auto" : "none",
            zIndex: c ? "" : "-1",
            boxShadow: TL(l),
            borderRadius: (o == null ? void 0 : o.definition.overrideOutlineRadius) ?? 8,
            background: o == null ? void 0 : o.definition.backgroundColor
          }
        }) : null
      });
    }
    indicator(e) {
      const n = b.useMemo(() => Cc(e.props.url), [
        e.props.url
      ]);
      return m.jsx("rect", {
        width: Y(e.props.w),
        height: Y(e.props.h),
        rx: (n == null ? void 0 : n.definition.overrideOutlineRadius) ?? 8,
        ry: (n == null ? void 0 : n.definition.overrideOutlineRadius) ?? 8
      });
    }
  }
  __publicField(mNe, "type", "embed");
  __publicField(mNe, "props", mbe);
  __publicField(mNe, "migrations", ybe);
  function yNe({ id: t, file: e, isInteractive: n, width: r, height: i, style: s, pageRotation: o }) {
    return m.jsx("iframe", {
      className: "tl-embed",
      draggable: false,
      width: Y(r),
      height: Y(i),
      frameBorder: "0",
      scrolling: "no",
      seamless: true,
      referrerPolicy: "no-referrer-when-downgrade",
      style: {
        ...s,
        pointerEvents: n ? "all" : "none",
        zIndex: n ? "" : "-1",
        boxShadow: TL(o)
      },
      srcDoc: `
			<html>
				<head>
					<base target="_blank">
				</head>
				<body>
					<script src=${`https://gist.github.com/${t}.js${e ? `?file=${e}` : ""}`}><\/script>
					<style type="text/css">
						* { margin: 0px; }
						table { height: 100%; background-color: red; }
						.gist { background-color: none; height: 100%;  }
						.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
					</style>
				</body>
			</html>`
    });
  }
  const vNe = b.forwardRef(({ id: t, name: e, isEditing: n }, r) => {
    const i = ue(), s = b.useCallback((l) => {
      l.key === "Enter" && !l.nativeEvent.isComposing && (_r(l), l.currentTarget.blur(), i.setEditingShape(null));
    }, [
      i
    ]), o = b.useCallback((l) => {
      const c = i.getShape(t);
      if (!c)
        return;
      const u = c.props.name, d = l.currentTarget.value.trim();
      u !== d && i.updateShapes([
        {
          id: t,
          type: "frame",
          props: {
            name: d
          }
        }
      ], {
        squashing: true
      });
    }, [
      t,
      i
    ]), a = b.useCallback((l) => {
      const c = i.getShape(t);
      if (!c)
        return;
      const u = c.props.name, d = l.currentTarget.value;
      u !== d && i.updateShapes([
        {
          id: t,
          type: "frame",
          props: {
            name: d
          }
        }
      ], {
        squashing: true
      });
    }, [
      t,
      i
    ]);
    return m.jsxs("div", {
      className: `tl-frame-label ${n ? "tl-frame-label__editing" : ""}`,
      children: [
        m.jsx("input", {
          className: "tl-frame-name-input",
          ref: r,
          style: {
            display: n ? void 0 : "none"
          },
          value: e,
          autoFocus: true,
          onKeyDown: s,
          onBlur: o,
          onChange: a
        }),
        uee(e, "Frame") + String.fromCharCode(8203)
      ]
    });
  }), ONe = function({ id: e, name: n, width: r, height: i }) {
    const s = ue(), o = Qa(s.getShapePageTransform(e).rotation()), a = MC(e), l = b.useRef(null), c = b.useCallback((y) => {
      const g = ps(y);
      s.editingShapeId !== e && (s.dispatch({
        type: "pointer",
        name: "pointer_down",
        target: "shape",
        shape: s.getShape(e),
        ...g
      }), y.preventDefault());
    }, [
      s,
      e
    ]);
    b.useEffect(() => {
      const y = l.current;
      y && a && (y.focus(), y.select(), requestAnimationFrame(() => {
        document.activeElement !== y && (y.focus(), y.select());
      }));
    }, [
      l,
      a
    ]);
    const d = ((o + Math.PI / 4) * (2 / Math.PI) + 4) % 4, h = [
      "top",
      "left",
      "bottom",
      "right"
    ][Math.floor(d)];
    let f;
    switch (h) {
      case "top":
        f = "";
        break;
      case "right":
        f = `translate(${Y(r)}px, 0px) rotate(90deg)`;
        break;
      case "bottom":
        f = `translate(${Y(r)}px, ${Y(i)}px) rotate(180deg)`;
        break;
      case "left":
        f = `translate(0px, ${Y(i)}px) rotate(270deg)`;
        break;
    }
    return m.jsx("div", {
      className: "tl-frame-heading",
      style: {
        overflow: a ? "visible" : "hidden",
        maxWidth: `calc(var(--tl-zoom) * ${Math.ceil(h === "top" || h === "bottom" ? r : i)}px + var(--space-5))`,
        bottom: "100%",
        transform: `${f} scale(var(--tl-scale)) translateX(calc(-1 * var(--space-3))`
      },
      onPointerDown: c,
      children: m.jsx("div", {
        className: "tl-frame-heading-hit-area",
        children: m.jsx(vNe, {
          ref: l,
          id: e,
          name: n,
          isEditing: a
        })
      })
    });
  };
  function uee(t, e) {
    return t.match(/^\s*$/) ? e : t;
  }
  class SNe extends Cm {
    constructor() {
      super(...arguments);
      __publicField(this, "canBind", () => true);
      __publicField(this, "canEdit", () => true);
      __publicField(this, "canReceiveNewChildrenOfType", (e, n) => !e.isLocked);
      __publicField(this, "canDropShapes", (e, n) => !e.isLocked);
      __publicField(this, "onDragShapesOver", (e, n) => n.every((r) => r.parentId === e.id) ? {
        shouldHint: false
      } : (this.editor.reparentShapes(n.map((r) => r.id), e.id), {
        shouldHint: true
      }));
      __publicField(this, "onDragShapesOut", (e, n) => {
        const r = this.editor.getShape(e.parentId);
        r && this.editor.isShapeOfType(r, "group") ? this.editor.reparentShapes(n, r.id) : this.editor.reparentShapes(n, this.editor.currentPageId);
      });
      __publicField(this, "onResizeEnd", (e) => {
        const n = this.editor.getShapePageBounds(e), r = this.editor.getSortedChildIdsForParent(e.id), i = [];
        for (const s of r) {
          const o = this.editor.getShapePageBounds(s);
          n.includes(o) || i.push(s);
        }
        i.length > 0 && this.editor.reparentShapes(i, this.editor.currentPageId);
      });
    }
    getDefaultProps() {
      return {
        w: 160 * 2,
        h: 90 * 2,
        name: ""
      };
    }
    getGeometry(e) {
      return new wd({
        width: e.props.w,
        height: e.props.h,
        isFilled: false
      });
    }
    component(e) {
      const n = this.editor.getShapeGeometry(e).bounds, r = Ir();
      return m.jsxs(m.Fragment, {
        children: [
          m.jsx(Gs, {
            children: m.jsx("rect", {
              className: "tl-frame__body",
              width: n.width,
              height: n.height,
              fill: r.solid,
              stroke: r.text
            })
          }),
          m.jsx(ONe, {
            id: e.id,
            name: e.props.name,
            width: n.width,
            height: n.height
          })
        ]
      });
    }
    toSvg(e) {
      const n = ks({
        isDarkMode: this.editor.user.isDarkMode
      }), r = document.createElementNS("http://www.w3.org/2000/svg", "g"), i = document.createElementNS("http://www.w3.org/2000/svg", "rect");
      i.setAttribute("width", e.props.w.toString()), i.setAttribute("height", e.props.h.toString()), i.setAttribute("fill", n.solid), i.setAttribute("stroke", n.black.solid), i.setAttribute("stroke-width", "1"), i.setAttribute("rx", "1"), i.setAttribute("ry", "1"), r.appendChild(i);
      const a = ((Qa(this.editor.getShapePageTransform(e.id).rotation()) + Math.PI / 4) * (2 / Math.PI) + 4) % 4, l = [
        "top",
        "left",
        "bottom",
        "right"
      ][Math.floor(a)];
      let c;
      switch (l) {
        case "top":
          c = "";
          break;
        case "right":
          c = `translate(${Y(e.props.w)}px, 0px) rotate(90deg)`;
          break;
        case "bottom":
          c = `translate(${Y(e.props.w)}px, ${Y(e.props.h)}px) rotate(180deg)`;
          break;
        case "left":
          c = `translate(0px, ${Y(e.props.h)}px) rotate(270deg)`;
          break;
        default:
          c = "";
      }
      const u = {
        fontSize: 12,
        fontFamily: "Inter, sans-serif",
        textAlign: "start",
        width: e.props.w,
        height: 32,
        padding: 0,
        lineHeight: 1,
        fontStyle: "normal",
        fontWeight: "normal",
        overflow: "truncate-ellipsis",
        verticalTextAlign: "middle"
      }, d = this.editor.textMeasure.measureTextSpans(uee(e.props.name, "Frame") + String.fromCharCode(8203), u), h = d[0], f = as(d), y = f.box.w + f.box.x - h.box.x, g = s2(this.editor, d, {
        offsetY: -u.height - 2,
        ...u
      });
      g.style.setProperty("transform", c);
      const O = document.createElementNS("http://www.w3.org/2000/svg", "rect");
      return O.setAttribute("x", "-8px"), O.setAttribute("y", -u.height - 4 + "px"), O.setAttribute("width", y + 16 + "px"), O.setAttribute("height", `${u.height}px`), O.setAttribute("rx", "4px"), O.setAttribute("ry", "4px"), O.setAttribute("fill", n.background), r.appendChild(O), r.appendChild(g), r;
    }
    indicator(e) {
      const n = this.editor.getShapeGeometry(e).bounds;
      return m.jsx("rect", {
        width: Y(n.width),
        height: Y(n.height),
        className: "tl-frame-indicator"
      });
    }
    providesBackgroundForChildren() {
      return true;
    }
  }
  __publicField(SNe, "type", "frame");
  __publicField(SNe, "props", vbe);
  __publicField(SNe, "migrations", Obe);
  function wNe(t, e, n, r) {
    if ((t === "start-legacy" || t === "end-legacy") && n.length !== 0) {
      const i = Te.From(n[0].box);
      for (const { box: s } of n)
        i.union(s);
      if (t === "start-legacy")
        return (r - 2 * e - i.width) / 2;
      if (t === "end-legacy")
        return -(r - 2 * e - i.width) / 2;
    }
  }
  function xNe(t) {
    return t === "start-legacy" || t === "middle-legacy" || t === "end-legacy";
  }
  const dee = $e.memo(function({ id: e, type: n, text: r, size: i, labelColor: s, font: o, align: a, verticalAlign: l, wrap: c, bounds: u }) {
    const { rInput: d, isEmpty: h, isEditing: f, handleFocus: y, handleChange: g, handleKeyDown: O, handleBlur: S, handleInputPointerDown: w, handleDoubleClick: x } = _L(e, n, r), P = pr.normalizeTextForDom(r), C = P.length > 0, _ = xNe(a), T = Ir();
    return !f && !C ? null : m.jsx("div", {
      className: "tl-text-label",
      "data-font": o,
      "data-align": a,
      "data-hastext": !h,
      "data-isediting": f,
      "data-textwrap": !!c,
      style: {
        justifyContent: a === "middle" || _ ? "center" : a,
        alignItems: l === "middle" ? "center" : l,
        ...u ? {
          top: u.minY,
          left: u.minX,
          width: u.width,
          height: u.height,
          position: "absolute"
        } : {}
      },
      children: m.jsxs("div", {
        className: "tl-text-label__inner",
        style: {
          fontSize: Wg[i],
          lineHeight: Wg[i] * Wr.lineHeight + "px",
          minHeight: Wr.lineHeight + 32,
          minWidth: 0,
          color: T[s].solid
        },
        children: [
          m.jsx("div", {
            className: "tl-text tl-text-content",
            dir: "ltr",
            children: P
          }),
          f && m.jsx("textarea", {
            ref: d,
            className: "tl-text tl-text-input",
            name: "text",
            tabIndex: -1,
            autoComplete: "false",
            autoCapitalize: "false",
            autoCorrect: "false",
            autoSave: "false",
            autoFocus: true,
            placeholder: "",
            spellCheck: "true",
            wrap: "off",
            dir: "auto",
            datatype: "wysiwyg",
            defaultValue: r,
            onFocus: y,
            onChange: g,
            onKeyDown: O,
            onBlur: S,
            onContextMenu: _r,
            onPointerDown: w,
            onDoubleClick: x
          })
        ]
      })
    });
  });
  function hee({ bounds: t, editor: e, font: n, shape: r }) {
    const s = {
      fontSize: Wg[r.props.size],
      fontFamily: n,
      textAlign: r.props.align,
      verticalTextAlign: r.props.verticalAlign,
      width: Math.ceil(t.width),
      height: Math.ceil(t.height),
      padding: 16,
      lineHeight: Wr.lineHeight,
      fontStyle: "normal",
      fontWeight: "normal",
      overflow: "wrap",
      offsetX: 0
    }, o = e.textMeasure.measureTextSpans(r.props.text, s), a = wNe(r.props.align, 16, o, t.width);
    return a && (s.offsetX = a), s2(e, o, s);
  }
  function ai(t) {
    return `${Y(t.x)},${Y(t.y)} `;
  }
  function fee(t = "") {
    let e = 0, n = 0, r = 0, i = 0;
    function s() {
      const o = e ^ e << 11;
      return e = n, n = r, r = i, i ^= (i >>> 19 ^ o ^ o >>> 8) >>> 0, i / 4294967296 * 2;
    }
    for (let o = 0; o < t.length + 64; o++)
      e ^= t.charCodeAt(o) | 0, s();
    return s;
  }
  function rO(t) {
    let e = "M";
    const n = t.length;
    let r, i, s;
    for (let o = 0, a = n; o < a; o += 3)
      r = t[o], i = t[o + 1], s = t[o + 2], e += `${ai(r)}L${ai(i)}Q${ai(s)}`;
    return e += `${ai(t[0])}`, e;
  }
  function iO(t, e, n, r, i) {
    const s = [], o = fee(t);
    let a = e[0], l;
    const c = e.length;
    for (let u = 0, d = c * i; u < d; u++) {
      l = I.AddXY(e[(u + 1) % c], o() * n, o() * n);
      const h = I.Sub(l, a), f = I.Len(h), y = I.Div(h, f).mul(Math.min(f / 4, r));
      s.push(I.Add(a, y), I.Add(l, y.neg()), l), a = l;
    }
    return s;
  }
  function gI(t, e, n) {
    let r = `M ${ai(e[0])}L`, i = `M ${ai(e[0])}L`;
    const s = n / 3, o = n * 2, a = fee(t);
    let l = e[0], c, u = e[0], d;
    const h = e.length;
    for (let f = 0, y = h - 1; f < y; f++) {
      c = e[f + 1], d = I.AddXY(e[f + 1], a() * s, a() * s);
      const g = I.Sub(c, l), O = I.Len(g), S = I.Div(g, O).mul(Math.min(O / 4, o)), w = I.Add(l, S), x = I.Add(c, S.neg()), P = I.Sub(d, u), C = I.Len(P), _ = I.Div(P, C).mul(Math.min(C / 4, o)), T = I.Add(u, _), $ = I.Add(d, _.neg());
      f === y - 1 ? (r += `${ai(w)}L ${ai(c)}`, i += `${ai(T)}L ${ai(d)}`) : (r += `${ai(w)}L ${ai(x)}Q ${ai(c)}`, i += `${ai(T)}L ${ai($)}Q ${ai(d)}`, l = c, u = d);
    }
    return [
      r,
      r + i
    ];
  }
  function y7(t, e) {
    const n = Math.min(t, e) / 2, r = Math.max(t, e) - n * 2;
    return Math.PI * (n * 2) + 2 * r;
  }
  function bNe(t, e, n) {
    const r = Math.min(t, e) / 2, i = Math.max(t, e) - r * 2, o = (Math.PI * (r * 2) + 2 * i) / n, a = t > e ? [
      {
        type: "straight",
        start: new I(r, 0),
        delta: new I(1, 0)
      },
      {
        type: "arc",
        center: new I(t - r, r),
        startAngle: -zt / 2
      },
      {
        type: "straight",
        start: new I(t - r, e),
        delta: new I(-1, 0)
      },
      {
        type: "arc",
        center: new I(r, r),
        startAngle: zt / 2
      }
    ] : [
      {
        type: "straight",
        start: new I(t, r),
        delta: new I(0, 1)
      },
      {
        type: "arc",
        center: new I(r, e - r),
        startAngle: 0
      },
      {
        type: "straight",
        start: new I(0, e - r),
        delta: new I(0, -1)
      },
      {
        type: "arc",
        center: new I(r, r),
        startAngle: zt
      }
    ];
    let l = 0;
    const c = [];
    for (let u = 0; u < n; u++) {
      const d = a[0];
      d.type === "straight" ? c.push(I.Add(d.start, I.Mul(d.delta, l))) : c.push(yG(d.center.x, d.center.y, r, d.startAngle + l / r)), l += o;
      let h = d.type === "straight" ? i : zt * r;
      for (; l > h; )
        l -= h, a.push(a.shift()), h = a[0].type === "straight" ? i : zt * r;
    }
    return c;
  }
  const kNe = (t, e, n, r, i) => {
    switch (t) {
      case "s":
        return e;
      case "m":
        return n;
      case "l":
        return r;
      case "xl":
        return i;
    }
  };
  function gS(t, e, n, r) {
    const i = md(n), s = y7(t, e), o = Math.max(Math.ceil(s / kNe(r, 50, 70, 100, 130)), 6, Math.ceil(s / Math.min(t, e))), a = s / o * 0.2, l = Math.max(t - a * 2, 1), c = Math.max(e - a * 2, 1), u = (t - l) / 2, d = (e - c) / 2, h = y7(l, c) / o, f = bNe(l, c, o).map((w) => w.addXY(u, d)), y = t < 20 ? 0 : a * 0.3, g = e < 20 ? 0 : a * 0.3, O = f.slice(0);
    for (let w = 0; w < Math.floor(o / 2); w++)
      O[w] = I.AddXY(O[w], i() * y, i() * g), O[o - w - 1] = I.AddXY(O[o - w - 1], i() * y, i() * g);
    const S = [];
    for (let w = 0; w < O.length; w++) {
      const x = w === O.length - 1 ? 0 : w + 1, P = O[w], C = O[x], _ = f[w], T = f[x], $ = I.Average([
        _,
        T
      ]), N = I.Angle(_, T) - Math.PI / 2, L = I.Dist(_, T), z = h - L, R = I.Dist(P, C) / L, F = (Math.max(u, d) + z) * R, Q = I.Add($, I.FromAngle(N, F));
      Q.x < 0 ? Q.x = 0 : Q.x > t && (Q.x = t), Q.y < 0 ? Q.y = 0 : Q.y > e && (Q.y = e);
      const X = pee(P, C, Q), Z = I.Dist(X || I.Average([
        P,
        C
      ]), P);
      S.push({
        leftPoint: P,
        rightPoint: C,
        arcPoint: Q,
        center: X,
        radius: Z
      });
    }
    return S;
  }
  function pee(t, e, n) {
    const r = t.x * (e.y - n.y) - t.y * (e.x - n.x) + e.x * n.y - n.x * e.y, i = (t.x * t.x + t.y * t.y) * (n.y - e.y) + (e.x * e.x + e.y * e.y) * (t.y - n.y) + (n.x * n.x + n.y * n.y) * (e.y - t.y), s = (t.x * t.x + t.y * t.y) * (e.x - n.x) + (e.x * e.x + e.y * e.y) * (n.x - t.x) + (n.x * n.x + n.y * n.y) * (t.x - e.x), o = -i / (2 * r), a = -s / (2 * r);
    return !Number.isFinite(o) || !Number.isFinite(a) ? null : new I(o, a);
  }
  function PNe(t, e, n, r) {
    const i = [], s = gS(t, e, n, r);
    for (const { center: o, radius: a, leftPoint: l, rightPoint: c } of s)
      i.push(...CNe(l, c, o, a, 10));
    return i;
  }
  function mS(t, e, n, r) {
    const i = gS(t, e, n, r);
    let s = `M${Y(i[0].leftPoint.x)},${Y(i[0].leftPoint.y)}`;
    for (const { leftPoint: o, rightPoint: a, radius: l, center: c } of i) {
      if (c === null) {
        s += ` L${Y(a.x)},${Y(a.y)}`;
        continue;
      }
      const u = mee(o, a, c) ? "0" : "1";
      s += ` A${Y(l)},${Y(l)} 0 ${u},1 ${Y(a.x)},${Y(a.y)}`;
    }
    return s += " Z", s;
  }
  function gee(t, e, n, r) {
    const i = md(n), s = r === "s" ? 0.5 : r === "m" ? 0.7 : r === "l" ? 0.9 : 1.6, o = (y) => y + i() * s * 2, a = gS(t, e, n, r), u = a.reduce((y, g) => y + I.Dist(g.leftPoint, g.rightPoint), 0) / a.length > s * 15 ? (y) => new I(o(y.x), o(y.y)) : (y) => y;
    let d = `M${Y(a[0].leftPoint.x)},${Y(a[0].leftPoint.y)}`, h = u(a[0].leftPoint), f = `M${Y(h.x)},${Y(h.y)}`;
    for (const { leftPoint: y, center: g, rightPoint: O, radius: S, arcPoint: w } of a) {
      if (g === null) {
        d += ` L${Y(O.x)},${Y(O.y)}`;
        const $ = u(O);
        f += ` L${Y($.x)},${Y($.y)}`, h = $;
        continue;
      }
      const x = mee(y, O, g) ? "0" : "1";
      d += ` A${Y(S)},${Y(S)} 0 ${x},1 ${Y(O.x)},${Y(O.y)}`;
      const P = u(O), C = u(w), _ = pee(h, P, C);
      if (!_) {
        f += ` L${Y(P.x)},${Y(P.y)}`, h = P;
        continue;
      }
      const T = Math.abs(I.Dist(_, h));
      f += ` A${Y(T)},${Y(T)} 0 ${x},1 ${Y(P.x)},${Y(P.y)}`, h = P;
    }
    return d + f + " Z";
  }
  function CNe(t, e, n, r, i) {
    if (n === null)
      return [
        I.From(t),
        I.From(e)
      ];
    const s = [], o = I.Angle(n, t), a = I.Angle(n, e), l = _C(o, a);
    for (let c = 0; c < i; c++) {
      const u = c / (i - 1), d = o + l * u, h = yG(n.x, n.y, r, d);
      s.push(h);
    }
    return s;
  }
  function mee(t, e, n) {
    return (e.x - t.x) * (n.y - t.y) - (e.y - t.y) * (n.x - t.x) > 0;
  }
  const _Ne = b.memo(function({ dash: e, fill: n, color: r, strokeWidth: i, w: s, h: o, id: a, size: l }) {
    const c = Ir(), u = mS(s, o, a, l), d = gS(s, o, a, l);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          theme: c,
          d: u,
          fill: n,
          color: r
        }),
        m.jsx("g", {
          strokeWidth: i,
          stroke: c[r].solid,
          fill: "none",
          pointerEvents: "all",
          children: d.map(({ leftPoint: h, rightPoint: f, center: y, radius: g }, O) => {
            const S = y ? g * Qa(Qa(I.Angle(y, f)) - Qa(I.Angle(y, h))) : I.Dist(h, f), { strokeDasharray: w, strokeDashoffset: x } = xi(S, i, {
              style: e,
              start: "outset",
              end: "outset"
            });
            return m.jsx("path", {
              d: y ? `M${h.x},${h.y}A${g},${g},0,0,1,${f.x},${f.y}` : `M${h.x},${h.y}L${f.x},${f.y}`,
              strokeDasharray: w,
              strokeDashoffset: x
            }, O);
          })
        })
      ]
    });
  });
  function TNe({ dash: t, fill: e, color: n, theme: r, strokeWidth: i, w: s, h: o, id: a, size: l }) {
    const c = mS(s, o, a, l), u = gS(s, o, a, l), d = document.createElementNS("http://www.w3.org/2000/svg", "g");
    d.setAttribute("stroke-width", i.toString()), d.setAttribute("stroke", r[n].solid), d.setAttribute("fill", "none");
    for (const { leftPoint: f, rightPoint: y, center: g, radius: O } of u) {
      const S = g ? O * Qa(Qa(I.Angle(g, y)) - Qa(I.Angle(g, f))) : I.Dist(f, y), { strokeDasharray: w, strokeDashoffset: x } = xi(S, i, {
        style: t,
        start: "outset",
        end: "outset"
      }), P = document.createElementNS("http://www.w3.org/2000/svg", "path");
      P.setAttribute("d", g ? `M${f.x},${f.y}A${O},${O},0,0,1,${y.x},${y.y}` : `M${f.x},${f.y}L${y.x},${y.y}`), P.setAttribute("stroke-dasharray", w.toString()), P.setAttribute("stroke-dashoffset", x.toString()), d.appendChild(P);
    }
    const h = ho({
      d: c,
      fill: e,
      color: n,
      theme: r
    });
    return qa(d, h);
  }
  const ENe = b.memo(function({ w: e, h: n, strokeWidth: r, dash: i, color: s, fill: o }) {
    const a = Ir(), l = e / 2, c = n / 2, u = Math.max(0, l), d = Math.max(0, c), h = Wv(u, d), { strokeDasharray: f, strokeDashoffset: y } = xi(h < 64 ? h * 2 : h, r, {
      style: i,
      snap: 4,
      closed: true
    }), g = `M${l - u},${c}a${u},${d},0,1,1,${u * 2},0a${u},${d},0,1,1,-${u * 2},0`;
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          theme: a,
          d: g,
          color: s,
          fill: o
        }),
        m.jsx("path", {
          d: g,
          strokeWidth: r,
          width: Y(e),
          height: Y(n),
          fill: "none",
          stroke: a[s].solid,
          strokeDasharray: f,
          strokeDashoffset: y,
          pointerEvents: "all"
        })
      ]
    });
  });
  function INe({ w: t, h: e, strokeWidth: n, dash: r, color: i, theme: s, fill: o }) {
    const a = t / 2, l = e / 2, c = Math.max(0, a - n / 2), u = Math.max(0, l - n / 2), d = Wv(c, u), { strokeDasharray: h, strokeDashoffset: f } = xi(d < 64 ? d * 2 : d, n, {
      style: r,
      snap: 4,
      closed: true
    }), y = `M${a - c},${l}a${c},${u},0,1,1,${c * 2},0a${c},${u},0,1,1,-${c * 2},0`, g = document.createElementNS("http://www.w3.org/2000/svg", "path");
    g.setAttribute("d", y), g.setAttribute("stroke-width", n.toString()), g.setAttribute("width", t.toString()), g.setAttribute("height", e.toString()), g.setAttribute("fill", "none"), g.setAttribute("stroke", s[i].solid), g.setAttribute("stroke-dasharray", h), g.setAttribute("stroke-dashoffset", f);
    const O = ho({
      d: y,
      fill: o,
      color: i,
      theme: s
    });
    return qa(g, O);
  }
  function yee(t, e) {
    if (e > t) {
      const r = t / 2;
      return `
    M0,${r}
    a${r},${r},0,1,1,${r * 2},0
    L${t},${e - r}
    a${r},${r},0,1,1,-${r * 2},0
    Z`;
    }
    const n = e / 2;
    return `
    M${n},0
    L${t - n},0
    a${n},${n},0,1,1,0,${n * 2}
    L${n},${e}
    a${n},${n},0,1,1,0,${-n * 2}
    Z`;
  }
  function vee(t, e) {
    if (t > e) {
      const r = e / 2;
      return Wv(r, r) + (t - r * 2) * 2;
    }
    const n = t / 2;
    return Wv(n, n) + (e - n * 2) * 2;
  }
  const $Ne = b.memo(function({ w: e, h: n, strokeWidth: r, dash: i, color: s, fill: o }) {
    const a = Ir(), l = yee(e, n), c = vee(e, n), { strokeDasharray: u, strokeDashoffset: d } = xi(c < 64 ? c * 2 : c, r, {
      style: i,
      snap: 4,
      start: "outset",
      end: "outset",
      closed: true
    });
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          theme: a,
          d: l,
          color: s,
          fill: o
        }),
        m.jsx("path", {
          d: l,
          strokeWidth: r,
          width: Y(e),
          height: Y(n),
          fill: "none",
          stroke: a[s].solid,
          strokeDasharray: u,
          strokeDashoffset: d,
          pointerEvents: "all"
        })
      ]
    });
  });
  function v7({ w: t, h: e, strokeWidth: n, dash: r, color: i, theme: s, fill: o }) {
    const a = yee(t, e), l = vee(t, e), { strokeDasharray: c, strokeDashoffset: u } = xi(l < 64 ? l * 2 : l, n, {
      style: r,
      snap: 4,
      closed: true
    }), d = document.createElementNS("http://www.w3.org/2000/svg", "path");
    d.setAttribute("d", a), d.setAttribute("stroke-width", n.toString()), d.setAttribute("width", t.toString()), d.setAttribute("height", e.toString()), d.setAttribute("fill", "none"), d.setAttribute("stroke", s[i].solid), d.setAttribute("stroke-dasharray", c), d.setAttribute("stroke-dashoffset", u);
    const h = ho({
      d: a,
      fill: o,
      color: i,
      theme: s
    });
    return qa(d, h);
  }
  const ANe = b.memo(function({ dash: e, fill: n, color: r, strokeWidth: i, outline: s, lines: o }) {
    const a = Ir(), l = "M" + s[0] + "L" + s.slice(1) + "Z";
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          theme: a,
          d: l,
          fill: n,
          color: r
        }),
        m.jsxs("g", {
          strokeWidth: i,
          stroke: a[r].solid,
          fill: "none",
          pointerEvents: "all",
          children: [
            Array.from(Array(s.length)).map((c, u) => {
              const d = s[u], h = s[(u + 1) % s.length], f = I.Dist(d, h), { strokeDasharray: y, strokeDashoffset: g } = xi(f, i, {
                style: e,
                start: "outset",
                end: "outset"
              });
              return m.jsx("line", {
                x1: d.x,
                y1: d.y,
                x2: h.x,
                y2: h.y,
                strokeDasharray: y,
                strokeDashoffset: g
              }, u);
            }),
            o && o.map(([c, u], d) => {
              const h = I.Dist(c, u), { strokeDasharray: f, strokeDashoffset: y } = xi(h, i, {
                style: e,
                start: "skip",
                end: "outset",
                snap: e === "dotted" ? 4 : void 0
              });
              return m.jsx("path", {
                d: `M${c.x},${c.y}L${u.x},${u.y}`,
                stroke: a[r].solid,
                strokeWidth: i,
                fill: "none",
                strokeDasharray: f,
                strokeDashoffset: y
              }, `line_fg_${d}`);
            })
          ]
        })
      ]
    });
  });
  function RNe({ dash: t, fill: e, color: n, theme: r, strokeWidth: i, outline: s, lines: o }) {
    const a = document.createElementNS("http://www.w3.org/2000/svg", "g");
    if (a.setAttribute("stroke-width", i.toString()), a.setAttribute("stroke", r[n].solid), a.setAttribute("fill", "none"), Array.from(Array(s.length)).forEach((c, u) => {
      const d = s[u], h = s[(u + 1) % s.length], f = I.Dist(d, h), { strokeDasharray: y, strokeDashoffset: g } = xi(f, i, {
        style: t
      }), O = document.createElementNS("http://www.w3.org/2000/svg", "line");
      O.setAttribute("x1", d.x.toString()), O.setAttribute("y1", d.y.toString()), O.setAttribute("x2", h.x.toString()), O.setAttribute("y2", h.y.toString()), O.setAttribute("stroke-dasharray", y.toString()), O.setAttribute("stroke-dashoffset", g.toString()), a.appendChild(O);
    }), o)
      for (const [c, u] of o) {
        const d = I.Dist(c, u), { strokeDasharray: h, strokeDashoffset: f } = xi(d, i, {
          style: t,
          start: "skip",
          end: "skip",
          snap: t === "dotted" ? 4 : 2
        }), y = document.createElementNS("http://www.w3.org/2000/svg", "line");
        y.setAttribute("x1", c.x.toString()), y.setAttribute("y1", c.y.toString()), y.setAttribute("x2", u.x.toString()), y.setAttribute("y2", u.y.toString()), y.setAttribute("stroke-dasharray", h.toString()), y.setAttribute("stroke-dashoffset", f.toString()), a.appendChild(y);
      }
    const l = ho({
      d: "M" + s[0] + "L" + s.slice(1) + "Z",
      fill: e,
      color: n,
      theme: r
    });
    return qa(a, l);
  }
  const MNe = b.memo(function({ fill: e, color: n, strokeWidth: r, w: i, h: s, id: o, size: a }) {
    const l = Ir(), c = gee(i, s, o, a);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          theme: l,
          d: c,
          fill: e,
          color: n
        }),
        m.jsx("path", {
          d: c,
          stroke: l[n].solid,
          strokeWidth: r,
          fill: "none"
        })
      ]
    });
  });
  function DNe({ fill: t, color: e, strokeWidth: n, theme: r, w: i, h: s, id: o, size: a }) {
    const l = gee(i, s, o, a), c = document.createElementNS("http://www.w3.org/2000/svg", "path");
    c.setAttribute("d", l), c.setAttribute("stroke-width", n.toString()), c.setAttribute("stroke", r[e].solid), c.setAttribute("fill", "none");
    const u = ho({
      d: l,
      fill: t,
      color: e,
      theme: r
    });
    return qa(c, u);
  }
  b.memo(function({ id: e, w: n, h: r, strokeWidth: i, fill: s, color: o }) {
    const a = Ir(), l = EL(e, n, r, i), c = wee(e, n, r, i);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          theme: a,
          d: l,
          color: o,
          fill: s
        }),
        m.jsx("path", {
          d: c,
          fill: a[o].solid,
          strokeWidth: 0,
          pointerEvents: "all"
        })
      ]
    });
  });
  function LNe({ id: t, w: e, h: n, strokeWidth: r, fill: i, color: s, theme: o }) {
    const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
    a.setAttribute("d", wee(t, e, n, r)), a.setAttribute("fill", o[s].solid);
    const l = ho({
      d: EL(t, e, n, r),
      fill: i,
      color: s,
      theme: o
    });
    return qa(a, l);
  }
  function Oee(t) {
    return {
      size: 1 + t,
      thinning: 0.25,
      end: {
        taper: t
      },
      start: {
        taper: t
      },
      streamline: 0,
      smoothing: 1,
      simulatePressure: false
    };
  }
  function See(t, e, n, r) {
    const i = md(t), s = e / 2, o = n / 2, a = Wv(s, o), l = [], c = Bt * i(), u = Bt + Ft / 2 + Math.abs(i()) * Ft, d = Math.max(16, a / 10);
    for (let h = 0; h < d; h++) {
      const f = h / (d - 1), y = c + f * u, g = Math.cos(y), O = Math.sin(y);
      l.push(new I(s * g + e * 0.5 + 0.05 * i(), o * O + n / 2 + 0.05 * i(), Math.min(1, 0.5 + Math.abs(0.5 - (i() > 0 ? Oi.easeInOutSine(f) : Oi.easeInExpo(f))) / 2)));
    }
    return Ic(l, Oee(r));
  }
  function wee(t, e, n, r) {
    const i = Oee(r);
    return Qg(Vg(Xg(See(t, e, n, r), i), i));
  }
  function EL(t, e, n, r) {
    return Wh(See(t, e, n, r));
  }
  const jNe = b.memo(function({ id: e, outline: n, lines: r, fill: i, color: s, strokeWidth: o }) {
    const a = Ir(), l = iO(e, n, o / 3, o * 2, 2);
    let c = rO(l);
    if (r)
      for (const [h, f] of r)
        c += `M${h.x},${h.y}L${f.x},${f.y}`;
    const u = iO(e, n, 0, o * 2, 1), d = rO(u);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          d,
          fill: i,
          color: s,
          theme: a
        }),
        m.jsx("path", {
          d: c,
          stroke: a[s].solid,
          strokeWidth: o,
          fill: "none"
        })
      ]
    });
  });
  function NNe({ id: t, outline: e, lines: n, fill: r, color: i, theme: s, strokeWidth: o }) {
    const a = iO(t, e, o / 3, o * 2, 2);
    let l = rO(a);
    if (n)
      for (const [f, y] of n)
        l += `M${f.x},${f.y}L${y.x},${y.y}`;
    const c = iO(t, e, 0, o * 2, 1), u = rO(c), d = document.createElementNS("http://www.w3.org/2000/svg", "path");
    d.setAttribute("d", l), d.setAttribute("fill", "none"), d.setAttribute("stroke", s[i].solid), d.setAttribute("stroke-width", o.toString());
    const h = ho({
      d: u,
      fill: r,
      color: i,
      theme: s
    });
    return qa(d, h);
  }
  const QNe = b.memo(function({ fill: e, color: n, strokeWidth: r, w: i, h: s, id: o, size: a }) {
    const l = Ir(), c = mS(i, s, o, a);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          theme: l,
          d: c,
          fill: e,
          color: n
        }),
        m.jsx("path", {
          d: c,
          stroke: l[n].solid,
          strokeWidth: r,
          fill: "none"
        })
      ]
    });
  });
  function zNe({ fill: t, color: e, strokeWidth: n, theme: r, w: i, h: s, id: o, size: a }) {
    const l = mS(i, s, o, a), c = document.createElementNS("http://www.w3.org/2000/svg", "path");
    c.setAttribute("d", l), c.setAttribute("stroke-width", n.toString()), c.setAttribute("stroke", r[e].solid), c.setAttribute("fill", "none");
    const u = ho({
      d: l,
      fill: t,
      color: e,
      theme: r
    });
    return qa(c, u);
  }
  const O7 = b.memo(function({ w: e, h: n, strokeWidth: r, fill: i, color: s }) {
    const o = Ir(), a = e / 2, l = n / 2, c = Math.max(0, a), u = Math.max(0, l), d = `M${a - c},${l}a${c},${u},0,1,1,${c * 2},0a${c},${u},0,1,1,-${c * 2},0`;
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          d,
          color: s,
          fill: i,
          theme: o
        }),
        m.jsx("path", {
          d,
          stroke: o[s].solid,
          strokeWidth: r,
          fill: "none"
        })
      ]
    });
  });
  function FNe({ w: t, h: e, strokeWidth: n, fill: r, color: i, theme: s }) {
    const o = t / 2, a = e / 2, l = Math.max(0, o), c = Math.max(0, a), u = `M${o - l},${a}a${l},${c},0,1,1,${l * 2},0a${l},${c},0,1,1,-${l * 2},0`, d = document.createElementNS("http://www.w3.org/2000/svg", "path");
    d.setAttribute("d", u), d.setAttribute("stroke-width", n.toString()), d.setAttribute("width", t.toString()), d.setAttribute("height", e.toString()), d.setAttribute("fill", "none"), d.setAttribute("stroke", s[i].solid);
    const h = ho({
      d: u,
      fill: r,
      color: i,
      theme: s
    });
    return qa(d, h);
  }
  const S7 = b.memo(function({ w: e, h: n, strokeWidth: r, fill: i, color: s }) {
    const o = Ir(), a = IL(e, n);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          d: a,
          color: s,
          fill: i,
          theme: o
        }),
        m.jsx("path", {
          d: a,
          stroke: o[s].solid,
          strokeWidth: r,
          fill: "none"
        })
      ]
    });
  });
  function BNe({ w: t, h: e, strokeWidth: n, fill: r, color: i, theme: s }) {
    const o = IL(t, e), a = document.createElementNS("http://www.w3.org/2000/svg", "path");
    a.setAttribute("d", o), a.setAttribute("stroke-width", n.toString()), a.setAttribute("width", t.toString()), a.setAttribute("height", e.toString()), a.setAttribute("fill", "none"), a.setAttribute("stroke", s[i].solid);
    const l = ho({
      d: o,
      fill: r,
      color: i,
      theme: s
    });
    return qa(a, l);
  }
  function IL(t, e) {
    let n;
    if (e > t) {
      const r = t / 2;
      n = `
    M0,${r}
    a${r},${r},0,1,1,${r * 2},0
    L${t},${e - r}
    a${r},${r},0,1,1,-${r * 2},0
    Z`;
    } else {
      const r = e / 2;
      n = `
    M${r},0
    L${t - r},0
    a${r},${r},0,1,1,0,${r * 2}
    L${r},${e}
    a${r},${r},0,1,1,0,${-r * 2}
    Z`;
    }
    return n;
  }
  const UNe = b.memo(function({ outline: e, lines: n, fill: r, color: i, strokeWidth: s }) {
    const o = Ir();
    let a = "M" + e[0] + "L" + e.slice(1) + "Z";
    if (n)
      for (const [l, c] of n)
        a += `M${l.x},${l.y}L${c.x},${c.y}`;
    return m.jsxs(m.Fragment, {
      children: [
        m.jsx(qn, {
          d: a,
          fill: r,
          color: i,
          theme: o
        }),
        m.jsx("path", {
          d: a,
          stroke: o[i].solid,
          strokeWidth: s,
          fill: "none"
        })
      ]
    });
  });
  function VNe({ outline: t, lines: e, fill: n, color: r, strokeWidth: i, theme: s }) {
    const o = "M" + t[0] + "L" + t.slice(1) + "Z", a = o;
    let l = o;
    if (e)
      for (const [d, h] of e)
        l += `M${d.x},${d.y}L${h.x},${h.y}`;
    const c = document.createElementNS("http://www.w3.org/2000/svg", "path");
    c.setAttribute("d", l), c.setAttribute("stroke-width", i.toString()), c.setAttribute("stroke", s[r].solid), c.setAttribute("fill", "none");
    const u = ho({
      d: a,
      fill: n,
      color: r,
      theme: s
    });
    return qa(c, u);
  }
  const mI = 16, _o = 17 * 3;
  class XNe extends Cm {
    constructor() {
      super(...arguments);
      __publicField(this, "canEdit", () => true);
      __publicField(this, "onEditEnd", (e) => {
        const { id: n, type: r, props: { text: i } } = e;
        i.trimEnd() !== e.props.text && this.editor.updateShapes([
          {
            id: n,
            type: r,
            props: {
              text: i.trimEnd()
            }
          }
        ]);
      });
      __publicField(this, "onResize", (e, { handle: n, newPoint: r, scaleX: i, scaleY: s, initialShape: o }) => {
        let a = o.props.w * i, l = (o.props.h + o.props.growY) * s, c = 0, u = 0;
        if (e.props.text.trim()) {
          let y = Math.max(Math.abs(a), _o), g = Math.max(Math.abs(l), _o);
          y < _o && g === _o && (y = _o), y === _o && g < _o && (g = _o);
          const O = Aw(this.editor, {
            ...e,
            props: {
              ...e.props,
              w: y,
              h: g
            }
          }), S = Math.max(Math.abs(a), O.w) * Math.sign(a), w = Math.max(Math.abs(l), O.h) * Math.sign(l);
          c = Math.abs(S) - Math.abs(a), u = Math.abs(w) - Math.abs(l), a = S, l = w;
        }
        const d = new I(0, 0);
        i < 0 && (d.x += a), (n === "left" || n === "top_left" || n === "bottom_left") && (d.x += i < 0 ? c : -c), s < 0 && (d.y += l), (n === "top" || n === "top_left" || n === "top_right") && (d.y += s < 0 ? u : -u);
        const { x: h, y: f } = d.rot(e.rotation).add(r);
        return {
          x: h,
          y: f,
          props: {
            w: Math.max(Math.abs(a), 1),
            h: Math.max(Math.abs(l), 1),
            growY: 0
          }
        };
      });
      __publicField(this, "onBeforeCreate", (e) => {
        if (!e.props.text)
          return e.props.growY ? {
            ...e,
            props: {
              ...e.props,
              growY: 0
            }
          } : void 0;
        const n = e.props.h, r = Aw(this.editor, e).h;
        let i = null;
        if (r > n ? i = r - n : e.props.growY && (i = 0), i !== null)
          return {
            ...e,
            props: {
              ...e.props,
              growY: i
            }
          };
      });
      __publicField(this, "onBeforeUpdate", (e, n) => {
        const r = e.props.text, i = n.props.text;
        if (r === i && e.props.font === n.props.font && e.props.size === n.props.size)
          return;
        if (r && !i)
          return {
            ...n,
            props: {
              ...n.props,
              growY: 0
            }
          };
        const s = e.props.w, o = e.props.h, a = Aw(this.editor, n), l = a.w, c = a.h;
        if (!r && i && i.length === 1) {
          let d = Math.max(s, l), h = Math.max(o, c);
          return e.props.w < _o && e.props.h < _o && (d = Math.max(d, _o), h = Math.max(h, _o), d = Math.max(d, h), h = Math.max(d, h)), {
            ...n,
            props: {
              ...n.props,
              w: d,
              h,
              growY: 0
            }
          };
        }
        let u = null;
        if (c > o ? u = c - o : e.props.growY && (u = 0), u !== null)
          return {
            ...n,
            props: {
              ...n.props,
              growY: u,
              w: Math.max(n.props.w, l)
            }
          };
        if (l > e.props.w)
          return {
            ...n,
            props: {
              ...n.props,
              w: l
            }
          };
      });
      __publicField(this, "onDoubleClick", (e) => {
        if (this.editor.inputs.altKey)
          switch (e.props.geo) {
            case "rectangle":
              return {
                ...e,
                props: {
                  geo: "check-box"
                }
              };
            case "check-box":
              return {
                ...e,
                props: {
                  geo: "rectangle"
                }
              };
          }
      });
    }
    getDefaultProps() {
      return {
        w: 100,
        h: 100,
        geo: "rectangle",
        color: "black",
        labelColor: "black",
        fill: "none",
        dash: "draw",
        size: "m",
        font: "draw",
        text: "",
        align: "middle",
        verticalAlign: "middle",
        growY: 0,
        url: ""
      };
    }
    getGeometry(e) {
      const n = Math.max(1, e.props.w), r = Math.max(1, e.props.h + e.props.growY), i = n / 2, s = r / 2, o = mi[e.props.size], a = e.props.fill !== "none";
      let l;
      switch (e.props.geo) {
        case "cloud": {
          l = new xr({
            points: PNe(n, r, e.id, e.props.size),
            isFilled: a
          });
          break;
        }
        case "triangle": {
          l = new xr({
            points: [
              new I(i, 0),
              new I(n, r),
              new I(0, r)
            ],
            isFilled: a
          });
          break;
        }
        case "diamond": {
          l = new xr({
            points: [
              new I(i, 0),
              new I(n, s),
              new I(i, r),
              new I(0, s)
            ],
            isFilled: a
          });
          break;
        }
        case "pentagon": {
          l = new xr({
            points: xE(n, r, 5),
            isFilled: a
          });
          break;
        }
        case "hexagon": {
          l = new xr({
            points: xE(n, r, 6),
            isFilled: a
          });
          break;
        }
        case "octagon": {
          l = new xr({
            points: xE(n, r, 8),
            isFilled: a
          });
          break;
        }
        case "ellipse": {
          l = new yq({
            width: n,
            height: r,
            isFilled: a
          });
          break;
        }
        case "oval": {
          l = new mEe({
            width: n,
            height: r,
            isFilled: a
          });
          break;
        }
        case "star": {
          const g = Bt / 5 / 2, O = Math.floor(5 / 4) * 2, S = 5 * 2 - O, w = 0, x = Math.floor(5 / 2) * 2, P = Math.cos(-Ft + O * g) * n / 2, C = Math.cos(-Ft + S * g) * n / 2, _ = Math.sin(-Ft + w * g) * r / 2, T = Math.sin(-Ft + x * g) * r / 2, $ = n - Math.abs(P - C), N = r - Math.abs(T - _), L = n / 2 + C - (n / 2 - P), z = r / 2 + _ - (r / 2 - T), M = 1, R = (n - L) / 2, F = (r - z) / 2, Q = (n + $) / 2, X = (r + N) / 2, Z = Q * M / 2, U = X * M / 2;
          l = new xr({
            points: Array.from(Array(5 * 2)).map((H, te) => {
              const se = -Ft + te * g;
              return new I(R + (te % 2 ? Z : Q) * Math.cos(se), F + (te % 2 ? U : X) * Math.sin(se));
            }),
            isFilled: a
          });
          break;
        }
        case "rhombus": {
          const y = Math.min(n * 0.38, r * 0.38);
          l = new xr({
            points: [
              new I(y, 0),
              new I(n, 0),
              new I(n - y, r),
              new I(0, r)
            ],
            isFilled: a
          });
          break;
        }
        case "rhombus-2": {
          const y = Math.min(n * 0.38, r * 0.38);
          l = new xr({
            points: [
              new I(0, 0),
              new I(n - y, 0),
              new I(n, r),
              new I(y, r)
            ],
            isFilled: a
          });
          break;
        }
        case "trapezoid": {
          const y = Math.min(n * 0.38, r * 0.38);
          l = new xr({
            points: [
              new I(y, 0),
              new I(n - y, 0),
              new I(n, r),
              new I(0, r)
            ],
            isFilled: a
          });
          break;
        }
        case "arrow-right": {
          const y = Math.min(n, r) * 0.38, g = r * 0.16;
          l = new xr({
            points: [
              new I(0, g),
              new I(n - y, g),
              new I(n - y, 0),
              new I(n, r / 2),
              new I(n - y, r),
              new I(n - y, r - g),
              new I(0, r - g)
            ],
            isFilled: a
          });
          break;
        }
        case "arrow-left": {
          const y = Math.min(n, r) * 0.38, g = r * 0.16;
          l = new xr({
            points: [
              new I(y, 0),
              new I(y, g),
              new I(n, g),
              new I(n, r - g),
              new I(y, r - g),
              new I(y, r),
              new I(0, r / 2)
            ],
            isFilled: a
          });
          break;
        }
        case "arrow-up": {
          const y = n * 0.16, g = Math.min(n, r) * 0.38;
          l = new xr({
            points: [
              new I(n / 2, 0),
              new I(n, g),
              new I(n - y, g),
              new I(n - y, r),
              new I(y, r),
              new I(y, g),
              new I(0, g)
            ],
            isFilled: a
          });
          break;
        }
        case "arrow-down": {
          const y = n * 0.16, g = Math.min(n, r) * 0.38;
          l = new xr({
            points: [
              new I(y, 0),
              new I(n - y, 0),
              new I(n - y, r - g),
              new I(n, r - g),
              new I(n / 2, r),
              new I(0, r - g),
              new I(y, r - g)
            ],
            isFilled: a
          });
          break;
        }
        case "check-box":
        case "x-box":
        case "rectangle": {
          l = new wd({
            width: n,
            height: r,
            isFilled: a,
            isSnappable: true
          });
          break;
        }
      }
      const c = Aw(this.editor, e), u = Math.min(n, Math.max(c.w, Math.min(32, Math.max(1, n - 8)))), d = Math.min(r, Math.max(c.h, Math.min(32, Math.max(1, n - 8)))), h = Rw(e.props, o), f = h ? h.map((y) => new Sf({
        points: y
      })) : [];
      return new Yu({
        children: [
          l,
          new wd({
            x: e.props.align === "start" ? 0 : e.props.align === "end" ? n - u : (n - u) / 2,
            y: e.props.verticalAlign === "start" ? 0 : e.props.verticalAlign === "end" ? r - d : (r - d) / 2,
            width: u,
            height: d,
            isFilled: true,
            isSnappable: false,
            isLabel: true
          }),
          ...f
        ],
        isSnappable: false
      });
    }
    component(e) {
      const { id: n, type: r, props: i } = e, s = mi[i.size], { w: o, color: a, labelColor: l, fill: c, dash: u, growY: d, font: h, align: f, verticalAlign: y, size: g, text: O } = i, S = () => {
        const w = i.h + d;
        switch (i.geo) {
          case "cloud": {
            if (u === "solid")
              return m.jsx(QNe, {
                color: a,
                fill: c,
                strokeWidth: s,
                w: o,
                h: w,
                id: n,
                size: g
              });
            if (u === "dashed" || u === "dotted")
              return m.jsx(_Ne, {
                color: a,
                fill: c,
                strokeWidth: s,
                w: o,
                h: w,
                id: n,
                size: g,
                dash: u
              });
            if (u === "draw")
              return m.jsx(MNe, {
                color: a,
                fill: c,
                strokeWidth: s,
                w: o,
                h: w,
                id: n,
                size: g
              });
            break;
          }
          case "ellipse": {
            if (u === "solid")
              return m.jsx(O7, {
                strokeWidth: s,
                w: o,
                h: w,
                color: a,
                fill: c
              });
            if (u === "dashed" || u === "dotted")
              return m.jsx(ENe, {
                id: n,
                strokeWidth: s,
                w: o,
                h: w,
                dash: u,
                color: a,
                fill: c
              });
            if (u === "draw")
              return m.jsx(O7, {
                strokeWidth: s,
                w: o,
                h: w,
                color: a,
                fill: c
              });
            break;
          }
          case "oval": {
            if (u === "solid")
              return m.jsx(S7, {
                strokeWidth: s,
                w: o,
                h: w,
                color: a,
                fill: c
              });
            if (u === "dashed" || u === "dotted")
              return m.jsx($Ne, {
                id: n,
                strokeWidth: s,
                w: o,
                h: w,
                dash: u,
                color: a,
                fill: c
              });
            if (u === "draw")
              return m.jsx(S7, {
                strokeWidth: s,
                w: o,
                h: w,
                color: a,
                fill: c
              });
            break;
          }
          default: {
            const x = this.editor.getShapeGeometry(e), P = x instanceof Yu ? x.children[0].vertices : x.vertices, C = Rw(e.props, s);
            if (u === "solid")
              return m.jsx(UNe, {
                fill: c,
                color: a,
                strokeWidth: s,
                outline: P,
                lines: C
              });
            if (u === "dashed" || u === "dotted")
              return m.jsx(ANe, {
                dash: u,
                fill: c,
                color: a,
                strokeWidth: s,
                outline: P,
                lines: C
              });
            if (u === "draw")
              return m.jsx(jNe, {
                id: n,
                fill: c,
                color: a,
                strokeWidth: s,
                outline: P,
                lines: C
              });
          }
        }
      };
      return m.jsxs(m.Fragment, {
        children: [
          m.jsx(Gs, {
            id: n,
            children: S()
          }),
          m.jsx(dee, {
            id: n,
            type: r,
            font: h,
            fill: c,
            size: g,
            align: f,
            verticalAlign: y,
            text: O,
            labelColor: l,
            wrap: true,
            bounds: i.geo === "cloud" ? this.getGeometry(e).bounds : void 0
          }),
          e.props.url && m.jsx(pS, {
            url: e.props.url,
            zoomLevel: this.editor.zoomLevel
          })
        ]
      });
    }
    indicator(e) {
      const { id: n, props: r } = e, { w: i, size: s } = r, o = r.h + r.growY, a = mi[s];
      switch (r.geo) {
        case "ellipse":
          return r.dash === "draw" ? m.jsx("path", {
            d: EL(n, i, o, a)
          }) : m.jsx("ellipse", {
            cx: i / 2,
            cy: o / 2,
            rx: i / 2,
            ry: o / 2
          });
        case "oval":
          return m.jsx("path", {
            d: IL(i, o)
          });
        case "cloud":
          return m.jsx("path", {
            d: mS(i, o, n, s)
          });
        default: {
          const l = this.editor.getShapeGeometry(e), c = l instanceof Yu ? l.children[0].vertices : l.vertices;
          let u;
          if (r.dash === "draw") {
            const h = iO(n, c, 0, a * 2, 1);
            u = rO(h);
          } else
            u = "M" + c[0] + "L" + c.slice(1) + "Z";
          const d = Rw(e.props, a);
          if (d)
            for (const [h, f] of d)
              u += `M${h.x},${h.y}L${f.x},${f.y}`;
          return m.jsx("path", {
            d: u
          });
        }
      }
    }
    toSvg(e, n) {
      const { id: r, props: i } = e, s = mi[i.size], o = ks({
        isDarkMode: this.editor.user.isDarkMode
      });
      n.addExportDef(PL(e.props.fill, o));
      let a;
      switch (i.geo) {
        case "ellipse": {
          switch (i.dash) {
            case "draw":
              a = LNe({
                id: r,
                w: i.w,
                h: i.h,
                color: i.color,
                fill: i.fill,
                strokeWidth: s,
                theme: o
              });
              break;
            case "solid":
              a = FNe({
                strokeWidth: s,
                w: i.w,
                h: i.h,
                color: i.color,
                fill: i.fill,
                theme: o
              });
              break;
            default:
              a = INe({
                id: r,
                strokeWidth: s,
                w: i.w,
                h: i.h,
                dash: i.dash,
                color: i.color,
                fill: i.fill,
                theme: o
              });
              break;
          }
          break;
        }
        case "oval": {
          switch (i.dash) {
            case "draw":
              a = v7({
                id: r,
                strokeWidth: s,
                w: i.w,
                h: i.h,
                dash: i.dash,
                color: i.color,
                fill: i.fill,
                theme: o
              });
              break;
            case "solid":
              a = BNe({
                strokeWidth: s,
                w: i.w,
                h: i.h,
                color: i.color,
                fill: i.fill,
                theme: o
              });
              break;
            default:
              a = v7({
                id: r,
                strokeWidth: s,
                w: i.w,
                h: i.h,
                dash: i.dash,
                color: i.color,
                fill: i.fill,
                theme: o
              });
          }
          break;
        }
        case "cloud": {
          switch (i.dash) {
            case "draw":
              a = DNe({
                id: r,
                strokeWidth: s,
                w: i.w,
                h: i.h,
                color: i.color,
                fill: i.fill,
                size: i.size,
                theme: o
              });
              break;
            case "solid":
              a = zNe({
                strokeWidth: s,
                w: i.w,
                h: i.h,
                color: i.color,
                fill: i.fill,
                size: i.size,
                id: r,
                theme: o
              });
              break;
            default:
              a = TNe({
                id: r,
                strokeWidth: s,
                w: i.w,
                h: i.h,
                dash: i.dash,
                color: i.color,
                fill: i.fill,
                theme: o,
                size: i.size
              });
          }
          break;
        }
        default: {
          const l = this.editor.getShapeGeometry(e), c = l instanceof Yu ? l.children[0].vertices : l.vertices, u = Rw(e.props, s);
          switch (i.dash) {
            case "draw":
              a = NNe({
                id: r,
                fill: i.fill,
                color: i.color,
                strokeWidth: s,
                outline: c,
                lines: u,
                theme: o
              });
              break;
            case "solid":
              a = VNe({
                fill: i.fill,
                color: i.color,
                strokeWidth: s,
                outline: c,
                lines: u,
                theme: o
              });
              break;
            default:
              a = RNe({
                dash: i.dash,
                fill: i.fill,
                color: i.color,
                strokeWidth: s,
                outline: c,
                lines: u,
                theme: o
              });
              break;
          }
          break;
        }
      }
      if (i.text) {
        const l = this.editor.getShapeGeometry(e).bounds;
        n.addExportDef(o2(e.props.font));
        const c = hee({
          editor: this.editor,
          shape: e,
          font: GO[e.props.font],
          bounds: l
        }), u = c.cloneNode(true);
        u.setAttribute("fill", o[e.props.labelColor].solid), u.setAttribute("stroke", "none");
        const d = c.cloneNode(true);
        d.setAttribute("stroke-width", "2"), d.setAttribute("fill", o.background), d.setAttribute("stroke", o.background);
        const h = document.createElementNS("http://www.w3.org/2000/svg", "g");
        if (h.append(d), h.append(u), a.nodeName === "g")
          return a.appendChild(h), a;
        {
          const f = document.createElementNS("http://www.w3.org/2000/svg", "g");
          return f.appendChild(a), f.appendChild(h), f;
        }
      }
      return a;
    }
    getCanvasSvgDefs() {
      return [
        CL()
      ];
    }
  }
  __publicField(XNe, "type", "geo");
  __publicField(XNe, "props", Sbe);
  __publicField(XNe, "migrations", wbe);
  function Aw(t, e) {
    const n = e.props.text;
    if (!n)
      return {
        w: 0,
        h: 0
      };
    const r = t.textMeasure.measureText("w", {
      ...Wr,
      fontFamily: Nc[e.props.font],
      fontSize: Wg[e.props.size],
      maxWidth: 100
    }), i = {
      s: 2,
      m: 3.5,
      l: 5,
      xl: 10
    }, s = t.textMeasure.measureText(n, {
      ...Wr,
      fontFamily: Nc[e.props.font],
      fontSize: Wg[e.props.size],
      minWidth: r.w + "px",
      maxWidth: Math.max(0, Math.ceil(r.w + i[e.props.size]), Math.ceil(e.props.w - mI * 2))
    });
    return {
      w: s.w + mI * 2,
      h: s.h + mI * 2
    };
  }
  function Rw(t, e) {
    switch (t.geo) {
      case "x-box":
        return WNe(t.w, t.h, e, t.dash);
      case "check-box":
        return ZNe(t.w, t.h);
      default:
        return;
    }
  }
  function WNe(t, e, n, r) {
    const i = r === "draw" ? 0.62 : 0;
    if (r === "dashed")
      return [
        [
          new I(0, 0),
          new I(t / 2, e / 2)
        ],
        [
          new I(t, e),
          new I(t / 2, e / 2)
        ],
        [
          new I(0, e),
          new I(t / 2, e / 2)
        ],
        [
          new I(t, 0),
          new I(t / 2, e / 2)
        ]
      ];
    const s = (a) => Math.max(0, Math.min(t, a)), o = (a) => Math.max(0, Math.min(e, a));
    return [
      [
        new I(s(n * i), o(n * i)),
        new I(s(t - n * i), o(e - n * i))
      ],
      [
        new I(s(n * i), o(e - n * i)),
        new I(s(t - n * i), o(n * i))
      ]
    ];
  }
  function ZNe(t, e) {
    const n = Math.min(t, e) * 0.82, r = (t - n) / 2, i = (e - n) / 2, s = (a) => Math.max(0, Math.min(t, a)), o = (a) => Math.max(0, Math.min(e, a));
    return [
      [
        new I(s(r + n * 0.25), o(i + n * 0.52)),
        new I(s(r + n * 0.45), o(i + n * 0.82))
      ],
      [
        new I(s(r + n * 0.45), o(i + n * 0.82)),
        new I(s(r + n * 0.82), o(i + n * 0.22))
      ]
    ];
  }
  function HNe() {
    const [t, e] = b.useState(false);
    return b.useEffect(() => {
      const r = CSS.supports("color", "color(display-p3 1 1 1)"), i = matchMedia("(color-gamut: p3)");
      e(r && i.matches);
      const s = () => e(r && i.matches);
      return i.addEventListener("change", s), () => i.removeEventListener("change", s);
    }, []), ye(un.forceSrgb) || !t ? "srgb" : "p3";
  }
  const w7 = 0.35, x7 = 0.82;
  class YNe extends Nd {
    constructor() {
      super(...arguments);
      __publicField(this, "hideResizeHandles", (e) => Mw(e));
      __publicField(this, "hideRotateHandle", (e) => Mw(e));
      __publicField(this, "hideSelectionBoundsFg", (e) => Mw(e));
      __publicField(this, "onResize", (e, n) => {
        const { scaleX: r, scaleY: i } = n, s = [];
        for (const o of e.props.segments)
          s.push({
            ...o,
            points: o.points.map(({ x: a, y: l, z: c }) => ({
              x: r * a,
              y: i * l,
              z: c
            }))
          });
        return {
          props: {
            segments: s
          }
        };
      });
    }
    getDefaultProps() {
      return {
        segments: [],
        color: "black",
        size: "m",
        isComplete: false,
        isPen: false
      };
    }
    getGeometry(e) {
      const n = xp(e);
      if (Mw(e))
        return new mq({
          x: -n / 2,
          y: -n / 2,
          radius: n / 2,
          isFilled: true
        });
      const { strokePoints: r, sw: i } = xee(e, n, true), s = $R({
        strokeWidth: i,
        showAsComplete: true
      });
      return Xg(r, s), new xr({
        points: Vg(r, s),
        isFilled: true
      });
    }
    component(e) {
      return m.jsx(b7, {
        strokeWidth: xp(e),
        shape: e,
        opacity: w7
      });
    }
    backgroundComponent(e) {
      return m.jsx(b7, {
        strokeWidth: xp(e),
        shape: e,
        opacity: x7
      });
    }
    indicator(e) {
      var _a3;
      const n = Wk(), r = xp(e), i = rg(e.props.segments);
      let s = r;
      !n && !e.props.isPen && i.length === 1 && (s += md(e.id)() * (r / 6));
      const o = e.props.isComplete || ((_a3 = as(e.props.segments)) == null ? void 0 : _a3.type) === "straight", a = $R({
        strokeWidth: r,
        showAsComplete: o
      }), l = Ic(i, a);
      let c;
      return l.length < 2 ? c = qNe(i[0], s) : c = Wh(l, false), m.jsx("path", {
        d: c
      });
    }
    toSvg(e) {
      const n = ks({
        isDarkMode: this.editor.user.isDarkMode
      });
      return k7(xp(e), e, w7, n);
    }
    toBackgroundSvg(e) {
      const n = ks({
        isDarkMode: this.editor.user.isDarkMode
      });
      return k7(xp(e), e, x7, n);
    }
  }
  __publicField(YNe, "type", "highlight");
  __publicField(YNe, "props", kbe);
  __publicField(YNe, "migrations", Pbe);
  function GNe(t) {
    return `M ${t.x} ${t.y} m -${0.1}, 0 a ${0.1},${0.1} 0 1,0 ${0.1 * 2},0 a ${0.1},${0.1} 0 1,0 -${0.1 * 2},0`;
  }
  function qNe(t, e) {
    const n = e / 2;
    return `M ${t.x} ${t.y} m -${n}, 0 a ${n},${n} 0 1,0 ${n * 2},0 a ${n},${n} 0 1,0 -${n * 2},0`;
  }
  function xee(t, e, n) {
    var _a3;
    const r = rg(t.props.segments), i = t.props.isComplete || ((_a3 = as(t.props.segments)) == null ? void 0 : _a3.type) === "straight";
    let s = e;
    !n && !t.props.isPen && r.length === 1 && (s += md(t.id)() * (e / 6));
    const o = $R({
      strokeWidth: s,
      showAsComplete: i
    });
    return {
      strokePoints: Ic(r, o),
      sw: s
    };
  }
  function bee(t, e, n) {
    const { strokePoints: r, sw: i } = xee(t, e, n);
    return {
      solidStrokePath: r.length > 1 ? Wh(r, false) : GNe(t.props.segments[0].points[0]),
      sw: i
    };
  }
  function b7({ strokeWidth: t, shape: e, opacity: n }) {
    const r = Ir(), i = Wk(), { solidStrokePath: s, sw: o } = bee(e, t, i), a = HNe(), l = r[e.props.color].highlight[a];
    return m.jsx(Gs, {
      id: e.id,
      style: {
        opacity: n
      },
      children: m.jsx("path", {
        d: s,
        strokeLinecap: "round",
        fill: "none",
        pointerEvents: "all",
        stroke: l,
        strokeWidth: o
      })
    });
  }
  function k7(t, e, n, r) {
    const { solidStrokePath: i, sw: s } = bee(e, t, false), o = document.createElementNS("http://www.w3.org/2000/svg", "path");
    return o.setAttribute("d", i), o.setAttribute("fill", "none"), o.setAttribute("stroke", r[e.props.color].highlight.srgb), o.setAttribute("stroke-width", `${s}`), o.setAttribute("opacity", `${n}`), o;
  }
  function xp(t) {
    return qu[t.props.size] * 1.12;
  }
  function Mw(t) {
    return t.props.segments.length === 1 && t.props.segments[0].points.length < 2;
  }
  function kee() {
    const [t, e] = b.useState(false);
    return b.useEffect(() => {
      const n = window.matchMedia("(prefers-reduced-motion: reduce)"), r = () => {
        e(n.matches);
      };
      return r(), n.addEventListener("change", r), () => n.removeEventListener("change", r);
    }, []), t;
  }
  const KNe = async (t) => new Promise((e, n) => {
    const r = new Image();
    r.onload = () => e(r), r.onerror = () => n(new Error("Failed to load image")), r.crossOrigin = "anonymous", r.src = t;
  }), JNe = async (t) => {
    const e = await KNe(t), n = document.createElement("canvas");
    n.width = e.width, n.height = e.height;
    const r = n.getContext("2d");
    if (r)
      return r.drawImage(e, 0, 0), n.toDataURL();
  };
  async function e4e(t) {
    const n = await (await fetch(t)).blob();
    return new Promise((r, i) => {
      const s = new FileReader();
      s.onloadend = () => r(s.result), s.onerror = i, s.readAsDataURL(n);
    });
  }
  class t4e extends Cm {
    constructor() {
      super(...arguments);
      __publicField(this, "isAspectRatioLocked", () => true);
      __publicField(this, "canCrop", () => true);
      __publicField(this, "onDoubleClick", (e) => {
        const n = e.props.assetId ? this.editor.getAsset(e.props.assetId) : void 0;
        !n || !(n.props.src && "mimeType" in n.props && n.props.mimeType === "image/gif") || this.editor.updateShapes([
          {
            type: "image",
            id: e.id,
            props: {
              playing: !e.props.playing
            }
          }
        ]);
      });
      __publicField(this, "onDoubleClickEdge", (e) => {
        const n = e.props;
        if (!n || this.editor.croppingShapeId !== e.id)
          return;
        const r = wi(n.crop) || {
          topLeft: {
            x: 0,
            y: 0
          },
          bottomRight: {
            x: 1,
            y: 1
          }
        }, i = 1 / (r.bottomRight.x - r.topLeft.x) * e.props.w, s = 1 / (r.bottomRight.y - r.topLeft.y) * e.props.h, o = new I(r.topLeft.x * i, r.topLeft.y * s).rot(e.rotation), a = {
          id: e.id,
          type: e.type,
          x: e.x - o.x,
          y: e.y - o.y,
          props: {
            crop: {
              topLeft: {
                x: 0,
                y: 0
              },
              bottomRight: {
                x: 1,
                y: 1
              }
            },
            w: i,
            h: s
          }
        };
        this.editor.updateShapes([
          a
        ]);
      });
    }
    getDefaultProps() {
      return {
        w: 100,
        h: 100,
        assetId: null,
        playing: true,
        url: "",
        crop: null
      };
    }
    component(e) {
      var _a3, _b3;
      const n = P7(e), r = G8(e.id), i = kee(), [s, o] = b.useState(""), a = e.props.assetId ? this.editor.getAsset(e.props.assetId) : void 0;
      if ((a == null ? void 0 : a.type) === "bookmark")
        throw Error("Bookmark assets can't be rendered as images");
      const c = ye("onlySelectedShape", () => {
        var _a4;
        return e.id === ((_a4 = this.editor.onlySelectedShape) == null ? void 0 : _a4.id);
      }, [
        this.editor
      ]) && r && this.editor.isInAny("select.crop", "select.cropping", "select.pointing_crop_handle"), u = i && (((_a3 = a == null ? void 0 : a.props.mimeType) == null ? void 0 : _a3.includes("video")) || ((_b3 = a == null ? void 0 : a.props.mimeType) == null ? void 0 : _b3.includes("gif")));
      return b.useEffect(() => {
        if ((a == null ? void 0 : a.props.src) && "mimeType" in a.props && (a == null ? void 0 : a.props.mimeType) === "image/gif") {
          let d = false;
          return (async () => {
            const f = await JNe(a.props.src);
            d || f && o(f);
          })(), () => {
            d = true;
          };
        }
      }, [
        i,
        a == null ? void 0 : a.props
      ]), m.jsxs(m.Fragment, {
        children: [
          (a == null ? void 0 : a.props.src) && c && m.jsx("div", {
            style: n,
            children: m.jsx("div", {
              className: "tl-image",
              style: {
                opacity: 0.1,
                backgroundImage: `url(${!e.props.playing || u ? s : a.props.src})`
              },
              draggable: false
            })
          }),
          m.jsx(Fg, {
            id: e.id,
            style: {
              overflow: "hidden",
              width: e.props.w,
              height: e.props.h
            },
            children: m.jsxs("div", {
              className: "tl-image-container",
              style: n,
              children: [
                (a == null ? void 0 : a.props.src) ? m.jsx("div", {
                  className: "tl-image",
                  style: {
                    backgroundImage: `url(${!e.props.playing || u ? s : a.props.src})`
                  },
                  draggable: false
                }) : null,
                (a == null ? void 0 : a.props.isAnimated) && !e.props.playing && m.jsx("div", {
                  className: "tl-image__tg",
                  children: "GIF"
                })
              ]
            })
          }),
          "url" in e.props && e.props.url && m.jsx(pS, {
            url: e.props.url,
            zoomLevel: this.editor.zoomLevel
          })
        ]
      });
    }
    indicator(e) {
      return G8(e.id) ? null : m.jsx("rect", {
        width: Y(e.props.w),
        height: Y(e.props.h)
      });
    }
    async toSvg(e) {
      var _a3;
      const n = document.createElementNS("http://www.w3.org/2000/svg", "g");
      let i = ((_a3 = e.props.assetId ? this.editor.getAsset(e.props.assetId) : null) == null ? void 0 : _a3.props.src) || "";
      i && i.startsWith("http") && (i = await e4e(i) || "");
      const s = document.createElementNS("http://www.w3.org/2000/svg", "image");
      s.setAttributeNS("http://www.w3.org/1999/xlink", "href", i);
      const o = P7(e), a = e.props.crop;
      if (o.transform && a) {
        const { transform: l, width: c, height: u } = o, d = [
          new I(a.topLeft.x * c, a.topLeft.y * u),
          new I(a.bottomRight.x * c, a.topLeft.y * u),
          new I(a.bottomRight.x * c, a.bottomRight.y * u),
          new I(a.topLeft.x * c, a.bottomRight.y * u)
        ], h = document.createElementNS("http://www.w3.org/2000/svg", "g");
        h.style.clipPath = `polygon(${d.map((f) => `${f.x}px ${f.y}px`).join(",")})`, s.setAttribute("width", c.toString()), s.setAttribute("height", u.toString()), s.style.transform = l, h.appendChild(s), n.appendChild(h);
      } else
        s.setAttribute("width", e.props.w.toString()), s.setAttribute("height", e.props.h.toString()), n.appendChild(s);
      return n;
    }
  }
  __publicField(t4e, "type", "image");
  __publicField(t4e, "props", _be);
  __publicField(t4e, "migrations", Tbe);
  function P7(t) {
    const e = t.props.crop, n = e == null ? void 0 : e.topLeft;
    if (!n)
      return {
        width: t.props.w,
        height: t.props.h
      };
    const r = 1 / (e.bottomRight.x - e.topLeft.x) * t.props.w, i = 1 / (e.bottomRight.y - e.topLeft.y) * t.props.h, s = -n.x * r, o = -n.y * i;
    return {
      transform: `translate(${s}px, ${o}px)`,
      width: r,
      height: i
    };
  }
  function AR(t, e) {
    const { start: n, end: r } = t;
    return e ? `M${Y(n.x)},${Y(n.y)} L${Y(r.x)},${Y(r.y)} ` : `${Y(r.x)},${Y(r.y)} `;
  }
  function RR(t, e) {
    const { a: n, b: r, c: i, d: s } = t;
    return I.Equals(n, s) ? "" : `${e ? `M${Y(n.x)},${Y(n.y)}` : ""}C${Y(r.x)},${Y(r.y)} ${Y(i.x)},${Y(i.y)} ${Y(s.x)},${Y(s.y)}`;
  }
  function Pee(t, e) {
    let n = t.segments.reduce((r, i, s) => r + RR(i, s === 0), "");
    return e && (n += "Z"), n;
  }
  function n4e(t, e) {
    let n = t.segments.reduce((r, i, s) => r + AR(i, s === 0), "");
    return e && (n += "Z"), n;
  }
  function Cee(t, e = false) {
    return t instanceof Sf ? n4e(t, e) : Pee(t, e);
  }
  function _ee(t) {
    return {
      size: t,
      thinning: 0.4,
      streamline: 0,
      smoothing: 0.5,
      simulatePressure: true,
      last: true
    };
  }
  function Tee(t, e, n) {
    const r = e.vertices, i = _ee(n);
    return Ic(r, i);
  }
  function r4e(t, e, n) {
    const r = _ee(n);
    return Vg(Xg(Tee(t, e, n), r), r);
  }
  function C7(t, e, n) {
    const r = r4e(t, e, n);
    return Qg(r);
  }
  function i4e(t, e, n) {
    if (t.props.dash === "draw") {
      const r = Tee(t, e, n);
      return Wh(r);
    }
    return Cee(e);
  }
  const s4e = new _5();
  class o4e extends Nd {
    constructor() {
      super(...arguments);
      __publicField(this, "hideResizeHandles", () => true);
      __publicField(this, "hideRotateHandle", () => true);
      __publicField(this, "hideSelectionBoundsFg", () => true);
      __publicField(this, "hideSelectionBoundsBg", () => true);
      __publicField(this, "onResize", (e, n) => {
        const { scaleX: r, scaleY: i } = n, s = wi(e.props.handles);
        return Object.values(e.props.handles).forEach(({ id: o, x: a, y: l }) => {
          s[o].x = a * r, s[o].y = l * i;
        }), {
          props: {
            handles: s
          }
        };
      });
      __publicField(this, "onHandleChange", (e, { handle: n }) => {
        const r = wi(e);
        switch (n.id) {
          case "start":
          case "end": {
            r.props.handles[n.id] = {
              ...r.props.handles[n.id],
              x: n.x,
              y: n.y
            };
            break;
          }
          default: {
            const i = "handle:" + n.index, s = e.props.handles[i];
            s ? r.props.handles[i] = {
              ...s,
              x: n.x,
              y: n.y
            } : r.props.handles[i] = {
              id: i,
              type: "vertex",
              canBind: false,
              index: n.index,
              x: n.x,
              y: n.y
            };
            break;
          }
        }
        return r;
      });
    }
    getDefaultProps() {
      return {
        dash: "draw",
        size: "m",
        color: "black",
        spline: "line",
        handles: {
          start: {
            id: "start",
            type: "vertex",
            canBind: false,
            canSnap: true,
            index: "a1",
            x: 0,
            y: 0
          },
          end: {
            id: "end",
            type: "vertex",
            canBind: false,
            canSnap: true,
            index: "a2",
            x: 0.1,
            y: 0.1
          }
        }
      };
    }
    getGeometry(e) {
      return Wy(e);
    }
    getHandles(e) {
      return s4e.get(e.props, () => {
        const n = e.props.handles, r = Wy(e), i = Object.values(n).sort(hi), s = i.slice();
        for (let o = 0; o < r.segments.length; o++) {
          const l = r.segments[o].midPoint(), c = G0(i[o].index, i[o + 1].index);
          s.push({
            id: `mid-${o}`,
            type: "create",
            index: c,
            x: l.x,
            y: l.y
          });
        }
        return s.sort(hi);
      });
    }
    getOutlineSegments(e) {
      return this.editor.getShapeGeometry(e).segments.map((r) => r.vertices);
    }
    component(e) {
      const n = Ir(), r = Wy(e), i = mi[e.props.size], { dash: s, color: o } = e.props;
      if (e.props.spline === "line") {
        if (s === "solid") {
          const a = r.points, l = "M" + a[0] + "L" + a.slice(1);
          return m.jsxs(Gs, {
            id: e.id,
            children: [
              m.jsx(qn, {
                d: l,
                fill: "none",
                color: o,
                theme: n
              }),
              m.jsx("path", {
                d: l,
                stroke: n[o].solid,
                strokeWidth: i,
                fill: "none"
              })
            ]
          });
        }
        if (s === "dashed" || s === "dotted") {
          const a = r.points, l = "M" + a[0] + "L" + a.slice(1);
          return m.jsxs(Gs, {
            id: e.id,
            children: [
              m.jsx(qn, {
                d: l,
                fill: "none",
                color: o,
                theme: n
              }),
              m.jsx("g", {
                stroke: n[o].solid,
                strokeWidth: i,
                children: r.segments.map((c, u) => {
                  const { strokeDasharray: d, strokeDashoffset: h } = xi(c.length, i, {
                    style: s,
                    start: u > 0 ? "outset" : "none",
                    end: u < r.segments.length - 1 ? "outset" : "none"
                  });
                  return m.jsx("path", {
                    strokeDasharray: d,
                    strokeDashoffset: h,
                    d: AR(c, true),
                    fill: "none"
                  }, u);
                })
              })
            ]
          });
        }
        if (s === "draw") {
          const a = r.points, [l, c] = gI(e.id, a, i);
          return m.jsxs(Gs, {
            id: e.id,
            children: [
              m.jsx(qn, {
                d: l,
                fill: "none",
                color: o,
                theme: n
              }),
              m.jsx("path", {
                d: c,
                stroke: n[o].solid,
                strokeWidth: i,
                fill: "none"
              })
            ]
          });
        }
      }
      if (e.props.spline === "cubic") {
        const a = Cee(r);
        if (s === "solid")
          return m.jsxs(Gs, {
            id: e.id,
            children: [
              m.jsx(qn, {
                d: a,
                fill: "none",
                color: o,
                theme: n
              }),
              m.jsx("path", {
                strokeWidth: i,
                stroke: n[o].solid,
                fill: "none",
                d: a
              })
            ]
          });
        if (s === "dashed" || s === "dotted")
          return m.jsxs(Gs, {
            id: e.id,
            children: [
              m.jsx(qn, {
                d: a,
                fill: "none",
                color: o,
                theme: n
              }),
              m.jsx("g", {
                stroke: n[o].solid,
                strokeWidth: i,
                children: r.segments.map((l, c) => {
                  const { strokeDasharray: u, strokeDashoffset: d } = xi(l.length, i, {
                    style: s,
                    start: c > 0 ? "outset" : "none",
                    end: c < r.segments.length - 1 ? "outset" : "none"
                  });
                  return m.jsx("path", {
                    strokeDasharray: u,
                    strokeDashoffset: d,
                    d: RR(l, true),
                    fill: "none"
                  }, c);
                })
              })
            ]
          });
        if (s === "draw")
          return m.jsxs(Gs, {
            id: e.id,
            children: [
              m.jsx(qn, {
                d: a,
                fill: "none",
                color: o,
                theme: n
              }),
              m.jsx("path", {
                d: C7(e, r, i),
                strokeWidth: 1,
                stroke: n[o].solid,
                fill: n[o].solid
              })
            ]
          });
      }
    }
    indicator(e) {
      const n = mi[e.props.size], r = Wy(e), { dash: i } = e.props;
      let s;
      if (e.props.spline === "line") {
        const o = r.points;
        if (i === "solid" || i === "dotted" || i === "dashed")
          s = "M" + o[0] + "L" + o.slice(1);
        else {
          const [a] = gI(e.id, o, n);
          s = a;
        }
      } else
        s = i4e(e, r, n);
      return m.jsx("path", {
        d: s
      });
    }
    toSvg(e) {
      const r = ks({
        isDarkMode: this.editor.user.isDarkMode
      })[e.props.color].solid, i = Wy(e), s = mi[e.props.size];
      switch (e.props.dash) {
        case "draw": {
          let o;
          if (i instanceof Gx)
            o = C7(e, i, s);
          else {
            const [l, c] = gI(e.id, i.points, s);
            o = c;
          }
          const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
          return a.setAttribute("stroke-width", s + "px"), a.setAttribute("stroke", r), a.setAttribute("fill", "none"), a.setAttribute("d", o), a;
        }
        case "solid": {
          let o;
          if (i instanceof Gx)
            o = Pee(i, false);
          else {
            const l = i.points;
            o = "M" + l[0] + "L" + l.slice(1);
          }
          const a = document.createElementNS("http://www.w3.org/2000/svg", "path");
          return a.setAttribute("stroke-width", s + "px"), a.setAttribute("stroke", r), a.setAttribute("fill", "none"), a.setAttribute("d", o), a;
        }
        default: {
          const { segments: o } = i, a = document.createElementNS("http://www.w3.org/2000/svg", "g");
          a.setAttribute("stroke", r), a.setAttribute("stroke-width", s.toString());
          const l = i instanceof Gx ? RR : AR;
          return o.forEach((c, u) => {
            const d = document.createElementNS("http://www.w3.org/2000/svg", "path"), { strokeDasharray: h, strokeDashoffset: f } = xi(c.length, s, {
              style: e.props.dash,
              start: u > 0 ? "outset" : "none",
              end: u < o.length - 1 ? "outset" : "none"
            });
            d.setAttribute("stroke-dasharray", h.toString()), d.setAttribute("stroke-dashoffset", f.toString()), d.setAttribute("d", l(c, true)), d.setAttribute("fill", "none"), a.appendChild(d);
          }), a;
        }
      }
    }
  }
  __publicField(o4e, "type", "line");
  __publicField(o4e, "props", $be);
  __publicField(o4e, "migrations", Abe);
  function Wy(t) {
    const { spline: e, handles: n } = t.props, r = Object.values(n).sort(hi).map(I.From);
    switch (e) {
      case "cubic":
        return new Gx({
          points: r
        });
      case "line":
        return new Sf({
          points: r
        });
    }
  }
  const xc = 200;
  class a4e extends Nd {
    constructor() {
      super(...arguments);
      __publicField(this, "canEdit", () => true);
      __publicField(this, "hideResizeHandles", () => true);
      __publicField(this, "hideSelectionBoundsFg", () => true);
      __publicField(this, "onBeforeCreate", (e) => _7(this.editor, e, e.props.growY));
      __publicField(this, "onBeforeUpdate", (e, n) => {
        if (!(e.props.text === n.props.text && e.props.font === n.props.font && e.props.size === n.props.size))
          return _7(this.editor, n, e.props.growY);
      });
      __publicField(this, "onEditEnd", (e) => {
        const { id: n, type: r, props: { text: i } } = e;
        i.trimEnd() !== e.props.text && this.editor.updateShapes([
          {
            id: n,
            type: r,
            props: {
              text: i.trimEnd()
            }
          }
        ]);
      });
    }
    getDefaultProps() {
      return {
        color: "black",
        size: "m",
        text: "",
        font: "draw",
        align: "middle",
        verticalAlign: "middle",
        growY: 0,
        url: ""
      };
    }
    getHeight(e) {
      return xc + e.props.growY;
    }
    getGeometry(e) {
      const n = this.getHeight(e);
      return new wd({
        width: xc,
        height: n,
        isFilled: true
      });
    }
    component(e) {
      const { id: n, type: r, props: { color: i, font: s, size: o, align: a, text: l, verticalAlign: c } } = e, u = Ir(), d = i === "black" ? "yellow" : i;
      return m.jsxs(m.Fragment, {
        children: [
          m.jsx("div", {
            style: {
              position: "absolute",
              width: xc,
              height: this.getHeight(e)
            },
            children: m.jsxs("div", {
              className: "tl-note__container",
              style: {
                color: u[d].solid,
                backgroundColor: u[d].solid
              },
              children: [
                m.jsx("div", {
                  className: "tl-note__scrim"
                }),
                m.jsx(dee, {
                  id: n,
                  type: r,
                  font: s,
                  size: o,
                  align: a,
                  verticalAlign: c,
                  text: l,
                  labelColor: "black",
                  wrap: true
                })
              ]
            })
          }),
          "url" in e.props && e.props.url && m.jsx(pS, {
            url: e.props.url,
            zoomLevel: this.editor.zoomLevel
          })
        ]
      });
    }
    indicator(e) {
      return m.jsx("rect", {
        rx: "7",
        width: Y(xc),
        height: Y(this.getHeight(e))
      });
    }
    toSvg(e, n) {
      n.addExportDef(o2(e.props.font));
      const r = ks({
        isDarkMode: this.editor.user.isDarkMode
      }), i = this.editor.getShapeGeometry(e).bounds, s = document.createElementNS("http://www.w3.org/2000/svg", "g"), o = e.props.color === "black" ? "yellow" : e.props.color, a = document.createElementNS("http://www.w3.org/2000/svg", "rect");
      a.setAttribute("rx", "10"), a.setAttribute("width", xc.toString()), a.setAttribute("height", i.height.toString()), a.setAttribute("fill", r[o].solid), a.setAttribute("stroke", r[o].solid), a.setAttribute("stroke-width", "1"), s.appendChild(a);
      const l = document.createElementNS("http://www.w3.org/2000/svg", "rect");
      l.setAttribute("rx", "10"), l.setAttribute("width", xc.toString()), l.setAttribute("height", i.height.toString()), l.setAttribute("fill", r.background), l.setAttribute("opacity", ".28"), s.appendChild(l);
      const c = hee({
        editor: this.editor,
        shape: e,
        font: GO[e.props.font],
        bounds: i
      });
      return c.setAttribute("fill", r.text), c.setAttribute("stroke", "none"), s.appendChild(c), s;
    }
  }
  __publicField(a4e, "type", "note");
  __publicField(a4e, "props", Rbe);
  __publicField(a4e, "migrations", Mbe);
  function _7(t, e, n = 0) {
    const s = t.textMeasure.measureText(e.props.text, {
      ...Wr,
      fontFamily: Nc[e.props.font],
      fontSize: Wg[e.props.size],
      maxWidth: xc - 34
    }).h + 17 * 2;
    let o = null;
    if (s > xc ? o = s - xc : n && (o = 0), o !== null)
      return {
        ...e,
        props: {
          ...e.props,
          growY: o
        }
      };
  }
  function l4e(t, { initialBounds: e, scaleX: n, scaleY: r, newPoint: i }) {
    const s = Math.max(0.01, Math.min(Math.abs(n), Math.abs(r))), o = new I(0, 0);
    n < 0 && (o.x = -(e.width * s)), r < 0 && (o.y = -(e.height * s));
    const { x: a, y: l } = I.Add(i, o.rot(t.rotation));
    return {
      x: a,
      y: l,
      props: {
        scale: s * t.props.scale
      }
    };
  }
  const c4e = new _5();
  class u4e extends Nd {
    constructor() {
      super(...arguments);
      __publicField(this, "canEdit", () => true);
      __publicField(this, "isAspectRatioLocked", () => true);
      __publicField(this, "onResize", (e, n) => {
        const { initialBounds: r, initialShape: i, scaleX: s, handle: o } = n;
        if (n.mode === "scale_shape" || o !== "right" && o !== "left")
          return {
            id: e.id,
            type: e.type,
            ...l4e(e, n)
          };
        {
          const a = r.width;
          let l = a * s;
          const c = new I(0, 0);
          l = Math.max(1, Math.abs(l)), o === "left" ? (c.x = a - l, s < 0 && (c.x += l)) : s < 0 && (c.x -= l);
          const { x: u, y: d } = c.rot(e.rotation).add(i);
          return {
            id: e.id,
            type: e.type,
            x: u,
            y: d,
            props: {
              w: l / i.props.scale,
              autoSize: false
            }
          };
        }
      });
      __publicField(this, "onBeforeCreate", (e) => {
        if (!e.props.autoSize || e.props.text.trim())
          return;
        const n = this.getMinDimensions(e);
        return {
          ...e,
          x: e.x - n.width / 2,
          y: e.y - n.height / 2
        };
      });
      __publicField(this, "onEditEnd", (e) => {
        const { id: n, type: r, props: { text: i } } = e, s = e.props.text.trimEnd();
        s.length === 0 ? this.editor.deleteShapes([
          e.id
        ]) : s !== e.props.text && this.editor.updateShapes([
          {
            id: n,
            type: r,
            props: {
              text: i.trimEnd()
            }
          }
        ]);
      });
      __publicField(this, "onBeforeUpdate", (e, n) => {
        if (!n.props.autoSize)
          return;
        const r = e.props.size !== n.props.size || e.props.align !== n.props.align || e.props.font !== n.props.font || e.props.scale !== 1 && n.props.scale === 1, i = e.props.text !== n.props.text;
        if (!r && !i)
          return;
        const s = this.getMinDimensions(e), o = T7(this.editor, n.props), a = s.width * e.props.scale, l = s.height * e.props.scale, c = o.width * n.props.scale, u = o.height * n.props.scale;
        let d;
        switch (n.props.align) {
          case "middle": {
            d = new I((c - a) / 2, i ? 0 : (u - l) / 2);
            break;
          }
          case "end": {
            d = new I(c - a, i ? 0 : (u - l) / 2);
            break;
          }
          default: {
            if (i)
              break;
            d = new I(0, (u - l) / 2);
            break;
          }
        }
        if (d) {
          d.rot(n.rotation);
          const { x: h, y: f } = n;
          return {
            ...n,
            x: h - d.x,
            y: f - d.y,
            props: {
              ...n.props,
              w: c
            }
          };
        } else
          return {
            ...n,
            props: {
              ...n.props,
              w: c
            }
          };
      });
      __publicField(this, "onDoubleClickEdge", (e) => {
        if (!e.props.autoSize)
          return {
            id: e.id,
            type: e.type,
            props: {
              autoSize: true
            }
          };
        if (e.props.scale !== 1)
          return {
            id: e.id,
            type: e.type,
            props: {
              scale: 1
            }
          };
      });
    }
    getDefaultProps() {
      return {
        color: "black",
        size: "m",
        w: 8,
        text: "",
        font: "draw",
        align: "middle",
        autoSize: true,
        scale: 1
      };
    }
    getMinDimensions(e) {
      return c4e.get(e.props, (n) => T7(this.editor, n));
    }
    getGeometry(e) {
      const { scale: n } = e.props, { width: r, height: i } = this.getMinDimensions(e);
      return new wd({
        width: r * n,
        height: i * n,
        isFilled: true
      });
    }
    component(e) {
      const { id: n, type: r, props: { text: i, color: s } } = e, o = ks({
        isDarkMode: this.editor.user.isDarkMode
      }), { width: a, height: l } = this.getMinDimensions(e), { rInput: c, isEmpty: u, isEditing: d, handleFocus: h, handleChange: f, handleKeyDown: y, handleBlur: g, handleInputPointerDown: O, handleDoubleClick: S } = _L(n, r, i);
      return m.jsx(Fg, {
        id: e.id,
        children: m.jsxs("div", {
          className: "tl-text-shape__wrapper tl-text-shadow",
          "data-font": e.props.font,
          "data-align": e.props.align,
          "data-hastext": !u,
          "data-isediting": d,
          "data-textwrap": true,
          style: {
            fontSize: qu[e.props.size],
            lineHeight: qu[e.props.size] * Wr.lineHeight + "px",
            transform: `scale(${e.props.scale})`,
            transformOrigin: "top left",
            width: Math.max(1, a),
            height: Math.max(qu[e.props.size] * Wr.lineHeight, l),
            color: o[s].solid
          },
          children: [
            m.jsx("div", {
              className: "tl-text tl-text-content",
              dir: "ltr",
              children: i
            }),
            d ? m.jsx("textarea", {
              ref: c,
              className: "tl-text tl-text-input",
              name: "text",
              tabIndex: -1,
              autoComplete: "false",
              autoCapitalize: "false",
              autoCorrect: "false",
              autoSave: "false",
              autoFocus: d,
              placeholder: "",
              spellCheck: "true",
              wrap: "off",
              dir: "ltr",
              datatype: "wysiwyg",
              defaultValue: i,
              onFocus: h,
              onChange: f,
              onKeyDown: y,
              onBlur: g,
              onTouchEnd: _r,
              onContextMenu: _r,
              onPointerDown: O,
              onDoubleClick: S
            }) : null
          ]
        })
      });
    }
    indicator(e) {
      const n = this.editor.getShapeGeometry(e).bounds;
      return m.jsx("rect", {
        width: Y(n.width),
        height: Y(n.height)
      });
    }
    toSvg(e, n) {
      n.addExportDef(o2(e.props.font));
      const r = ks({
        isDarkMode: this.editor.user.isDarkMode
      }), i = this.editor.getShapeGeometry(e).bounds, s = e.props.text, o = i.width / (e.props.scale ?? 1), a = i.height / (e.props.scale ?? 1), l = {
        fontSize: qu[e.props.size],
        fontFamily: GO[e.props.font],
        textAlign: e.props.align,
        verticalTextAlign: "middle",
        width: o,
        height: a,
        padding: 0,
        lineHeight: Wr.lineHeight,
        fontStyle: "normal",
        fontWeight: "normal",
        overflow: "wrap"
      }, c = r[e.props.color].solid, u = document.createElementNS("http://www.w3.org/2000/svg", "g"), d = s2(this.editor, this.editor.textMeasure.measureTextSpans(s, l), {
        ...l,
        stroke: r.background,
        strokeWidth: 2,
        fill: r.background,
        padding: 0
      }), h = d.cloneNode(true);
      return h.setAttribute("fill", c), h.setAttribute("stroke", "none"), u.append(d), u.append(h), u;
    }
  }
  __publicField(u4e, "type", "text");
  __publicField(u4e, "props", Dbe);
  __publicField(u4e, "migrations", Lbe);
  function T7(t, e) {
    const { font: n, text: r, autoSize: i, size: s, w: o } = e, a = i ? 16 : Math.max(16, o), l = qu[s], c = i ? null : Math.floor(Math.max(a, o)), u = t.textMeasure.measureText(r, {
      ...Wr,
      fontFamily: Nc[n],
      fontSize: l,
      maxWidth: c
    });
    return i && (u.w += 1), {
      width: Math.max(a, u.w),
      height: Math.max(l, u.h)
    };
  }
  class d4e extends Cm {
    constructor() {
      super(...arguments);
      __publicField(this, "canEdit", () => true);
      __publicField(this, "isAspectRatioLocked", () => true);
    }
    getDefaultProps() {
      return {
        w: 100,
        h: 100,
        assetId: null,
        time: 0,
        playing: true,
        url: ""
      };
    }
    component(e) {
      return m.jsx(f4e, {
        shape: e,
        videoUtil: this
      });
    }
    indicator(e) {
      return m.jsx("rect", {
        width: Y(e.props.w),
        height: Y(e.props.h)
      });
    }
    toSvg(e) {
      const n = document.createElementNS("http://www.w3.org/2000/svg", "g"), r = document.createElementNS("http://www.w3.org/2000/svg", "image");
      return r.setAttributeNS("http://www.w3.org/1999/xlink", "href", h4e(e.id)), r.setAttribute("width", e.props.w.toString()), r.setAttribute("height", e.props.h.toString()), n.appendChild(r), n;
    }
  }
  __publicField(d4e, "type", "video");
  __publicField(d4e, "props", jbe);
  __publicField(d4e, "migrations", Nbe);
  function h4e(t) {
    const e = t.split(":")[1], n = document.querySelector(`.tl-video-shape-${e}`);
    if (n) {
      const r = document.createElement("canvas");
      return r.width = n.videoWidth, r.height = n.videoHeight, r.getContext("2d").drawImage(n, 0, 0), r.toDataURL("image/png");
    } else
      throw new Error("Video with id " + e + " not found");
  }
  const f4e = Vt(function(e) {
    const { shape: n, videoUtil: r } = e, i = r.editor.getShapeGeometry(n).bounds.w * r.editor.zoomLevel >= 110, s = n.props.assetId ? r.editor.getAsset(n.props.assetId) : null, { time: o, playing: a } = n.props, l = MC(n.id), c = kee(), u = $e.useRef(null), d = $e.useCallback((S) => {
      const w = S.currentTarget;
      r.editor.updateShapes([
        {
          type: "video",
          id: n.id,
          props: {
            playing: true,
            time: w.currentTime
          }
        }
      ]);
    }, [
      n.id,
      r.editor
    ]), h = $e.useCallback((S) => {
      const w = S.currentTarget;
      r.editor.updateShapes([
        {
          type: "video",
          id: n.id,
          props: {
            playing: false,
            time: w.currentTime
          }
        }
      ]);
    }, [
      n.id,
      r.editor
    ]), f = $e.useCallback((S) => {
      const w = S.currentTarget;
      l && r.editor.updateShapes([
        {
          type: "video",
          id: n.id,
          props: {
            time: w.currentTime
          }
        }
      ]);
    }, [
      l,
      n.id,
      r.editor
    ]), [y, g] = $e.useState(false), O = $e.useCallback((S) => {
      const w = S.currentTarget;
      o !== w.currentTime && (w.currentTime = o), a || w.pause(), g(true);
    }, [
      a,
      o
    ]);
    return $e.useEffect(() => {
      const S = u.current;
      S && (y && !l && o !== S.currentTime && (S.currentTime = o), l && document.activeElement !== S && S.focus());
    }, [
      l,
      y,
      o
    ]), $e.useEffect(() => {
      if (c) {
        const S = u.current;
        S.pause(), S.currentTime = 0;
      }
    }, [
      u,
      c
    ]), m.jsxs(m.Fragment, {
      children: [
        m.jsx(Fg, {
          id: n.id,
          children: m.jsx("div", {
            className: "tl-counter-scaled",
            children: (s == null ? void 0 : s.props.src) ? m.jsx("video", {
              ref: u,
              style: l ? {
                pointerEvents: "all"
              } : void 0,
              className: `tl-video tl-video-shape-${n.id.split(":")[1]}`,
              width: "100%",
              height: "100%",
              draggable: false,
              playsInline: true,
              autoPlay: true,
              muted: true,
              loop: true,
              disableRemotePlayback: true,
              disablePictureInPicture: true,
              controls: l && i,
              onPlay: d,
              onPause: h,
              onTimeUpdate: f,
              onLoadedData: O,
              hidden: !y,
              children: m.jsx("source", {
                src: s.props.src
              })
            }) : null
          })
        }),
        "url" in n.props && n.props.url && m.jsx(pS, {
          url: n.props.url,
          zoomLevel: r.editor.zoomLevel
        })
      ]
    });
  }), Eee = [
    u4e,
    aNe,
    fNe,
    XNe,
    a4e,
    o4e,
    SNe,
    iNe,
    YNe,
    mNe,
    t4e,
    d4e
  ];
  function p4e(t) {
    return [
      t.sideEffects.registerAfterChangeHandler("instance", (e, n) => {
        e.isFocused !== n.isFocused && (n.isFocused ? (t.getContainer().focus(), t.updateViewportScreenBounds()) : (t.complete(), t.getContainer().blur(), t.updateViewportScreenBounds()));
      }),
      t.sideEffects.registerAfterChangeHandler("instance_page_state", (e, n) => {
        if (e.croppingShapeId !== n.croppingShapeId) {
          const r = t.isInAny("select.crop", "select.pointing_crop_handle", "select.cropping");
          !e.croppingShapeId && n.croppingShapeId ? r || t.setCurrentTool("select.crop.idle") : e.croppingShapeId && !n.croppingShapeId && r && t.setCurrentTool("select.idle");
        }
        e.editingShapeId !== n.editingShapeId && (!e.editingShapeId && n.editingShapeId ? t.isIn("select.editing_shape") || t.setCurrentTool("select.editing_shape") : e.editingShapeId && !n.editingShapeId && t.isIn("select.editing_shape") && t.setCurrentTool("select.idle"));
      })
    ];
  }
  class $L {
    constructor(e) {
      __publicField(this, "state");
      __publicField(this, "points");
      __publicField(this, "size");
      __publicField(this, "color");
      __publicField(this, "opacity");
      __publicField(this, "delay");
      __publicField(this, "timeoutMs", 0);
      __publicField(this, "delayRemaining", 0);
      __publicField(this, "onUpdate");
      __publicField(this, "onComplete");
      __publicField(this, "prev", null);
      __publicField(this, "next", null);
      __publicField(this, "resume", () => {
        this.state = "active";
      });
      __publicField(this, "pause", () => {
        this.state = "starting";
      });
      __publicField(this, "stop", () => {
        this.delayRemaining = Math.min(this.delayRemaining, 200), this.state = "stopping";
      });
      __publicField(this, "addPoint", (e, n) => {
        const { prev: r } = this, i = {
          x: e,
          y: n,
          z: 0.5
        };
        r && I.Dist(r, i) < 1 || (this.next = i);
      });
      __publicField(this, "tick", (e) => {
        this.timeoutMs += e, this.delayRemaining > 0 && (this.delayRemaining = Math.max(0, this.delayRemaining - e)), this.timeoutMs >= 16 && (this.timeoutMs = 0);
        const { timeoutMs: n, state: r, prev: i, next: s, points: o } = this;
        switch (r) {
          case "active": {
            s && s !== i ? (this.prev = s, o.push(s), this.delayRemaining === 0 && o.length > 8 && o.shift(), this.updateScribble()) : n === 0 && (o.length > 1 ? (o.shift(), this.updateScribble()) : this.delayRemaining = this.delay);
            break;
          }
          case "stopping": {
            if (this.delayRemaining === 0 && n === 0) {
              if (o.length === 1) {
                this.state = "paused", this.onComplete();
                return;
              }
              this.size *= 0.9, o.shift(), this.updateScribble();
            }
            break;
          }
        }
      });
      const { size: n = 20, color: r = "accent", opacity: i = 0.8, delay: s = 0, onComplete: o, onUpdate: a } = e;
      this.onUpdate = a, this.onComplete = o, this.size = n, this.color = r, this.delay = s, this.opacity = i, this.points = [], this.state = "starting", this.prev = null, this.next = null, this.delayRemaining = this.delay, this.resume();
    }
    getScribble() {
      return {
        state: this.state,
        size: this.size,
        color: this.color,
        opacity: this.opacity,
        delay: this.delay,
        points: [
          ...this.points
        ]
      };
    }
    updateScribble() {
      this.onUpdate(this.getScribble());
    }
  }
  class g4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "scribble", {});
      __publicField(this, "markId", "");
      __publicField(this, "excludedShapeIds", /* @__PURE__ */ new Set());
      __publicField(this, "onEnter", (e) => {
        this.markId = "erase scribble begin", this.editor.mark(this.markId), this.info = e;
        const { originPagePoint: n } = this.editor.inputs;
        this.excludedShapeIds = new Set(this.editor.currentPageShapes.filter((r) => {
          if (this.editor.isShapeOrAncestorLocked(r))
            return true;
          if (this.editor.isShapeOfType(r, "group") || this.editor.isShapeOfType(r, "frame")) {
            const i = this.editor.getPointInShapeSpace(r, n);
            return this.editor.getShapeGeometry(r).bounds.containsPoint(i);
          }
          return false;
        }).map((r) => r.id)), this.startScribble(), this.update();
      });
      __publicField(this, "startScribble", () => {
        var _a3;
        this.scribble.tick && this.editor.off("tick", (_a3 = this.scribble) == null ? void 0 : _a3.tick), this.scribble = new $L({
          onUpdate: this.onScribbleUpdate,
          onComplete: this.onScribbleComplete,
          color: "muted-1",
          size: 12
        }), this.editor.on("tick", this.scribble.tick);
      });
      __publicField(this, "pushPointToScribble", () => {
        const { x: e, y: n } = this.editor.inputs.currentPagePoint;
        this.scribble.addPoint(e, n);
      });
      __publicField(this, "onScribbleUpdate", (e) => {
        this.editor.updateInstanceState({
          scribble: e
        });
      });
      __publicField(this, "onScribbleComplete", () => {
        this.editor.off("tick", this.scribble.tick), this.editor.updateInstanceState({
          scribble: null
        });
      });
      __publicField(this, "onExit", () => {
        this.scribble.stop();
      });
      __publicField(this, "onPointerMove", () => {
        this.update();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
    }
    update() {
      const { zoomLevel: e, currentPageShapes: n, erasingShapeIds: r, inputs: { currentPagePoint: i, previousPagePoint: s } } = this.editor, { excludedShapeIds: o } = this;
      this.pushPointToScribble();
      const a = new Set(r);
      for (const l of n) {
        if (this.editor.isShapeOfType(l, "group"))
          continue;
        const c = this.editor.getShapeMask(l.id);
        if (c && !Ql(i, c))
          continue;
        const u = this.editor.getShapeGeometry(l), d = this.editor.getPointInShapeSpace(l, s), h = this.editor.getPointInShapeSpace(l, i);
        u.hitTestLineSegment(d, h, Va / e) && a.add(this.editor.getOutermostSelectableShape(l).id);
      }
      this.editor.setErasingShapes([
        ...a
      ].filter((l) => !o.has(l)));
    }
    complete() {
      this.editor.deleteShapes(this.editor.currentPageState.erasingShapeIds), this.editor.setErasingShapes([]), this.parent.transition("idle", {});
    }
    cancel() {
      this.editor.setErasingShapes([]), this.editor.bailToMark(this.markId), this.parent.transition("idle", this.info);
    }
  }
  __publicField(g4e, "id", "erasing");
  let m4e = (_n2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("pointing", e);
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
    }
  }, __publicField(_n2, "id", "idle"), _n2), y4e = (_o2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        const { inputs: { currentPagePoint: e }, currentPageShapesSorted: n, zoomLevel: r } = this.editor, i = /* @__PURE__ */ new Set(), s = i.size;
        for (let o = n.length, a = o - 1; a >= 0; a--) {
          const l = n[a];
          if (!(this.editor.isShapeOrAncestorLocked(l) || this.editor.isShapeOfType(l, "group")) && this.editor.isPointInShape(l, e, {
            hitInside: false,
            margin: Va / r
          })) {
            const c = this.editor.getOutermostSelectableShape(l);
            if (this.editor.isShapeOfType(c, "frame") && i.size > s)
              break;
            i.add(c.id);
          }
        }
        this.editor.setErasingShapes([
          ...i
        ]);
      });
      __publicField(this, "onPointerMove", (e) => {
        this.editor.inputs.isDragging && this.parent.transition("erasing", e);
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    complete() {
      const { erasingShapeIds: e } = this.editor;
      e.length && (this.editor.mark("erase end"), this.editor.deleteShapes(e)), this.editor.setErasingShapes([]), this.parent.transition("idle", {});
    }
    cancel() {
      this.editor.setErasingShapes([]), this.parent.transition("idle", {});
    }
  }, __publicField(_o2, "id", "pointing"), _o2);
  class v4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
    }
  }
  __publicField(v4e, "id", "eraser");
  __publicField(v4e, "initial", "idle");
  __publicField(v4e, "children", () => [
    m4e,
    y4e,
    g4e
  ]);
  class O4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        this.update();
      });
      __publicField(this, "onPointerMove", () => {
        this.update();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
    }
    update() {
      const { currentScreenPoint: e, previousScreenPoint: n } = this.editor.inputs, r = I.Sub(e, n);
      (Math.abs(r.x) > 0 || Math.abs(r.y) > 0) && this.editor.pan(r);
    }
    complete() {
      this.editor.slideCamera({
        speed: Math.min(2, this.editor.inputs.pointerVelocity.len()),
        direction: this.editor.inputs.pointerVelocity,
        friction: Zx
      }), this.parent.transition("idle", {});
    }
  }
  __publicField(O4e, "id", "dragging");
  let S4e = (_p2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "grab",
          rotation: 0
        });
      });
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("pointing", e);
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select");
      });
    }
  }, __publicField(_p2, "id", "idle"), _p2), w4e = (_q2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        this.editor.stopCameraAnimation(), this.editor.updateInstanceState({
          cursor: {
            type: "grabbing",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
      });
      __publicField(this, "onPointerMove", (e) => {
        this.editor.inputs.isDragging && this.parent.transition("dragging", e);
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.complete();
      });
    }
    complete() {
      this.parent.transition("idle", {});
    }
  }, __publicField(_q2, "id", "pointing"), _q2);
  class x4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onDoubleClick", (e) => {
        if (e.phase === "settle") {
          const { currentScreenPoint: n } = this.editor.inputs;
          this.editor.zoomIn(n, {
            duration: 220,
            easing: Oi.easeOutQuint
          });
        }
      });
      __publicField(this, "onTripleClick", (e) => {
        if (e.phase === "settle") {
          const { currentScreenPoint: n } = this.editor.inputs;
          this.editor.zoomOut(n, {
            duration: 320,
            easing: Oi.easeOutQuint
          });
        }
      });
      __publicField(this, "onQuadrupleClick", (e) => {
        if (e.phase === "settle") {
          const { zoomLevel: n, inputs: { currentScreenPoint: r } } = this.editor;
          n === 1 ? this.editor.zoomToFit({
            duration: 400,
            easing: Oi.easeOutQuint
          }) : this.editor.resetZoom(r, {
            duration: 320,
            easing: Oi.easeOutQuint
          });
        }
      });
    }
  }
  __publicField(x4e, "id", "hand");
  __publicField(x4e, "initial", "idle");
  __publicField(x4e, "children", () => [
    S4e,
    w4e,
    O4e
  ]);
  let b4e = (_r2 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onPointerDown", (e) => {
        this.parent.transition("lasering", e);
      });
    }
  }, __publicField(_r2, "id", "idle"), _r2);
  class k4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "scribble", {});
      __publicField(this, "onEnter", () => {
        this.startScribble(), this.pushPointToScribble();
      });
      __publicField(this, "onExit", () => {
        this.scribble.stop();
      });
      __publicField(this, "onPointerMove", () => {
        this.pushPointToScribble();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "startScribble", () => {
        var _a3;
        this.scribble.tick && this.editor.off("tick", (_a3 = this.scribble) == null ? void 0 : _a3.tick), this.scribble = new $L({
          onUpdate: this.onScribbleUpdate,
          onComplete: this.onScribbleComplete,
          color: "laser",
          opacity: 0.7,
          size: 4,
          delay: 1200
        }), this.editor.on("tick", this.scribble.tick);
      });
      __publicField(this, "pushPointToScribble", () => {
        const { x: e, y: n } = this.editor.inputs.currentPagePoint;
        this.scribble.addPoint(e, n);
      });
      __publicField(this, "onScribbleUpdate", (e) => {
        this.editor.updateInstanceState({
          scribble: e
        });
      });
      __publicField(this, "onScribbleComplete", () => {
        this.editor.off("tick", this.scribble.tick), this.editor.updateInstanceState({
          scribble: null
        });
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
    }
    complete() {
      this.parent.transition("idle", {});
    }
    cancel() {
      this.parent.transition("idle", {});
    }
  }
  __publicField(k4e, "id", "lasering");
  class P4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        this.editor.setCursor({
          type: "cross",
          rotation: 0
        });
      });
    }
  }
  __publicField(P4e, "id", "laser");
  __publicField(P4e, "initial", "idle");
  __publicField(P4e, "children", () => [
    b4e,
    k4e
  ]);
  class C4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "brush", new Te());
      __publicField(this, "initialSelectedShapeIds", []);
      __publicField(this, "excludedShapeIds", /* @__PURE__ */ new Set());
      __publicField(this, "initialStartShape", null);
      __publicField(this, "onEnter", (e) => {
        const { altKey: n, currentPagePoint: r } = this.editor.inputs;
        if (n) {
          this.parent.transition("scribble_brushing", e);
          return;
        }
        this.excludedShapeIds = new Set(this.editor.currentPageShapes.filter((i) => this.editor.isShapeOfType(i, "group") || this.editor.isShapeOrAncestorLocked(i)).map((i) => i.id)), this.info = e, this.initialSelectedShapeIds = this.editor.selectedShapeIds.slice(), this.initialStartShape = this.editor.getShapesAtPoint(r)[0], this.onPointerMove();
      });
      __publicField(this, "onExit", () => {
        this.initialSelectedShapeIds = [], this.editor.updateInstanceState({
          brush: null
        });
      });
      __publicField(this, "onPointerMove", () => {
        this.hitTestShapes();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onCancel", (e) => {
        this.editor.setSelectedShapes(this.initialSelectedShapeIds, {
          squashing: true
        }), this.parent.transition("idle", e);
      });
      __publicField(this, "onKeyDown", (e) => {
        this.editor.inputs.altKey ? this.parent.transition("scribble_brushing", e) : this.hitTestShapes();
      });
      __publicField(this, "onKeyUp", () => {
        this.hitTestShapes();
      });
      __publicField(this, "onInterrupt", () => {
        this.editor.updateInstanceState({
          brush: null
        });
      });
    }
    complete() {
      this.parent.transition("idle", {});
    }
    hitTestShapes() {
      const { zoomLevel: e, currentPageId: n, currentPageShapes: r, inputs: { originPagePoint: i, currentPagePoint: s, shiftKey: o, ctrlKey: a } } = this.editor;
      this.brush.setTo(Te.FromPoints([
        i,
        s
      ]));
      const l = new Set(o ? this.initialSelectedShapeIds : []);
      let c, u, d, h, f, y;
      const { corners: g } = this.brush, { excludedShapeIds: O } = this;
      e:
        for (let S = 0, w = r.length; S < w; S++) {
          if (d = r[S], O.has(d.id) || l.has(d.id) || (h = this.editor.getShapePageBounds(d), !h))
            continue e;
          if (this.brush.contains(h)) {
            this.handleHit(d, s, n, l, g);
            continue e;
          }
          if (a || this.editor.isShapeOfType(d, "frame"))
            continue e;
          if (this.brush.collides(h)) {
            const x = this.editor.getShapeGeometry(d);
            if (f = this.editor.getShapePageTransform(d), !f)
              continue e;
            y = f.clone().invert().applyToPoints(g);
            t:
              for (let P = 0; P < y.length; P++)
                if (c = y[P], u = y[(P + 1) % y.length], x.hitTestLineSegment(c, u, Va / e)) {
                  this.handleHit(d, s, n, l, g);
                  break t;
                }
          }
        }
      this.editor.updateInstanceState({
        brush: {
          ...this.brush.toJson()
        }
      }), this.editor.setSelectedShapes(Array.from(l), {
        squashing: true
      });
    }
    handleHit(e, n, r, i, s) {
      if (e.parentId === r) {
        i.add(e.id);
        return;
      }
      const o = this.editor.getOutermostSelectableShape(e), a = this.editor.getShapeMask(o.id);
      a && !t_e(a, s) && !Ql(n, a) || i.add(o.id);
    }
  }
  __publicField(C4e, "id", "brushing");
  function AL(t) {
    const { zoomLevel: e, inputs: { currentPagePoint: n } } = t;
    return t.getShapeAtPoint(n, {
      hitInside: false,
      hitLabels: false,
      margin: Va / e,
      renderingOnly: true
    }) ?? t.getSelectedShapeAtPoint(n);
  }
  function Iee(t, e, n) {
    if (!e)
      throw Error("Needs to translate a cropped shape!");
    const { crop: r } = e.props;
    if (!r)
      return;
    const i = t.inputs.shiftKey ? Math.abs(n.x) < Math.abs(n.y) ? "x" : "y" : null;
    i === "x" ? n.x = 0 : i === "y" && (n.y = 0), n.rot(-e.rotation);
    const s = 1 / (r.bottomRight.x - r.topLeft.x) * e.props.w, o = 1 / (r.bottomRight.y - r.topLeft.y) * e.props.h, a = r.bottomRight.y - r.topLeft.y, l = r.bottomRight.x - r.topLeft.x, c = wi(r);
    return c.topLeft.x = Math.min(1 - l, Math.max(0, c.topLeft.x - n.x / s)), c.topLeft.y = Math.min(1 - a, Math.max(0, c.topLeft.y - n.y / o)), c.bottomRight.x = c.topLeft.x + l, c.bottomRight.y = c.topLeft.y + a, {
      id: e.id,
      type: e.type,
      props: {
        crop: c
      }
    };
  }
  let _4e = (_s = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
        const { onlySelectedShape: e } = this.editor;
        this.editor.on("change-history", this.cleanupCroppingState), e && (this.editor.mark("crop"), this.editor.setCroppingShape(e.id));
      });
      __publicField(this, "onExit", () => {
        this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        }), this.editor.off("change-history", this.cleanupCroppingState);
      });
      __publicField(this, "onCancel", () => {
        this.editor.setCroppingShape(null), this.editor.setCurrentTool("select.idle", {});
      });
      __publicField(this, "onPointerDown", (e) => {
        var _a3;
        if (!this.editor.isMenuOpen) {
          if (e.ctrlKey) {
            this.cancel(), this.editor.root.handleEvent(e);
            return;
          }
          switch (e.target) {
            case "canvas": {
              const n = AL(this.editor);
              if (n && !this.editor.isShapeOfType(n, "group")) {
                this.onPointerDown({
                  ...e,
                  shape: n,
                  target: "shape"
                });
                return;
              }
              this.cancel(), this.editor.root.handleEvent(e);
              break;
            }
            case "shape": {
              if (e.shape.id === this.editor.croppingShapeId) {
                this.editor.setCurrentTool("select.crop.pointing_crop", e);
                return;
              } else
                ((_a3 = this.editor.getShapeUtil(e.shape)) == null ? void 0 : _a3.canCrop(e.shape)) ? (this.editor.setCroppingShape(e.shape.id), this.editor.setSelectedShapes([
                  e.shape.id
                ]), this.editor.setCurrentTool("select.crop.pointing_crop", e)) : (this.cancel(), this.editor.root.handleEvent(e));
              break;
            }
            case "selection": {
              switch (e.handle) {
                case "mobile_rotate":
                case "top_left_rotate":
                case "top_right_rotate":
                case "bottom_left_rotate":
                case "bottom_right_rotate": {
                  this.editor.setCurrentTool("select.pointing_rotate_handle", {
                    ...e,
                    onInteractionEnd: "select.crop"
                  });
                  break;
                }
                case "top":
                case "right":
                case "bottom":
                case "left": {
                  this.editor.setCurrentTool("select.pointing_crop_handle", {
                    ...e,
                    onInteractionEnd: "select.crop"
                  });
                  break;
                }
                case "top_left":
                case "top_right":
                case "bottom_left":
                case "bottom_right": {
                  this.editor.setCurrentTool("select.pointing_crop_handle", {
                    ...e,
                    onInteractionEnd: "select.crop"
                  });
                  break;
                }
                default:
                  this.cancel();
              }
              break;
            }
          }
        }
      });
      __publicField(this, "onDoubleClick", (e) => {
        var _a3;
        if (this.editor.inputs.shiftKey || e.phase !== "up" || !this.editor.croppingShapeId)
          return;
        const n = this.editor.getShape(this.editor.croppingShapeId);
        if (!n)
          return;
        const r = this.editor.getShapeUtil(n);
        r && e.target === "selection" && ((_a3 = r.onDoubleClickEdge) == null ? void 0 : _a3.call(r, n));
      });
      __publicField(this, "onKeyDown", () => {
        this.nudgeCroppingImage(false);
      });
      __publicField(this, "onKeyRepeat", () => {
        this.nudgeCroppingImage(true);
      });
      __publicField(this, "onKeyUp", (e) => {
        switch (e.code) {
          case "Enter": {
            this.editor.setCroppingShape(null), this.editor.setCurrentTool("select.idle", {});
            break;
          }
        }
      });
      __publicField(this, "cleanupCroppingState", () => {
        this.editor.croppingShapeId || this.editor.setCurrentTool("select.idle", {});
      });
    }
    cancel() {
      this.editor.setCroppingShape(null), this.editor.setCurrentTool("select.idle", {});
    }
    nudgeCroppingImage(e = false) {
      const { editor: { inputs: { keys: n } } } = this, r = n.has("ShiftLeft"), i = new I(0, 0);
      if (n.has("ArrowLeft") && (i.x += 1), n.has("ArrowRight") && (i.x -= 1), n.has("ArrowUp") && (i.y += 1), n.has("ArrowDown") && (i.y -= 1), i.equals(new I(0, 0)))
        return;
      r && i.mul(10);
      const s = this.editor.getShape(this.editor.croppingShapeId);
      if (!s)
        return;
      const o = Iee(this.editor, s, i);
      o && (e || this.editor.mark("translate crop"), this.editor.updateShapes([
        o
      ]));
    }
  }, __publicField(_s, "id", "idle"), _s);
  class T4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onCancel", () => {
        this.editor.setCurrentTool("select.crop.idle", {});
      });
      __publicField(this, "onPointerMove", (e) => {
        this.editor.inputs.isDragging && this.editor.setCurrentTool("select.crop.translating_crop", e);
      });
      __publicField(this, "onPointerUp", (e) => {
        this.editor.setCurrentTool("select.crop.idle", e);
      });
    }
  }
  __publicField(T4e, "id", "pointing_crop");
  class E4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "markId", "translating crop");
      __publicField(this, "snapshot", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e, this.snapshot = this.createSnapshot(), this.editor.mark(this.markId), this.editor.setCursor({
          type: "move",
          rotation: 0
        }), this.updateShapes();
      });
      __publicField(this, "onExit", () => {
        this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
      });
      __publicField(this, "onPointerMove", () => {
        this.updateShapes();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onKeyDown", (e) => {
        switch (e.key) {
          case "Alt":
          case "Shift": {
            this.updateShapes();
            return;
          }
        }
      });
      __publicField(this, "onKeyUp", (e) => {
        switch (e.key) {
          case "Enter": {
            this.complete();
            return;
          }
          case "Alt":
          case "Shift":
            this.updateShapes();
        }
      });
    }
    complete() {
      this.updateShapes(), this.editor.setCurrentTool("select.crop.idle", this.info);
    }
    cancel() {
      this.editor.bailToMark(this.markId), this.editor.setCurrentTool("select.crop.idle", this.info);
    }
    createSnapshot() {
      return {
        shape: this.editor.onlySelectedShape
      };
    }
    updateShapes() {
      const e = this.snapshot.shape;
      if (!e)
        return;
      const { originPagePoint: n, currentPagePoint: r } = this.editor.inputs, i = r.clone().sub(n), s = Iee(this.editor, e, i);
      s && this.editor.updateShapes([
        s
      ], {
        squashing: true
      });
    }
  }
  __publicField(E4e, "id", "translating_crop");
  class I4e extends ze {
  }
  __publicField(I4e, "id", "crop");
  __publicField(I4e, "initial", "idle");
  __publicField(I4e, "children", () => [
    _4e,
    E4e,
    T4e
  ]);
  const To = 8, Zg = {
    bottom: "ns-resize",
    top: "ns-resize",
    left: "ew-resize",
    right: "ew-resize",
    bottom_left: "nesw-resize",
    bottom_right: "nwse-resize",
    top_left: "nwse-resize",
    top_right: "nesw-resize",
    bottom_left_rotate: "swne-rotate",
    bottom_right_rotate: "senw-rotate",
    top_left_rotate: "nwse-rotate",
    top_right_rotate: "nesw-rotate",
    mobile_rotate: "grabbing"
  };
  class $4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e, this.updateCursor();
      });
      __publicField(this, "onPointerMove", () => {
        this.editor.inputs.isDragging && this.parent.transition("resizing", this.info);
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.cancel();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    updateCursor() {
      const e = this.editor.selectedShapes, n = Zg[this.info.handle];
      this.editor.updateInstanceState({
        cursor: {
          type: n,
          rotation: e.length === 1 ? e[0].rotation : 0
        }
      });
    }
    complete() {
      this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, {}) : this.parent.transition("idle", {});
    }
    cancel() {
      this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, {}) : this.parent.transition("idle", {});
    }
  }
  __publicField($4e, "id", "pointing_resize_handle");
  class A4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "markId", "");
      __publicField(this, "snapshot", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e, this.markId = "cropping", this.editor.mark(this.markId), this.snapshot = this.createSnapshot(), this.updateShapes();
      });
      __publicField(this, "onPointerMove", () => {
        this.updateShapes();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "getDefaultCrop", () => ({
        topLeft: {
          x: 0,
          y: 0
        },
        bottomRight: {
          x: 1,
          y: 1
        }
      }));
    }
    updateCursor() {
      const e = this.editor.selectedShapes[0];
      if (!e)
        return;
      const n = Zg[this.info.handle];
      this.editor.updateInstanceState({
        cursor: {
          type: n,
          rotation: e.rotation
        }
      });
    }
    updateShapes() {
      const { shape: e, cursorHandleOffset: n } = this.snapshot;
      if (!e || !this.editor.getShapeUtil("image"))
        return;
      const i = e.props, s = this.editor.inputs.currentPagePoint.clone().sub(n), o = this.editor.inputs.originPagePoint.clone().sub(n), a = s.clone().sub(o).rot(-e.rotation), l = i.crop ?? this.getDefaultCrop(), c = wi(l), u = new I(e.x, e.y), d = new I(0, 0), h = 1 / (l.bottomRight.x - l.topLeft.x) * i.w, f = 1 / (l.bottomRight.y - l.topLeft.y) * i.h;
      let y = false;
      switch (this.info.handle) {
        case "top":
        case "top_left":
        case "top_right": {
          if (f < To)
            break;
          y = true, c.topLeft.y = c.topLeft.y + a.y / f, f * (c.bottomRight.y - c.topLeft.y) < To ? (c.topLeft.y = c.bottomRight.y - To / f, d.y = (c.topLeft.y - l.topLeft.y) * f) : c.topLeft.y <= 0 ? (c.topLeft.y = 0, d.y = (c.topLeft.y - l.topLeft.y) * f) : d.y = a.y;
          break;
        }
        case "bottom":
        case "bottom_left":
        case "bottom_right": {
          if (f < To)
            break;
          y = true, c.bottomRight.y = Math.min(1, c.bottomRight.y + a.y / f), f * (c.bottomRight.y - c.topLeft.y) < To && (c.bottomRight.y = c.topLeft.y + To / f);
          break;
        }
      }
      switch (this.info.handle) {
        case "left":
        case "top_left":
        case "bottom_left": {
          if (h < To)
            break;
          y = true, c.topLeft.x = c.topLeft.x + a.x / h, h * (c.bottomRight.x - c.topLeft.x) < To ? (c.topLeft.x = c.bottomRight.x - To / h, d.x = (c.topLeft.x - l.topLeft.x) * h) : c.topLeft.x <= 0 ? (c.topLeft.x = 0, d.x = (c.topLeft.x - l.topLeft.x) * h) : d.x = a.x;
          break;
        }
        case "right":
        case "top_right":
        case "bottom_right": {
          if (h < To)
            break;
          y = true, c.bottomRight.x = Math.min(1, c.bottomRight.x + a.x / h), h * (c.bottomRight.x - c.topLeft.x) < To && (c.bottomRight.x = c.topLeft.x + To / h);
          break;
        }
      }
      if (!y)
        return;
      u.add(d.rot(e.rotation));
      const g = {
        id: e.id,
        type: e.type,
        x: u.x,
        y: u.y,
        props: {
          crop: c,
          w: (c.bottomRight.x - c.topLeft.x) * h,
          h: (c.bottomRight.y - c.topLeft.y) * f
        }
      };
      this.editor.updateShapes([
        g
      ], {
        squashing: true
      }), this.updateCursor();
    }
    complete() {
      this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, this.info) : (this.editor.setCroppingShape(null), this.parent.transition("idle", {}));
    }
    cancel() {
      this.editor.bailToMark(this.markId), this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, this.info) : (this.editor.setCroppingShape(null), this.parent.transition("idle", {}));
    }
    createSnapshot() {
      const { selectionRotation: e, inputs: { originPagePoint: n } } = this.editor, r = this.editor.onlySelectedShape, i = this.editor.selectionRotatedPageBounds, s = I.RotWith(i.getHandlePoint(this.info.handle), i.point, e), o = I.Sub(n, s);
      return {
        shape: r,
        cursorHandleOffset: o
      };
    }
  }
  __publicField(A4e, "id", "cropping");
  class R4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "shapeId", "");
      __publicField(this, "initialHandle", {});
      __publicField(this, "initialAdjacentHandle", null);
      __publicField(this, "initialPagePoint", {});
      __publicField(this, "markId", "");
      __publicField(this, "initialPageTransform");
      __publicField(this, "initialPageRotation");
      __publicField(this, "info", {});
      __publicField(this, "isPrecise", false);
      __publicField(this, "isPreciseId", null);
      __publicField(this, "pointingId", null);
      __publicField(this, "onEnter", (e) => {
        const { shape: n, isCreating: r, handle: i } = e;
        this.info = e, this.parent.currentToolIdMask = e.onInteractionEnd, this.shapeId = n.id, this.markId = r ? `creating:${n.id}` : "dragging handle", r || this.editor.mark(this.markId), this.initialHandle = wi(i), this.initialPageTransform = this.editor.getShapePageTransform(n), this.initialPageRotation = this.initialPageTransform.rotation(), this.initialPagePoint = this.editor.inputs.originPagePoint.clone(), this.editor.updateInstanceState({
          cursor: {
            type: r ? "cross" : "grabbing",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
        const s = this.editor.getShapeHandles(n).sort(hi), o = s.findIndex((l) => l.id === e.handle.id);
        this.initialAdjacentHandle = null;
        for (let l = o + 1; l < s.length; l++) {
          const c = s[l];
          if (c.type === "vertex" && c.id !== "middle" && c.id !== e.handle.id) {
            this.initialAdjacentHandle = c;
            break;
          }
        }
        if (!this.initialAdjacentHandle)
          for (let l = s.length - 1; l >= 0; l--) {
            const c = s[l];
            if (c.type === "vertex" && c.id !== "middle" && c.id !== e.handle.id) {
              this.initialAdjacentHandle = c;
              break;
            }
          }
        const a = n.props[e.handle.id];
        this.isPrecise = false, (a == null ? void 0 : a.type) === "binding" ? (this.editor.setHintingShapes([
          a.boundShapeId
        ]), this.isPrecise = !I.Equals(a.normalizedAnchor, {
          x: 0.5,
          y: 0.5
        }), this.isPrecise ? this.isPreciseId = a.boundShapeId : this.resetExactTimeout()) : this.editor.setHintingShapes([]), this.update(), this.editor.select(this.shapeId);
      });
      __publicField(this, "exactTimeout", -1);
      __publicField(this, "onPointerMove", () => {
        this.update();
      });
      __publicField(this, "onKeyDown", () => {
        this.update();
      });
      __publicField(this, "onKeyUp", () => {
        this.update();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onExit", () => {
        this.parent.currentToolIdMask = void 0, this.editor.setHintingShapes([]), this.editor.snaps.clear(), this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
      });
    }
    resetExactTimeout() {
      this.exactTimeout !== -1 && this.clearExactTimeout(), this.exactTimeout = setTimeout(() => {
        this.isActive && !this.isPrecise && (this.isPrecise = true, this.isPreciseId = this.pointingId, this.update()), this.exactTimeout = -1;
      }, 750);
    }
    clearExactTimeout() {
      this.exactTimeout !== -1 && (clearTimeout(this.exactTimeout), this.exactTimeout = -1);
    }
    complete() {
      this.editor.snaps.clear();
      const { onInteractionEnd: e } = this.info;
      if (this.editor.instanceState.isToolLocked && e) {
        this.editor.setCurrentTool(e, {
          shapeId: this.shapeId
        });
        return;
      }
      this.parent.transition("idle", {});
    }
    cancel() {
      this.editor.bailToMark(this.markId), this.editor.snaps.clear();
      const { onInteractionEnd: e } = this.info;
      if (e) {
        this.editor.setCurrentTool(e, {
          shapeId: this.shapeId
        });
        return;
      }
      this.parent.transition("idle", {});
    }
    update() {
      var _a3;
      const { editor: e, shapeId: n, initialPagePoint: r } = this, { initialHandle: i, initialPageRotation: s, initialAdjacentHandle: o } = this, { user: { isSnapMode: a }, hintingShapeIds: l, snaps: c, inputs: { currentPagePoint: u, shiftKey: d, ctrlKey: h, altKey: f, pointerVelocity: y } } = e, g = e.getShape(n);
      if (!g)
        return;
      const O = e.getShapeUtil(g);
      let S = u.clone().sub(r).rot(-s).add(i);
      if (d && o && i.id !== "middle") {
        const P = I.Angle(o, S), _ = kk(P, 24) - P;
        S = I.RotWith(S, o, _);
      }
      if (e.snaps.clear(), i.canSnap && (a ? !h : h)) {
        const P = e.getShapePageTransform(g.id);
        if (!P)
          throw Error("Expected a page transform");
        const C = e.getShapeHandles(g).filter(({ type: $ }) => $ === "vertex").sort(hi).findIndex(({ index: $ }) => i.index === $), _ = O.getOutlineSegments(g).map(($) => Se.applyToPoints(P, $)).filter(($, N) => N !== C - 1 && N !== C), T = c.getSnappingHandleDelta({
          additionalSegments: _,
          handlePoint: Se.applyToPoint(P, S)
        });
        T && (T.rot(-e.getShapeParentTransform(g).rotation()), S.add(T));
      }
      const w = (_a3 = O.onHandleChange) == null ? void 0 : _a3.call(O, g, {
        handle: {
          ...i,
          x: S.x,
          y: S.y
        },
        isPrecise: this.isPrecise || f
      }), x = {
        ...g,
        ...w
      };
      if (i.canBind) {
        const P = x.props[i.id];
        (P == null ? void 0 : P.type) === "binding" ? l[0] !== P.boundShapeId && (e.setHintingShapes([
          P.boundShapeId
        ]), this.pointingId = P.boundShapeId, this.isPrecise = y.len() < 0.5 || f, this.isPreciseId = this.isPrecise ? P.boundShapeId : null, this.resetExactTimeout()) : l.length > 0 && (e.setHintingShapes([]), this.pointingId = null, this.isPrecise = false, this.isPreciseId = null, this.resetExactTimeout());
      }
      w && e.updateShapes([
        x
      ], {
        squashing: true
      });
    }
  }
  __publicField(R4e, "id", "dragging_handle");
  class M4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        const { editingShape: e } = this.editor;
        if (!e)
          throw Error("Entered editing state without an editing shape");
        nO(this.editor), this.editor.select(e);
      });
      __publicField(this, "onExit", () => {
        var _a3, _b3;
        const { editingShapeId: e } = this.editor.currentPageState;
        if (!e)
          return;
        this.editor.setEditingShape(null);
        const n = this.editor.getShape(e);
        (_b3 = (_a3 = this.editor.getShapeUtil(n)).onEditEnd) == null ? void 0 : _b3.call(_a3, n), setTimeout(() => {
          this.editor.updateViewportScreenBounds();
        }, 500);
      });
      __publicField(this, "onPointerMove", (e) => {
        switch (e.target) {
          case "shape":
          case "canvas": {
            nO(this.editor);
            return;
          }
        }
      });
      __publicField(this, "onPointerDown", (e) => {
        switch (e.target) {
          case "canvas": {
            const n = AL(this.editor);
            if (n) {
              this.onPointerDown({
                ...e,
                shape: n,
                target: "shape"
              });
              return;
            }
            break;
          }
          case "shape": {
            const { shape: n } = e, { editingShape: r } = this.editor;
            if (!r)
              throw Error("Expected an editing shape!");
            if (n.type === r.type)
              if (this.editor.isShapeOfType(n, "geo") || this.editor.isShapeOfType(n, "arrow")) {
                const s = this.editor.getShapeUtil(n).getGeometry(n).children[1];
                if (s) {
                  const o = this.editor.getPointInShapeSpace(n, this.editor.inputs.currentPagePoint);
                  if (s.bounds.containsPoint(o)) {
                    if (n.id === r.id)
                      return;
                    this.parent.transition("pointing_shape", e);
                    return;
                  }
                }
              } else {
                if (n.id === r.id)
                  this.editor.isShapeOfType(n, "frame") && this.editor.setEditingShape(null);
                else {
                  this.parent.transition("pointing_shape", e);
                  return;
                }
                return;
              }
            break;
          }
        }
        this.parent.transition("idle", e), this.editor.root.handleEvent(e);
      });
      __publicField(this, "onComplete", (e) => {
        this.parent.transition("idle", e);
      });
      __publicField(this, "onCancel", (e) => {
        this.parent.transition("idle", e);
      });
    }
  }
  __publicField(M4e, "id", "editing_shape");
  function E7(t) {
    const { onlySelectedShape: e } = t;
    return !!(e && !t.isShapeOrAncestorLocked(e) && t.getShapeUtil(e).canCrop(e));
  }
  function Zk(t) {
    const { selectedShapeIds: e } = t, { shiftKey: n, altKey: r, currentPagePoint: i } = t.inputs, s = t.getShapeAtPoint(i, {
      hitInside: false,
      margin: Va / t.zoomLevel,
      hitLabels: true,
      renderingOnly: true,
      filter: (o) => !o.isLocked
    });
    if (s) {
      const o = t.getOutermostSelectableShape(s);
      if (n && !r)
        t.cancelDoubleClick(), e.includes(o.id) ? (t.mark("deselecting shape"), t.deselect(o)) : (t.mark("shift selecting shape"), t.setSelectedShapes([
          ...e,
          o.id
        ]));
      else {
        let a;
        o === s || o.id === t.focusedGroupId || e.includes(o.id) ? a = s : a = o, a && !e.includes(a.id) && (t.mark("selecting shape"), t.select(a.id));
      }
    } else {
      if (n)
        return;
      {
        e.length > 0 && (t.mark("selecting none"), t.selectNone());
        const { focusedGroupId: o } = t;
        if (Ro(o)) {
          const a = t.getShape(o);
          t.isPointInShape(a, i, {
            margin: 0,
            hitInside: true
          }) || t.setFocusedGroup(null);
        }
      }
    }
  }
  let D4e = (_t3 = class extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        this.parent.currentToolIdMask = void 0, nO(this.editor), this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
      });
      __publicField(this, "onPointerMove", () => {
        nO(this.editor);
      });
      __publicField(this, "onPointerDown", (e) => {
        if (this.editor.isMenuOpen)
          return;
        const n = e.ctrlKey && E7(this.editor);
        if (e.ctrlKey && !n) {
          if (e.target === "shape" && this.isDarwin && this.editor.inputs.keys.has("ControlLeft") && !this.editor.isShapeOrAncestorLocked(e.shape)) {
            this.parent.transition("pointing_shape", e);
            return;
          }
          this.parent.transition("brushing", e);
          return;
        }
        switch (e.target) {
          case "canvas": {
            const r = AL(this.editor);
            if (r) {
              this.onPointerDown({
                ...e,
                shape: r,
                target: "shape"
              });
              return;
            }
            const { onlySelectedShape: i, selectedShapeIds: s, inputs: { currentPagePoint: o } } = this.editor;
            if ((s.length > 1 || i && !this.editor.getShapeUtil(i).hideSelectionBoundsBg(i)) && I7(this.editor, o)) {
              this.onPointerDown({
                ...e,
                target: "selection"
              });
              return;
            }
            this.parent.transition("pointing_canvas", e);
            break;
          }
          case "shape": {
            if (this.editor.isShapeOrAncestorLocked(e.shape))
              break;
            this.parent.transition("pointing_shape", e);
            break;
          }
          case "handle": {
            if (this.editor.instanceState.isReadonly)
              break;
            this.editor.inputs.altKey ? this.parent.transition("pointing_shape", e) : this.parent.transition("pointing_handle", e);
            break;
          }
          case "selection": {
            switch (e.handle) {
              case "mobile_rotate":
              case "top_left_rotate":
              case "top_right_rotate":
              case "bottom_left_rotate":
              case "bottom_right_rotate": {
                this.parent.transition("pointing_rotate_handle", e);
                break;
              }
              case "top":
              case "right":
              case "bottom":
              case "left": {
                n ? this.parent.transition("pointing_crop_handle", e) : this.parent.transition("pointing_resize_handle", e);
                break;
              }
              case "top_left":
              case "top_right":
              case "bottom_left":
              case "bottom_right": {
                n ? this.parent.transition("pointing_crop_handle", e) : this.parent.transition("pointing_resize_handle", e);
                break;
              }
              default: {
                const { hoveredShape: r } = this.editor;
                if (r && !this.editor.selectedShapeIds.includes(r.id)) {
                  this.onPointerDown({
                    ...e,
                    shape: r,
                    target: "shape"
                  });
                  return;
                }
                this.parent.transition("pointing_selection", e);
              }
            }
            break;
          }
        }
      });
      __publicField(this, "onDoubleClick", (e) => {
        var _a3, _b3, _c3, _d3, _e3;
        if (!(this.editor.inputs.shiftKey || e.phase !== "up"))
          switch (e.target) {
            case "canvas": {
              const { hoveredShape: n } = this.editor, r = n && !this.editor.isShapeOfType(n, "group") ? n : this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ?? this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
                margin: Va / this.editor.zoomLevel,
                hitInside: false
              }), { focusedGroupId: i } = this.editor;
              if (r) {
                if (this.editor.isShapeOfType(r, "group")) {
                  Zk(this.editor);
                  return;
                } else {
                  const s = this.editor.getShape(r.parentId);
                  if (s && this.editor.isShapeOfType(s, "group") && !(i && s.id === i)) {
                    Zk(this.editor);
                    return;
                  }
                }
                this.onDoubleClick({
                  ...e,
                  shape: r,
                  target: "shape"
                });
                return;
              }
              this.editor.inputs.shiftKey || this.handleDoubleClickOnCanvas(e);
              break;
            }
            case "selection": {
              if (this.editor.instanceState.isReadonly)
                break;
              const { onlySelectedShape: n } = this.editor;
              if (n) {
                const r = this.editor.getShapeUtil(n);
                if (!this.canInteractWithShapeInReadOnly(n))
                  return;
                if (e.handle === "right" || e.handle === "left" || e.handle === "top" || e.handle === "bottom") {
                  const i = (_a3 = r.onDoubleClickEdge) == null ? void 0 : _a3.call(r, n);
                  if (i) {
                    this.editor.mark("double click edge"), this.editor.updateShapes([
                      i
                    ]);
                    return;
                  }
                }
                if (r.canCrop(n) && !this.editor.isShapeOrAncestorLocked(n)) {
                  this.parent.transition("crop", e);
                  return;
                }
                this.shouldStartEditingShape(n) && this.startEditingShape(n, e);
              }
              break;
            }
            case "shape": {
              const { shape: n } = e, r = this.editor.getShapeUtil(n);
              if (n.type !== "video" && n.type !== "embed" && this.editor.instanceState.isReadonly)
                break;
              if (r.onDoubleClick) {
                const i = (_b3 = r.onDoubleClick) == null ? void 0 : _b3.call(r, n);
                if (i) {
                  this.editor.updateShapes([
                    i
                  ]);
                  return;
                } else if (r.canCrop(n) && !this.editor.isShapeOrAncestorLocked(n)) {
                  this.editor.mark("select and crop"), this.editor.select((_c3 = e.shape) == null ? void 0 : _c3.id), this.parent.transition("crop", e);
                  return;
                }
              }
              this.shouldStartEditingShape(n) ? this.startEditingShape(n, e) : this.handleDoubleClickOnCanvas(e);
              break;
            }
            case "handle": {
              if (this.editor.instanceState.isReadonly)
                break;
              const { shape: n, handle: r } = e, s = (_e3 = (_d3 = this.editor.getShapeUtil(n)).onDoubleClickHandle) == null ? void 0 : _e3.call(_d3, n, r);
              s ? this.editor.updateShapes([
                s
              ]) : this.shouldStartEditingShape(n) && this.startEditingShape(n, e);
            }
          }
      });
      __publicField(this, "onRightClick", (e) => {
        switch (e.target) {
          case "canvas": {
            const { hoveredShape: n } = this.editor, r = n && !this.editor.isShapeOfType(n, "group") ? n : this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
              margin: Va / this.editor.zoomLevel,
              hitInside: false,
              hitLabels: true,
              hitFrameInside: false,
              renderingOnly: true
            });
            if (r) {
              this.onRightClick({
                ...e,
                shape: r,
                target: "shape"
              });
              return;
            }
            const { onlySelectedShape: i, selectedShapeIds: s, inputs: { currentPagePoint: o } } = this.editor;
            if ((s.length > 1 || i && !this.editor.getShapeUtil(i).hideSelectionBoundsBg(i)) && I7(this.editor, o)) {
              this.onRightClick({
                ...e,
                target: "selection"
              });
              return;
            }
            this.editor.selectNone();
            break;
          }
          case "shape": {
            const { selectedShapeIds: n } = this.editor.currentPageState, { shape: r } = e, i = this.editor.getOutermostSelectableShape(r, (s) => !n.includes(s.id));
            n.includes(i.id) || (this.editor.mark("selecting shape"), this.editor.setSelectedShapes([
              i.id
            ]));
            break;
          }
        }
      });
      __publicField(this, "onCancel", () => {
        this.editor.focusedGroupId !== this.editor.currentPageId && this.editor.selectedShapeIds.length > 0 ? this.editor.popFocusedGroupId() : (this.editor.mark("clearing selection"), this.editor.selectNone());
      });
      __publicField(this, "onKeyDown", (e) => {
        switch (e.code) {
          case "ArrowLeft":
          case "ArrowRight":
          case "ArrowUp":
          case "ArrowDown": {
            this.nudgeSelectedShapes(false);
            break;
          }
        }
      });
      __publicField(this, "onKeyRepeat", (e) => {
        switch (e.code) {
          case "ArrowLeft":
          case "ArrowRight":
          case "ArrowUp":
          case "ArrowDown": {
            this.nudgeSelectedShapes(true);
            break;
          }
        }
      });
      __publicField(this, "onKeyUp", (e) => {
        switch (e.code) {
          case "Enter": {
            const { selectedShapes: n } = this.editor;
            if (n.every((i) => this.editor.isShapeOfType(i, "group"))) {
              this.editor.setSelectedShapes(n.flatMap((i) => this.editor.getSortedChildIdsForParent(i.id)));
              return;
            }
            const { onlySelectedShape: r } = this.editor;
            if (r && this.shouldStartEditingShape(r)) {
              this.startEditingShape(r, {
                ...e,
                target: "shape",
                shape: r
              });
              return;
            }
            E7(this.editor) && this.parent.transition("crop", e);
            break;
          }
        }
      });
      __publicField(this, "isDarwin", window.navigator.userAgent.toLowerCase().indexOf("mac") > -1);
    }
    shouldStartEditingShape(e = this.editor.onlySelectedShape) {
      return !e || this.editor.isShapeOrAncestorLocked(e) && e.type !== "embed" || !this.canInteractWithShapeInReadOnly(e) ? false : this.editor.getShapeUtil(e).canEdit(e);
    }
    startEditingShape(e, n) {
      this.editor.isShapeOrAncestorLocked(e) && e.type !== "embed" || (this.editor.mark("editing shape"), this.editor.setEditingShape(e.id), this.parent.transition("editing_shape", n));
    }
    handleDoubleClickOnCanvas(e) {
      if (this.editor.instanceState.isReadonly)
        return;
      this.editor.mark("creating text shape");
      const n = bn(), { x: r, y: i } = this.editor.inputs.currentPagePoint;
      this.editor.createShapes([
        {
          id: n,
          type: "text",
          x: r,
          y: i,
          props: {
            text: "",
            autoSize: true
          }
        }
      ]);
      const s = this.editor.getShape(n);
      if (!s)
        return;
      const o = this.editor.getShapeUtil(s);
      this.editor.instanceState.isReadonly && !o.canEditInReadOnly(s) || (this.editor.setEditingShape(n), this.editor.select(n), this.parent.transition("editing_shape", e));
    }
    nudgeSelectedShapes(e = false) {
      const { editor: { inputs: { keys: n } } } = this, r = n.has("ShiftLeft"), i = new I(0, 0);
      if (n.has("ArrowLeft") && (i.x -= 1), n.has("ArrowRight") && (i.x += 1), n.has("ArrowUp") && (i.y -= 1), n.has("ArrowDown") && (i.y += 1), i.equals(new I(0, 0)))
        return;
      e || this.editor.mark("nudge shapes");
      const { gridSize: s } = this.editor.documentSettings, o = this.editor.instanceState.isGridMode ? r ? s * N4e : s : r ? L4e : j4e;
      this.editor.nudgeShapes(this.editor.selectedShapeIds, i.mul(o));
    }
    canInteractWithShapeInReadOnly(e) {
      return !!(!this.editor.instanceState.isReadonly || this.editor.getShapeUtil(e).canEditInReadOnly(e));
    }
  }, __publicField(_t3, "id", "idle"), _t3);
  const L4e = 10, j4e = 1, N4e = 5;
  function I7(t, e) {
    const { selectionRotatedPageBounds: n } = t;
    if (!n)
      return false;
    const { selectionRotation: r } = t;
    return r ? Ql(e, n.corners.map((i) => I.RotWith(i, n.point, r))) : n.containsPoint(e);
  }
  class Q4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onEnter", () => {
        const { inputs: e } = this.editor;
        e.shiftKey || this.editor.selectedShapeIds.length > 0 && (this.editor.mark("selecting none"), this.editor.selectNone());
      });
      __publicField(this, "onPointerMove", (e) => {
        this.editor.inputs.isDragging && this.parent.transition("brushing", e);
      });
      __publicField(this, "onPointerUp", () => {
        Zk(this.editor), this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.parent.transition("idle", {});
      });
    }
    complete() {
      this.parent.transition("idle", {});
    }
  }
  __publicField(Q4e, "id", "pointing_canvas");
  class z4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e, this.parent.currentToolIdMask = e.onInteractionEnd;
        const n = this.editor.selectedShapes[0];
        n && (this.updateCursor(n), this.editor.setCroppingShape(n.id));
      });
      __publicField(this, "onExit", () => {
        this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        }), this.parent.currentToolIdMask = void 0;
      });
      __publicField(this, "onPointerMove", () => {
        this.editor.inputs.isDragging && this.parent.transition("cropping", {
          ...this.info,
          onInteractionEnd: this.info.onInteractionEnd
        });
      });
      __publicField(this, "onPointerUp", () => {
        this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, this.info) : (this.editor.setCroppingShape(null), this.parent.transition("idle", {}));
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.cancel();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    updateCursor(e) {
      const n = Zg[this.info.handle];
      this.editor.updateInstanceState({
        cursor: {
          type: n,
          rotation: e.rotation
        }
      });
    }
    cancel() {
      this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, this.info) : (this.editor.setCroppingShape(null), this.parent.transition("idle", {}));
    }
  }
  __publicField(z4e, "id", "pointing_crop_handle");
  class F4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e;
        const n = e.shape.props[e.handle.id];
        (n == null ? void 0 : n.type) === "binding" && this.editor.setHintingShapes([
          n.boundShapeId
        ]), this.editor.updateInstanceState({
          cursor: {
            type: "grabbing",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
      });
      __publicField(this, "onExit", () => {
        this.editor.setHintingShapes([]), this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
      });
      __publicField(this, "onPointerUp", () => {
        this.parent.transition("idle", this.info);
      });
      __publicField(this, "onPointerMove", () => {
        this.editor.inputs.isDragging && this.parent.transition("dragging_handle", this.info);
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.cancel();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    cancel() {
      this.parent.transition("idle", {});
    }
  }
  __publicField(F4e, "id", "pointing_handle");
  class B4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "onEnter", (e) => {
        this.parent.currentToolIdMask = e.onInteractionEnd, this.info = e, this.updateCursor();
      });
      __publicField(this, "onExit", () => {
        this.parent.currentToolIdMask = void 0, this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        });
      });
      __publicField(this, "onPointerMove", () => {
        const { isDragging: e } = this.editor.inputs;
        e && this.parent.transition("rotating", this.info);
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.cancel();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    updateCursor() {
      const { selectionRotation: e } = this.editor;
      this.editor.updateInstanceState({
        cursor: {
          type: Zg[this.info.handle],
          rotation: e
        }
      });
    }
    complete() {
      this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, {}) : this.parent.transition("idle", {});
    }
    cancel() {
      this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, {}) : this.parent.transition("idle", {});
    }
  }
  __publicField(B4e, "id", "pointing_rotate_handle");
  class U4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e;
      });
      __publicField(this, "onPointerUp", (e) => {
        Zk(this.editor), this.parent.transition("idle", e);
      });
      __publicField(this, "onPointerMove", (e) => {
        if (this.editor.inputs.isDragging) {
          if (this.editor.instanceState.isReadonly)
            return;
          this.parent.transition("translating", e);
        }
      });
      __publicField(this, "onDoubleClick", (e) => {
        var _a3, _b3;
        const { hoveredShape: n } = this.editor, r = n && !this.editor.isShapeOfType(n, "group") ? n : this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
          hitInside: true,
          margin: 0,
          renderingOnly: true
        });
        if (r) {
          this.parent.transition("idle", {}), (_b3 = (_a3 = this.parent).onDoubleClick) == null ? void 0 : _b3.call(_a3, {
            ...e,
            target: "shape",
            shape: this.editor.getShape(r)
          });
          return;
        }
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.cancel();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    cancel() {
      this.parent.transition("idle", {});
    }
  }
  __publicField(U4e, "id", "pointing_selection");
  class V4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "hitShape", {});
      __publicField(this, "hitShapeForPointerUp", {});
      __publicField(this, "didSelectOnEnter", false);
      __publicField(this, "onEnter", (e) => {
        const { selectedShapeIds: n, focusedGroupId: r, selectionRotatedPageBounds: i, inputs: { currentPagePoint: s, shiftKey: o, altKey: a } } = this.editor;
        this.hitShape = e.shape;
        const l = this.editor.getOutermostSelectableShape(e.shape);
        if (this.editor.getShapeUtil(e.shape).onClick || l.id === r || n.includes(l.id) || this.editor.isAncestorSelected(l.id) || n.length > 1 && (i == null ? void 0 : i.containsPoint(s))) {
          this.didSelectOnEnter = false, this.hitShapeForPointerUp = l;
          return;
        }
        this.didSelectOnEnter = true, o && !a ? (this.editor.cancelDoubleClick(), n.includes(l.id) || (this.editor.mark("shift selecting shape"), this.editor.setSelectedShapes([
          ...n,
          l.id
        ]))) : (this.editor.mark("selecting shape"), this.editor.setSelectedShapes([
          l.id
        ]));
      });
      __publicField(this, "onPointerUp", (e) => {
        var _a3;
        const { zoomLevel: n, focusedGroupId: r, selectedShapeIds: i, inputs: { currentPagePoint: s, shiftKey: o } } = this.editor, a = this.editor.getShapeAtPoint(s, {
          margin: Va / n,
          hitInside: true,
          renderingOnly: true
        }) ?? this.hitShape, l = a ? this.editor.getOutermostSelectableShape(a) : this.hitShapeForPointerUp;
        if (l) {
          const c = this.editor.getShapeUtil(l);
          if (c.onClick) {
            const u = (_a3 = c.onClick) == null ? void 0 : _a3.call(c, l);
            if (u) {
              this.editor.mark("shape on click"), this.editor.updateShapes([
                u
              ]), this.parent.transition("idle", e);
              return;
            }
          }
          if (l.id === r) {
            i.length > 0 ? (this.editor.mark("clearing shape ids"), this.editor.setSelectedShapes([])) : this.editor.popFocusedGroupId(), this.parent.transition("idle", e);
            return;
          }
        }
        if (!this.didSelectOnEnter) {
          const c = this.editor.getOutermostSelectableShape(a, (u) => !i.includes(u.id));
          if (i.includes(c.id))
            if (o)
              this.editor.mark("deselecting on pointer up"), this.editor.deselect(l);
            else if (i.includes(l.id)) {
              if (i.length === 1 && (this.editor.isShapeOfType(l, "geo") || this.editor.isShapeOfType(l, "arrow"))) {
                const d = this.editor.getShapeGeometry(l).children[1];
                if (d) {
                  const h = this.editor.getPointInShapeSpace(l, s);
                  if (d.bounds.containsPoint(h, 0) && d.hitTestPoint(h)) {
                    this.editor.batch(() => {
                      this.editor.mark("editing on pointer up"), this.editor.select(l.id);
                      const f = this.editor.getShapeUtil(l);
                      this.editor.instanceState.isReadonly && !f.canEditInReadOnly(l) || (this.editor.setEditingShape(l.id), this.editor.setCurrentTool("select.editing_shape"));
                    });
                    return;
                  }
                }
              }
              this.editor.mark("selecting on pointer up"), this.editor.select(l.id);
            } else
              this.editor.mark("selecting on pointer up"), this.editor.select(l);
          else if (o) {
            const u = this.editor.getShapeAncestors(c);
            this.editor.mark("shift deselecting on pointer up"), this.editor.setSelectedShapes([
              ...this.editor.selectedShapeIds.filter((d) => !u.find((h) => h.id === d)),
              c.id
            ]);
          } else
            this.editor.mark("selecting on pointer up"), this.editor.setSelectedShapes([
              c.id
            ]);
        }
        this.parent.transition("idle", e);
      });
      __publicField(this, "onPointerMove", (e) => {
        if (this.editor.inputs.isDragging) {
          if (this.editor.instanceState.isReadonly)
            return;
          this.parent.transition("translating", e);
        }
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.cancel();
      });
      __publicField(this, "onInterrupt", () => {
        this.cancel();
      });
    }
    cancel() {
      this.parent.transition("idle", {});
    }
  }
  __publicField(V4e, "id", "pointing_shape");
  class X4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "markId", "");
      __publicField(this, "creationCursorOffset", {
        x: 0,
        y: 0
      });
      __publicField(this, "editAfterComplete", false);
      __publicField(this, "snapshot", {});
      __publicField(this, "onEnter", (e) => {
        const { isCreating: n = false, editAfterComplete: r = false, creationCursorOffset: i = {
          x: 0,
          y: 0
        } } = e;
        this.info = e, this.parent.currentToolIdMask = e.onInteractionEnd, this.editAfterComplete = r, this.creationCursorOffset = i, e.isCreating && this.editor.updateInstanceState({
          cursor: {
            type: "cross",
            rotation: 0
          }
        }, {
          ephemeral: true
        }), this.snapshot = this._createSnapshot(), this.markId = n ? `creating:${this.editor.onlySelectedShape.id}` : "starting resizing", n || this.editor.mark(this.markId), this.handleResizeStart(), this.updateShapes();
      });
      __publicField(this, "onPointerMove", () => {
        this.updateShapes();
      });
      __publicField(this, "onKeyDown", () => {
        this.updateShapes();
      });
      __publicField(this, "onKeyUp", () => {
        this.updateShapes();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onExit", () => {
        this.parent.currentToolIdMask = void 0, this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        }), this.editor.snaps.clear();
      });
      __publicField(this, "_createSnapshot", () => {
        const { selectedShapeIds: e, selectionRotation: n, inputs: { originPagePoint: r } } = this.editor, i = this.editor.selectionRotatedPageBounds, s = I.RotWith(i.getHandlePoint(this.info.handle), i.point, n), o = I.Sub(r, s), a = /* @__PURE__ */ new Map();
        e.forEach((c) => {
          const u = this.editor.getShape(c);
          if (u) {
            if (a.set(u.id, this._createShapeSnapshot(u)), this.editor.isShapeOfType(u, "frame") && e.length === 1)
              return;
            this.editor.visitDescendants(u.id, (d) => {
              const h = this.editor.getShape(d);
              if (h && (a.set(h.id, this._createShapeSnapshot(h)), this.editor.isShapeOfType(h, "frame")))
                return false;
            });
          }
        });
        const l = ![
          ...a.values()
        ].some((c) => !mG(c.pageRotation, n) || c.isAspectRatioLocked);
        return {
          shapeSnapshots: a,
          selectionBounds: i,
          cursorHandleOffset: o,
          selectionRotation: n,
          selectedShapeIds: e,
          canShapesDeform: l,
          initialSelectionPageBounds: this.editor.selectionPageBounds
        };
      });
      __publicField(this, "_createShapeSnapshot", (e) => {
        const n = this.editor.getShapePageTransform(e), r = this.editor.getShapeUtil(e);
        return {
          shape: e,
          bounds: this.editor.getShapeGeometry(e).bounds,
          pageTransform: n,
          pageRotation: Se.Decompose(n).rotation,
          isAspectRatioLocked: r.isAspectRatioLocked(e)
        };
      });
    }
    cancel() {
      this.editor.bailToMark(this.markId), this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, {}) : this.parent.transition("idle", {});
    }
    complete() {
      if (this.handleResizeEnd(), this.editAfterComplete && this.editor.onlySelectedShape) {
        this.editor.setEditingShape(this.editor.onlySelectedShape.id), this.editor.setCurrentTool("select.editing_shape");
        return;
      }
      if (this.editor.instanceState.isToolLocked && this.info.onInteractionEnd) {
        this.editor.setCurrentTool(this.info.onInteractionEnd, {});
        return;
      }
      this.parent.transition("idle", {});
    }
    handleResizeStart() {
      const { shapeSnapshots: e } = this.snapshot, n = [];
      e.forEach(({ shape: r }) => {
        var _a3, _b3;
        const s = (_b3 = (_a3 = this.editor.getShapeUtil(r)).onResizeStart) == null ? void 0 : _b3.call(_a3, r);
        s && n.push(s);
      }), n.length > 0 && this.editor.updateShapes(n);
    }
    handleResizeEnd() {
      const { shapeSnapshots: e } = this.snapshot, n = [];
      e.forEach(({ shape: r }) => {
        var _a3, _b3;
        const i = this.editor.getShape(r.id), o = (_b3 = (_a3 = this.editor.getShapeUtil(r)).onResizeEnd) == null ? void 0 : _b3.call(_a3, r, i);
        o && n.push(o);
      }), n.length > 0 && this.editor.updateShapes(n);
    }
    updateShapes() {
      const { altKey: e, shiftKey: n } = this.editor.inputs, { shapeSnapshots: r, selectionBounds: i, cursorHandleOffset: s, selectedShapeIds: o, selectionRotation: a, canShapesDeform: l } = this.snapshot, c = n || !l, { ctrlKey: u } = this.editor.inputs, d = this.editor.inputs.currentPagePoint.clone().sub(s).sub(this.creationCursorOffset), h = this.editor.inputs.originPagePoint.clone().sub(s);
      if (this.editor.instanceState.isGridMode && !u) {
        const { gridSize: _ } = this.editor.documentSettings;
        d.snapToGrid(_);
      }
      const f = this.info.handle, y = $7(f, Math.PI);
      if (this.editor.snaps.clear(), (this.editor.user.isSnapMode ? !u : u) && a % Ft === 0) {
        const { nudge: _ } = this.editor.snaps.snapResize({
          dragDelta: I.Sub(d, h),
          initialSelectionPageBounds: this.snapshot.initialSelectionPageBounds,
          handle: $7(f, a),
          isAspectRatioLocked: c,
          isResizingFromCenter: e
        });
        d.add(_);
      }
      const O = I.RotWith(e ? i.center : i.getHandlePoint(y), i.point, a), S = I.Sub(d, O).rot(-a), w = I.Sub(h, O).rot(-a), x = I.DivV(S, w);
      Number.isFinite(x.x) || (x.x = 1), Number.isFinite(x.y) || (x.y = 1);
      const P = f === "top" || f === "bottom", C = f === "left" || f === "right";
      c ? C ? x.y = Math.abs(x.x) : P ? x.x = Math.abs(x.y) : Math.abs(x.x) > Math.abs(x.y) ? x.y = Math.abs(x.x) * (x.y < 0 ? -1 : 1) : x.x = Math.abs(x.y) * (x.x < 0 ? -1 : 1) : (P && (x.x = 1), C && (x.y = 1)), this.info.isCreating || this.updateCursor({
        dragHandle: f,
        isFlippedX: x.x < 0,
        isFlippedY: x.y < 0,
        rotation: a
      });
      for (const _ of r.keys()) {
        const T = r.get(_);
        this.editor.resizeShape(_, x, {
          initialShape: T.shape,
          initialBounds: T.bounds,
          initialPageTransform: T.pageTransform,
          dragHandle: f,
          mode: o.length === 1 && _ === o[0] ? "resize_bounds" : "scale_shape",
          scaleOrigin: O,
          scaleAxisRotation: a
        });
      }
    }
    updateCursor({ dragHandle: e, isFlippedX: n, isFlippedY: r, rotation: i }) {
      const s = {
        ...this.editor.instanceState.cursor
      };
      switch (e) {
        case "top_left":
        case "bottom_right": {
          s.type = "nwse-resize", n !== r && (s.type = "nesw-resize");
          break;
        }
        case "top_right":
        case "bottom_left": {
          s.type = "nesw-resize", n !== r && (s.type = "nwse-resize");
          break;
        }
      }
      s.rotation = i, this.editor.setCursor(s);
    }
  }
  __publicField(X4e, "id", "resizing");
  const yI = [
    "top",
    "top_right",
    "right",
    "bottom_right",
    "bottom",
    "bottom_left",
    "left",
    "top_left"
  ];
  function $7(t, e) {
    e = e % Bt;
    const n = Math.round(e / (zt / 4)), r = yI.indexOf(t);
    return yI[(r + n) % yI.length];
  }
  class W4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "snapshot", {});
      __publicField(this, "info", {});
      __publicField(this, "markId", "");
      __publicField(this, "onEnter", (e) => {
        this.info = e, this.parent.currentToolIdMask = e.onInteractionEnd, this.markId = "rotate start", this.editor.mark(this.markId);
        const n = oq({
          editor: this.editor
        });
        if (!n)
          return this.parent.transition("idle", this.info);
        this.snapshot = n, this.handleStart();
      });
      __publicField(this, "onExit", () => {
        this.editor.setCursor({
          type: "default",
          rotation: 0
        }), this.parent.currentToolIdMask = void 0, this.snapshot = {};
      });
      __publicField(this, "onPointerMove", () => {
        this.update();
      });
      __publicField(this, "onKeyDown", () => {
        this.update();
      });
      __publicField(this, "onKeyUp", () => {
        this.update();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "update", () => {
        const e = this._getRotationFromPointerPosition({
          snapToNearestDegree: false
        });
        Yx({
          editor: this.editor,
          delta: e,
          snapshot: this.snapshot,
          stage: "update"
        }), this.editor.updateInstanceState({
          cursor: {
            type: Zg[this.info.handle],
            rotation: e + this.snapshot.initialSelectionRotation
          }
        });
      });
      __publicField(this, "cancel", () => {
        this.editor.bailToMark(this.markId), this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, this.info) : this.parent.transition("idle", this.info);
      });
      __publicField(this, "complete", () => {
        Yx({
          editor: this.editor,
          delta: this._getRotationFromPointerPosition({
            snapToNearestDegree: true
          }),
          snapshot: this.snapshot,
          stage: "end"
        }), this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd, this.info) : this.parent.transition("idle", this.info);
      });
    }
    handleStart() {
      const e = this._getRotationFromPointerPosition({
        snapToNearestDegree: false
      });
      Yx({
        editor: this.editor,
        delta: this._getRotationFromPointerPosition({
          snapToNearestDegree: false
        }),
        snapshot: this.snapshot,
        stage: "start"
      }), this.editor.updateInstanceState({
        cursor: {
          type: Zg[this.info.handle],
          rotation: e + this.snapshot.initialSelectionRotation
        }
      });
    }
    _getRotationFromPointerPosition({ snapToNearestDegree: e }) {
      const { selectionRotatedPageBounds: n, selectionRotation: r, inputs: { shiftKey: i, currentPagePoint: s } } = this.editor, { initialCursorAngle: o, initialSelectionRotation: a } = this.snapshot;
      if (!n)
        return a;
      const c = n.center.clone().rotWith(n.point, r).angle(s) - o;
      let u = a + c;
      if (i)
        u = kk(u, 24);
      else if (e && (u = Math.round(u / o8) * o8, this.editor.instanceState.isCoarsePointer)) {
        const d = kk(u, 4), h = cke(u, d);
        Math.abs(h) < uke(5) && (u = d);
      }
      return u - a;
    }
  }
  __publicField(W4e, "id", "rotating");
  class Z4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "hits", /* @__PURE__ */ new Set());
      __publicField(this, "size", 0);
      __publicField(this, "scribble", {});
      __publicField(this, "initialSelectedShapeIds", /* @__PURE__ */ new Set());
      __publicField(this, "newlySelectedShapeIds", /* @__PURE__ */ new Set());
      __publicField(this, "onEnter", () => {
        this.initialSelectedShapeIds = new Set(this.editor.inputs.shiftKey ? this.editor.selectedShapeIds : []), this.newlySelectedShapeIds = /* @__PURE__ */ new Set(), this.size = 0, this.hits.clear(), this.startScribble(), this.updateScribbleSelection(true), requestAnimationFrame(() => {
          this.editor.updateInstanceState({
            brush: null
          });
        });
      });
      __publicField(this, "onExit", () => {
        this.scribble.stop();
      });
      __publicField(this, "onPointerMove", () => {
        this.updateScribbleSelection(true);
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onKeyDown", () => {
        this.updateScribbleSelection(false);
      });
      __publicField(this, "onKeyUp", () => {
        this.editor.inputs.altKey ? this.updateScribbleSelection(false) : this.parent.transition("brushing", {});
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "startScribble", () => {
        var _a3;
        this.scribble.tick && this.editor.off("tick", (_a3 = this.scribble) == null ? void 0 : _a3.tick), this.scribble = new $L({
          onUpdate: this.onScribbleUpdate,
          onComplete: this.onScribbleComplete,
          color: "selection-stroke",
          opacity: 0.32,
          size: 12
        }), this.editor.on("tick", this.scribble.tick);
      });
      __publicField(this, "pushPointToScribble", () => {
        const { x: e, y: n } = this.editor.inputs.currentPagePoint;
        this.scribble.addPoint(e, n);
      });
      __publicField(this, "onScribbleUpdate", (e) => {
        this.editor.updateInstanceState({
          scribble: e
        });
      });
      __publicField(this, "onScribbleComplete", () => {
        this.editor.off("tick", this.scribble.tick), this.editor.updateInstanceState({
          scribble: null
        });
      });
    }
    updateScribbleSelection(e) {
      const { zoomLevel: n, currentPageShapes: r, inputs: { shiftKey: i, originPagePoint: s, previousPagePoint: o, currentPagePoint: a } } = this.editor, { newlySelectedShapeIds: l, initialSelectedShapeIds: c } = this;
      e && this.pushPointToScribble();
      const u = r;
      let d, h, f, y;
      for (let g = 0, O = u.length; g < O; g++)
        if (d = u[g], h = this.editor.getShapeGeometry(d), !(this.editor.isShapeOfType(d, "group") || l.has(d.id) || this.editor.isShapeOrAncestorLocked(d))) {
          if (this.editor.isShapeOfType(d, "frame")) {
            const S = this.editor.getPointInShapeSpace(d, s);
            if (h.bounds.containsPoint(S))
              continue;
          }
          if (f = this.editor.getPointInShapeSpace(d, o), y = this.editor.getPointInShapeSpace(d, a), h.hitTestLineSegment(f, y, Va / n)) {
            const S = this.editor.getOutermostSelectableShape(d), w = this.editor.getShapeMask(S.id);
            if (w && KG(o, a, w) !== null && !Ql(a, w))
              continue;
            l.add(S.id);
          }
        }
      this.editor.setSelectedShapes([
        ...new Set(i ? [
          ...l,
          ...c
        ] : [
          ...l
        ])
      ], {
        squashing: true
      });
    }
    complete() {
      this.parent.transition("idle", {});
    }
    cancel() {
      this.editor.setSelectedShapes([
        ...this.initialSelectedShapeIds
      ], {
        squashing: true
      }), this.parent.transition("idle", {});
    }
  }
  __publicField(Z4e, "id", "scribble_brushing");
  const A7 = 100;
  class H4e {
    constructor(e) {
      __publicField(this, "prevDroppingShapeId", null);
      __publicField(this, "droppingNodeTimer", null);
      __publicField(this, "first", true);
      __publicField(this, "dispose", () => {
        this.clear();
      });
      this.editor = e, e.disposables.add(this.dispose);
    }
    updateDroppingNode(e, n) {
      var _a3;
      this.first && (this.prevDroppingShapeId = ((_a3 = this.editor.getDroppingOverShape(this.editor.inputs.originPagePoint, e)) == null ? void 0 : _a3.id) ?? null, this.first = false), this.droppingNodeTimer === null ? this.setDragTimer(e, A7 * 10, n) : this.editor.inputs.pointerVelocity.len() > 0.5 && (clearInterval(this.droppingNodeTimer), this.setDragTimer(e, A7, n));
    }
    setDragTimer(e, n, r) {
      this.droppingNodeTimer = setTimeout(() => {
        this.editor.batch(() => {
          this.handleDrag(this.editor.inputs.currentPagePoint, e, r);
        }), this.droppingNodeTimer = null;
      }, n);
    }
    handleDrag(e, n, r) {
      var _a3, _b3, _c3, _d3, _e3;
      n = Je(n.map((l) => this.editor.getShape(l.id)));
      const i = ((_a3 = this.editor.getDroppingOverShape(e, n)) == null ? void 0 : _a3.id) ?? null;
      if (i === this.prevDroppingShapeId)
        return;
      const { prevDroppingShapeId: s } = this, o = s && this.editor.getShape(s), a = i && this.editor.getShape(i);
      if (o && ((_c3 = (_b3 = this.editor.getShapeUtil(o)).onDragShapesOut) == null ? void 0 : _c3.call(_b3, o, n)), a) {
        const l = (_e3 = (_d3 = this.editor.getShapeUtil(a)).onDragShapesOver) == null ? void 0 : _e3.call(_d3, a, n);
        l && l.shouldHint && this.editor.setHintingShapes([
          a.id
        ]);
      } else
        this.editor.setHintingShapes([]);
      r == null ? void 0 : r(), this.prevDroppingShapeId = i;
    }
    dropShapes(e) {
      var _a3, _b3;
      const { prevDroppingShapeId: n } = this;
      if (this.handleDrag(this.editor.inputs.currentPagePoint, e), n) {
        const r = this.editor.getShape(n);
        if (!r)
          return;
        (_b3 = (_a3 = this.editor.getShapeUtil(r)).onDropShapesOver) == null ? void 0 : _b3.call(_a3, r, e);
      }
    }
    clear() {
      this.prevDroppingShapeId = null, this.droppingNodeTimer !== null && clearInterval(this.droppingNodeTimer), this.droppingNodeTimer = null, this.editor.setHintingShapes([]), this.first = true;
    }
  }
  class Y4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "selectionSnapshot", {});
      __publicField(this, "snapshot", {});
      __publicField(this, "markId", "");
      __publicField(this, "isCloning", false);
      __publicField(this, "isCreating", false);
      __publicField(this, "editAfterComplete", false);
      __publicField(this, "dragAndDropManager", new H4e(this.editor));
      __publicField(this, "onEnter", (e) => {
        const { isCreating: n = false, editAfterComplete: r = false } = e;
        if (this.info = e, this.parent.currentToolIdMask = e.onInteractionEnd, this.isCreating = n, this.editAfterComplete = r, this.markId = n ? `creating:${this.editor.onlySelectedShape.id}` : "translating", this.editor.mark(this.markId), this.isCloning = false, this.info = e, this.editor.setCursor({
          type: "move",
          rotation: 0
        }), this.selectionSnapshot = R7(this.editor), !this.isCreating && this.editor.inputs.altKey) {
          this.startCloning();
          return;
        }
        this.snapshot = this.selectionSnapshot, this.handleStart(), this.updateShapes(), this.editor.on("tick", this.updateParent);
      });
      __publicField(this, "onExit", () => {
        this.parent.currentToolIdMask = void 0, this.editor.off("tick", this.updateParent), this.selectionSnapshot = {}, this.snapshot = {}, this.editor.snaps.clear(), this.editor.updateInstanceState({
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        }), this.dragAndDropManager.clear();
      });
      __publicField(this, "onPointerMove", () => {
        this.updateShapes();
      });
      __publicField(this, "onKeyDown", () => {
        if (this.editor.inputs.altKey && !this.isCloning) {
          this.startCloning();
          return;
        }
        this.updateShapes();
      });
      __publicField(this, "onKeyUp", () => {
        if (!this.editor.inputs.altKey && this.isCloning) {
          this.stopCloning();
          return;
        }
        this.updateShapes();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onComplete", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
      __publicField(this, "updateParent", () => {
        const { snapshot: e } = this;
        this.dragAndDropManager.updateDroppingNode(e.movingShapes, this.updateParentTransforms);
      });
      __publicField(this, "updateParentTransforms", () => {
        const { editor: e, snapshot: { shapeSnapshots: n } } = this;
        n.forEach((r) => {
          const i = e.getShape(r.shape.id);
          if (!i)
            return null;
          const s = rs(i.parentId) ? null : Se.Inverse(e.getShapePageTransform(i.parentId));
          r.parentTransform = s;
        });
      });
    }
    startCloning() {
      this.isCreating || (this.isCloning = true, this.reset(), this.markId = "translating", this.editor.mark(this.markId), this.editor.duplicateShapes(Array.from(this.editor.selectedShapeIds)), this.snapshot = R7(this.editor), this.handleStart(), this.updateShapes());
    }
    stopCloning() {
      this.isCloning = false, this.snapshot = this.selectionSnapshot, this.reset(), this.markId = "translating", this.editor.mark(this.markId), this.updateShapes();
    }
    reset() {
      this.editor.bailToMark(this.markId);
    }
    complete() {
      if (this.updateShapes(), this.dragAndDropManager.dropShapes(this.snapshot.movingShapes), this.handleEnd(), this.editor.instanceState.isToolLocked && this.info.onInteractionEnd)
        this.editor.setCurrentTool(this.info.onInteractionEnd);
      else if (this.editAfterComplete) {
        const e = this.editor.onlySelectedShape;
        e && (this.editor.setEditingShape(e.id), this.editor.setCurrentTool("select.editing_shape"));
      } else
        this.parent.transition("idle", {});
    }
    cancel() {
      this.reset(), this.info.onInteractionEnd ? this.editor.setCurrentTool(this.info.onInteractionEnd) : this.parent.transition("idle", this.info);
    }
    handleStart() {
      const { movingShapes: e } = this.snapshot, n = [];
      e.forEach((r) => {
        var _a3, _b3;
        const s = (_b3 = (_a3 = this.editor.getShapeUtil(r)).onTranslateStart) == null ? void 0 : _b3.call(_a3, r);
        s && n.push(s);
      }), n.length > 0 && this.editor.updateShapes(n), this.editor.setHoveredShape(null);
    }
    handleEnd() {
      const { movingShapes: e } = this.snapshot, n = [];
      e.forEach((r) => {
        var _a3, _b3;
        const i = this.editor.getShape(r.id), o = (_b3 = (_a3 = this.editor.getShapeUtil(r)).onTranslateEnd) == null ? void 0 : _b3.call(_a3, r, i);
        o && n.push(o);
      }), n.length > 0 && this.editor.updateShapes(n);
    }
    handleChange() {
      const { movingShapes: e } = this.snapshot, n = [];
      e.forEach((r) => {
        var _a3, _b3;
        const i = this.editor.getShape(r.id), o = (_b3 = (_a3 = this.editor.getShapeUtil(r)).onTranslate) == null ? void 0 : _b3.call(_a3, r, i);
        o && n.push(o);
      }), n.length > 0 && this.editor.updateShapes(n);
    }
    updateShapes() {
      const { snapshot: e } = this;
      this.dragAndDropManager.updateDroppingNode(e.movingShapes, this.updateParentTransforms), G4e({
        editor: this.editor,
        shapeSnapshots: e.shapeSnapshots,
        averagePagePoint: e.averagePagePoint,
        initialSelectionPageBounds: e.initialPageBounds,
        initialSelectionSnapPoints: e.initialSnapPoints
      }), this.handleChange();
    }
  }
  __publicField(Y4e, "id", "translating");
  function R7(t) {
    const e = [], n = [], r = Je(t.selectedShapeIds.map((i) => {
      const s = t.getShape(i);
      if (!s)
        return null;
      e.push(s);
      const o = t.getShapePageTransform(i).point();
      if (!o)
        return null;
      n.push(o);
      const a = Zc.isId(s.parentId) ? null : Se.Inverse(t.getShapePageTransform(s.parentId));
      return {
        shape: s,
        pagePoint: o,
        parentTransform: a
      };
    }));
    return {
      averagePagePoint: I.Average(n),
      movingShapes: e,
      shapeSnapshots: r,
      initialPageBounds: t.selectionPageBounds,
      initialSnapPoints: t.selectedShapeIds.length === 1 ? t.snaps.snapPointsCache.get(t.selectedShapeIds[0]) : t.selectionPageBounds ? t.selectionPageBounds.snapPoints.map((i, s) => ({
        id: "selection:" + s,
        x: i.x,
        y: i.y
      })) : []
    };
  }
  function G4e({ editor: t, shapeSnapshots: e, averagePagePoint: n, initialSelectionPageBounds: r, initialSelectionSnapPoints: i }) {
    const { inputs: s, instanceState: { isGridMode: o }, documentSettings: { gridSize: a } } = t, l = I.Sub(s.currentPagePoint, s.originPagePoint), c = t.inputs.shiftKey ? Math.abs(l.x) < Math.abs(l.y) ? "x" : "y" : null;
    if (c === "x" ? l.x = 0 : c === "y" && (l.y = 0), t.snaps.clear(), (t.user.isSnapMode ? !s.ctrlKey : s.ctrlKey) && t.inputs.pointerVelocity.len() < 0.5) {
      const { nudge: f } = t.snaps.snapTranslate({
        dragDelta: l,
        initialSelectionPageBounds: r,
        lockedAxis: c,
        initialSelectionSnapPoints: i
      });
      l.add(f);
    }
    const d = I.Add(n, l);
    o && !s.ctrlKey && d.snapToGrid(a);
    const h = I.Sub(d, n);
    t.updateShapes(Je(e.map(({ shape: f, pagePoint: y, parentTransform: g }) => {
      const O = I.Add(y, h), S = g ? Se.applyToPoint(g, O) : O;
      return {
        id: f.id,
        type: f.type,
        x: S.x,
        y: S.y
      };
    })), {
      squashing: true
    });
  }
  class q4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "onExit", () => {
        this.editor.currentPageState.editingShapeId && this.editor.setEditingShape(null);
      });
    }
  }
  __publicField(q4e, "id", "select");
  __publicField(q4e, "initial", "idle");
  __publicField(q4e, "children", () => [
    I4e,
    A4e,
    D4e,
    Q4e,
    V4e,
    Y4e,
    C4e,
    Z4e,
    z4e,
    U4e,
    $4e,
    M4e,
    X4e,
    W4e,
    B4e,
    F4e,
    R4e
  ]);
  class K4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e;
      });
      __publicField(this, "onPointerDown", () => {
        this.parent.transition("pointing", this.info);
      });
    }
  }
  __publicField(K4e, "id", "idle");
  class J4e extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e;
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onPointerMove", () => {
        this.editor.inputs.isDragging && this.parent.transition("zoom_brushing", this.info);
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
    }
    complete() {
      const { currentScreenPoint: e } = this.editor.inputs;
      this.editor.inputs.altKey ? this.editor.zoomOut(e, {
        duration: 220
      }) : this.editor.zoomIn(e, {
        duration: 220
      }), this.parent.transition("idle", this.info);
    }
    cancel() {
      this.parent.transition("idle", this.info);
    }
  }
  __publicField(J4e, "id", "pointing");
  class eQe extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "zoomBrush", new Te());
      __publicField(this, "onEnter", (e) => {
        this.info = e, this.update();
      });
      __publicField(this, "onExit", () => {
        this.editor.updateInstanceState({
          zoomBrush: null
        });
      });
      __publicField(this, "onPointerMove", () => {
        this.update();
      });
      __publicField(this, "onPointerUp", () => {
        this.complete();
      });
      __publicField(this, "onCancel", () => {
        this.cancel();
      });
    }
    update() {
      const { inputs: { originPagePoint: e, currentPagePoint: n } } = this.editor;
      this.zoomBrush.setTo(Te.FromPoints([
        e,
        n
      ])), this.editor.updateInstanceState({
        zoomBrush: this.zoomBrush.toJson()
      });
    }
    cancel() {
      this.parent.transition("idle", this.info);
    }
    complete() {
      const { zoomBrush: e } = this, n = 8 / this.editor.zoomLevel;
      if (e.width < n && e.height < n) {
        const r = this.editor.inputs.currentScreenPoint;
        this.editor.inputs.altKey ? this.editor.zoomOut(r, {
          duration: 220
        }) : this.editor.zoomIn(r, {
          duration: 220
        });
      } else {
        const r = this.editor.inputs.altKey ? this.editor.zoomLevel / 2 : void 0;
        this.editor.zoomToBounds(e, r, {
          duration: 220
        });
      }
      this.parent.transition("idle", this.info);
    }
  }
  __publicField(eQe, "id", "zoom_brushing");
  class tQe extends ze {
    constructor() {
      super(...arguments);
      __publicField(this, "info", {});
      __publicField(this, "onEnter", (e) => {
        this.info = e, this.currentToolIdMask = e.onInteractionEnd, this.updateCursor();
      });
      __publicField(this, "onExit", () => {
        this.currentToolIdMask = void 0, this.editor.updateInstanceState({
          zoomBrush: null,
          cursor: {
            type: "default",
            rotation: 0
          }
        }, {
          ephemeral: true
        }), this.currentToolIdMask = void 0;
      });
      __publicField(this, "onKeyDown", () => {
        this.updateCursor();
      });
      __publicField(this, "onKeyUp", (e) => {
        this.updateCursor(), e.code === "KeyZ" && this.complete();
      });
      __publicField(this, "onInterrupt", () => {
        this.complete();
      });
    }
    complete() {
      this.info.onInteractionEnd && this.info.onInteractionEnd !== "select" ? this.editor.setCurrentTool(this.info.onInteractionEnd, this.info) : this.parent.transition("select", {});
    }
    updateCursor() {
      this.editor.inputs.altKey ? this.editor.updateInstanceState({
        cursor: {
          type: "zoom-out",
          rotation: 0
        }
      }, {
        ephemeral: true
      }) : this.editor.updateInstanceState({
        cursor: {
          type: "zoom-in",
          rotation: 0
        }
      }, {
        ephemeral: true
      });
    }
  }
  __publicField(tQe, "id", "zoom");
  __publicField(tQe, "initial", "idle");
  __publicField(tQe, "children", () => [
    K4e,
    eQe,
    J4e
  ]);
  const nQe = [
    v4e,
    x4e,
    P4e,
    tQe,
    q4e
  ];
  var rQe = Object.freeze({
    position: "absolute",
    border: 0,
    width: 1,
    height: 1,
    padding: 0,
    margin: -1,
    overflow: "hidden",
    clip: "rect(0, 0, 0, 0)",
    whiteSpace: "nowrap",
    wordWrap: "normal"
  }), iQe = "VisuallyHidden", a2 = b.forwardRef((t, e) => m.jsx(rt.span, {
    ...t,
    ref: e,
    style: {
      ...rQe,
      ...t.style
    }
  }));
  a2.displayName = iQe;
  var sQe = a2, RL = "ToastProvider", [ML, oQe, aQe] = VC("Toast"), [$ee, eat] = Ps("Toast", [
    aQe
  ]), [lQe, l2] = $ee(RL), Aee = (t) => {
    const { __scopeToast: e, label: n = "Notification", duration: r = 5e3, swipeDirection: i = "right", swipeThreshold: s = 50, children: o } = t, [a, l] = b.useState(null), [c, u] = b.useState(0), d = b.useRef(false), h = b.useRef(false);
    return n.trim() || console.error(`Invalid prop \`label\` supplied to \`${RL}\`. Expected non-empty \`string\`.`), m.jsx(ML.Provider, {
      scope: e,
      children: m.jsx(lQe, {
        scope: e,
        label: n,
        duration: r,
        swipeDirection: i,
        swipeThreshold: s,
        toastCount: c,
        viewport: a,
        onViewportChange: l,
        onToastAdd: b.useCallback(() => u((f) => f + 1), []),
        onToastRemove: b.useCallback(() => u((f) => f - 1), []),
        isFocusedToastEscapeKeyDownRef: d,
        isClosePausedRef: h,
        children: o
      })
    });
  };
  Aee.displayName = RL;
  var Ree = "ToastViewport", cQe = [
    "F8"
  ], MR = "toast.viewportPause", DR = "toast.viewportResume", Mee = b.forwardRef((t, e) => {
    const { __scopeToast: n, hotkey: r = cQe, label: i = "Notifications ({hotkey})", ...s } = t, o = l2(Ree, n), a = oQe(n), l = b.useRef(null), c = b.useRef(null), u = b.useRef(null), d = b.useRef(null), h = Ht(e, d, o.onViewportChange), f = r.join("+").replace(/Key/g, "").replace(/Digit/g, ""), y = o.toastCount > 0;
    b.useEffect(() => {
      const O = (S) => {
        var _a3;
        r.length !== 0 && r.every((x) => S[x] || S.code === x) && ((_a3 = d.current) == null ? void 0 : _a3.focus());
      };
      return document.addEventListener("keydown", O), () => document.removeEventListener("keydown", O);
    }, [
      r
    ]), b.useEffect(() => {
      const O = l.current, S = d.current;
      if (y && O && S) {
        const w = () => {
          if (!o.isClosePausedRef.current) {
            const _ = new CustomEvent(MR);
            S.dispatchEvent(_), o.isClosePausedRef.current = true;
          }
        }, x = () => {
          if (o.isClosePausedRef.current) {
            const _ = new CustomEvent(DR);
            S.dispatchEvent(_), o.isClosePausedRef.current = false;
          }
        }, P = (_) => {
          !O.contains(_.relatedTarget) && x();
        }, C = () => {
          O.contains(document.activeElement) || x();
        };
        return O.addEventListener("focusin", w), O.addEventListener("focusout", P), O.addEventListener("pointermove", w), O.addEventListener("pointerleave", C), window.addEventListener("blur", w), window.addEventListener("focus", x), () => {
          O.removeEventListener("focusin", w), O.removeEventListener("focusout", P), O.removeEventListener("pointermove", w), O.removeEventListener("pointerleave", C), window.removeEventListener("blur", w), window.removeEventListener("focus", x);
        };
      }
    }, [
      y,
      o.isClosePausedRef
    ]);
    const g = b.useCallback(({ tabbingDirection: O }) => {
      const w = a().map((x) => {
        const P = x.ref.current, C = [
          P,
          ...xQe(P)
        ];
        return O === "forwards" ? C : C.reverse();
      });
      return (O === "forwards" ? w.reverse() : w).flat();
    }, [
      a
    ]);
    return b.useEffect(() => {
      const O = d.current;
      if (O) {
        const S = (w) => {
          var _a3, _b3, _c3;
          const x = w.altKey || w.ctrlKey || w.metaKey;
          if (w.key === "Tab" && !x) {
            const C = document.activeElement, _ = w.shiftKey;
            if (w.target === O && _) {
              (_a3 = c.current) == null ? void 0 : _a3.focus();
              return;
            }
            const N = g({
              tabbingDirection: _ ? "backwards" : "forwards"
            }), L = N.findIndex((z) => z === C);
            vI(N.slice(L + 1)) ? w.preventDefault() : _ ? (_b3 = c.current) == null ? void 0 : _b3.focus() : (_c3 = u.current) == null ? void 0 : _c3.focus();
          }
        };
        return O.addEventListener("keydown", S), () => O.removeEventListener("keydown", S);
      }
    }, [
      a,
      g
    ]), m.jsxs(Q1e, {
      ref: l,
      role: "region",
      "aria-label": i.replace("{hotkey}", f),
      tabIndex: -1,
      style: {
        pointerEvents: y ? void 0 : "none"
      },
      children: [
        y && m.jsx(LR, {
          ref: c,
          onFocusFromOutsideViewport: () => {
            const O = g({
              tabbingDirection: "forwards"
            });
            vI(O);
          }
        }),
        m.jsx(ML.Slot, {
          scope: n,
          children: m.jsx(rt.ol, {
            tabIndex: -1,
            ...s,
            ref: h
          })
        }),
        y && m.jsx(LR, {
          ref: u,
          onFocusFromOutsideViewport: () => {
            const O = g({
              tabbingDirection: "backwards"
            });
            vI(O);
          }
        })
      ]
    });
  });
  Mee.displayName = Ree;
  var Dee = "ToastFocusProxy", LR = b.forwardRef((t, e) => {
    const { __scopeToast: n, onFocusFromOutsideViewport: r, ...i } = t, s = l2(Dee, n);
    return m.jsx(a2, {
      tabIndex: 0,
      ...i,
      ref: e,
      style: {
        position: "fixed"
      },
      onFocus: (o) => {
        var _a3;
        const a = o.relatedTarget;
        !((_a3 = s.viewport) == null ? void 0 : _a3.contains(a)) && r();
      }
    });
  });
  LR.displayName = Dee;
  var yS = "Toast", uQe = "toast.swipeStart", dQe = "toast.swipeMove", hQe = "toast.swipeCancel", fQe = "toast.swipeEnd", Lee = b.forwardRef((t, e) => {
    const { forceMount: n, open: r, defaultOpen: i, onOpenChange: s, ...o } = t, [a, l] = Wl({
      prop: r,
      defaultProp: i ?? true,
      onChange: s,
      caller: yS
    });
    return m.jsx(uo, {
      present: n || a,
      children: m.jsx(mQe, {
        open: a,
        ...o,
        ref: e,
        onClose: () => l(false),
        onPause: ki(t.onPause),
        onResume: ki(t.onResume),
        onSwipeStart: Pe(t.onSwipeStart, (c) => {
          c.currentTarget.setAttribute("data-swipe", "start");
        }),
        onSwipeMove: Pe(t.onSwipeMove, (c) => {
          const { x: u, y: d } = c.detail.delta;
          c.currentTarget.setAttribute("data-swipe", "move"), c.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${u}px`), c.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${d}px`);
        }),
        onSwipeCancel: Pe(t.onSwipeCancel, (c) => {
          c.currentTarget.setAttribute("data-swipe", "cancel"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
        }),
        onSwipeEnd: Pe(t.onSwipeEnd, (c) => {
          const { x: u, y: d } = c.detail.delta;
          c.currentTarget.setAttribute("data-swipe", "end"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), c.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${u}px`), c.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${d}px`), l(false);
        })
      })
    });
  });
  Lee.displayName = yS;
  var [pQe, gQe] = $ee(yS, {
    onClose() {
    }
  }), mQe = b.forwardRef((t, e) => {
    const { __scopeToast: n, type: r = "foreground", duration: i, open: s, onClose: o, onEscapeKeyDown: a, onPause: l, onResume: c, onSwipeStart: u, onSwipeMove: d, onSwipeCancel: h, onSwipeEnd: f, ...y } = t, g = l2(yS, n), [O, S] = b.useState(null), w = Ht(e, (F) => S(F)), x = b.useRef(null), P = b.useRef(null), C = i || g.duration, _ = b.useRef(0), T = b.useRef(C), $ = b.useRef(0), { onToastAdd: N, onToastRemove: L } = g, z = ki(() => {
      var _a3;
      (O == null ? void 0 : O.contains(document.activeElement)) && ((_a3 = g.viewport) == null ? void 0 : _a3.focus()), o();
    }), M = b.useCallback((F) => {
      !F || F === 1 / 0 || (window.clearTimeout($.current), _.current = (/* @__PURE__ */ new Date()).getTime(), $.current = window.setTimeout(z, F));
    }, [
      z
    ]);
    b.useEffect(() => {
      const F = g.viewport;
      if (F) {
        const Q = () => {
          M(T.current), c == null ? void 0 : c();
        }, X = () => {
          const Z = (/* @__PURE__ */ new Date()).getTime() - _.current;
          T.current = T.current - Z, window.clearTimeout($.current), l == null ? void 0 : l();
        };
        return F.addEventListener(MR, X), F.addEventListener(DR, Q), () => {
          F.removeEventListener(MR, X), F.removeEventListener(DR, Q);
        };
      }
    }, [
      g.viewport,
      C,
      l,
      c,
      M
    ]), b.useEffect(() => {
      s && !g.isClosePausedRef.current && M(C);
    }, [
      s,
      C,
      g.isClosePausedRef,
      M
    ]), b.useEffect(() => (N(), () => L()), [
      N,
      L
    ]);
    const R = b.useMemo(() => O ? Uee(O) : null, [
      O
    ]);
    return g.viewport ? m.jsxs(m.Fragment, {
      children: [
        R && m.jsx(yQe, {
          __scopeToast: n,
          role: "status",
          "aria-live": r === "foreground" ? "assertive" : "polite",
          children: R
        }),
        m.jsx(pQe, {
          scope: n,
          onClose: z,
          children: jd.createPortal(m.jsx(ML.ItemSlot, {
            scope: n,
            children: m.jsx(N1e, {
              asChild: true,
              onEscapeKeyDown: Pe(a, () => {
                g.isFocusedToastEscapeKeyDownRef.current || z(), g.isFocusedToastEscapeKeyDownRef.current = false;
              }),
              children: m.jsx(rt.li, {
                tabIndex: 0,
                "data-state": s ? "open" : "closed",
                "data-swipe-direction": g.swipeDirection,
                ...y,
                ref: w,
                style: {
                  userSelect: "none",
                  touchAction: "none",
                  ...t.style
                },
                onKeyDown: Pe(t.onKeyDown, (F) => {
                  F.key === "Escape" && (a == null ? void 0 : a(F.nativeEvent), F.nativeEvent.defaultPrevented || (g.isFocusedToastEscapeKeyDownRef.current = true, z()));
                }),
                onPointerDown: Pe(t.onPointerDown, (F) => {
                  F.button === 0 && (x.current = {
                    x: F.clientX,
                    y: F.clientY
                  });
                }),
                onPointerMove: Pe(t.onPointerMove, (F) => {
                  if (!x.current)
                    return;
                  const Q = F.clientX - x.current.x, X = F.clientY - x.current.y, Z = !!P.current, U = [
                    "left",
                    "right"
                  ].includes(g.swipeDirection), H = [
                    "left",
                    "up"
                  ].includes(g.swipeDirection) ? Math.min : Math.max, te = U ? H(0, Q) : 0, se = U ? 0 : H(0, X), ae = F.pointerType === "touch" ? 10 : 2, _e3 = {
                    x: te,
                    y: se
                  }, Me = {
                    originalEvent: F,
                    delta: _e3
                  };
                  Z ? (P.current = _e3, Dw(dQe, d, Me, {
                    discrete: false
                  })) : M7(_e3, g.swipeDirection, ae) ? (P.current = _e3, Dw(uQe, u, Me, {
                    discrete: false
                  }), F.target.setPointerCapture(F.pointerId)) : (Math.abs(Q) > ae || Math.abs(X) > ae) && (x.current = null);
                }),
                onPointerUp: Pe(t.onPointerUp, (F) => {
                  const Q = P.current, X = F.target;
                  if (X.hasPointerCapture(F.pointerId) && X.releasePointerCapture(F.pointerId), P.current = null, x.current = null, Q) {
                    const Z = F.currentTarget, U = {
                      originalEvent: F,
                      delta: Q
                    };
                    M7(Q, g.swipeDirection, g.swipeThreshold) ? Dw(fQe, f, U, {
                      discrete: true
                    }) : Dw(hQe, h, U, {
                      discrete: true
                    }), Z.addEventListener("click", (H) => H.preventDefault(), {
                      once: true
                    });
                  }
                })
              })
            })
          }), g.viewport)
        })
      ]
    }) : null;
  }), yQe = (t) => {
    const { __scopeToast: e, children: n, ...r } = t, i = l2(yS, e), [s, o] = b.useState(false), [a, l] = b.useState(false);
    return SQe(() => o(true)), b.useEffect(() => {
      const c = window.setTimeout(() => l(true), 1e3);
      return () => window.clearTimeout(c);
    }, []), a ? null : m.jsx(ZO, {
      asChild: true,
      children: m.jsx(a2, {
        ...r,
        children: s && m.jsxs(m.Fragment, {
          children: [
            i.label,
            " ",
            n
          ]
        })
      })
    });
  }, vQe = "ToastTitle", jee = b.forwardRef((t, e) => {
    const { __scopeToast: n, ...r } = t;
    return m.jsx(rt.div, {
      ...r,
      ref: e
    });
  });
  jee.displayName = vQe;
  var OQe = "ToastDescription", Nee = b.forwardRef((t, e) => {
    const { __scopeToast: n, ...r } = t;
    return m.jsx(rt.div, {
      ...r,
      ref: e
    });
  });
  Nee.displayName = OQe;
  var Qee = "ToastAction", zee = b.forwardRef((t, e) => {
    const { altText: n, ...r } = t;
    return n.trim() ? m.jsx(Bee, {
      altText: n,
      asChild: true,
      children: m.jsx(DL, {
        ...r,
        ref: e
      })
    }) : (console.error(`Invalid prop \`altText\` supplied to \`${Qee}\`. Expected non-empty \`string\`.`), null);
  });
  zee.displayName = Qee;
  var Fee = "ToastClose", DL = b.forwardRef((t, e) => {
    const { __scopeToast: n, ...r } = t, i = gQe(Fee, n);
    return m.jsx(Bee, {
      asChild: true,
      children: m.jsx(rt.button, {
        type: "button",
        ...r,
        ref: e,
        onClick: Pe(t.onClick, i.onClose)
      })
    });
  });
  DL.displayName = Fee;
  var Bee = b.forwardRef((t, e) => {
    const { __scopeToast: n, altText: r, ...i } = t;
    return m.jsx(rt.div, {
      "data-radix-toast-announce-exclude": "",
      "data-radix-toast-announce-alt": r || void 0,
      ...i,
      ref: e
    });
  });
  function Uee(t) {
    const e = [];
    return Array.from(t.childNodes).forEach((r) => {
      if (r.nodeType === r.TEXT_NODE && r.textContent && e.push(r.textContent), wQe(r)) {
        const i = r.ariaHidden || r.hidden || r.style.display === "none", s = r.dataset.radixToastAnnounceExclude === "";
        if (!i)
          if (s) {
            const o = r.dataset.radixToastAnnounceAlt;
            o && e.push(o);
          } else
            e.push(...Uee(r));
      }
    }), e;
  }
  function Dw(t, e, n, { discrete: r }) {
    const i = n.originalEvent.currentTarget, s = new CustomEvent(t, {
      bubbles: true,
      cancelable: true,
      detail: n
    });
    e && i.addEventListener(t, e, {
      once: true
    }), r ? Z3(i, s) : i.dispatchEvent(s);
  }
  var M7 = (t, e, n = 0) => {
    const r = Math.abs(t.x), i = Math.abs(t.y), s = r > i;
    return e === "left" || e === "right" ? s && r > n : !s && i > n;
  };
  function SQe(t = () => {
  }) {
    const e = ki(t);
    ta(() => {
      let n = 0, r = 0;
      return n = window.requestAnimationFrame(() => r = window.requestAnimationFrame(e)), () => {
        window.cancelAnimationFrame(n), window.cancelAnimationFrame(r);
      };
    }, [
      e
    ]);
  }
  function wQe(t) {
    return t.nodeType === t.ELEMENT_NODE;
  }
  function xQe(t) {
    const e = [], n = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
      acceptNode: (r) => {
        const i = r.tagName === "INPUT" && r.type === "hidden";
        return r.disabled || r.hidden || i ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
      }
    });
    for (; n.nextNode(); )
      e.push(n.currentNode);
    return e;
  }
  function vI(t) {
    const e = document.activeElement;
    return t.some((n) => n === e ? true : (n.focus(), document.activeElement !== e));
  }
  var bQe = Lee, kQe = jee, PQe = Nee, CQe = zee, D7 = DL;
  const Lh = "2.0.0-alpha.17";
  let jR = {
    fonts: {
      draw: `https://unpkg.com/@tldraw/assets@${Lh}/fonts/Shantell_Sans-Normal-SemiBold.woff2`,
      serif: `https://unpkg.com/@tldraw/assets@${Lh}/fonts/IBMPlexSerif-Medium.woff2`,
      sansSerif: `https://unpkg.com/@tldraw/assets@${Lh}/fonts/IBMPlexSans-Medium.woff2`,
      monospace: `https://unpkg.com/@tldraw/assets@${Lh}/fonts/IBMPlexMono-Medium.woff2`
    }
  };
  function _Qe(t) {
    return b.useMemo(() => t ? {
      fonts: {
        ...jR.fonts,
        ...t == null ? void 0 : t.fonts
      }
    } : jR, [
      t
    ]);
  }
  const TQe = [
    "align-bottom-center",
    "align-bottom-left",
    "align-bottom-right",
    "align-bottom",
    "align-center-center",
    "align-center-horizontal",
    "align-center-left",
    "align-center-right",
    "align-center-vertical",
    "align-left",
    "align-right",
    "align-top-center",
    "align-top-left",
    "align-top-right",
    "align-top",
    "arrow-left",
    "arrowhead-arrow",
    "arrowhead-bar",
    "arrowhead-diamond",
    "arrowhead-dot",
    "arrowhead-none",
    "arrowhead-square",
    "arrowhead-triangle-inverted",
    "arrowhead-triangle",
    "aspect-ratio",
    "avatar",
    "blob",
    "bring-forward",
    "bring-to-front",
    "check",
    "checkbox-checked",
    "checkbox-empty",
    "chevron-down",
    "chevron-left",
    "chevron-right",
    "chevron-up",
    "chevrons-ne",
    "chevrons-sw",
    "clipboard-copied",
    "clipboard-copy",
    "code",
    "collab",
    "color",
    "comment",
    "cross-2",
    "cross",
    "dash-dashed",
    "dash-dotted",
    "dash-draw",
    "dash-solid",
    "discord",
    "distribute-horizontal",
    "distribute-vertical",
    "dot",
    "dots-horizontal",
    "dots-vertical",
    "drag-handle-dots",
    "duplicate",
    "edit",
    "external-link",
    "file",
    "fill-none",
    "fill-pattern",
    "fill-semi",
    "fill-solid",
    "follow",
    "following",
    "font-draw",
    "font-mono",
    "font-sans",
    "font-serif",
    "geo-arrow-down",
    "geo-arrow-left",
    "geo-arrow-right",
    "geo-arrow-up",
    "geo-check-box",
    "geo-cloud",
    "geo-diamond",
    "geo-ellipse",
    "geo-hexagon",
    "geo-octagon",
    "geo-oval",
    "geo-pentagon",
    "geo-rectangle",
    "geo-rhombus-2",
    "geo-rhombus",
    "geo-star",
    "geo-trapezoid",
    "geo-triangle",
    "geo-x-box",
    "github",
    "group",
    "hidden",
    "image",
    "info-circle",
    "leading",
    "link",
    "lock-small",
    "lock",
    "menu",
    "minus",
    "mixed",
    "pack",
    "page",
    "plus",
    "question-mark-circle",
    "question-mark",
    "redo",
    "reset-zoom",
    "rotate-ccw",
    "rotate-cw",
    "ruler",
    "search",
    "send-backward",
    "send-to-back",
    "settings-horizontal",
    "settings-vertical-1",
    "settings-vertical",
    "share-1",
    "share-2",
    "size-extra-large",
    "size-large",
    "size-medium",
    "size-small",
    "spline-cubic",
    "spline-line",
    "stack-horizontal",
    "stack-vertical",
    "status-offline",
    "status-online",
    "stretch-horizontal",
    "stretch-vertical",
    "text-align-center",
    "text-align-justify",
    "text-align-left",
    "text-align-right",
    "tool-arrow",
    "tool-embed",
    "tool-eraser",
    "tool-frame",
    "tool-hand",
    "tool-highlight",
    "tool-laser",
    "tool-line",
    "tool-media",
    "tool-note",
    "tool-pencil",
    "tool-pointer",
    "tool-text",
    "trash",
    "triangle-down",
    "triangle-up",
    "twitter",
    "undo",
    "ungroup",
    "unlock-small",
    "unlock",
    "vertical-align-center",
    "vertical-align-end",
    "vertical-align-start",
    "visible",
    "warning-triangle",
    "zoom-in",
    "zoom-out"
  ];
  let Zy = {
    ...jR,
    icons: Object.fromEntries(TQe.map((t) => [
      t,
      `https://unpkg.com/@tldraw/assets@${Lh}/icons/icon/${t}.svg`
    ])),
    translations: Object.fromEntries(Vv.map((t) => [
      t.locale,
      `https://unpkg.com/@tldraw/assets@${Lh}/translations/${t.locale}.json`
    ])),
    embedIcons: Object.fromEntries(Ng.map((t) => [
      t.type,
      `https://unpkg.com/@tldraw/assets@${Lh}/embed-icons/${t.type}.png`
    ]))
  };
  function EQe(t) {
    return t ? {
      fonts: Object.assign({
        ...Zy.fonts
      }, {
        ...t == null ? void 0 : t.fonts
      }),
      icons: Object.assign({
        ...Zy.icons
      }, {
        ...t == null ? void 0 : t.icons
      }),
      embedIcons: Object.assign({
        ...Zy.embedIcons
      }, {
        ...t == null ? void 0 : t.embedIcons
      }),
      translations: Object.assign({
        ...Zy.translations
      }, {
        ...t == null ? void 0 : t.translations
      })
    } : Zy;
  }
  const LL = b.forwardRef(function({ className: e, label: n, icon: r, iconLeft: i, autoselect: s = false, autofocus: o = false, defaultValue: a, placeholder: l, onComplete: c, onValueChange: u, onCancel: d, onBlur: h, shouldManuallyMaintainScrollPositionWhenFocused: f = false, children: y, value: g }, O) {
    const S = ue(), w = b.useRef(null);
    b.useImperativeHandle(O, () => w.current);
    const x = Tt(), P = b.useRef(a ?? ""), C = b.useRef(a ?? ""), [_, T] = b.useState(false), $ = b.useCallback((M) => {
      T(true);
      const R = M.currentTarget;
      C.current = R.value, requestAnimationFrame(() => {
        s && R.select();
      });
    }, [
      s
    ]), N = b.useCallback((M) => {
      const R = M.currentTarget.value;
      C.current = R, u == null ? void 0 : u(R);
    }, [
      u
    ]), L = b.useCallback((M) => {
      switch (M.key) {
        case "Enter": {
          M.currentTarget.blur(), _r(M), c == null ? void 0 : c(M.currentTarget.value);
          break;
        }
        case "Escape": {
          M.currentTarget.value = P.current, M.currentTarget.blur(), _r(M), d == null ? void 0 : d(M.currentTarget.value);
          break;
        }
      }
    }, [
      c,
      d
    ]), z = b.useCallback((M) => {
      T(false);
      const R = M.currentTarget.value;
      h == null ? void 0 : h(R);
    }, [
      h
    ]);
    return b.useEffect(() => {
      if (!S.environment.isIos)
        return;
      const M = window.visualViewport;
      if (_ && f && M) {
        const R = () => {
          var _a3;
          (_a3 = w.current) == null ? void 0 : _a3.scrollIntoView({
            block: "center"
          });
        };
        return M.addEventListener("resize", R), M.addEventListener("scroll", R), requestAnimationFrame(() => {
          var _a3;
          (_a3 = w.current) == null ? void 0 : _a3.scrollIntoView({
            block: "center"
          });
        }), () => {
          M.removeEventListener("resize", R), M.removeEventListener("scroll", R);
        };
      }
    }, [
      S,
      _,
      f
    ]), m.jsxs("div", {
      draggable: false,
      className: "tlui-input__wrapper",
      children: [
        y,
        n && m.jsx("label", {
          children: x(n)
        }),
        i && m.jsx(Ss, {
          icon: i,
          className: "tlui-icon-left",
          small: true
        }),
        m.jsx("input", {
          ref: w,
          className: Ze("tlui-input", e),
          type: "text",
          defaultValue: a,
          onKeyUp: L,
          onChange: N,
          onFocus: $,
          onBlur: z,
          autoFocus: o,
          placeholder: l,
          value: g
        }),
        r && m.jsx(Ss, {
          icon: r,
          small: !!n
        })
      ]
    });
  });
  function L7(t) {
    return qA(t) ? {
      isValid: true,
      hasProtocol: true
    } : qA("https://" + t) ? {
      isValid: true,
      hasProtocol: false
    } : {
      isValid: false,
      hasProtocol: false
    };
  }
  const IQe = Vt(function({ onClose: e }) {
    const r = ue().onlySelectedShape;
    return r && "url" in r.props && typeof r.props.url == "string" ? m.jsx($Qe, {
      onClose: e,
      selectedShape: r
    }) : null;
  }), $Qe = Vt(function({ onClose: e, selectedShape: n }) {
    const r = ue(), i = Tt(), s = b.useRef(null);
    b.useEffect(() => {
      requestAnimationFrame(() => {
        var _a3;
        return (_a3 = s.current) == null ? void 0 : _a3.focus();
      });
    }, []);
    const o = b.useRef(n.props.url), [a, l] = b.useState(() => {
      const y = L7(n.props.url), g = y.isValid === true ? y.hasProtocol ? n.props.url : "https://" + n.props.url : "https://";
      return {
        actual: g,
        safe: g,
        valid: true
      };
    }), c = b.useCallback((y) => {
      const g = y.replace(/https?:\/\/(https?:\/\/)/, (w, x) => x), O = L7(g), S = O.isValid === true ? O.hasProtocol ? g : "https://" + g : "https://";
      l({
        actual: g,
        safe: S,
        valid: O.isValid
      });
    }, []), u = b.useCallback(() => {
      const { onlySelectedShape: y } = r;
      y && (r.updateShapes([
        {
          id: y.id,
          type: y.type,
          props: {
            url: ""
          }
        }
      ]), e());
    }, [
      r,
      e
    ]), d = b.useCallback(() => {
      const { onlySelectedShape: y } = r;
      y && (y && "url" in y.props && y.props.url !== a.safe && r.updateShapes([
        {
          id: y.id,
          type: y.type,
          props: {
            url: a.safe
          }
        }
      ]), e());
    }, [
      r,
      e,
      a
    ]), h = b.useCallback(() => {
      e();
    }, [
      e
    ]);
    if (!n)
      return e(), null;
    const f = o.current && !a.valid;
    return m.jsxs(m.Fragment, {
      children: [
        m.jsxs(FC, {
          children: [
            m.jsx(BC, {
              children: i("edit-link-dialog.title")
            }),
            m.jsx(UC, {})
          ]
        }),
        m.jsx(qv, {
          children: m.jsxs("div", {
            className: "tlui-edit-link-dialog",
            children: [
              m.jsx(LL, {
                ref: s,
                className: "tlui-edit-link-dialog__input",
                label: "edit-link-dialog.url",
                autofocus: true,
                value: a.actual,
                onValueChange: c,
                onComplete: d,
                onCancel: h
              }),
              m.jsx("div", {
                children: a.valid ? i("edit-link-dialog.detail") : i("edit-link-dialog.invalid-url")
              })
            ]
          })
        }),
        m.jsxs(J5, {
          className: "tlui-dialog__footer__actions",
          children: [
            m.jsx(Be, {
              onClick: h,
              onTouchEnd: h,
              children: i("edit-link-dialog.cancel")
            }),
            f ? m.jsx(Be, {
              type: "danger",
              onTouchEnd: u,
              onClick: u,
              children: i("edit-link-dialog.clear")
            }) : m.jsx(Be, {
              type: "primary",
              disabled: !a.valid,
              onTouchEnd: d,
              onClick: d,
              children: i("edit-link-dialog.save")
            })
          ]
        })
      ]
    });
  }), Vee = Vt(function({ onClose: e }) {
    const n = ue(), r = Tt(), i = K5(), [s, o] = b.useState(null), [a, l] = b.useState(""), [c, u] = b.useState(null), [d, h] = b.useState(false), f = b.useRef(-1);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsxs(FC, {
          children: [
            m.jsx(BC, {
              children: s ? `${r("embed-dialog.title")} \u2014 ${s.title}` : r("embed-dialog.title")
            }),
            m.jsx(UC, {})
          ]
        }),
        s ? m.jsxs(m.Fragment, {
          children: [
            m.jsxs(qv, {
              className: "tlui-embed-dialog__enter",
              children: [
                m.jsx(LL, {
                  className: "tlui-embed-dialog__input",
                  label: "embed-dialog.url",
                  placeholder: "http://example.com",
                  autofocus: true,
                  onValueChange: (y) => {
                    l(y);
                    const g = Cc(y);
                    u(g && g.definition.type === s.type ? g : null), h(false), clearTimeout(f.current), f.current = setTimeout(() => h(!g), 320);
                  }
                }),
                a === "" ? m.jsxs("div", {
                  className: "tlui-embed-dialog__instruction",
                  children: [
                    m.jsx("span", {
                      children: r("embed-dialog.instruction")
                    }),
                    " ",
                    s.instructionLink && m.jsxs("a", {
                      target: "_blank",
                      rel: "noopener noreferrer",
                      href: s.instructionLink,
                      className: "tlui-embed-dialog__instruction__link",
                      children: [
                        "Learn more.",
                        m.jsx(Ss, {
                          icon: "external-link",
                          small: true
                        })
                      ]
                    })
                  ]
                }) : m.jsx("div", {
                  className: "tlui-embed-dialog__warning",
                  children: d ? r("embed-dialog.invalid-url") : "\xA0"
                })
              ]
            }),
            m.jsxs(J5, {
              className: "tlui-dialog__footer__actions",
              children: [
                m.jsx(Be, {
                  onClick: () => {
                    o(null), u(null), l("");
                  },
                  label: "embed-dialog.back"
                }),
                m.jsx("div", {
                  className: "tlui-embed__spacer"
                }),
                m.jsx(Be, {
                  label: "embed-dialog.cancel",
                  onClick: e
                }),
                m.jsx(Be, {
                  type: "primary",
                  disabled: !c,
                  label: "embed-dialog.create",
                  onClick: () => {
                    c && (n.putExternalContent({
                      type: "embed",
                      url: a,
                      point: n.viewportPageCenter,
                      embed: c.definition
                    }), e());
                  }
                })
              ]
            })
          ]
        }) : m.jsxs(m.Fragment, {
          children: [
            m.jsx(qv, {
              className: "tlui-embed-dialog__list",
              children: Ng.map((y) => m.jsxs("button", {
                className: "tlui-embed-dialog__item",
                onClick: () => o(y),
                children: [
                  m.jsx("div", {
                    className: "tlui-embed-dialog__item__image",
                    children: m.jsx("div", {
                      className: "tlui-embed-dialog__item__image__img",
                      style: {
                        backgroundImage: `url(${i.embedIcons[y.type]})`
                      }
                    })
                  }),
                  m.jsx("div", {
                    className: "tlui-embed-dialog__item__title",
                    children: y.title
                  })
                ]
              }, y.type))
            }),
            m.jsx("div", {
              className: "tlui-dialog__scrim"
            })
          ]
        })
      ]
    });
  });
  var jL = {
    exports: {}
  };
  jL.exports;
  (function(t) {
    var e = function() {
      var n = String.fromCharCode, r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$", s = {};
      function o(l, c) {
        if (!s[l]) {
          s[l] = {};
          for (var u = 0; u < l.length; u++)
            s[l][l.charAt(u)] = u;
        }
        return s[l][c];
      }
      var a = {
        compressToBase64: function(l) {
          if (l == null)
            return "";
          var c = a._compress(l, 6, function(u) {
            return r.charAt(u);
          });
          switch (c.length % 4) {
            default:
            case 0:
              return c;
            case 1:
              return c + "===";
            case 2:
              return c + "==";
            case 3:
              return c + "=";
          }
        },
        decompressFromBase64: function(l) {
          return l == null ? "" : l == "" ? null : a._decompress(l.length, 32, function(c) {
            return o(r, l.charAt(c));
          });
        },
        compressToUTF16: function(l) {
          return l == null ? "" : a._compress(l, 15, function(c) {
            return n(c + 32);
          }) + " ";
        },
        decompressFromUTF16: function(l) {
          return l == null ? "" : l == "" ? null : a._decompress(l.length, 16384, function(c) {
            return l.charCodeAt(c) - 32;
          });
        },
        compressToUint8Array: function(l) {
          for (var c = a.compress(l), u = new Uint8Array(c.length * 2), d = 0, h = c.length; d < h; d++) {
            var f = c.charCodeAt(d);
            u[d * 2] = f >>> 8, u[d * 2 + 1] = f % 256;
          }
          return u;
        },
        decompressFromUint8Array: function(l) {
          if (l == null)
            return a.decompress(l);
          for (var c = new Array(l.length / 2), u = 0, d = c.length; u < d; u++)
            c[u] = l[u * 2] * 256 + l[u * 2 + 1];
          var h = [];
          return c.forEach(function(f) {
            h.push(n(f));
          }), a.decompress(h.join(""));
        },
        compressToEncodedURIComponent: function(l) {
          return l == null ? "" : a._compress(l, 6, function(c) {
            return i.charAt(c);
          });
        },
        decompressFromEncodedURIComponent: function(l) {
          return l == null ? "" : l == "" ? null : (l = l.replace(/ /g, "+"), a._decompress(l.length, 32, function(c) {
            return o(i, l.charAt(c));
          }));
        },
        compress: function(l) {
          return a._compress(l, 16, function(c) {
            return n(c);
          });
        },
        _compress: function(l, c, u) {
          if (l == null)
            return "";
          var d, h, f = {}, y = {}, g = "", O = "", S = "", w = 2, x = 3, P = 2, C = [], _ = 0, T = 0, $;
          for ($ = 0; $ < l.length; $ += 1)
            if (g = l.charAt($), Object.prototype.hasOwnProperty.call(f, g) || (f[g] = x++, y[g] = true), O = S + g, Object.prototype.hasOwnProperty.call(f, O))
              S = O;
            else {
              if (Object.prototype.hasOwnProperty.call(y, S)) {
                if (S.charCodeAt(0) < 256) {
                  for (d = 0; d < P; d++)
                    _ = _ << 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++;
                  for (h = S.charCodeAt(0), d = 0; d < 8; d++)
                    _ = _ << 1 | h & 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = h >> 1;
                } else {
                  for (h = 1, d = 0; d < P; d++)
                    _ = _ << 1 | h, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = 0;
                  for (h = S.charCodeAt(0), d = 0; d < 16; d++)
                    _ = _ << 1 | h & 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = h >> 1;
                }
                w--, w == 0 && (w = Math.pow(2, P), P++), delete y[S];
              } else
                for (h = f[S], d = 0; d < P; d++)
                  _ = _ << 1 | h & 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = h >> 1;
              w--, w == 0 && (w = Math.pow(2, P), P++), f[O] = x++, S = String(g);
            }
          if (S !== "") {
            if (Object.prototype.hasOwnProperty.call(y, S)) {
              if (S.charCodeAt(0) < 256) {
                for (d = 0; d < P; d++)
                  _ = _ << 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++;
                for (h = S.charCodeAt(0), d = 0; d < 8; d++)
                  _ = _ << 1 | h & 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = h >> 1;
              } else {
                for (h = 1, d = 0; d < P; d++)
                  _ = _ << 1 | h, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = 0;
                for (h = S.charCodeAt(0), d = 0; d < 16; d++)
                  _ = _ << 1 | h & 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = h >> 1;
              }
              w--, w == 0 && (w = Math.pow(2, P), P++), delete y[S];
            } else
              for (h = f[S], d = 0; d < P; d++)
                _ = _ << 1 | h & 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = h >> 1;
            w--, w == 0 && (w = Math.pow(2, P), P++);
          }
          for (h = 2, d = 0; d < P; d++)
            _ = _ << 1 | h & 1, T == c - 1 ? (T = 0, C.push(u(_)), _ = 0) : T++, h = h >> 1;
          for (; ; )
            if (_ = _ << 1, T == c - 1) {
              C.push(u(_));
              break;
            } else
              T++;
          return C.join("");
        },
        decompress: function(l) {
          return l == null ? "" : l == "" ? null : a._decompress(l.length, 32768, function(c) {
            return l.charCodeAt(c);
          });
        },
        _decompress: function(l, c, u) {
          var d = [], h = 4, f = 4, y = 3, g = "", O = [], S, w, x, P, C, _, T, $ = {
            val: u(0),
            position: c,
            index: 1
          };
          for (S = 0; S < 3; S += 1)
            d[S] = S;
          for (x = 0, C = Math.pow(2, 2), _ = 1; _ != C; )
            P = $.val & $.position, $.position >>= 1, $.position == 0 && ($.position = c, $.val = u($.index++)), x |= (P > 0 ? 1 : 0) * _, _ <<= 1;
          switch (x) {
            case 0:
              for (x = 0, C = Math.pow(2, 8), _ = 1; _ != C; )
                P = $.val & $.position, $.position >>= 1, $.position == 0 && ($.position = c, $.val = u($.index++)), x |= (P > 0 ? 1 : 0) * _, _ <<= 1;
              T = n(x);
              break;
            case 1:
              for (x = 0, C = Math.pow(2, 16), _ = 1; _ != C; )
                P = $.val & $.position, $.position >>= 1, $.position == 0 && ($.position = c, $.val = u($.index++)), x |= (P > 0 ? 1 : 0) * _, _ <<= 1;
              T = n(x);
              break;
            case 2:
              return "";
          }
          for (d[3] = T, w = T, O.push(T); ; ) {
            if ($.index > l)
              return "";
            for (x = 0, C = Math.pow(2, y), _ = 1; _ != C; )
              P = $.val & $.position, $.position >>= 1, $.position == 0 && ($.position = c, $.val = u($.index++)), x |= (P > 0 ? 1 : 0) * _, _ <<= 1;
            switch (T = x) {
              case 0:
                for (x = 0, C = Math.pow(2, 8), _ = 1; _ != C; )
                  P = $.val & $.position, $.position >>= 1, $.position == 0 && ($.position = c, $.val = u($.index++)), x |= (P > 0 ? 1 : 0) * _, _ <<= 1;
                d[f++] = n(x), T = f - 1, h--;
                break;
              case 1:
                for (x = 0, C = Math.pow(2, 16), _ = 1; _ != C; )
                  P = $.val & $.position, $.position >>= 1, $.position == 0 && ($.position = c, $.val = u($.index++)), x |= (P > 0 ? 1 : 0) * _, _ <<= 1;
                d[f++] = n(x), T = f - 1, h--;
                break;
              case 2:
                return O.join("");
            }
            if (h == 0 && (h = Math.pow(2, y), y++), d[T])
              g = d[T];
            else if (T === f)
              g = w + w.charAt(0);
            else
              return null;
            O.push(g), d[f++] = w + g.charAt(0), h--, w = g, h == 0 && (h = Math.pow(2, y), y++);
          }
        }
      };
      return a;
    }();
    t != null ? t.exports = e : typeof angular < "u" && angular != null && angular.module("LZString", []).factory("LZString", function() {
      return e;
    });
  })(jL);
  var Xee = jL.exports;
  async function AQe(t, e, n) {
    var _a3, _b3, _c3;
    const { elements: r, files: i } = e, s = {
      shapes: [],
      rootShapeIds: [],
      assets: [],
      schema: t.store.schema.serialize()
    }, o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), { currentPageId: l } = t, c = /* @__PURE__ */ new Map(), u = [], d = /* @__PURE__ */ new Set();
    r.forEach((S) => {
      if (c.set(S.id, bn()), S.boundElements !== null)
        for (const w of S.boundElements)
          w.type === "text" && d.add(w.id);
    });
    let h = "a1";
    for (const S of r) {
      if (d.has(S.id))
        continue;
      const w = c.get(S.id), x = {
        id: w,
        typeName: "shape",
        parentId: l,
        index: h,
        x: S.x,
        y: S.y,
        rotation: 0,
        isLocked: S.locked,
        opacity: RQe(S.opacity),
        meta: {}
      };
      switch (S.angle !== 0 && a.set(w, S.angle), S.groupIds && S.groupIds.length > 0 ? o.has(S.groupIds[0]) ? (_a3 = o.get(S.groupIds[0])) == null ? void 0 : _a3.push(w) : o.set(S.groupIds[0], [
        w
      ]) : u.push(w), S.type) {
        case "rectangle":
        case "ellipse":
        case "diamond": {
          let P = "", C = "middle";
          if (S.boundElements !== null) {
            for (const T of S.boundElements)
              if (T.type === "text") {
                const $ = r.find((N) => N.id === T.id);
                $ && (P = $.text, C = j7[$.textAlign]);
              }
          }
          const _ = S.backgroundColor === "transparent" ? S.strokeColor : S.backgroundColor;
          s.shapes.push({
            ...x,
            type: "geo",
            props: {
              geo: S.type,
              url: S.link ?? "",
              w: S.width,
              h: S.height,
              size: Lw[S.strokeWidth] ?? "draw",
              color: Hy[_] ?? "black",
              text: P,
              align: C,
              dash: jw(S),
              fill: zQe(S)
            }
          });
          break;
        }
        case "freedraw": {
          s.shapes.push({
            ...x,
            type: "draw",
            props: {
              dash: jw(S),
              size: Lw[S.strokeWidth],
              color: Hy[S.strokeColor] ?? "black",
              segments: [
                {
                  type: "free",
                  points: S.points.map(([P, C, _ = 0.5]) => ({
                    x: P,
                    y: C,
                    z: _
                  }))
                }
              ]
            }
          });
          break;
        }
        case "line": {
          const P = S.points[0], C = S.points[S.points.length - 1], _ = sq(S.points.length);
          s.shapes.push({
            ...x,
            type: "line",
            props: {
              dash: jw(S),
              size: Lw[S.strokeWidth],
              color: Hy[S.strokeColor] ?? "black",
              spline: S.roundness ? "cubic" : "line",
              handles: {
                start: {
                  id: "start",
                  type: "vertex",
                  index: _[0],
                  x: P[0],
                  y: P[1]
                },
                end: {
                  id: "end",
                  type: "vertex",
                  index: _[_.length - 1],
                  x: C[0],
                  y: C[1]
                },
                ...Object.fromEntries(S.points.slice(1, -1).map(([T, $], N) => {
                  const L = wn();
                  return [
                    L,
                    {
                      id: L,
                      type: "vertex",
                      index: _[N + 1],
                      x: T,
                      y: $
                    }
                  ];
                }))
              }
            }
          });
          break;
        }
        case "arrow": {
          let P = "";
          if (S.boundElements !== null) {
            for (const N of S.boundElements)
              if (N.type === "text") {
                const L = r.find((z) => z.id === N.id);
                L && (P = L.text);
              }
          }
          const C = S.points[0], _ = S.points[S.points.length - 1], T = c.get((_b3 = S.startBinding) == null ? void 0 : _b3.elementId), $ = c.get((_c3 = S.endBinding) == null ? void 0 : _c3.elementId);
          s.shapes.push({
            ...x,
            type: "arrow",
            props: {
              text: P,
              bend: QQe(S, C, _),
              dash: jw(S),
              size: Lw[S.strokeWidth] ?? "m",
              color: Hy[S.strokeColor] ?? "black",
              start: T ? {
                type: "binding",
                boundShapeId: T,
                normalizedAnchor: {
                  x: 0.5,
                  y: 0.5
                },
                isExact: false
              } : {
                type: "point",
                x: C[0],
                y: C[1]
              },
              end: $ ? {
                type: "binding",
                boundShapeId: $,
                normalizedAnchor: {
                  x: 0.5,
                  y: 0.5
                },
                isExact: false
              } : {
                type: "point",
                x: _[0],
                y: _[1]
              },
              arrowheadEnd: N7[S.endArrowhead] ?? "none",
              arrowheadStart: N7[S.startArrowhead] ?? "none"
            }
          });
          break;
        }
        case "text": {
          const { size: P, scale: C } = DQe(S.fontSize);
          s.shapes.push({
            ...x,
            type: "text",
            props: {
              size: P,
              scale: C,
              font: LQe[S.fontFamily] ?? "draw",
              color: Hy[S.strokeColor] ?? "black",
              text: S.text,
              align: j7[S.textAlign]
            }
          });
          break;
        }
        case "image": {
          const P = i[S.fileId];
          if (!P)
            break;
          const C = Mh.createId();
          s.assets.push({
            id: C,
            typeName: "asset",
            type: "image",
            props: {
              w: S.width,
              h: S.height,
              name: S.id ?? "Untitled",
              isAnimated: false,
              mimeType: P.mimeType,
              src: P.dataURL
            },
            meta: {}
          }), s.shapes.push({
            ...x,
            type: "image",
            props: {
              w: S.width,
              h: S.height,
              assetId: C
            }
          });
        }
      }
      h = wc(h);
    }
    const f = n ?? (t.inputs.shiftKey ? t.inputs.currentPagePoint : void 0);
    t.mark("paste"), t.putContentOntoCurrentPage(s, {
      point: f,
      select: false,
      preserveIds: true
    });
    for (const S of o.values())
      if (S.length > 1) {
        t.groupShapes(S);
        const w = t.getShape(S[0]);
        (w == null ? void 0 : w.parentId) && Ro(w.parentId) && u.push(w.parentId);
      }
    for (const [S, w] of a)
      t.select(S), t.rotateShapesBy([
        S
      ], w);
    const y = Je(u.map((S) => t.getShape(S))), g = Te.Common(y.map((S) => t.getShapePageBounds(S))), O = t.viewportPageBounds.center;
    t.updateShapes(y.map((S) => {
      const w = {
        x: (S.x ?? 0) - (g.x + g.w / 2),
        y: (S.y ?? 0) - (g.y + g.h / 2)
      };
      return {
        id: S.id,
        type: S.type,
        x: O.x + w.x,
        y: O.y + w.y
      };
    })), t.setSelectedShapes(u);
  }
  const RQe = (t) => {
    const e = t / 100;
    return e < 0.2 ? 0.1 : e < 0.4 ? 0.25 : e < 0.6 ? 0.5 : e < 0.8 ? 0.75 : 1;
  }, Lw = {
    1: "s",
    2: "m",
    3: "l",
    4: "xl"
  }, MQe = {
    16: "s",
    20: "m",
    28: "l",
    36: "xl"
  };
  function DQe(t) {
    const e = MQe[t];
    return e ? {
      size: e,
      scale: 1
    } : t < 16 ? {
      size: "s",
      scale: t / 16
    } : t > 36 ? {
      size: "xl",
      scale: t / 36
    } : {
      size: "m",
      scale: 1
    };
  }
  const LQe = {
    1: "draw",
    2: "sans",
    3: "mono"
  }, Hy = {
    "#ffffff": "grey",
    "#000000": "black",
    "#343a40": "black",
    "#495057": "grey",
    "#c92a2a": "red",
    "#a61e4d": "light-red",
    "#862e9c": "violet",
    "#5f3dc4": "light-violet",
    "#364fc7": "blue",
    "#1864ab": "light-blue",
    "#0b7285": "light-green",
    "#087f5b": "light-green",
    "#2b8a3e": "green",
    "#5c940d": "light-green",
    "#e67700": "yellow",
    "#d9480f": "orange",
    "#ced4da": "grey",
    "#868e96": "grey",
    "#fa5252": "light-red",
    "#e64980": "red",
    "#be4bdb": "light-violet",
    "#7950f2": "violet",
    "#4c6ef5": "blue",
    "#228be6": "light-blue",
    "#15aabf": "light-green",
    "#12b886": "green",
    "#40c057": "green",
    "#82c91e": "light-green",
    "#fab005": "yellow",
    "#fd7e14": "orange",
    "#212529": "grey"
  }, jQe = {
    solid: "draw",
    dashed: "dashed",
    dotted: "dotted"
  }, NQe = {
    "cross-hatch": "pattern",
    hachure: "pattern",
    solid: "solid"
  }, j7 = {
    left: "start",
    center: "middle",
    right: "end"
  }, N7 = {
    arrow: "arrow",
    dot: "dot",
    triangle: "triangle",
    bar: "pipe"
  };
  function QQe(t, e, n) {
    let r = 0;
    if (t.points.length > 2) {
      const i = new I(e[0], e[1]), s = new I(n[0], n[1]), o = new I(t.points[1][0], t.points[1][1]), a = I.Sub(s, i), l = I.Per(a), c = I.Med(s, i), u = I.Sub(c, l), d = I.Add(c, l), h = I.NearestPointOnLineSegment(u, d, o, false);
      r = I.Dist(h, c), I.Clockwise(h, s, c) && (r *= -1);
    }
    return r;
  }
  const jw = (t) => {
    let e = jQe[t.strokeStyle] ?? "draw";
    return e === "draw" && t.roughness === 0 && (e = "solid"), e;
  }, zQe = (t) => t.backgroundColor === "transparent" ? "none" : NQe[t.fillStyle] ?? "solid";
  async function Wee(t, e, n, r) {
    const s = (await Promise.all(e.map(async (o) => await (await fetch(o)).blob()))).map((o) => new File([
      o
    ], "tldrawFile", {
      type: o.type
    }));
    t.mark("paste"), await t.putExternalContent({
      type: "files",
      files: s,
      point: n,
      ignoreParent: false,
      sources: r
    }), e.forEach((o) => URL.revokeObjectURL(o));
  }
  function FQe(t, e, n) {
    const r = n ?? (t.inputs.shiftKey ? t.inputs.currentPagePoint : void 0);
    t.mark("paste"), t.putContentOntoCurrentPage(e, {
      point: r,
      select: true
    });
  }
  async function NR(t, e, n, r) {
    var _a3;
    try {
      if ((_a3 = (await fetch(e)).headers.get("content-type")) == null ? void 0 : _a3.match(/^image\//)) {
        t.mark("paste"), Wee(t, [
          e
        ]);
        return;
      }
    } catch (i) {
      i.message !== "Failed to fetch" && console.error(i);
    }
    return t.mark("paste"), await t.putExternalContent({
      type: "url",
      point: n,
      url: e,
      sources: r
    });
  }
  function BQe(t) {
    const e = document.implementation.createHTMLDocument("");
    return e.documentElement.innerHTML = t.trim(), e.body.textContent || e.body.innerText || "";
  }
  const UQe = (t) => {
    try {
      const e = new URL(t);
      return e.protocol === "http:" || e.protocol === "https:";
    } catch {
      return false;
    }
  }, VQe = (t) => {
    const e = t.split(/[\n\s]/);
    for (const n of e)
      try {
        const r = new URL(n);
        if (!(r.protocol === "http:" || r.protocol === "https:"))
          return;
      } catch {
        return;
      }
    return jG(e);
  }, XQe = (t) => /^<svg/.test(t), WQe = [
    "input",
    "select",
    "textarea"
  ];
  function tb(t) {
    const { activeElement: e } = document;
    return t.isMenuOpen || e && (e.getAttribute("contenteditable") || WQe.indexOf(e.tagName.toLowerCase()) > -1);
  }
  async function OI(t) {
    return new Promise((e, n) => {
      const r = new FileReader();
      r.addEventListener("loadend", () => {
        const i = r.result;
        e(i);
      }), r.addEventListener("error", () => {
        n(r.error);
      }), r.readAsText(t);
    });
  }
  const ZQe = (t) => t.types.find((e) => e.match(/^image\//)), SI = (t, e, n, r) => {
    const i = VQe(e);
    if (i)
      for (const s of i)
        NR(t, s, n);
    else
      UQe(e) ? NR(t, e, n) : XQe(e) ? (t.mark("paste"), t.putExternalContent({
        type: "svg-text",
        text: e,
        point: n,
        sources: r
      })) : (t.mark("paste"), t.putExternalContent({
        type: "text",
        text: e,
        point: n,
        sources: r
      }));
  }, HQe = async (t, e, n) => {
    if (t.editingShapeId !== null)
      return;
    if (!e)
      throw Error("No clipboard data");
    const r = [];
    for (const i of Object.values(e.items))
      switch (i.kind) {
        case "file": {
          r.push({
            type: "file",
            source: new Promise((s) => s(i.getAsFile()))
          });
          break;
        }
        case "string": {
          i.type === "text/html" ? r.push({
            type: "html",
            source: new Promise((s) => i.getAsString(s))
          }) : i.type === "text/plain" ? r.push({
            type: "text",
            source: new Promise((s) => i.getAsString(s))
          }) : r.push({
            type: i.type,
            source: new Promise((s) => i.getAsString(s))
          });
          break;
        }
      }
    Hee(t, r, n);
  }, Zee = async (t, e, n) => {
    const r = [];
    for (const i of e) {
      if (ZQe(i))
        for (const s of i.types)
          s.match(/^image\//) && r.push({
            type: "blob",
            source: i.getType(s)
          });
      i.types.includes("text/html") && r.push({
        type: "html",
        source: new Promise((s) => i.getType("text/html").then((o) => OI(o).then(s)))
      }), i.types.includes("text/uri-list") && r.push({
        type: "url",
        source: new Promise((s) => i.getType("text/uri-list").then((o) => OI(o).then(s)))
      }), i.types.includes("text/plain") && r.push({
        type: "text",
        source: new Promise((s) => i.getType("text/plain").then((o) => OI(o).then(s)))
      });
    }
    return await Hee(t, r, n);
  };
  async function Hee(t, e, n) {
    const r = e.filter((s) => (s.type === "file" || s.type === "blob") && s.source !== null);
    if (r.length) {
      const o = (await Promise.all(r.map((a) => a.source))).filter(Boolean).map((a) => URL.createObjectURL(a));
      return await Wee(t, o, n);
    }
    const i = await Promise.all(e.filter((s) => s.type !== "file").map((s) => new Promise((o) => {
      const a = s;
      if (a.type === "file") {
        o({
          type: "error",
          data: null,
          reason: "unexpected file"
        });
        return;
      }
      a.source.then((l) => {
        var _a3;
        const c = (_a3 = l.match(/<tldraw[^>]*>(.*)<\/tldraw>/)) == null ? void 0 : _a3[1];
        if (c)
          try {
            const u = Xee.decompressFromBase64(c);
            if (u === null) {
              o({
                type: "error",
                data: u,
                reason: "found tldraw data comment but could not parse base64"
              });
              return;
            } else {
              const d = JSON.parse(u);
              if (d.type !== "application/tldraw" && o({
                type: "error",
                data: d,
                reason: `found tldraw data comment but JSON was of a different type: ${d.type}`
              }), typeof d.data == "string") {
                o({
                  type: "error",
                  data: d,
                  reason: "found tldraw json but data was a string instead of a TLClipboardModel object"
                });
                return;
              }
              o({
                type: "tldraw",
                data: d.data
              });
              return;
            }
          } catch {
            o({
              type: "error",
              data: c,
              reason: "found tldraw json but data was a string instead of a TLClipboardModel object"
            });
            return;
          }
        else {
          if (a.type === "html") {
            o({
              type: "text",
              data: l,
              subtype: "html"
            });
            return;
          }
          if (a.type === "url") {
            o({
              type: "text",
              data: l,
              subtype: "url"
            });
            return;
          }
          try {
            const u = JSON.parse(l);
            if (u.type === "excalidraw/clipboard") {
              o({
                type: "excalidraw",
                data: u
              });
              return;
            } else {
              o({
                type: "text",
                data: l,
                subtype: "json"
              });
              return;
            }
          } catch {
            o({
              type: "text",
              data: l,
              subtype: "text"
            });
            return;
          }
        }
        o({
          type: "error",
          data: l,
          reason: "unhandled case"
        });
      });
    })));
    for (const s of i)
      if (s.type === "tldraw") {
        FQe(t, s.data, n);
        return;
      }
    for (const s of i)
      if (s.type === "excalidraw") {
        AQe(t, s.data, n);
        return;
      }
    for (const s of i)
      if (s.type === "text" && s.subtype === "html") {
        const a = new DOMParser().parseFromString(s.data, "text/html").querySelector("body");
        if (a && Array.from(a.children).filter((c) => c.nodeType === 1).length === 1 && a.firstElementChild && a.firstElementChild.tagName === "A" && a.firstElementChild.hasAttribute("href") && a.firstElementChild.getAttribute("href") !== "") {
          const c = a.firstElementChild.getAttribute("href");
          SI(t, c, n, i);
          return;
        }
        if (!i.some((c) => c.type === "text" && c.subtype !== "html") && s.data.trim()) {
          SI(t, BQe(s.data), n, i);
          return;
        }
      }
    for (const s of i)
      if (s.type === "text" && s.subtype === "url") {
        NR(t, s.data, n, i);
        return;
      }
    for (const s of i)
      if (s.type === "text" && s.subtype === "text" && s.data.trim()) {
        SI(t, s.data, n, i);
        return;
      }
  }
  const Hk = (t) => {
    var _a3;
    const e = t.getContentFromCurrentPage(t.selectedShapeIds);
    if (!e) {
      navigator && navigator.clipboard && navigator.clipboard.writeText("");
      return;
    }
    const n = Xee.compressToBase64(JSON.stringify({
      type: "application/tldraw",
      kind: "content",
      data: e
    }));
    if (!(typeof navigator > "u")) {
      const r = e.shapes.map((i) => t.isShapeOfType(i, "text") || t.isShapeOfType(i, "geo") || t.isShapeOfType(i, "arrow") ? i.props.text : t.isShapeOfType(i, "bookmark") || t.isShapeOfType(i, "embed") ? i.props.url : null).filter(lxe);
      if ((_a3 = navigator.clipboard) == null ? void 0 : _a3.write) {
        const i = new Blob([
          `<tldraw>${n}</tldraw>`
        ], {
          type: "text/html"
        });
        let s = r.join(" ");
        s === "" && (s = " "), navigator.clipboard.write([
          new ClipboardItem({
            "text/html": i,
            "text/plain": new Blob([
              s
            ], {
              type: "text/plain"
            })
          })
        ]);
      } else
        navigator.clipboard.writeText && navigator.clipboard.writeText(`<tldraw>${n}</tldraw>`);
    }
  };
  function YQe() {
    const t = ue(), e = Mm(), n = b.useCallback(function(o) {
      t.selectedShapeIds.length !== 0 && (Hk(t), e("copy", {
        source: o
      }));
    }, [
      t,
      e
    ]), r = b.useCallback(function(o) {
      t.selectedShapeIds.length !== 0 && (Hk(t), t.deleteShapes(t.selectedShapeIds), e("cut", {
        source: o
      }));
    }, [
      t,
      e
    ]), i = b.useCallback(async function(o, a, l) {
      t.editingShapeId !== null || tb(t) || (Array.isArray(o) && o[0] instanceof ClipboardItem ? (Zee(t, o, l), e("paste", {
        source: "menu"
      })) : navigator.clipboard.read().then((c) => {
        i(c, a, l);
      }));
    }, [
      t,
      e
    ]);
    return {
      copy: n,
      cut: r,
      paste: i
    };
  }
  function GQe() {
    const t = ue(), e = Mm(), n = ye("editor.isFocused", () => t.instanceState.isFocused, [
      t
    ]);
    b.useEffect(() => {
      if (!n)
        return;
      const r = () => {
        t.selectedShapeIds.length === 0 || t.editingShapeId !== null || tb(t) || (Hk(t), e("copy", {
          source: "kbd"
        }));
      };
      function i() {
        t.selectedShapeIds.length === 0 || t.editingShapeId !== null || tb(t) || (Hk(t), t.deleteShapes(t.selectedShapeIds), e("cut", {
          source: "kbd"
        }));
      }
      let s = false;
      const o = (l) => {
        l.button === 1 && (s = true, requestAnimationFrame(() => {
          s = false;
        }));
      }, a = (l) => {
        if (s) {
          l.stopPropagation();
          return;
        }
        t.editingShapeId !== null || tb(t) || (l.clipboardData && !t.inputs.shiftKey ? HQe(t, l.clipboardData) : navigator.clipboard.read().then((c) => {
          Array.isArray(c) && c[0] instanceof ClipboardItem && Zee(t, c, t.inputs.currentPagePoint);
        }), e("paste", {
          source: "kbd"
        }));
      };
      return document.addEventListener("copy", r), document.addEventListener("cut", i), document.addEventListener("paste", a), document.addEventListener("pointerup", o), () => {
        document.removeEventListener("copy", r), document.removeEventListener("cut", i), document.removeEventListener("paste", a), document.removeEventListener("pointerup", o);
      };
    }, [
      t,
      e,
      n
    ]);
  }
  function Yee(t) {
    const e = t.cloneNode(true);
    return t.setAttribute("width", +t.getAttribute("width") + ""), t.setAttribute("height", +t.getAttribute("height") + ""), new XMLSerializer().serializeToString(e).replaceAll("&#10;      ", "").replaceAll(/((\s|")[0-9]*\.[0-9]{2})([0-9]*)(\b|"|\))/g, "$1");
  }
  async function Gee(t, e) {
    const { type: n, quality: r, scale: i } = e, s = +t.getAttribute("width"), o = +t.getAttribute("height");
    let a = s * i, l = o * i;
    const c = await qee(t), u = await iee();
    if (s > u.maxWidth && (a = u.maxWidth, l = a / s * o), o > u.maxHeight && (l = u.maxHeight, a = l / o * s), a * l > u.maxArea) {
      const g = Math.sqrt(u.maxArea / (a * l));
      a *= g, l *= g;
    }
    a = Math.floor(a), l = Math.floor(l);
    const d = a / s, h = await new Promise((g) => {
      const O = new Image();
      O.crossOrigin = "anonymous", O.onload = async () => {
        await new Promise((x) => setTimeout(x, 250));
        const S = document.createElement("canvas"), w = S.getContext("2d");
        S.width = a, S.height = l, w.imageSmoothingEnabled = true, w.imageSmoothingQuality = "high", w.drawImage(O, 0, 0, a, l), URL.revokeObjectURL(c), g(S);
      }, O.onerror = () => {
        g(null);
      }, O.src = c;
    });
    if (!h)
      return null;
    const f = await new Promise((g) => h.toBlob((O) => {
      (!O || un.throwToBlob.value) && g(null), g(O);
    }, "image/" + n, r));
    if (!f)
      return null;
    const y = new DataView(await f.arrayBuffer());
    return bl.setPhysChunk(y, d, {
      type: "image/" + n
    });
  }
  async function qee(t) {
    const e = t.cloneNode(true);
    e.setAttribute("encoding", 'UTF-8"');
    const n = new FileReader(), r = Array.from(e.querySelectorAll("image"));
    for (const i of r) {
      const s = i.getAttribute("xlink:href");
      if (s && !s.startsWith("data:")) {
        const o = await (await fetch(s)).blob(), a = await new Promise((l, c) => {
          n.onload = () => l(n.result), n.onerror = () => c(n.error), n.readAsDataURL(o);
        });
        i.setAttribute("xlink:href", a);
      }
    }
    return qQe(e);
  }
  function qQe(t) {
    const e = new XMLSerializer().serializeToString(t);
    return `data:image/svg+xml;base64,${window.btoa(unescape(encodeURIComponent(e)))}`;
  }
  function wI(t, e) {
    const n = document.createElement("a");
    n.href = t, n.download = e, n.click();
  }
  const Kee = b.createContext({});
  function KQe({ children: t }) {
    const [e, n] = b.useState([]), r = b.useCallback((o) => {
      const a = o.id ?? wn();
      return n((l) => [
        ...l.filter((c) => c.id !== o.id),
        {
          ...o,
          id: a
        }
      ]), a;
    }, []), i = b.useCallback((o) => (n((a) => a.filter((l) => l.id !== o)), o), []), s = b.useCallback(() => {
      n(() => []);
    }, []);
    return m.jsx(Kee.Provider, {
      value: {
        toasts: e,
        addToast: r,
        removeToast: i,
        clearToasts: s
      },
      children: t
    });
  }
  function Hl() {
    const t = b.useContext(Kee);
    if (!t)
      throw new Error("useToasts must be used within a ToastsProvider");
    return t;
  }
  function JQe() {
    const t = ue(), { addToast: e } = Hl(), n = Tt();
    return b.useCallback(function(i = t.selectedShapeIds, s = "svg") {
      if (i.length === 0 && (i = [
        ...t.currentPageShapeIds
      ]), i.length !== 0)
        switch (s) {
          case "svg": {
            window.navigator.clipboard && (window.navigator.clipboard.write ? window.navigator.clipboard.write([
              new ClipboardItem({
                "text/plain": e6e(t, i)
              })
            ]) : Q7(async () => Yee(await NL(t, i))));
            break;
          }
          case "jpeg":
          case "png": {
            const o = s === "jpeg" ? "image/jpeg" : "image/png", a = t6e(t, i, s).then((l) => {
              if (l) {
                if (window.navigator.clipboard)
                  return l;
                throw new Error("Copy not supported");
              } else
                throw e({
                  id: "copy-fail",
                  icon: "warning-triangle",
                  title: n("toast.error.copy-fail.title"),
                  description: n("toast.error.copy-fail.desc")
                }), new Error("Copy not possible");
            });
            window.navigator.clipboard.write([
              new ClipboardItem({
                [o]: a
              })
            ]).catch((l) => {
              l.toString().match(/^TypeError: DOMString not supported/) || console.error(l), a.then((c) => {
                window.navigator.clipboard.write([
                  new ClipboardItem({
                    [o]: c
                  })
                ]);
              });
            });
            break;
          }
          case "json": {
            const o = t.getContentFromCurrentPage(i);
            if (window.navigator.clipboard) {
              const a = JSON.stringify(o);
              window.navigator.clipboard.write ? window.navigator.clipboard.write([
                new ClipboardItem({
                  "text/plain": new Blob([
                    a
                  ], {
                    type: "text/plain"
                  })
                })
              ]) : Q7(async () => a);
            }
            break;
          }
          default:
            throw new Error(`Copy type ${s} not supported.`);
        }
    }, [
      t,
      e,
      n
    ]);
  }
  async function NL(t, e) {
    const n = await t.getSvg(e, {
      scale: 1,
      background: t.instanceState.exportBackground
    });
    if (!n)
      throw new Error("Could not construct SVG.");
    return n;
  }
  async function e6e(t, e) {
    return new Blob([
      Yee(await NL(t, e))
    ], {
      type: "text/plain"
    });
  }
  async function t6e(t, e, n) {
    return await Gee(await NL(t, e), {
      type: n,
      quality: 1,
      scale: 2
    });
  }
  async function Q7(t) {
    navigator && navigator.clipboard && navigator.clipboard.writeText(await t());
  }
  const Jee = b.createContext({});
  function n6e({ children: t }) {
    const e = ue(), n = Mm(), [r, i] = b.useState([]), s = b.useCallback((c) => {
      const u = c.id ?? wn();
      return i((d) => [
        ...d.filter((h) => h.id !== c.id),
        {
          ...c,
          id: u
        }
      ]), n("open-menu", {
        source: "dialog",
        id: u
      }), e.addOpenMenu(u), u;
    }, [
      e,
      n
    ]), o = b.useCallback((c, u) => (i((d) => d.map((h) => h.id === c ? {
      ...h,
      ...u
    } : h)), n("open-menu", {
      source: "dialog",
      id: c
    }), e.addOpenMenu(c), c), [
      e,
      n
    ]), a = b.useCallback((c) => (i((u) => u.filter((d) => {
      var _a3;
      return d.id === c ? ((_a3 = d.onClose) == null ? void 0 : _a3.call(d), false) : true;
    })), n("close-menu", {
      source: "dialog",
      id: c
    }), e.deleteOpenMenu(c), c), [
      e,
      n
    ]), l = b.useCallback(() => {
      i((c) => (c.forEach((u) => {
        var _a3;
        (_a3 = u.onClose) == null ? void 0 : _a3.call(u), n("close-menu", {
          source: "dialog",
          id: u.id
        }), e.deleteOpenMenu(u.id);
      }), []));
    }, [
      e,
      n
    ]);
    return m.jsx(Jee.Provider, {
      value: {
        dialogs: r,
        addDialog: s,
        removeDialog: a,
        clearDialogs: l,
        updateDialog: o
      },
      children: t
    });
  }
  function Cf() {
    const t = b.useContext(Jee);
    if (!t)
      throw new Error("useDialogs must be used within a DialogsProvider");
    return t;
  }
  function r6e() {
    const t = ue(), { addToast: e } = Hl(), n = Tt();
    return b.useCallback(async function(i = t.selectedShapeIds, s = "png") {
      if (i.length === 0 && (i = [
        ...t.currentPageShapeIds
      ]), i.length === 0)
        return;
      const o = await t.getSvg(i, {
        scale: 1,
        background: t.instanceState.exportBackground
      });
      if (!o)
        throw new Error("Could not construct SVG.");
      let a = "shapes" + i6e();
      if (i.length === 1) {
        const l = t.getShape(i[0]);
        t.isShapeOfType(l, "frame") ? a = l.props.name ?? "frame" : a = l.id.replace(/:/, "_");
      }
      switch (s) {
        case "svg": {
          const l = await qee(o);
          wI(l, `${a}.svg`);
          return;
        }
        case "webp":
        case "png": {
          const l = await Gee(o, {
            type: s,
            quality: 1,
            scale: 2
          });
          if (!l) {
            e({
              id: "export-fail",
              title: n("toast.error.export-fail.title"),
              description: n("toast.error.export-fail.desc")
            });
            return;
          }
          const c = URL.createObjectURL(l);
          wI(c, `${a}.${s}`), URL.revokeObjectURL(c);
          return;
        }
        case "json": {
          const l = t.getContentFromCurrentPage(i), c = URL.createObjectURL(new Blob([
            JSON.stringify(l, null, 4)
          ], {
            type: "application/json"
          }));
          wI(c, `${a || "shapes"}.json`), URL.revokeObjectURL(c);
          return;
        }
        default:
          throw new Error(`Export type ${s} not supported.`);
      }
    }, [
      t,
      e,
      n
    ]);
  }
  function i6e() {
    const t = /* @__PURE__ */ new Date(), e = String(t.getFullYear()).slice(2), n = String(t.getMonth() + 1).padStart(2, "0"), r = String(t.getDate()).padStart(2, "0"), i = String(t.getHours()).padStart(2, "0"), s = String(t.getMinutes()).padStart(2, "0"), o = String(t.getSeconds()).padStart(2, "0");
    return ` at ${e}-${n}-${r} ${i}.${s}.${o}`;
  }
  function ete() {
    const t = ue(), e = b.useRef();
    return b.useEffect(() => {
      const n = window.document.createElement("input");
      n.type = "file", n.accept = "image/jpeg,image/png,image/gif,image/svg+xml,video/mp4,video/quicktime", n.multiple = true, e.current = n;
      async function r(i) {
        const s = i.target.files;
        !s || s.length === 0 || (await t.putExternalContent({
          type: "files",
          files: Array.from(s),
          point: t.viewportPageBounds.center,
          ignoreParent: false
        }), n.value = "");
      }
      return n.addEventListener("change", r), () => {
        e.current = void 0, n.removeEventListener("change", r);
      };
    }, [
      t
    ]), b.useCallback(() => {
      var _a3;
      (_a3 = e.current) == null ? void 0 : _a3.click();
    }, [
      e
    ]);
  }
  function s6e() {
    const t = ue(), e = b.useRef(null), n = b.useRef(null);
    return b.useCallback(async function() {
      const i = document.createElement("div"), s = document.createElement("style"), o = (S, w) => {
        S && (S.innerHTML = ""), w && document.head.contains(w) && document.head.removeChild(w), S && document.body.contains(S) && document.body.removeChild(S);
      };
      o(e.current, n.current), e.current = i, n.current = s;
      const a = `tl-print-surface-${wn()}`;
      i.className = a, s.innerHTML = `
			.${a} {
				display: none;
			}

			.${a} svg {
				max-width: 100%;
				height: 100%;
				display: block;
			}

			@media print {				  
				html, body {
					min-height: 100%;
					height: 100%;
					margin: 0;
				}

				body {
					position: relative;
				}

				body > * {
					display: none;
				}

				.${a} {
					display: block !important;
					background: white;
					min-height: 100%;
					height: 100%;
					max-width: 100%;
				}

				.${a}__item {
					padding: 10mm;
					display: flex;
					min-height: 100%;
					flex-direction: column;
					page-break-after: always;
					position: relative;
					overflow: hidden;
					height: 100%;
				}

				.${a}__item__main {
					flex: 1;
					display: flex;
					align-items: center;
					justify-content: center;
					max-height: 100%;
				}

				.${a}__item__header {
					display: none;
				}

				.${a}__item__footer {
					display: none;
					text-align: right;
				}

				.${a}__item__footer__hide {
					display: none;
				}

				
			}

		`;
      const l = () => {
        document.head.appendChild(s), document.body.appendChild(i);
      }, c = () => {
        t.once("change-history", () => {
          o(i, s);
        });
      };
      window.addEventListener("beforeprint", l), window.addEventListener("afterprint", c);
      function u(S, w, x) {
        try {
          i.innerHTML += `<div class="${a}__item">
        <div class="${a}__item__header">
          ${S.replace(/</g, "&lt;").replace(/>/g, "&gt;")}
        </div>
        <div class="${a}__item__main">
          ${x.outerHTML}
        </div>
        <div class="${a}__item__footer ${a}__item__footer__${w ? "" : "hide"}">
          ${w ?? ""}
        </div>
      </div>`;
        } catch (P) {
          console.error(P);
        }
      }
      function d() {
        t.environment.isChromeForIos ? (l(), window.print()) : t.environment.isSafari ? (l(), document.execCommand("print", false)) : window.print();
      }
      const { pages: h, currentPageId: f, selectedShapeIds: y } = t, O = {
        scale: 1,
        background: false,
        darkMode: false,
        preserveAspectRatio: "xMidYMid meet"
      };
      if (t.selectedShapeIds.length > 0) {
        const S = await t.getSvg(y, O);
        if (S) {
          const w = h.find((x) => x.id === f);
          u(`tldraw \u2014 ${w == null ? void 0 : w.name}`, null, S), d();
        }
      } else {
        const S = t.currentPage, w = await t.getSvg(t.getSortedChildIdsForParent(S.id), O);
        w && (u(`tldraw \u2014 ${S.name}`, null, w), d());
      }
      window.removeEventListener("beforeprint", l), window.removeEventListener("afterprint", c);
    }, [
      t
    ]);
  }
  const tte = b.createContext({});
  function o6e(t) {
    return Object.fromEntries(t.map((e) => [
      e.id,
      e
    ]));
  }
  function a6e({ overrides: t, children: e }) {
    const n = ue(), { addDialog: r, clearDialogs: i } = Cf(), { clearToasts: s } = Hl(), o = ete(), a = s6e(), { cut: l, copy: c, paste: u } = YQe(), d = JQe(), h = r6e(), f = Mm(), y = b.useMemo(() => {
      function g() {
        return n.isIn("select") || (n.complete(), n.setCurrentTool("select")), false;
      }
      function O() {
        return n.selectedShapeIds.length > 0;
      }
      const S = o6e([
        {
          id: "edit-link",
          label: "action.edit-link",
          icon: "link",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("edit-link", {
              source: w
            }), n.mark("edit-link"), r({
              component: IQe
            })));
          }
        },
        {
          id: "insert-embed",
          label: "action.insert-embed",
          readonlyOk: false,
          kbd: "$i",
          onSelect(w) {
            f("insert-embed", {
              source: w
            }), r({
              component: Vee
            });
          }
        },
        {
          id: "insert-media",
          label: "action.insert-media",
          kbd: "$u",
          readonlyOk: false,
          onSelect(w) {
            f("insert-media", {
              source: w
            }), o();
          }
        },
        {
          id: "undo",
          label: "action.undo",
          icon: "undo",
          kbd: "$z",
          readonlyOk: false,
          onSelect(w) {
            f("undo", {
              source: w
            }), n.undo();
          }
        },
        {
          id: "redo",
          label: "action.redo",
          icon: "redo",
          kbd: "$!z",
          readonlyOk: false,
          onSelect(w) {
            f("redo", {
              source: w
            }), n.redo();
          }
        },
        {
          id: "export-as-svg",
          label: "action.export-as-svg",
          menuLabel: "action.export-as-svg.short",
          contextMenuLabel: "action.export-as-svg.short",
          readonlyOk: true,
          onSelect(w) {
            f("export-as", {
              format: "svg",
              source: w
            }), h(n.selectedShapeIds, "svg");
          }
        },
        {
          id: "export-as-png",
          label: "action.export-as-png",
          menuLabel: "action.export-as-png.short",
          contextMenuLabel: "action.export-as-png.short",
          readonlyOk: true,
          onSelect(w) {
            f("export-as", {
              format: "png",
              source: w
            }), h(n.selectedShapeIds, "png");
          }
        },
        {
          id: "export-as-json",
          label: "action.export-as-json",
          menuLabel: "action.export-as-json.short",
          contextMenuLabel: "action.export-as-json.short",
          readonlyOk: true,
          onSelect(w) {
            f("export-as", {
              format: "json",
              source: w
            }), h(n.selectedShapeIds, "json");
          }
        },
        {
          id: "copy-as-svg",
          label: "action.copy-as-svg",
          menuLabel: "action.copy-as-svg.short",
          contextMenuLabel: "action.copy-as-svg.short",
          kbd: "$!c",
          readonlyOk: true,
          onSelect(w) {
            f("copy-as", {
              format: "svg",
              source: w
            }), d(n.selectedShapeIds, "svg");
          }
        },
        {
          id: "copy-as-png",
          label: "action.copy-as-png",
          menuLabel: "action.copy-as-png.short",
          contextMenuLabel: "action.copy-as-png.short",
          readonlyOk: true,
          onSelect(w) {
            f("copy-as", {
              format: "png",
              source: w
            }), d(n.selectedShapeIds, "png");
          }
        },
        {
          id: "copy-as-json",
          label: "action.copy-as-json",
          menuLabel: "action.copy-as-json.short",
          contextMenuLabel: "action.copy-as-json.short",
          readonlyOk: true,
          onSelect(w) {
            f("copy-as", {
              format: "json",
              source: w
            }), d(n.selectedShapeIds, "json");
          }
        },
        {
          id: "toggle-auto-size",
          label: "action.toggle-auto-size",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("toggle-auto-size", {
              source: w
            }), n.mark("toggling auto size"), n.updateShapes(n.selectedShapes.filter((x) => n.isShapeOfType(x, "text") && x.props.autoSize === false).map((x) => ({
              id: x.id,
              type: x.type,
              props: {
                ...x.props,
                w: 8,
                autoSize: true
              }
            })))));
          }
        },
        {
          id: "open-embed-link",
          label: "action.open-embed-link",
          readonlyOk: true,
          onSelect(w) {
            f("open-embed-link", {
              source: w
            });
            const x = n.selectedShapeIds, P = "No embed shapes selected";
            if (x.length !== 1) {
              console.error(P);
              return;
            }
            const C = n.getShape(x[0]);
            if (!C || !n.isShapeOfType(C, "embed")) {
              console.error(P);
              return;
            }
            vEe(C.props.url, "_blank");
          }
        },
        {
          id: "select-zoom-tool",
          readonlyOk: true,
          kbd: "z",
          onSelect(w) {
            var _a3, _b3;
            if (((_a3 = n.root.current.value) == null ? void 0 : _a3.id) !== "zoom" && (f("zoom-tool", {
              source: w
            }), !(n.inputs.shiftKey || n.inputs.ctrlKey))) {
              const x = n.root.current.value;
              x && ((_b3 = x.current.value) == null ? void 0 : _b3.id) === "idle" && n.setCurrentTool("zoom", {
                onInteractionEnd: x.id,
                maskAs: "zoom"
              });
            }
          }
        },
        {
          id: "convert-to-bookmark",
          label: "action.convert-to-bookmark",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || n.batch(() => {
              f("convert-to-bookmark", {
                source: w
              });
              const x = n.selectedShapes, P = [], C = [];
              for (const _ of x) {
                if (!_ || !n.isShapeOfType(_, "embed") || !_.props.url)
                  continue;
                const T = new I(_.x, _.y);
                T.rot(-_.rotation), T.add(new I(_.props.w / 2 - 300 / 2, _.props.h / 2 - 320 / 2)), T.rot(_.rotation);
                const $ = {
                  id: bn(),
                  type: "bookmark",
                  rotation: _.rotation,
                  x: T.x,
                  y: T.y,
                  opacity: 1,
                  props: {
                    url: _.props.url
                  }
                };
                P.push($), C.push(_.id);
              }
              n.mark("convert shapes to bookmark"), n.deleteShapes(C), n.createShapes(P);
            }));
          }
        },
        {
          id: "convert-to-embed",
          label: "action.convert-to-embed",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("convert-to-embed", {
              source: w
            }), n.batch(() => {
              const x = n.selectedShapeIds, P = Je(x.map((T) => n.getShape(T))), C = [], _ = [];
              for (const T of P) {
                if (!n.isShapeOfType(T, "bookmark"))
                  continue;
                const { url: $ } = T.props, N = Cc(T.props.url);
                if (!N || !N.definition)
                  continue;
                const { width: L, height: z } = N.definition, M = new I(T.x, T.y);
                M.rot(-T.rotation), M.add(new I(T.props.w / 2 - L / 2, T.props.h / 2 - z / 2)), M.rot(T.rotation);
                const R = {
                  id: bn(),
                  type: "embed",
                  x: M.x,
                  y: M.y,
                  rotation: T.rotation,
                  props: {
                    url: $,
                    w: L,
                    h: z
                  }
                };
                C.push(R), _.push(T.id);
              }
              n.mark("convert shapes to embed"), n.deleteShapes(_), n.createShapes(C);
            })));
          }
        },
        {
          id: "duplicate",
          kbd: "$d",
          label: "action.duplicate",
          icon: "duplicate",
          readonlyOk: false,
          onSelect(w) {
            if (!O() || g())
              return;
            f("duplicate-shapes", {
              source: w
            });
            const x = n.selectedShapeIds, P = Te.Common(Je(x.map((_) => n.getShapePageBounds(_)))), C = n.instanceState.canMoveCamera ? {
              x: P.width + 10,
              y: 0
            } : {
              x: 16 / n.zoomLevel,
              y: 16 / n.zoomLevel
            };
            n.mark("duplicate shapes"), n.duplicateShapes(x, C);
          }
        },
        {
          id: "ungroup",
          label: "action.ungroup",
          kbd: "$!g",
          icon: "ungroup",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("ungroup-shapes", {
              source: w
            }), n.mark("ungroup"), n.ungroupShapes(n.selectedShapeIds)));
          }
        },
        {
          id: "group",
          label: "action.group",
          kbd: "$g",
          icon: "group",
          readonlyOk: false,
          onSelect(w) {
            if (!O() || g())
              return;
            f("group-shapes", {
              source: w
            });
            const { onlySelectedShape: x } = n;
            x && n.isShapeOfType(x, "group") ? (n.mark("ungroup"), n.ungroupShapes(n.selectedShapeIds)) : (n.mark("group"), n.groupShapes(n.selectedShapeIds));
          }
        },
        {
          id: "align-left",
          label: "action.align-left",
          kbd: "?A",
          icon: "align-left",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("align-shapes", {
              operation: "left",
              source: w
            }), n.mark("align left"), n.alignShapes(n.selectedShapeIds, "left")));
          }
        },
        {
          id: "align-center-horizontal",
          label: "action.align-center-horizontal",
          contextMenuLabel: "action.align-center-horizontal.short",
          kbd: "?H",
          icon: "align-center-horizontal",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("align-shapes", {
              operation: "center-horizontal",
              source: w
            }), n.mark("align center horizontal"), n.alignShapes(n.selectedShapeIds, "center-horizontal")));
          }
        },
        {
          id: "align-right",
          label: "action.align-right",
          kbd: "?D",
          icon: "align-right",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("align-shapes", {
              operation: "right",
              source: w
            }), n.mark("align right"), n.alignShapes(n.selectedShapeIds, "right")));
          }
        },
        {
          id: "align-center-vertical",
          label: "action.align-center-vertical",
          contextMenuLabel: "action.align-center-vertical.short",
          kbd: "?V",
          icon: "align-center-vertical",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("align-shapes", {
              operation: "center-vertical",
              source: w
            }), n.mark("align center vertical"), n.alignShapes(n.selectedShapeIds, "center-vertical")));
          }
        },
        {
          id: "align-top",
          label: "action.align-top",
          icon: "align-top",
          kbd: "?W",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("align-shapes", {
              operation: "top",
              source: w
            }), n.mark("align top"), n.alignShapes(n.selectedShapeIds, "top")));
          }
        },
        {
          id: "align-bottom",
          label: "action.align-bottom",
          icon: "align-bottom",
          kbd: "?S",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("align-shapes", {
              operation: "bottom",
              source: w
            }), n.mark("align bottom"), n.alignShapes(n.selectedShapeIds, "bottom")));
          }
        },
        {
          id: "distribute-horizontal",
          label: "action.distribute-horizontal",
          contextMenuLabel: "action.distribute-horizontal.short",
          icon: "distribute-horizontal",
          kbd: "?!h",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("distribute-shapes", {
              operation: "horizontal",
              source: w
            }), n.mark("distribute horizontal"), n.distributeShapes(n.selectedShapeIds, "horizontal")));
          }
        },
        {
          id: "distribute-vertical",
          label: "action.distribute-vertical",
          contextMenuLabel: "action.distribute-vertical.short",
          icon: "distribute-vertical",
          kbd: "?!V",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("distribute-shapes", {
              operation: "vertical",
              source: w
            }), n.mark("distribute vertical"), n.distributeShapes(n.selectedShapeIds, "vertical")));
          }
        },
        {
          id: "stretch-horizontal",
          label: "action.stretch-horizontal",
          contextMenuLabel: "action.stretch-horizontal.short",
          icon: "stretch-horizontal",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("stretch-shapes", {
              operation: "horizontal",
              source: w
            }), n.mark("stretch horizontal"), n.stretchShapes(n.selectedShapeIds, "horizontal")));
          }
        },
        {
          id: "stretch-vertical",
          label: "action.stretch-vertical",
          contextMenuLabel: "action.stretch-vertical.short",
          icon: "stretch-vertical",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("stretch-shapes", {
              operation: "vertical",
              source: w
            }), n.mark("stretch vertical"), n.stretchShapes(n.selectedShapeIds, "vertical")));
          }
        },
        {
          id: "flip-horizontal",
          label: "action.flip-horizontal",
          contextMenuLabel: "action.flip-horizontal.short",
          kbd: "!h",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("flip-shapes", {
              operation: "horizontal",
              source: w
            }), n.mark("flip horizontal"), n.flipShapes(n.selectedShapeIds, "horizontal")));
          }
        },
        {
          id: "flip-vertical",
          label: "action.flip-vertical",
          contextMenuLabel: "action.flip-vertical.short",
          kbd: "!v",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("flip-shapes", {
              operation: "vertical",
              source: w
            }), n.mark("flip vertical"), n.flipShapes(n.selectedShapeIds, "vertical")));
          }
        },
        {
          id: "pack",
          label: "action.pack",
          icon: "pack",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("pack-shapes", {
              source: w
            }), n.mark("pack"), n.packShapes(n.selectedShapeIds, 16)));
          }
        },
        {
          id: "stack-vertical",
          label: "action.stack-vertical",
          contextMenuLabel: "action.stack-vertical.short",
          icon: "stack-vertical",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("stack-shapes", {
              operation: "vertical",
              source: w
            }), n.mark("stack-vertical"), n.stackShapes(n.selectedShapeIds, "vertical", 16)));
          }
        },
        {
          id: "stack-horizontal",
          label: "action.stack-horizontal",
          contextMenuLabel: "action.stack-horizontal.short",
          icon: "stack-horizontal",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("stack-shapes", {
              operation: "horizontal",
              source: w
            }), n.mark("stack-horizontal"), n.stackShapes(n.selectedShapeIds, "horizontal", 16)));
          }
        },
        {
          id: "bring-to-front",
          label: "action.bring-to-front",
          kbd: "]",
          icon: "bring-to-front",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("reorder-shapes", {
              operation: "toFront",
              source: w
            }), n.mark("bring to front"), n.bringToFront(n.selectedShapeIds)));
          }
        },
        {
          id: "bring-forward",
          label: "action.bring-forward",
          icon: "bring-forward",
          kbd: "?]",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("reorder-shapes", {
              operation: "forward",
              source: w
            }), n.mark("bring forward"), n.bringForward(n.selectedShapeIds)));
          }
        },
        {
          id: "send-backward",
          label: "action.send-backward",
          icon: "send-backward",
          kbd: "?[",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("reorder-shapes", {
              operation: "backward",
              source: w
            }), n.mark("send backward"), n.sendBackward(n.selectedShapeIds)));
          }
        },
        {
          id: "send-to-back",
          label: "action.send-to-back",
          icon: "send-to-back",
          kbd: "[",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("reorder-shapes", {
              operation: "toBack",
              source: w
            }), n.mark("send to back"), n.sendToBack(n.selectedShapeIds)));
          }
        },
        {
          id: "cut",
          label: "action.cut",
          kbd: "$x",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (n.mark("cut"), l(w)));
          }
        },
        {
          id: "copy",
          label: "action.copy",
          kbd: "$c",
          readonlyOk: true,
          onSelect(w) {
            O() && (g() || c(w));
          }
        },
        {
          id: "paste",
          label: "action.paste",
          kbd: "$v",
          readonlyOk: false,
          onSelect(w) {
            var _a3;
            (_a3 = navigator.clipboard) == null ? void 0 : _a3.read().then((x) => {
              u(x, w, w === "context-menu" ? n.inputs.currentPagePoint : void 0);
            });
          }
        },
        {
          id: "select-all",
          label: "action.select-all",
          kbd: "$a",
          readonlyOk: true,
          onSelect(w) {
            n.batch(() => {
              g() || (f("select-all-shapes", {
                source: w
              }), n.mark("select all kbd"), n.selectAll());
            });
          }
        },
        {
          id: "select-none",
          label: "action.select-none",
          readonlyOk: true,
          onSelect(w) {
            O() && (g() || (f("select-none-shapes", {
              source: w
            }), n.mark("select none"), n.selectNone()));
          }
        },
        {
          id: "delete",
          label: "action.delete",
          kbd: "\u232B,del,backspace",
          icon: "trash",
          readonlyOk: false,
          onSelect(w) {
            O() && (g() || (f("delete-shapes", {
              source: w
            }), n.mark("delete"), n.deleteShapes(n.selectedShapeIds)));
          }
        },
        {
          id: "rotate-cw",
          label: "action.rotate-cw",
          icon: "rotate-cw",
          readonlyOk: false,
          onSelect(w) {
            if (!O() || g())
              return;
            f("rotate-cw", {
              source: w
            }), n.mark("rotate-cw");
            const x = n.selectionRotation % (Ft / 2), P = Y0(x, 0) || Y0(x, Ft / 2);
            n.rotateShapesBy(n.selectedShapeIds, Ft / 2 - (P ? 0 : x));
          }
        },
        {
          id: "rotate-ccw",
          label: "action.rotate-ccw",
          icon: "rotate-ccw",
          readonlyOk: false,
          onSelect(w) {
            if (!O() || g())
              return;
            f("rotate-ccw", {
              source: w
            }), n.mark("rotate-ccw");
            const x = n.selectionRotation % (Ft / 2), P = Y0(x, 0);
            n.rotateShapesBy(n.selectedShapeIds, P ? -(Ft / 2) : -x);
          }
        },
        {
          id: "zoom-in",
          label: "action.zoom-in",
          kbd: "$=,=",
          readonlyOk: true,
          onSelect(w) {
            f("zoom-in", {
              source: w
            }), n.zoomIn(n.viewportScreenCenter, {
              duration: Pc
            });
          }
        },
        {
          id: "zoom-out",
          label: "action.zoom-out",
          kbd: "$-,-",
          readonlyOk: true,
          onSelect(w) {
            f("zoom-out", {
              source: w
            }), n.zoomOut(n.viewportScreenCenter, {
              duration: Pc
            });
          }
        },
        {
          id: "zoom-to-100",
          label: "action.zoom-to-100",
          icon: "reset-zoom",
          kbd: "!0",
          readonlyOk: true,
          onSelect(w) {
            f("reset-zoom", {
              source: w
            }), n.resetZoom(n.viewportScreenCenter, {
              duration: Pc
            });
          }
        },
        {
          id: "zoom-to-fit",
          label: "action.zoom-to-fit",
          kbd: "!1",
          readonlyOk: true,
          onSelect(w) {
            f("zoom-to-fit", {
              source: w
            }), n.zoomToFit({
              duration: Pc
            });
          }
        },
        {
          id: "zoom-to-selection",
          label: "action.zoom-to-selection",
          kbd: "!2",
          readonlyOk: true,
          onSelect(w) {
            O() && (g() || (f("zoom-to-selection", {
              source: w
            }), n.zoomToSelection({
              duration: Pc
            })));
          }
        },
        {
          id: "toggle-snap-mode",
          label: "action.toggle-snap-mode",
          menuLabel: "action.toggle-snap-mode.menu",
          readonlyOk: false,
          onSelect(w) {
            f("toggle-snap-mode", {
              source: w
            }), n.user.updateUserPreferences({
              isSnapMode: !n.user.isSnapMode
            });
          },
          checkbox: true
        },
        {
          id: "toggle-dark-mode",
          label: "action.toggle-dark-mode",
          menuLabel: "action.toggle-dark-mode.menu",
          kbd: "$/",
          readonlyOk: true,
          onSelect(w) {
            f("toggle-dark-mode", {
              source: w
            }), n.user.updateUserPreferences({
              isDarkMode: !n.user.isDarkMode
            });
          },
          checkbox: true
        },
        {
          id: "toggle-reduce-motion",
          label: "action.toggle-reduce-motion",
          menuLabel: "action.toggle-reduce-motion.menu",
          readonlyOk: true,
          onSelect(w) {
            f("toggle-reduce-motion", {
              source: w
            }), n.user.updateUserPreferences({
              animationSpeed: n.user.animationSpeed === 0 ? 1 : 0
            });
          },
          checkbox: true
        },
        {
          id: "toggle-transparent",
          label: "action.toggle-transparent",
          menuLabel: "action.toggle-transparent.menu",
          contextMenuLabel: "action.toggle-transparent.context-menu",
          readonlyOk: true,
          onSelect(w) {
            f("toggle-transparent", {
              source: w
            }), n.updateInstanceState({
              exportBackground: !n.instanceState.exportBackground
            }, {
              ephemeral: true
            });
          },
          checkbox: true
        },
        {
          id: "toggle-tool-lock",
          label: "action.toggle-tool-lock",
          menuLabel: "action.toggle-tool-lock.menu",
          readonlyOk: false,
          kbd: "q",
          onSelect(w) {
            f("toggle-tool-lock", {
              source: w
            }), n.updateInstanceState({
              isToolLocked: !n.instanceState.isToolLocked
            });
          },
          checkbox: true
        },
        {
          id: "unlock-all",
          label: "action.unlock-all",
          readonlyOk: false,
          onSelect(w) {
            f("unlock-all", {
              source: w
            });
            const x = [];
            for (const P of n.currentPageShapes)
              P.isLocked && x.push({
                id: P.id,
                type: P.type,
                isLocked: false
              });
            x.length > 0 && n.updateShapes(x);
          }
        },
        {
          id: "toggle-focus-mode",
          label: "action.toggle-focus-mode",
          menuLabel: "action.toggle-focus-mode.menu",
          readonlyOk: true,
          kbd: "$.",
          checkbox: true,
          onSelect(w) {
            requestAnimationFrame(() => {
              n.batch(() => {
                f("toggle-focus-mode", {
                  source: w
                }), i(), s(), n.updateInstanceState({
                  isFocusMode: !n.instanceState.isFocusMode
                });
              });
            });
          }
        },
        {
          id: "toggle-grid",
          label: "action.toggle-grid",
          menuLabel: "action.toggle-grid.menu",
          readonlyOk: true,
          kbd: "$'",
          onSelect(w) {
            f("toggle-grid-mode", {
              source: w
            }), n.updateInstanceState({
              isGridMode: !n.instanceState.isGridMode
            });
          },
          checkbox: true
        },
        {
          id: "toggle-debug-mode",
          label: "action.toggle-debug-mode",
          menuLabel: "action.toggle-debug-mode.menu",
          readonlyOk: true,
          onSelect(w) {
            f("toggle-debug-mode", {
              source: w
            }), n.updateInstanceState({
              isDebugMode: !n.instanceState.isDebugMode
            });
          },
          checkbox: true
        },
        {
          id: "print",
          label: "action.print",
          kbd: "$p",
          readonlyOk: true,
          onSelect(w) {
            f("print", {
              source: w
            }), a();
          }
        },
        {
          id: "exit-pen-mode",
          label: "action.exit-pen-mode",
          icon: "cross-2",
          readonlyOk: true,
          onSelect(w) {
            f("exit-pen-mode", {
              source: w
            }), n.updateInstanceState({
              isPenMode: false
            });
          }
        },
        {
          id: "stop-following",
          label: "action.stop-following",
          icon: "cross-2",
          readonlyOk: true,
          onSelect(w) {
            f("stop-following", {
              source: w
            }), n.stopFollowingUser();
          }
        },
        {
          id: "back-to-content",
          label: "action.back-to-content",
          icon: "arrow-left",
          readonlyOk: true,
          onSelect(w) {
            f("zoom-to-content", {
              source: w
            }), n.zoomToContent();
          }
        },
        {
          id: "toggle-lock",
          label: "action.toggle-lock",
          readonlyOk: false,
          kbd: "!l",
          onSelect(w) {
            n.mark("locking"), f("toggle-lock", {
              source: w
            }), n.toggleLock(n.selectedShapeIds);
          }
        }
      ]);
      return t ? t(n, S, void 0) : S;
    }, [
      f,
      t,
      n,
      r,
      o,
      h,
      d,
      l,
      c,
      u,
      i,
      s,
      a
    ]);
    return m.jsx(tte.Provider, {
      value: y,
      children: e
    });
  }
  function $i() {
    const t = b.useContext(tte);
    if (!t)
      throw new Error("useTools must be used within a ToolProvider");
    return t;
  }
  function c2(t) {
    return t.filter((e) => e != null && e !== false);
  }
  function ft(t, ...e) {
    const n = c2(e);
    return n.length === 0 ? null : {
      id: t,
      type: "group",
      checkbox: n.every((r) => r.type === "item" && r.actionItem.checkbox),
      disabled: n.every((r) => r.disabled),
      readonlyOk: n.some((r) => r.readonlyOk),
      children: n
    };
  }
  function Ol(t, e, ...n) {
    const r = c2(n);
    return r.length === 0 ? null : {
      id: t,
      type: "submenu",
      label: e,
      children: r,
      disabled: r.every((i) => i.disabled),
      readonlyOk: r.some((i) => i.readonlyOk)
    };
  }
  function QL(t, e = {}) {
    const { readonlyOk: n = true, disabled: r = false } = e;
    return {
      id: t,
      type: "custom",
      disabled: r,
      readonlyOk: n
    };
  }
  function re(t, e = {}) {
    if (!t)
      throw Error("No action item provided to menuItem");
    if (!t.label)
      throw Error("Trying to create menu item for action item that doesn't have a label");
    const { checked: n = false, disabled: r = false } = e;
    return {
      id: t.id,
      type: "item",
      actionItem: t,
      disabled: r,
      checked: n,
      readonlyOk: t.readonlyOk
    };
  }
  function nte(t) {
    const { selectedShapeIds: e } = t;
    return e.map((r) => t.getShape(r)).filter((r) => !(!r || t.isShapeOfType(r, "arrow") && r.props.start.type === "binding" || t.isShapeOfType(r, "arrow") && r.props.end.type === "binding"));
  }
  const rte = () => {
    const t = ue();
    return ye("threeStackableItems", () => nte(t).length > 2, [
      t
    ]);
  }, zL = () => {
    const t = ue();
    return ye("allowGroup", () => nte(t).length > 1, [
      t
    ]);
  }, FL = () => {
    const t = ue();
    return ye("allowUngroup", () => t.selectedShapeIds.some((e) => {
      var _a3;
      return ((_a3 = t.getShape(e)) == null ? void 0 : _a3.type) === "group";
    }), []);
  }, ite = typeof window < "u" && "navigator" in window && !!navigator.clipboard && !!navigator.clipboard.read, l6e = [
    0,
    380,
    420,
    460,
    580,
    640,
    840,
    1023
  ], ste = $e.createContext(0);
  function c6e({ children: t }) {
    const e = ue(), n = ye("breakpoint", () => {
      const { width: r } = e.viewportScreenBounds, i = l6e;
      for (let s = 0; s < i.length - 1; s++)
        if (r > i[s] && r <= i[s + 1])
          return s;
      return i.length;
    }, [
      e
    ]);
    return m.jsx(ste.Provider, {
      value: n,
      children: t
    });
  }
  function oa() {
    let t = b.useContext(ste);
    const e = new URL(window.location.href).searchParams.get("layout");
    return e === "desktop" ? t = 7 : e === "mobile" && (t = 1), t;
  }
  function BL() {
    const t = ue();
    return ye("hasLinkShapeSelected", () => {
      const { selectedShapes: e } = t;
      return e.length === 1 && "url" in e[0].props && e[0].type !== "embed";
    }, [
      t
    ]);
  }
  const ote = $e.createContext({}), u6e = Vt(function({ overrides: e, children: n }) {
    const r = ue(), i = $i(), s = r.selectedShapeIds.length, o = s > 0, a = s > 1, l = s > 2, c = rte(), u = zL(), d = FL(), h = BL(), f = oa(), y = r.zoomLevel === 1, g = b.useMemo(() => {
      const O = [
        re(i["align-left"], {
          disabled: !a
        }),
        re(i["align-center-horizontal"], {
          disabled: !a
        }),
        re(i["align-right"], {
          disabled: !a
        }),
        re(i["stretch-horizontal"], {
          disabled: !a
        }),
        re(i["align-top"], {
          disabled: !a
        }),
        re(i["align-center-vertical"], {
          disabled: !a
        }),
        re(i["align-bottom"], {
          disabled: !a
        }),
        re(i["stretch-vertical"], {
          disabled: !a
        }),
        re(i["distribute-horizontal"], {
          disabled: !l
        }),
        re(i["distribute-vertical"], {
          disabled: !l
        }),
        re(i["stack-horizontal"], {
          disabled: !c
        }),
        re(i["stack-vertical"], {
          disabled: !c
        }),
        re(i["send-to-back"], {
          disabled: !o
        }),
        re(i["send-backward"], {
          disabled: !o
        }),
        re(i["bring-forward"], {
          disabled: !o
        }),
        re(i["bring-to-front"], {
          disabled: !o
        }),
        f < 5 ? re(i["zoom-to-100"], {
          disabled: !!y
        }) : re(i["rotate-ccw"], {
          disabled: !o
        }),
        re(i["rotate-cw"], {
          disabled: !o
        }),
        re(i["edit-link"], {
          disabled: !h
        }),
        u ? re(i.group, {
          disabled: !a
        }) : d ? re(i.ungroup) : re(i.group, {
          disabled: !a
        })
      ];
      return e ? e(r, O, {
        actions: i,
        oneSelected: o,
        twoSelected: a,
        threeSelected: l
      }) : O;
    }, [
      r,
      y,
      u,
      e,
      i,
      o,
      a,
      l,
      c,
      d,
      h,
      f
    ]);
    return m.jsx(ote.Provider, {
      value: g,
      children: n
    });
  });
  function d6e() {
    const t = $e.useContext(ote);
    if (!t)
      throw new Error("useActionsMenuSchema must be used inside of a ActionsMenuSchemaProvider.");
    return t;
  }
  function h6e() {
    const t = ue();
    return ye("onlyFlippableShape", () => {
      const { selectedShapes: e } = t;
      return e.length === 1 && e.every((n) => t.isShapeOfType(n, "group") || t.isShapeOfType(n, "arrow") || t.isShapeOfType(n, "line") || t.isShapeOfType(n, "draw"));
    }, [
      t
    ]);
  }
  function ate() {
    const t = ue();
    return ye("showAutoSizeToggle", () => {
      const { selectedShapes: e } = t;
      return e.length === 1 && t.isShapeOfType(e[0], "text") && e[0].props.autoSize === false;
    }, [
      t
    ]);
  }
  const lte = $e.createContext({}), f6e = Vt(function({ overrides: e, children: n }) {
    var _a3;
    const r = ue(), i = $i(), s = ate(), o = h6e(), a = r.selectedShapeIds.length, l = a > 0, c = a > 1, u = a > 2, d = rte(), h = ye("atLeastOneShapeOnPage", () => r.currentPageShapeIds.size > 0, []), f = ye("isTransparentBg", () => r.instanceState.exportBackground, []), y = zL(), g = FL(), O = !!((_a3 = window.navigator.clipboard) == null ? void 0 : _a3.write), S = BL(), { onlySelectedShape: w } = r, x = w && r.isShapeOrAncestorLocked(w), P = b.useMemo(() => {
      let C = c2([
        ft("selection", s && re(i["toggle-auto-size"]), S && !x && re(i["edit-link"]), l && !x && re(i.duplicate), y && !x && re(i.group), g && !x && re(i.ungroup), l && re(i["toggle-lock"])),
        ft("modify", (c || o) && Ol("arrange", "context-menu.arrange", c && ft("align", re(i["align-left"]), re(i["align-center-horizontal"]), re(i["align-right"]), re(i["align-top"]), re(i["align-center-vertical"]), re(i["align-bottom"])), u && ft("distribute", re(i["distribute-horizontal"]), re(i["distribute-vertical"])), c && ft("stretch", re(i["stretch-horizontal"]), re(i["stretch-vertical"])), o && !x && ft("flip", re(i["flip-horizontal"]), re(i["flip-vertical"])), c && ft("order", re(i.pack, {
          disabled: !c
        }), d && re(i["stack-vertical"]), d && re(i["stack-horizontal"]))), l && !x && Ol("reorder", "context-menu.reorder", ft("reorder", re(i["bring-to-front"]), re(i["bring-forward"]), re(i["send-backward"]), re(i["send-to-back"]))), l && !x && QL("MOVE_TO_PAGE_MENU", {
          readonlyOk: false
        })),
        ft("clipboard-group", l && !x && re(i.cut), l && re(i.copy), ite && re(i.paste)),
        h && ft("conversions", Ol("copy-as", "context-menu.copy-as", ft("copy-as-group", re(i["copy-as-svg"]), O && re(i["copy-as-png"]), re(i["copy-as-json"])), ft("export-bg", re(i["toggle-transparent"], {
          checked: !f
        }))), Ol("export-as", "context-menu.export-as", ft("export-as-group", re(i["export-as-svg"]), re(i["export-as-png"]), re(i["export-as-json"])), ft("export-bg,", re(i["toggle-transparent"], {
          checked: !f
        })))),
        h && ft("set-selection-group", re(i["select-all"]), l && re(i["select-none"])),
        l && !x && ft("delete-group", re(i.delete))
      ]);
      return e && (C = e(r, C, {
        actions: i,
        oneSelected: l,
        twoSelected: c,
        threeSelected: u,
        showAutoSizeToggle: s,
        showUngroup: g,
        onlyFlippableShapeSelected: o
      })), C;
    }, [
      r,
      e,
      i,
      l,
      c,
      u,
      s,
      o,
      h,
      d,
      y,
      g,
      O,
      S,
      f,
      x
    ]);
    return m.jsx(lte.Provider, {
      value: P,
      children: n
    });
  });
  function cte() {
    const t = $e.useContext(lte);
    if (!t)
      throw new Error("useContextMenuSchema must be used inside of a TLUiContextMenuSchemaProvider.");
    return t;
  }
  const ute = b.createContext({});
  function p6e({ overrides: t, children: e }) {
    const n = ue(), r = Mm(), { addDialog: i } = Cf(), s = ete(), o = b.useMemo(() => {
      const a = [
        {
          id: "select",
          label: "tool.select",
          icon: "tool-pointer",
          kbd: "v",
          readonlyOk: true,
          onSelect(c) {
            n.setCurrentTool("select"), r("select-tool", {
              source: c,
              id: "select"
            });
          }
        },
        {
          id: "hand",
          label: "tool.hand",
          icon: "tool-hand",
          kbd: "h",
          readonlyOk: true,
          onSelect(c) {
            n.setCurrentTool("hand"), r("select-tool", {
              source: c,
              id: "hand"
            });
          }
        },
        {
          id: "eraser",
          label: "tool.eraser",
          icon: "tool-eraser",
          kbd: "e",
          readonlyOk: false,
          onSelect(c) {
            n.setCurrentTool("eraser"), r("select-tool", {
              source: c,
              id: "eraser"
            });
          }
        },
        {
          id: "draw",
          label: "tool.draw",
          readonlyOk: false,
          icon: "tool-pencil",
          kbd: "d,b,x",
          onSelect(c) {
            n.setCurrentTool("draw"), r("select-tool", {
              source: c,
              id: "draw"
            });
          }
        },
        ...[
          ...Al.values
        ].map((c) => ({
          id: c,
          label: `tool.${c}`,
          readonlyOk: false,
          meta: {
            geo: c
          },
          kbd: c === "rectangle" ? "r" : c === "ellipse" ? "o" : void 0,
          icon: "geo-" + c,
          onSelect(u) {
            n.batch(() => {
              n.updateInstanceState({
                stylesForNextShape: {
                  ...n.instanceState.stylesForNextShape,
                  [Al.id]: c
                }
              }, {
                ephemeral: true
              }), n.setCurrentTool("geo"), r("select-tool", {
                source: u,
                id: `geo-${c}`
              });
            });
          }
        })),
        {
          id: "arrow",
          label: "tool.arrow",
          readonlyOk: false,
          icon: "tool-arrow",
          kbd: "a",
          onSelect(c) {
            n.setCurrentTool("arrow"), r("select-tool", {
              source: c,
              id: "arrow"
            });
          }
        },
        {
          id: "line",
          label: "tool.line",
          readonlyOk: false,
          icon: "tool-line",
          kbd: "l",
          onSelect(c) {
            n.setCurrentTool("line"), r("select-tool", {
              source: c,
              id: "line"
            });
          }
        },
        {
          id: "frame",
          label: "tool.frame",
          readonlyOk: false,
          icon: "tool-frame",
          kbd: "f",
          onSelect(c) {
            n.setCurrentTool("frame"), r("select-tool", {
              source: c,
              id: "frame"
            });
          }
        },
        {
          id: "text",
          label: "tool.text",
          readonlyOk: false,
          icon: "tool-text",
          kbd: "t",
          onSelect(c) {
            n.setCurrentTool("text"), r("select-tool", {
              source: c,
              id: "text"
            });
          }
        },
        {
          id: "asset",
          label: "tool.asset",
          readonlyOk: false,
          icon: "tool-media",
          kbd: "$u",
          onSelect(c) {
            s(), r("select-tool", {
              source: c,
              id: "media"
            });
          }
        },
        {
          id: "note",
          label: "tool.note",
          readonlyOk: false,
          icon: "tool-note",
          kbd: "n",
          onSelect(c) {
            n.setCurrentTool("note"), r("select-tool", {
              source: c,
              id: "note"
            });
          }
        },
        {
          id: "laser",
          label: "tool.laser",
          readonlyOk: true,
          icon: "tool-laser",
          kbd: "k",
          onSelect(c) {
            n.setCurrentTool("laser"), r("select-tool", {
              source: c,
              id: "laser"
            });
          }
        },
        {
          id: "embed",
          label: "tool.embed",
          readonlyOk: false,
          icon: "tool-embed",
          onSelect(c) {
            i({
              component: Vee
            }), r("select-tool", {
              source: c,
              id: "embed"
            });
          }
        }
      ];
      a.push({
        id: "highlight",
        label: "tool.highlight",
        readonlyOk: true,
        icon: "tool-highlight",
        kbd: "!d",
        onSelect(c) {
          n.setCurrentTool("highlight"), r("select-tool", {
            source: c,
            id: "highlight"
          });
        }
      });
      const l = Object.fromEntries(a.map((c) => [
        c.id,
        c
      ]));
      return t ? t(n, l, {
        insertMedia: s
      }) : l;
    }, [
      t,
      n,
      r,
      s,
      i
    ]);
    return m.jsx(ute.Provider, {
      value: o,
      children: e
    });
  }
  function UL() {
    const t = b.useContext(ute);
    if (!t)
      throw new Error("useTools must be used within a ToolProvider");
    return t;
  }
  const dte = $e.createContext({}), g6e = Vt(function({ overrides: e, children: n }) {
    const r = ue(), i = UL(), s = $i(), o = b.useMemo(() => {
      const a = Je([
        ft("shortcuts-dialog.tools", re(s["toggle-tool-lock"]), re(i.select), re(i.draw), re(i.eraser), re(i.hand), re(i.rectangle), re(i.ellipse), re(i.arrow), re(i.line), re(i.text), re(i.frame), re(i.note), re(i.laser)),
        ft("shortcuts-dialog.file", re(s["insert-media"]), re(s.print)),
        ft("shortcuts-dialog.preferences", re(s["toggle-dark-mode"]), re(s["toggle-focus-mode"]), re(s["toggle-grid"])),
        ft("shortcuts-dialog.edit", re(s.undo), re(s.redo), re(s.cut), re(s.copy), re(s.paste), re(s["select-all"]), re(s.delete), re(s.duplicate), re(s["export-as-svg"]), re(s["export-as-png"])),
        ft("shortcuts-dialog.view", re(s["zoom-in"]), re(s["zoom-out"]), re(s["zoom-to-100"]), re(s["zoom-to-fit"]), re(s["zoom-to-selection"])),
        ft("shortcuts-dialog.transform", re(s["bring-to-front"]), re(s["bring-forward"]), re(s["send-backward"]), re(s["send-to-back"]), re(s.group), re(s.ungroup), re(s["flip-horizontal"]), re(s["flip-vertical"]), re(s["align-top"]), re(s["align-center-vertical"]), re(s["align-bottom"]), re(s["align-left"]), re(s["align-center-horizontal"]), re(s["align-right"]))
      ]);
      return e ? e(r, a, {
        tools: i,
        actions: s
      }) : a;
    }, [
      r,
      e,
      s,
      i
    ]);
    return m.jsx(dte.Provider, {
      value: o,
      children: n
    });
  });
  function m6e() {
    const t = $e.useContext(dte);
    if (!t)
      throw new Error("Shortcuts must be used inside of a ShortcutsProvider.");
    return t;
  }
  const y6e = () => {
    const t = Tt(), e = sa(), n = m6e();
    function r(i) {
      if (e && !i.readonlyOk)
        return null;
      switch (i.type) {
        case "group":
          return m.jsxs("div", {
            className: "tlui-shortcuts-dialog__group",
            children: [
              m.jsx("h2", {
                className: "tlui-shortcuts-dialog__group__title",
                children: t(i.id)
              }),
              m.jsx("div", {
                className: "tlui-shortcuts-dialog__group__content",
                children: i.children.filter((s) => s.type === "item" && s.actionItem.kbd).map(r)
              })
            ]
          }, i.id);
        case "item": {
          const { id: s, label: o, shortcutsLabel: a, kbd: l } = i.actionItem;
          return m.jsxs("div", {
            className: "tlui-shortcuts-dialog__key-pair",
            children: [
              m.jsx("div", {
                className: "tlui-shortcuts-dialog__key-pair__key",
                children: t(a ?? o)
              }),
              m.jsx("div", {
                className: "tlui-shortcuts-dialog__key-pair__value",
                children: m.jsx(zC, {
                  children: l
                })
              })
            ]
          }, s);
        }
      }
    }
    return m.jsxs(m.Fragment, {
      children: [
        m.jsxs(FC, {
          className: "tlui-shortcuts-dialog__header",
          children: [
            m.jsx(BC, {
              children: t("shortcuts-dialog.title")
            }),
            m.jsx(UC, {})
          ]
        }),
        m.jsx(qv, {
          className: "tlui-shortcuts-dialog__body",
          children: n.map(r)
        }),
        m.jsx("div", {
          className: "tlui-dialog__scrim"
        })
      ]
    });
  };
  function hte() {
    const t = ue();
    return {
      languages: Vv,
      currentLanguage: t.user.locale
    };
  }
  const fte = $e.createContext({}), v6e = Vt(function({ overrides: e, children: n }) {
    const r = ue(), i = $i(), s = r.selectedShapeIds.length, o = s > 0, a = s > 1, l = s > 2, { languages: c, currentLanguage: u } = hte(), { addDialog: d } = Cf(), h = b.useMemo(() => {
      const f = Je([
        ft("top", QL("LANGUAGE_MENU", {
          readonlyOk: true
        }), re({
          id: "keyboard-shortcuts",
          label: "help-menu.keyboard-shortcuts",
          readonlyOk: true,
          onSelect() {
            d({
              component: y6e
            });
          }
        }))
      ]);
      return e ? e(r, f, {
        actions: i,
        currentLanguage: u,
        languages: c,
        oneSelected: o,
        twoSelected: a,
        threeSelected: l
      }) : f;
    }, [
      r,
      e,
      c,
      i,
      o,
      a,
      l,
      u,
      d
    ]);
    return m.jsx(fte.Provider, {
      value: h,
      children: n
    });
  });
  function O6e() {
    const t = $e.useContext(fte);
    if (!t)
      throw new Error("useHelpMenuSchema must be used inside of a helpTLUiMenuSchemaProvider.");
    return t;
  }
  function pte() {
    const t = ue();
    return ye("useCanRedo", () => t.canRedo, [
      t
    ]);
  }
  function gte() {
    const t = ue();
    return ye("useCanUndo", () => t.canUndo, [
      t
    ]);
  }
  const mte = $e.createContext({});
  function S6e({ overrides: t, children: e }) {
    var _a3;
    const n = ue(), r = $i(), s = oa() < 5, o = ye("isDarkMode", () => n.user.isDarkMode, [
      n
    ]), a = ye("animationSpeed", () => n.user.animationSpeed, [
      n
    ]), l = ye("isGridMode", () => n.instanceState.isGridMode, [
      n
    ]), c = ye("isSnapMode", () => n.user.isSnapMode, [
      n
    ]), u = ye("isToolLock", () => n.instanceState.isToolLocked, [
      n
    ]), d = ye("isFocusMode", () => n.instanceState.isFocusMode, [
      n
    ]), h = ye("isDebugMode", () => n.instanceState.isDebugMode, [
      n
    ]), f = ye("exportBackground", () => n.instanceState.exportBackground, [
      n
    ]), y = ye("emptyPage", () => n.currentPageShapeIds.size === 0, [
      n
    ]), g = ye("selectedCount", () => n.selectedShapeIds.length, [
      n
    ]), O = g === 0, S = g > 0, w = g > 1, x = g > 2, P = !!((_a3 = window.navigator.clipboard) == null ? void 0 : _a3.write), C = BL(), _ = ate(), T = zL(), $ = FL(), N = gte(), L = pte(), z = ye("isZoomedTo100", () => n.zoomLevel === 1, [
      n
    ]), M = ye("oneEmbedSelected", () => {
      const { onlySelectedShape: Q } = n;
      return Q ? !!(n.isShapeOfType(Q, "embed") && Q.props.url && !n.isShapeOrAncestorLocked(Q)) : false;
    }, []), R = ye("oneEmbeddableBookmarkSelected", () => {
      const { onlySelectedShape: Q } = n;
      return Q ? !!(n.isShapeOfType(Q, "bookmark") && Q.props.url && Cc(Q.props.url) && !n.isShapeOrAncestorLocked(Q)) : false;
    }, []), F = b.useMemo(() => {
      const Q = c2([
        ft("menu", Ol("file", "menu.file", ft("print", re(r.print, {
          disabled: y
        }))), Ol("edit", "menu.edit", ft("undo-actions", re(r.undo, {
          disabled: !N
        }), re(r.redo, {
          disabled: !L
        })), ft("clipboard-actions", re(r.cut, {
          disabled: O
        }), re(r.copy, {
          disabled: O
        }), re(r.paste, {
          disabled: !ite
        })), ft("conversions", Ol("copy-as", "menu.copy-as", ft("copy-as-group", re(r["copy-as-svg"], {
          disabled: y
        }), re(r["copy-as-png"], {
          disabled: y || !P
        }), re(r["copy-as-json"], {
          disabled: y
        })), ft("export-bg", re(r["toggle-transparent"], {
          checked: !f
        }))), Ol("export-as", "menu.export-as", ft("export-as-group", re(r["export-as-svg"], {
          disabled: y
        }), re(r["export-as-png"], {
          disabled: y
        }), re(r["export-as-json"], {
          disabled: y
        })), ft("export-bg", re(r["toggle-transparent"], {
          checked: !f
        })))), ft("set-selection-group", re(r["select-all"], {
          disabled: y
        }), re(r["select-none"], {
          disabled: !S
        })), ft("selection", _ && re(r["toggle-auto-size"]), C && re(r["edit-link"]), re(r.duplicate, {
          disabled: !S
        }), T && re(r.group), $ && re(r.ungroup), re(r["unlock-all"], {
          disabled: y
        })), ft("delete-group", re(r.delete, {
          disabled: !S
        })), ft("embeds", M && re(r["open-embed-link"]), M && re(r["convert-to-bookmark"]), R && re(r["convert-to-embed"]))), Ol("view", "menu.view", ft("view-actions", re(r["zoom-in"]), re(r["zoom-out"]), re(r["zoom-to-100"], {
          disabled: z
        }), re(r["zoom-to-fit"], {
          disabled: y
        }), re(r["zoom-to-selection"], {
          disabled: y || !S
        })))),
        ft("extras", re(r["insert-embed"]), re(r["insert-media"])),
        ft("preferences", Ol("preferences", "menu.preferences", ft("preferences-actions", re(r["toggle-snap-mode"], {
          checked: c
        }), re(r["toggle-tool-lock"], {
          checked: u
        }), re(r["toggle-grid"], {
          checked: l
        }), re(r["toggle-dark-mode"], {
          checked: o
        }), re(r["toggle-focus-mode"], {
          checked: d
        }), re(r["toggle-reduce-motion"], {
          checked: a === 0
        }), re(r["toggle-debug-mode"], {
          checked: h
        }))), s && QL("LANGUAGE_MENU", {
          readonlyOk: true
        }))
      ]);
      return t ? t(n, Q, {
        actions: r,
        noneSelected: O,
        oneSelected: S,
        twoSelected: w,
        threeSelected: x
      }) : Q;
    }, [
      n,
      t,
      r,
      S,
      w,
      x,
      y,
      s,
      T,
      $,
      C,
      P,
      _,
      O,
      N,
      L,
      a,
      o,
      l,
      c,
      u,
      d,
      f,
      h,
      z,
      R,
      M
    ]);
    return m.jsx(mte.Provider, {
      value: F,
      children: e
    });
  }
  function w6e() {
    const t = $e.useContext(mte);
    if (!t)
      throw new Error("useMenuSchema must be used inside of a TLUiMenuSchemaProvider.");
    return t;
  }
  function Kt(t) {
    return {
      id: t.id,
      type: "item",
      readonlyOk: t.readonlyOk,
      toolItem: t
    };
  }
  const yte = $e.createContext([]);
  function x6e({ overrides: t, children: e }) {
    const n = ue(), r = UL(), i = $e.useMemo(() => {
      const s = Je([
        Kt(r.select),
        Kt(r.hand),
        Kt(r.draw),
        Kt(r.eraser),
        Kt(r.arrow),
        Kt(r.text),
        Kt(r.note),
        Kt(r.asset),
        Kt(r.rectangle),
        Kt(r.ellipse),
        Kt(r.diamond),
        Kt(r.triangle),
        Kt(r.trapezoid),
        Kt(r.rhombus),
        Kt(r.hexagon),
        Kt(r.cloud),
        Kt(r.star),
        Kt(r.oval),
        Kt(r["x-box"]),
        Kt(r["check-box"]),
        Kt(r["arrow-left"]),
        Kt(r["arrow-up"]),
        Kt(r["arrow-down"]),
        Kt(r["arrow-right"]),
        Kt(r.frame),
        Kt(r.line),
        Kt(r.highlight),
        Kt(r.laser)
      ]);
      return t ? t(n, s, {
        tools: r
      }) : s;
    }, [
      n,
      t,
      r
    ]);
    return m.jsx(yte.Provider, {
      value: i,
      children: e
    });
  }
  function b6e() {
    const t = $e.useContext(yte);
    if (!t)
      throw new Error("useToolbarSchema must be used within a ToolbarSchemaProvider");
    return t;
  }
  function k6e() {
    const { addToast: t, removeToast: e, clearToasts: n } = Hl(), { addDialog: r, clearDialogs: i, removeDialog: s, updateDialog: o } = Cf(), l = oa() < 5, c = Tt();
    return b.useMemo(() => ({
      addToast: t,
      removeToast: e,
      clearToasts: n,
      addDialog: r,
      clearDialogs: i,
      removeDialog: s,
      updateDialog: o,
      msg: c,
      isMobile: l
    }), [
      r,
      t,
      i,
      n,
      c,
      s,
      e,
      o,
      l
    ]);
  }
  function P6e(t, e) {
    const n = {};
    for (const r of t)
      if (r.translations)
        for (const [i, s] of Mc(r.translations)) {
          let o = n[i];
          o || (o = n[i] = {}), Object.assign(o, s);
        }
    return {
      actionsMenu: (r, i, s) => {
        for (const o of t)
          o.actionsMenu && (i = o.actionsMenu(r, i, {
            ...e,
            ...s
          }));
        return i;
      },
      actions: (r, i) => {
        for (const s of t)
          s.actions && (i = s.actions(r, i, e));
        return i;
      },
      contextMenu: (r, i, s) => {
        for (const o of t)
          o.contextMenu && (i = o.contextMenu(r, i, {
            ...e,
            ...s
          }));
        return i;
      },
      helpMenu: (r, i, s) => {
        for (const o of t)
          o.helpMenu && (i = o.helpMenu(r, i, {
            ...e,
            ...s
          }));
        return i;
      },
      menu: (r, i, s) => {
        for (const o of t)
          o.menu && (i = o.menu(r, i, {
            ...e,
            ...s
          }));
        return i;
      },
      toolbar: (r, i, s) => {
        for (const o of t)
          o.toolbar && (i = o.toolbar(r, i, {
            ...e,
            ...s
          }));
        return i;
      },
      keyboardShortcutsMenu: (r, i, s) => {
        for (const o of t)
          o.keyboardShortcutsMenu && (i = o.keyboardShortcutsMenu(r, i, {
            ...e,
            ...s
          }));
        return i;
      },
      tools: (r, i, s) => {
        for (const o of t)
          o.tools && (i = o.tools(r, i, {
            ...e,
            ...s
          }));
        return i;
      },
      translations: n
    };
  }
  function vte(t) {
    return b.useMemo(() => t, t);
  }
  function C6e(t) {
    const e = vte(t == null ? [] : Array.isArray(t) ? t : [
      t
    ]);
    return b.useMemo(() => {
      const n = {};
      for (const r of e)
        if (r.translations)
          for (const [i, s] of Mc(r.translations)) {
            let o = n[i];
            o || (o = n[i] = {}), Object.assign(o, s);
          }
      return n;
    }, [
      e
    ]);
  }
  function _6e(t) {
    const e = k6e(), n = vte(t == null ? [] : Array.isArray(t) ? t : [
      t
    ]);
    return b.useMemo(() => P6e(n, e), [
      n,
      e
    ]);
  }
  function T6e({ overrides: t, assetUrls: e, onUiEvent: n, children: r }) {
    return m.jsx(g3e, {
      assetUrls: EQe(e),
      children: m.jsx(v3e, {
        overrides: C6e(t),
        children: m.jsx(BLe, {
          onEvent: n,
          children: m.jsx(KQe, {
            children: m.jsx(n6e, {
              children: m.jsx(c6e, {
                children: m.jsx(E6e, {
                  overrides: t,
                  children: r
                })
              })
            })
          })
        })
      })
    });
  }
  function E6e({ overrides: t, children: e }) {
    const n = _6e(t);
    return m.jsx(a6e, {
      overrides: n.actions,
      children: m.jsx(p6e, {
        overrides: n.tools,
        children: m.jsx(x6e, {
          overrides: n.toolbar,
          children: m.jsx(u6e, {
            overrides: n.actionsMenu,
            children: m.jsx(g6e, {
              overrides: n.keyboardShortcutsMenu,
              children: m.jsx(f6e, {
                overrides: n.contextMenu,
                children: m.jsx(v6e, {
                  overrides: n.helpMenu,
                  children: m.jsx(S6e, {
                    overrides: n.menu,
                    children: e
                  })
                })
              })
            })
          })
        })
      })
    });
  }
  function I6e() {
    const t = ue(), n = $i()["back-to-content"], [r, i] = b.useState(false);
    return b.useEffect(() => {
      let s = false;
      const o = setInterval(() => {
        const { renderingShapes: a, renderingBounds: l } = t, u = a.filter((d) => d.maskedPageBounds && l.includes(d.maskedPageBounds)).length === 0 && t.currentPageShapes.length > 0;
        s !== u && (i(u), s = u);
      }, 1e3);
      return () => {
        clearInterval(o);
      };
    }, [
      t
    ]), r ? m.jsx(Be, {
      iconLeft: n.icon,
      label: n.label,
      onClick: () => {
        n.onSelect("helper-buttons"), i(false);
      }
    }) : null;
  }
  let z7 = 0;
  function $6e(t, e) {
    const n = Array(e), r = Math.floor(Math.sqrt(e));
    for (let i = 0; i < e; i++)
      z7++, n[i] = {
        id: bn("box" + z7),
        type: "geo",
        x: i % r * 132,
        y: Math.floor(i / r) * 132
      };
    t.batch(() => {
      t.createShapes(n).setSelectedShapes(n.map((i) => i.id));
    });
  }
  const A6e = b.memo(function({ renderDebugMenuItems: e }) {
    const n = Tt();
    return m.jsxs("div", {
      className: "tlui-debug-panel",
      children: [
        m.jsx(R6e, {}),
        m.jsx(M6e, {}),
        m.jsxs(Pd, {
          id: "debug",
          children: [
            m.jsx(fS, {
              children: m.jsx(Be, {
                icon: "dots-horizontal",
                title: n("debug-panel.more")
              })
            }),
            m.jsx(Cd, {
              side: "top",
              align: "end",
              alignOffset: 0,
              children: m.jsx(D6e, {
                renderDebugMenuItems: e
              })
            })
          ]
        })
      ]
    });
  }), R6e = Vt(function() {
    const e = ue();
    return m.jsx("div", {
      className: "tlui-debug-panel__current-state",
      children: e.root.path.value
    });
  }), M6e = function() {
    const e = ue(), n = ye("rendering shapes count", () => e.renderingShapes.length, [
      e
    ]);
    return m.jsxs("div", {
      children: [
        n,
        " Shapes"
      ]
    });
  }, D6e = Vt(function({ renderDebugMenuItems: e }) {
    const n = ue(), { addToast: r } = Hl(), { addDialog: i } = Cf(), [s, o] = b.useState(false);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsxs(jc, {
          children: [
            m.jsx(Ks, {
              onClick: () => {
                r({
                  id: wn(),
                  title: "Something happened",
                  description: "Hey, attend to this thing over here. It might be important!"
                });
              },
              children: m.jsx("span", {
                children: "Show toast"
              })
            }),
            m.jsx(Ks, {
              onClick: () => {
                i({
                  component: ({ onClose: a }) => m.jsx(j6e, {
                    displayDontShowAgain: true,
                    onCancel: () => {
                      a();
                    },
                    onContinue: () => {
                      a();
                    }
                  }),
                  onClose: () => {
                  }
                });
              },
              children: m.jsx("span", {
                children: "Show dialog"
              })
            }),
            m.jsx(Ks, {
              onClick: () => $6e(n, 100),
              children: m.jsx("span", {
                children: "Create 100 shapes"
              })
            }),
            m.jsx(Ks, {
              onClick: () => {
                function a({ children: h }) {
                  let f = 0;
                  if (!h.length)
                    return 0;
                  for (const y of [
                    ...h
                  ])
                    f++, f += a(y);
                  return f;
                }
                const { selectedShapes: l } = n, c = l.length === 0 ? n.renderingShapes : l, u = c.map((h) => document.getElementById(h.id).parentElement);
                let d = u.length;
                for (const h of u)
                  d += a(h);
                window.alert(`Shapes ${c.length}, DOM nodes:${d}`);
              },
              children: m.jsx("span", {
                children: "Count shapes and nodes"
              })
            }),
            (() => {
              if (s)
                throw Error("oh no!");
            })(),
            m.jsx(Ks, {
              onClick: () => {
                o(true);
              },
              children: m.jsx("span", {
                children: "Throw error"
              })
            }),
            m.jsx(Ks, {
              onClick: () => {
                vG();
              },
              children: m.jsx("span", {
                children: "Hard reset"
              })
            })
          ]
        }),
        m.jsxs(jc, {
          children: [
            m.jsx(Yy, {
              flag: un.debugSvg
            }),
            m.jsx(Yy, {
              flag: un.forceSrgb
            }),
            m.jsx(Yy, {
              flag: un.debugGeometry
            }),
            m.jsx(Yy, {
              flag: un.hideShapes
            })
          ]
        }),
        m.jsx(jc, {
          children: Object.values(Bbe).map((a) => m.jsx(Yy, {
            flag: a
          }, a.name))
        }),
        e == null ? void 0 : e()
      ]
    });
  });
  function L6e({ label: t, value: e, onChange: n }) {
    return m.jsx(nee, {
      title: t,
      checked: e,
      onSelect: () => n(!e),
      children: t
    });
  }
  const Yy = Vt(function({ flag: e, onChange: n }) {
    return m.jsx(L6e, {
      label: e.name.replace(/([a-z0-9])([A-Z])/g, (r) => `${r[0]} ${r[1].toLowerCase()}`).replace(/^[a-z]/, (r) => r.toUpperCase()),
      value: e.value,
      onChange: (r) => {
        e.set(r), n == null ? void 0 : n(r);
      }
    });
  });
  function j6e({ title: t = "title", body: e = "hello hello hello", cancel: n = "Cancel", confirm: r = "Continue", displayDontShowAgain: i = false, onCancel: s, onContinue: o }) {
    const [a, l] = b.useState(false);
    return m.jsxs(m.Fragment, {
      children: [
        m.jsxs(FC, {
          children: [
            m.jsx(BC, {
              children: t
            }),
            m.jsx(UC, {})
          ]
        }),
        m.jsx(qv, {
          style: {
            maxWidth: 350
          },
          children: e
        }),
        m.jsxs(J5, {
          className: "tlui-dialog__footer__actions",
          children: [
            i && m.jsx(Be, {
              onClick: () => l(!a),
              iconLeft: a ? "checkbox-checked" : "checkbox-empty",
              style: {
                marginRight: "auto"
              },
              children: "Don't show again"
            }),
            m.jsx(Be, {
              onClick: s,
              children: n
            }),
            m.jsx(Be, {
              type: "primary",
              onClick: async () => o(),
              children: r
            })
          ]
        })
      ]
    });
  }
  const N6e = ({ id: t, component: e, onClose: n }) => {
    const { removeDialog: r } = Cf(), i = Kr(), s = b.useCallback((o) => {
      if (!o) {
        if (n)
          try {
            n();
          } catch (a) {
            console.warn(a);
          }
        r(t);
      }
    }, [
      t,
      n,
      r
    ]);
    return m.jsx(NY, {
      onOpenChange: s,
      defaultOpen: true,
      children: m.jsx(QY, {
        container: i,
        children: m.jsx(r5, {
          dir: "ltr",
          className: "tlui-dialog__overlay",
          children: m.jsx(i5, {
            dir: "ltr",
            className: "tlui-dialog__content",
            children: m.jsx(e, {
              onClose: () => s(false)
            })
          })
        })
      })
    });
  };
  function Q6e() {
    const { dialogs: t } = Cf();
    return m.jsx(m.Fragment, {
      children: t.map((e) => m.jsx(N6e, {
        ...e
      }, e.id))
    });
  }
  const z6e = $e.memo(Q6e);
  function F6e() {
    const t = ue(), e = ye("follow", () => t.instanceState.followingUserId, [
      t
    ]);
    return e ? m.jsx(B6e, {
      userId: e
    }) : null;
  }
  function B6e({ userId: t }) {
    const e = NG(t);
    return e ? m.jsx("div", {
      className: "tlui-following",
      style: {
        borderColor: e.color
      }
    }) : null;
  }
  function Ote() {
    const t = ue(), { languages: e, currentLanguage: n } = hte(), r = b.useCallback((i) => t.user.updateUserPreferences({
      locale: i
    }), [
      t
    ]);
    return m.jsxs(xL, {
      id: "help menu language",
      children: [
        m.jsx(bL, {
          label: "menu.language",
          "data-direction": "left"
        }),
        m.jsx(kL, {
          sideOffset: -4,
          children: m.jsx(jc, {
            children: e.map(({ locale: i, label: s }) => m.jsx(ULe, {
              title: i,
              checked: i === n,
              onSelect: () => r(i),
              children: m.jsx("span", {
                children: s
              })
            }, i))
          })
        })
      ]
    });
  }
  const U6e = b.memo(function() {
    const e = Kr(), n = Tt(), [r, i] = Pf("help menu");
    return m.jsx("div", {
      className: "tlui-help-menu",
      children: m.jsxs(vL, {
        dir: "ltr",
        open: r,
        onOpenChange: i,
        modal: false,
        children: [
          m.jsx(Ug, {
            className: "tlui-button tlui-help-menu__button",
            dir: "ltr",
            title: n("help-menu.title"),
            children: m.jsx(Ss, {
              icon: "question-mark"
            })
          }),
          m.jsx(n2, {
            container: e,
            dir: "ltr",
            children: m.jsx(r2, {
              className: "tlui-menu",
              side: "top",
              sideOffset: 8,
              align: "end",
              alignOffset: 0,
              collisionPadding: 4,
              children: m.jsx(V6e, {})
            })
          })
        ]
      })
    });
  });
  function V6e() {
    const t = O6e(), e = sa();
    function n(r) {
      if (e && !r.readonlyOk)
        return null;
      switch (r.type) {
        case "custom": {
          if (r.id === "LANGUAGE_MENU")
            return m.jsx(Ote, {}, "item");
          break;
        }
        case "group":
          return m.jsx(jc, {
            size: "small",
            children: r.children.map(n)
          }, r.id);
        case "submenu":
          return m.jsxs(xL, {
            id: `help menu ${r.id}`,
            children: [
              m.jsx(bL, {
                label: r.label
              }),
              m.jsx(kL, {
                children: r.children.map(n)
              })
            ]
          }, r.id);
        case "item": {
          const { id: i, kbd: s, label: o, onSelect: a, icon: l } = r.actionItem;
          return m.jsx(Ks, {
            kbd: s,
            label: o,
            onClick: () => a("help-menu"),
            iconLeft: l
          }, i);
        }
      }
    }
    return m.jsx(m.Fragment, {
      children: t.map(n)
    });
  }
  function Yr() {
    return Yr = Object.assign ? Object.assign.bind() : function(t) {
      for (var e = 1; e < arguments.length; e++) {
        var n = arguments[e];
        for (var r in n)
          ({}).hasOwnProperty.call(n, r) && (t[r] = n[r]);
      }
      return t;
    }, Yr.apply(null, arguments);
  }
  function Zh(t, e, { checkForDefaultPrevented: n = true } = {}) {
    return function(i) {
      if (t == null ? void 0 : t(i), n === false || !i.defaultPrevented)
        return e == null ? void 0 : e(i);
    };
  }
  function X6e(t, e) {
    typeof t == "function" ? t(e) : t != null && (t.current = e);
  }
  function Ste(...t) {
    return (e) => t.forEach((n) => X6e(n, e));
  }
  function _f(...t) {
    return b.useCallback(Ste(...t), t);
  }
  function wte(t, e = []) {
    let n = [];
    function r(s, o) {
      const a = b.createContext(o), l = n.length;
      n = [
        ...n,
        o
      ];
      function c(d) {
        const { scope: h, children: f, ...y } = d, g = (h == null ? void 0 : h[t][l]) || a, O = b.useMemo(() => y, Object.values(y));
        return b.createElement(g.Provider, {
          value: O
        }, f);
      }
      function u(d, h) {
        const f = (h == null ? void 0 : h[t][l]) || a, y = b.useContext(f);
        if (y)
          return y;
        if (o !== void 0)
          return o;
        throw new Error(`\`${d}\` must be used within \`${s}\``);
      }
      return c.displayName = s + "Provider", [
        c,
        u
      ];
    }
    const i = () => {
      const s = n.map((o) => b.createContext(o));
      return function(a) {
        const l = (a == null ? void 0 : a[t]) || s;
        return b.useMemo(() => ({
          [`__scope${t}`]: {
            ...a,
            [t]: l
          }
        }), [
          a,
          l
        ]);
      };
    };
    return i.scopeName = t, [
      r,
      W6e(i, ...e)
    ];
  }
  function W6e(...t) {
    const e = t[0];
    if (t.length === 1)
      return e;
    const n = () => {
      const r = t.map((i) => ({
        useScope: i(),
        scopeName: i.scopeName
      }));
      return function(s) {
        const o = r.reduce((a, { useScope: l, scopeName: c }) => {
          const d = l(s)[`__scope${c}`];
          return {
            ...a,
            ...d
          };
        }, {});
        return b.useMemo(() => ({
          [`__scope${e.scopeName}`]: o
        }), [
          o
        ]);
      };
    };
    return n.scopeName = e.scopeName, n;
  }
  const VL = b.forwardRef((t, e) => {
    const { children: n, ...r } = t, i = b.Children.toArray(n), s = i.find(H6e);
    if (s) {
      const o = s.props.children, a = i.map((l) => l === s ? b.Children.count(o) > 1 ? b.Children.only(null) : b.isValidElement(o) ? o.props.children : null : l);
      return b.createElement(QR, Yr({}, r, {
        ref: e
      }), b.isValidElement(o) ? b.cloneElement(o, void 0, a) : null);
    }
    return b.createElement(QR, Yr({}, r, {
      ref: e
    }), n);
  });
  VL.displayName = "Slot";
  const QR = b.forwardRef((t, e) => {
    const { children: n, ...r } = t;
    return b.isValidElement(n) ? b.cloneElement(n, {
      ...Y6e(r, n.props),
      ref: Ste(e, n.ref)
    }) : b.Children.count(n) > 1 ? b.Children.only(null) : null;
  });
  QR.displayName = "SlotClone";
  const Z6e = ({ children: t }) => b.createElement(b.Fragment, null, t);
  function H6e(t) {
    return b.isValidElement(t) && t.type === Z6e;
  }
  function Y6e(t, e) {
    const n = {
      ...e
    };
    for (const r in e) {
      const i = t[r], s = e[r];
      /^on[A-Z]/.test(r) ? i && s ? n[r] = (...a) => {
        s(...a), i(...a);
      } : i && (n[r] = i) : r === "style" ? n[r] = {
        ...i,
        ...s
      } : r === "className" && (n[r] = [
        i,
        s
      ].filter(Boolean).join(" "));
    }
    return {
      ...t,
      ...n
    };
  }
  const G6e = [
    "a",
    "button",
    "div",
    "form",
    "h2",
    "h3",
    "img",
    "input",
    "label",
    "li",
    "nav",
    "ol",
    "p",
    "span",
    "svg",
    "ul"
  ], lf = G6e.reduce((t, e) => {
    const n = b.forwardRef((r, i) => {
      const { asChild: s, ...o } = r, a = s ? VL : e;
      return b.useEffect(() => {
        window[Symbol.for("radix-ui")] = true;
      }, []), b.createElement(a, Yr({}, o, {
        ref: i
      }));
    });
    return n.displayName = `Primitive.${e}`, {
      ...t,
      [e]: n
    };
  }, {});
  function q6e(t, e) {
    t && jd.flushSync(() => t.dispatchEvent(e));
  }
  function _d(t) {
    const e = b.useRef(t);
    return b.useEffect(() => {
      e.current = t;
    }), b.useMemo(() => (...n) => {
      var r;
      return (r = e.current) === null || r === void 0 ? void 0 : r.call(e, ...n);
    }, []);
  }
  function K6e(t, e = globalThis == null ? void 0 : globalThis.document) {
    const n = _d(t);
    b.useEffect(() => {
      const r = (i) => {
        i.key === "Escape" && n(i);
      };
      return e.addEventListener("keydown", r), () => e.removeEventListener("keydown", r);
    }, [
      n,
      e
    ]);
  }
  const zR = "dismissableLayer.update", J6e = "dismissableLayer.pointerDownOutside", eze = "dismissableLayer.focusOutside";
  let F7;
  const tze = b.createContext({
    layers: /* @__PURE__ */ new Set(),
    layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
    branches: /* @__PURE__ */ new Set()
  }), nze = b.forwardRef((t, e) => {
    var n;
    const { disableOutsidePointerEvents: r = false, onEscapeKeyDown: i, onPointerDownOutside: s, onFocusOutside: o, onInteractOutside: a, onDismiss: l, ...c } = t, u = b.useContext(tze), [d, h] = b.useState(null), f = (n = d == null ? void 0 : d.ownerDocument) !== null && n !== void 0 ? n : globalThis == null ? void 0 : globalThis.document, [, y] = b.useState({}), g = _f(e, ($) => h($)), O = Array.from(u.layers), [S] = [
      ...u.layersWithOutsidePointerEventsDisabled
    ].slice(-1), w = O.indexOf(S), x = d ? O.indexOf(d) : -1, P = u.layersWithOutsidePointerEventsDisabled.size > 0, C = x >= w, _ = rze(($) => {
      const N = $.target, L = [
        ...u.branches
      ].some((z) => z.contains(N));
      !C || L || (s == null ? void 0 : s($), a == null ? void 0 : a($), $.defaultPrevented || (l == null ? void 0 : l()));
    }, f), T = ize(($) => {
      const N = $.target;
      [
        ...u.branches
      ].some((z) => z.contains(N)) || (o == null ? void 0 : o($), a == null ? void 0 : a($), $.defaultPrevented || (l == null ? void 0 : l()));
    }, f);
    return K6e(($) => {
      x === u.layers.size - 1 && (i == null ? void 0 : i($), !$.defaultPrevented && l && ($.preventDefault(), l()));
    }, f), b.useEffect(() => {
      if (d)
        return r && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (F7 = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(d)), u.layers.add(d), B7(), () => {
          r && u.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = F7);
        };
    }, [
      d,
      f,
      r,
      u
    ]), b.useEffect(() => () => {
      d && (u.layers.delete(d), u.layersWithOutsidePointerEventsDisabled.delete(d), B7());
    }, [
      d,
      u
    ]), b.useEffect(() => {
      const $ = () => y({});
      return document.addEventListener(zR, $), () => document.removeEventListener(zR, $);
    }, []), b.createElement(lf.div, Yr({}, c, {
      ref: g,
      style: {
        pointerEvents: P ? C ? "auto" : "none" : void 0,
        ...t.style
      },
      onFocusCapture: Zh(t.onFocusCapture, T.onFocusCapture),
      onBlurCapture: Zh(t.onBlurCapture, T.onBlurCapture),
      onPointerDownCapture: Zh(t.onPointerDownCapture, _.onPointerDownCapture)
    }));
  });
  function rze(t, e = globalThis == null ? void 0 : globalThis.document) {
    const n = _d(t), r = b.useRef(false), i = b.useRef(() => {
    });
    return b.useEffect(() => {
      const s = (a) => {
        if (a.target && !r.current) {
          let c = function() {
            xte(J6e, n, l, {
              discrete: true
            });
          };
          const l = {
            originalEvent: a
          };
          a.pointerType === "touch" ? (e.removeEventListener("click", i.current), i.current = c, e.addEventListener("click", i.current, {
            once: true
          })) : c();
        }
        r.current = false;
      }, o = window.setTimeout(() => {
        e.addEventListener("pointerdown", s);
      }, 0);
      return () => {
        window.clearTimeout(o), e.removeEventListener("pointerdown", s), e.removeEventListener("click", i.current);
      };
    }, [
      e,
      n
    ]), {
      onPointerDownCapture: () => r.current = true
    };
  }
  function ize(t, e = globalThis == null ? void 0 : globalThis.document) {
    const n = _d(t), r = b.useRef(false);
    return b.useEffect(() => {
      const i = (s) => {
        s.target && !r.current && xte(eze, n, {
          originalEvent: s
        }, {
          discrete: false
        });
      };
      return e.addEventListener("focusin", i), () => e.removeEventListener("focusin", i);
    }, [
      e,
      n
    ]), {
      onFocusCapture: () => r.current = true,
      onBlurCapture: () => r.current = false
    };
  }
  function B7() {
    const t = new CustomEvent(zR);
    document.dispatchEvent(t);
  }
  function xte(t, e, n, { discrete: r }) {
    const i = n.originalEvent.target, s = new CustomEvent(t, {
      bubbles: false,
      cancelable: true,
      detail: n
    });
    e && i.addEventListener(t, e, {
      once: true
    }), r ? q6e(i, s) : i.dispatchEvent(s);
  }
  let xI = 0;
  function sze() {
    b.useEffect(() => {
      var t, e;
      const n = document.querySelectorAll("[data-radix-focus-guard]");
      return document.body.insertAdjacentElement("afterbegin", (t = n[0]) !== null && t !== void 0 ? t : U7()), document.body.insertAdjacentElement("beforeend", (e = n[1]) !== null && e !== void 0 ? e : U7()), xI++, () => {
        xI === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((r) => r.remove()), xI--;
      };
    }, []);
  }
  function U7() {
    const t = document.createElement("span");
    return t.setAttribute("data-radix-focus-guard", ""), t.tabIndex = 0, t.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none", t;
  }
  const bI = "focusScope.autoFocusOnMount", kI = "focusScope.autoFocusOnUnmount", V7 = {
    bubbles: false,
    cancelable: true
  }, oze = b.forwardRef((t, e) => {
    const { loop: n = false, trapped: r = false, onMountAutoFocus: i, onUnmountAutoFocus: s, ...o } = t, [a, l] = b.useState(null), c = _d(i), u = _d(s), d = b.useRef(null), h = _f(e, (g) => l(g)), f = b.useRef({
      paused: false,
      pause() {
        this.paused = true;
      },
      resume() {
        this.paused = false;
      }
    }).current;
    b.useEffect(() => {
      if (r) {
        let g = function(S) {
          if (f.paused || !a)
            return;
          const w = S.target;
          a.contains(w) ? d.current = w : Oh(d.current, {
            select: true
          });
        }, O = function(S) {
          f.paused || !a || a.contains(S.relatedTarget) || Oh(d.current, {
            select: true
          });
        };
        return document.addEventListener("focusin", g), document.addEventListener("focusout", O), () => {
          document.removeEventListener("focusin", g), document.removeEventListener("focusout", O);
        };
      }
    }, [
      r,
      a,
      f.paused
    ]), b.useEffect(() => {
      if (a) {
        W7.add(f);
        const g = document.activeElement;
        if (!a.contains(g)) {
          const S = new CustomEvent(bI, V7);
          a.addEventListener(bI, c), a.dispatchEvent(S), S.defaultPrevented || (aze(hze(bte(a)), {
            select: true
          }), document.activeElement === g && Oh(a));
        }
        return () => {
          a.removeEventListener(bI, c), setTimeout(() => {
            const S = new CustomEvent(kI, V7);
            a.addEventListener(kI, u), a.dispatchEvent(S), S.defaultPrevented || Oh(g ?? document.body, {
              select: true
            }), a.removeEventListener(kI, u), W7.remove(f);
          }, 0);
        };
      }
    }, [
      a,
      c,
      u,
      f
    ]);
    const y = b.useCallback((g) => {
      if (!n && !r || f.paused)
        return;
      const O = g.key === "Tab" && !g.altKey && !g.ctrlKey && !g.metaKey, S = document.activeElement;
      if (O && S) {
        const w = g.currentTarget, [x, P] = lze(w);
        x && P ? !g.shiftKey && S === P ? (g.preventDefault(), n && Oh(x, {
          select: true
        })) : g.shiftKey && S === x && (g.preventDefault(), n && Oh(P, {
          select: true
        })) : S === w && g.preventDefault();
      }
    }, [
      n,
      r,
      f.paused
    ]);
    return b.createElement(lf.div, Yr({
      tabIndex: -1
    }, o, {
      ref: h,
      onKeyDown: y
    }));
  });
  function aze(t, { select: e = false } = {}) {
    const n = document.activeElement;
    for (const r of t)
      if (Oh(r, {
        select: e
      }), document.activeElement !== n)
        return;
  }
  function lze(t) {
    const e = bte(t), n = X7(e, t), r = X7(e.reverse(), t);
    return [
      n,
      r
    ];
  }
  function bte(t) {
    const e = [], n = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
      acceptNode: (r) => {
        const i = r.tagName === "INPUT" && r.type === "hidden";
        return r.disabled || r.hidden || i ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
      }
    });
    for (; n.nextNode(); )
      e.push(n.currentNode);
    return e;
  }
  function X7(t, e) {
    for (const n of t)
      if (!cze(n, {
        upTo: e
      }))
        return n;
  }
  function cze(t, { upTo: e }) {
    if (getComputedStyle(t).visibility === "hidden")
      return true;
    for (; t; ) {
      if (e !== void 0 && t === e)
        return false;
      if (getComputedStyle(t).display === "none")
        return true;
      t = t.parentElement;
    }
    return false;
  }
  function uze(t) {
    return t instanceof HTMLInputElement && "select" in t;
  }
  function Oh(t, { select: e = false } = {}) {
    if (t && t.focus) {
      const n = document.activeElement;
      t.focus({
        preventScroll: true
      }), t !== n && uze(t) && e && t.select();
    }
  }
  const W7 = dze();
  function dze() {
    let t = [];
    return {
      add(e) {
        const n = t[0];
        e !== n && (n == null ? void 0 : n.pause()), t = Z7(t, e), t.unshift(e);
      },
      remove(e) {
        var n;
        t = Z7(t, e), (n = t[0]) === null || n === void 0 || n.resume();
      }
    };
  }
  function Z7(t, e) {
    const n = [
      ...t
    ], r = n.indexOf(e);
    return r !== -1 && n.splice(r, 1), n;
  }
  function hze(t) {
    return t.filter((e) => e.tagName !== "A");
  }
  const Ku = (globalThis == null ? void 0 : globalThis.document) ? b.useLayoutEffect : () => {
  }, fze = UD["useId".toString()] || (() => {
  });
  let pze = 0;
  function gze(t) {
    const [e, n] = b.useState(fze());
    return Ku(() => {
      t || n((r) => r ?? String(pze++));
    }, [
      t
    ]), t || (e ? `radix-${e}` : "");
  }
  function Tf(t) {
    return t.split("-")[0];
  }
  function vS(t) {
    return t.split("-")[1];
  }
  function Dm(t) {
    return [
      "top",
      "bottom"
    ].includes(Tf(t)) ? "x" : "y";
  }
  function XL(t) {
    return t === "y" ? "height" : "width";
  }
  function H7(t, e, n) {
    let { reference: r, floating: i } = t;
    const s = r.x + r.width / 2 - i.width / 2, o = r.y + r.height / 2 - i.height / 2, a = Dm(e), l = XL(a), c = r[l] / 2 - i[l] / 2, u = a === "x";
    let d;
    switch (Tf(e)) {
      case "top":
        d = {
          x: s,
          y: r.y - i.height
        };
        break;
      case "bottom":
        d = {
          x: s,
          y: r.y + r.height
        };
        break;
      case "right":
        d = {
          x: r.x + r.width,
          y: o
        };
        break;
      case "left":
        d = {
          x: r.x - i.width,
          y: o
        };
        break;
      default:
        d = {
          x: r.x,
          y: r.y
        };
    }
    switch (vS(e)) {
      case "start":
        d[a] -= c * (n && u ? -1 : 1);
        break;
      case "end":
        d[a] += c * (n && u ? -1 : 1);
    }
    return d;
  }
  const mze = async (t, e, n) => {
    const { placement: r = "bottom", strategy: i = "absolute", middleware: s = [], platform: o } = n, a = await (o.isRTL == null ? void 0 : o.isRTL(e));
    let l = await o.getElementRects({
      reference: t,
      floating: e,
      strategy: i
    }), { x: c, y: u } = H7(l, r, a), d = r, h = {}, f = 0;
    for (let y = 0; y < s.length; y++) {
      const { name: g, fn: O } = s[y], { x: S, y: w, data: x, reset: P } = await O({
        x: c,
        y: u,
        initialPlacement: r,
        placement: d,
        strategy: i,
        middlewareData: h,
        rects: l,
        platform: o,
        elements: {
          reference: t,
          floating: e
        }
      });
      c = S ?? c, u = w ?? u, h = {
        ...h,
        [g]: {
          ...h[g],
          ...x
        }
      }, P && f <= 50 && (f++, typeof P == "object" && (P.placement && (d = P.placement), P.rects && (l = P.rects === true ? await o.getElementRects({
        reference: t,
        floating: e,
        strategy: i
      }) : P.rects), { x: c, y: u } = H7(l, d, a)), y = -1);
    }
    return {
      x: c,
      y: u,
      placement: d,
      strategy: i,
      middlewareData: h
    };
  };
  function kte(t) {
    return typeof t != "number" ? function(e) {
      return {
        top: 0,
        right: 0,
        bottom: 0,
        left: 0,
        ...e
      };
    }(t) : {
      top: t,
      right: t,
      bottom: t,
      left: t
    };
  }
  function Yk(t) {
    return {
      ...t,
      top: t.y,
      left: t.x,
      right: t.x + t.width,
      bottom: t.y + t.height
    };
  }
  async function sO(t, e) {
    var n;
    e === void 0 && (e = {});
    const { x: r, y: i, platform: s, rects: o, elements: a, strategy: l } = t, { boundary: c = "clippingAncestors", rootBoundary: u = "viewport", elementContext: d = "floating", altBoundary: h = false, padding: f = 0 } = e, y = kte(f), g = a[h ? d === "floating" ? "reference" : "floating" : d], O = Yk(await s.getClippingRect({
      element: (n = await (s.isElement == null ? void 0 : s.isElement(g))) == null || n ? g : g.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(a.floating)),
      boundary: c,
      rootBoundary: u,
      strategy: l
    })), S = Yk(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
      rect: d === "floating" ? {
        ...o.floating,
        x: r,
        y: i
      } : o.reference,
      offsetParent: await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(a.floating)),
      strategy: l
    }) : o[d]);
    return {
      top: O.top - S.top + y.top,
      bottom: S.bottom - O.bottom + y.bottom,
      left: O.left - S.left + y.left,
      right: S.right - O.right + y.right
    };
  }
  const yze = Math.min, Sh = Math.max;
  function FR(t, e, n) {
    return Sh(t, yze(e, n));
  }
  const Y7 = (t) => ({
    name: "arrow",
    options: t,
    async fn(e) {
      const { element: n, padding: r = 0 } = t ?? {}, { x: i, y: s, placement: o, rects: a, platform: l } = e;
      if (n == null)
        return {};
      const c = kte(r), u = {
        x: i,
        y: s
      }, d = Dm(o), h = vS(o), f = XL(d), y = await l.getDimensions(n), g = d === "y" ? "top" : "left", O = d === "y" ? "bottom" : "right", S = a.reference[f] + a.reference[d] - u[d] - a.floating[f], w = u[d] - a.reference[d], x = await (l.getOffsetParent == null ? void 0 : l.getOffsetParent(n));
      let P = x ? d === "y" ? x.clientHeight || 0 : x.clientWidth || 0 : 0;
      P === 0 && (P = a.floating[f]);
      const C = S / 2 - w / 2, _ = c[g], T = P - y[f] - c[O], $ = P / 2 - y[f] / 2 + C, N = FR(_, $, T), L = (h === "start" ? c[g] : c[O]) > 0 && $ !== N && a.reference[f] <= a.floating[f];
      return {
        [d]: u[d] - (L ? $ < _ ? _ - $ : T - $ : 0),
        data: {
          [d]: N,
          centerOffset: $ - N
        }
      };
    }
  }), vze = {
    left: "right",
    right: "left",
    bottom: "top",
    top: "bottom"
  };
  function Gk(t) {
    return t.replace(/left|right|bottom|top/g, (e) => vze[e]);
  }
  function Oze(t, e, n) {
    n === void 0 && (n = false);
    const r = vS(t), i = Dm(t), s = XL(i);
    let o = i === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
    return e.reference[s] > e.floating[s] && (o = Gk(o)), {
      main: o,
      cross: Gk(o)
    };
  }
  const Sze = {
    start: "end",
    end: "start"
  };
  function G7(t) {
    return t.replace(/start|end/g, (e) => Sze[e]);
  }
  const Pte = [
    "top",
    "right",
    "bottom",
    "left"
  ];
  Pte.reduce((t, e) => t.concat(e, e + "-start", e + "-end"), []);
  const wze = function(t) {
    return t === void 0 && (t = {}), {
      name: "flip",
      options: t,
      async fn(e) {
        var n;
        const { placement: r, middlewareData: i, rects: s, initialPlacement: o, platform: a, elements: l } = e, { mainAxis: c = true, crossAxis: u = true, fallbackPlacements: d, fallbackStrategy: h = "bestFit", flipAlignment: f = true, ...y } = t, g = Tf(r), O = d || (g === o || !f ? [
          Gk(o)
        ] : function($) {
          const N = Gk($);
          return [
            G7($),
            N,
            G7(N)
          ];
        }(o)), S = [
          o,
          ...O
        ], w = await sO(e, y), x = [];
        let P = ((n = i.flip) == null ? void 0 : n.overflows) || [];
        if (c && x.push(w[g]), u) {
          const { main: $, cross: N } = Oze(r, s, await (a.isRTL == null ? void 0 : a.isRTL(l.floating)));
          x.push(w[$], w[N]);
        }
        if (P = [
          ...P,
          {
            placement: r,
            overflows: x
          }
        ], !x.every(($) => $ <= 0)) {
          var C, _;
          const $ = ((C = (_ = i.flip) == null ? void 0 : _.index) != null ? C : 0) + 1, N = S[$];
          if (N)
            return {
              data: {
                index: $,
                overflows: P
              },
              reset: {
                placement: N
              }
            };
          let L = "bottom";
          switch (h) {
            case "bestFit": {
              var T;
              const z = (T = P.map((M) => [
                M,
                M.overflows.filter((R) => R > 0).reduce((R, F) => R + F, 0)
              ]).sort((M, R) => M[1] - R[1])[0]) == null ? void 0 : T[0].placement;
              z && (L = z);
              break;
            }
            case "initialPlacement":
              L = o;
          }
          if (r !== L)
            return {
              reset: {
                placement: L
              }
            };
        }
        return {};
      }
    };
  };
  function q7(t, e) {
    return {
      top: t.top - e.height,
      right: t.right - e.width,
      bottom: t.bottom - e.height,
      left: t.left - e.width
    };
  }
  function K7(t) {
    return Pte.some((e) => t[e] >= 0);
  }
  const xze = function(t) {
    let { strategy: e = "referenceHidden", ...n } = t === void 0 ? {} : t;
    return {
      name: "hide",
      async fn(r) {
        const { rects: i } = r;
        switch (e) {
          case "referenceHidden": {
            const s = q7(await sO(r, {
              ...n,
              elementContext: "reference"
            }), i.reference);
            return {
              data: {
                referenceHiddenOffsets: s,
                referenceHidden: K7(s)
              }
            };
          }
          case "escaped": {
            const s = q7(await sO(r, {
              ...n,
              altBoundary: true
            }), i.floating);
            return {
              data: {
                escapedOffsets: s,
                escaped: K7(s)
              }
            };
          }
          default:
            return {};
        }
      }
    };
  }, bze = function(t) {
    return t === void 0 && (t = 0), {
      name: "offset",
      options: t,
      async fn(e) {
        const { x: n, y: r } = e, i = await async function(s, o) {
          const { placement: a, platform: l, elements: c } = s, u = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), d = Tf(a), h = vS(a), f = Dm(a) === "x", y = [
            "left",
            "top"
          ].includes(d) ? -1 : 1, g = u && f ? -1 : 1, O = typeof o == "function" ? o(s) : o;
          let { mainAxis: S, crossAxis: w, alignmentAxis: x } = typeof O == "number" ? {
            mainAxis: O,
            crossAxis: 0,
            alignmentAxis: null
          } : {
            mainAxis: 0,
            crossAxis: 0,
            alignmentAxis: null,
            ...O
          };
          return h && typeof x == "number" && (w = h === "end" ? -1 * x : x), f ? {
            x: w * g,
            y: S * y
          } : {
            x: S * y,
            y: w * g
          };
        }(e, t);
        return {
          x: n + i.x,
          y: r + i.y,
          data: i
        };
      }
    };
  };
  function Cte(t) {
    return t === "x" ? "y" : "x";
  }
  const kze = function(t) {
    return t === void 0 && (t = {}), {
      name: "shift",
      options: t,
      async fn(e) {
        const { x: n, y: r, placement: i } = e, { mainAxis: s = true, crossAxis: o = false, limiter: a = {
          fn: (O) => {
            let { x: S, y: w } = O;
            return {
              x: S,
              y: w
            };
          }
        }, ...l } = t, c = {
          x: n,
          y: r
        }, u = await sO(e, l), d = Dm(Tf(i)), h = Cte(d);
        let f = c[d], y = c[h];
        if (s) {
          const O = d === "y" ? "bottom" : "right";
          f = FR(f + u[d === "y" ? "top" : "left"], f, f - u[O]);
        }
        if (o) {
          const O = h === "y" ? "bottom" : "right";
          y = FR(y + u[h === "y" ? "top" : "left"], y, y - u[O]);
        }
        const g = a.fn({
          ...e,
          [d]: f,
          [h]: y
        });
        return {
          ...g,
          data: {
            x: g.x - n,
            y: g.y - r
          }
        };
      }
    };
  }, Pze = function(t) {
    return t === void 0 && (t = {}), {
      options: t,
      fn(e) {
        const { x: n, y: r, placement: i, rects: s, middlewareData: o } = e, { offset: a = 0, mainAxis: l = true, crossAxis: c = true } = t, u = {
          x: n,
          y: r
        }, d = Dm(i), h = Cte(d);
        let f = u[d], y = u[h];
        const g = typeof a == "function" ? a({
          ...s,
          placement: i
        }) : a, O = typeof g == "number" ? {
          mainAxis: g,
          crossAxis: 0
        } : {
          mainAxis: 0,
          crossAxis: 0,
          ...g
        };
        if (l) {
          const C = d === "y" ? "height" : "width", _ = s.reference[d] - s.floating[C] + O.mainAxis, T = s.reference[d] + s.reference[C] - O.mainAxis;
          f < _ ? f = _ : f > T && (f = T);
        }
        if (c) {
          var S, w, x, P;
          const C = d === "y" ? "width" : "height", _ = [
            "top",
            "left"
          ].includes(Tf(i)), T = s.reference[h] - s.floating[C] + (_ && (S = (w = o.offset) == null ? void 0 : w[h]) != null ? S : 0) + (_ ? 0 : O.crossAxis), $ = s.reference[h] + s.reference[C] + (_ ? 0 : (x = (P = o.offset) == null ? void 0 : P[h]) != null ? x : 0) - (_ ? O.crossAxis : 0);
          y < T ? y = T : y > $ && (y = $);
        }
        return {
          [d]: f,
          [h]: y
        };
      }
    };
  }, Cze = function(t) {
    return t === void 0 && (t = {}), {
      name: "size",
      options: t,
      async fn(e) {
        const { placement: n, rects: r, platform: i, elements: s } = e, { apply: o, ...a } = t, l = await sO(e, a), c = Tf(n), u = vS(n);
        let d, h;
        c === "top" || c === "bottom" ? (d = c, h = u === (await (i.isRTL == null ? void 0 : i.isRTL(s.floating)) ? "start" : "end") ? "left" : "right") : (h = c, d = u === "end" ? "top" : "bottom");
        const f = Sh(l.left, 0), y = Sh(l.right, 0), g = Sh(l.top, 0), O = Sh(l.bottom, 0), S = {
          availableHeight: r.floating.height - ([
            "left",
            "right"
          ].includes(n) ? 2 * (g !== 0 || O !== 0 ? g + O : Sh(l.top, l.bottom)) : l[d]),
          availableWidth: r.floating.width - ([
            "top",
            "bottom"
          ].includes(n) ? 2 * (f !== 0 || y !== 0 ? f + y : Sh(l.left, l.right)) : l[h])
        }, w = await i.getDimensions(s.floating);
        o == null ? void 0 : o({
          ...e,
          ...S
        });
        const x = await i.getDimensions(s.floating);
        return w.width !== x.width || w.height !== x.height ? {
          reset: {
            rects: true
          }
        } : {};
      }
    };
  };
  function _te(t) {
    return t && t.document && t.location && t.alert && t.setInterval;
  }
  function au(t) {
    if (t == null)
      return window;
    if (!_te(t)) {
      const e = t.ownerDocument;
      return e && e.defaultView || window;
    }
    return t;
  }
  function OS(t) {
    return au(t).getComputedStyle(t);
  }
  function Qc(t) {
    return _te(t) ? "" : t ? (t.nodeName || "").toLowerCase() : "";
  }
  function Tte() {
    const t = navigator.userAgentData;
    return t != null && t.brands ? t.brands.map((e) => e.brand + "/" + e.version).join(" ") : navigator.userAgent;
  }
  function Bl(t) {
    return t instanceof au(t).HTMLElement;
  }
  function Td(t) {
    return t instanceof au(t).Element;
  }
  function WL(t) {
    return typeof ShadowRoot > "u" ? false : t instanceof au(t).ShadowRoot || t instanceof ShadowRoot;
  }
  function u2(t) {
    const { overflow: e, overflowX: n, overflowY: r } = OS(t);
    return /auto|scroll|overlay|hidden/.test(e + r + n);
  }
  function _ze(t) {
    return [
      "table",
      "td",
      "th"
    ].includes(Qc(t));
  }
  function J7(t) {
    const e = /firefox/i.test(Tte()), n = OS(t);
    return n.transform !== "none" || n.perspective !== "none" || n.contain === "paint" || [
      "transform",
      "perspective"
    ].includes(n.willChange) || e && n.willChange === "filter" || e && !!n.filter && n.filter !== "none";
  }
  function Ete() {
    return !/^((?!chrome|android).)*safari/i.test(Tte());
  }
  const e9 = Math.min, ev = Math.max, qk = Math.round;
  function zc(t, e, n) {
    var r, i, s, o;
    e === void 0 && (e = false), n === void 0 && (n = false);
    const a = t.getBoundingClientRect();
    let l = 1, c = 1;
    e && Bl(t) && (l = t.offsetWidth > 0 && qk(a.width) / t.offsetWidth || 1, c = t.offsetHeight > 0 && qk(a.height) / t.offsetHeight || 1);
    const u = Td(t) ? au(t) : window, d = !Ete() && n, h = (a.left + (d && (r = (i = u.visualViewport) == null ? void 0 : i.offsetLeft) != null ? r : 0)) / l, f = (a.top + (d && (s = (o = u.visualViewport) == null ? void 0 : o.offsetTop) != null ? s : 0)) / c, y = a.width / l, g = a.height / c;
    return {
      width: y,
      height: g,
      top: f,
      right: h + y,
      bottom: f + g,
      left: h,
      x: h,
      y: f
    };
  }
  function yd(t) {
    return (e = t, (e instanceof au(e).Node ? t.ownerDocument : t.document) || window.document).documentElement;
    var e;
  }
  function d2(t) {
    return Td(t) ? {
      scrollLeft: t.scrollLeft,
      scrollTop: t.scrollTop
    } : {
      scrollLeft: t.pageXOffset,
      scrollTop: t.pageYOffset
    };
  }
  function Ite(t) {
    return zc(yd(t)).left + d2(t).scrollLeft;
  }
  function Tze(t, e, n) {
    const r = Bl(e), i = yd(e), s = zc(t, r && function(l) {
      const c = zc(l);
      return qk(c.width) !== l.offsetWidth || qk(c.height) !== l.offsetHeight;
    }(e), n === "fixed");
    let o = {
      scrollLeft: 0,
      scrollTop: 0
    };
    const a = {
      x: 0,
      y: 0
    };
    if (r || !r && n !== "fixed")
      if ((Qc(e) !== "body" || u2(i)) && (o = d2(e)), Bl(e)) {
        const l = zc(e, true);
        a.x = l.x + e.clientLeft, a.y = l.y + e.clientTop;
      } else
        i && (a.x = Ite(i));
    return {
      x: s.left + o.scrollLeft - a.x,
      y: s.top + o.scrollTop - a.y,
      width: s.width,
      height: s.height
    };
  }
  function $te(t) {
    return Qc(t) === "html" ? t : t.assignedSlot || t.parentNode || (WL(t) ? t.host : null) || yd(t);
  }
  function t9(t) {
    return Bl(t) && getComputedStyle(t).position !== "fixed" ? t.offsetParent : null;
  }
  function BR(t) {
    const e = au(t);
    let n = t9(t);
    for (; n && _ze(n) && getComputedStyle(n).position === "static"; )
      n = t9(n);
    return n && (Qc(n) === "html" || Qc(n) === "body" && getComputedStyle(n).position === "static" && !J7(n)) ? e : n || function(r) {
      let i = $te(r);
      for (WL(i) && (i = i.host); Bl(i) && ![
        "html",
        "body"
      ].includes(Qc(i)); ) {
        if (J7(i))
          return i;
        i = i.parentNode;
      }
      return null;
    }(t) || e;
  }
  function n9(t) {
    if (Bl(t))
      return {
        width: t.offsetWidth,
        height: t.offsetHeight
      };
    const e = zc(t);
    return {
      width: e.width,
      height: e.height
    };
  }
  function Ate(t) {
    const e = $te(t);
    return [
      "html",
      "body",
      "#document"
    ].includes(Qc(e)) ? t.ownerDocument.body : Bl(e) && u2(e) ? e : Ate(e);
  }
  function Kk(t, e) {
    var n;
    e === void 0 && (e = []);
    const r = Ate(t), i = r === ((n = t.ownerDocument) == null ? void 0 : n.body), s = au(r), o = i ? [
      s
    ].concat(s.visualViewport || [], u2(r) ? r : []) : r, a = e.concat(o);
    return i ? a : a.concat(Kk(o));
  }
  function r9(t, e, n) {
    return e === "viewport" ? Yk(function(r, i) {
      const s = au(r), o = yd(r), a = s.visualViewport;
      let l = o.clientWidth, c = o.clientHeight, u = 0, d = 0;
      if (a) {
        l = a.width, c = a.height;
        const h = Ete();
        (h || !h && i === "fixed") && (u = a.offsetLeft, d = a.offsetTop);
      }
      return {
        width: l,
        height: c,
        x: u,
        y: d
      };
    }(t, n)) : Td(e) ? function(r, i) {
      const s = zc(r, false, i === "fixed"), o = s.top + r.clientTop, a = s.left + r.clientLeft;
      return {
        top: o,
        left: a,
        x: a,
        y: o,
        right: a + r.clientWidth,
        bottom: o + r.clientHeight,
        width: r.clientWidth,
        height: r.clientHeight
      };
    }(e, n) : Yk(function(r) {
      var i;
      const s = yd(r), o = d2(r), a = (i = r.ownerDocument) == null ? void 0 : i.body, l = ev(s.scrollWidth, s.clientWidth, a ? a.scrollWidth : 0, a ? a.clientWidth : 0), c = ev(s.scrollHeight, s.clientHeight, a ? a.scrollHeight : 0, a ? a.clientHeight : 0);
      let u = -o.scrollLeft + Ite(r);
      const d = -o.scrollTop;
      return OS(a || s).direction === "rtl" && (u += ev(s.clientWidth, a ? a.clientWidth : 0) - l), {
        width: l,
        height: c,
        x: u,
        y: d
      };
    }(yd(t)));
  }
  function Eze(t) {
    const e = Kk(t), n = [
      "absolute",
      "fixed"
    ].includes(OS(t).position) && Bl(t) ? BR(t) : t;
    return Td(n) ? e.filter((r) => Td(r) && function(i, s) {
      const o = s.getRootNode == null ? void 0 : s.getRootNode();
      if (i.contains(s))
        return true;
      if (o && WL(o)) {
        let a = s;
        do {
          if (a && i === a)
            return true;
          a = a.parentNode || a.host;
        } while (a);
      }
      return false;
    }(r, n) && Qc(r) !== "body") : [];
  }
  const Ize = {
    getClippingRect: function(t) {
      let { element: e, boundary: n, rootBoundary: r, strategy: i } = t;
      const s = [
        ...n === "clippingAncestors" ? Eze(e) : [].concat(n),
        r
      ], o = s[0], a = s.reduce((l, c) => {
        const u = r9(e, c, i);
        return l.top = ev(u.top, l.top), l.right = e9(u.right, l.right), l.bottom = e9(u.bottom, l.bottom), l.left = ev(u.left, l.left), l;
      }, r9(e, o, i));
      return {
        width: a.right - a.left,
        height: a.bottom - a.top,
        x: a.left,
        y: a.top
      };
    },
    convertOffsetParentRelativeRectToViewportRelativeRect: function(t) {
      let { rect: e, offsetParent: n, strategy: r } = t;
      const i = Bl(n), s = yd(n);
      if (n === s)
        return e;
      let o = {
        scrollLeft: 0,
        scrollTop: 0
      };
      const a = {
        x: 0,
        y: 0
      };
      if ((i || !i && r !== "fixed") && ((Qc(n) !== "body" || u2(s)) && (o = d2(n)), Bl(n))) {
        const l = zc(n, true);
        a.x = l.x + n.clientLeft, a.y = l.y + n.clientTop;
      }
      return {
        ...e,
        x: e.x - o.scrollLeft + a.x,
        y: e.y - o.scrollTop + a.y
      };
    },
    isElement: Td,
    getDimensions: n9,
    getOffsetParent: BR,
    getDocumentElement: yd,
    getElementRects: (t) => {
      let { reference: e, floating: n, strategy: r } = t;
      return {
        reference: Tze(e, BR(n), r),
        floating: {
          ...n9(n),
          x: 0,
          y: 0
        }
      };
    },
    getClientRects: (t) => Array.from(t.getClientRects()),
    isRTL: (t) => OS(t).direction === "rtl"
  };
  function $ze(t, e, n, r) {
    r === void 0 && (r = {});
    const { ancestorScroll: i = true, ancestorResize: s = true, elementResize: o = true, animationFrame: a = false } = r, l = i && !a, c = s && !a, u = l || c ? [
      ...Td(t) ? Kk(t) : [],
      ...Kk(e)
    ] : [];
    u.forEach((y) => {
      l && y.addEventListener("scroll", n, {
        passive: true
      }), c && y.addEventListener("resize", n);
    });
    let d, h = null;
    if (o) {
      let y = true;
      h = new ResizeObserver(() => {
        y || n(), y = false;
      }), Td(t) && !a && h.observe(t), h.observe(e);
    }
    let f = a ? zc(t) : null;
    return a && function y() {
      const g = zc(t);
      !f || g.x === f.x && g.y === f.y && g.width === f.width && g.height === f.height || n(), f = g, d = requestAnimationFrame(y);
    }(), n(), () => {
      var y;
      u.forEach((g) => {
        l && g.removeEventListener("scroll", n), c && g.removeEventListener("resize", n);
      }), (y = h) == null || y.disconnect(), h = null, a && cancelAnimationFrame(d);
    };
  }
  const Aze = (t, e, n) => mze(t, e, {
    platform: Ize,
    ...n
  });
  var UR = typeof document < "u" ? b.useLayoutEffect : b.useEffect;
  function VR(t, e) {
    if (t === e)
      return true;
    if (typeof t != typeof e)
      return false;
    if (typeof t == "function" && t.toString() === e.toString())
      return true;
    let n, r, i;
    if (t && e && typeof t == "object") {
      if (Array.isArray(t)) {
        if (n = t.length, n != e.length)
          return false;
        for (r = n; r-- !== 0; )
          if (!VR(t[r], e[r]))
            return false;
        return true;
      }
      if (i = Object.keys(t), n = i.length, n !== Object.keys(e).length)
        return false;
      for (r = n; r-- !== 0; )
        if (!Object.prototype.hasOwnProperty.call(e, i[r]))
          return false;
      for (r = n; r-- !== 0; ) {
        const s = i[r];
        if (!(s === "_owner" && t.$$typeof) && !VR(t[s], e[s]))
          return false;
      }
      return true;
    }
    return t !== t && e !== e;
  }
  function Rze(t) {
    const e = b.useRef(t);
    return UR(() => {
      e.current = t;
    }), e;
  }
  function Mze(t) {
    let { middleware: e, placement: n = "bottom", strategy: r = "absolute", whileElementsMounted: i } = t === void 0 ? {} : t;
    const s = b.useRef(null), o = b.useRef(null), a = Rze(i), l = b.useRef(null), [c, u] = b.useState({
      x: null,
      y: null,
      strategy: r,
      placement: n,
      middlewareData: {}
    }), [d, h] = b.useState(e);
    VR(d == null ? void 0 : d.map((x) => {
      let { options: P } = x;
      return P;
    }), e == null ? void 0 : e.map((x) => {
      let { options: P } = x;
      return P;
    })) || h(e);
    const f = b.useCallback(() => {
      !s.current || !o.current || Aze(s.current, o.current, {
        middleware: d,
        placement: n,
        strategy: r
      }).then((x) => {
        y.current && jd.flushSync(() => {
          u(x);
        });
      });
    }, [
      d,
      n,
      r
    ]);
    UR(() => {
      y.current && f();
    }, [
      f
    ]);
    const y = b.useRef(false);
    UR(() => (y.current = true, () => {
      y.current = false;
    }), []);
    const g = b.useCallback(() => {
      if (typeof l.current == "function" && (l.current(), l.current = null), s.current && o.current)
        if (a.current) {
          const x = a.current(s.current, o.current, f);
          l.current = x;
        } else
          f();
    }, [
      f,
      a
    ]), O = b.useCallback((x) => {
      s.current = x, g();
    }, [
      g
    ]), S = b.useCallback((x) => {
      o.current = x, g();
    }, [
      g
    ]), w = b.useMemo(() => ({
      reference: s,
      floating: o
    }), []);
    return b.useMemo(() => ({
      ...c,
      update: f,
      refs: w,
      reference: O,
      floating: S
    }), [
      c,
      f,
      w,
      O,
      S
    ]);
  }
  const Dze = (t) => {
    const { element: e, padding: n } = t;
    function r(i) {
      return Object.prototype.hasOwnProperty.call(i, "current");
    }
    return {
      name: "arrow",
      options: t,
      fn(i) {
        return r(e) ? e.current != null ? Y7({
          element: e.current,
          padding: n
        }).fn(i) : {} : e ? Y7({
          element: e,
          padding: n
        }).fn(i) : {};
      }
    };
  };
  function Lze(t) {
    const [e, n] = b.useState(void 0);
    return Ku(() => {
      if (t) {
        n({
          width: t.offsetWidth,
          height: t.offsetHeight
        });
        const r = new ResizeObserver((i) => {
          if (!Array.isArray(i) || !i.length)
            return;
          const s = i[0];
          let o, a;
          if ("borderBoxSize" in s) {
            const l = s.borderBoxSize, c = Array.isArray(l) ? l[0] : l;
            o = c.inlineSize, a = c.blockSize;
          } else
            o = t.offsetWidth, a = t.offsetHeight;
          n({
            width: o,
            height: a
          });
        });
        return r.observe(t, {
          box: "border-box"
        }), () => r.unobserve(t);
      } else
        n(void 0);
    }, [
      t
    ]), e;
  }
  const Rte = "Popper", [ZL, Mte] = wte(Rte), [jze, Dte] = ZL(Rte), Nze = (t) => {
    const { __scopePopper: e, children: n } = t, [r, i] = b.useState(null);
    return b.createElement(jze, {
      scope: e,
      anchor: r,
      onAnchorChange: i
    }, n);
  }, Qze = "PopperAnchor", zze = b.forwardRef((t, e) => {
    const { __scopePopper: n, virtualRef: r, ...i } = t, s = Dte(Qze, n), o = b.useRef(null), a = _f(e, o);
    return b.useEffect(() => {
      s.onAnchorChange((r == null ? void 0 : r.current) || o.current);
    }), r ? null : b.createElement(lf.div, Yr({}, i, {
      ref: a
    }));
  }), Jk = "PopperContent", [Fze, tat] = ZL(Jk), [Bze, Uze] = ZL(Jk, {
    hasParent: false,
    positionUpdateFns: /* @__PURE__ */ new Set()
  }), Vze = b.forwardRef((t, e) => {
    var n, r, i, s, o, a, l, c;
    const { __scopePopper: u, side: d = "bottom", sideOffset: h = 0, align: f = "center", alignOffset: y = 0, arrowPadding: g = 0, collisionBoundary: O = [], collisionPadding: S = 0, sticky: w = "partial", hideWhenDetached: x = false, avoidCollisions: P = true, onPlaced: C, ..._ } = t, T = Dte(Jk, u), [$, N] = b.useState(null), L = _f(e, (Cs) => N(Cs)), [z, M] = b.useState(null), R = Lze(z), F = (n = R == null ? void 0 : R.width) !== null && n !== void 0 ? n : 0, Q = (r = R == null ? void 0 : R.height) !== null && r !== void 0 ? r : 0, X = d + (f !== "center" ? "-" + f : ""), Z = typeof S == "number" ? S : {
      top: 0,
      right: 0,
      bottom: 0,
      left: 0,
      ...S
    }, U = Array.isArray(O) ? O : [
      O
    ], H = U.length > 0, te = {
      padding: Z,
      boundary: U.filter(Wze),
      altBoundary: H
    }, { reference: se, floating: ae, strategy: _e3, x: Me, y: ke, placement: tt, middlewareData: it, update: pt } = Mze({
      strategy: "fixed",
      placement: X,
      whileElementsMounted: $ze,
      middleware: [
        bze({
          mainAxis: h + Q,
          alignmentAxis: y
        }),
        P ? kze({
          mainAxis: true,
          crossAxis: false,
          limiter: w === "partial" ? Pze() : void 0,
          ...te
        }) : void 0,
        P ? wze({
          ...te
        }) : void 0,
        Cze({
          ...te,
          apply: ({ elements: Cs, rects: cu, availableWidth: Ym, availableHeight: Kl }) => {
            const { width: Gm, height: yo } = cu.reference, Ri = Cs.floating.style;
            Ri.setProperty("--radix-popper-available-width", `${Ym}px`), Ri.setProperty("--radix-popper-available-height", `${Kl}px`), Ri.setProperty("--radix-popper-anchor-width", `${Gm}px`), Ri.setProperty("--radix-popper-anchor-height", `${yo}px`);
          }
        }),
        z ? Dze({
          element: z,
          padding: g
        }) : void 0,
        Zze({
          arrowWidth: F,
          arrowHeight: Q
        }),
        x ? xze({
          strategy: "referenceHidden"
        }) : void 0
      ].filter(Xze)
    });
    Ku(() => {
      se(T.anchor);
    }, [
      se,
      T.anchor
    ]);
    const kt = Me !== null && ke !== null, [Yt, Ar] = Lte(tt), Cn = _d(C);
    Ku(() => {
      kt && (Cn == null ? void 0 : Cn());
    }, [
      kt,
      Cn
    ]);
    const Vn = (i = it.arrow) === null || i === void 0 ? void 0 : i.x, Lt = (s = it.arrow) === null || s === void 0 ? void 0 : s.y, tr = ((o = it.arrow) === null || o === void 0 ? void 0 : o.centerOffset) !== 0, [ql, nr] = b.useState();
    Ku(() => {
      $ && nr(window.getComputedStyle($).zIndex);
    }, [
      $
    ]);
    const { hasParent: go, positionUpdateFns: mo } = Uze(Jk, u), Jr = !go;
    b.useLayoutEffect(() => {
      if (!Jr)
        return mo.add(pt), () => {
          mo.delete(pt);
        };
    }, [
      Jr,
      mo,
      pt
    ]), Ku(() => {
      Jr && kt && Array.from(mo).reverse().forEach((Cs) => requestAnimationFrame(Cs));
    }, [
      Jr,
      kt,
      mo
    ]);
    const ei = {
      "data-side": Yt,
      "data-align": Ar,
      ..._,
      ref: L,
      style: {
        ..._.style,
        animation: kt ? void 0 : "none",
        opacity: (a = it.hide) !== null && a !== void 0 && a.referenceHidden ? 0 : void 0
      }
    };
    return b.createElement("div", {
      ref: ae,
      "data-radix-popper-content-wrapper": "",
      style: {
        position: _e3,
        left: 0,
        top: 0,
        transform: kt ? `translate3d(${Math.round(Me)}px, ${Math.round(ke)}px, 0)` : "translate3d(0, -200%, 0)",
        minWidth: "max-content",
        zIndex: ql,
        "--radix-popper-transform-origin": [
          (l = it.transformOrigin) === null || l === void 0 ? void 0 : l.x,
          (c = it.transformOrigin) === null || c === void 0 ? void 0 : c.y
        ].join(" ")
      },
      dir: t.dir
    }, b.createElement(Fze, {
      scope: u,
      placedSide: Yt,
      onArrowChange: M,
      arrowX: Vn,
      arrowY: Lt,
      shouldHideArrow: tr
    }, Jr ? b.createElement(Bze, {
      scope: u,
      hasParent: true,
      positionUpdateFns: mo
    }, b.createElement(lf.div, ei)) : b.createElement(lf.div, ei)));
  });
  function Xze(t) {
    return t !== void 0;
  }
  function Wze(t) {
    return t !== null;
  }
  const Zze = (t) => ({
    name: "transformOrigin",
    options: t,
    fn(e) {
      var n, r, i, s, o;
      const { placement: a, rects: l, middlewareData: c } = e, d = ((n = c.arrow) === null || n === void 0 ? void 0 : n.centerOffset) !== 0, h = d ? 0 : t.arrowWidth, f = d ? 0 : t.arrowHeight, [y, g] = Lte(a), O = {
        start: "0%",
        center: "50%",
        end: "100%"
      }[g], S = ((r = (i = c.arrow) === null || i === void 0 ? void 0 : i.x) !== null && r !== void 0 ? r : 0) + h / 2, w = ((s = (o = c.arrow) === null || o === void 0 ? void 0 : o.y) !== null && s !== void 0 ? s : 0) + f / 2;
      let x = "", P = "";
      return y === "bottom" ? (x = d ? O : `${S}px`, P = `${-f}px`) : y === "top" ? (x = d ? O : `${S}px`, P = `${l.floating.height + f}px`) : y === "right" ? (x = `${-f}px`, P = d ? O : `${w}px`) : y === "left" && (x = `${l.floating.width + f}px`, P = d ? O : `${w}px`), {
        data: {
          x,
          y: P
        }
      };
    }
  });
  function Lte(t) {
    const [e, n = "center"] = t.split("-");
    return [
      e,
      n
    ];
  }
  const Hze = Nze, Yze = zze, Gze = Vze, qze = b.forwardRef((t, e) => {
    var n;
    const { container: r = globalThis == null || (n = globalThis.document) === null || n === void 0 ? void 0 : n.body, ...i } = t;
    return r ? qH.createPortal(b.createElement(lf.div, Yr({}, i, {
      ref: e
    })), r) : null;
  });
  function Kze(t, e) {
    return b.useReducer((n, r) => {
      const i = e[n][r];
      return i ?? n;
    }, t);
  }
  const HL = (t) => {
    const { present: e, children: n } = t, r = Jze(e), i = typeof n == "function" ? n({
      present: r.isPresent
    }) : b.Children.only(n), s = _f(r.ref, i.ref);
    return typeof n == "function" || r.isPresent ? b.cloneElement(i, {
      ref: s
    }) : null;
  };
  HL.displayName = "Presence";
  function Jze(t) {
    const [e, n] = b.useState(), r = b.useRef({}), i = b.useRef(t), s = b.useRef("none"), o = t ? "mounted" : "unmounted", [a, l] = Kze(o, {
      mounted: {
        UNMOUNT: "unmounted",
        ANIMATION_OUT: "unmountSuspended"
      },
      unmountSuspended: {
        MOUNT: "mounted",
        ANIMATION_END: "unmounted"
      },
      unmounted: {
        MOUNT: "mounted"
      }
    });
    return b.useEffect(() => {
      const c = Nw(r.current);
      s.current = a === "mounted" ? c : "none";
    }, [
      a
    ]), Ku(() => {
      const c = r.current, u = i.current;
      if (u !== t) {
        const h = s.current, f = Nw(c);
        t ? l("MOUNT") : f === "none" || (c == null ? void 0 : c.display) === "none" ? l("UNMOUNT") : l(u && h !== f ? "ANIMATION_OUT" : "UNMOUNT"), i.current = t;
      }
    }, [
      t,
      l
    ]), Ku(() => {
      if (e) {
        const c = (d) => {
          const f = Nw(r.current).includes(d.animationName);
          d.target === e && f && jd.flushSync(() => l("ANIMATION_END"));
        }, u = (d) => {
          d.target === e && (s.current = Nw(r.current));
        };
        return e.addEventListener("animationstart", u), e.addEventListener("animationcancel", c), e.addEventListener("animationend", c), () => {
          e.removeEventListener("animationstart", u), e.removeEventListener("animationcancel", c), e.removeEventListener("animationend", c);
        };
      } else
        l("ANIMATION_END");
    }, [
      e,
      l
    ]), {
      isPresent: [
        "mounted",
        "unmountSuspended"
      ].includes(a),
      ref: b.useCallback((c) => {
        c && (r.current = getComputedStyle(c)), n(c);
      }, [])
    };
  }
  function Nw(t) {
    return (t == null ? void 0 : t.animationName) || "none";
  }
  function e8e({ prop: t, defaultProp: e, onChange: n = () => {
  } }) {
    const [r, i] = t8e({
      defaultProp: e,
      onChange: n
    }), s = t !== void 0, o = s ? t : r, a = _d(n), l = b.useCallback((c) => {
      if (s) {
        const d = typeof c == "function" ? c(t) : c;
        d !== t && a(d);
      } else
        i(c);
    }, [
      s,
      t,
      i,
      a
    ]);
    return [
      o,
      l
    ];
  }
  function t8e({ defaultProp: t, onChange: e }) {
    const n = b.useState(t), [r] = n, i = b.useRef(r), s = _d(e);
    return b.useEffect(() => {
      i.current !== r && (s(r), i.current = r);
    }, [
      r,
      i,
      s
    ]), n;
  }
  var jte = pY(), PI = function() {
  }, h2 = b.forwardRef(function(t, e) {
    var n = b.useRef(null), r = b.useState({
      onScrollCapture: PI,
      onWheelCapture: PI,
      onTouchMoveCapture: PI
    }), i = r[0], s = r[1], o = t.forwardProps, a = t.children, l = t.className, c = t.removeScrollBar, u = t.enabled, d = t.shards, h = t.sideCar, f = t.noIsolation, y = t.inert, g = t.allowPinchZoom, O = t.as, S = O === void 0 ? "div" : O, w = Y3(t, [
      "forwardProps",
      "children",
      "className",
      "removeScrollBar",
      "enabled",
      "shards",
      "sideCar",
      "noIsolation",
      "inert",
      "allowPinchZoom",
      "as"
    ]), x = h, P = fY([
      n,
      e
    ]), C = pi(pi({}, w), i);
    return b.createElement(b.Fragment, null, u && b.createElement(x, {
      sideCar: jte,
      removeScrollBar: c,
      shards: d,
      noIsolation: f,
      inert: y,
      setCallbacks: s,
      allowPinchZoom: !!g,
      lockRef: n
    }), o ? b.cloneElement(b.Children.only(a), pi(pi({}, C), {
      ref: P
    })) : b.createElement(S, pi({}, C, {
      className: l,
      ref: P
    }), a));
  });
  h2.defaultProps = {
    enabled: true,
    removeScrollBar: true,
    inert: false
  };
  h2.classNames = {
    fullWidth: Z0,
    zeroRight: W0
  };
  var XR = false;
  if (typeof window < "u")
    try {
      var Qw = Object.defineProperty({}, "passive", {
        get: function() {
          return XR = true, true;
        }
      });
      window.addEventListener("test", Qw, Qw), window.removeEventListener("test", Qw, Qw);
    } catch {
      XR = false;
    }
  var bp = XR ? {
    passive: false
  } : false, n8e = function(t) {
    return t.tagName === "TEXTAREA";
  }, Nte = function(t, e) {
    var n = window.getComputedStyle(t);
    return n[e] !== "hidden" && !(n.overflowY === n.overflowX && !n8e(t) && n[e] === "visible");
  }, r8e = function(t) {
    return Nte(t, "overflowY");
  }, i8e = function(t) {
    return Nte(t, "overflowX");
  }, i9 = function(t, e) {
    var n = e;
    do {
      typeof ShadowRoot < "u" && n instanceof ShadowRoot && (n = n.host);
      var r = Qte(t, n);
      if (r) {
        var i = zte(t, n), s = i[1], o = i[2];
        if (s > o)
          return true;
      }
      n = n.parentNode;
    } while (n && n !== document.body);
    return false;
  }, s8e = function(t) {
    var e = t.scrollTop, n = t.scrollHeight, r = t.clientHeight;
    return [
      e,
      n,
      r
    ];
  }, o8e = function(t) {
    var e = t.scrollLeft, n = t.scrollWidth, r = t.clientWidth;
    return [
      e,
      n,
      r
    ];
  }, Qte = function(t, e) {
    return t === "v" ? r8e(e) : i8e(e);
  }, zte = function(t, e) {
    return t === "v" ? s8e(e) : o8e(e);
  }, a8e = function(t, e) {
    return t === "h" && e === "rtl" ? -1 : 1;
  }, l8e = function(t, e, n, r, i) {
    var s = a8e(t, window.getComputedStyle(e).direction), o = s * r, a = n.target, l = e.contains(a), c = false, u = o > 0, d = 0, h = 0;
    do {
      var f = zte(t, a), y = f[0], g = f[1], O = f[2], S = g - O - s * y;
      (y || S) && Qte(t, a) && (d += S, h += y), a = a.parentNode;
    } while (!l && a !== document.body || l && (e.contains(a) || e === a));
    return (u && (i && d === 0 || !i && o > d) || !u && (i && h === 0 || !i && -o > h)) && (c = true), c;
  }, zw = function(t) {
    return "changedTouches" in t ? [
      t.changedTouches[0].clientX,
      t.changedTouches[0].clientY
    ] : [
      0,
      0
    ];
  }, s9 = function(t) {
    return [
      t.deltaX,
      t.deltaY
    ];
  }, o9 = function(t) {
    return t && "current" in t ? t.current : t;
  }, c8e = function(t, e) {
    return t[0] === e[0] && t[1] === e[1];
  }, u8e = function(t) {
    return `
  .block-interactivity-`.concat(t, ` {pointer-events: none;}
  .allow-interactivity-`).concat(t, ` {pointer-events: all;}
`);
  }, d8e = 0, kp = [];
  function h8e(t) {
    var e = b.useRef([]), n = b.useRef([
      0,
      0
    ]), r = b.useRef(), i = b.useState(d8e++)[0], s = b.useState(function() {
      return G3();
    })[0], o = b.useRef(t);
    b.useEffect(function() {
      o.current = t;
    }, [
      t
    ]), b.useEffect(function() {
      if (t.inert) {
        document.body.classList.add("block-interactivity-".concat(i));
        var g = hY([
          t.lockRef.current
        ], (t.shards || []).map(o9), true).filter(Boolean);
        return g.forEach(function(O) {
          return O.classList.add("allow-interactivity-".concat(i));
        }), function() {
          document.body.classList.remove("block-interactivity-".concat(i)), g.forEach(function(O) {
            return O.classList.remove("allow-interactivity-".concat(i));
          });
        };
      }
    }, [
      t.inert,
      t.lockRef.current,
      t.shards
    ]);
    var a = b.useCallback(function(g, O) {
      if ("touches" in g && g.touches.length === 2)
        return !o.current.allowPinchZoom;
      var S = zw(g), w = n.current, x = "deltaX" in g ? g.deltaX : w[0] - S[0], P = "deltaY" in g ? g.deltaY : w[1] - S[1], C, _ = g.target, T = Math.abs(x) > Math.abs(P) ? "h" : "v";
      if ("touches" in g && T === "h" && _.type === "range")
        return false;
      var $ = i9(T, _);
      if (!$)
        return true;
      if ($ ? C = T : (C = T === "v" ? "h" : "v", $ = i9(T, _)), !$)
        return false;
      if (!r.current && "changedTouches" in g && (x || P) && (r.current = C), !C)
        return true;
      var N = r.current || C;
      return l8e(N, O, g, N === "h" ? x : P, true);
    }, []), l = b.useCallback(function(g) {
      var O = g;
      if (!(!kp.length || kp[kp.length - 1] !== s)) {
        var S = "deltaY" in O ? s9(O) : zw(O), w = e.current.filter(function(C) {
          return C.name === O.type && C.target === O.target && c8e(C.delta, S);
        })[0];
        if (w && w.should) {
          O.cancelable && O.preventDefault();
          return;
        }
        if (!w) {
          var x = (o.current.shards || []).map(o9).filter(Boolean).filter(function(C) {
            return C.contains(O.target);
          }), P = x.length > 0 ? a(O, x[0]) : !o.current.noIsolation;
          P && O.cancelable && O.preventDefault();
        }
      }
    }, []), c = b.useCallback(function(g, O, S, w) {
      var x = {
        name: g,
        delta: O,
        target: S,
        should: w
      };
      e.current.push(x), setTimeout(function() {
        e.current = e.current.filter(function(P) {
          return P !== x;
        });
      }, 1);
    }, []), u = b.useCallback(function(g) {
      n.current = zw(g), r.current = void 0;
    }, []), d = b.useCallback(function(g) {
      c(g.type, s9(g), g.target, a(g, t.lockRef.current));
    }, []), h = b.useCallback(function(g) {
      c(g.type, zw(g), g.target, a(g, t.lockRef.current));
    }, []);
    b.useEffect(function() {
      return kp.push(s), t.setCallbacks({
        onScrollCapture: d,
        onWheelCapture: d,
        onTouchMoveCapture: h
      }), document.addEventListener("wheel", l, bp), document.addEventListener("touchmove", l, bp), document.addEventListener("touchstart", u, bp), function() {
        kp = kp.filter(function(g) {
          return g !== s;
        }), document.removeEventListener("wheel", l, bp), document.removeEventListener("touchmove", l, bp), document.removeEventListener("touchstart", u, bp);
      };
    }, []);
    var f = t.removeScrollBar, y = t.inert;
    return b.createElement(b.Fragment, null, y ? b.createElement(s, {
      styles: u8e(i)
    }) : null, f ? b.createElement(vY, {
      gapMode: "margin"
    }) : null);
  }
  const f8e = mY(jte, h8e);
  var Fte = b.forwardRef(function(t, e) {
    return b.createElement(h2, pi({}, t, {
      ref: e,
      sideCar: f8e
    }));
  });
  Fte.classNames = h2.classNames;
  const p8e = Fte, Bte = "Popover", [Ute, nat] = wte(Bte, [
    Mte
  ]), YL = Mte(), [g8e, Lm] = Ute(Bte), m8e = (t) => {
    const { __scopePopover: e, children: n, open: r, defaultOpen: i, onOpenChange: s, modal: o = false } = t, a = YL(e), l = b.useRef(null), [c, u] = b.useState(false), [d = false, h] = e8e({
      prop: r,
      defaultProp: i,
      onChange: s
    });
    return b.createElement(Hze, a, b.createElement(g8e, {
      scope: e,
      contentId: gze(),
      triggerRef: l,
      open: d,
      onOpenChange: h,
      onOpenToggle: b.useCallback(() => h((f) => !f), [
        h
      ]),
      hasCustomAnchor: c,
      onCustomAnchorAdd: b.useCallback(() => u(true), []),
      onCustomAnchorRemove: b.useCallback(() => u(false), []),
      modal: o
    }, n));
  }, y8e = "PopoverTrigger", v8e = b.forwardRef((t, e) => {
    const { __scopePopover: n, ...r } = t, i = Lm(y8e, n), s = YL(n), o = _f(e, i.triggerRef), a = b.createElement(lf.button, Yr({
      type: "button",
      "aria-haspopup": "dialog",
      "aria-expanded": i.open,
      "aria-controls": i.contentId,
      "data-state": Wte(i.open)
    }, r, {
      ref: o,
      onClick: Zh(t.onClick, i.onOpenToggle)
    }));
    return i.hasCustomAnchor ? a : b.createElement(Yze, Yr({
      asChild: true
    }, s), a);
  }), Vte = "PopoverPortal", [O8e, S8e] = Ute(Vte, {
    forceMount: void 0
  }), w8e = (t) => {
    const { __scopePopover: e, forceMount: n, children: r, container: i } = t, s = Lm(Vte, e);
    return b.createElement(O8e, {
      scope: e,
      forceMount: n
    }, b.createElement(HL, {
      present: n || s.open
    }, b.createElement(qze, {
      asChild: true,
      container: i
    }, r)));
  }, oO = "PopoverContent", x8e = b.forwardRef((t, e) => {
    const n = S8e(oO, t.__scopePopover), { forceMount: r = n.forceMount, ...i } = t, s = Lm(oO, t.__scopePopover);
    return b.createElement(HL, {
      present: r || s.open
    }, s.modal ? b.createElement(b8e, Yr({}, i, {
      ref: e
    })) : b.createElement(k8e, Yr({}, i, {
      ref: e
    })));
  }), b8e = b.forwardRef((t, e) => {
    const n = Lm(oO, t.__scopePopover), r = b.useRef(null), i = _f(e, r), s = b.useRef(false);
    return b.useEffect(() => {
      const o = r.current;
      if (o)
        return OC(o);
    }, []), b.createElement(p8e, {
      as: VL,
      allowPinchZoom: true
    }, b.createElement(Xte, Yr({}, t, {
      ref: i,
      trapFocus: n.open,
      disableOutsidePointerEvents: true,
      onCloseAutoFocus: Zh(t.onCloseAutoFocus, (o) => {
        var a;
        o.preventDefault(), s.current || (a = n.triggerRef.current) === null || a === void 0 || a.focus();
      }),
      onPointerDownOutside: Zh(t.onPointerDownOutside, (o) => {
        const a = o.detail.originalEvent, l = a.button === 0 && a.ctrlKey === true, c = a.button === 2 || l;
        s.current = c;
      }, {
        checkForDefaultPrevented: false
      }),
      onFocusOutside: Zh(t.onFocusOutside, (o) => o.preventDefault(), {
        checkForDefaultPrevented: false
      })
    })));
  }), k8e = b.forwardRef((t, e) => {
    const n = Lm(oO, t.__scopePopover), r = b.useRef(false), i = b.useRef(false);
    return b.createElement(Xte, Yr({}, t, {
      ref: e,
      trapFocus: false,
      disableOutsidePointerEvents: false,
      onCloseAutoFocus: (s) => {
        var o;
        if ((o = t.onCloseAutoFocus) === null || o === void 0 || o.call(t, s), !s.defaultPrevented) {
          var a;
          r.current || (a = n.triggerRef.current) === null || a === void 0 || a.focus(), s.preventDefault();
        }
        r.current = false, i.current = false;
      },
      onInteractOutside: (s) => {
        var o, a;
        (o = t.onInteractOutside) === null || o === void 0 || o.call(t, s), s.defaultPrevented || (r.current = true, s.detail.originalEvent.type === "pointerdown" && (i.current = true));
        const l = s.target;
        ((a = n.triggerRef.current) === null || a === void 0 ? void 0 : a.contains(l)) && s.preventDefault(), s.detail.originalEvent.type === "focusin" && i.current && s.preventDefault();
      }
    }));
  }), Xte = b.forwardRef((t, e) => {
    const { __scopePopover: n, trapFocus: r, onOpenAutoFocus: i, onCloseAutoFocus: s, disableOutsidePointerEvents: o, onEscapeKeyDown: a, onPointerDownOutside: l, onFocusOutside: c, onInteractOutside: u, ...d } = t, h = Lm(oO, n), f = YL(n);
    return sze(), b.createElement(oze, {
      asChild: true,
      loop: true,
      trapped: r,
      onMountAutoFocus: i,
      onUnmountAutoFocus: s
    }, b.createElement(nze, {
      asChild: true,
      disableOutsidePointerEvents: o,
      onInteractOutside: u,
      onEscapeKeyDown: a,
      onPointerDownOutside: l,
      onFocusOutside: c,
      onDismiss: () => h.onOpenChange(false)
    }, b.createElement(Gze, Yr({
      "data-state": Wte(h.open),
      role: "dialog",
      id: h.contentId
    }, f, d, {
      ref: e,
      style: {
        ...d.style,
        "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-popover-content-available-width": "var(--radix-popper-available-width)",
        "--radix-popover-content-available-height": "var(--radix-popper-available-height)",
        "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
      }
    }))));
  });
  function Wte(t) {
    return t ? "open" : "closed";
  }
  const P8e = m8e, C8e = v8e, Zte = w8e, Hte = x8e, GL = ({ id: t, children: e, onOpenChange: n }) => {
    const [r, i] = Pf(t, n);
    return m.jsx(P8e, {
      onOpenChange: i,
      open: r,
      children: m.jsx("div", {
        className: "tlui-popover",
        children: e
      })
    });
  }, qL = ({ children: t, disabled: e, "data-testid": n }) => m.jsx(C8e, {
    "data-testid": n,
    disabled: e,
    asChild: true,
    dir: "ltr",
    children: t
  }), Yte = ({ side: t, children: e, align: n = "center", sideOffset: r = 8, alignOffset: i = 0 }) => {
    const s = Kr();
    return m.jsx(Zte, {
      dir: "ltr",
      container: s,
      children: m.jsx(Hte, {
        className: "tlui-popover__content",
        side: t,
        sideOffset: r,
        align: n,
        alignOffset: i,
        dir: "ltr",
        children: e
      })
    });
  }, Gte = b.memo(function() {
    const e = Tt(), n = Kr(), r = d6e(), i = sa();
    function s(o) {
      if (i && !o.readonlyOk)
        return null;
      switch (o.type) {
        case "item": {
          const { id: a, icon: l, label: c, kbd: u, onSelect: d } = o.actionItem;
          return m.jsx(Be, {
            className: "tlui-button-grid__button",
            "data-testid": `menu-item.${o.id}`,
            icon: l,
            title: c ? u ? `${e(c)} ${zl(u)}` : `${e(c)}` : u ? `${zl(u)}` : "",
            onClick: () => d("actions-menu"),
            disabled: o.disabled
          }, a);
        }
      }
    }
    return m.jsxs(GL, {
      id: "actions menu",
      children: [
        m.jsx(qL, {
          children: m.jsx(Be, {
            className: "tlui-menu__trigger",
            "data-testid": "main.action-menu",
            icon: "dots-vertical",
            title: e("actions-menu.title"),
            smallIcon: true
          })
        }),
        m.jsx(Zte, {
          dir: "ltr",
          container: n,
          children: m.jsx(Hte, {
            className: "tlui-popover__content",
            side: "bottom",
            dir: "ltr",
            sideOffset: 6,
            children: m.jsx("div", {
              className: "tlui-actions-menu tlui-button-grid__four",
              children: r.map(s)
            })
          })
        })
      ]
    });
  }), qte = Vt(function() {
    const e = ue(), n = $i(), r = Tt(), i = n.duplicate;
    return m.jsx(Be, {
      icon: i.icon,
      onClick: () => i.onSelect("quick-actions"),
      disabled: !(e.isIn("select") && e.selectedShapeIds.length > 0),
      title: `${r(i.label)} ${zl(i.kbd)}`,
      smallIcon: true
    });
  }), _8e = b.memo(function() {
    const e = Tt();
    return m.jsxs(Pd, {
      id: "main menu",
      children: [
        m.jsx(fS, {
          children: m.jsx(Be, {
            className: "tlui-menu__trigger",
            "data-testid": "main.menu",
            title: e("menu.title"),
            icon: "menu"
          })
        }),
        m.jsx(Cd, {
          alignOffset: 0,
          sideOffset: 6,
          children: m.jsx(T8e, {})
        })
      ]
    });
  });
  function T8e() {
    const t = ue(), e = Tt(), n = w6e(), r = oa(), i = sa();
    function s(o, a, l, c) {
      switch (a.type) {
        case "custom":
          return i && !a.readonlyOk ? null : a.id === "LANGUAGE_MENU" ? m.jsx(Ote, {}, "item") : null;
        case "group":
          return i && !a.readonlyOk ? null : m.jsx(jc, {
            size: c <= 1 ? "medium" : r < 3 || (l == null ? void 0 : l.type) === "submenu" && c > 2 ? "tiny" : "medium",
            children: a.children.map((u) => s(o, u, a, c + 1))
          }, a.id);
        case "submenu":
          return i && !a.readonlyOk ? null : m.jsxs(xL, {
            id: `main menu ${l ? l.id + " " : ""}${a.id}`,
            children: [
              m.jsx(bL, {
                label: a.label,
                "data-testid": `menu-item.${a.id}`
              }),
              m.jsx(kL, {
                sideOffset: -4,
                alignOffset: -1,
                children: a.children.map((u) => s(o, u, a, c + 1))
              })
            ]
          }, a.id);
        case "item": {
          if (i && !a.readonlyOk)
            return null;
          const { id: u, checkbox: d, menuLabel: h, label: f, onSelect: y, kbd: g } = a.actionItem, O = h ?? f, S = O ? e(O) : void 0;
          return d ? m.jsxs(nee, {
            onSelect: () => y("menu"),
            title: S || "",
            checked: a.checked,
            disabled: a.disabled,
            children: [
              S && m.jsx("span", {
                children: S
              }),
              g && m.jsx(zC, {
                children: g
              })
            ]
          }, u) : m.jsx(Ks, {
            "data-testid": `menu-item.${a.id}`,
            kbd: g,
            label: O,
            onClick: () => y("menu"),
            disabled: a.disabled
          }, u);
        }
      }
    }
    return m.jsx(m.Fragment, {
      children: n.map((o) => s(t, o, null, 0))
    });
  }
  const E8e = function({ name: e, id: n, isCurrentPage: r }) {
    const i = ue(), s = b.useRef(null), o = b.useCallback((l) => {
      i.renamePage(n, l || "New Page", {
        ephemeral: true
      });
    }, [
      i,
      n
    ]), a = b.useCallback((l) => {
      i.mark("rename page"), i.renamePage(n, l || "New Page", {
        ephemeral: false
      });
    }, [
      i,
      n
    ]);
    return m.jsx(LL, {
      className: "tlui-page-menu__item__input",
      ref: (l) => s.current = l,
      defaultValue: e,
      onValueChange: o,
      onComplete: a,
      onCancel: a,
      shouldManuallyMaintainScrollPositionWhenFocused: true,
      autofocus: r,
      autoselect: true
    });
  }, WR = (t, e, n, r) => {
    let i;
    const s = t.pages, o = n > r ? s[r - 1] : s[r], a = n > r ? s[r] : s[r + 1];
    o && !a ? i = wc(o.index) : !o && a ? i = u_e(s[0].index) : i = G0(o.index, a.index), i !== s[n].index && (t.mark("moving page"), t.updatePage({
      id: e,
      index: i
    }));
  }, a9 = Vt(function({ index: e, listSize: n, item: r, onRename: i }) {
    const s = ue(), o = Tt(), a = s.pages, l = b.useCallback(() => {
      s.mark("creating page");
      const h = Zc.createId();
      s.duplicatePage(r.id, h);
    }, [
      s,
      r
    ]), c = b.useCallback(() => {
      WR(s, r.id, e, e - 1);
    }, [
      s,
      r,
      e
    ]), u = b.useCallback(() => {
      WR(s, r.id, e, e + 1);
    }, [
      s,
      r,
      e
    ]), d = b.useCallback(() => {
      s.mark("deleting page"), s.deletePage(r.id);
    }, [
      s,
      r
    ]);
    return m.jsxs(Pd, {
      id: `page item submenu ${e}`,
      children: [
        m.jsx(fS, {
          children: m.jsx(Be, {
            title: o("page-menu.submenu.title"),
            icon: "dots-vertical"
          })
        }),
        m.jsxs(Cd, {
          alignOffset: 0,
          children: [
            m.jsxs(jc, {
              children: [
                i && m.jsx(Bu, {
                  dir: "ltr",
                  onSelect: i,
                  asChild: true,
                  children: m.jsx(Be, {
                    className: "tlui-menu__button",
                    label: "page-menu.submenu.rename"
                  })
                }),
                m.jsx(Bu, {
                  dir: "ltr",
                  onSelect: l,
                  disabled: a.length >= Ck,
                  asChild: true,
                  children: m.jsx(Be, {
                    className: "tlui-menu__button",
                    label: "page-menu.submenu.duplicate-page"
                  })
                }),
                e > 0 && m.jsx(Bu, {
                  dir: "ltr",
                  onSelect: c,
                  asChild: true,
                  children: m.jsx(Be, {
                    className: "tlui-menu__button",
                    label: "page-menu.submenu.move-up"
                  })
                }),
                e < n - 1 && m.jsx(Bu, {
                  dir: "ltr",
                  onSelect: u,
                  asChild: true,
                  children: m.jsx(Be, {
                    className: "tlui-menu__button",
                    label: "page-menu.submenu.move-down"
                  })
                })
              ]
            }),
            n > 1 && m.jsx(jc, {
              children: m.jsx(Bu, {
                dir: "ltr",
                onSelect: d,
                asChild: true,
                children: m.jsx(Be, {
                  className: "tlui-menu__button",
                  label: "page-menu.submenu.delete"
                })
              })
            })
          ]
        })
      ]
    });
  }), I8e = function() {
    const e = ue(), n = Tt(), r = oa(), i = b.useCallback(() => O(false), []), [s, o] = Pf("page-menu", i), a = r < 5 ? 36 : 40, l = b.useRef(null), c = ye("pages", () => e.pages, [
      e
    ]), u = ye("currentPage", () => e.currentPage, [
      e
    ]), d = ye("currentPageId", () => e.currentPageId, [
      e
    ]), h = sa(), f = ye("maxPageCountReached", () => e.pages.length >= Ck, [
      e
    ]), y = ye("isCoarsePointer", () => e.instanceState.isCoarsePointer, [
      e
    ]), [g, O] = b.useState(false), S = b.useCallback(() => {
      h || O((L) => !L);
    }, [
      h
    ]), w = b.useRef({
      isPointing: false,
      status: "idle",
      pointing: null,
      startY: 0,
      startIndex: 0,
      dragIndex: 0
    }), [x, P] = b.useState(Object.fromEntries(c.map((L, z) => [
      L.id,
      {
        y: z * a,
        offsetY: 0,
        isSelected: false
      }
    ])));
    b.useLayoutEffect(() => {
      P(Object.fromEntries(c.map((L, z) => [
        L.id,
        {
          y: z * a,
          offsetY: 0,
          isSelected: false
        }
      ])));
    }, [
      a,
      c
    ]), b.useEffect(() => {
      s && requestAnimationFrame(() => {
        const L = document.querySelector(`[data-testid="page-menu-item-${d}"]`);
        if (L) {
          const z = l.current;
          if (!z)
            return;
          const M = L.offsetTop, R = z.scrollTop;
          M < R && z.scrollTo({
            top: M
          });
          const F = M + a, Q = z.scrollTop + z.offsetHeight;
          F > Q && z.scrollTo({
            top: F - z.offsetHeight
          });
        }
      });
    }, [
      a,
      d,
      s
    ]);
    const C = b.useCallback((L) => {
      const { clientY: z, currentTarget: M } = L, { dataset: { id: R, index: F } } = M;
      if (!R || !F)
        return;
      const Q = w.current;
      qO(L.currentTarget, L), Q.status = "pointing", Q.pointing = {
        id: R,
        index: +F
      };
      const Z = x[R].y;
      Q.startY = z, Q.startIndex = Math.max(0, Math.min(Math.round(Z / a), c.length - 1));
    }, [
      a,
      c.length,
      x
    ]), _ = b.useCallback((L) => {
      const z = w.current;
      if (z.status === "pointing") {
        const { clientY: M } = L, R = M - z.startY;
        Math.abs(R) > 5 && (z.status = "dragging");
      }
      if (z.status === "dragging") {
        const { clientY: M } = L, R = M - z.startY, F = x[z.pointing.id], { startIndex: Q, pointing: X } = z, Z = F.y + R, U = Math.max(0, Math.min(Math.round(Z / a), c.length - 1)), H = {
          ...x
        };
        if (H[X.id] = {
          y: F.y,
          offsetY: R,
          isSelected: true
        }, U !== z.dragIndex) {
          z.dragIndex = U;
          for (let te = 0; te < c.length; te++) {
            const se = c[te];
            if (se.id === z.pointing.id)
              continue;
            let { y: ae } = H[se.id];
            U === Q ? ae = te * a : U < Q ? U <= te && te < Q ? ae = (te + 1) * a : ae = te * a : U > Q && (U >= te && te > Q ? ae = (te - 1) * a : ae = te * a), ae !== H[se.id].y && (H[se.id] = {
              y: ae,
              offsetY: 0,
              isSelected: true
            });
          }
        }
        P(H);
      }
    }, [
      a,
      c,
      x
    ]), T = b.useCallback((L) => {
      const z = w.current;
      if (z.status === "dragging") {
        const { id: M, index: R } = z.pointing;
        WR(e, M, R, z.dragIndex);
      }
      KO(L.currentTarget, L), z.status = "idle";
    }, [
      e
    ]), $ = b.useCallback((L) => {
      const z = w.current;
      L.key === "Escape" && (z.status === "dragging" && P(Object.fromEntries(c.map((M, R) => [
        M.id,
        {
          y: R * a,
          offsetY: 0,
          isSelected: false
        }
      ]))), z.status = "idle");
    }, [
      a,
      c
    ]), N = b.useCallback(() => {
      h || e.batch(() => {
        e.mark("creating page");
        const L = Zc.createId();
        e.createPage({
          name: n("page-menu.new-page-initial-name"),
          id: L
        }), e.setCurrentPage(L), O(true);
      });
    }, [
      e,
      n,
      h
    ]);
    return m.jsxs(GL, {
      id: "page menu",
      onOpenChange: o,
      open: s,
      children: [
        m.jsx(qL, {
          children: m.jsx(Be, {
            className: "tlui-page-menu__trigger tlui-menu__trigger",
            "data-testid": "main.page-menu",
            icon: "chevron-down",
            title: u.name,
            children: m.jsx("div", {
              className: "tlui-page-menu__name",
              children: u.name
            })
          })
        }),
        m.jsx(Yte, {
          side: "bottom",
          align: "start",
          sideOffset: 6,
          children: m.jsxs("div", {
            className: "tlui-page-menu__wrapper",
            children: [
              m.jsxs("div", {
                className: "tlui-page-menu__header",
                children: [
                  m.jsx("div", {
                    className: "tlui-page-menu__header__title",
                    children: n("page-menu.title")
                  }),
                  !h && m.jsxs(m.Fragment, {
                    children: [
                      m.jsx(Be, {
                        "data-testid": "page-menu.edit",
                        title: n(g ? "page-menu.edit-done" : "page-menu.edit-start"),
                        icon: g ? "check" : "edit",
                        onClick: S
                      }),
                      m.jsx(Be, {
                        "data-testid": "page-menu.create",
                        icon: "plus",
                        title: n(f ? "page-menu.max-page-count-reached" : "page-menu.create-new-page"),
                        disabled: f,
                        onClick: N
                      })
                    ]
                  })
                ]
              }),
              m.jsx("div", {
                className: "tlui-page-menu__list tlui-menu__group",
                style: {
                  height: a * c.length + 4
                },
                ref: l,
                children: c.map((L, z) => {
                  const M = x[L.id] ?? {
                    position: z * 40,
                    offsetY: 0
                  };
                  return g ? m.jsxs("div", {
                    "data-testid": `page-menu-item-${L.id}`,
                    className: "tlui-page_menu__item__sortable",
                    style: {
                      zIndex: L.id === u.id ? 888 : z,
                      transform: `translate(0px, ${M.y + M.offsetY}px)`
                    },
                    children: [
                      m.jsx(Be, {
                        tabIndex: -1,
                        className: "tlui-page_menu__item__sortable__handle",
                        icon: "drag-handle-dots",
                        onPointerDown: C,
                        onPointerUp: T,
                        onPointerMove: _,
                        onKeyDown: $,
                        "data-id": L.id,
                        "data-index": z
                      }),
                      r < 5 && y ? m.jsx(Be, {
                        className: "tlui-page-menu__item__button",
                        onClick: () => {
                          const R = window.prompt("Rename page", L.name);
                          R && R !== L.name && e.renamePage(L.id, R);
                        },
                        onDoubleClick: S,
                        isChecked: L.id === u.id,
                        children: m.jsx("span", {
                          children: L.name
                        })
                      }) : m.jsx("div", {
                        className: "tlui-page_menu__item__sortable__title",
                        style: {
                          height: a
                        },
                        children: m.jsx(E8e, {
                          id: L.id,
                          name: L.name,
                          isCurrentPage: L.id === u.id
                        })
                      }),
                      !h && m.jsx("div", {
                        className: "tlui-page_menu__item__submenu",
                        "data-isediting": g,
                        children: m.jsx(a9, {
                          index: z,
                          item: L,
                          listSize: c.length
                        })
                      })
                    ]
                  }, L.id + "_editing") : m.jsxs("div", {
                    "data-testid": `page-menu-item-${L.id}`,
                    className: "tlui-page-menu__item",
                    children: [
                      m.jsxs(Be, {
                        className: "tlui-page-menu__item__button tlui-page-menu__item__button__checkbox",
                        onClick: () => e.setCurrentPage(L.id),
                        onDoubleClick: S,
                        isChecked: L.id === u.id,
                        title: n("page-menu.go-to-page"),
                        children: [
                          m.jsx("div", {
                            className: "tlui-page-menu__item__button__check",
                            children: L.id === u.id && m.jsx(Ss, {
                              icon: "check"
                            })
                          }),
                          m.jsx("span", {
                            children: L.name
                          })
                        ]
                      }),
                      !h && m.jsx("div", {
                        className: "tlui-page_menu__item__submenu",
                        children: m.jsx(a9, {
                          index: z,
                          item: L,
                          listSize: c.length,
                          onRename: () => {
                            if (e.environment.isIos) {
                              const R = window.prompt("Rename page", L.name);
                              R && R !== L.name && e.renamePage(L.id, R);
                            } else
                              e.batch(() => {
                                O(true), e.setCurrentPage(L.id);
                              });
                          }
                        })
                      })
                    ]
                  }, L.id);
                })
              })
            ]
          })
        })
      ]
    });
  }, Kte = b.memo(function() {
    const e = Tt(), n = pte(), i = $i().redo;
    return m.jsx(Be, {
      "data-testid": "main.redo",
      icon: i.icon,
      title: `${e(i.label)} ${zl(i.kbd)}`,
      disabled: !n,
      onClick: () => i.onSelect("quick-actions"),
      smallIcon: true
    });
  }), Jte = Vt(function() {
    const e = ue(), n = $i(), r = Tt(), i = n.delete;
    return sa() ? null : m.jsx(Be, {
      icon: i.icon,
      onClick: () => i.onSelect("quick-actions"),
      disabled: !(e.isIn("select") && e.selectedShapeIds.length > 0),
      title: `${r(i.label)} ${zl(i.kbd)}`,
      smallIcon: true
    });
  }), ene = b.memo(function() {
    const e = Tt(), n = gte(), i = $i().undo;
    return m.jsx(Be, {
      "data-testid": "main.undo",
      icon: i.icon,
      title: `${e(i.label)} ${zl(i.kbd)}`,
      disabled: !n,
      onClick: () => i.onSelect("quick-actions"),
      smallIcon: true
    });
  }), $8e = Vt(function() {
    const e = ue(), n = oa(), r = sa();
    return m.jsx("div", {
      className: "tlui-menu-zone",
      children: m.jsxs("div", {
        className: "tlui-menu-zone__controls",
        children: [
          m.jsx(_8e, {}),
          m.jsx("div", {
            className: "tlui-menu-zone__divider"
          }),
          m.jsx(I8e, {}),
          n >= 6 && !r && !e.isInAny("hand", "zoom") && m.jsxs(m.Fragment, {
            children: [
              m.jsx("div", {
                className: "tlui-menu-zone__divider"
              }),
              m.jsx(ene, {}),
              m.jsx(Kte, {}),
              m.jsx(Jte, {}),
              m.jsx(qte, {}),
              m.jsx(Gte, {})
            ]
          })
        ]
      })
    });
  });
  function A8e(t, e) {
    const [n, r] = $e.useState(e);
    $e.useLayoutEffect(() => {
      const s = localStorage.getItem(t);
      if (s)
        try {
          r(JSON.parse(s));
        } catch {
          console.error(`Could not restore value ${t} from local storage.`);
        }
    }, [
      t
    ]);
    const i = $e.useCallback((s) => {
      r((o) => {
        const a = typeof s == "function" ? s(o) : s;
        return localStorage.setItem(t, JSON.stringify(a)), a;
      });
    }, [
      t
    ]);
    return [
      n,
      i
    ];
  }
  class tv {
    constructor(e) {
      __publicField(this, "dpr", 1);
      __publicField(this, "colors", {
        shapeFill: "rgba(144, 144, 144, .1)",
        selectFill: "#2f80ed",
        viewportFill: "rgba(144, 144, 144, .1)"
      });
      __publicField(this, "id", wn());
      __publicField(this, "cvs", null);
      __publicField(this, "pageBounds", []);
      __publicField(this, "collaborators", []);
      __publicField(this, "canvasScreenBounds", new Te());
      __publicField(this, "canvasPageBounds", new Te());
      __publicField(this, "contentPageBounds", new Te());
      __publicField(this, "contentScreenBounds", new Te());
      __publicField(this, "originPagePoint", new I());
      __publicField(this, "originPageCenter", new I());
      __publicField(this, "isInViewport", false);
      __publicField(this, "debug", false);
      __publicField(this, "updateContentScreenBounds", () => {
        const { contentScreenBounds: e, contentPageBounds: n, canvasScreenBounds: r } = this;
        let { x: i, y: s, w: o, h: a } = e;
        if (n.w > n.h) {
          const l = r.w / (n.w / n.h);
          l > r.h ? (i = (r.w - r.w * (r.h / l)) / 2, s = 0, o = r.w * (r.h / l), a = r.h) : (i = 0, s = (r.h - l) / 2, o = r.w, a = l);
        } else if (n.w < n.h) {
          const l = r.h / (n.h / n.w);
          i = (r.w - l) / 2, s = 0, o = l, a = r.h;
        } else
          i = r.h / 2, s = 0, o = r.h, a = r.h;
        e.set(i, s, o, a);
      });
      __publicField(this, "updateCanvasPageBounds", () => {
        const { canvasPageBounds: e, canvasScreenBounds: n, contentPageBounds: r, contentScreenBounds: i } = this;
        e.set(0, 0, r.width / (i.width / n.width), r.height / (i.height / n.height)), e.center = r.center;
      });
      __publicField(this, "getScreenPoint", (e, n) => {
        const { canvasScreenBounds: r } = this, i = (e - r.minX) * this.dpr, s = (n - r.minY) * this.dpr;
        return {
          x: i,
          y: s
        };
      });
      __publicField(this, "getPagePoint", (e, n) => {
        const { contentPageBounds: r, contentScreenBounds: i, canvasPageBounds: s } = this, { x: o, y: a } = this.getScreenPoint(e, n);
        return new I(s.minX + o * r.width / i.width, s.minY + a * r.height / i.height, 1);
      });
      __publicField(this, "minimapScreenPointToPagePoint", (e, n, r = false, i = false) => {
        const { editor: s } = this, { viewportPageBounds: o } = s;
        let { x: a, y: l } = this.getPagePoint(e, n);
        if (i) {
          const c = this.editor.currentPageBounds, u = o, d = ((c == null ? void 0 : c.minX) ?? 0) - u.width / 2, h = ((c == null ? void 0 : c.maxX) ?? 0) + u.width / 2, f = ((c == null ? void 0 : c.minY) ?? 0) - u.height / 2, y = ((c == null ? void 0 : c.maxY) ?? 0) + u.height / 2, g = Math.max(0, d + u.width - a), O = Math.max(0, -(h - u.width - a)), S = Math.max(0, f + u.height - l), w = Math.max(0, -(y - u.height - l)), x = Math.max(0, g - O), P = Math.max(0, O - g), C = Math.max(0, S - w), _ = Math.max(0, w - S);
          x && x > P ? a += x / 2 : P && (a -= P / 2), C && C > _ ? l += C / 2 : _ && (l -= _ / 2), a = _a(a, d, h), l = _a(l, f, y);
        }
        if (r) {
          const { originPagePoint: c } = this, u = Math.abs(a - c.x), d = Math.abs(l - c.y);
          u > d ? l = c.y : a = c.x;
        }
        return new I(a, l);
      });
      __publicField(this, "render", () => {
        const { cvs: e, pageBounds: n } = this;
        this.updateCanvasPageBounds();
        const { editor: r, canvasScreenBounds: i, canvasPageBounds: s, contentPageBounds: o, contentScreenBounds: a } = this, { width: l, height: c } = i, { viewportPageBounds: u, selectedShapeIds: d } = r;
        if (!e || !n)
          return;
        const h = e.getContext("2d");
        if (!h)
          throw new Error("Minimap (shapes): Could not get context");
        h.resetTransform(), h.globalAlpha = 1, h.clearRect(0, 0, l, c);
        const f = a.width / o.width, y = a.height / o.height;
        h.translate((l - a.width) / 2, (c - a.height) / 2), h.scale(f, y), h.translate(-o.minX, -o.minY);
        const g = 8 / f, O = 8 / f, S = 1 / f, w = 1 / f, x = g / 4, P = O / 4, C = new Path2D(), _ = new Path2D(), { shapeFill: T, selectFill: $, viewportFill: N } = this.colors;
        let L;
        for (let Q = 0, X = n.length; Q < X; Q++)
          L = n[Q], tv.roundedRect(d.includes(L.id) ? _ : C, L.minX, L.minY, L.width, L.height, _a(g, S, L.width / x), _a(O, w, L.height / P));
        if (h.fillStyle = T, h.fill(C), h.fillStyle = $, h.fill(_), this.debug) {
          const Q = Te.Common(n), { minX: X, minY: Z, width: U, height: H } = Q;
          h.strokeStyle = "green", h.lineWidth = 2 / f, h.strokeRect(X + 1 / f, Z + 1 / y, U - 2 / f, H - 2 / y);
        }
        {
          const { brush: Q } = r.instanceState;
          if (Q) {
            const { x: X, y: Z, w: U, h: H } = Q;
            h.beginPath(), tv.sharpRect(h, X, Z, U, H), h.closePath(), h.fillStyle = N, h.fill();
          }
        }
        {
          const { minX: Q, minY: X, width: Z, height: U } = u;
          h.beginPath();
          const H = 12 / f, te = 12 / f;
          tv.roundedRect(h, Q, X, Z, U, Math.min(Z / 4, H), Math.min(U / 4, te)), h.closePath(), h.fillStyle = N, h.fill(), this.debug && (h.strokeStyle = "orange", h.strokeRect(Q + 1 / f, X + 1 / y, Z - 2 / f, U - 2 / y));
        }
        const z = 2.5 / f, M = 2.5 / y, { currentPageId: R } = r;
        let F;
        for (let Q = 0; Q < this.collaborators.length; Q++)
          F = this.collaborators[Q], F.currentPageId === R && (h.beginPath(), h.ellipse(_a(F.cursor.x, s.minX + z, s.maxX - z), _a(F.cursor.y, s.minY + M, s.maxY - M), 5 / f, 5 / y, 0, 0, Bt), h.fillStyle = F.color, h.fill());
        if (this.debug) {
          h.lineWidth = 2 / f;
          {
            const { minX: Q, minY: X, width: Z, height: U } = o;
            h.strokeStyle = "red", h.strokeRect(Q + 1 / f, X + 1 / y, Z - 2 / f, U - 2 / y);
          }
          {
            const { minX: Q, minY: X, width: Z, height: U } = s;
            h.strokeStyle = "blue", h.strokeRect(Q + 1 / f, X + 1 / y, Z - 2 / f, U - 2 / y);
          }
        }
      });
      this.editor = e;
    }
    setDpr(e) {
      this.dpr = +e.toFixed(2);
    }
    static roundedRect(e, n, r, i, s, o, a) {
      if (o < 1 && a < 1) {
        e.rect(n, r, i, s);
        return;
      }
      e.moveTo(n + o, r), e.lineTo(n + i - o, r), e.quadraticCurveTo(n + i, r, n + i, r + a), e.lineTo(n + i, r + s - a), e.quadraticCurveTo(n + i, r + s, n + i - o, r + s), e.lineTo(n + o, r + s), e.quadraticCurveTo(n, r + s, n, r + s - a), e.lineTo(n, r + a), e.quadraticCurveTo(n, r, n + o, r);
    }
    static sharpRect(e, n, r, i, s, o, a) {
      e.rect(n, r, i, s);
    }
  }
  function R8e({ shapeFill: t, selectFill: e, viewportFill: n }) {
    const r = ue(), i = b.useRef(null), s = b.useRef(false), o = $C(), a = KY("dpr", () => r.instanceState.devicePixelRatio, [
      r
    ]), l = b.useMemo(() => r.store.query.records("instance_presence"), [
      r
    ]), c = b.useMemo(() => new tv(r), [
      r
    ]);
    b.useEffect(() => {
      const y = requestAnimationFrame(() => {
        const g = getComputedStyle(r.getContainer());
        c.colors = {
          shapeFill: g.getPropertyValue(t).trim(),
          selectFill: g.getPropertyValue(e).trim(),
          viewportFill: g.getPropertyValue(n).trim()
        }, c.render();
      });
      return () => {
        cancelAnimationFrame(y);
      };
    }, [
      r,
      e,
      t,
      n,
      c,
      o
    ]);
    const u = b.useCallback((y) => {
      if (!r.currentPageShapeIds.size)
        return;
      const g = c.minimapScreenPointToPagePoint(y.clientX, y.clientY, false, false), O = c.minimapScreenPointToPagePoint(y.clientX, y.clientY, false, true);
      c.originPagePoint.setTo(O), c.originPageCenter.setTo(r.viewportPageBounds.center), r.centerOnPoint(g, {
        duration: Pc
      });
    }, [
      r,
      c
    ]), d = b.useCallback((y) => {
      const g = y.currentTarget;
      if (qO(g, y), !r.currentPageShapeIds.size)
        return;
      s.current = true, c.isInViewport = false;
      const O = c.minimapScreenPointToPagePoint(y.clientX, y.clientY, false, false), S = c.minimapScreenPointToPagePoint(y.clientX, y.clientY, false, true), w = r.viewportPageBounds;
      if (c.isInViewport = w.containsPoint(S), c.isInViewport)
        c.originPagePoint.setTo(S), c.originPageCenter.setTo(w.center);
      else {
        const P = I.Sub(w.center, w.point), C = I.Add(O, P);
        c.originPagePoint.setTo(C), c.originPageCenter.setTo(O), r.centerOnPoint(O, {
          duration: Pc
        });
      }
      function x(P) {
        g && KO(g, P), s.current = false, document.body.removeEventListener("pointerup", x);
      }
      document.body.addEventListener("pointerup", x);
    }, [
      r,
      c
    ]), h = b.useCallback((y) => {
      const g = c.minimapScreenPointToPagePoint(y.clientX, y.clientY, y.shiftKey, true);
      if (s.current) {
        if (c.isInViewport) {
          const x = c.originPagePoint.clone().sub(c.originPageCenter);
          r.centerOnPoint(I.Sub(g, x));
          return;
        }
        r.centerOnPoint(g);
      }
      const O = c.getPagePoint(y.clientX, y.clientY), S = r.pageToScreen(O), w = {
        type: "pointer",
        target: "canvas",
        name: "pointer_move",
        ...ps(y),
        point: S,
        isPen: r.instanceState.isPenMode
      };
      r.dispatch(w);
    }, [
      r,
      c
    ]), f = b.useCallback((y) => {
      const g = $G(y);
      r.dispatch({
        type: "wheel",
        name: "wheel",
        delta: g,
        shiftKey: y.shiftKey,
        altKey: y.altKey,
        ctrlKey: y.metaKey || y.ctrlKey
      });
    }, [
      r
    ]);
    return Vh("update when dpr changes", () => {
      const y = a.value;
      c.setDpr(y);
      const g = i.current, O = g.getBoundingClientRect(), S = O.width * y, w = O.height * y;
      g.width = S, g.height = w, c.canvasScreenBounds.set(O.x, O.y, S, w), c.cvs = i.current;
    }, [
      a,
      c
    ]), Vh("minimap render when pagebounds or collaborators changes", () => {
      const { currentPageShapeIds: y, viewportPageBounds: g, currentPageBounds: O } = r;
      a.value, c.contentPageBounds = O ? Te.Expand(O, g) : g, c.updateContentScreenBounds();
      const S = [];
      y.forEach((w) => {
        let x = r.getShapePageBounds(w);
        if (!x)
          return;
        const P = r.getShapeMask(w);
        if (P) {
          const C = sR(P, x.corners);
          if (!C)
            return;
          x = Te.FromPoints(C);
        }
        x && (x.id = w, S.push(x));
      }), c.pageBounds = S, c.collaborators = l.value, c.render();
    }, [
      r,
      c
    ]), m.jsx("div", {
      className: "tlui-minimap",
      children: m.jsx("canvas", {
        ref: i,
        className: "tlui-minimap__canvas",
        onDoubleClick: u,
        onPointerMove: h,
        onPointerDown: d,
        onWheel: f
      })
    });
  }
  const CI = Vt(function() {
    const e = ue(), n = Tt(), r = oa(), i = e.zoomLevel, s = e.currentPageShapeIds.size > 0, o = e.selectedShapeIds.length > 0, a = e.zoomLevel === 1, l = b.useCallback(() => {
      e.resetZoom(e.viewportScreenCenter, {
        duration: Pc
      });
    }, [
      e
    ]);
    return m.jsxs(Pd, {
      id: "zoom",
      children: [
        m.jsx(fS, {
          children: m.jsx(Be, {
            title: `${n("navigation-zone.zoom")}`,
            "data-testid": "minimap.zoom-menu",
            className: r < 5 ? "tlui-zoom-menu__button" : "tlui-zoom-menu__button__pct",
            onDoubleClick: l,
            icon: r < 4 ? "zoom-in" : void 0,
            children: r < 4 ? null : m.jsxs("span", {
              style: {
                flexGrow: 0,
                textAlign: "center"
              },
              children: [
                Math.floor(i * 100),
                "%"
              ]
            })
          })
        }),
        m.jsx(Cd, {
          side: "top",
          align: "start",
          alignOffset: 0,
          children: m.jsxs(jc, {
            children: [
              m.jsx(Gy, {
                action: "zoom-in",
                "data-testid": "minimap.zoom-menu.zoom-in",
                noClose: true
              }),
              m.jsx(Gy, {
                action: "zoom-out",
                "data-testid": "minimap.zoom-menu.zoom-out",
                noClose: true
              }),
              m.jsx(Gy, {
                action: "zoom-to-100",
                "data-testid": "minimap.zoom-menu.zoom-to-100",
                noClose: true,
                disabled: a
              }),
              m.jsx(Gy, {
                action: "zoom-to-fit",
                disabled: !s,
                "data-testid": "minimap.zoom-menu.zoom-to-fit",
                noClose: true
              }),
              m.jsx(Gy, {
                action: "zoom-to-selection",
                disabled: !o,
                "data-testid": "minimap.zoom-menu.zoom-to-selection",
                noClose: true
              })
            ]
          })
        })
      ]
    });
  });
  function Gy(t) {
    const { action: e, disabled: n = false, noClose: r = false } = t, i = $i();
    return m.jsx(Ks, {
      label: i[e].label,
      kbd: i[e].kbd,
      "data-testid": t["data-testid"],
      onClick: () => i[e].onSelect("zoom-menu"),
      noClose: r,
      disabled: n
    });
  }
  const M8e = b.memo(function() {
    const e = $i(), n = Tt(), r = oa(), [i, s] = A8e("minimap", true), o = b.useCallback(() => {
      s((a) => !a);
    }, [
      s
    ]);
    return r < 4 ? null : m.jsxs("div", {
      className: "tlui-navigation-zone",
      children: [
        m.jsx("div", {
          className: "tlui-navigation-zone__controls",
          children: r < 6 ? m.jsx(CI, {}) : i ? m.jsxs(m.Fragment, {
            children: [
              m.jsx(CI, {}),
              m.jsx(Be, {
                title: n("navigation-zone.toggle-minimap"),
                className: "tlui-navigation-zone__toggle",
                "data-testid": "minimap.toggle",
                onClick: o,
                icon: i ? "chevrons-ne" : "chevrons-sw"
              })
            ]
          }) : m.jsxs(m.Fragment, {
            children: [
              m.jsx(Be, {
                icon: "minus",
                "data-testid": "minimap.zoom-out",
                title: `${n(e["zoom-out"].label)} ${zl(e["zoom-out"].kbd)}`,
                onClick: () => e["zoom-out"].onSelect("navigation-zone")
              }),
              m.jsx(CI, {}),
              m.jsx(Be, {
                icon: "plus",
                "data-testid": "minimap.zoom-in",
                title: `${n(e["zoom-in"].label)} ${zl(e["zoom-in"].kbd)}`,
                onClick: () => e["zoom-in"].onSelect("navigation-zone")
              }),
              m.jsx(Be, {
                title: n("navigation-zone.toggle-minimap"),
                className: "tlui-navigation-zone__toggle",
                onClick: o,
                icon: i ? "chevrons-ne" : "chevrons-sw"
              })
            ]
          })
        }),
        r >= 6 && !i && m.jsx(R8e, {
          viewportFill: "--color-muted-1",
          selectFill: "--color-selected",
          shapeFill: "--color-text-3"
        })
      ]
    });
  }), D8e = Vt(function() {
    const n = ue().instanceState.isPenMode, r = $i();
    if (!n)
      return null;
    const i = r["exit-pen-mode"];
    return m.jsx(Be, {
      label: i.label,
      iconLeft: i.icon,
      onClick: () => i.onSelect("helper-buttons")
    });
  }), L8e = Vt(function() {
    const e = ue(), n = $i();
    if (!e.instanceState.followingUserId)
      return null;
    const r = n["stop-following"];
    return m.jsx(Be, {
      label: r.label,
      iconLeft: r.icon,
      onClick: () => r.onSelect("people-menu")
    });
  }), j8e = [
    na,
    sf,
    jg,
    Nl
  ];
  function tne() {
    const t = ue();
    return ye("getRelevantStyles", () => {
      var _a3;
      const e = new oR(t.sharedStyles), n = t.selectedShapeIds.length > 0 || !!((_a3 = t.root.current.value) == null ? void 0 : _a3.shapeType);
      if (e.size === 0 && t.isIn("select") && t.selectedShapeIds.length === 0)
        for (const r of j8e)
          e.applyValue(r, t.getStyleForNextShape(r));
      return e.size === 0 && !n ? null : {
        styles: e,
        opacity: t.sharedOpacity
      };
    }, [
      t
    ]);
  }
  function N8e(t) {
    const { uiType: e, items: n, title: r, style: i, value: s, columns: o = _a(n.length, 2, 4), onValueChange: a } = t, l = ue(), c = Tt(), u = b.useRef(false), { handleButtonClick: d, handleButtonPointerDown: h, handleButtonPointerEnter: f, handleButtonPointerUp: y } = b.useMemo(() => {
      const O = () => {
        u.current = false, window.removeEventListener("pointerup", O);
      };
      return {
        handleButtonClick: (C) => {
          const { id: _ } = C.currentTarget.dataset;
          s.type === "shared" && s.value === _ || (l.mark("point picker item"), a(i, _, false));
        },
        handleButtonPointerDown: (C) => {
          const { id: _ } = C.currentTarget.dataset;
          l.mark("point picker item"), a(i, _, true), u.current = true, window.addEventListener("pointerup", O);
        },
        handleButtonPointerEnter: (C) => {
          if (!u.current)
            return;
          const { id: _ } = C.currentTarget.dataset;
          a(i, _, true);
        },
        handleButtonPointerUp: (C) => {
          const { id: _ } = C.currentTarget.dataset;
          a(i, _, false);
        }
      };
    }, [
      s,
      l,
      a,
      i
    ]), g = ye("theme", () => ks({
      isDarkMode: l.user.isDarkMode
    }), [
      l
    ]);
    return m.jsx("div", {
      className: Ze("tlui-button-grid", {
        "tlui-button-grid__two": o === 2,
        "tlui-button-grid__three": o === 3,
        "tlui-button-grid__four": o === 4
      }),
      children: n.map((O) => m.jsx(Be, {
        "data-id": O.value,
        "data-testid": `style.${e}.${O.value}`,
        "aria-label": O.value,
        "data-state": s.type === "shared" && s.value === O.value ? "hinted" : void 0,
        title: r + " \u2014 " + c(`${e}-style.${O.value}`),
        className: Ze("tlui-button-grid__button"),
        style: i === na ? {
          color: g[O.value].solid
        } : void 0,
        onPointerEnter: f,
        onPointerDown: h,
        onPointerUp: y,
        onClick: d,
        icon: O.icon
      }, O.value))
    });
  }
  const ig = b.memo(N8e);
  function nne(t, [e, n]) {
    return Math.min(n, Math.max(e, t));
  }
  function Q8e(t) {
    const e = b.useRef({
      value: t,
      previous: t
    });
    return b.useMemo(() => (e.current.value !== t && (e.current.previous = e.current.value, e.current.value = t), e.current.previous), [
      t
    ]);
  }
  var rne = [
    "PageUp",
    "PageDown"
  ], ine = [
    "ArrowUp",
    "ArrowDown",
    "ArrowLeft",
    "ArrowRight"
  ], sne = {
    "from-left": [
      "Home",
      "PageDown",
      "ArrowDown",
      "ArrowLeft"
    ],
    "from-right": [
      "Home",
      "PageDown",
      "ArrowDown",
      "ArrowRight"
    ],
    "from-bottom": [
      "Home",
      "PageDown",
      "ArrowDown",
      "ArrowLeft"
    ],
    "from-top": [
      "Home",
      "PageDown",
      "ArrowUp",
      "ArrowLeft"
    ]
  }, jm = "Slider", [ZR, z8e, F8e] = VC(jm), [one, rat] = Ps(jm, [
    F8e
  ]), [B8e, f2] = one(jm), ane = b.forwardRef((t, e) => {
    const { name: n, min: r = 0, max: i = 100, step: s = 1, orientation: o = "horizontal", disabled: a = false, minStepsBetweenThumbs: l = 0, defaultValue: c = [
      r
    ], value: u, onValueChange: d = () => {
    }, onValueCommit: h = () => {
    }, inverted: f = false, form: y, ...g } = t, O = b.useRef(/* @__PURE__ */ new Set()), S = b.useRef(0), x = o === "horizontal" ? U8e : V8e, [P = [], C] = Wl({
      prop: u,
      defaultProp: c,
      onChange: (z) => {
        var _a3;
        (_a3 = [
          ...O.current
        ][S.current]) == null ? void 0 : _a3.focus(), d(z);
      }
    }), _ = b.useRef(P);
    function T(z) {
      const M = Y8e(P, z);
      L(z, M);
    }
    function $(z) {
      L(z, S.current);
    }
    function N() {
      const z = _.current[S.current];
      P[S.current] !== z && h(P);
    }
    function L(z, M, { commit: R } = {
      commit: false
    }) {
      const F = J8e(s), Q = eFe(Math.round((z - r) / s) * s + r, F), X = nne(Q, [
        r,
        i
      ]);
      C((Z = []) => {
        const U = Z8e(Z, X, M);
        if (K8e(U, l * s)) {
          S.current = U.indexOf(X);
          const H = String(U) !== String(Z);
          return H && R && h(U), H ? U : Z;
        } else
          return Z;
      });
    }
    return m.jsx(B8e, {
      scope: t.__scopeSlider,
      name: n,
      disabled: a,
      min: r,
      max: i,
      valueIndexToChangeRef: S,
      thumbs: O.current,
      values: P,
      orientation: o,
      form: y,
      children: m.jsx(ZR.Provider, {
        scope: t.__scopeSlider,
        children: m.jsx(ZR.Slot, {
          scope: t.__scopeSlider,
          children: m.jsx(x, {
            "aria-disabled": a,
            "data-disabled": a ? "" : void 0,
            ...g,
            ref: e,
            onPointerDown: Pe(g.onPointerDown, () => {
              a || (_.current = P);
            }),
            min: r,
            max: i,
            inverted: f,
            onSlideStart: a ? void 0 : T,
            onSlideMove: a ? void 0 : $,
            onSlideEnd: a ? void 0 : N,
            onHomeKeyDown: () => !a && L(r, 0, {
              commit: true
            }),
            onEndKeyDown: () => !a && L(i, P.length - 1, {
              commit: true
            }),
            onStepKeyDown: ({ event: z, direction: M }) => {
              if (!a) {
                const Q = rne.includes(z.key) || z.shiftKey && ine.includes(z.key) ? 10 : 1, X = S.current, Z = P[X], U = s * Q * M;
                L(Z + U, X, {
                  commit: true
                });
              }
            }
          })
        })
      })
    });
  });
  ane.displayName = jm;
  var [lne, cne] = one(jm, {
    startEdge: "left",
    endEdge: "right",
    size: "width",
    direction: 1
  }), U8e = b.forwardRef((t, e) => {
    const { min: n, max: r, dir: i, inverted: s, onSlideStart: o, onSlideMove: a, onSlideEnd: l, onStepKeyDown: c, ...u } = t, [d, h] = b.useState(null), f = Ht(e, (x) => h(x)), y = b.useRef(void 0), g = XC(i), O = g === "ltr", S = O && !s || !O && s;
    function w(x) {
      const P = y.current || d.getBoundingClientRect(), C = [
        0,
        P.width
      ], T = KL(C, S ? [
        n,
        r
      ] : [
        r,
        n
      ]);
      return y.current = P, T(x - P.left);
    }
    return m.jsx(lne, {
      scope: t.__scopeSlider,
      startEdge: S ? "left" : "right",
      endEdge: S ? "right" : "left",
      direction: S ? 1 : -1,
      size: "width",
      children: m.jsx(une, {
        dir: g,
        "data-orientation": "horizontal",
        ...u,
        ref: f,
        style: {
          ...u.style,
          "--radix-slider-thumb-transform": "translateX(-50%)"
        },
        onSlideStart: (x) => {
          const P = w(x.clientX);
          o == null ? void 0 : o(P);
        },
        onSlideMove: (x) => {
          const P = w(x.clientX);
          a == null ? void 0 : a(P);
        },
        onSlideEnd: () => {
          y.current = void 0, l == null ? void 0 : l();
        },
        onStepKeyDown: (x) => {
          const C = sne[S ? "from-left" : "from-right"].includes(x.key);
          c == null ? void 0 : c({
            event: x,
            direction: C ? -1 : 1
          });
        }
      })
    });
  }), V8e = b.forwardRef((t, e) => {
    const { min: n, max: r, inverted: i, onSlideStart: s, onSlideMove: o, onSlideEnd: a, onStepKeyDown: l, ...c } = t, u = b.useRef(null), d = Ht(e, u), h = b.useRef(void 0), f = !i;
    function y(g) {
      const O = h.current || u.current.getBoundingClientRect(), S = [
        0,
        O.height
      ], x = KL(S, f ? [
        r,
        n
      ] : [
        n,
        r
      ]);
      return h.current = O, x(g - O.top);
    }
    return m.jsx(lne, {
      scope: t.__scopeSlider,
      startEdge: f ? "bottom" : "top",
      endEdge: f ? "top" : "bottom",
      size: "height",
      direction: f ? 1 : -1,
      children: m.jsx(une, {
        "data-orientation": "vertical",
        ...c,
        ref: d,
        style: {
          ...c.style,
          "--radix-slider-thumb-transform": "translateY(50%)"
        },
        onSlideStart: (g) => {
          const O = y(g.clientY);
          s == null ? void 0 : s(O);
        },
        onSlideMove: (g) => {
          const O = y(g.clientY);
          o == null ? void 0 : o(O);
        },
        onSlideEnd: () => {
          h.current = void 0, a == null ? void 0 : a();
        },
        onStepKeyDown: (g) => {
          const S = sne[f ? "from-bottom" : "from-top"].includes(g.key);
          l == null ? void 0 : l({
            event: g,
            direction: S ? -1 : 1
          });
        }
      })
    });
  }), une = b.forwardRef((t, e) => {
    const { __scopeSlider: n, onSlideStart: r, onSlideMove: i, onSlideEnd: s, onHomeKeyDown: o, onEndKeyDown: a, onStepKeyDown: l, ...c } = t, u = f2(jm, n);
    return m.jsx(rt.span, {
      ...c,
      ref: e,
      onKeyDown: Pe(t.onKeyDown, (d) => {
        d.key === "Home" ? (o(d), d.preventDefault()) : d.key === "End" ? (a(d), d.preventDefault()) : rne.concat(ine).includes(d.key) && (l(d), d.preventDefault());
      }),
      onPointerDown: Pe(t.onPointerDown, (d) => {
        const h = d.target;
        h.setPointerCapture(d.pointerId), d.preventDefault(), u.thumbs.has(h) ? h.focus() : r(d);
      }),
      onPointerMove: Pe(t.onPointerMove, (d) => {
        d.target.hasPointerCapture(d.pointerId) && i(d);
      }),
      onPointerUp: Pe(t.onPointerUp, (d) => {
        const h = d.target;
        h.hasPointerCapture(d.pointerId) && (h.releasePointerCapture(d.pointerId), s(d));
      })
    });
  }), dne = "SliderTrack", hne = b.forwardRef((t, e) => {
    const { __scopeSlider: n, ...r } = t, i = f2(dne, n);
    return m.jsx(rt.span, {
      "data-disabled": i.disabled ? "" : void 0,
      "data-orientation": i.orientation,
      ...r,
      ref: e
    });
  });
  hne.displayName = dne;
  var HR = "SliderRange", fne = b.forwardRef((t, e) => {
    const { __scopeSlider: n, ...r } = t, i = f2(HR, n), s = cne(HR, n), o = b.useRef(null), a = Ht(e, o), l = i.values.length, c = i.values.map((h) => mne(h, i.min, i.max)), u = l > 1 ? Math.min(...c) : 0, d = 100 - Math.max(...c);
    return m.jsx(rt.span, {
      "data-orientation": i.orientation,
      "data-disabled": i.disabled ? "" : void 0,
      ...r,
      ref: a,
      style: {
        ...t.style,
        [s.startEdge]: u + "%",
        [s.endEdge]: d + "%"
      }
    });
  });
  fne.displayName = HR;
  var YR = "SliderThumb", pne = b.forwardRef((t, e) => {
    const n = z8e(t.__scopeSlider), [r, i] = b.useState(null), s = Ht(e, (a) => i(a)), o = b.useMemo(() => r ? n().findIndex((a) => a.ref.current === r) : -1, [
      n,
      r
    ]);
    return m.jsx(X8e, {
      ...t,
      ref: s,
      index: o
    });
  }), X8e = b.forwardRef((t, e) => {
    const { __scopeSlider: n, index: r, name: i, ...s } = t, o = f2(YR, n), a = cne(YR, n), [l, c] = b.useState(null), u = Ht(e, (w) => c(w)), d = l ? o.form || !!l.closest("form") : true, h = AK(l), f = o.values[r], y = f === void 0 ? 0 : mne(f, o.min, o.max), g = H8e(r, o.values.length), O = h == null ? void 0 : h[a.size], S = O ? G8e(O, y, a.direction) : 0;
    return b.useEffect(() => {
      if (l)
        return o.thumbs.add(l), () => {
          o.thumbs.delete(l);
        };
    }, [
      l,
      o.thumbs
    ]), m.jsxs("span", {
      style: {
        transform: "var(--radix-slider-thumb-transform)",
        position: "absolute",
        [a.startEdge]: `calc(${y}% + ${S}px)`
      },
      children: [
        m.jsx(ZR.ItemSlot, {
          scope: t.__scopeSlider,
          children: m.jsx(rt.span, {
            role: "slider",
            "aria-label": t["aria-label"] || g,
            "aria-valuemin": o.min,
            "aria-valuenow": f,
            "aria-valuemax": o.max,
            "aria-orientation": o.orientation,
            "data-orientation": o.orientation,
            "data-disabled": o.disabled ? "" : void 0,
            tabIndex: o.disabled ? void 0 : 0,
            ...s,
            ref: u,
            style: f === void 0 ? {
              display: "none"
            } : t.style,
            onFocus: Pe(t.onFocus, () => {
              o.valueIndexToChangeRef.current = r;
            })
          })
        }),
        d && m.jsx(gne, {
          name: i ?? (o.name ? o.name + (o.values.length > 1 ? "[]" : "") : void 0),
          form: o.form,
          value: f
        }, r)
      ]
    });
  });
  pne.displayName = YR;
  var W8e = "RadioBubbleInput", gne = b.forwardRef(({ __scopeSlider: t, value: e, ...n }, r) => {
    const i = b.useRef(null), s = Ht(i, r), o = Q8e(e);
    return b.useEffect(() => {
      const a = i.current;
      if (!a)
        return;
      const l = window.HTMLInputElement.prototype, u = Object.getOwnPropertyDescriptor(l, "value").set;
      if (o !== e && u) {
        const d = new Event("input", {
          bubbles: true
        });
        u.call(a, e), a.dispatchEvent(d);
      }
    }, [
      o,
      e
    ]), m.jsx(rt.input, {
      style: {
        display: "none"
      },
      ...n,
      ref: s,
      defaultValue: e
    });
  });
  gne.displayName = W8e;
  function Z8e(t = [], e, n) {
    const r = [
      ...t
    ];
    return r[n] = e, r.sort((i, s) => i - s);
  }
  function mne(t, e, n) {
    const s = 100 / (n - e) * (t - e);
    return nne(s, [
      0,
      100
    ]);
  }
  function H8e(t, e) {
    return e > 2 ? `Value ${t + 1} of ${e}` : e === 2 ? [
      "Minimum",
      "Maximum"
    ][t] : void 0;
  }
  function Y8e(t, e) {
    if (t.length === 1)
      return 0;
    const n = t.map((i) => Math.abs(i - e)), r = Math.min(...n);
    return n.indexOf(r);
  }
  function G8e(t, e, n) {
    const r = t / 2, s = KL([
      0,
      50
    ], [
      0,
      r
    ]);
    return (r - s(e) * n) * n;
  }
  function q8e(t) {
    return t.slice(0, -1).map((e, n) => t[n + 1] - e);
  }
  function K8e(t, e) {
    if (e > 0) {
      const n = q8e(t);
      return Math.min(...n) >= e;
    }
    return true;
  }
  function KL(t, e) {
    return (n) => {
      if (t[0] === t[1] || e[0] === e[1])
        return e[0];
      const r = (e[1] - e[0]) / (t[1] - t[0]);
      return e[0] + r * (n - t[0]);
    };
  }
  function J8e(t) {
    return (String(t).split(".")[1] || "").length;
  }
  function eFe(t, e) {
    const n = Math.pow(10, e);
    return Math.round(t * n) / n;
  }
  var tFe = ane, nFe = hne, rFe = fne, iFe = pne;
  const sFe = b.memo(function(e) {
    const { title: n, steps: r, value: i, label: s, onValueChange: o } = e, a = ue(), l = Tt(), c = b.useCallback((h) => {
      o(h[0], true);
    }, [
      o
    ]), u = b.useCallback(() => {
      a.mark("click slider");
    }, [
      a
    ]), d = b.useCallback(() => {
      i && o(i, false);
    }, [
      i,
      o
    ]);
    return m.jsx("div", {
      className: "tlui-slider__container",
      children: m.jsxs(tFe, {
        "data-testid": e["data-testid"],
        className: "tlui-slider",
        "area-label": "Opacity",
        dir: "ltr",
        min: 0,
        max: r,
        step: 1,
        value: i ? [
          i
        ] : void 0,
        onPointerDown: u,
        onValueChange: c,
        onPointerUp: d,
        title: n + " \u2014 " + l(s),
        children: [
          m.jsx(nFe, {
            className: "tlui-slider__track",
            dir: "ltr",
            children: i !== null && m.jsx(rFe, {
              className: "tlui-slider__range",
              dir: "ltr"
            })
          }),
          i !== null && m.jsx(iFe, {
            className: "tlui-slider__thumb",
            dir: "ltr"
          })
        ]
      })
    });
  }), oFe = b.memo(function({ label: e, uiTypeA: n, uiTypeB: r, labelA: i, labelB: s, itemsA: o, itemsB: a, styleA: l, styleB: c, valueA: u, valueB: d, onValueChange: h }) {
    const f = Tt(), y = b.useMemo(() => {
      var _a3;
      return ((_a3 = o.find((O) => u.type === "shared" && u.value === O.value)) == null ? void 0 : _a3.icon) ?? "mixed";
    }, [
      o,
      u
    ]), g = b.useMemo(() => {
      var _a3;
      return ((_a3 = a.find((O) => d.type === "shared" && d.value === O.value)) == null ? void 0 : _a3.icon) ?? "mixed";
    }, [
      a,
      d
    ]);
    return u === void 0 && d === void 0 ? null : m.jsxs("div", {
      className: "tlui-style-panel__double-select-picker",
      children: [
        m.jsx("div", {
          title: f(e),
          className: "tlui-style-panel__double-select-picker-label",
          children: f(e)
        }),
        m.jsxs(Pd, {
          id: `style panel ${n} A`,
          children: [
            m.jsx(Ug, {
              asChild: true,
              onTouchEnd: (O) => Rt(O),
              children: m.jsx(Be, {
                "data-testid": `style.${n}`,
                title: f(i) + " \u2014 " + f(u === null ? "style-panel.mixed" : `${n}-style.${u}`),
                icon: y,
                invertIcon: true,
                smallIcon: true
              })
            }),
            m.jsx(Cd, {
              side: "bottom",
              align: "end",
              sideOffset: 0,
              alignOffset: -2,
              children: m.jsx("div", {
                className: Ze("tlui-button-grid", {
                  "tlui-button-grid__two": o.length < 4,
                  "tlui-button-grid__four": o.length >= 4
                }),
                children: o.map((O) => m.jsx(Ks, {
                  className: "tlui-button-grid__button",
                  title: f(i) + " \u2014 " + f(`${n}-style.${O.value}`),
                  "data-testid": `style.${n}.${O.value}`,
                  icon: O.icon,
                  onClick: () => h(l, O.value, false),
                  invertIcon: true
                }, O.value))
              })
            })
          ]
        }),
        m.jsxs(Pd, {
          id: `style panel ${r}`,
          children: [
            m.jsx(Ug, {
              asChild: true,
              onTouchEnd: (O) => Rt(O),
              children: m.jsx(Be, {
                "data-testid": `style.${r}`,
                title: f(s) + " \u2014 " + f(d === null ? "style-panel.mixed" : `${r}-style.${d}`),
                icon: g,
                smallIcon: true
              })
            }),
            m.jsx(Cd, {
              side: "bottom",
              align: "end",
              sideOffset: 0,
              alignOffset: -2,
              children: m.jsx("div", {
                className: Ze("tlui-button-grid", {
                  "tlui-button-grid__two": o.length < 4,
                  "tlui-button-grid__four": o.length >= 4
                }),
                children: a.map((O) => m.jsx(Ks, {
                  className: "tlui-button-grid__button",
                  title: f(s) + " \u2014 " + f(`${r}-style.${O.value}`),
                  "data-testid": `style.${r}.${O.value}`,
                  icon: O.icon,
                  onClick: () => h(c, O.value, false)
                }, O.value))
              })
            })
          ]
        })
      ]
    });
  }), JL = b.memo(function({ id: e, label: n, uiType: r, style: i, items: s, value: o, onValueChange: a }) {
    const l = Tt(), c = b.useMemo(() => {
      var _a3;
      return (_a3 = s.find((u) => o.type === "shared" && u.value === o.value)) == null ? void 0 : _a3.icon;
    }, [
      s,
      o
    ]);
    return m.jsxs(Pd, {
      id: `style panel ${e}`,
      children: [
        m.jsx(Ug, {
          asChild: true,
          onTouchEnd: (u) => Rt(u),
          children: m.jsx(Be, {
            "data-testid": `style.${r}`,
            title: o.type === "mixed" ? l("style-panel.mixed") : l(`${r}-style.${o.value}`),
            label: n,
            icon: c ?? "mixed"
          })
        }),
        m.jsx(Cd, {
          side: "left",
          align: "center",
          alignOffset: 0,
          children: m.jsx("div", {
            className: Ze("tlui-button-grid", {
              "tlui-button-grid__two": s.length < 3,
              "tlui-button-grid__three": s.length == 3,
              "tlui-button-grid__four": s.length >= 4
            }),
            children: s.map((u) => m.jsx(Ks, {
              className: "tlui-button-grid__button",
              "data-testid": `style.${r}.${u.value}`,
              title: l(`${r}-style.${u.value}`),
              icon: u.icon,
              onClick: () => a(i, u.value, false)
            }, u.value))
          })
        })
      ]
    });
  }), Aa = {
    color: [
      {
        value: "black",
        icon: "color"
      },
      {
        value: "grey",
        icon: "color"
      },
      {
        value: "light-violet",
        icon: "color"
      },
      {
        value: "violet",
        icon: "color"
      },
      {
        value: "blue",
        icon: "color"
      },
      {
        value: "light-blue",
        icon: "color"
      },
      {
        value: "yellow",
        icon: "color"
      },
      {
        value: "orange",
        icon: "color"
      },
      {
        value: "green",
        icon: "color"
      },
      {
        value: "light-green",
        icon: "color"
      },
      {
        value: "light-red",
        icon: "color"
      },
      {
        value: "red",
        icon: "color"
      }
    ],
    fill: [
      {
        value: "none",
        icon: "fill-none"
      },
      {
        value: "semi",
        icon: "fill-semi"
      },
      {
        value: "solid",
        icon: "fill-solid"
      },
      {
        value: "pattern",
        icon: "fill-pattern"
      }
    ],
    dash: [
      {
        value: "draw",
        icon: "dash-draw"
      },
      {
        value: "dashed",
        icon: "dash-dashed"
      },
      {
        value: "dotted",
        icon: "dash-dotted"
      },
      {
        value: "solid",
        icon: "dash-solid"
      }
    ],
    size: [
      {
        value: "s",
        icon: "size-small"
      },
      {
        value: "m",
        icon: "size-medium"
      },
      {
        value: "l",
        icon: "size-large"
      },
      {
        value: "xl",
        icon: "size-extra-large"
      }
    ],
    font: [
      {
        value: "draw",
        icon: "font-draw"
      },
      {
        value: "sans",
        icon: "font-sans"
      },
      {
        value: "serif",
        icon: "font-serif"
      },
      {
        value: "mono",
        icon: "font-mono"
      }
    ],
    horizontalAlign: [
      {
        value: "start",
        icon: "text-align-left"
      },
      {
        value: "middle",
        icon: "text-align-center"
      },
      {
        value: "end",
        icon: "text-align-right"
      }
    ],
    verticalAlign: [
      {
        value: "start",
        icon: "vertical-align-start"
      },
      {
        value: "middle",
        icon: "vertical-align-center"
      },
      {
        value: "end",
        icon: "vertical-align-end"
      }
    ],
    geo: [
      {
        value: "rectangle",
        icon: "geo-rectangle"
      },
      {
        value: "ellipse",
        icon: "geo-ellipse"
      },
      {
        value: "cloud",
        icon: "geo-cloud"
      },
      {
        value: "triangle",
        icon: "geo-triangle"
      },
      {
        value: "diamond",
        icon: "geo-diamond"
      },
      {
        value: "pentagon",
        icon: "geo-pentagon"
      },
      {
        value: "hexagon",
        icon: "geo-hexagon"
      },
      {
        value: "octagon",
        icon: "geo-octagon"
      },
      {
        value: "star",
        icon: "geo-star"
      },
      {
        value: "rhombus",
        icon: "geo-rhombus"
      },
      {
        value: "rhombus-2",
        icon: "geo-rhombus-2"
      },
      {
        value: "oval",
        icon: "geo-oval"
      },
      {
        value: "trapezoid",
        icon: "geo-trapezoid"
      },
      {
        value: "arrow-right",
        icon: "geo-arrow-right"
      },
      {
        value: "arrow-left",
        icon: "geo-arrow-left"
      },
      {
        value: "arrow-up",
        icon: "geo-arrow-up"
      },
      {
        value: "arrow-down",
        icon: "geo-arrow-down"
      },
      {
        value: "x-box",
        icon: "geo-x-box"
      },
      {
        value: "check-box",
        icon: "geo-check-box"
      }
    ],
    arrowheadStart: [
      {
        value: "none",
        icon: "arrowhead-none"
      },
      {
        value: "arrow",
        icon: "arrowhead-arrow"
      },
      {
        value: "triangle",
        icon: "arrowhead-triangle"
      },
      {
        value: "square",
        icon: "arrowhead-square"
      },
      {
        value: "dot",
        icon: "arrowhead-dot"
      },
      {
        value: "diamond",
        icon: "arrowhead-diamond"
      },
      {
        value: "inverted",
        icon: "arrowhead-triangle-inverted"
      },
      {
        value: "bar",
        icon: "arrowhead-bar"
      }
    ],
    arrowheadEnd: [
      {
        value: "none",
        icon: "arrowhead-none"
      },
      {
        value: "arrow",
        icon: "arrowhead-arrow"
      },
      {
        value: "triangle",
        icon: "arrowhead-triangle"
      },
      {
        value: "square",
        icon: "arrowhead-square"
      },
      {
        value: "dot",
        icon: "arrowhead-dot"
      },
      {
        value: "diamond",
        icon: "arrowhead-diamond"
      },
      {
        value: "inverted",
        icon: "arrowhead-triangle-inverted"
      },
      {
        value: "bar",
        icon: "arrowhead-bar"
      }
    ],
    spline: [
      {
        value: "line",
        icon: "spline-line"
      },
      {
        value: "cubic",
        icon: "spline-cubic"
      }
    ]
  }, yne = function({ isMobile: e }) {
    const n = ue(), r = tne(), i = b.useCallback(() => {
      e || n.updateInstanceState({
        isChangingStyle: false
      });
    }, [
      n,
      e
    ]);
    if (!r)
      return null;
    const { styles: s, opacity: o } = r, a = s.get(Al), l = s.get(Sk), c = s.get(Ok), u = s.get(xk), d = s.get(jl), h = a === void 0, f = l === void 0 && c === void 0, y = u === void 0, g = d === void 0;
    return m.jsxs("div", {
      className: "tlui-style-panel",
      "data-ismobile": e,
      onPointerLeave: i,
      children: [
        m.jsx(aFe, {
          styles: s,
          opacity: o
        }),
        !g && m.jsx(lFe, {
          styles: s
        }),
        !(h && f && y) && m.jsxs("div", {
          className: "tlui-style-panel__section",
          "aria-label": "style panel styles",
          children: [
            m.jsx(cFe, {
              styles: s
            }),
            m.jsx(dFe, {
              styles: s
            }),
            m.jsx(uFe, {
              styles: s
            })
          ]
        })
      ]
    });
  };
  function SS() {
    const t = ue();
    return $e.useMemo(() => function(n, r, i) {
      t.batch(() => {
        t.isIn("select") && t.setStyleForSelectedShapes(n, r, {
          squashing: i
        }), t.setStyleForNextShapes(n, r, {
          squashing: i
        }), t.updateInstanceState({
          isChangingStyle: true
        });
      });
    }, [
      t
    ]);
  }
  const qy = [
    0.1,
    0.25,
    0.5,
    0.75,
    1
  ];
  function aFe({ styles: t, opacity: e }) {
    const n = ue(), r = Tt(), i = SS(), s = $e.useCallback((h, f) => {
      const y = qy[h];
      n.batch(() => {
        n.isIn("select") && n.setOpacityForSelectedShapes(y, {
          ephemeral: f
        }), n.setOpacityForNextShapes(y, {
          ephemeral: f
        }), n.updateInstanceState({
          isChangingStyle: true
        });
      });
    }, [
      n
    ]), o = t.get(na), a = t.get(jg), l = t.get(sf), c = t.get(Nl), u = a !== void 0 || l !== void 0 || c !== void 0, d = e.type === "mixed" ? -1 : qy.indexOf(Kwe(qy, (h) => Math.abs(h - e.value)));
    return m.jsxs(m.Fragment, {
      children: [
        m.jsxs("div", {
          tabIndex: -1,
          className: "tlui-style-panel__section__common",
          "aria-label": "style panel styles",
          children: [
            o === void 0 ? null : m.jsx(ig, {
              title: r("style-panel.color"),
              uiType: "color",
              style: na,
              items: Aa.color,
              value: o,
              onValueChange: i
            }),
            e === void 0 ? null : m.jsx(sFe, {
              "data-testid": "style.opacity",
              value: d >= 0 ? d : qy.length - 1,
              label: e.type === "mixed" ? "style-panel.mixed" : `opacity-style.${e.value}`,
              onValueChange: s,
              steps: qy.length - 1,
              title: r("style-panel.opacity")
            })
          ]
        }),
        u && m.jsxs("div", {
          className: "tlui-style-panel__section",
          "aria-label": "style panel styles",
          children: [
            a === void 0 ? null : m.jsx(ig, {
              title: r("style-panel.fill"),
              uiType: "fill",
              style: jg,
              items: Aa.fill,
              value: a,
              onValueChange: i
            }),
            l === void 0 ? null : m.jsx(ig, {
              title: r("style-panel.dash"),
              uiType: "dash",
              style: sf,
              items: Aa.dash,
              value: l,
              onValueChange: i
            }),
            c === void 0 ? null : m.jsx(ig, {
              title: r("style-panel.size"),
              uiType: "size",
              style: Nl,
              items: Aa.size,
              value: c,
              onValueChange: i
            })
          ]
        })
      ]
    });
  }
  function lFe({ styles: t }) {
    const e = Tt(), n = SS(), r = t.get(jl), i = t.get(Uv), s = t.get(wk);
    return r === void 0 && i === void 0 ? null : m.jsxs("div", {
      className: "tlui-style-panel__section",
      "aria-label": "style panel text",
      children: [
        r === void 0 ? null : m.jsx(ig, {
          title: e("style-panel.font"),
          uiType: "font",
          style: jl,
          items: Aa.font,
          value: r,
          onValueChange: n
        }),
        i === void 0 ? null : m.jsxs("div", {
          className: "tlui-style-panel__row",
          children: [
            m.jsx(ig, {
              title: e("style-panel.align"),
              uiType: "align",
              style: Uv,
              items: Aa.horizontalAlign,
              value: i,
              onValueChange: n
            }),
            s === void 0 ? m.jsx(Be, {
              title: e("style-panel.vertical-align"),
              "data-testid": "vertical-align",
              icon: "vertical-align-center",
              disabled: true
            }) : m.jsx(JL, {
              id: "geo-vertical-alignment",
              uiType: "verticalAlign",
              style: wk,
              items: Aa.verticalAlign,
              value: s,
              onValueChange: n
            })
          ]
        })
      ]
    });
  }
  function cFe({ styles: t }) {
    const e = SS(), n = t.get(Al);
    return n === void 0 ? null : m.jsx(JL, {
      id: "geo",
      label: "style-panel.geo",
      uiType: "geo",
      style: Al,
      items: Aa.geo,
      value: n,
      onValueChange: e
    });
  }
  function uFe({ styles: t }) {
    const e = SS(), n = t.get(xk);
    return n === void 0 ? null : m.jsx(JL, {
      id: "spline",
      label: "style-panel.spline",
      uiType: "spline",
      style: xk,
      items: Aa.spline,
      value: n,
      onValueChange: e
    });
  }
  function dFe({ styles: t }) {
    const e = SS(), n = t.get(Sk), r = t.get(Ok);
    return !n || !r ? null : m.jsx(oFe, {
      label: "style-panel.arrowheads",
      uiTypeA: "arrowheadStart",
      styleA: Ok,
      itemsA: Aa.arrowheadStart,
      valueA: r,
      uiTypeB: "arrowheadEnd",
      styleB: Sk,
      itemsB: Aa.arrowheadEnd,
      valueB: n,
      onValueChange: e,
      labelA: "style-panel.arrowhead-start",
      labelB: "style-panel.arrowhead-end"
    });
  }
  function hFe({ toast: t }) {
    const { removeToast: e } = Hl(), n = Tt(), r = (s) => {
      s || e(t.id);
    }, i = t.actions && t.actions.length > 0;
    return m.jsxs(bQe, {
      onOpenChange: r,
      className: "tlui-toast__container",
      duration: t.keepOpen ? 1 / 0 : 5e3,
      children: [
        t.icon && m.jsx("div", {
          className: "tlui-toast__icon",
          children: m.jsx(Ss, {
            icon: t.icon
          })
        }),
        m.jsxs("div", {
          className: "tlui-toast__main",
          children: [
            m.jsxs("div", {
              className: "tlui-toast__content",
              children: [
                t.title && m.jsx(kQe, {
                  className: "tlui-toast__title",
                  children: t.title
                }),
                t.description && m.jsx(PQe, {
                  className: "tlui-toast__description",
                  children: t.description
                })
              ]
            }),
            t.actions && m.jsxs("div", {
              className: "tlui-toast__actions",
              children: [
                t.actions.map((s, o) => m.jsx(CQe, {
                  altText: s.label,
                  asChild: true,
                  onClick: s.onClick,
                  children: m.jsx(Be, {
                    className: s.type === "warn" ? "tlui-button__warning" : "tlui-button__primary",
                    children: s.label
                  })
                }, o)),
                i && m.jsx(D7, {
                  asChild: true,
                  children: m.jsx(Be, {
                    className: "tlui-toast__close",
                    style: {
                      marginLeft: "auto"
                    },
                    children: t.closeLabel ?? n("toast.close")
                  })
                })
              ]
            })
          ]
        }),
        !i && m.jsx(D7, {
          asChild: true,
          children: m.jsx(Be, {
            className: "tlui-toast__close",
            children: t.closeLabel ?? n("toast.close")
          })
        })
      ]
    });
  }
  function fFe() {
    const { toasts: t } = Hl();
    return m.jsx(m.Fragment, {
      children: t.map((e) => m.jsx(hFe, {
        toast: e
      }, e.id))
    });
  }
  const pFe = b.memo(fFe);
  function gFe() {
    const { toasts: t } = Hl(), [e, n] = b.useState(false);
    return b.useEffect(() => {
      let r = false;
      return t.length ? n(true) : setTimeout(() => {
        r || n(false);
      }, 1e3), () => {
        r = true;
      };
    }, [
      t.length,
      n
    ]), e ? m.jsx(Mee, {
      className: "tlui-toast__viewport"
    }) : null;
  }
  function mFe() {
    const t = ue(), e = b.useRef(false), n = b.useCallback(() => {
      t.openMenus.length > 0 && (t.updateInstanceState({
        openMenus: []
      }), e.current = true);
    }, [
      t
    ]), r = b.useCallback((i) => {
      e.current && Rt(i), e.current = false;
    }, []);
    return {
      handlePointerDown: n,
      handleClick: r
    };
  }
  function yFe() {
    var _a3;
    const t = ue(), e = Tt(), r = (_a3 = tne()) == null ? void 0 : _a3.styles.get(na), i = ks({
      isDarkMode: t.user.isDarkMode
    }), s = ((r == null ? void 0 : r.type) === "shared" ? i[r.value] : i.black).solid, o = ye("isHandOrEraserToolActive", () => t.isInAny("hand", "zoom", "eraser", "laser"), [
      t
    ]), a = b.useCallback((c) => {
      c || t.updateInstanceState({
        isChangingStyle: false
      });
    }, [
      t
    ]), l = mFe();
    return m.jsxs(GL, {
      id: "style menu",
      onOpenChange: a,
      children: [
        m.jsx(qL, {
          disabled: o,
          children: m.jsx(Be, {
            className: "tlui-toolbar__tools__button tlui-toolbar__styles__button",
            "data-testid": "mobile.styles",
            style: {
              color: o ? "var(--color-muted-1)" : s
            },
            title: e("style-panel.title"),
            ...l,
            children: m.jsx(Ss, {
              icon: o ? "blob" : (r == null ? void 0 : r.type) === "mixed" ? "mixed" : "blob"
            })
          })
        }),
        m.jsx(Yte, {
          side: "top",
          align: "end",
          children: m.jsx(yne, {
            isMobile: true
          })
        })
      ]
    });
  }
  const vFe = [
    "select",
    "hand",
    "draw",
    "eraser",
    "text",
    "zoom",
    "laser",
    "highlight"
  ];
  function OFe({ activeToolId: t }) {
    const e = ue(), n = oa(), r = Tt(), i = ye("is tool locked", () => e.instanceState.isToolLocked, [
      e
    ]);
    return !t || vFe.includes(t) ? null : m.jsx(Be, {
      title: r("action.toggle-tool-lock"),
      className: Ze("tlui-toolbar__lock-button", {
        "tlui-toolbar__lock-button__mobile": n < 5
      }),
      icon: i ? "lock" : "unlock",
      onClick: () => e.updateInstanceState({
        isToolLocked: !i
      }),
      smallIcon: true
    });
  }
  const SFe = b.memo(function() {
    const e = ue(), n = Tt(), r = oa(), i = $e.useRef(void 0), s = sa(), o = b6e(), a = o.find((O) => O.toolItem.id === "laser"), l = ye("current tool id", () => e.currentToolId, [
      e
    ]), c = ye("geo", () => e.sharedStyles.getAsKnownValue(Al), [
      e
    ]), u = !s, d = (O) => O.label ? `${n(O.label)} ${O.kbd ? zl(O.kbd) : ""}` : "", h = o.find((O) => Pp(O.toolItem, l, c)), { itemsInPanel: f, itemsInDropdown: y, dropdownFirstItem: g } = $e.useMemo(() => {
      const O = [], S = [];
      let w;
      const x = Math.min(8, 5 + r);
      for (let P = 4; P < o.length; P++) {
        const C = o[P];
        P < x ? O.push(C) : (C === h && (w = C), S.push(C));
      }
      return w || (i.current || (i.current = S[0]), w = i.current, S.includes(w) || (w = S[0])), i.current = w, S.length <= 2 && (O.push(...S), S.length = 0), {
        itemsInPanel: O,
        itemsInDropdown: S,
        dropdownFirstItem: w
      };
    }, [
      o,
      h,
      r
    ]);
    return m.jsx("div", {
      className: "tlui-toolbar",
      children: m.jsxs("div", {
        className: "tlui-toolbar__inner",
        children: [
          m.jsxs("div", {
            className: "tlui-toolbar__left",
            children: [
              !s && m.jsxs("div", {
                className: "tlui-toolbar__extras",
                children: [
                  r < 6 && !(l === "hand" || l === "zoom") && m.jsxs("div", {
                    className: "tlui-toolbar__extras__controls",
                    children: [
                      m.jsx(ene, {}),
                      m.jsx(Kte, {}),
                      m.jsx(Jte, {}),
                      m.jsx(qte, {}),
                      m.jsx(Gte, {})
                    ]
                  }),
                  m.jsx(OFe, {
                    activeToolId: l
                  })
                ]
              }),
              m.jsxs("div", {
                className: Ze("tlui-toolbar__tools", {
                  "tlui-toolbar__tools__mobile": r < 5
                }),
                children: [
                  o.slice(0, 2).map(({ toolItem: O }) => m.jsx(Ky, {
                    item: O,
                    title: d(O),
                    isSelected: Pp(O, l, c)
                  }, O.id)),
                  s && a && m.jsx(Ky, {
                    item: a.toolItem,
                    title: d(a.toolItem),
                    isSelected: Pp(a.toolItem, l, c)
                  }, a.toolItem.id),
                  u && m.jsxs(m.Fragment, {
                    children: [
                      m.jsx("div", {
                        className: "tlui-toolbar__divider"
                      }),
                      o.slice(2, 4).map(({ toolItem: O }) => m.jsx(Ky, {
                        item: O,
                        title: d(O),
                        isSelected: Pp(O, l, c)
                      }, O.id)),
                      m.jsx("div", {
                        className: "tlui-toolbar__divider"
                      }),
                      f.map(({ toolItem: O }) => m.jsx(Ky, {
                        item: O,
                        title: d(O),
                        isSelected: Pp(O, l, c)
                      }, O.id)),
                      y.length ? m.jsxs(m.Fragment, {
                        children: [
                          m.jsx(Ky, {
                            item: g.toolItem,
                            title: d(g.toolItem),
                            isSelected: Pp(g.toolItem, l, c)
                          }, g.toolItem.id),
                          m.jsxs(Pd, {
                            id: "toolbar overflow",
                            modal: false,
                            children: [
                              m.jsx(fS, {
                                children: m.jsx(Be, {
                                  className: "tlui-toolbar__tools__button tlui-toolbar__overflow",
                                  icon: "chevron-up",
                                  "data-testid": "tools.more",
                                  title: n("tool-panel.more")
                                })
                              }),
                              m.jsx(Cd, {
                                side: "top",
                                align: "center",
                                children: m.jsx(wFe, {
                                  toolbarItems: y
                                })
                              })
                            ]
                          })
                        ]
                      }) : null
                    ]
                  })
                ]
              })
            ]
          }),
          r < 5 && !s && m.jsx("div", {
            className: "tlui-toolbar__tools",
            children: m.jsx(yFe, {})
          })
        ]
      })
    });
  }), wFe = Vt(function({ toolbarItems: e }) {
    const n = Tt();
    return m.jsx("div", {
      className: "tlui-button-grid__four tlui-button-grid__reverse",
      children: e.map(({ toolItem: { id: r, meta: i, kbd: s, label: o, onSelect: a, icon: l } }) => m.jsx(Ks, {
        className: "tlui-button-grid__button",
        "data-testid": `tools.${r}`,
        "data-tool": r,
        "data-geo": (i == null ? void 0 : i.geo) ?? "",
        "aria-label": o,
        onClick: () => a("toolbar"),
        title: o ? `${n(o)} ${s ? zl(s) : ""}` : "",
        icon: l
      }, r))
    });
  });
  function Ky({ item: t, title: e, isSelected: n }) {
    var _a3;
    return m.jsx(Be, {
      className: "tlui-toolbar__tools__button",
      "data-testid": `tools.${t.id}`,
      "data-tool": t.id,
      "data-geo": ((_a3 = t.meta) == null ? void 0 : _a3.geo) ?? "",
      "aria-label": t.label,
      title: e,
      icon: t.icon,
      "data-state": n ? "selected" : void 0,
      onClick: () => t.onSelect("toolbar"),
      onTouchStart: (r) => {
        Rt(r), t.onSelect("toolbar");
      }
    });
  }
  const Pp = (t, e, n) => {
    var _a3, _b3;
    return ((_a3 = t.meta) == null ? void 0 : _a3.geo) ? e === "geo" && n === ((_b3 = t.meta) == null ? void 0 : _b3.geo) : e === t.id;
  };
  function xFe() {
    const t = ue(), { addToast: e } = Hl();
    b.useEffect(() => {
      function n({ name: r, count: i }) {
        e({
          title: "Maximum Shapes Reached",
          description: `You've reached the maximum number of shapes allowed on ${r} (${i}). Please delete some shapes or move to a different page to continue.`
        });
      }
      return t.addListener("max-shapes", n), () => {
        t.removeListener("max-shapes", n);
      };
    }, [
      t,
      e
    ]);
  }
  const _I = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : false;
  function TI(t, e, n, r) {
    t.addEventListener ? t.addEventListener(e, n, r) : t.attachEvent && t.attachEvent("on".concat(e), n);
  }
  function Jy(t, e, n, r) {
    t.removeEventListener ? t.removeEventListener(e, n, r) : t.detachEvent && t.detachEvent("on".concat(e), n);
  }
  function vne(t, e) {
    const n = e.slice(0, e.length - 1);
    for (let r = 0; r < n.length; r++)
      n[r] = t[n[r].toLowerCase()];
    return n;
  }
  function One(t) {
    typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
    const e = t.split(",");
    let n = e.lastIndexOf("");
    for (; n >= 0; )
      e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
    return e;
  }
  function bFe(t, e) {
    const n = t.length >= e.length ? t : e, r = t.length >= e.length ? e : t;
    let i = true;
    for (let s = 0; s < n.length; s++)
      r.indexOf(n[s]) === -1 && (i = false);
    return i;
  }
  const aO = {
    backspace: 8,
    "\u232B": 8,
    tab: 9,
    clear: 12,
    enter: 13,
    "\u21A9": 13,
    return: 13,
    esc: 27,
    escape: 27,
    space: 32,
    left: 37,
    up: 38,
    right: 39,
    down: 40,
    arrowup: 38,
    arrowdown: 40,
    arrowleft: 37,
    arrowright: 39,
    del: 46,
    delete: 46,
    ins: 45,
    insert: 45,
    home: 36,
    end: 35,
    pageup: 33,
    pagedown: 34,
    capslock: 20,
    num_0: 96,
    num_1: 97,
    num_2: 98,
    num_3: 99,
    num_4: 100,
    num_5: 101,
    num_6: 102,
    num_7: 103,
    num_8: 104,
    num_9: 105,
    num_multiply: 106,
    num_add: 107,
    num_enter: 108,
    num_subtract: 109,
    num_decimal: 110,
    num_divide: 111,
    "\u21EA": 20,
    ",": 188,
    ".": 190,
    "/": 191,
    "`": 192,
    "-": _I ? 173 : 189,
    "=": _I ? 61 : 187,
    ";": _I ? 59 : 186,
    "'": 222,
    "{": 219,
    "}": 221,
    "[": 219,
    "]": 221,
    "\\": 220
  }, za = {
    "\u21E7": 16,
    shift: 16,
    "\u2325": 18,
    alt: 18,
    option: 18,
    "\u2303": 17,
    ctrl: 17,
    control: 17,
    "\u2318": 91,
    cmd: 91,
    meta: 91,
    command: 91
  }, x0 = {
    16: "shiftKey",
    18: "altKey",
    17: "ctrlKey",
    91: "metaKey",
    shiftKey: 16,
    ctrlKey: 17,
    altKey: 18,
    metaKey: 91
  }, zr = {
    16: false,
    18: false,
    17: false,
    91: false
  }, Mn = {};
  for (let t = 1; t < 20; t++)
    aO["f".concat(t)] = 111 + t;
  let Tn = [], nv = null, Sne = "all";
  const Oc = /* @__PURE__ */ new Map(), Nm = (t) => aO[t.toLowerCase()] || za[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), kFe = (t) => Object.keys(aO).find((e) => aO[e] === t), PFe = (t) => Object.keys(za).find((e) => za[e] === t);
  function wne(t) {
    Sne = t || "all";
  }
  function lO() {
    return Sne || "all";
  }
  function CFe() {
    return Tn.slice(0);
  }
  function _Fe() {
    return Tn.map((t) => kFe(t) || PFe(t) || String.fromCharCode(t));
  }
  function TFe() {
    const t = [];
    return Object.keys(Mn).forEach((e) => {
      Mn[e].forEach((n) => {
        let { key: r, scope: i, mods: s, shortcut: o } = n;
        t.push({
          scope: i,
          shortcut: o,
          mods: s,
          keys: r.split("+").map((a) => Nm(a))
        });
      });
    }), t;
  }
  function EFe(t) {
    const e = t.target || t.srcElement, { tagName: n } = e;
    let r = true;
    const i = n === "INPUT" && ![
      "checkbox",
      "radio",
      "range",
      "button",
      "file",
      "reset",
      "submit",
      "color"
    ].includes(e.type);
    return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (r = false), r;
  }
  function IFe(t) {
    return typeof t == "string" && (t = Nm(t)), Tn.indexOf(t) !== -1;
  }
  function $Fe(t, e) {
    let n, r;
    t || (t = lO());
    for (const i in Mn)
      if (Object.prototype.hasOwnProperty.call(Mn, i))
        for (n = Mn[i], r = 0; r < n.length; )
          n[r].scope === t ? n.splice(r, 1).forEach((o) => {
            let { element: a } = o;
            return ej(a);
          }) : r++;
    lO() === t && wne(e || "all");
  }
  function AFe(t) {
    let e = t.keyCode || t.which || t.charCode;
    t.key && t.key.toLowerCase() === "capslock" && (e = Nm(t.key));
    const n = Tn.indexOf(e);
    if (n >= 0 && Tn.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && Tn.splice(0, Tn.length), (e === 93 || e === 224) && (e = 91), e in zr) {
      zr[e] = false;
      for (const r in za)
        za[r] === e && (Ra[r] = false);
    }
  }
  function xne(t) {
    if (typeof t > "u")
      Object.keys(Mn).forEach((i) => {
        Array.isArray(Mn[i]) && Mn[i].forEach((s) => Fw(s)), delete Mn[i];
      }), ej(null);
    else if (Array.isArray(t))
      t.forEach((i) => {
        i.key && Fw(i);
      });
    else if (typeof t == "object")
      t.key && Fw(t);
    else if (typeof t == "string") {
      for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++)
        n[r - 1] = arguments[r];
      let [i, s] = n;
      typeof i == "function" && (s = i, i = ""), Fw({
        key: t,
        scope: i,
        method: s,
        splitKey: "+"
      });
    }
  }
  const Fw = (t) => {
    let { key: e, scope: n, method: r, splitKey: i = "+" } = t;
    One(e).forEach((o) => {
      const a = o.split(i), l = a.length, c = a[l - 1], u = c === "*" ? "*" : Nm(c);
      if (!Mn[u])
        return;
      n || (n = lO());
      const d = l > 1 ? vne(za, a) : [], h = [];
      Mn[u] = Mn[u].filter((f) => {
        const g = (r ? f.method === r : true) && f.scope === n && bFe(f.mods, d);
        return g && h.push(f.element), !g;
      }), h.forEach((f) => ej(f));
    });
  };
  function l9(t, e, n, r) {
    if (e.element !== r)
      return;
    let i;
    if (e.scope === n || e.scope === "all") {
      i = e.mods.length > 0;
      for (const s in zr)
        Object.prototype.hasOwnProperty.call(zr, s) && (!zr[s] && e.mods.indexOf(+s) > -1 || zr[s] && e.mods.indexOf(+s) === -1) && (i = false);
      (e.mods.length === 0 && !zr[16] && !zr[18] && !zr[17] && !zr[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(Tn), e.method(t, e) === false && (t.preventDefault ? t.preventDefault() : t.returnValue = false, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = true)));
    }
  }
  function c9(t, e) {
    const n = Mn["*"];
    let r = t.keyCode || t.which || t.charCode;
    if (t.key && t.key.toLowerCase() === "capslock" || !Ra.filter.call(this, t))
      return;
    if ((r === 93 || r === 224) && (r = 91), Tn.indexOf(r) === -1 && r !== 229 && Tn.push(r), [
      "metaKey",
      "ctrlKey",
      "altKey",
      "shiftKey"
    ].forEach((a) => {
      const l = x0[a];
      t[a] && Tn.indexOf(l) === -1 ? Tn.push(l) : !t[a] && Tn.indexOf(l) > -1 ? Tn.splice(Tn.indexOf(l), 1) : a === "metaKey" && t[a] && (Tn = Tn.filter((c) => c in x0 || c === r));
    }), r in zr) {
      zr[r] = true;
      for (const a in za)
        if (Object.prototype.hasOwnProperty.call(za, a)) {
          const l = x0[za[a]];
          Ra[a] = t[l];
        }
      if (!n)
        return;
    }
    for (const a in zr)
      Object.prototype.hasOwnProperty.call(zr, a) && (zr[a] = t[x0[a]]);
    t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (Tn.indexOf(17) === -1 && Tn.push(17), Tn.indexOf(18) === -1 && Tn.push(18), zr[17] = true, zr[18] = true);
    const i = lO();
    if (n)
      for (let a = 0; a < n.length; a++)
        n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && l9(t, n[a], i, e);
    if (!(r in Mn))
      return;
    const s = Mn[r], o = s.length;
    for (let a = 0; a < o; a++)
      if ((t.type === "keydown" && s[a].keydown || t.type === "keyup" && s[a].keyup) && s[a].key) {
        const l = s[a], { splitKey: c } = l, u = l.key.split(c), d = [];
        for (let h = 0; h < u.length; h++)
          d.push(Nm(u[h]));
        d.sort().join("") === Tn.sort().join("") && l9(t, l, i, e);
      }
  }
  function Ra(t, e, n) {
    Tn = [];
    const r = One(t);
    let i = [], s = "all", o = document, a = 0, l = false, c = true, u = "+", d = false, h = false;
    for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (o = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (d = e.capture), typeof e.splitKey == "string" && (u = e.splitKey), e.single === true && (h = true)), typeof e == "string" && (s = e), h && xne(t, s); a < r.length; a++)
      t = r[a].split(u), i = [], t.length > 1 && (i = vne(za, t)), t = t[t.length - 1], t = t === "*" ? "*" : Nm(t), t in Mn || (Mn[t] = []), Mn[t].push({
        keyup: l,
        keydown: c,
        scope: s,
        mods: i,
        shortcut: r[a],
        method: n,
        key: r[a],
        splitKey: u,
        element: o
      });
    if (typeof o < "u" && window) {
      if (!Oc.has(o)) {
        const f = function() {
          let g = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
          return c9(g, o);
        }, y = function() {
          let g = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
          c9(g, o), AFe(g);
        };
        Oc.set(o, {
          keydownListener: f,
          keyupListenr: y,
          capture: d
        }), TI(o, "keydown", f, d), TI(o, "keyup", y, d);
      }
      if (!nv) {
        const f = () => {
          Tn = [];
        };
        nv = {
          listener: f,
          capture: d
        }, TI(window, "focus", f, d);
      }
    }
  }
  function RFe(t) {
    let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
    Object.keys(Mn).forEach((n) => {
      Mn[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
        i && i.method && i.method();
      });
    });
  }
  function ej(t) {
    const e = Object.values(Mn).flat();
    if (e.findIndex((r) => {
      let { element: i } = r;
      return i === t;
    }) < 0) {
      const { keydownListener: r, keyupListenr: i, capture: s } = Oc.get(t) || {};
      r && i && (Jy(t, "keyup", i, s), Jy(t, "keydown", r, s), Oc.delete(t));
    }
    if ((e.length <= 0 || Oc.size <= 0) && (Object.keys(Oc).forEach((i) => {
      const { keydownListener: s, keyupListenr: o, capture: a } = Oc.get(i) || {};
      s && o && (Jy(i, "keyup", o, a), Jy(i, "keydown", s, a), Oc.delete(i));
    }), Oc.clear(), Object.keys(Mn).forEach((i) => delete Mn[i]), nv)) {
      const { listener: i, capture: s } = nv;
      Jy(window, "focus", i, s), nv = null;
    }
  }
  const EI = {
    getPressedKeyString: _Fe,
    setScope: wne,
    getScope: lO,
    deleteScope: $Fe,
    getPressedKeyCodes: CFe,
    getAllKeyCodes: TFe,
    isPressed: IFe,
    filter: EFe,
    trigger: RFe,
    unbind: xne,
    keyMap: aO,
    modifier: za,
    modifierMap: x0
  };
  for (const t in EI)
    Object.prototype.hasOwnProperty.call(EI, t) && (Ra[t] = EI[t]);
  if (typeof window < "u") {
    const t = window.hotkeys;
    Ra.noConflict = (e) => (e && window.hotkeys === Ra && (window.hotkeys = t), Ra), window.hotkeys = Ra;
  }
  const u9 = [
    "copy",
    "cut",
    "paste",
    "asset"
  ];
  function MFe() {
    const t = ue(), e = sa(), n = $i(), r = UL(), i = ye("is focused", () => t.instanceState.isFocused, [
      t
    ]);
    b.useEffect(() => {
      if (!i)
        return;
      const s = t.getContainer();
      Ra.setScope(t.store.id);
      const o = (l, c) => {
        Ra(l, {
          element: s,
          scope: t.store.id
        }, c);
      }, a = () => t.isMenuOpen || t.editingShapeId !== null || t.crashingError;
      for (const l of Object.values(n))
        l.kbd && (e && !l.readonlyOk || u9.includes(l.id) || o(d9(l.kbd), (c) => {
          a() || (Rt(c), l.onSelect("kbd"));
        }));
      for (const l of Object.values(r))
        !l.kbd || !l.readonlyOk && t.instanceState.isReadonly || u9.includes(l.id) || o(d9(l.kbd), (c) => {
          a() || (Rt(c), l.onSelect("kbd"));
        });
      return () => {
        Ra.deleteScope(t.store.id);
      };
    }, [
      n,
      r,
      e,
      t,
      i
    ]);
  }
  function d9(t) {
    return DFe(t).map((e) => {
      let n = "";
      const r = e.split("");
      return r.length === 1 ? n = r[0] : r[0] === "!" ? n = `shift+${r[1]}` : r[0] === "?" ? r.length === 3 && r[1] === "!" ? n = `alt+shift+${r[2]}` : n = `alt+${r[1]}` : r[0] === "$" ? r[1] === "!" ? n = `cmd+shift+${r[2]},ctrl+shift+${r[2]}` : r[1] === "?" ? n = `cmd+\u2325+${r[2]},ctrl+alt+${r[2]}` : n = `cmd+${r[1]},ctrl+${r[1]}` : n = e, n;
    }).join(",");
  }
  function DFe(t) {
    typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
    const e = t.split(",");
    let n = e.lastIndexOf("");
    for (; n >= 0; )
      e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
    return e;
  }
  const LFe = $e.memo(function({ shareZone: e, topZone: n, renderDebugMenuItems: r, children: i, hideUi: s, ...o }) {
    return m.jsx(T6e, {
      ...o,
      children: m.jsx(jFe, {
        hideUi: s,
        shareZone: e,
        topZone: n,
        renderDebugMenuItems: r,
        children: i
      })
    });
  }), jFe = $e.memo(function({ children: e, hideUi: n, ...r }) {
    return m.jsxs(m.Fragment, {
      children: [
        e,
        n ? null : m.jsx(NFe, {
          ...r
        })
      ]
    });
  }), NFe = $e.memo(function({ shareZone: e, topZone: n, renderDebugMenuItems: r }) {
    const i = ue(), s = Tt(), o = oa(), a = ye("isReadonlyMode", () => i.instanceState.isReadonly, [
      i
    ]), l = ye("focus", () => i.instanceState.isFocusMode, [
      i
    ]), c = ye("debug", () => i.instanceState.isDebugMode, [
      i
    ]);
    MFe(), GQe(), xFe();
    const { "toggle-focus-mode": u } = $i();
    return m.jsx(Aee, {
      children: m.jsxs("div", {
        className: Ze("tlui-layout", {
          "tlui-layout__mobile": o < 5
        }),
        "data-breakpoint": o,
        children: [
          l ? m.jsx("div", {
            className: "tlui-layout__top",
            children: m.jsx(Be, {
              className: "tlui-focus-button",
              title: `${s("focus-mode.toggle-focus-mode")}`,
              icon: "dot",
              onClick: () => u.onSelect("menu")
            })
          }) : m.jsxs(m.Fragment, {
            children: [
              m.jsxs("div", {
                className: "tlui-layout__top",
                children: [
                  m.jsxs("div", {
                    className: "tlui-layout__top__left",
                    children: [
                      m.jsx($8e, {}),
                      m.jsxs("div", {
                        className: "tlui-helper-buttons",
                        children: [
                          m.jsx(D8e, {}),
                          m.jsx(I6e, {}),
                          m.jsx(L8e, {})
                        ]
                      })
                    ]
                  }),
                  m.jsx("div", {
                    className: "tlui-layout__top__center",
                    children: n
                  }),
                  m.jsxs("div", {
                    className: "tlui-layout__top__right",
                    children: [
                      e,
                      o >= 5 && !a && m.jsx("div", {
                        className: "tlui-style-panel__wrapper",
                        children: m.jsx(yne, {})
                      })
                    ]
                  })
                ]
              }),
              m.jsxs("div", {
                className: "tlui-layout__bottom",
                children: [
                  m.jsxs("div", {
                    className: "tlui-layout__bottom__main",
                    children: [
                      m.jsx(M8e, {}),
                      m.jsx(SFe, {}),
                      o >= 4 && m.jsx(U6e, {})
                    ]
                  }),
                  c && m.jsx(A6e, {
                    renderDebugMenuItems: r ?? null
                  })
                ]
              })
            ]
          }),
          m.jsx(pFe, {}),
          m.jsx(z6e, {}),
          m.jsx(gFe, {}),
          m.jsx(F6e, {})
        ]
      })
    });
  });
  var tj = "ContextMenu", [QFe, iat] = Ps(tj, [
    JC
  ]), Ai = JC(), [zFe, bne] = QFe(tj), kne = (t) => {
    const { __scopeContextMenu: e, children: n, onOpenChange: r, dir: i, modal: s = true } = t, [o, a] = b.useState(false), l = Ai(e), c = ki(r), u = b.useCallback((d) => {
      a(d), c(d);
    }, [
      c
    ]);
    return m.jsx(zFe, {
      scope: e,
      open: o,
      onOpenChange: u,
      modal: s,
      children: m.jsx(OJ, {
        ...l,
        dir: i,
        open: o,
        onOpenChange: u,
        modal: s,
        children: n
      })
    });
  };
  kne.displayName = tj;
  var Pne = "ContextMenuTrigger", Cne = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, disabled: r = false, ...i } = t, s = bne(Pne, n), o = Ai(n), a = b.useRef({
      x: 0,
      y: 0
    }), l = b.useRef({
      getBoundingClientRect: () => DOMRect.fromRect({
        width: 0,
        height: 0,
        ...a.current
      })
    }), c = b.useRef(0), u = b.useCallback(() => window.clearTimeout(c.current), []), d = (h) => {
      a.current = {
        x: h.clientX,
        y: h.clientY
      }, s.onOpenChange(true);
    };
    return b.useEffect(() => u, [
      u
    ]), b.useEffect(() => void (r && u()), [
      r,
      u
    ]), m.jsxs(m.Fragment, {
      children: [
        m.jsx(SJ, {
          ...o,
          virtualRef: l
        }),
        m.jsx(rt.span, {
          "data-state": s.open ? "open" : "closed",
          "data-disabled": r ? "" : void 0,
          ...i,
          ref: e,
          style: {
            WebkitTouchCallout: "none",
            ...t.style
          },
          onContextMenu: r ? t.onContextMenu : Pe(t.onContextMenu, (h) => {
            u(), d(h), h.preventDefault();
          }),
          onPointerDown: r ? t.onPointerDown : Pe(t.onPointerDown, Bw((h) => {
            u(), c.current = window.setTimeout(() => d(h), 700);
          })),
          onPointerMove: r ? t.onPointerMove : Pe(t.onPointerMove, Bw(u)),
          onPointerCancel: r ? t.onPointerCancel : Pe(t.onPointerCancel, Bw(u)),
          onPointerUp: r ? t.onPointerUp : Pe(t.onPointerUp, Bw(u))
        })
      ]
    });
  });
  Cne.displayName = Pne;
  var FFe = "ContextMenuPortal", _ne = (t) => {
    const { __scopeContextMenu: e, ...n } = t, r = Ai(e);
    return m.jsx(wJ, {
      ...r,
      ...n
    });
  };
  _ne.displayName = FFe;
  var Tne = "ContextMenuContent", Ene = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = bne(Tne, n), s = Ai(n), o = b.useRef(false);
    return m.jsx(xJ, {
      ...s,
      ...r,
      ref: e,
      side: "right",
      sideOffset: 2,
      align: "start",
      onCloseAutoFocus: (a) => {
        var _a3;
        (_a3 = t.onCloseAutoFocus) == null ? void 0 : _a3.call(t, a), !a.defaultPrevented && o.current && a.preventDefault(), o.current = false;
      },
      onInteractOutside: (a) => {
        var _a3;
        (_a3 = t.onInteractOutside) == null ? void 0 : _a3.call(t, a), !a.defaultPrevented && !i.modal && (o.current = true);
      },
      style: {
        ...t.style,
        "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)"
      }
    });
  });
  Ene.displayName = Tne;
  var BFe = "ContextMenuGroup", Ine = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(bJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  Ine.displayName = BFe;
  var UFe = "ContextMenuLabel", VFe = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(kJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  VFe.displayName = UFe;
  var XFe = "ContextMenuItem", $ne = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(PJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  $ne.displayName = XFe;
  var WFe = "ContextMenuCheckboxItem", Ane = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(CJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  Ane.displayName = WFe;
  var ZFe = "ContextMenuRadioGroup", HFe = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(_J, {
      ...i,
      ...r,
      ref: e
    });
  });
  HFe.displayName = ZFe;
  var YFe = "ContextMenuRadioItem", GFe = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(TJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  GFe.displayName = YFe;
  var qFe = "ContextMenuItemIndicator", KFe = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(EJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  KFe.displayName = qFe;
  var JFe = "ContextMenuSeparator", e7e = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(IJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  e7e.displayName = JFe;
  var t7e = "ContextMenuArrow", n7e = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx($J, {
      ...i,
      ...r,
      ref: e
    });
  });
  n7e.displayName = t7e;
  var Rne = "ContextMenuSub", Mne = (t) => {
    const { __scopeContextMenu: e, children: n, onOpenChange: r, open: i, defaultOpen: s } = t, o = Ai(e), [a, l] = Wl({
      prop: i,
      defaultProp: s ?? false,
      onChange: r,
      caller: Rne
    });
    return m.jsx(AJ, {
      ...o,
      open: a,
      onOpenChange: l,
      children: n
    });
  };
  Mne.displayName = Rne;
  var r7e = "ContextMenuSubTrigger", Dne = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(RJ, {
      ...i,
      ...r,
      ref: e
    });
  });
  Dne.displayName = r7e;
  var i7e = "ContextMenuSubContent", Lne = b.forwardRef((t, e) => {
    const { __scopeContextMenu: n, ...r } = t, i = Ai(n);
    return m.jsx(MJ, {
      ...i,
      ...r,
      ref: e,
      style: {
        ...t.style,
        "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)"
      }
    });
  });
  Lne.displayName = i7e;
  function Bw(t) {
    return (e) => e.pointerType !== "mouse" ? t(e) : void 0;
  }
  var s7e = kne, o7e = Cne, eP = _ne, a7e = Ene, GR = Ine, qR = $ne, l7e = Ane, jne = Mne, Nne = Dne, Qne = Lne;
  const c7e = Vt(function() {
    const e = ue(), n = Kr(), r = e.pages, i = e.currentPageId, s = Tt(), { addToast: o } = Hl();
    return m.jsxs(jne, {
      children: [
        m.jsx(Nne, {
          dir: "ltr",
          asChild: true,
          children: m.jsx(Be, {
            className: "tlui-menu__button",
            label: "context-menu.move-to-page",
            "data-testid": "menu-item.move-to-page",
            icon: "chevron-right"
          })
        }),
        m.jsx(eP, {
          container: n,
          dir: "ltr",
          children: m.jsxs(Qne, {
            className: "tlui-menu",
            sideOffset: -4,
            collisionPadding: 4,
            children: [
              m.jsx(GR, {
                dir: "ltr",
                className: "tlui-menu__group",
                "data-testid": "menu-item.pages",
                children: r.map((a) => m.jsx(qR, {
                  disabled: i === a.id,
                  onSelect: () => {
                    e.mark("move_shapes_to_page"), e.moveShapesToPage(e.selectedShapeIds, a.id);
                    const l = e.getPage(a.id);
                    l && o({
                      title: "Changed Page",
                      description: `Moved to ${l.name}.`,
                      actions: [
                        {
                          label: "Go Back",
                          type: "primary",
                          onClick: () => {
                            e.mark("change-page"), e.setCurrentPage(i);
                          }
                        }
                      ]
                    });
                  },
                  asChild: true,
                  children: m.jsx(Be, {
                    title: a.name,
                    className: "tlui-menu__button tlui-context-menu__move-to-page__name",
                    children: m.jsx("span", {
                      children: a.name
                    })
                  })
                }, a.id))
              }, "pages"),
              m.jsx(GR, {
                dir: "ltr",
                className: "tlui-menu__group",
                "data-testid": "menu-item.new-page",
                children: m.jsx(qR, {
                  onSelect: () => {
                    const a = Zc.createId(), l = e.selectedShapeIds;
                    e.batch(() => {
                      e.mark("move_shapes_to_page"), e.createPage({
                        name: "Page",
                        id: a
                      }), e.moveShapesToPage(l, a);
                    });
                  },
                  asChild: true,
                  children: m.jsx(Be, {
                    title: s("context.pages.new-page"),
                    className: "tlui-menu__button tlui-context-menu__move-to-page__name",
                    children: s("context.pages.new-page")
                  })
                }, "new-page")
              }, "new-page")
            ]
          })
        })
      ]
    });
  }), u7e = function({ children: e }) {
    const n = ue(), r = cte(), i = b.useCallback((h) => {
      if (h) {
        if (n.instanceState.isCoarsePointer) {
          const { selectedShapes: f, inputs: { currentPagePoint: y } } = n, g = n.getShapesAtPoint(y);
          if (!n.selectedShapes.length || !g.some((O) => f.includes(O))) {
            const O = g.filter((S) => n.isShapeOrAncestorLocked(S));
            O.length && n.select(...O.map((S) => S.id));
          }
        }
      } else {
        const { onlySelectedShape: f } = n;
        f && n.isShapeOrAncestorLocked(f) && n.setSelectedShapes([]);
      }
    }, [
      n
    ]), s = Kr(), [o, a] = Pf("context menu", i), l = sa(), c = r.length === 0 || l && r.every((h) => !h.readonlyOk), d = !ye("isSelectToolActive", () => n.currentToolId === "select", [
      n
    ]) || c;
    return m.jsxs(s7e, {
      dir: "ltr",
      onOpenChange: a,
      children: [
        m.jsx(o7e, {
          onContextMenu: d ? Rt : void 0,
          dir: "ltr",
          disabled: d,
          children: e
        }),
        m.jsx(eP, {
          container: s,
          children: m.jsx(d7e, {})
        })
      ]
    });
  };
  function d7e() {
    const t = ue(), e = Tt(), n = cte(), [r, i] = Pf("context menu sub"), s = sa(), o = oa(), a = Kr(), [l, c] = b.useState(false);
    function u(d, h, f, y) {
      if (s && !h.readonlyOk)
        return null;
      switch (h.type) {
        case "custom": {
          switch (h.id) {
            case "MOVE_TO_PAGE_MENU":
              return m.jsx(c7e, {}, h.id);
          }
          break;
        }
        case "group":
          return m.jsx(GR, {
            dir: "ltr",
            className: Ze("tlui-menu__group", {
              "tlui-menu__group__small": (f == null ? void 0 : f.type) === "submenu"
            }),
            "data-testid": `menu-item.${h.id}`,
            children: h.children.map((g) => u(d, g, h, y + 1))
          }, h.id);
        case "submenu":
          return m.jsxs(jne, {
            onOpenChange: i,
            children: [
              m.jsx(Nne, {
                dir: "ltr",
                disabled: h.disabled,
                asChild: true,
                children: m.jsx(Be, {
                  className: "tlui-menu__button",
                  label: h.label,
                  "data-testid": `menu-item.${h.id}`,
                  icon: "chevron-right"
                })
              }),
              m.jsx(eP, {
                container: a,
                dir: "ltr",
                children: m.jsx(Qne, {
                  className: "tlui-menu",
                  sideOffset: -4,
                  collisionPadding: 4,
                  children: h.children.map((g) => u(d, g, h, y + 1))
                })
              })
            ]
          }, h.id);
        case "item": {
          if (s && !h.readonlyOk)
            return null;
          const { id: g, checkbox: O, contextMenuLabel: S, label: w, onSelect: x, kbd: P, icon: C } = h.actionItem, _ = S ?? w, T = _ ? e(_) : void 0;
          return O ? m.jsxs(l7e, {
            className: "tlui-button tlui-menu__button tlui-menu__checkbox-item",
            dir: "ltr",
            disabled: h.disabled,
            onSelect: ($) => {
              x("context-menu"), Rt($);
            },
            title: T || void 0,
            checked: h.checked,
            children: [
              m.jsx("div", {
                className: "tlui-menu__checkbox-item__check",
                style: {
                  transformOrigin: "75% center",
                  transform: `scale(${h.checked ? 1 : 0.5})`,
                  opacity: h.checked ? 1 : 0.5
                },
                children: m.jsx(Ss, {
                  small: true,
                  icon: h.checked ? "check" : "checkbox-empty"
                })
              }),
              T && m.jsx("span", {
                children: T
              }),
              P && m.jsx(zC, {
                children: P
              })
            ]
          }, g) : m.jsx(qR, {
            dir: "ltr",
            asChild: true,
            children: m.jsx(Be, {
              className: "tlui-menu__button",
              "data-testid": `menu-item.${g}`,
              kbd: P,
              label: _,
              disabled: h.disabled,
              iconLeft: o < 3 && y > 2 ? C : void 0,
              onClick: () => {
                l ? c(false) : x("context-menu");
              }
            })
          }, g);
        }
      }
    }
    return m.jsx(eP, {
      dir: "ltr",
      container: a,
      children: m.jsx(a7e, {
        className: "tlui-menu scrollable",
        alignOffset: -4,
        collisionPadding: 4,
        onContextMenu: Rt,
        children: n.map((d) => u(t, d, null, 0))
      })
    });
  }
  const Uw = (t, e) => {
    const [n, r] = b.useState(2);
    return b.useEffect(() => {
      const { url: i, style: s = "normal", weight: o = "500", display: a, featureSettings: l, stretch: c, unicodeRange: u, variant: d } = e;
      let h = false;
      r(2);
      const f = {
        style: s,
        weight: o,
        display: a,
        featureSettings: l,
        stretch: c,
        unicodeRange: u,
        variant: d
      }, y = new FontFace(t, `url(${i})`, f);
      return y.load().then(() => {
        h || (document.fonts.add(y), r(0));
      }).catch((g) => {
        h || (console.error(g), r(1));
      }), y.$$_url = i, y.$$_fontface = `
@font-face {
	font-family: ${y.family};
	font-stretch: ${y.stretch};
	font-weight: ${y.weight};
	font-style: ${y.style};
	src: url("${i}") format("woff2")
}`, () => {
        document.fonts.delete(y), h = true;
      };
    }, [
      t,
      e
    ]), n;
  };
  function h7e(t) {
    return {
      draw: {
        url: t.fonts.draw
      },
      serif: {
        url: t.fonts.serif
      },
      sansSerif: {
        url: t.fonts.sansSerif
      },
      monospace: {
        url: t.fonts.monospace
      }
    };
  }
  function f7e(t) {
    const e = b.useMemo(() => h7e(t), [
      t
    ]), n = [
      Uw("tldraw_draw", e.draw),
      Uw("tldraw_serif", e.serif),
      Uw("tldraw_sans", e.sansSerif),
      Uw("tldraw_mono", e.monospace)
    ];
    return {
      error: n.some((r) => r === 1),
      done: !n.some((r) => r === 2)
    };
  }
  function p7e(t) {
    const { children: e, maxImageDimension: n, maxAssetSize: r, acceptedImageMimeTypes: i, acceptedVideoMimeTypes: s, onMount: o, ...a } = t, l = {
      initialState: "select",
      ...a,
      components: b.useMemo(() => ({
        Scribble: r7,
        CollaboratorScribble: r7,
        SelectionForeground: JLe,
        SelectionBackground: GLe,
        Handles: VLe,
        HoveredShapeIndicator: XLe,
        ...a.components
      }), [
        a.components
      ]),
      shapeUtils: b.useMemo(() => [
        ...Eee,
        ...a.shapeUtils ?? []
      ], [
        a.shapeUtils
      ]),
      tools: b.useMemo(() => [
        ...nQe,
        ...Yje,
        ...a.tools ?? []
      ], [
        a.tools
      ])
    }, c = _Qe(a.assetUrls), { done: u, error: d } = f7e(c);
    return d ? m.jsx(GTe, {
      children: "Could not load assets. Please refresh the page."
    }) : u ? m.jsx(WTe, {
      ...l,
      children: m.jsxs(LFe, {
        ...l,
        children: [
          m.jsx(u7e, {
            children: m.jsx(P5, {})
          }),
          m.jsx(g7e, {
            maxImageDimension: n,
            maxAssetSize: r,
            acceptedImageMimeTypes: i,
            acceptedVideoMimeTypes: s,
            onMount: o
          }),
          e
        ]
      })
    }) : m.jsx(gq, {
      children: "Loading assets..."
    });
  }
  function g7e({ maxImageDimension: t = 1e3, maxAssetSize: e = 10 * 1024 * 1024, acceptedImageMimeTypes: n = [
    "image/jpeg",
    "image/png",
    "image/gif",
    "image/svg+xml"
  ], acceptedVideoMimeTypes: r = [
    "video/mp4",
    "video/quicktime"
  ], onMount: i }) {
    const s = ue(), o = m7e((a) => {
      const l = [];
      return l.push(...p4e(a)), Ije(a, {
        maxImageDimension: t,
        maxAssetSize: e,
        acceptedImageMimeTypes: n,
        acceptedVideoMimeTypes: r
      }), l.push(i == null ? void 0 : i(a)), () => {
        l.forEach((c) => c == null ? void 0 : c());
      };
    });
    return b.useLayoutEffect(() => {
      if (s)
        return o == null ? void 0 : o(s);
    }, [
      s,
      o
    ]), null;
  }
  function m7e(t) {
    const e = b.useRef();
    return b.useLayoutEffect(() => {
      e.current = t;
    }), b.useDebugValue(t), b.useCallback((...n) => {
      const r = e.current;
      return xC(r, "fn does not exist"), r(...n);
    }, []);
  }
  $t({
    tldrawFileFormatVersion: xxe,
    schema: $t({
      schemaVersion: dw,
      storeVersion: dw,
      recordVersions: JA(et, $t({
        version: dw,
        subTypeVersions: JA(et, dw).optional(),
        subTypeKey: et.optional()
      }))
    }),
    records: so($t({
      id: et,
      typeName: et
    }).allowUnknownProperties())
  });
  function y7e(t, e) {
    const n = [], r = {};
    t.forEach((s) => {
      if (!v7e(s))
        return;
      const o = h9(s.path), a = r[o] || JSON.parse(JSON.stringify(e.get(o) || {}));
      switch (s.action) {
        case "insert": {
          r[o] = O7e(s, a);
          break;
        }
        case "put":
          r[o] = S7e(s, a);
          break;
        case "update": {
          r[o] = w7e(s, a);
          break;
        }
        case "splice": {
          r[o] = x7e(s, a);
          break;
        }
        case "del": {
          const l = h9(s.path);
          n.push(l);
          break;
        }
        default:
          console.log("Unsupported patch:", s);
      }
    });
    const i = Object.values(r);
    console.log({
      patches: t,
      toPut: i
    }), e.mergeRemoteChanges(() => {
      n.length && e.remove(n), i.length && e.put(i);
    });
  }
  const v7e = (t) => t.path[0] === "store" && t.path.length > 1, h9 = (t) => t[1], O7e = (t, e) => {
    const { path: n, values: r } = t;
    let i = e;
    const s = n[n.length - 1], o = n[n.length - 2], a = n.slice(2, -2);
    for (const c of a) {
      if (i[c] === void 0)
        throw new Error("NO WAY");
      i = i[c];
    }
    const l = i[o].slice(0);
    return l.splice(s, 0, ...r), i[o] = l, e;
  }, S7e = (t, e) => {
    const { path: n, value: r } = t;
    let i = e;
    if (n.length === 2)
      return e;
    const s = n.slice(2, -2), o = n[n.length - 1], a = n[n.length - 2];
    if (n.length === 3)
      return {
        ...e,
        [o]: r
      };
    for (const l of s)
      i = i[l];
    return i[a] = {
      ...i[a],
      [o]: r
    }, e;
  }, w7e = (t, e) => {
    const { path: n, value: r } = t;
    let i = e;
    const s = n.slice(2, -1), o = n[n.length - 1];
    for (const a of s) {
      if (i[a] === void 0)
        throw new Error("NO WAY");
      i = i[a];
    }
    return i[o] = r, e;
  }, x7e = (t, e) => {
    const { path: n, value: r } = t;
    let i = e;
    const s = n[n.length - 1], o = n[n.length - 2], a = n.slice(2, -2);
    for (const l of a) {
      if (i[l] === void 0)
        throw new Error("NO WAY");
      i = i[l];
    }
    if (s !== 0)
      throw new Error("Splices are not supported yet");
    return i[o] = r, e;
  };
  function b7e(t, e) {
    Object.values(e.added).forEach((n) => {
      t.store[n.id] = n;
    }), Object.values(e.updated).forEach(([n, r]) => {
      KR(t.store[r.id], r);
    }), Object.values(e.removed).forEach((n) => {
      delete t.store[n.id];
    });
  }
  function KR(t, e) {
    if (ul.isArray(e))
      if (!ul.isArray(t))
        t = e.slice();
      else {
        for (let n = 0; n < e.length; n++)
          n >= t.length ? t.push(e[n]) : ul.isObject(e[n]) || ul.isArray(e[n]) ? KR(t[n], e[n]) : t[n] !== e[n] && (t[n] = e[n]);
        t.length > e.length && t.splice(e.length);
      }
    else
      ul.isObject(e) && (ul.forIn(e, (n, r) => {
        t[r] === void 0 ? t[r] = n : ul.isObject(n) || ul.isArray(n) ? KR(t[r], n) : t[r] !== n && (t[r] = n);
      }), ul.forIn(t, (n, r) => {
        e[r] === void 0 && delete t[r];
      }));
  }
  function k7e({ handle: t, userId: e, shapeUtils: n = [] }) {
    const [r] = b.useState(() => cR({
      shapeUtils: [
        ...Eee,
        ...n
      ]
    })), [i, s] = b.useState({
      status: "loading"
    }), [, o] = Sve({
      handle: t,
      userId: e,
      initialState: {}
    }), [a] = Ove({
      handle: t,
      localUserId: e
    });
    return b.useEffect(() => {
      const l = [], c = Object.values(a).filter((u) => u && Object.keys(u).length !== 0);
      l.length && r.remove(l), c.length && r.put(c);
    }, [
      r,
      a
    ]), b.useEffect(() => {
      XG({
        id: e
      });
      const l = ve("userPreferences", () => {
        const d = YG();
        return {
          id: d.id,
          color: d.color ?? Ys.color,
          name: d.name ?? Ys.name
        };
      }), c = yk.createId(e), u = Vxe(l, c)(r);
      return wm("when presence changes", () => {
        const d = u.value;
        requestAnimationFrame(() => {
          o(d);
        });
      });
    }, [
      r,
      e,
      o
    ]), b.useEffect(() => {
      const l = [];
      let c = false;
      function u({ changes: h }) {
        c = true, t.change((f) => {
          b7e(f, h);
        }), c = false;
      }
      l.push(r.listen(u, {
        source: "user",
        scope: "document"
      }));
      const d = ({ patches: h }) => {
        c || y7e(h, r);
      };
      return t.on("change", d), l.push(() => t.off("change", d)), t.whenReady().then(() => {
        const h = t.docSync();
        if (!h)
          throw new Error("Document not found");
        if (!h.store)
          throw new Error("Document store not initialized");
        r.mergeRemoteChanges(() => {
          r.loadSnapshot({
            store: JSON.parse(JSON.stringify(h.store)),
            schema: h.schema
          });
        }), s({
          store: r,
          status: "synced-remote",
          connectionStatus: "online"
        });
      }), () => {
        l.forEach((h) => h()), l.length = 0;
      };
    }, [
      t,
      r
    ]), i;
  }
  function P7e(t) {
    Object.assign(t, x1e);
  }
  var C7e = {
    xmlns: "http://www.w3.org/2000/svg",
    width: 24,
    height: 24,
    viewBox: "0 0 24 24",
    fill: "none",
    stroke: "currentColor",
    strokeWidth: 2,
    strokeLinecap: "round",
    strokeLinejoin: "round"
  };
  const _7e = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Pn = (t, e) => {
    const n = b.forwardRef(({ color: r = "currentColor", size: i = 24, strokeWidth: s = 2, absoluteStrokeWidth: o, children: a, ...l }, c) => b.createElement("svg", {
      ref: c,
      ...C7e,
      width: i,
      height: i,
      stroke: r,
      strokeWidth: o ? Number(s) * 24 / Number(i) : s,
      className: `lucide lucide-${_7e(t)}`,
      ...l
    }, [
      ...e.map(([u, d]) => b.createElement(u, d)),
      ...(Array.isArray(a) ? a : [
        a
      ]) || []
    ]));
    return n.displayName = `${t}`, n;
  }, zne = Pn("Check", [
    [
      "polyline",
      {
        points: "20 6 9 17 4 12",
        key: "10jjfj"
      }
    ]
  ]), T7e = Pn("ChevronRight", [
    [
      "path",
      {
        d: "m9 18 6-6-6-6",
        key: "mthhwq"
      }
    ]
  ]), E7e = Pn("ChevronsLeft", [
    [
      "path",
      {
        d: "m11 17-5-5 5-5",
        key: "13zhaf"
      }
    ],
    [
      "path",
      {
        d: "m18 17-5-5 5-5",
        key: "h8a8et"
      }
    ]
  ]), I7e = Pn("Circle", [
    [
      "circle",
      {
        cx: "12",
        cy: "12",
        r: "10",
        key: "1mglay"
      }
    ]
  ]), $7e = Pn("Copy", [
    [
      "rect",
      {
        width: "14",
        height: "14",
        x: "8",
        y: "8",
        rx: "2",
        ry: "2",
        key: "17jyea"
      }
    ],
    [
      "path",
      {
        d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",
        key: "zix9uf"
      }
    ]
  ]), A7e = Pn("Download", [
    [
      "path",
      {
        d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",
        key: "ih7n3h"
      }
    ],
    [
      "polyline",
      {
        points: "7 10 12 15 17 10",
        key: "2ggqvy"
      }
    ],
    [
      "line",
      {
        x1: "12",
        x2: "12",
        y1: "15",
        y2: "3",
        key: "1vk2je"
      }
    ]
  ]), f9 = Pn("EyeOff", [
    [
      "path",
      {
        d: "M9.88 9.88a3 3 0 1 0 4.24 4.24",
        key: "1jxqfv"
      }
    ],
    [
      "path",
      {
        d: "M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",
        key: "9wicm4"
      }
    ],
    [
      "path",
      {
        d: "M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",
        key: "1jreej"
      }
    ],
    [
      "line",
      {
        x1: "2",
        x2: "22",
        y1: "2",
        y2: "22",
        key: "a6p6uj"
      }
    ]
  ]), p9 = Pn("Eye", [
    [
      "path",
      {
        d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",
        key: "rwhkz3"
      }
    ],
    [
      "circle",
      {
        cx: "12",
        cy: "12",
        r: "3",
        key: "1v7zrd"
      }
    ]
  ]), R7e = Pn("FileQuestion", [
    [
      "path",
      {
        d: "M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",
        key: "1nnpy2"
      }
    ],
    [
      "path",
      {
        d: "M10 10.3c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",
        key: "1umxtm"
      }
    ],
    [
      "path",
      {
        d: "M12 17h.01",
        key: "p32p05"
      }
    ]
  ]), M7e = Pn("FolderInput", [
    [
      "path",
      {
        d: "M2 9V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",
        key: "1gu97c"
      }
    ],
    [
      "path",
      {
        d: "M2 13h10",
        key: "pgb2dq"
      }
    ],
    [
      "path",
      {
        d: "m9 16 3-3-3-3",
        key: "6m91ic"
      }
    ]
  ]), D7e = Pn("Folder", [
    [
      "path",
      {
        d: "M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",
        key: "1fr9dc"
      }
    ]
  ]), L7e = Pn("GitFork", [
    [
      "circle",
      {
        cx: "12",
        cy: "18",
        r: "3",
        key: "1mpf1b"
      }
    ],
    [
      "circle",
      {
        cx: "6",
        cy: "6",
        r: "3",
        key: "1lh9wr"
      }
    ],
    [
      "circle",
      {
        cx: "18",
        cy: "6",
        r: "3",
        key: "1h7g24"
      }
    ],
    [
      "path",
      {
        d: "M18 9v1a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V9",
        key: "c89w8i"
      }
    ],
    [
      "path",
      {
        d: "M12 12v3",
        key: "158kv8"
      }
    ]
  ]), j7e = Pn("Menu", [
    [
      "line",
      {
        x1: "4",
        x2: "20",
        y1: "12",
        y2: "12",
        key: "1e0a9i"
      }
    ],
    [
      "line",
      {
        x1: "4",
        x2: "20",
        y1: "6",
        y2: "6",
        key: "1owob3"
      }
    ],
    [
      "line",
      {
        x1: "4",
        x2: "20",
        y1: "18",
        y2: "18",
        key: "yk5zj1"
      }
    ]
  ]), N7e = Pn("MessageSquarePlus", [
    [
      "path",
      {
        d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",
        key: "1lielz"
      }
    ],
    [
      "line",
      {
        x1: "9",
        x2: "15",
        y1: "10",
        y2: "10",
        key: "1lj1wd"
      }
    ],
    [
      "line",
      {
        x1: "12",
        x2: "12",
        y1: "7",
        y2: "13",
        key: "1cppfj"
      }
    ]
  ]), Q7e = Pn("MoreHorizontal", [
    [
      "circle",
      {
        cx: "12",
        cy: "12",
        r: "1",
        key: "41hilf"
      }
    ],
    [
      "circle",
      {
        cx: "19",
        cy: "12",
        r: "1",
        key: "1wjl8i"
      }
    ],
    [
      "circle",
      {
        cx: "5",
        cy: "12",
        r: "1",
        key: "1pcz8c"
      }
    ]
  ]), z7e = Pn("PenLine", [
    [
      "path",
      {
        d: "M12 20h9",
        key: "t2du7b"
      }
    ],
    [
      "path",
      {
        d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",
        key: "ymcmye"
      }
    ]
  ]), F7e = Pn("Reply", [
    [
      "polyline",
      {
        points: "9 17 4 12 9 7",
        key: "hvgpf2"
      }
    ],
    [
      "path",
      {
        d: "M20 18v-2a4 4 0 0 0-4-4H4",
        key: "5vmcpk"
      }
    ]
  ]), B7e = Pn("Save", [
    [
      "path",
      {
        d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",
        key: "1owoqh"
      }
    ],
    [
      "polyline",
      {
        points: "17 21 17 13 7 13 7 21",
        key: "1md35c"
      }
    ],
    [
      "polyline",
      {
        points: "7 3 7 8 15 8",
        key: "8nz8an"
      }
    ]
  ]), U7e = Pn("Share", [
    [
      "path",
      {
        d: "M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",
        key: "1b2hhj"
      }
    ],
    [
      "polyline",
      {
        points: "16 6 12 2 8 6",
        key: "m901s6"
      }
    ],
    [
      "line",
      {
        x1: "12",
        x2: "12",
        y1: "2",
        y2: "15",
        key: "1p0rca"
      }
    ]
  ]), V7e = Pn("Text", [
    [
      "path",
      {
        d: "M17 6.1H3",
        key: "wptmhv"
      }
    ],
    [
      "path",
      {
        d: "M21 12.1H3",
        key: "1j38uz"
      }
    ],
    [
      "path",
      {
        d: "M15.1 18H3",
        key: "1nb16a"
      }
    ]
  ]), X7e = Pn("Trash2", [
    [
      "path",
      {
        d: "M3 6h18",
        key: "d0wm0j"
      }
    ],
    [
      "path",
      {
        d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",
        key: "4alrt4"
      }
    ],
    [
      "path",
      {
        d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",
        key: "v07s0e"
      }
    ],
    [
      "line",
      {
        x1: "10",
        x2: "10",
        y1: "11",
        y2: "17",
        key: "1uufr5"
      }
    ],
    [
      "line",
      {
        x1: "14",
        x2: "14",
        y1: "11",
        y2: "17",
        key: "xtxkd"
      }
    ]
  ]), W7e = Pn("User", [
    [
      "path",
      {
        d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",
        key: "975kel"
      }
    ],
    [
      "circle",
      {
        cx: "12",
        cy: "7",
        r: "4",
        key: "17ys0d"
      }
    ]
  ]), Z7e = Pn("WifiOff", [
    [
      "line",
      {
        x1: "2",
        x2: "22",
        y1: "2",
        y2: "22",
        key: "a6p6uj"
      }
    ],
    [
      "path",
      {
        d: "M8.5 16.5a5 5 0 0 1 7 0",
        key: "sej527"
      }
    ],
    [
      "path",
      {
        d: "M2 8.82a15 15 0 0 1 4.17-2.65",
        key: "11utq1"
      }
    ],
    [
      "path",
      {
        d: "M10.66 5c4.01-.36 8.14.9 11.34 3.76",
        key: "hxefdu"
      }
    ],
    [
      "path",
      {
        d: "M16.85 11.25a10 10 0 0 1 2.22 1.68",
        key: "q734kn"
      }
    ],
    [
      "path",
      {
        d: "M5 13a10 10 0 0 1 5.24-2.76",
        key: "piq4yl"
      }
    ],
    [
      "line",
      {
        x1: "12",
        x2: "12.01",
        y1: "20",
        y2: "20",
        key: "of4bc4"
      }
    ]
  ]), g9 = Pn("Wifi", [
    [
      "path",
      {
        d: "M5 13a10 10 0 0 1 14 0",
        key: "6v8j51"
      }
    ],
    [
      "path",
      {
        d: "M8.5 16.5a5 5 0 0 1 7 0",
        key: "sej527"
      }
    ],
    [
      "path",
      {
        d: "M2 8.82a15 15 0 0 1 20 0",
        key: "dnpr2z"
      }
    ],
    [
      "line",
      {
        x1: "12",
        x2: "12.01",
        y1: "20",
        y2: "20",
        key: "of4bc4"
      }
    ]
  ]), H7e = Pn("X", [
    [
      "path",
      {
        d: "M18 6 6 18",
        key: "1bl5f8"
      }
    ],
    [
      "path",
      {
        d: "m6 6 12 12",
        key: "d8bk6v"
      }
    ]
  ]), Y7e = (t) => {
    t.store["page:page"].name = "Copy of " + t.store["page:page"].name;
  }, G7e = (t) => t.store["page:page"].name || "Drawing", q7e = (t, e) => {
    t.store["page:page"].name = e;
  }, K7e = (t) => {
    P7e(t), t.store["page:page"].name = "Drawing";
  }, J7e = {
    id: "tldraw",
    name: "Drawing",
    icon: z7e,
    init: K7e,
    getTitle: G7e,
    setTitle: q7e,
    markCopy: Y7e
  };
  Tye(Eye);
  const e9e = (t, e) => {
    t.content = `# Untitled

`, t.commentThreads = {};
    const n = e.create();
    n.change((r) => {
      r.files = {};
    }), t.assetsDocUrl = n.url;
  }, t9e = (t) => {
    const e = t.content.search(/^#\s.*$/m);
    e !== -1 && dW(t, [
      "content"
    ], e + 2, 0, "Copy of ");
  }, n9e = (t) => new Blob([
    t.content
  ], {
    type: "text/markdown"
  }), r9e = (t) => {
    const e = t.content, n = /---\n([\s\S]+?)\n---/, r = e.match(n), i = r ? r[1] : "", s = /title:\s"(.+?)"/, o = /subtitle:\s"(.+?)"/, a = i.match(s), l = i.match(o);
    let c = a ? a[1] : null;
    const u = l ? l[1] : "";
    if (!c) {
      const d = /(^|\n)#\s(.+)/, h = e.match(d);
      c = h ? h[2] : "Untitled";
    }
    return `${c} ${u && `: ${u}`}`;
  }, i9e = {
    id: "essay",
    name: "Essay",
    icon: V7e,
    init: e9e,
    getTitle: r9e,
    markCopy: t9e
  }, s9e = (t) => {
    t.title = "Untitled Folder", t.docs = [];
  }, o9e = (t) => {
    t.title = `Copy of ${t.title}`;
  }, a9e = (t) => t.title, l9e = (t, e) => {
    t.title = e;
  }, c9e = {
    id: "folder",
    name: "Folder",
    icon: D7e,
    init: s9e,
    getTitle: a9e,
    setTitle: l9e,
    markCopy: o9e
  }, ws = {
    essay: i9e,
    tldraw: J7e,
    folder: c9e
  };
  var Fne = {
    exports: {}
  }, Bne = {};
  var Hg = b;
  function u9e(t, e) {
    return t === e && (t !== 0 || 1 / t === 1 / e) || t !== t && e !== e;
  }
  var d9e = typeof Object.is == "function" ? Object.is : u9e, h9e = Hg.useState, f9e = Hg.useEffect, p9e = Hg.useLayoutEffect, g9e = Hg.useDebugValue;
  function m9e(t, e) {
    var n = e(), r = h9e({
      inst: {
        value: n,
        getSnapshot: e
      }
    }), i = r[0].inst, s = r[1];
    return p9e(function() {
      i.value = n, i.getSnapshot = e, II(i) && s({
        inst: i
      });
    }, [
      t,
      n,
      e
    ]), f9e(function() {
      return II(i) && s({
        inst: i
      }), t(function() {
        II(i) && s({
          inst: i
        });
      });
    }, [
      t
    ]), g9e(n), n;
  }
  function II(t) {
    var e = t.getSnapshot;
    t = t.value;
    try {
      var n = e();
      return !d9e(t, n);
    } catch {
      return true;
    }
  }
  function y9e(t, e) {
    return e();
  }
  var v9e = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? y9e : m9e;
  Bne.useSyncExternalStore = Hg.useSyncExternalStore !== void 0 ? Hg.useSyncExternalStore : v9e;
  Fne.exports = Bne;
  var p2 = Fne.exports;
  const Une = b.createContext(null);
  function fo() {
    const t = b.useContext(Une);
    if (t === null)
      throw new Error("No Tree Api Provided");
    return t;
  }
  const Vne = b.createContext(null);
  function O9e() {
    const t = b.useContext(Vne);
    if (t === null)
      throw new Error("Provide a NodesContext");
    return t;
  }
  const Xne = b.createContext(null);
  function S9e() {
    const t = b.useContext(Xne);
    if (t === null)
      throw new Error("Provide a DnDContext");
    return t;
  }
  const Wne = b.createContext(0);
  function Zne() {
    b.useContext(Wne);
  }
  function nb(t, e, n) {
    return Math.max(Math.min(t, n), e);
  }
  function Hne(t) {
    return t && t.isLeaf;
  }
  function Yne(t) {
    return t && t.isInternal && !t.isOpen;
  }
  function Gne(t) {
    var e;
    return t && t.isOpen && !(!((e = t.children) === null || e === void 0) && e.length);
  }
  const qne = (t, e) => {
    let n = t;
    for (; n; ) {
      if (n.id === e.id)
        return true;
      n = n.parent;
    }
    return false;
  }, Kne = (t) => {
    if (!t.parent)
      throw Error("Node does not have a parent");
    return t.parent.children.findIndex((e) => e.id === t.id);
  };
  function w9e() {
  }
  function nj(t, e) {
    if (!t)
      return null;
    if (t.id === e)
      return t;
    if (t.children)
      for (let n of t.children) {
        const r = nj(n, e);
        if (r)
          return r;
      }
    return null;
  }
  function tP(t, e) {
    if (e(t), t.children)
      for (let n of t.children)
        tP(n, e);
  }
  function Jne(t) {
    const e = tre(t);
    let n;
    for (let r = 0; r < e.length; ++r)
      if (e[r] === t) {
        n = x9e(e, r);
        break;
      }
    n == null ? void 0 : n.focus();
  }
  function ere(t) {
    const e = tre(t);
    let n;
    for (let r = 0; r < e.length; ++r)
      if (e[r] === t) {
        n = b9e(e, r);
        break;
      }
    n == null ? void 0 : n.focus();
  }
  function x9e(t, e) {
    return e + 1 < t.length ? t[e + 1] : t[0];
  }
  function b9e(t, e) {
    return e - 1 >= 0 ? t[e - 1] : t[t.length - 1];
  }
  function tre(t) {
    return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter((e) => e === t || !t.contains(e));
  }
  function b0(t, e) {
    return typeof e == "boolean" ? e : typeof e == "string" ? t[e] : e(t);
  }
  function nre(t) {
    return t === null ? null : xh(t);
  }
  function xh(t) {
    return typeof t == "string" ? t : t.id;
  }
  function k9e(...t) {
    return (e) => {
      t.forEach((n) => {
        typeof n == "function" ? n(e) : n != null && (n.current = e);
      });
    };
  }
  function rre(t, ...e) {
    if (t)
      return t(...e);
  }
  function ire(t) {
    return new Promise((e, n) => {
      let r = 0;
      function i() {
        r += 1, r === 100 && n(), t() ? e() : setTimeout(i, 10);
      }
      i();
    });
  }
  function sre(t) {
    var e, n;
    const r = t.focusedNode;
    return r ? r.isOpen ? 0 : r.parent ? r.childIndex + 1 : 0 : (n = (e = t.root.children) === null || e === void 0 ? void 0 : e.length) !== null && n !== void 0 ? n : 0;
  }
  function ore(t) {
    const e = t.focusedNode;
    return e ? e.isOpen ? e.id : e.parent && !e.parent.isRoot ? e.parent.id : null : null;
  }
  const P9e = Object.freeze(Object.defineProperty({
    __proto__: null,
    access: b0,
    bound: nb,
    dfs: nj,
    focusNextElement: Jne,
    focusPrevElement: ere,
    getInsertIndex: sre,
    getInsertParentId: ore,
    identify: xh,
    identifyNull: nre,
    indexOf: Kne,
    isClosed: Yne,
    isDescendant: qne,
    isItem: Hne,
    isOpenWithEmptyChildren: Gne,
    mergeRefs: k9e,
    noop: w9e,
    safeRun: rre,
    waitFor: ire,
    walk: tP
  }, Symbol.toStringTag, {
    value: "Module"
  })), C9e = {
    display: "flex",
    alignItems: "center",
    zIndex: 1
  }, _9e = {
    flex: 1,
    height: "2px",
    background: "#4B91E2",
    borderRadius: "1px"
  }, T9e = {
    width: "4px",
    height: "4px",
    boxShadow: "0 0 0 3px #4B91E2",
    borderRadius: "50%"
  }, E9e = $e.memo(function({ top: e, left: n, indent: r }) {
    const i = {
      position: "absolute",
      pointerEvents: "none",
      top: e - 2 + "px",
      left: n + "px",
      right: r + "px"
    };
    return m.jsxs("div", {
      style: Object.assign(Object.assign({}, C9e), i),
      children: [
        m.jsx("div", {
          style: Object.assign({}, T9e)
        }),
        m.jsx("div", {
          style: Object.assign({}, _9e)
        })
      ]
    });
  });
  function I9e({ node: t, attrs: e, innerRef: n, children: r }) {
    return m.jsx("div", Object.assign({}, e, {
      ref: n,
      onFocus: (i) => i.stopPropagation(),
      onClick: t.handleClick,
      children: r
    }));
  }
  function $9e(t) {
    return m.jsxs("div", {
      ref: t.dragHandle,
      style: t.style,
      children: [
        m.jsx("span", {
          onClick: (e) => {
            e.stopPropagation(), t.node.toggle();
          },
          children: t.node.isLeaf ? "\u{1F333}" : t.node.isOpen ? "\u{1F5C1}" : "\u{1F5C0}"
        }),
        " ",
        t.node.isEditing ? m.jsx(R9e, Object.assign({}, t)) : m.jsx(A9e, Object.assign({}, t))
      ]
    });
  }
  function A9e(t) {
    return m.jsx(m.Fragment, {
      children: m.jsx("span", {
        children: t.node.data.name
      })
    });
  }
  function R9e({ node: t }) {
    const e = b.useRef();
    return b.useEffect(() => {
      var n, r;
      (n = e.current) === null || n === void 0 || n.focus(), (r = e.current) === null || r === void 0 || r.select();
    }, []), m.jsx("input", {
      ref: e,
      defaultValue: t.data.name,
      onBlur: () => t.reset(),
      onKeyDown: (n) => {
        var r;
        n.key === "Escape" && t.reset(), n.key === "Enter" && t.submit(((r = e.current) === null || r === void 0 ? void 0 : r.value) || "");
      }
    });
  }
  function $I(t) {
    return {
      type: "EDIT",
      id: t
    };
  }
  function M9e(t = {
    id: null
  }, e) {
    return e.type === "EDIT" ? Object.assign(Object.assign({}, t), {
      id: e.id
    }) : t;
  }
  function Cp(t) {
    return {
      type: "FOCUS",
      id: t
    };
  }
  function D9e() {
    return {
      type: "TREE_BLUR"
    };
  }
  function L9e(t = {
    id: null,
    treeFocused: false
  }, e) {
    return e.type === "FOCUS" ? Object.assign(Object.assign({}, t), {
      id: e.id,
      treeFocused: true
    }) : e.type === "TREE_BLUR" ? Object.assign(Object.assign({}, t), {
      treeFocused: false
    }) : t;
  }
  class nP {
    constructor(e) {
      this.handleClick = (n) => {
        n.metaKey && !this.tree.props.disableMultiSelection ? this.isSelected ? this.deselect() : this.selectMulti() : n.shiftKey && !this.tree.props.disableMultiSelection ? this.selectContiguous() : (this.select(), this.activate());
      }, this.tree = e.tree, this.id = e.id, this.data = e.data, this.level = e.level, this.children = e.children, this.parent = e.parent, this.isDraggable = e.isDraggable, this.rowIndex = e.rowIndex;
    }
    get isRoot() {
      return this.id === cO;
    }
    get isLeaf() {
      return !Array.isArray(this.children);
    }
    get isInternal() {
      return !this.isLeaf;
    }
    get isOpen() {
      return this.isLeaf ? false : this.tree.isOpen(this.id);
    }
    get isClosed() {
      return this.isLeaf ? false : !this.tree.isOpen(this.id);
    }
    get isEditable() {
      return this.tree.isEditable(this.data);
    }
    get isEditing() {
      return this.tree.editingId === this.id;
    }
    get isSelected() {
      return this.tree.isSelected(this.id);
    }
    get isOnlySelection() {
      return this.isSelected && this.tree.hasOneSelection;
    }
    get isSelectedStart() {
      var e;
      return this.isSelected && !(!((e = this.prev) === null || e === void 0) && e.isSelected);
    }
    get isSelectedEnd() {
      var e;
      return this.isSelected && !(!((e = this.next) === null || e === void 0) && e.isSelected);
    }
    get isFocused() {
      return this.tree.isFocused(this.id);
    }
    get isDragging() {
      return this.tree.isDragging(this.id);
    }
    get willReceiveDrop() {
      return this.tree.willReceiveDrop(this.id);
    }
    get state() {
      return {
        isClosed: this.isClosed,
        isDragging: this.isDragging,
        isEditing: this.isEditing,
        isFocused: this.isFocused,
        isInternal: this.isInternal,
        isLeaf: this.isLeaf,
        isOpen: this.isOpen,
        isSelected: this.isSelected,
        isSelectedEnd: this.isSelectedEnd,
        isSelectedStart: this.isSelectedStart,
        willReceiveDrop: this.willReceiveDrop
      };
    }
    get childIndex() {
      return this.parent && this.parent.children ? this.parent.children.findIndex((e) => e.id === this.id) : -1;
    }
    get next() {
      return this.rowIndex === null ? null : this.tree.at(this.rowIndex + 1);
    }
    get prev() {
      return this.rowIndex === null ? null : this.tree.at(this.rowIndex - 1);
    }
    get nextSibling() {
      var e, n;
      const r = this.childIndex;
      return (n = (e = this.parent) === null || e === void 0 ? void 0 : e.children[r + 1]) !== null && n !== void 0 ? n : null;
    }
    isAncestorOf(e) {
      if (!e)
        return false;
      let n = e;
      for (; n; ) {
        if (n.id === this.id)
          return true;
        n = n.parent;
      }
      return false;
    }
    select() {
      this.tree.select(this);
    }
    deselect() {
      this.tree.deselect(this);
    }
    selectMulti() {
      this.tree.selectMulti(this);
    }
    selectContiguous() {
      this.tree.selectContiguous(this);
    }
    activate() {
      this.tree.activate(this);
    }
    focus() {
      this.tree.focus(this);
    }
    toggle() {
      this.tree.toggle(this);
    }
    open() {
      this.tree.open(this);
    }
    openParents() {
      this.tree.openParents(this);
    }
    close() {
      this.tree.close(this);
    }
    submit(e) {
      this.tree.submit(this, e);
    }
    reset() {
      this.tree.reset();
    }
    clone() {
      return new nP(Object.assign({}, this));
    }
    edit() {
      return this.tree.edit(this);
    }
  }
  const cO = "__REACT_ARBORIST_INTERNAL_ROOT__";
  function m9(t) {
    var e;
    function n(s, o, a) {
      const l = t.accessId(s), c = new nP({
        tree: t,
        data: s,
        level: o,
        parent: a,
        id: l,
        children: null,
        isDraggable: t.isDraggable(s),
        rowIndex: null
      }), u = t.accessChildren(s);
      return u && (c.children = u.map((d) => n(d, o + 1, c))), c;
    }
    const r = new nP({
      tree: t,
      id: cO,
      data: {
        id: cO
      },
      level: -1,
      parent: null,
      children: null,
      isDraggable: true,
      rowIndex: null
    }), i = (e = t.props.data) !== null && e !== void 0 ? e : [];
    return r.children = i.map((s) => n(s, 0, r)), r;
  }
  const JR = {
    open(t, e) {
      return {
        type: "VISIBILITY_OPEN",
        id: t,
        filtered: e
      };
    },
    close(t, e) {
      return {
        type: "VISIBILITY_CLOSE",
        id: t,
        filtered: e
      };
    },
    toggle(t, e) {
      return {
        type: "VISIBILITY_TOGGLE",
        id: t,
        filtered: e
      };
    },
    clear(t) {
      return {
        type: "VISIBILITY_CLEAR",
        filtered: t
      };
    }
  };
  function y9(t = {}, e) {
    if (e.type === "VISIBILITY_OPEN")
      return Object.assign(Object.assign({}, t), {
        [e.id]: true
      });
    if (e.type === "VISIBILITY_CLOSE")
      return Object.assign(Object.assign({}, t), {
        [e.id]: false
      });
    if (e.type === "VISIBILITY_TOGGLE") {
      const n = t[e.id];
      return Object.assign(Object.assign({}, t), {
        [e.id]: !n
      });
    } else
      return e.type === "VISIBILITY_CLEAR" ? {} : t;
  }
  function j9e(t = {
    filtered: {},
    unfiltered: {}
  }, e) {
    return e.type.startsWith("VISIBILITY") ? e.filtered ? Object.assign(Object.assign({}, t), {
      filtered: y9(t.filtered, e)
    }) : Object.assign(Object.assign({}, t), {
      unfiltered: y9(t.unfiltered, e)
    }) : t;
  }
  const Yg = (t) => {
    var e;
    return {
      nodes: {
        open: {
          filtered: {},
          unfiltered: (e = t == null ? void 0 : t.initialOpenState) !== null && e !== void 0 ? e : {}
        },
        focus: {
          id: null,
          treeFocused: false
        },
        edit: {
          id: null
        },
        drag: {
          id: null,
          selectedIds: [],
          destinationParentId: null,
          destinationIndex: null
        },
        selection: {
          ids: /* @__PURE__ */ new Set(),
          anchor: null,
          mostRecent: null
        }
      },
      dnd: {
        cursor: {
          type: "none"
        },
        dragId: null,
        dragIds: [],
        parentId: null,
        index: -1
      }
    };
  }, ya = {
    clear: () => ({
      type: "SELECTION_CLEAR"
    }),
    only: (t) => ({
      type: "SELECTION_ONLY",
      id: xh(t)
    }),
    add: (t) => ({
      type: "SELECTION_ADD",
      ids: (Array.isArray(t) ? t : [
        t
      ]).map(xh)
    }),
    remove: (t) => ({
      type: "SELECTION_REMOVE",
      ids: (Array.isArray(t) ? t : [
        t
      ]).map(xh)
    }),
    set: (t) => Object.assign({
      type: "SELECTION_SET"
    }, t),
    mostRecent: (t) => ({
      type: "SELECTION_MOST_RECENT",
      id: t === null ? null : xh(t)
    }),
    anchor: (t) => ({
      type: "SELECTION_ANCHOR",
      id: t === null ? null : xh(t)
    })
  };
  function N9e(t = Yg().nodes.selection, e) {
    const n = t.ids;
    switch (e.type) {
      case "SELECTION_CLEAR":
        return Object.assign(Object.assign({}, t), {
          ids: /* @__PURE__ */ new Set()
        });
      case "SELECTION_ONLY":
        return Object.assign(Object.assign({}, t), {
          ids: /* @__PURE__ */ new Set([
            e.id
          ])
        });
      case "SELECTION_ADD":
        return e.ids.length === 0 ? t : (e.ids.forEach((r) => n.add(r)), Object.assign(Object.assign({}, t), {
          ids: new Set(n)
        }));
      case "SELECTION_REMOVE":
        return e.ids.length === 0 ? t : (e.ids.forEach((r) => n.delete(r)), Object.assign(Object.assign({}, t), {
          ids: new Set(n)
        }));
      case "SELECTION_SET":
        return Object.assign(Object.assign({}, t), {
          ids: e.ids,
          mostRecent: e.mostRecent,
          anchor: e.anchor
        });
      case "SELECTION_MOST_RECENT":
        return Object.assign(Object.assign({}, t), {
          mostRecent: e.id
        });
      case "SELECTION_ANCHOR":
        return Object.assign(Object.assign({}, t), {
          anchor: e.id
        });
      default:
        return t;
    }
  }
  const Gg = {
    cursor(t) {
      return {
        type: "DND_CURSOR",
        cursor: t
      };
    },
    dragStart(t, e) {
      return {
        type: "DND_DRAG_START",
        id: t,
        dragIds: e
      };
    },
    dragEnd() {
      return {
        type: "DND_DRAG_END"
      };
    },
    hovering(t, e) {
      return {
        type: "DND_HOVERING",
        parentId: t,
        index: e
      };
    }
  };
  function Q9e(t = Yg().dnd, e) {
    switch (e.type) {
      case "DND_CURSOR":
        return Object.assign(Object.assign({}, t), {
          cursor: e.cursor
        });
      case "DND_DRAG_START":
        return Object.assign(Object.assign({}, t), {
          dragId: e.id,
          dragIds: e.dragIds
        });
      case "DND_DRAG_END":
        return Yg().dnd;
      case "DND_HOVERING":
        return Object.assign(Object.assign({}, t), {
          parentId: e.parentId,
          index: e.index
        });
      default:
        return t;
    }
  }
  const z9e = {
    position: "fixed",
    pointerEvents: "none",
    zIndex: 100,
    left: 0,
    top: 0,
    width: "100%",
    height: "100%"
  }, F9e = (t) => {
    if (!t)
      return {
        display: "none"
      };
    const { x: e, y: n } = t;
    return {
      transform: `translate(${e}px, ${n}px)`
    };
  }, B9e = (t) => {
    if (!t)
      return {
        display: "none"
      };
    const { x: e, y: n } = t;
    return {
      transform: `translate(${e + 10}px, ${n + 10}px)`
    };
  };
  function are({ offset: t, mouse: e, id: n, dragIds: r, isDragging: i }) {
    return m.jsxs(U9e, {
      isDragging: i,
      children: [
        m.jsx(V9e, {
          offset: t,
          children: m.jsx(W9e, {
            id: n,
            dragIds: r
          })
        }),
        m.jsx(X9e, {
          mouse: e,
          count: r.length
        })
      ]
    });
  }
  const U9e = b.memo(function(e) {
    return e.isDragging ? m.jsx("div", {
      style: z9e,
      children: e.children
    }) : null;
  });
  function V9e(t) {
    return m.jsx("div", {
      className: "row preview",
      style: F9e(t.offset),
      children: t.children
    });
  }
  function X9e(t) {
    const { count: e, mouse: n } = t;
    return e > 1 ? m.jsx("div", {
      className: "selected-count",
      style: B9e(n),
      children: e
    }) : null;
  }
  const W9e = b.memo(function(e) {
    const n = fo(), r = n.get(e.id);
    return r ? m.jsx(n.renderNode, {
      preview: true,
      node: r,
      style: {
        paddingLeft: r.level * n.indent,
        opacity: 0.2,
        background: "transparent"
      },
      tree: n
    }) : null;
  });
  function v9(t) {
    if (t === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return t;
  }
  function eM(t, e) {
    return eM = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, r) {
      return n.__proto__ = r, n;
    }, eM(t, e);
  }
  function Z9e(t, e) {
    t.prototype = Object.create(e.prototype), t.prototype.constructor = t, eM(t, e);
  }
  var O9 = Number.isNaN || function(e) {
    return typeof e == "number" && e !== e;
  };
  function H9e(t, e) {
    return !!(t === e || O9(t) && O9(e));
  }
  function Y9e(t, e) {
    if (t.length !== e.length)
      return false;
    for (var n = 0; n < t.length; n++)
      if (!H9e(t[n], e[n]))
        return false;
    return true;
  }
  function AI(t, e) {
    e === void 0 && (e = Y9e);
    var n, r = [], i, s = false;
    function o() {
      for (var a = [], l = 0; l < arguments.length; l++)
        a[l] = arguments[l];
      return s && n === this && e(a, r) || (i = t.apply(this, a), s = true, n = this, r = a), i;
    }
    return o;
  }
  var G9e = typeof performance == "object" && typeof performance.now == "function", S9 = G9e ? function() {
    return performance.now();
  } : function() {
    return Date.now();
  };
  function w9(t) {
    cancelAnimationFrame(t.id);
  }
  function q9e(t, e) {
    var n = S9();
    function r() {
      S9() - n >= e ? t.call(null) : i.id = requestAnimationFrame(r);
    }
    var i = {
      id: requestAnimationFrame(r)
    };
    return i;
  }
  var RI = -1;
  function x9(t) {
    if (t === void 0 && (t = false), RI === -1 || t) {
      var e = document.createElement("div"), n = e.style;
      n.width = "50px", n.height = "50px", n.overflow = "scroll", document.body.appendChild(e), RI = e.offsetWidth - e.clientWidth, document.body.removeChild(e);
    }
    return RI;
  }
  var _p = null;
  function b9(t) {
    if (t === void 0 && (t = false), _p === null || t) {
      var e = document.createElement("div"), n = e.style;
      n.width = "50px", n.height = "50px", n.overflow = "scroll", n.direction = "rtl";
      var r = document.createElement("div"), i = r.style;
      return i.width = "100px", i.height = "100px", e.appendChild(r), document.body.appendChild(e), e.scrollLeft > 0 ? _p = "positive-descending" : (e.scrollLeft = 1, e.scrollLeft === 0 ? _p = "negative" : _p = "positive-ascending"), document.body.removeChild(e), _p;
    }
    return _p;
  }
  var K9e = 150, J9e = function(e, n) {
    return e;
  };
  function eBe(t) {
    var e, n = t.getItemOffset, r = t.getEstimatedTotalSize, i = t.getItemSize, s = t.getOffsetForIndexAndAlignment, o = t.getStartIndexForOffset, a = t.getStopIndexForStartIndex, l = t.initInstanceProps, c = t.shouldResetStyleCacheOnItemSizeChange, u = t.validateProps;
    return e = function(d) {
      Z9e(h, d);
      function h(y) {
        var g;
        return g = d.call(this, y) || this, g._instanceProps = l(g.props, v9(g)), g._outerRef = void 0, g._resetIsScrollingTimeoutId = null, g.state = {
          instance: v9(g),
          isScrolling: false,
          scrollDirection: "forward",
          scrollOffset: typeof g.props.initialScrollOffset == "number" ? g.props.initialScrollOffset : 0,
          scrollUpdateWasRequested: false
        }, g._callOnItemsRendered = void 0, g._callOnItemsRendered = AI(function(O, S, w, x) {
          return g.props.onItemsRendered({
            overscanStartIndex: O,
            overscanStopIndex: S,
            visibleStartIndex: w,
            visibleStopIndex: x
          });
        }), g._callOnScroll = void 0, g._callOnScroll = AI(function(O, S, w) {
          return g.props.onScroll({
            scrollDirection: O,
            scrollOffset: S,
            scrollUpdateWasRequested: w
          });
        }), g._getItemStyle = void 0, g._getItemStyle = function(O) {
          var S = g.props, w = S.direction, x = S.itemSize, P = S.layout, C = g._getItemStyleCache(c && x, c && P, c && w), _;
          if (C.hasOwnProperty(O))
            _ = C[O];
          else {
            var T = n(g.props, O, g._instanceProps), $ = i(g.props, O, g._instanceProps), N = w === "horizontal" || P === "horizontal", L = w === "rtl", z = N ? T : 0;
            C[O] = _ = {
              position: "absolute",
              left: L ? void 0 : z,
              right: L ? z : void 0,
              top: N ? 0 : T,
              height: N ? "100%" : $,
              width: N ? $ : "100%"
            };
          }
          return _;
        }, g._getItemStyleCache = void 0, g._getItemStyleCache = AI(function(O, S, w) {
          return {};
        }), g._onScrollHorizontal = function(O) {
          var S = O.currentTarget, w = S.clientWidth, x = S.scrollLeft, P = S.scrollWidth;
          g.setState(function(C) {
            if (C.scrollOffset === x)
              return null;
            var _ = g.props.direction, T = x;
            if (_ === "rtl")
              switch (b9()) {
                case "negative":
                  T = -x;
                  break;
                case "positive-descending":
                  T = P - w - x;
                  break;
              }
            return T = Math.max(0, Math.min(T, P - w)), {
              isScrolling: true,
              scrollDirection: C.scrollOffset < T ? "forward" : "backward",
              scrollOffset: T,
              scrollUpdateWasRequested: false
            };
          }, g._resetIsScrollingDebounced);
        }, g._onScrollVertical = function(O) {
          var S = O.currentTarget, w = S.clientHeight, x = S.scrollHeight, P = S.scrollTop;
          g.setState(function(C) {
            if (C.scrollOffset === P)
              return null;
            var _ = Math.max(0, Math.min(P, x - w));
            return {
              isScrolling: true,
              scrollDirection: C.scrollOffset < _ ? "forward" : "backward",
              scrollOffset: _,
              scrollUpdateWasRequested: false
            };
          }, g._resetIsScrollingDebounced);
        }, g._outerRefSetter = function(O) {
          var S = g.props.outerRef;
          g._outerRef = O, typeof S == "function" ? S(O) : S != null && typeof S == "object" && S.hasOwnProperty("current") && (S.current = O);
        }, g._resetIsScrollingDebounced = function() {
          g._resetIsScrollingTimeoutId !== null && w9(g._resetIsScrollingTimeoutId), g._resetIsScrollingTimeoutId = q9e(g._resetIsScrolling, K9e);
        }, g._resetIsScrolling = function() {
          g._resetIsScrollingTimeoutId = null, g.setState({
            isScrolling: false
          }, function() {
            g._getItemStyleCache(-1, null);
          });
        }, g;
      }
      h.getDerivedStateFromProps = function(g, O) {
        return tBe(g, O), u(g), null;
      };
      var f = h.prototype;
      return f.scrollTo = function(g) {
        g = Math.max(0, g), this.setState(function(O) {
          return O.scrollOffset === g ? null : {
            scrollDirection: O.scrollOffset < g ? "forward" : "backward",
            scrollOffset: g,
            scrollUpdateWasRequested: true
          };
        }, this._resetIsScrollingDebounced);
      }, f.scrollToItem = function(g, O) {
        O === void 0 && (O = "auto");
        var S = this.props, w = S.itemCount, x = S.layout, P = this.state.scrollOffset;
        g = Math.max(0, Math.min(g, w - 1));
        var C = 0;
        if (this._outerRef) {
          var _ = this._outerRef;
          x === "vertical" ? C = _.scrollWidth > _.clientWidth ? x9() : 0 : C = _.scrollHeight > _.clientHeight ? x9() : 0;
        }
        this.scrollTo(s(this.props, g, O, P, this._instanceProps, C));
      }, f.componentDidMount = function() {
        var g = this.props, O = g.direction, S = g.initialScrollOffset, w = g.layout;
        if (typeof S == "number" && this._outerRef != null) {
          var x = this._outerRef;
          O === "horizontal" || w === "horizontal" ? x.scrollLeft = S : x.scrollTop = S;
        }
        this._callPropsCallbacks();
      }, f.componentDidUpdate = function() {
        var g = this.props, O = g.direction, S = g.layout, w = this.state, x = w.scrollOffset, P = w.scrollUpdateWasRequested;
        if (P && this._outerRef != null) {
          var C = this._outerRef;
          if (O === "horizontal" || S === "horizontal")
            if (O === "rtl")
              switch (b9()) {
                case "negative":
                  C.scrollLeft = -x;
                  break;
                case "positive-ascending":
                  C.scrollLeft = x;
                  break;
                default:
                  var _ = C.clientWidth, T = C.scrollWidth;
                  C.scrollLeft = T - _ - x;
                  break;
              }
            else
              C.scrollLeft = x;
          else
            C.scrollTop = x;
        }
        this._callPropsCallbacks();
      }, f.componentWillUnmount = function() {
        this._resetIsScrollingTimeoutId !== null && w9(this._resetIsScrollingTimeoutId);
      }, f.render = function() {
        var g = this.props, O = g.children, S = g.className, w = g.direction, x = g.height, P = g.innerRef, C = g.innerElementType, _ = g.innerTagName, T = g.itemCount, $ = g.itemData, N = g.itemKey, L = N === void 0 ? J9e : N, z = g.layout, M = g.outerElementType, R = g.outerTagName, F = g.style, Q = g.useIsScrolling, X = g.width, Z = this.state.isScrolling, U = w === "horizontal" || z === "horizontal", H = U ? this._onScrollHorizontal : this._onScrollVertical, te = this._getRangeToRender(), se = te[0], ae = te[1], _e3 = [];
        if (T > 0)
          for (var Me = se; Me <= ae; Me++)
            _e3.push(b.createElement(O, {
              data: $,
              key: L(Me, $),
              index: Me,
              isScrolling: Q ? Z : void 0,
              style: this._getItemStyle(Me)
            }));
        var ke = r(this.props, this._instanceProps);
        return b.createElement(M || R || "div", {
          className: S,
          onScroll: H,
          ref: this._outerRefSetter,
          style: Yr({
            position: "relative",
            height: x,
            width: X,
            overflow: "auto",
            WebkitOverflowScrolling: "touch",
            willChange: "transform",
            direction: w
          }, F)
        }, b.createElement(C || _ || "div", {
          children: _e3,
          ref: P,
          style: {
            height: U ? "100%" : ke,
            pointerEvents: Z ? "none" : void 0,
            width: U ? ke : "100%"
          }
        }));
      }, f._callPropsCallbacks = function() {
        if (typeof this.props.onItemsRendered == "function") {
          var g = this.props.itemCount;
          if (g > 0) {
            var O = this._getRangeToRender(), S = O[0], w = O[1], x = O[2], P = O[3];
            this._callOnItemsRendered(S, w, x, P);
          }
        }
        if (typeof this.props.onScroll == "function") {
          var C = this.state, _ = C.scrollDirection, T = C.scrollOffset, $ = C.scrollUpdateWasRequested;
          this._callOnScroll(_, T, $);
        }
      }, f._getRangeToRender = function() {
        var g = this.props, O = g.itemCount, S = g.overscanCount, w = this.state, x = w.isScrolling, P = w.scrollDirection, C = w.scrollOffset;
        if (O === 0)
          return [
            0,
            0,
            0,
            0
          ];
        var _ = o(this.props, C, this._instanceProps), T = a(this.props, _, C, this._instanceProps), $ = !x || P === "backward" ? Math.max(1, S) : 1, N = !x || P === "forward" ? Math.max(1, S) : 1;
        return [
          Math.max(0, _ - $),
          Math.max(0, Math.min(O - 1, T + N)),
          _,
          T
        ];
      }, h;
    }(b.PureComponent), e.defaultProps = {
      direction: "ltr",
      itemData: void 0,
      layout: "vertical",
      overscanCount: 2,
      useIsScrolling: false
    }, e;
  }
  var tBe = function(e, n) {
    e.children, e.direction, e.height, e.layout, e.innerTagName, e.outerTagName, e.width, n.instance;
  }, nBe = eBe({
    getItemOffset: function(e, n) {
      var r = e.itemSize;
      return n * r;
    },
    getItemSize: function(e, n) {
      var r = e.itemSize;
      return r;
    },
    getEstimatedTotalSize: function(e) {
      var n = e.itemCount, r = e.itemSize;
      return r * n;
    },
    getOffsetForIndexAndAlignment: function(e, n, r, i, s, o) {
      var a = e.direction, l = e.height, c = e.itemCount, u = e.itemSize, d = e.layout, h = e.width, f = a === "horizontal" || d === "horizontal", y = f ? h : l, g = Math.max(0, c * u - y), O = Math.min(g, n * u), S = Math.max(0, n * u - y + u + o);
      switch (r === "smart" && (i >= S - y && i <= O + y ? r = "auto" : r = "center"), r) {
        case "start":
          return O;
        case "end":
          return S;
        case "center": {
          var w = Math.round(S + (O - S) / 2);
          return w < Math.ceil(y / 2) ? 0 : w > g + Math.floor(y / 2) ? g : w;
        }
        case "auto":
        default:
          return i >= S && i <= O ? i : i < S ? S : O;
      }
    },
    getStartIndexForOffset: function(e, n) {
      var r = e.itemCount, i = e.itemSize;
      return Math.max(0, Math.min(r - 1, Math.floor(n / i)));
    },
    getStopIndexForStartIndex: function(e, n, r) {
      var i = e.direction, s = e.height, o = e.itemCount, a = e.itemSize, l = e.layout, c = e.width, u = i === "horizontal" || l === "horizontal", d = n * a, h = u ? c : s, f = Math.ceil((h + r - d) / a);
      return Math.max(0, Math.min(o - 1, n + f - 1));
    },
    initInstanceProps: function(e) {
    },
    shouldResetStyleCacheOnItemSizeChange: true,
    validateProps: function(e) {
      e.itemSize;
    }
  });
  function rBe() {
    var t, e;
    const n = fo(), i = S9e().cursor;
    if (!i || i.type !== "line")
      return null;
    const s = n.indent, o = n.rowHeight * i.index + ((e = (t = n.props.padding) !== null && t !== void 0 ? t : n.props.paddingTop) !== null && e !== void 0 ? e : 0), a = s * i.level, l = n.renderCursor;
    return m.jsx(l, {
      top: o,
      left: a,
      indent: s
    });
  }
  var iBe = globalThis && globalThis.__rest || function(t, e) {
    var n = {};
    for (var r in t)
      Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
    if (t != null && typeof Object.getOwnPropertySymbols == "function")
      for (var i = 0, r = Object.getOwnPropertySymbols(t); i < r.length; i++)
        e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
    return n;
  };
  const sBe = b.forwardRef(function(e, n) {
    const { children: r } = e, i = iBe(e, [
      "children"
    ]), s = fo();
    return m.jsxs("div", Object.assign({
      ref: n
    }, i, {
      onClick: (o) => {
        o.currentTarget === o.target && s.deselectAll();
      },
      children: [
        m.jsx(oBe, {}),
        r
      ]
    }));
  }), oBe = () => {
    const t = fo();
    return m.jsx("div", {
      style: {
        height: t.visibleNodes.length * t.rowHeight,
        width: "100%",
        position: "absolute",
        left: "0",
        right: "0"
      },
      children: m.jsx(rBe, {})
    });
  };
  var aBe = globalThis && globalThis.__rest || function(t, e) {
    var n = {};
    for (var r in t)
      Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
    if (t != null && typeof Object.getOwnPropertySymbols == "function")
      for (var i = 0, r = Object.getOwnPropertySymbols(t); i < r.length; i++)
        e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
    return n;
  };
  const lBe = b.forwardRef(function(e, n) {
    var r, i, s, o, { style: a } = e, l = aBe(e, [
      "style"
    ]);
    const c = fo(), u = (i = (r = c.props.padding) !== null && r !== void 0 ? r : c.props.paddingTop) !== null && i !== void 0 ? i : 0, d = (o = (s = c.props.padding) !== null && s !== void 0 ? s : c.props.paddingBottom) !== null && o !== void 0 ? o : 0;
    return m.jsx("div", Object.assign({
      ref: n,
      style: Object.assign(Object.assign({}, a), {
        height: `${parseFloat(a.height) + u + d}px`
      })
    }, l));
  });
  var lre = b.createContext({
    dragDropManager: void 0
  }), Bo;
  (function(t) {
    t.SOURCE = "SOURCE", t.TARGET = "TARGET";
  })(Bo || (Bo = {}));
  function lt(t, e) {
    for (var n = arguments.length, r = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++)
      r[i - 2] = arguments[i];
    if (!t) {
      var s;
      if (e === void 0)
        s = new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");
      else {
        var o = 0;
        s = new Error(e.replace(/%s/g, function() {
          return r[o++];
        })), s.name = "Invariant Violation";
      }
      throw s.framesToPop = 1, s;
    }
  }
  var rj = "dnd-core/INIT_COORDS", g2 = "dnd-core/BEGIN_DRAG", ij = "dnd-core/PUBLISH_DRAG_SOURCE", m2 = "dnd-core/HOVER", y2 = "dnd-core/DROP", v2 = "dnd-core/END_DRAG";
  function k9(t, e) {
    return {
      type: rj,
      payload: {
        sourceClientOffset: e || null,
        clientOffset: t || null
      }
    };
  }
  function rb(t) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? rb = function(n) {
      return typeof n;
    } : rb = function(n) {
      return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
    }, rb(t);
  }
  function cBe(t, e, n) {
    return e.split(".").reduce(function(r, i) {
      return r && r[i] ? r[i] : n || null;
    }, t);
  }
  function uBe(t, e) {
    return t.filter(function(n) {
      return n !== e;
    });
  }
  function cre(t) {
    return rb(t) === "object";
  }
  function dBe(t, e) {
    var n = /* @__PURE__ */ new Map(), r = function(o) {
      n.set(o, n.has(o) ? n.get(o) + 1 : 1);
    };
    t.forEach(r), e.forEach(r);
    var i = [];
    return n.forEach(function(s, o) {
      s === 1 && i.push(o);
    }), i;
  }
  function hBe(t, e) {
    return t.filter(function(n) {
      return e.indexOf(n) > -1;
    });
  }
  var fBe = {
    type: rj,
    payload: {
      clientOffset: null,
      sourceClientOffset: null
    }
  };
  function pBe(t) {
    return function() {
      var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
        publishSource: true
      }, i = r.publishSource, s = i === void 0 ? true : i, o = r.clientOffset, a = r.getSourceClientOffset, l = t.getMonitor(), c = t.getRegistry();
      t.dispatch(k9(o)), gBe(n, l, c);
      var u = vBe(n, l);
      if (u === null) {
        t.dispatch(fBe);
        return;
      }
      var d = null;
      if (o) {
        if (!a)
          throw new Error("getSourceClientOffset must be defined");
        mBe(a), d = a(u);
      }
      t.dispatch(k9(o, d));
      var h = c.getSource(u), f = h.beginDrag(l, u);
      if (f != null) {
        yBe(f), c.pinSource(u);
        var y = c.getSourceType(u);
        return {
          type: g2,
          payload: {
            itemType: y,
            item: f,
            sourceId: u,
            clientOffset: o || null,
            sourceClientOffset: d || null,
            isSourcePublic: !!s
          }
        };
      }
    };
  }
  function gBe(t, e, n) {
    lt(!e.isDragging(), "Cannot call beginDrag while dragging."), t.forEach(function(r) {
      lt(n.getSource(r), "Expected sourceIds to be registered.");
    });
  }
  function mBe(t) {
    lt(typeof t == "function", "When clientOffset is provided, getSourceClientOffset must be a function.");
  }
  function yBe(t) {
    lt(cre(t), "Item must be an object.");
  }
  function vBe(t, e) {
    for (var n = null, r = t.length - 1; r >= 0; r--)
      if (e.canDragSource(t[r])) {
        n = t[r];
        break;
      }
    return n;
  }
  function OBe(t) {
    return function() {
      var n = t.getMonitor();
      if (n.isDragging())
        return {
          type: ij
        };
    };
  }
  function tM(t, e) {
    return e === null ? t === null : Array.isArray(t) ? t.some(function(n) {
      return n === e;
    }) : t === e;
  }
  function SBe(t) {
    return function(n) {
      var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = r.clientOffset;
      wBe(n);
      var s = n.slice(0), o = t.getMonitor(), a = t.getRegistry();
      xBe(s, o, a);
      var l = o.getItemType();
      return bBe(s, a, l), kBe(s, o, a), {
        type: m2,
        payload: {
          targetIds: s,
          clientOffset: i || null
        }
      };
    };
  }
  function wBe(t) {
    lt(Array.isArray(t), "Expected targetIds to be an array.");
  }
  function xBe(t, e, n) {
    lt(e.isDragging(), "Cannot call hover while not dragging."), lt(!e.didDrop(), "Cannot call hover after drop.");
    for (var r = 0; r < t.length; r++) {
      var i = t[r];
      lt(t.lastIndexOf(i) === r, "Expected targetIds to be unique in the passed array.");
      var s = n.getTarget(i);
      lt(s, "Expected targetIds to be registered.");
    }
  }
  function bBe(t, e, n) {
    for (var r = t.length - 1; r >= 0; r--) {
      var i = t[r], s = e.getTargetType(i);
      tM(s, n) || t.splice(r, 1);
    }
  }
  function kBe(t, e, n) {
    t.forEach(function(r) {
      var i = n.getTarget(r);
      i.hover(e, r);
    });
  }
  function P9(t, e) {
    var n = Object.keys(t);
    if (Object.getOwnPropertySymbols) {
      var r = Object.getOwnPropertySymbols(t);
      e && (r = r.filter(function(i) {
        return Object.getOwnPropertyDescriptor(t, i).enumerable;
      })), n.push.apply(n, r);
    }
    return n;
  }
  function C9(t) {
    for (var e = 1; e < arguments.length; e++) {
      var n = arguments[e] != null ? arguments[e] : {};
      e % 2 ? P9(Object(n), true).forEach(function(r) {
        PBe(t, r, n[r]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : P9(Object(n)).forEach(function(r) {
        Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
      });
    }
    return t;
  }
  function PBe(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  function CBe(t) {
    return function() {
      var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, r = t.getMonitor(), i = t.getRegistry();
      _Be(r);
      var s = IBe(r);
      s.forEach(function(o, a) {
        var l = TBe(o, a, i, r), c = {
          type: y2,
          payload: {
            dropResult: C9(C9({}, n), l)
          }
        };
        t.dispatch(c);
      });
    };
  }
  function _Be(t) {
    lt(t.isDragging(), "Cannot call drop while not dragging."), lt(!t.didDrop(), "Cannot call drop twice during one drag operation.");
  }
  function TBe(t, e, n, r) {
    var i = n.getTarget(t), s = i ? i.drop(r, t) : void 0;
    return EBe(s), typeof s > "u" && (s = e === 0 ? {} : r.getDropResult()), s;
  }
  function EBe(t) {
    lt(typeof t > "u" || cre(t), "Drop result must either be an object or undefined.");
  }
  function IBe(t) {
    var e = t.getTargetIds().filter(t.canDropOnTarget, t);
    return e.reverse(), e;
  }
  function $Be(t) {
    return function() {
      var n = t.getMonitor(), r = t.getRegistry();
      ABe(n);
      var i = n.getSourceId();
      if (i != null) {
        var s = r.getSource(i, true);
        s.endDrag(n, i), r.unpinSource();
      }
      return {
        type: v2
      };
    };
  }
  function ABe(t) {
    lt(t.isDragging(), "Cannot call endDrag while not dragging.");
  }
  function RBe(t) {
    return {
      beginDrag: pBe(t),
      publishDragSource: OBe(t),
      hover: SBe(t),
      drop: CBe(t),
      endDrag: $Be(t)
    };
  }
  function MBe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function _9(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function DBe(t, e, n) {
    return e && _9(t.prototype, e), n && _9(t, n), t;
  }
  function e0(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var LBe = function() {
    function t(e, n) {
      var r = this;
      MBe(this, t), e0(this, "store", void 0), e0(this, "monitor", void 0), e0(this, "backend", void 0), e0(this, "isSetUp", false), e0(this, "handleRefCountChange", function() {
        var i = r.store.getState().refCount > 0;
        r.backend && (i && !r.isSetUp ? (r.backend.setup(), r.isSetUp = true) : !i && r.isSetUp && (r.backend.teardown(), r.isSetUp = false));
      }), this.store = e, this.monitor = n, e.subscribe(this.handleRefCountChange);
    }
    return DBe(t, [
      {
        key: "receiveBackend",
        value: function(n) {
          this.backend = n;
        }
      },
      {
        key: "getMonitor",
        value: function() {
          return this.monitor;
        }
      },
      {
        key: "getBackend",
        value: function() {
          return this.backend;
        }
      },
      {
        key: "getRegistry",
        value: function() {
          return this.monitor.registry;
        }
      },
      {
        key: "getActions",
        value: function() {
          var n = this, r = this.store.dispatch;
          function i(o) {
            return function() {
              for (var a = arguments.length, l = new Array(a), c = 0; c < a; c++)
                l[c] = arguments[c];
              var u = o.apply(n, l);
              typeof u < "u" && r(u);
            };
          }
          var s = RBe(this);
          return Object.keys(s).reduce(function(o, a) {
            var l = s[a];
            return o[a] = i(l), o;
          }, {});
        }
      },
      {
        key: "dispatch",
        value: function(n) {
          this.store.dispatch(n);
        }
      }
    ]), t;
  }();
  function Eo(t) {
    return "Minified Redux error #" + t + "; visit https://redux.js.org/Errors?code=" + t + " for the full message or use the non-minified dev environment for full errors. ";
  }
  var T9 = function() {
    return typeof Symbol == "function" && Symbol.observable || "@@observable";
  }(), MI = function() {
    return Math.random().toString(36).substring(7).split("").join(".");
  }, E9 = {
    INIT: "@@redux/INIT" + MI(),
    REPLACE: "@@redux/REPLACE" + MI(),
    PROBE_UNKNOWN_ACTION: function() {
      return "@@redux/PROBE_UNKNOWN_ACTION" + MI();
    }
  };
  function jBe(t) {
    if (typeof t != "object" || t === null)
      return false;
    for (var e = t; Object.getPrototypeOf(e) !== null; )
      e = Object.getPrototypeOf(e);
    return Object.getPrototypeOf(t) === e;
  }
  function ure(t, e, n) {
    var r;
    if (typeof e == "function" && typeof n == "function" || typeof n == "function" && typeof arguments[3] == "function")
      throw new Error(Eo(0));
    if (typeof e == "function" && typeof n > "u" && (n = e, e = void 0), typeof n < "u") {
      if (typeof n != "function")
        throw new Error(Eo(1));
      return n(ure)(t, e);
    }
    if (typeof t != "function")
      throw new Error(Eo(2));
    var i = t, s = e, o = [], a = o, l = false;
    function c() {
      a === o && (a = o.slice());
    }
    function u() {
      if (l)
        throw new Error(Eo(3));
      return s;
    }
    function d(g) {
      if (typeof g != "function")
        throw new Error(Eo(4));
      if (l)
        throw new Error(Eo(5));
      var O = true;
      return c(), a.push(g), function() {
        if (O) {
          if (l)
            throw new Error(Eo(6));
          O = false, c();
          var w = a.indexOf(g);
          a.splice(w, 1), o = null;
        }
      };
    }
    function h(g) {
      if (!jBe(g))
        throw new Error(Eo(7));
      if (typeof g.type > "u")
        throw new Error(Eo(8));
      if (l)
        throw new Error(Eo(9));
      try {
        l = true, s = i(s, g);
      } finally {
        l = false;
      }
      for (var O = o = a, S = 0; S < O.length; S++) {
        var w = O[S];
        w();
      }
      return g;
    }
    function f(g) {
      if (typeof g != "function")
        throw new Error(Eo(10));
      i = g, h({
        type: E9.REPLACE
      });
    }
    function y() {
      var g, O = d;
      return g = {
        subscribe: function(w) {
          if (typeof w != "object" || w === null)
            throw new Error(Eo(11));
          function x() {
            w.next && w.next(u());
          }
          x();
          var P = O(x);
          return {
            unsubscribe: P
          };
        }
      }, g[T9] = function() {
        return this;
      }, g;
    }
    return h({
      type: E9.INIT
    }), r = {
      dispatch: h,
      subscribe: d,
      getState: u,
      replaceReducer: f
    }, r[T9] = y, r;
  }
  var NBe = function(e, n) {
    return e === n;
  };
  function QBe(t, e) {
    return !t && !e ? true : !t || !e ? false : t.x === e.x && t.y === e.y;
  }
  function zBe(t, e) {
    var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : NBe;
    if (t.length !== e.length)
      return false;
    for (var r = 0; r < t.length; ++r)
      if (!n(t[r], e[r]))
        return false;
    return true;
  }
  function I9(t, e) {
    var n = Object.keys(t);
    if (Object.getOwnPropertySymbols) {
      var r = Object.getOwnPropertySymbols(t);
      e && (r = r.filter(function(i) {
        return Object.getOwnPropertyDescriptor(t, i).enumerable;
      })), n.push.apply(n, r);
    }
    return n;
  }
  function $9(t) {
    for (var e = 1; e < arguments.length; e++) {
      var n = arguments[e] != null ? arguments[e] : {};
      e % 2 ? I9(Object(n), true).forEach(function(r) {
        FBe(t, r, n[r]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : I9(Object(n)).forEach(function(r) {
        Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
      });
    }
    return t;
  }
  function FBe(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var A9 = {
    initialSourceClientOffset: null,
    initialClientOffset: null,
    clientOffset: null
  };
  function BBe() {
    var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : A9, e = arguments.length > 1 ? arguments[1] : void 0, n = e.payload;
    switch (e.type) {
      case rj:
      case g2:
        return {
          initialSourceClientOffset: n.sourceClientOffset,
          initialClientOffset: n.clientOffset,
          clientOffset: n.clientOffset
        };
      case m2:
        return QBe(t.clientOffset, n.clientOffset) ? t : $9($9({}, t), {}, {
          clientOffset: n.clientOffset
        });
      case v2:
      case y2:
        return A9;
      default:
        return t;
    }
  }
  var sj = "dnd-core/ADD_SOURCE", oj = "dnd-core/ADD_TARGET", aj = "dnd-core/REMOVE_SOURCE", O2 = "dnd-core/REMOVE_TARGET";
  function UBe(t) {
    return {
      type: sj,
      payload: {
        sourceId: t
      }
    };
  }
  function VBe(t) {
    return {
      type: oj,
      payload: {
        targetId: t
      }
    };
  }
  function XBe(t) {
    return {
      type: aj,
      payload: {
        sourceId: t
      }
    };
  }
  function WBe(t) {
    return {
      type: O2,
      payload: {
        targetId: t
      }
    };
  }
  function R9(t, e) {
    var n = Object.keys(t);
    if (Object.getOwnPropertySymbols) {
      var r = Object.getOwnPropertySymbols(t);
      e && (r = r.filter(function(i) {
        return Object.getOwnPropertyDescriptor(t, i).enumerable;
      })), n.push.apply(n, r);
    }
    return n;
  }
  function Io(t) {
    for (var e = 1; e < arguments.length; e++) {
      var n = arguments[e] != null ? arguments[e] : {};
      e % 2 ? R9(Object(n), true).forEach(function(r) {
        ZBe(t, r, n[r]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : R9(Object(n)).forEach(function(r) {
        Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
      });
    }
    return t;
  }
  function ZBe(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var HBe = {
    itemType: null,
    item: null,
    sourceId: null,
    targetIds: [],
    dropResult: null,
    didDrop: false,
    isSourcePublic: null
  };
  function YBe() {
    var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : HBe, e = arguments.length > 1 ? arguments[1] : void 0, n = e.payload;
    switch (e.type) {
      case g2:
        return Io(Io({}, t), {}, {
          itemType: n.itemType,
          item: n.item,
          sourceId: n.sourceId,
          isSourcePublic: n.isSourcePublic,
          dropResult: null,
          didDrop: false
        });
      case ij:
        return Io(Io({}, t), {}, {
          isSourcePublic: true
        });
      case m2:
        return Io(Io({}, t), {}, {
          targetIds: n.targetIds
        });
      case O2:
        return t.targetIds.indexOf(n.targetId) === -1 ? t : Io(Io({}, t), {}, {
          targetIds: uBe(t.targetIds, n.targetId)
        });
      case y2:
        return Io(Io({}, t), {}, {
          dropResult: n.dropResult,
          didDrop: true,
          targetIds: []
        });
      case v2:
        return Io(Io({}, t), {}, {
          itemType: null,
          item: null,
          sourceId: null,
          dropResult: null,
          didDrop: false,
          isSourcePublic: null,
          targetIds: []
        });
      default:
        return t;
    }
  }
  function GBe() {
    var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, e = arguments.length > 1 ? arguments[1] : void 0;
    switch (e.type) {
      case sj:
      case oj:
        return t + 1;
      case aj:
      case O2:
        return t - 1;
      default:
        return t;
    }
  }
  var rP = [], lj = [];
  rP.__IS_NONE__ = true;
  lj.__IS_ALL__ = true;
  function qBe(t, e) {
    if (t === rP)
      return false;
    if (t === lj || typeof e > "u")
      return true;
    var n = hBe(e, t);
    return n.length > 0;
  }
  function KBe() {
    var t = arguments.length > 1 ? arguments[1] : void 0;
    switch (t.type) {
      case m2:
        break;
      case sj:
      case oj:
      case O2:
      case aj:
        return rP;
      case g2:
      case ij:
      case v2:
      case y2:
      default:
        return lj;
    }
    var e = t.payload, n = e.targetIds, r = n === void 0 ? [] : n, i = e.prevTargetIds, s = i === void 0 ? [] : i, o = dBe(r, s), a = o.length > 0 || !zBe(r, s);
    if (!a)
      return rP;
    var l = s[s.length - 1], c = r[r.length - 1];
    return l !== c && (l && o.push(l), c && o.push(c)), o;
  }
  function JBe() {
    var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
    return t + 1;
  }
  function M9(t, e) {
    var n = Object.keys(t);
    if (Object.getOwnPropertySymbols) {
      var r = Object.getOwnPropertySymbols(t);
      e && (r = r.filter(function(i) {
        return Object.getOwnPropertyDescriptor(t, i).enumerable;
      })), n.push.apply(n, r);
    }
    return n;
  }
  function D9(t) {
    for (var e = 1; e < arguments.length; e++) {
      var n = arguments[e] != null ? arguments[e] : {};
      e % 2 ? M9(Object(n), true).forEach(function(r) {
        eUe(t, r, n[r]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : M9(Object(n)).forEach(function(r) {
        Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
      });
    }
    return t;
  }
  function eUe(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  function tUe() {
    var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, e = arguments.length > 1 ? arguments[1] : void 0;
    return {
      dirtyHandlerIds: KBe(t.dirtyHandlerIds, {
        type: e.type,
        payload: D9(D9({}, e.payload), {}, {
          prevTargetIds: cBe(t, "dragOperation.targetIds", [])
        })
      }),
      dragOffset: BBe(t.dragOffset, e),
      refCount: GBe(t.refCount, e),
      dragOperation: YBe(t.dragOperation, e),
      stateId: JBe(t.stateId)
    };
  }
  function nUe(t, e) {
    return {
      x: t.x + e.x,
      y: t.y + e.y
    };
  }
  function dre(t, e) {
    return {
      x: t.x - e.x,
      y: t.y - e.y
    };
  }
  function rUe(t) {
    var e = t.clientOffset, n = t.initialClientOffset, r = t.initialSourceClientOffset;
    return !e || !n || !r ? null : dre(nUe(e, r), n);
  }
  function iUe(t) {
    var e = t.clientOffset, n = t.initialClientOffset;
    return !e || !n ? null : dre(e, n);
  }
  function sUe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function L9(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function oUe(t, e, n) {
    return e && L9(t.prototype, e), n && L9(t, n), t;
  }
  function j9(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var aUe = function() {
    function t(e, n) {
      sUe(this, t), j9(this, "store", void 0), j9(this, "registry", void 0), this.store = e, this.registry = n;
    }
    return oUe(t, [
      {
        key: "subscribeToStateChange",
        value: function(n) {
          var r = this, i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
            handlerIds: void 0
          }, s = i.handlerIds;
          lt(typeof n == "function", "listener must be a function."), lt(typeof s > "u" || Array.isArray(s), "handlerIds, when specified, must be an array of strings.");
          var o = this.store.getState().stateId, a = function() {
            var c = r.store.getState(), u = c.stateId;
            try {
              var d = u === o || u === o + 1 && !qBe(c.dirtyHandlerIds, s);
              d || n();
            } finally {
              o = u;
            }
          };
          return this.store.subscribe(a);
        }
      },
      {
        key: "subscribeToOffsetChange",
        value: function(n) {
          var r = this;
          lt(typeof n == "function", "listener must be a function.");
          var i = this.store.getState().dragOffset, s = function() {
            var a = r.store.getState().dragOffset;
            a !== i && (i = a, n());
          };
          return this.store.subscribe(s);
        }
      },
      {
        key: "canDragSource",
        value: function(n) {
          if (!n)
            return false;
          var r = this.registry.getSource(n);
          return lt(r, "Expected to find a valid source. sourceId=".concat(n)), this.isDragging() ? false : r.canDrag(this, n);
        }
      },
      {
        key: "canDropOnTarget",
        value: function(n) {
          if (!n)
            return false;
          var r = this.registry.getTarget(n);
          if (lt(r, "Expected to find a valid target. targetId=".concat(n)), !this.isDragging() || this.didDrop())
            return false;
          var i = this.registry.getTargetType(n), s = this.getItemType();
          return tM(i, s) && r.canDrop(this, n);
        }
      },
      {
        key: "isDragging",
        value: function() {
          return !!this.getItemType();
        }
      },
      {
        key: "isDraggingSource",
        value: function(n) {
          if (!n)
            return false;
          var r = this.registry.getSource(n, true);
          if (lt(r, "Expected to find a valid source. sourceId=".concat(n)), !this.isDragging() || !this.isSourcePublic())
            return false;
          var i = this.registry.getSourceType(n), s = this.getItemType();
          return i !== s ? false : r.isDragging(this, n);
        }
      },
      {
        key: "isOverTarget",
        value: function(n) {
          var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
            shallow: false
          };
          if (!n)
            return false;
          var i = r.shallow;
          if (!this.isDragging())
            return false;
          var s = this.registry.getTargetType(n), o = this.getItemType();
          if (o && !tM(s, o))
            return false;
          var a = this.getTargetIds();
          if (!a.length)
            return false;
          var l = a.indexOf(n);
          return i ? l === a.length - 1 : l > -1;
        }
      },
      {
        key: "getItemType",
        value: function() {
          return this.store.getState().dragOperation.itemType;
        }
      },
      {
        key: "getItem",
        value: function() {
          return this.store.getState().dragOperation.item;
        }
      },
      {
        key: "getSourceId",
        value: function() {
          return this.store.getState().dragOperation.sourceId;
        }
      },
      {
        key: "getTargetIds",
        value: function() {
          return this.store.getState().dragOperation.targetIds;
        }
      },
      {
        key: "getDropResult",
        value: function() {
          return this.store.getState().dragOperation.dropResult;
        }
      },
      {
        key: "didDrop",
        value: function() {
          return this.store.getState().dragOperation.didDrop;
        }
      },
      {
        key: "isSourcePublic",
        value: function() {
          return !!this.store.getState().dragOperation.isSourcePublic;
        }
      },
      {
        key: "getInitialClientOffset",
        value: function() {
          return this.store.getState().dragOffset.initialClientOffset;
        }
      },
      {
        key: "getInitialSourceClientOffset",
        value: function() {
          return this.store.getState().dragOffset.initialSourceClientOffset;
        }
      },
      {
        key: "getClientOffset",
        value: function() {
          return this.store.getState().dragOffset.clientOffset;
        }
      },
      {
        key: "getSourceClientOffset",
        value: function() {
          return rUe(this.store.getState().dragOffset);
        }
      },
      {
        key: "getDifferenceFromInitialOffset",
        value: function() {
          return iUe(this.store.getState().dragOffset);
        }
      }
    ]), t;
  }(), lUe = 0;
  function cUe() {
    return lUe++;
  }
  function ib(t) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? ib = function(n) {
      return typeof n;
    } : ib = function(n) {
      return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
    }, ib(t);
  }
  function uUe(t) {
    lt(typeof t.canDrag == "function", "Expected canDrag to be a function."), lt(typeof t.beginDrag == "function", "Expected beginDrag to be a function."), lt(typeof t.endDrag == "function", "Expected endDrag to be a function.");
  }
  function dUe(t) {
    lt(typeof t.canDrop == "function", "Expected canDrop to be a function."), lt(typeof t.hover == "function", "Expected hover to be a function."), lt(typeof t.drop == "function", "Expected beginDrag to be a function.");
  }
  function nM(t, e) {
    if (e && Array.isArray(t)) {
      t.forEach(function(n) {
        return nM(n, false);
      });
      return;
    }
    lt(typeof t == "string" || ib(t) === "symbol", e ? "Type can only be a string, a symbol, or an array of either." : "Type can only be a string or a symbol.");
  }
  const N9 = typeof global < "u" ? global : self, hre = N9.MutationObserver || N9.WebKitMutationObserver;
  function fre(t) {
    return function() {
      const n = setTimeout(i, 0), r = setInterval(i, 50);
      function i() {
        clearTimeout(n), clearInterval(r), t();
      }
    };
  }
  function hUe(t) {
    let e = 1;
    const n = new hre(t), r = document.createTextNode("");
    return n.observe(r, {
      characterData: true
    }), function() {
      e = -e, r.data = e;
    };
  }
  const fUe = typeof hre == "function" ? hUe : fre;
  class pUe {
    enqueueTask(e) {
      const { queue: n, requestFlush: r } = this;
      n.length || (r(), this.flushing = true), n[n.length] = e;
    }
    constructor() {
      this.queue = [], this.pendingErrors = [], this.flushing = false, this.index = 0, this.capacity = 1024, this.flush = () => {
        const { queue: e } = this;
        for (; this.index < e.length; ) {
          const n = this.index;
          if (this.index++, e[n].call(), this.index > this.capacity) {
            for (let r = 0, i = e.length - this.index; r < i; r++)
              e[r] = e[r + this.index];
            e.length -= this.index, this.index = 0;
          }
        }
        e.length = 0, this.index = 0, this.flushing = false;
      }, this.registerPendingError = (e) => {
        this.pendingErrors.push(e), this.requestErrorThrow();
      }, this.requestFlush = fUe(this.flush), this.requestErrorThrow = fre(() => {
        if (this.pendingErrors.length)
          throw this.pendingErrors.shift();
      });
    }
  }
  class gUe {
    call() {
      try {
        this.task && this.task();
      } catch (e) {
        this.onError(e);
      } finally {
        this.task = null, this.release(this);
      }
    }
    constructor(e, n) {
      this.onError = e, this.release = n, this.task = null;
    }
  }
  class mUe {
    create(e) {
      const n = this.freeTasks, r = n.length ? n.pop() : new gUe(this.onError, (i) => n[n.length] = i);
      return r.task = e, r;
    }
    constructor(e) {
      this.onError = e, this.freeTasks = [];
    }
  }
  const pre = new pUe(), yUe = new mUe(pre.registerPendingError);
  function vUe(t) {
    pre.enqueueTask(yUe.create(t));
  }
  function OUe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function Q9(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function SUe(t, e, n) {
    return e && Q9(t.prototype, e), n && Q9(t, n), t;
  }
  function Tp(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  function wUe(t, e) {
    return PUe(t) || kUe(t, e) || bUe(t, e) || xUe();
  }
  function xUe() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function bUe(t, e) {
    if (t) {
      if (typeof t == "string")
        return z9(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return z9(t, e);
    }
  }
  function z9(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function kUe(t, e) {
    var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
    if (n != null) {
      var r = [], i = true, s = false, o, a;
      try {
        for (n = n.call(t); !(i = (o = n.next()).done) && (r.push(o.value), !(e && r.length === e)); i = true)
          ;
      } catch (l) {
        s = true, a = l;
      } finally {
        try {
          !i && n.return != null && n.return();
        } finally {
          if (s)
            throw a;
        }
      }
      return r;
    }
  }
  function PUe(t) {
    if (Array.isArray(t))
      return t;
  }
  function CUe(t) {
    var e = cUe().toString();
    switch (t) {
      case Bo.SOURCE:
        return "S".concat(e);
      case Bo.TARGET:
        return "T".concat(e);
      default:
        throw new Error("Unknown Handler Role: ".concat(t));
    }
  }
  function F9(t) {
    switch (t[0]) {
      case "S":
        return Bo.SOURCE;
      case "T":
        return Bo.TARGET;
      default:
        lt(false, "Cannot parse handler ID: ".concat(t));
    }
  }
  function B9(t, e) {
    var n = t.entries(), r = false;
    do {
      var i = n.next(), s = i.done, o = wUe(i.value, 2), a = o[1];
      if (a === e)
        return true;
      r = !!s;
    } while (!r);
    return false;
  }
  var _Ue = function() {
    function t(e) {
      OUe(this, t), Tp(this, "types", /* @__PURE__ */ new Map()), Tp(this, "dragSources", /* @__PURE__ */ new Map()), Tp(this, "dropTargets", /* @__PURE__ */ new Map()), Tp(this, "pinnedSourceId", null), Tp(this, "pinnedSource", null), Tp(this, "store", void 0), this.store = e;
    }
    return SUe(t, [
      {
        key: "addSource",
        value: function(n, r) {
          nM(n), uUe(r);
          var i = this.addHandler(Bo.SOURCE, n, r);
          return this.store.dispatch(UBe(i)), i;
        }
      },
      {
        key: "addTarget",
        value: function(n, r) {
          nM(n, true), dUe(r);
          var i = this.addHandler(Bo.TARGET, n, r);
          return this.store.dispatch(VBe(i)), i;
        }
      },
      {
        key: "containsHandler",
        value: function(n) {
          return B9(this.dragSources, n) || B9(this.dropTargets, n);
        }
      },
      {
        key: "getSource",
        value: function(n) {
          var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
          lt(this.isSourceId(n), "Expected a valid source ID.");
          var i = r && n === this.pinnedSourceId, s = i ? this.pinnedSource : this.dragSources.get(n);
          return s;
        }
      },
      {
        key: "getTarget",
        value: function(n) {
          return lt(this.isTargetId(n), "Expected a valid target ID."), this.dropTargets.get(n);
        }
      },
      {
        key: "getSourceType",
        value: function(n) {
          return lt(this.isSourceId(n), "Expected a valid source ID."), this.types.get(n);
        }
      },
      {
        key: "getTargetType",
        value: function(n) {
          return lt(this.isTargetId(n), "Expected a valid target ID."), this.types.get(n);
        }
      },
      {
        key: "isSourceId",
        value: function(n) {
          var r = F9(n);
          return r === Bo.SOURCE;
        }
      },
      {
        key: "isTargetId",
        value: function(n) {
          var r = F9(n);
          return r === Bo.TARGET;
        }
      },
      {
        key: "removeSource",
        value: function(n) {
          var r = this;
          lt(this.getSource(n), "Expected an existing source."), this.store.dispatch(XBe(n)), vUe(function() {
            r.dragSources.delete(n), r.types.delete(n);
          });
        }
      },
      {
        key: "removeTarget",
        value: function(n) {
          lt(this.getTarget(n), "Expected an existing target."), this.store.dispatch(WBe(n)), this.dropTargets.delete(n), this.types.delete(n);
        }
      },
      {
        key: "pinSource",
        value: function(n) {
          var r = this.getSource(n);
          lt(r, "Expected an existing source."), this.pinnedSourceId = n, this.pinnedSource = r;
        }
      },
      {
        key: "unpinSource",
        value: function() {
          lt(this.pinnedSource, "No source is pinned at the time."), this.pinnedSourceId = null, this.pinnedSource = null;
        }
      },
      {
        key: "addHandler",
        value: function(n, r, i) {
          var s = CUe(n);
          return this.types.set(s, r), n === Bo.SOURCE ? this.dragSources.set(s, i) : n === Bo.TARGET && this.dropTargets.set(s, i), s;
        }
      }
    ]), t;
  }();
  function TUe(t) {
    var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : void 0, n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, i = EUe(r), s = new aUe(i, new _Ue(i)), o = new LBe(i, s), a = t(o, e, n);
    return o.receiveBackend(a), o;
  }
  function EUe(t) {
    var e = typeof window < "u" && window.__REDUX_DEVTOOLS_EXTENSION__;
    return ure(tUe, t && e && e({
      name: "dnd-core",
      instanceId: "dnd-core"
    }));
  }
  var IUe = [
    "children"
  ];
  function $Ue(t, e) {
    return DUe(t) || MUe(t, e) || RUe(t, e) || AUe();
  }
  function AUe() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function RUe(t, e) {
    if (t) {
      if (typeof t == "string")
        return U9(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return U9(t, e);
    }
  }
  function U9(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function MUe(t, e) {
    var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
    if (n != null) {
      var r = [], i = true, s = false, o, a;
      try {
        for (n = n.call(t); !(i = (o = n.next()).done) && (r.push(o.value), !(e && r.length === e)); i = true)
          ;
      } catch (l) {
        s = true, a = l;
      } finally {
        try {
          !i && n.return != null && n.return();
        } finally {
          if (s)
            throw a;
        }
      }
      return r;
    }
  }
  function DUe(t) {
    if (Array.isArray(t))
      return t;
  }
  function LUe(t, e) {
    if (t == null)
      return {};
    var n = jUe(t, e), r, i;
    if (Object.getOwnPropertySymbols) {
      var s = Object.getOwnPropertySymbols(t);
      for (i = 0; i < s.length; i++)
        r = s[i], !(e.indexOf(r) >= 0) && Object.prototype.propertyIsEnumerable.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }
  function jUe(t, e) {
    if (t == null)
      return {};
    var n = {}, r = Object.keys(t), i, s;
    for (s = 0; s < r.length; s++)
      i = r[s], !(e.indexOf(i) >= 0) && (n[i] = t[i]);
    return n;
  }
  var V9 = 0, sb = Symbol.for("__REACT_DND_CONTEXT_INSTANCE__"), NUe = b.memo(function(e) {
    var n = e.children, r = LUe(e, IUe), i = QUe(r), s = $Ue(i, 2), o = s[0], a = s[1];
    return b.useEffect(function() {
      if (a) {
        var l = gre();
        return ++V9, function() {
          --V9 === 0 && (l[sb] = null);
        };
      }
    }, []), m.jsx(lre.Provider, Object.assign({
      value: o
    }, {
      children: n
    }), void 0);
  });
  function QUe(t) {
    if ("manager" in t) {
      var e = {
        dragDropManager: t.manager
      };
      return [
        e,
        false
      ];
    }
    var n = zUe(t.backend, t.context, t.options, t.debugMode), r = !t.context;
    return [
      n,
      r
    ];
  }
  function zUe(t) {
    var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : gre(), n = arguments.length > 2 ? arguments[2] : void 0, r = arguments.length > 3 ? arguments[3] : void 0, i = e;
    return i[sb] || (i[sb] = {
      dragDropManager: TUe(t, e, n, r)
    }), i[sb];
  }
  function gre() {
    return typeof global < "u" ? global : window;
  }
  function FUe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function X9(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function BUe(t, e, n) {
    return e && X9(t.prototype, e), n && X9(t, n), t;
  }
  function W9(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var DI = false, LI = false, UUe = function() {
    function t(e) {
      FUe(this, t), W9(this, "internalMonitor", void 0), W9(this, "sourceId", null), this.internalMonitor = e.getMonitor();
    }
    return BUe(t, [
      {
        key: "receiveHandlerId",
        value: function(n) {
          this.sourceId = n;
        }
      },
      {
        key: "getHandlerId",
        value: function() {
          return this.sourceId;
        }
      },
      {
        key: "canDrag",
        value: function() {
          lt(!DI, "You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");
          try {
            return DI = true, this.internalMonitor.canDragSource(this.sourceId);
          } finally {
            DI = false;
          }
        }
      },
      {
        key: "isDragging",
        value: function() {
          if (!this.sourceId)
            return false;
          lt(!LI, "You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");
          try {
            return LI = true, this.internalMonitor.isDraggingSource(this.sourceId);
          } finally {
            LI = false;
          }
        }
      },
      {
        key: "subscribeToStateChange",
        value: function(n, r) {
          return this.internalMonitor.subscribeToStateChange(n, r);
        }
      },
      {
        key: "isDraggingSource",
        value: function(n) {
          return this.internalMonitor.isDraggingSource(n);
        }
      },
      {
        key: "isOverTarget",
        value: function(n, r) {
          return this.internalMonitor.isOverTarget(n, r);
        }
      },
      {
        key: "getTargetIds",
        value: function() {
          return this.internalMonitor.getTargetIds();
        }
      },
      {
        key: "isSourcePublic",
        value: function() {
          return this.internalMonitor.isSourcePublic();
        }
      },
      {
        key: "getSourceId",
        value: function() {
          return this.internalMonitor.getSourceId();
        }
      },
      {
        key: "subscribeToOffsetChange",
        value: function(n) {
          return this.internalMonitor.subscribeToOffsetChange(n);
        }
      },
      {
        key: "canDragSource",
        value: function(n) {
          return this.internalMonitor.canDragSource(n);
        }
      },
      {
        key: "canDropOnTarget",
        value: function(n) {
          return this.internalMonitor.canDropOnTarget(n);
        }
      },
      {
        key: "getItemType",
        value: function() {
          return this.internalMonitor.getItemType();
        }
      },
      {
        key: "getItem",
        value: function() {
          return this.internalMonitor.getItem();
        }
      },
      {
        key: "getDropResult",
        value: function() {
          return this.internalMonitor.getDropResult();
        }
      },
      {
        key: "didDrop",
        value: function() {
          return this.internalMonitor.didDrop();
        }
      },
      {
        key: "getInitialClientOffset",
        value: function() {
          return this.internalMonitor.getInitialClientOffset();
        }
      },
      {
        key: "getInitialSourceClientOffset",
        value: function() {
          return this.internalMonitor.getInitialSourceClientOffset();
        }
      },
      {
        key: "getSourceClientOffset",
        value: function() {
          return this.internalMonitor.getSourceClientOffset();
        }
      },
      {
        key: "getClientOffset",
        value: function() {
          return this.internalMonitor.getClientOffset();
        }
      },
      {
        key: "getDifferenceFromInitialOffset",
        value: function() {
          return this.internalMonitor.getDifferenceFromInitialOffset();
        }
      }
    ]), t;
  }();
  function VUe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function Z9(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function XUe(t, e, n) {
    return e && Z9(t.prototype, e), n && Z9(t, n), t;
  }
  function H9(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var jI = false, WUe = function() {
    function t(e) {
      VUe(this, t), H9(this, "internalMonitor", void 0), H9(this, "targetId", null), this.internalMonitor = e.getMonitor();
    }
    return XUe(t, [
      {
        key: "receiveHandlerId",
        value: function(n) {
          this.targetId = n;
        }
      },
      {
        key: "getHandlerId",
        value: function() {
          return this.targetId;
        }
      },
      {
        key: "subscribeToStateChange",
        value: function(n, r) {
          return this.internalMonitor.subscribeToStateChange(n, r);
        }
      },
      {
        key: "canDrop",
        value: function() {
          if (!this.targetId)
            return false;
          lt(!jI, "You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");
          try {
            return jI = true, this.internalMonitor.canDropOnTarget(this.targetId);
          } finally {
            jI = false;
          }
        }
      },
      {
        key: "isOver",
        value: function(n) {
          return this.targetId ? this.internalMonitor.isOverTarget(this.targetId, n) : false;
        }
      },
      {
        key: "getItemType",
        value: function() {
          return this.internalMonitor.getItemType();
        }
      },
      {
        key: "getItem",
        value: function() {
          return this.internalMonitor.getItem();
        }
      },
      {
        key: "getDropResult",
        value: function() {
          return this.internalMonitor.getDropResult();
        }
      },
      {
        key: "didDrop",
        value: function() {
          return this.internalMonitor.didDrop();
        }
      },
      {
        key: "getInitialClientOffset",
        value: function() {
          return this.internalMonitor.getInitialClientOffset();
        }
      },
      {
        key: "getInitialSourceClientOffset",
        value: function() {
          return this.internalMonitor.getInitialSourceClientOffset();
        }
      },
      {
        key: "getSourceClientOffset",
        value: function() {
          return this.internalMonitor.getSourceClientOffset();
        }
      },
      {
        key: "getClientOffset",
        value: function() {
          return this.internalMonitor.getClientOffset();
        }
      },
      {
        key: "getDifferenceFromInitialOffset",
        value: function() {
          return this.internalMonitor.getDifferenceFromInitialOffset();
        }
      }
    ]), t;
  }();
  function ZUe(t) {
    if (typeof t.type != "string") {
      var e = t.type.displayName || t.type.name || "the component";
      throw new Error("Only native element nodes can now be passed to React DnD connectors." + "You can either wrap ".concat(e, " into a <div>, or turn it into a ") + "drag source or a drop target itself.");
    }
  }
  function HUe(t) {
    return function() {
      var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
      if (!b.isValidElement(e)) {
        var r = e;
        return t(r, n), r;
      }
      var i = e;
      ZUe(i);
      var s = n ? function(o) {
        return t(o, n);
      } : t;
      return YUe(i, s);
    };
  }
  function mre(t) {
    var e = {};
    return Object.keys(t).forEach(function(n) {
      var r = t[n];
      if (n.endsWith("Ref"))
        e[n] = t[n];
      else {
        var i = HUe(r);
        e[n] = function() {
          return i;
        };
      }
    }), e;
  }
  function Y9(t, e) {
    typeof t == "function" ? t(e) : t.current = e;
  }
  function YUe(t, e) {
    var n = t.ref;
    return lt(typeof n != "string", "Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"), n ? b.cloneElement(t, {
      ref: function(i) {
        Y9(n, i), Y9(e, i);
      }
    }) : b.cloneElement(t, {
      ref: e
    });
  }
  function ob(t) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? ob = function(n) {
      return typeof n;
    } : ob = function(n) {
      return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
    }, ob(t);
  }
  function rM(t) {
    return t !== null && ob(t) === "object" && Object.prototype.hasOwnProperty.call(t, "current");
  }
  function iM(t, e, n, r) {
    var i = n ? n.call(r, t, e) : void 0;
    if (i !== void 0)
      return !!i;
    if (t === e)
      return true;
    if (typeof t != "object" || !t || typeof e != "object" || !e)
      return false;
    var s = Object.keys(t), o = Object.keys(e);
    if (s.length !== o.length)
      return false;
    for (var a = Object.prototype.hasOwnProperty.bind(e), l = 0; l < s.length; l++) {
      var c = s[l];
      if (!a(c))
        return false;
      var u = t[c], d = e[c];
      if (i = n ? n.call(r, u, d, c) : void 0, i === false || i === void 0 && u !== d)
        return false;
    }
    return true;
  }
  function GUe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function G9(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function qUe(t, e, n) {
    return e && G9(t.prototype, e), n && G9(t, n), t;
  }
  function si(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var KUe = function() {
    function t(e) {
      var n = this;
      GUe(this, t), si(this, "hooks", mre({
        dragSource: function(i, s) {
          n.clearDragSource(), n.dragSourceOptions = s || null, rM(i) ? n.dragSourceRef = i : n.dragSourceNode = i, n.reconnectDragSource();
        },
        dragPreview: function(i, s) {
          n.clearDragPreview(), n.dragPreviewOptions = s || null, rM(i) ? n.dragPreviewRef = i : n.dragPreviewNode = i, n.reconnectDragPreview();
        }
      })), si(this, "handlerId", null), si(this, "dragSourceRef", null), si(this, "dragSourceNode", void 0), si(this, "dragSourceOptionsInternal", null), si(this, "dragSourceUnsubscribe", void 0), si(this, "dragPreviewRef", null), si(this, "dragPreviewNode", void 0), si(this, "dragPreviewOptionsInternal", null), si(this, "dragPreviewUnsubscribe", void 0), si(this, "lastConnectedHandlerId", null), si(this, "lastConnectedDragSource", null), si(this, "lastConnectedDragSourceOptions", null), si(this, "lastConnectedDragPreview", null), si(this, "lastConnectedDragPreviewOptions", null), si(this, "backend", void 0), this.backend = e;
    }
    return qUe(t, [
      {
        key: "receiveHandlerId",
        value: function(n) {
          this.handlerId !== n && (this.handlerId = n, this.reconnect());
        }
      },
      {
        key: "connectTarget",
        get: function() {
          return this.dragSource;
        }
      },
      {
        key: "dragSourceOptions",
        get: function() {
          return this.dragSourceOptionsInternal;
        },
        set: function(n) {
          this.dragSourceOptionsInternal = n;
        }
      },
      {
        key: "dragPreviewOptions",
        get: function() {
          return this.dragPreviewOptionsInternal;
        },
        set: function(n) {
          this.dragPreviewOptionsInternal = n;
        }
      },
      {
        key: "reconnect",
        value: function() {
          this.reconnectDragSource(), this.reconnectDragPreview();
        }
      },
      {
        key: "reconnectDragSource",
        value: function() {
          var n = this.dragSource, r = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
          if (r && this.disconnectDragSource(), !!this.handlerId) {
            if (!n) {
              this.lastConnectedDragSource = n;
              return;
            }
            r && (this.lastConnectedHandlerId = this.handlerId, this.lastConnectedDragSource = n, this.lastConnectedDragSourceOptions = this.dragSourceOptions, this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, n, this.dragSourceOptions));
          }
        }
      },
      {
        key: "reconnectDragPreview",
        value: function() {
          var n = this.dragPreview, r = this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
          if (r && this.disconnectDragPreview(), !!this.handlerId) {
            if (!n) {
              this.lastConnectedDragPreview = n;
              return;
            }
            r && (this.lastConnectedHandlerId = this.handlerId, this.lastConnectedDragPreview = n, this.lastConnectedDragPreviewOptions = this.dragPreviewOptions, this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, n, this.dragPreviewOptions));
          }
        }
      },
      {
        key: "didHandlerIdChange",
        value: function() {
          return this.lastConnectedHandlerId !== this.handlerId;
        }
      },
      {
        key: "didConnectedDragSourceChange",
        value: function() {
          return this.lastConnectedDragSource !== this.dragSource;
        }
      },
      {
        key: "didConnectedDragPreviewChange",
        value: function() {
          return this.lastConnectedDragPreview !== this.dragPreview;
        }
      },
      {
        key: "didDragSourceOptionsChange",
        value: function() {
          return !iM(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
        }
      },
      {
        key: "didDragPreviewOptionsChange",
        value: function() {
          return !iM(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
        }
      },
      {
        key: "disconnectDragSource",
        value: function() {
          this.dragSourceUnsubscribe && (this.dragSourceUnsubscribe(), this.dragSourceUnsubscribe = void 0);
        }
      },
      {
        key: "disconnectDragPreview",
        value: function() {
          this.dragPreviewUnsubscribe && (this.dragPreviewUnsubscribe(), this.dragPreviewUnsubscribe = void 0, this.dragPreviewNode = null, this.dragPreviewRef = null);
        }
      },
      {
        key: "dragSource",
        get: function() {
          return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
        }
      },
      {
        key: "dragPreview",
        get: function() {
          return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
        }
      },
      {
        key: "clearDragSource",
        value: function() {
          this.dragSourceNode = null, this.dragSourceRef = null;
        }
      },
      {
        key: "clearDragPreview",
        value: function() {
          this.dragPreviewNode = null, this.dragPreviewRef = null;
        }
      }
    ]), t;
  }();
  function JUe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function q9(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function eVe(t, e, n) {
    return e && q9(t.prototype, e), n && q9(t, n), t;
  }
  function ol(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var tVe = function() {
    function t(e) {
      var n = this;
      JUe(this, t), ol(this, "hooks", mre({
        dropTarget: function(i, s) {
          n.clearDropTarget(), n.dropTargetOptions = s, rM(i) ? n.dropTargetRef = i : n.dropTargetNode = i, n.reconnect();
        }
      })), ol(this, "handlerId", null), ol(this, "dropTargetRef", null), ol(this, "dropTargetNode", void 0), ol(this, "dropTargetOptionsInternal", null), ol(this, "unsubscribeDropTarget", void 0), ol(this, "lastConnectedHandlerId", null), ol(this, "lastConnectedDropTarget", null), ol(this, "lastConnectedDropTargetOptions", null), ol(this, "backend", void 0), this.backend = e;
    }
    return eVe(t, [
      {
        key: "connectTarget",
        get: function() {
          return this.dropTarget;
        }
      },
      {
        key: "reconnect",
        value: function() {
          var n = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange();
          n && this.disconnectDropTarget();
          var r = this.dropTarget;
          if (this.handlerId) {
            if (!r) {
              this.lastConnectedDropTarget = r;
              return;
            }
            n && (this.lastConnectedHandlerId = this.handlerId, this.lastConnectedDropTarget = r, this.lastConnectedDropTargetOptions = this.dropTargetOptions, this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, r, this.dropTargetOptions));
          }
        }
      },
      {
        key: "receiveHandlerId",
        value: function(n) {
          n !== this.handlerId && (this.handlerId = n, this.reconnect());
        }
      },
      {
        key: "dropTargetOptions",
        get: function() {
          return this.dropTargetOptionsInternal;
        },
        set: function(n) {
          this.dropTargetOptionsInternal = n;
        }
      },
      {
        key: "didHandlerIdChange",
        value: function() {
          return this.lastConnectedHandlerId !== this.handlerId;
        }
      },
      {
        key: "didDropTargetChange",
        value: function() {
          return this.lastConnectedDropTarget !== this.dropTarget;
        }
      },
      {
        key: "didOptionsChange",
        value: function() {
          return !iM(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
        }
      },
      {
        key: "disconnectDropTarget",
        value: function() {
          this.unsubscribeDropTarget && (this.unsubscribeDropTarget(), this.unsubscribeDropTarget = void 0);
        }
      },
      {
        key: "dropTarget",
        get: function() {
          return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
        }
      },
      {
        key: "clearDropTarget",
        value: function() {
          this.dropTargetRef = null, this.dropTargetNode = null;
        }
      }
    ]), t;
  }();
  function nVe(t, e, n) {
    var r = n.getRegistry(), i = r.addTarget(t, e);
    return [
      i,
      function() {
        return r.removeTarget(i);
      }
    ];
  }
  function rVe(t, e, n) {
    var r = n.getRegistry(), i = r.addSource(t, e);
    return [
      i,
      function() {
        return r.removeSource(i);
      }
    ];
  }
  var cf = typeof window < "u" ? b.useLayoutEffect : b.useEffect;
  function ab(t) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? ab = function(n) {
      return typeof n;
    } : ab = function(n) {
      return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
    }, ab(t);
  }
  function iVe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function K9(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function sVe(t, e, n) {
    return e && K9(t.prototype, e), n && K9(t, n), t;
  }
  function NI(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var oVe = function() {
    function t(e, n, r) {
      iVe(this, t), NI(this, "spec", void 0), NI(this, "monitor", void 0), NI(this, "connector", void 0), this.spec = e, this.monitor = n, this.connector = r;
    }
    return sVe(t, [
      {
        key: "beginDrag",
        value: function() {
          var n, r = this.spec, i = this.monitor, s = null;
          return ab(r.item) === "object" ? s = r.item : typeof r.item == "function" ? s = r.item(i) : s = {}, (n = s) !== null && n !== void 0 ? n : null;
        }
      },
      {
        key: "canDrag",
        value: function() {
          var n = this.spec, r = this.monitor;
          return typeof n.canDrag == "boolean" ? n.canDrag : typeof n.canDrag == "function" ? n.canDrag(r) : true;
        }
      },
      {
        key: "isDragging",
        value: function(n, r) {
          var i = this.spec, s = this.monitor, o = i.isDragging;
          return o ? o(s) : r === n.getSourceId();
        }
      },
      {
        key: "endDrag",
        value: function() {
          var n = this.spec, r = this.monitor, i = this.connector, s = n.end;
          s && s(r.getItem(), r), i.reconnect();
        }
      }
    ]), t;
  }();
  function aVe(t, e, n) {
    var r = b.useMemo(function() {
      return new oVe(t, e, n);
    }, [
      e,
      n
    ]);
    return b.useEffect(function() {
      r.spec = t;
    }, [
      t
    ]), r;
  }
  function Ef() {
    var t = b.useContext(lre), e = t.dragDropManager;
    return lt(e != null, "Expected drag drop context"), e;
  }
  function lVe(t) {
    return b.useMemo(function() {
      var e = t.type;
      return lt(e != null, "spec.type must be defined"), e;
    }, [
      t
    ]);
  }
  function cVe(t, e) {
    return fVe(t) || hVe(t, e) || dVe(t, e) || uVe();
  }
  function uVe() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function dVe(t, e) {
    if (t) {
      if (typeof t == "string")
        return J9(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return J9(t, e);
    }
  }
  function J9(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function hVe(t, e) {
    var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
    if (n != null) {
      var r = [], i = true, s = false, o, a;
      try {
        for (n = n.call(t); !(i = (o = n.next()).done) && (r.push(o.value), !(e && r.length === e)); i = true)
          ;
      } catch (l) {
        s = true, a = l;
      } finally {
        try {
          !i && n.return != null && n.return();
        } finally {
          if (s)
            throw a;
        }
      }
      return r;
    }
  }
  function fVe(t) {
    if (Array.isArray(t))
      return t;
  }
  function pVe(t, e, n) {
    var r = Ef(), i = aVe(t, e, n), s = lVe(t);
    cf(function() {
      if (s != null) {
        var a = rVe(s, i, r), l = cVe(a, 2), c = l[0], u = l[1];
        return e.receiveHandlerId(c), n.receiveHandlerId(c), u;
      }
    }, [
      r,
      e,
      n,
      i,
      s
    ]);
  }
  function gVe(t) {
    return OVe(t) || vVe(t) || yVe(t) || mVe();
  }
  function mVe() {
    throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function yVe(t, e) {
    if (t) {
      if (typeof t == "string")
        return sM(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return sM(t, e);
    }
  }
  function vVe(t) {
    if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null)
      return Array.from(t);
  }
  function OVe(t) {
    if (Array.isArray(t))
      return sM(t);
  }
  function sM(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function yre(t, e) {
    var n = gVe(e || []);
    return e == null && typeof t != "function" && n.push(t), b.useMemo(function() {
      return typeof t == "function" ? t() : t;
    }, n);
  }
  function SVe() {
    var t = Ef();
    return b.useMemo(function() {
      return new UUe(t);
    }, [
      t
    ]);
  }
  function wVe(t, e) {
    var n = Ef(), r = b.useMemo(function() {
      return new KUe(n.getBackend());
    }, [
      n
    ]);
    return cf(function() {
      return r.dragSourceOptions = t || null, r.reconnect(), function() {
        return r.disconnectDragSource();
      };
    }, [
      r,
      t
    ]), cf(function() {
      return r.dragPreviewOptions = e || null, r.reconnect(), function() {
        return r.disconnectDragPreview();
      };
    }, [
      r,
      e
    ]), r;
  }
  var xVe = function t(e, n) {
    if (e === n)
      return true;
    if (e && n && typeof e == "object" && typeof n == "object") {
      if (e.constructor !== n.constructor)
        return false;
      var r, i, s;
      if (Array.isArray(e)) {
        if (r = e.length, r != n.length)
          return false;
        for (i = r; i-- !== 0; )
          if (!t(e[i], n[i]))
            return false;
        return true;
      }
      if (e.constructor === RegExp)
        return e.source === n.source && e.flags === n.flags;
      if (e.valueOf !== Object.prototype.valueOf)
        return e.valueOf() === n.valueOf();
      if (e.toString !== Object.prototype.toString)
        return e.toString() === n.toString();
      if (s = Object.keys(e), r = s.length, r !== Object.keys(n).length)
        return false;
      for (i = r; i-- !== 0; )
        if (!Object.prototype.hasOwnProperty.call(n, s[i]))
          return false;
      for (i = r; i-- !== 0; ) {
        var o = s[i];
        if (!t(e[o], n[o]))
          return false;
      }
      return true;
    }
    return e !== e && n !== n;
  };
  const bVe = Rd(xVe);
  function kVe(t, e) {
    return TVe(t) || _Ve(t, e) || CVe(t, e) || PVe();
  }
  function PVe() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function CVe(t, e) {
    if (t) {
      if (typeof t == "string")
        return eB(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return eB(t, e);
    }
  }
  function eB(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function _Ve(t, e) {
    var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
    if (n != null) {
      var r = [], i = true, s = false, o, a;
      try {
        for (n = n.call(t); !(i = (o = n.next()).done) && (r.push(o.value), !(e && r.length === e)); i = true)
          ;
      } catch (l) {
        s = true, a = l;
      } finally {
        try {
          !i && n.return != null && n.return();
        } finally {
          if (s)
            throw a;
        }
      }
      return r;
    }
  }
  function TVe(t) {
    if (Array.isArray(t))
      return t;
  }
  function vre(t, e, n) {
    var r = b.useState(function() {
      return e(t);
    }), i = kVe(r, 2), s = i[0], o = i[1], a = b.useCallback(function() {
      var l = e(t);
      bVe(s, l) || (o(l), n && n());
    }, [
      s,
      t,
      n
    ]);
    return cf(a), [
      s,
      a
    ];
  }
  function EVe(t, e) {
    return RVe(t) || AVe(t, e) || $Ve(t, e) || IVe();
  }
  function IVe() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function $Ve(t, e) {
    if (t) {
      if (typeof t == "string")
        return tB(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return tB(t, e);
    }
  }
  function tB(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function AVe(t, e) {
    var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
    if (n != null) {
      var r = [], i = true, s = false, o, a;
      try {
        for (n = n.call(t); !(i = (o = n.next()).done) && (r.push(o.value), !(e && r.length === e)); i = true)
          ;
      } catch (l) {
        s = true, a = l;
      } finally {
        try {
          !i && n.return != null && n.return();
        } finally {
          if (s)
            throw a;
        }
      }
      return r;
    }
  }
  function RVe(t) {
    if (Array.isArray(t))
      return t;
  }
  function MVe(t, e, n) {
    var r = vre(t, e, n), i = EVe(r, 2), s = i[0], o = i[1];
    return cf(function() {
      var l = t.getHandlerId();
      if (l != null)
        return t.subscribeToStateChange(o, {
          handlerIds: [
            l
          ]
        });
    }, [
      t,
      o
    ]), s;
  }
  function Ore(t, e, n) {
    return MVe(e, t || function() {
      return {};
    }, function() {
      return n.reconnect();
    });
  }
  function DVe(t) {
    return b.useMemo(function() {
      return t.hooks.dragSource();
    }, [
      t
    ]);
  }
  function LVe(t) {
    return b.useMemo(function() {
      return t.hooks.dragPreview();
    }, [
      t
    ]);
  }
  function jVe(t, e) {
    var n = yre(t, e);
    lt(!n.begin, "useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)");
    var r = SVe(), i = wVe(n.options, n.previewOptions);
    return pVe(n, r, i), [
      Ore(n.collect, r, i),
      DVe(i),
      LVe(i)
    ];
  }
  function NVe(t) {
    var e = t.accept;
    return b.useMemo(function() {
      return lt(t.accept != null, "accept must be defined"), Array.isArray(e) ? e : [
        e
      ];
    }, [
      e
    ]);
  }
  function QVe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function nB(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function zVe(t, e, n) {
    return e && nB(t.prototype, e), n && nB(t, n), t;
  }
  function rB(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var FVe = function() {
    function t(e, n) {
      QVe(this, t), rB(this, "spec", void 0), rB(this, "monitor", void 0), this.spec = e, this.monitor = n;
    }
    return zVe(t, [
      {
        key: "canDrop",
        value: function() {
          var n = this.spec, r = this.monitor;
          return n.canDrop ? n.canDrop(r.getItem(), r) : true;
        }
      },
      {
        key: "hover",
        value: function() {
          var n = this.spec, r = this.monitor;
          n.hover && n.hover(r.getItem(), r);
        }
      },
      {
        key: "drop",
        value: function() {
          var n = this.spec, r = this.monitor;
          if (n.drop)
            return n.drop(r.getItem(), r);
        }
      }
    ]), t;
  }();
  function BVe(t, e) {
    var n = b.useMemo(function() {
      return new FVe(t, e);
    }, [
      e
    ]);
    return b.useEffect(function() {
      n.spec = t;
    }, [
      t
    ]), n;
  }
  function UVe(t, e) {
    return ZVe(t) || WVe(t, e) || XVe(t, e) || VVe();
  }
  function VVe() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function XVe(t, e) {
    if (t) {
      if (typeof t == "string")
        return iB(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return iB(t, e);
    }
  }
  function iB(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function WVe(t, e) {
    var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
    if (n != null) {
      var r = [], i = true, s = false, o, a;
      try {
        for (n = n.call(t); !(i = (o = n.next()).done) && (r.push(o.value), !(e && r.length === e)); i = true)
          ;
      } catch (l) {
        s = true, a = l;
      } finally {
        try {
          !i && n.return != null && n.return();
        } finally {
          if (s)
            throw a;
        }
      }
      return r;
    }
  }
  function ZVe(t) {
    if (Array.isArray(t))
      return t;
  }
  function HVe(t, e, n) {
    var r = Ef(), i = BVe(t, e), s = NVe(t);
    cf(function() {
      var a = nVe(s, i, r), l = UVe(a, 2), c = l[0], u = l[1];
      return e.receiveHandlerId(c), n.receiveHandlerId(c), u;
    }, [
      r,
      e,
      i,
      n,
      s.map(function(o) {
        return o.toString();
      }).join("|")
    ]);
  }
  function YVe() {
    var t = Ef();
    return b.useMemo(function() {
      return new WUe(t);
    }, [
      t
    ]);
  }
  function GVe(t) {
    var e = Ef(), n = b.useMemo(function() {
      return new tVe(e.getBackend());
    }, [
      e
    ]);
    return cf(function() {
      return n.dropTargetOptions = t || null, n.reconnect(), function() {
        return n.disconnectDropTarget();
      };
    }, [
      t
    ]), n;
  }
  function qVe(t) {
    return b.useMemo(function() {
      return t.hooks.dropTarget();
    }, [
      t
    ]);
  }
  function Sre(t, e) {
    var n = yre(t, e), r = YVe(), i = GVe(n.options);
    return HVe(n, r, i), [
      Ore(n.collect, r, i),
      qVe(i)
    ];
  }
  function KVe(t, e) {
    return nXe(t) || tXe(t, e) || eXe(t, e) || JVe();
  }
  function JVe() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function eXe(t, e) {
    if (t) {
      if (typeof t == "string")
        return sB(t, e);
      var n = Object.prototype.toString.call(t).slice(8, -1);
      if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
        return Array.from(t);
      if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
        return sB(t, e);
    }
  }
  function sB(t, e) {
    (e == null || e > t.length) && (e = t.length);
    for (var n = 0, r = new Array(e); n < e; n++)
      r[n] = t[n];
    return r;
  }
  function tXe(t, e) {
    var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
    if (n != null) {
      var r = [], i = true, s = false, o, a;
      try {
        for (n = n.call(t); !(i = (o = n.next()).done) && (r.push(o.value), !(e && r.length === e)); i = true)
          ;
      } catch (l) {
        s = true, a = l;
      } finally {
        try {
          !i && n.return != null && n.return();
        } finally {
          if (s)
            throw a;
        }
      }
      return r;
    }
  }
  function nXe(t) {
    if (Array.isArray(t))
      return t;
  }
  function rXe(t) {
    var e = Ef(), n = e.getMonitor(), r = vre(n, t), i = KVe(r, 2), s = i[0], o = i[1];
    return b.useEffect(function() {
      return n.subscribeToOffsetChange(o);
    }), b.useEffect(function() {
      return n.subscribeToStateChange(o);
    }), s;
  }
  function wre(t) {
    var e = null, n = function() {
      return e == null && (e = t()), e;
    };
    return n;
  }
  function iXe(t, e) {
    return t.filter(function(n) {
      return n !== e;
    });
  }
  function sXe(t, e) {
    var n = /* @__PURE__ */ new Set(), r = function(o) {
      return n.add(o);
    };
    t.forEach(r), e.forEach(r);
    var i = [];
    return n.forEach(function(s) {
      return i.push(s);
    }), i;
  }
  function oXe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function oB(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function aXe(t, e, n) {
    return e && oB(t.prototype, e), n && oB(t, n), t;
  }
  function aB(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var lXe = function() {
    function t(e) {
      oXe(this, t), aB(this, "entered", []), aB(this, "isNodeInDocument", void 0), this.isNodeInDocument = e;
    }
    return aXe(t, [
      {
        key: "enter",
        value: function(n) {
          var r = this, i = this.entered.length, s = function(a) {
            return r.isNodeInDocument(a) && (!a.contains || a.contains(n));
          };
          return this.entered = sXe(this.entered.filter(s), [
            n
          ]), i === 0 && this.entered.length > 0;
        }
      },
      {
        key: "leave",
        value: function(n) {
          var r = this.entered.length;
          return this.entered = iXe(this.entered.filter(this.isNodeInDocument), n), r > 0 && this.entered.length === 0;
        }
      },
      {
        key: "reset",
        value: function() {
          this.entered = [];
        }
      }
    ]), t;
  }(), cXe = wre(function() {
    return /firefox/i.test(navigator.userAgent);
  }), xre = wre(function() {
    return !!window.safari;
  });
  function uXe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function lB(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function dXe(t, e, n) {
    return e && lB(t.prototype, e), n && lB(t, n), t;
  }
  function t0(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var cB = function() {
    function t(e, n) {
      uXe(this, t), t0(this, "xs", void 0), t0(this, "ys", void 0), t0(this, "c1s", void 0), t0(this, "c2s", void 0), t0(this, "c3s", void 0);
      for (var r = e.length, i = [], s = 0; s < r; s++)
        i.push(s);
      i.sort(function($, N) {
        return e[$] < e[N] ? -1 : 1;
      });
      for (var o = [], a = [], l, c, u = 0; u < r - 1; u++)
        l = e[u + 1] - e[u], c = n[u + 1] - n[u], o.push(l), a.push(c / l);
      for (var d = [
        a[0]
      ], h = 0; h < o.length - 1; h++) {
        var f = a[h], y = a[h + 1];
        if (f * y <= 0)
          d.push(0);
        else {
          l = o[h];
          var g = o[h + 1], O = l + g;
          d.push(3 * O / ((O + g) / f + (O + l) / y));
        }
      }
      d.push(a[a.length - 1]);
      for (var S = [], w = [], x, P = 0; P < d.length - 1; P++) {
        x = a[P];
        var C = d[P], _ = 1 / o[P], T = C + d[P + 1] - x - x;
        S.push((x - C - T) * _), w.push(T * _ * _);
      }
      this.xs = e, this.ys = n, this.c1s = d, this.c2s = S, this.c3s = w;
    }
    return dXe(t, [
      {
        key: "interpolate",
        value: function(n) {
          var r = this.xs, i = this.ys, s = this.c1s, o = this.c2s, a = this.c3s, l = r.length - 1;
          if (n === r[l])
            return i[l];
          for (var c = 0, u = a.length - 1, d; c <= u; ) {
            d = Math.floor(0.5 * (c + u));
            var h = r[d];
            if (h < n)
              c = d + 1;
            else if (h > n)
              u = d - 1;
            else
              return i[d];
          }
          l = Math.max(0, u);
          var f = n - r[l], y = f * f;
          return i[l] + s[l] * f + o[l] * y + a[l] * f * y;
        }
      }
    ]), t;
  }(), hXe = 1;
  function bre(t) {
    var e = t.nodeType === hXe ? t : t.parentElement;
    if (!e)
      return null;
    var n = e.getBoundingClientRect(), r = n.top, i = n.left;
    return {
      x: i,
      y: r
    };
  }
  function Vw(t) {
    return {
      x: t.clientX,
      y: t.clientY
    };
  }
  function fXe(t) {
    var e;
    return t.nodeName === "IMG" && (cXe() || !((e = document.documentElement) !== null && e !== void 0 && e.contains(t)));
  }
  function pXe(t, e, n, r) {
    var i = t ? e.width : n, s = t ? e.height : r;
    return xre() && t && (s /= window.devicePixelRatio, i /= window.devicePixelRatio), {
      dragPreviewWidth: i,
      dragPreviewHeight: s
    };
  }
  function gXe(t, e, n, r, i) {
    var s = fXe(e), o = s ? t : e, a = bre(o), l = {
      x: n.x - a.x,
      y: n.y - a.y
    }, c = t.offsetWidth, u = t.offsetHeight, d = r.anchorX, h = r.anchorY, f = pXe(s, e, c, u), y = f.dragPreviewWidth, g = f.dragPreviewHeight, O = function() {
      var T = new cB([
        0,
        0.5,
        1
      ], [
        l.y,
        l.y / u * g,
        l.y + g - u
      ]), $ = T.interpolate(h);
      return xre() && s && ($ += (window.devicePixelRatio - 1) * g), $;
    }, S = function() {
      var T = new cB([
        0,
        0.5,
        1
      ], [
        l.x,
        l.x / c * y,
        l.x + y - c
      ]);
      return T.interpolate(d);
    }, w = i.offsetX, x = i.offsetY, P = w === 0 || w, C = x === 0 || x;
    return {
      x: P ? w : S(),
      y: C ? x : O()
    };
  }
  var kre = "__NATIVE_FILE__", Pre = "__NATIVE_URL__", Cre = "__NATIVE_TEXT__", _re = "__NATIVE_HTML__";
  const uB = Object.freeze(Object.defineProperty({
    __proto__: null,
    FILE: kre,
    HTML: _re,
    TEXT: Cre,
    URL: Pre
  }, Symbol.toStringTag, {
    value: "Module"
  }));
  function QI(t, e, n) {
    var r = e.reduce(function(i, s) {
      return i || t.getData(s);
    }, "");
    return r ?? n;
  }
  var Ep;
  function Xw(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var oM = (Ep = {}, Xw(Ep, kre, {
    exposeProperties: {
      files: function(e) {
        return Array.prototype.slice.call(e.files);
      },
      items: function(e) {
        return e.items;
      },
      dataTransfer: function(e) {
        return e;
      }
    },
    matchesTypes: [
      "Files"
    ]
  }), Xw(Ep, _re, {
    exposeProperties: {
      html: function(e, n) {
        return QI(e, n, "");
      },
      dataTransfer: function(e) {
        return e;
      }
    },
    matchesTypes: [
      "Html",
      "text/html"
    ]
  }), Xw(Ep, Pre, {
    exposeProperties: {
      urls: function(e, n) {
        return QI(e, n, "").split(`
`);
      },
      dataTransfer: function(e) {
        return e;
      }
    },
    matchesTypes: [
      "Url",
      "text/uri-list"
    ]
  }), Xw(Ep, Cre, {
    exposeProperties: {
      text: function(e, n) {
        return QI(e, n, "");
      },
      dataTransfer: function(e) {
        return e;
      }
    },
    matchesTypes: [
      "Text",
      "text/plain"
    ]
  }), Ep);
  function mXe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function dB(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function yXe(t, e, n) {
    return e && dB(t.prototype, e), n && dB(t, n), t;
  }
  function hB(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var vXe = function() {
    function t(e) {
      mXe(this, t), hB(this, "item", void 0), hB(this, "config", void 0), this.config = e, this.item = {}, this.initializeExposedProperties();
    }
    return yXe(t, [
      {
        key: "initializeExposedProperties",
        value: function() {
          var n = this;
          Object.keys(this.config.exposeProperties).forEach(function(r) {
            Object.defineProperty(n.item, r, {
              configurable: true,
              enumerable: true,
              get: function() {
                return console.warn(`Browser doesn't allow reading "`.concat(r, '" until the drop event.')), null;
              }
            });
          });
        }
      },
      {
        key: "loadDataTransfer",
        value: function(n) {
          var r = this;
          if (n) {
            var i = {};
            Object.keys(this.config.exposeProperties).forEach(function(s) {
              i[s] = {
                value: r.config.exposeProperties[s](n, r.config.matchesTypes),
                configurable: true,
                enumerable: true
              };
            }), Object.defineProperties(this.item, i);
          }
        }
      },
      {
        key: "canDrag",
        value: function() {
          return true;
        }
      },
      {
        key: "beginDrag",
        value: function() {
          return this.item;
        }
      },
      {
        key: "isDragging",
        value: function(n, r) {
          return r === n.getSourceId();
        }
      },
      {
        key: "endDrag",
        value: function() {
        }
      }
    ]), t;
  }();
  function OXe(t, e) {
    var n = new vXe(oM[t]);
    return n.loadDataTransfer(e), n;
  }
  function zI(t) {
    if (!t)
      return null;
    var e = Array.prototype.slice.call(t.types || []);
    return Object.keys(oM).filter(function(n) {
      var r = oM[n].matchesTypes;
      return r.some(function(i) {
        return e.indexOf(i) > -1;
      });
    })[0] || null;
  }
  function SXe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function fB(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function wXe(t, e, n) {
    return e && fB(t.prototype, e), n && fB(t, n), t;
  }
  function FI(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var xXe = function() {
    function t(e, n) {
      SXe(this, t), FI(this, "ownerDocument", null), FI(this, "globalContext", void 0), FI(this, "optionsArgs", void 0), this.globalContext = e, this.optionsArgs = n;
    }
    return wXe(t, [
      {
        key: "window",
        get: function() {
          if (this.globalContext)
            return this.globalContext;
          if (typeof window < "u")
            return window;
        }
      },
      {
        key: "document",
        get: function() {
          var n;
          return (n = this.globalContext) !== null && n !== void 0 && n.document ? this.globalContext.document : this.window ? this.window.document : void 0;
        }
      },
      {
        key: "rootElement",
        get: function() {
          var n;
          return ((n = this.optionsArgs) === null || n === void 0 ? void 0 : n.rootElement) || this.window;
        }
      }
    ]), t;
  }();
  function pB(t, e) {
    var n = Object.keys(t);
    if (Object.getOwnPropertySymbols) {
      var r = Object.getOwnPropertySymbols(t);
      e && (r = r.filter(function(i) {
        return Object.getOwnPropertyDescriptor(t, i).enumerable;
      })), n.push.apply(n, r);
    }
    return n;
  }
  function gB(t) {
    for (var e = 1; e < arguments.length; e++) {
      var n = arguments[e] != null ? arguments[e] : {};
      e % 2 ? pB(Object(n), true).forEach(function(r) {
        Ot(t, r, n[r]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : pB(Object(n)).forEach(function(r) {
        Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
      });
    }
    return t;
  }
  function bXe(t, e) {
    if (!(t instanceof e))
      throw new TypeError("Cannot call a class as a function");
  }
  function mB(t, e) {
    for (var n = 0; n < e.length; n++) {
      var r = e[n];
      r.enumerable = r.enumerable || false, r.configurable = true, "value" in r && (r.writable = true), Object.defineProperty(t, r.key, r);
    }
  }
  function kXe(t, e, n) {
    return e && mB(t.prototype, e), n && mB(t, n), t;
  }
  function Ot(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
      value: n,
      enumerable: true,
      configurable: true,
      writable: true
    }) : t[e] = n, t;
  }
  var PXe = function() {
    function t(e, n, r) {
      var i = this;
      bXe(this, t), Ot(this, "options", void 0), Ot(this, "actions", void 0), Ot(this, "monitor", void 0), Ot(this, "registry", void 0), Ot(this, "enterLeaveCounter", void 0), Ot(this, "sourcePreviewNodes", /* @__PURE__ */ new Map()), Ot(this, "sourcePreviewNodeOptions", /* @__PURE__ */ new Map()), Ot(this, "sourceNodes", /* @__PURE__ */ new Map()), Ot(this, "sourceNodeOptions", /* @__PURE__ */ new Map()), Ot(this, "dragStartSourceIds", null), Ot(this, "dropTargetIds", []), Ot(this, "dragEnterTargetIds", []), Ot(this, "currentNativeSource", null), Ot(this, "currentNativeHandle", null), Ot(this, "currentDragSourceNode", null), Ot(this, "altKeyPressed", false), Ot(this, "mouseMoveTimeoutTimer", null), Ot(this, "asyncEndDragFrameId", null), Ot(this, "dragOverTargetIds", null), Ot(this, "lastClientOffset", null), Ot(this, "hoverRafId", null), Ot(this, "getSourceClientOffset", function(s) {
        var o = i.sourceNodes.get(s);
        return o && bre(o) || null;
      }), Ot(this, "endDragNativeItem", function() {
        i.isDraggingNativeItem() && (i.actions.endDrag(), i.currentNativeHandle && i.registry.removeSource(i.currentNativeHandle), i.currentNativeHandle = null, i.currentNativeSource = null);
      }), Ot(this, "isNodeInDocument", function(s) {
        return !!(s && i.document && i.document.body && i.document.body.contains(s));
      }), Ot(this, "endDragIfSourceWasRemovedFromDOM", function() {
        var s = i.currentDragSourceNode;
        s == null || i.isNodeInDocument(s) || i.clearCurrentDragSourceNode() && i.monitor.isDragging() && i.actions.endDrag();
      }), Ot(this, "handleTopDragStartCapture", function() {
        i.clearCurrentDragSourceNode(), i.dragStartSourceIds = [];
      }), Ot(this, "handleTopDragStart", function(s) {
        if (!s.defaultPrevented) {
          var o = i.dragStartSourceIds;
          i.dragStartSourceIds = null;
          var a = Vw(s);
          i.monitor.isDragging() && i.actions.endDrag(), i.actions.beginDrag(o || [], {
            publishSource: false,
            getSourceClientOffset: i.getSourceClientOffset,
            clientOffset: a
          });
          var l = s.dataTransfer, c = zI(l);
          if (i.monitor.isDragging()) {
            if (l && typeof l.setDragImage == "function") {
              var u = i.monitor.getSourceId(), d = i.sourceNodes.get(u), h = i.sourcePreviewNodes.get(u) || d;
              if (h) {
                var f = i.getCurrentSourcePreviewNodeOptions(), y = f.anchorX, g = f.anchorY, O = f.offsetX, S = f.offsetY, w = {
                  anchorX: y,
                  anchorY: g
                }, x = {
                  offsetX: O,
                  offsetY: S
                }, P = gXe(d, h, a, w, x);
                l.setDragImage(h, P.x, P.y);
              }
            }
            try {
              l == null ? void 0 : l.setData("application/json", {});
            } catch {
            }
            i.setCurrentDragSourceNode(s.target);
            var C = i.getCurrentSourcePreviewNodeOptions(), _ = C.captureDraggingState;
            _ ? i.actions.publishDragSource() : setTimeout(function() {
              return i.actions.publishDragSource();
            }, 0);
          } else if (c)
            i.beginDragNativeItem(c);
          else {
            if (l && !l.types && (s.target && !s.target.hasAttribute || !s.target.hasAttribute("draggable")))
              return;
            s.preventDefault();
          }
        }
      }), Ot(this, "handleTopDragEndCapture", function() {
        i.clearCurrentDragSourceNode() && i.monitor.isDragging() && i.actions.endDrag();
      }), Ot(this, "handleTopDragEnterCapture", function(s) {
        i.dragEnterTargetIds = [];
        var o = i.enterLeaveCounter.enter(s.target);
        if (!(!o || i.monitor.isDragging())) {
          var a = s.dataTransfer, l = zI(a);
          l && i.beginDragNativeItem(l, a);
        }
      }), Ot(this, "handleTopDragEnter", function(s) {
        var o = i.dragEnterTargetIds;
        if (i.dragEnterTargetIds = [], !!i.monitor.isDragging()) {
          i.altKeyPressed = s.altKey, o.length > 0 && i.actions.hover(o, {
            clientOffset: Vw(s)
          });
          var a = o.some(function(l) {
            return i.monitor.canDropOnTarget(l);
          });
          a && (s.preventDefault(), s.dataTransfer && (s.dataTransfer.dropEffect = i.getCurrentDropEffect()));
        }
      }), Ot(this, "handleTopDragOverCapture", function() {
        i.dragOverTargetIds = [];
      }), Ot(this, "handleTopDragOver", function(s) {
        var o = i.dragOverTargetIds;
        if (i.dragOverTargetIds = [], !i.monitor.isDragging()) {
          s.preventDefault(), s.dataTransfer && (s.dataTransfer.dropEffect = "none");
          return;
        }
        i.altKeyPressed = s.altKey, i.lastClientOffset = Vw(s), i.hoverRafId === null && typeof requestAnimationFrame < "u" && (i.hoverRafId = requestAnimationFrame(function() {
          i.monitor.isDragging() && i.actions.hover(o || [], {
            clientOffset: i.lastClientOffset
          }), i.hoverRafId = null;
        }));
        var a = (o || []).some(function(l) {
          return i.monitor.canDropOnTarget(l);
        });
        a ? (s.preventDefault(), s.dataTransfer && (s.dataTransfer.dropEffect = i.getCurrentDropEffect())) : i.isDraggingNativeItem() ? s.preventDefault() : (s.preventDefault(), s.dataTransfer && (s.dataTransfer.dropEffect = "none"));
      }), Ot(this, "handleTopDragLeaveCapture", function(s) {
        i.isDraggingNativeItem() && s.preventDefault();
        var o = i.enterLeaveCounter.leave(s.target);
        o && i.isDraggingNativeItem() && setTimeout(function() {
          return i.endDragNativeItem();
        }, 0);
      }), Ot(this, "handleTopDropCapture", function(s) {
        if (i.dropTargetIds = [], i.isDraggingNativeItem()) {
          var o;
          s.preventDefault(), (o = i.currentNativeSource) === null || o === void 0 || o.loadDataTransfer(s.dataTransfer);
        } else
          zI(s.dataTransfer) && s.preventDefault();
        i.enterLeaveCounter.reset();
      }), Ot(this, "handleTopDrop", function(s) {
        var o = i.dropTargetIds;
        i.dropTargetIds = [], i.actions.hover(o, {
          clientOffset: Vw(s)
        }), i.actions.drop({
          dropEffect: i.getCurrentDropEffect()
        }), i.isDraggingNativeItem() ? i.endDragNativeItem() : i.monitor.isDragging() && i.actions.endDrag();
      }), Ot(this, "handleSelectStart", function(s) {
        var o = s.target;
        typeof o.dragDrop == "function" && (o.tagName === "INPUT" || o.tagName === "SELECT" || o.tagName === "TEXTAREA" || o.isContentEditable || (s.preventDefault(), o.dragDrop()));
      }), this.options = new xXe(n, r), this.actions = e.getActions(), this.monitor = e.getMonitor(), this.registry = e.getRegistry(), this.enterLeaveCounter = new lXe(this.isNodeInDocument);
    }
    return kXe(t, [
      {
        key: "profile",
        value: function() {
          var n, r;
          return {
            sourcePreviewNodes: this.sourcePreviewNodes.size,
            sourcePreviewNodeOptions: this.sourcePreviewNodeOptions.size,
            sourceNodeOptions: this.sourceNodeOptions.size,
            sourceNodes: this.sourceNodes.size,
            dragStartSourceIds: ((n = this.dragStartSourceIds) === null || n === void 0 ? void 0 : n.length) || 0,
            dropTargetIds: this.dropTargetIds.length,
            dragEnterTargetIds: this.dragEnterTargetIds.length,
            dragOverTargetIds: ((r = this.dragOverTargetIds) === null || r === void 0 ? void 0 : r.length) || 0
          };
        }
      },
      {
        key: "window",
        get: function() {
          return this.options.window;
        }
      },
      {
        key: "document",
        get: function() {
          return this.options.document;
        }
      },
      {
        key: "rootElement",
        get: function() {
          return this.options.rootElement;
        }
      },
      {
        key: "setup",
        value: function() {
          var n = this.rootElement;
          if (n !== void 0) {
            if (n.__isReactDndBackendSetUp)
              throw new Error("Cannot have two HTML5 backends at the same time.");
            n.__isReactDndBackendSetUp = true, this.addEventListeners(n);
          }
        }
      },
      {
        key: "teardown",
        value: function() {
          var n = this.rootElement;
          if (n !== void 0 && (n.__isReactDndBackendSetUp = false, this.removeEventListeners(this.rootElement), this.clearCurrentDragSourceNode(), this.asyncEndDragFrameId)) {
            var r;
            (r = this.window) === null || r === void 0 || r.cancelAnimationFrame(this.asyncEndDragFrameId);
          }
        }
      },
      {
        key: "connectDragPreview",
        value: function(n, r, i) {
          var s = this;
          return this.sourcePreviewNodeOptions.set(n, i), this.sourcePreviewNodes.set(n, r), function() {
            s.sourcePreviewNodes.delete(n), s.sourcePreviewNodeOptions.delete(n);
          };
        }
      },
      {
        key: "connectDragSource",
        value: function(n, r, i) {
          var s = this;
          this.sourceNodes.set(n, r), this.sourceNodeOptions.set(n, i);
          var o = function(c) {
            return s.handleDragStart(c, n);
          }, a = function(c) {
            return s.handleSelectStart(c);
          };
          return r.setAttribute("draggable", "true"), r.addEventListener("dragstart", o), r.addEventListener("selectstart", a), function() {
            s.sourceNodes.delete(n), s.sourceNodeOptions.delete(n), r.removeEventListener("dragstart", o), r.removeEventListener("selectstart", a), r.setAttribute("draggable", "false");
          };
        }
      },
      {
        key: "connectDropTarget",
        value: function(n, r) {
          var i = this, s = function(c) {
            return i.handleDragEnter(c, n);
          }, o = function(c) {
            return i.handleDragOver(c, n);
          }, a = function(c) {
            return i.handleDrop(c, n);
          };
          return r.addEventListener("dragenter", s), r.addEventListener("dragover", o), r.addEventListener("drop", a), function() {
            r.removeEventListener("dragenter", s), r.removeEventListener("dragover", o), r.removeEventListener("drop", a);
          };
        }
      },
      {
        key: "addEventListeners",
        value: function(n) {
          n.addEventListener && (n.addEventListener("dragstart", this.handleTopDragStart), n.addEventListener("dragstart", this.handleTopDragStartCapture, true), n.addEventListener("dragend", this.handleTopDragEndCapture, true), n.addEventListener("dragenter", this.handleTopDragEnter), n.addEventListener("dragenter", this.handleTopDragEnterCapture, true), n.addEventListener("dragleave", this.handleTopDragLeaveCapture, true), n.addEventListener("dragover", this.handleTopDragOver), n.addEventListener("dragover", this.handleTopDragOverCapture, true), n.addEventListener("drop", this.handleTopDrop), n.addEventListener("drop", this.handleTopDropCapture, true));
        }
      },
      {
        key: "removeEventListeners",
        value: function(n) {
          n.removeEventListener && (n.removeEventListener("dragstart", this.handleTopDragStart), n.removeEventListener("dragstart", this.handleTopDragStartCapture, true), n.removeEventListener("dragend", this.handleTopDragEndCapture, true), n.removeEventListener("dragenter", this.handleTopDragEnter), n.removeEventListener("dragenter", this.handleTopDragEnterCapture, true), n.removeEventListener("dragleave", this.handleTopDragLeaveCapture, true), n.removeEventListener("dragover", this.handleTopDragOver), n.removeEventListener("dragover", this.handleTopDragOverCapture, true), n.removeEventListener("drop", this.handleTopDrop), n.removeEventListener("drop", this.handleTopDropCapture, true));
        }
      },
      {
        key: "getCurrentSourceNodeOptions",
        value: function() {
          var n = this.monitor.getSourceId(), r = this.sourceNodeOptions.get(n);
          return gB({
            dropEffect: this.altKeyPressed ? "copy" : "move"
          }, r || {});
        }
      },
      {
        key: "getCurrentDropEffect",
        value: function() {
          return this.isDraggingNativeItem() ? "copy" : this.getCurrentSourceNodeOptions().dropEffect;
        }
      },
      {
        key: "getCurrentSourcePreviewNodeOptions",
        value: function() {
          var n = this.monitor.getSourceId(), r = this.sourcePreviewNodeOptions.get(n);
          return gB({
            anchorX: 0.5,
            anchorY: 0.5,
            captureDraggingState: false
          }, r || {});
        }
      },
      {
        key: "isDraggingNativeItem",
        value: function() {
          var n = this.monitor.getItemType();
          return Object.keys(uB).some(function(r) {
            return uB[r] === n;
          });
        }
      },
      {
        key: "beginDragNativeItem",
        value: function(n, r) {
          this.clearCurrentDragSourceNode(), this.currentNativeSource = OXe(n, r), this.currentNativeHandle = this.registry.addSource(n, this.currentNativeSource), this.actions.beginDrag([
            this.currentNativeHandle
          ]);
        }
      },
      {
        key: "setCurrentDragSourceNode",
        value: function(n) {
          var r = this;
          this.clearCurrentDragSourceNode(), this.currentDragSourceNode = n;
          var i = 1e3;
          this.mouseMoveTimeoutTimer = setTimeout(function() {
            var s;
            return (s = r.rootElement) === null || s === void 0 ? void 0 : s.addEventListener("mousemove", r.endDragIfSourceWasRemovedFromDOM, true);
          }, i);
        }
      },
      {
        key: "clearCurrentDragSourceNode",
        value: function() {
          if (this.currentDragSourceNode) {
            if (this.currentDragSourceNode = null, this.rootElement) {
              var n;
              (n = this.window) === null || n === void 0 || n.clearTimeout(this.mouseMoveTimeoutTimer || void 0), this.rootElement.removeEventListener("mousemove", this.endDragIfSourceWasRemovedFromDOM, true);
            }
            return this.mouseMoveTimeoutTimer = null, true;
          }
          return false;
        }
      },
      {
        key: "handleDragStart",
        value: function(n, r) {
          n.defaultPrevented || (this.dragStartSourceIds || (this.dragStartSourceIds = []), this.dragStartSourceIds.unshift(r));
        }
      },
      {
        key: "handleDragEnter",
        value: function(n, r) {
          this.dragEnterTargetIds.unshift(r);
        }
      },
      {
        key: "handleDragOver",
        value: function(n, r) {
          this.dragOverTargetIds === null && (this.dragOverTargetIds = []), this.dragOverTargetIds.unshift(r);
        }
      },
      {
        key: "handleDrop",
        value: function(n, r) {
          this.dropTargetIds.unshift(r);
        }
      }
    ]), t;
  }(), Ww;
  function CXe() {
    return Ww || (Ww = new Image(), Ww.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="), Ww;
  }
  var _Xe = function(e, n, r) {
    return new PXe(e, n, r);
  };
  function TXe(t) {
    const e = fo(), n = e.selectedIds, [r, i, s] = jVe(() => ({
      canDrag: () => t.isDraggable,
      type: "NODE",
      item: () => {
        const o = e.isSelected(t.id) ? Array.from(n) : [
          t.id
        ];
        return e.dispatch(Gg.dragStart(t.id, o)), {
          id: t.id,
          dragIds: o
        };
      },
      end: () => {
        e.hideCursor(), e.dispatch(Gg.dragEnd());
      }
    }), [
      n,
      t
    ]);
    return b.useEffect(() => {
      s(CXe());
    }, [
      s
    ]), i;
  }
  function EXe(t, e) {
    const n = t.getBoundingClientRect(), r = e.x - Math.round(n.x), i = e.y - Math.round(n.y), s = n.height, o = i < s / 2, a = !o, l = s / 4, c = i > l && i < s - l;
    return {
      x: r,
      inTopHalf: o,
      inBottomHalf: a,
      inMiddle: c,
      atTop: !c && o,
      atBottom: !c && a
    };
  }
  function IXe(t, e, n, r) {
    return t ? t.isInternal ? r.atTop ? [
      e,
      t
    ] : r.inMiddle ? [
      t,
      t
    ] : [
      t,
      n
    ] : r.inTopHalf ? [
      e,
      t
    ] : [
      t,
      n
    ] : [
      e,
      null
    ];
  }
  function Zw(t, e) {
    return {
      parentId: t || null,
      index: e
    };
  }
  function Ip(t, e) {
    return {
      type: "line",
      index: t,
      level: e
    };
  }
  function $Xe(t) {
    return {
      type: "highlight",
      id: t
    };
  }
  function BI(t, e) {
    var n;
    let r = t;
    for (; r.parent && r.level > e; )
      r = r.parent;
    const i = ((n = r.parent) === null || n === void 0 ? void 0 : n.id) || null, s = Kne(r) + 1;
    return {
      parentId: i,
      index: s
    };
  }
  function Tre(t) {
    var e;
    const n = EXe(t.element, t.offset), r = t.indent, i = Math.round(Math.max(0, n.x - r) / r), { node: s, nextNode: o, prevNode: a } = t, [l, c] = IXe(s, a, o, n);
    if (s && s.isInternal && n.inMiddle)
      return {
        drop: Zw(s.id, null),
        cursor: $Xe(s.id)
      };
    if (!l)
      return {
        drop: Zw((e = c == null ? void 0 : c.parent) === null || e === void 0 ? void 0 : e.id, 0),
        cursor: Ip(0, 0)
      };
    if (Hne(l)) {
      const u = nb(i, (c == null ? void 0 : c.level) || 0, l.level);
      return {
        drop: BI(l, u),
        cursor: Ip(l.rowIndex + 1, u)
      };
    }
    if (Yne(l)) {
      const u = nb(i, (c == null ? void 0 : c.level) || 0, l.level);
      return {
        drop: BI(l, u),
        cursor: Ip(l.rowIndex + 1, u)
      };
    }
    if (Gne(l)) {
      const u = nb(i, 0, l.level + 1);
      return u > l.level ? {
        drop: Zw(l.id, 0),
        cursor: Ip(l.rowIndex + 1, u)
      } : {
        drop: BI(l, u),
        cursor: Ip(l.rowIndex + 1, u)
      };
    }
    return {
      drop: Zw(l == null ? void 0 : l.id, 0),
      cursor: Ip(l.rowIndex + 1, l.level + 1)
    };
  }
  function AXe(t, e) {
    const n = fo(), [r, i] = Sre(() => ({
      accept: "NODE",
      canDrop: () => n.canDrop(),
      hover: (s, o) => {
        const a = o.getClientOffset();
        if (!t.current || !a)
          return;
        const { cursor: l, drop: c } = Tre({
          element: t.current,
          offset: a,
          indent: n.indent,
          node: e,
          prevNode: e.prev,
          nextNode: e.next
        });
        c && n.dispatch(Gg.hovering(c.parentId, c.index)), o.canDrop() ? l && n.showCursor(l) : n.hideCursor();
      },
      drop: (s, o) => {
        if (!o.canDrop())
          return null;
        let { parentId: a, index: l, dragIds: c } = n.state.dnd;
        rre(n.props.onMove, {
          dragIds: c,
          parentId: a === cO ? null : a,
          index: l === null ? 0 : l,
          dragNodes: n.dragNodes,
          parentNode: n.get(a)
        }), n.open(a);
      }
    }), [
      e,
      t.current,
      n.props
    ]);
    return i;
  }
  function RXe(t) {
    const e = fo(), n = e.at(t);
    if (!n)
      throw new Error(`Could not find node for index: ${t}`);
    return b.useMemo(() => {
      const r = n.clone();
      return e.visibleNodes[t] = r, r;
    }, [
      ...Object.values(n.state),
      n
    ]);
  }
  const MXe = $e.memo(function({ index: e, style: n }) {
    Zne(), O9e();
    const r = fo(), i = RXe(e), s = b.useRef(null), o = TXe(i), a = AXe(s, i), l = b.useCallback((g) => {
      s.current = g, a(g);
    }, [
      a
    ]), c = r.indent * i.level, u = b.useMemo(() => ({
      paddingLeft: c
    }), [
      c
    ]), d = b.useMemo(() => {
      var g, O;
      return Object.assign(Object.assign({}, n), {
        top: parseFloat(n.top) + ((O = (g = r.props.padding) !== null && g !== void 0 ? g : r.props.paddingTop) !== null && O !== void 0 ? O : 0)
      });
    }, [
      n,
      r.props.padding,
      r.props.paddingTop
    ]), h = {
      role: "treeitem",
      "aria-level": i.level + 1,
      "aria-selected": i.isSelected,
      "aria-expanded": i.isOpen,
      style: d,
      tabIndex: -1,
      className: r.props.rowClassName
    };
    b.useEffect(() => {
      var g;
      !i.isEditing && i.isFocused && ((g = s.current) === null || g === void 0 || g.focus({
        preventScroll: true
      }));
    }, [
      i.isEditing,
      i.isFocused,
      s.current
    ]);
    const f = r.renderNode, y = r.renderRow;
    return m.jsx(y, {
      node: i,
      innerRef: l,
      attrs: h,
      children: m.jsx(f, {
        node: i,
        tree: r,
        style: u,
        dragHandle: o
      })
    });
  });
  let UI = "", yB = null;
  function Ere() {
    Zne();
    const t = fo();
    return m.jsx("div", {
      role: "tree",
      style: {
        height: t.height,
        width: t.width,
        minHeight: 0,
        minWidth: 0
      },
      onContextMenu: t.props.onContextMenu,
      onClick: t.props.onClick,
      tabIndex: 0,
      onFocus: (e) => {
        e.currentTarget.contains(e.relatedTarget) || t.onFocus();
      },
      onBlur: (e) => {
        e.currentTarget.contains(e.relatedTarget) || t.onBlur();
      },
      onKeyDown: (e) => {
        var n;
        if (t.isEditing)
          return;
        if (e.key === "Backspace") {
          if (!t.props.onDelete)
            return;
          const i = Array.from(t.selectedIds);
          if (i.length > 1) {
            let s = t.mostRecentNode;
            for (; s && s.isSelected; )
              s = s.nextSibling;
            s || (s = t.lastNode), t.focus(s, {
              scroll: false
            }), t.delete(Array.from(i));
          } else {
            const s = t.focusedNode;
            if (s) {
              const o = s.nextSibling, a = s.parent;
              t.focus(o || a, {
                scroll: false
              }), t.delete(s);
            }
          }
          return;
        }
        if (e.key === "Tab" && !e.shiftKey) {
          e.preventDefault(), Jne(e.currentTarget);
          return;
        }
        if (e.key === "Tab" && e.shiftKey) {
          e.preventDefault(), ere(e.currentTarget);
          return;
        }
        if (e.key === "ArrowDown") {
          e.preventDefault();
          const i = t.nextNode;
          if (e.metaKey) {
            t.select(t.focusedNode), t.activate(t.focusedNode);
            return;
          } else if (!e.shiftKey || t.props.disableMultiSelection) {
            t.focus(i);
            return;
          } else {
            if (!i)
              return;
            const s = t.focusedNode;
            s ? s.isSelected ? t.selectContiguous(i) : t.selectMulti(i) : t.focus(t.firstNode);
            return;
          }
        }
        if (e.key === "ArrowUp") {
          e.preventDefault();
          const i = t.prevNode;
          if (!e.shiftKey || t.props.disableMultiSelection) {
            t.focus(i);
            return;
          } else {
            if (!i)
              return;
            const s = t.focusedNode;
            s ? s.isSelected ? t.selectContiguous(i) : t.selectMulti(i) : t.focus(t.lastNode);
            return;
          }
        }
        if (e.key === "ArrowRight") {
          const i = t.focusedNode;
          if (!i)
            return;
          i.isInternal && i.isOpen ? t.focus(t.nextNode) : i.isInternal && t.open(i.id);
          return;
        }
        if (e.key === "ArrowLeft") {
          const i = t.focusedNode;
          if (!i || i.isRoot)
            return;
          i.isInternal && i.isOpen ? t.close(i.id) : !((n = i.parent) === null || n === void 0) && n.isRoot || t.focus(i.parent);
          return;
        }
        if (e.key === "a" && e.metaKey && !t.props.disableMultiSelection) {
          e.preventDefault(), t.selectAll();
          return;
        }
        if (e.key === "a" && !e.metaKey && t.props.onCreate) {
          t.createLeaf();
          return;
        }
        if (e.key === "A" && !e.metaKey) {
          if (!t.props.onCreate)
            return;
          t.createInternal();
          return;
        }
        if (e.key === "Home") {
          e.preventDefault(), t.focus(t.firstNode);
          return;
        }
        if (e.key === "End") {
          e.preventDefault(), t.focus(t.lastNode);
          return;
        }
        if (e.key === "Enter") {
          const i = t.focusedNode;
          if (!i || !i.isEditable || !t.props.onRename)
            return;
          setTimeout(() => {
            i && t.edit(i);
          });
          return;
        }
        if (e.key === " ") {
          e.preventDefault();
          const i = t.focusedNode;
          if (!i)
            return;
          i.isLeaf ? (i.select(), i.activate()) : i.toggle();
          return;
        }
        if (e.key === "*") {
          const i = t.focusedNode;
          if (!i)
            return;
          t.openSiblings(i);
          return;
        }
        if (e.key === "PageUp") {
          e.preventDefault(), t.pageUp();
          return;
        }
        e.key === "PageDown" && (e.preventDefault(), t.pageDown()), clearTimeout(yB), UI += e.key, yB = setTimeout(() => {
          UI = "";
        }, 600);
        const r = t.visibleNodes.find((i) => {
          const s = i.data.name;
          return typeof s == "string" ? s.toLowerCase().startsWith(UI) : false;
        });
        r && t.focus(r.id);
      },
      children: m.jsx(nBe, {
        className: t.props.className,
        outerRef: t.listEl,
        itemCount: t.visibleNodes.length,
        height: t.height,
        width: t.width,
        itemSize: t.rowHeight,
        overscanCount: t.overscanCount,
        itemKey: (e) => {
          var n;
          return ((n = t.visibleNodes[e]) === null || n === void 0 ? void 0 : n.id) || e;
        },
        outerElementType: sBe,
        innerElementType: lBe,
        onScroll: t.props.onScroll,
        onItemsRendered: t.onItemsRendered.bind(t),
        ref: t.list,
        children: MXe
      })
    });
  }
  function vB(t) {
    return t.isFiltered ? LXe(t.root, t.isMatch.bind(t)) : DXe(t.root);
  }
  function DXe(t) {
    const e = [];
    function n(r) {
      var i;
      r.level >= 0 && e.push(r), r.isOpen && ((i = r.children) === null || i === void 0 || i.forEach(n));
    }
    return n(t), e.forEach(Ire), e;
  }
  function LXe(t, e) {
    const n = {}, r = [];
    function i(o) {
      if (!o.isRoot && e(o)) {
        n[o.id] = true;
        let l = o.parent;
        for (; l; )
          n[l.id] = true, l = l.parent;
      }
      if (o.children)
        for (let l of o.children)
          i(l);
    }
    function s(o) {
      var a;
      o.level >= 0 && n[o.id] && r.push(o), o.isOpen && ((a = o.children) === null || a === void 0 || a.forEach(s));
    }
    return i(t), s(t), r.forEach(Ire), r;
  }
  function Ire(t, e) {
    t.rowIndex = e;
  }
  const OB = (t) => t.reduce((e, n, r) => (e[n.id] = r, e), {});
  var VI = globalThis && globalThis.__awaiter || function(t, e, n, r) {
    function i(s) {
      return s instanceof n ? s : new n(function(o) {
        o(s);
      });
    }
    return new (n || (n = Promise))(function(s, o) {
      function a(u) {
        try {
          c(r.next(u));
        } catch (d) {
          o(d);
        }
      }
      function l(u) {
        try {
          c(r.throw(u));
        } catch (d) {
          o(d);
        }
      }
      function c(u) {
        u.done ? s(u.value) : i(u.value).then(a, l);
      }
      c((r = r.apply(t, e || [])).next());
    });
  };
  const { safeRun: Sr, identify: hc, identifyNull: va } = P9e;
  class rv {
    constructor(e, n, r, i) {
      this.store = e, this.props = n, this.list = r, this.listEl = i, this.visibleStartIndex = 0, this.visibleStopIndex = 0, this.root = m9(this), this.visibleNodes = vB(this), this.idToIndex = OB(this.visibleNodes);
    }
    update(e) {
      this.props = e, this.root = m9(this), this.visibleNodes = vB(this), this.idToIndex = OB(this.visibleNodes);
    }
    dispatch(e) {
      return this.store.dispatch(e);
    }
    get state() {
      return this.store.getState();
    }
    get openState() {
      return this.state.nodes.open.unfiltered;
    }
    get width() {
      var e;
      return (e = this.props.width) !== null && e !== void 0 ? e : 300;
    }
    get height() {
      var e;
      return (e = this.props.height) !== null && e !== void 0 ? e : 500;
    }
    get indent() {
      var e;
      return (e = this.props.indent) !== null && e !== void 0 ? e : 24;
    }
    get rowHeight() {
      var e;
      return (e = this.props.rowHeight) !== null && e !== void 0 ? e : 24;
    }
    get overscanCount() {
      var e;
      return (e = this.props.overscanCount) !== null && e !== void 0 ? e : 1;
    }
    get searchTerm() {
      return (this.props.searchTerm || "").trim();
    }
    get matchFn() {
      var e;
      const n = (e = this.props.searchMatch) !== null && e !== void 0 ? e : (r, i) => JSON.stringify(Object.values(r.data)).toLocaleLowerCase().includes(i.toLocaleLowerCase());
      return (r) => n(r, this.searchTerm);
    }
    accessChildren(e) {
      var n;
      const r = this.props.childrenAccessor || "children";
      return (n = b0(e, r)) !== null && n !== void 0 ? n : null;
    }
    accessId(e) {
      const n = this.props.idAccessor || "id", r = b0(e, n);
      if (!r)
        throw new Error("Data must contain an 'id' property or props.idAccessor must return a string");
      return r;
    }
    get firstNode() {
      var e;
      return (e = this.visibleNodes[0]) !== null && e !== void 0 ? e : null;
    }
    get lastNode() {
      var e;
      return (e = this.visibleNodes[this.visibleNodes.length - 1]) !== null && e !== void 0 ? e : null;
    }
    get focusedNode() {
      var e;
      return (e = this.get(this.state.nodes.focus.id)) !== null && e !== void 0 ? e : null;
    }
    get mostRecentNode() {
      var e;
      return (e = this.get(this.state.nodes.selection.mostRecent)) !== null && e !== void 0 ? e : null;
    }
    get nextNode() {
      const e = this.indexOf(this.focusedNode);
      return e === null ? null : this.at(e + 1);
    }
    get prevNode() {
      const e = this.indexOf(this.focusedNode);
      return e === null ? null : this.at(e - 1);
    }
    get(e) {
      return e && e in this.idToIndex && this.visibleNodes[this.idToIndex[e]] || null;
    }
    at(e) {
      return this.visibleNodes[e] || null;
    }
    nodesBetween(e, n) {
      var r;
      if (e === null || n === null)
        return [];
      const i = (r = this.indexOf(e)) !== null && r !== void 0 ? r : 0, s = this.indexOf(n);
      if (s === null)
        return [];
      const o = Math.min(i, s), a = Math.max(i, s);
      return this.visibleNodes.slice(o, a + 1);
    }
    indexOf(e) {
      const n = nre(e);
      return n ? this.idToIndex[n] : null;
    }
    get editingId() {
      return this.state.nodes.edit.id;
    }
    createInternal() {
      return this.create({
        type: "internal"
      });
    }
    createLeaf() {
      return this.create({
        type: "leaf"
      });
    }
    create() {
      return VI(this, arguments, void 0, function* (e = {}) {
        var n, r;
        const i = e.parentId === void 0 ? ore(this) : e.parentId, s = (n = e.index) !== null && n !== void 0 ? n : sre(this), o = (r = e.type) !== null && r !== void 0 ? r : "leaf", a = yield Sr(this.props.onCreate, {
          type: o,
          parentId: i,
          index: s,
          parentNode: this.get(i)
        });
        a && (this.focus(a), setTimeout(() => {
          this.edit(a).then(() => {
            this.select(a), this.activate(a);
          });
        }));
      });
    }
    delete(e) {
      return VI(this, void 0, void 0, function* () {
        if (!e)
          return;
        const r = (Array.isArray(e) ? e : [
          e
        ]).map(hc), i = r.map((s) => this.get(s)).filter((s) => !!s);
        yield Sr(this.props.onDelete, {
          nodes: i,
          ids: r
        });
      });
    }
    edit(e) {
      const n = hc(e);
      return this.resolveEdit({
        cancelled: true
      }), this.scrollTo(n), this.dispatch($I(n)), new Promise((r) => {
        rv.editPromise = r;
      });
    }
    submit(e, n) {
      return VI(this, void 0, void 0, function* () {
        if (!e)
          return;
        const r = hc(e);
        yield Sr(this.props.onRename, {
          id: r,
          name: n,
          node: this.get(r)
        }), this.dispatch($I(null)), this.resolveEdit({
          cancelled: false,
          value: n
        }), setTimeout(() => this.onFocus());
      });
    }
    reset() {
      this.dispatch($I(null)), this.resolveEdit({
        cancelled: true
      }), setTimeout(() => this.onFocus());
    }
    activate(e) {
      const n = this.get(va(e));
      n && Sr(this.props.onActivate, n);
    }
    resolveEdit(e) {
      const n = rv.editPromise;
      n && n(e), rv.editPromise = null;
    }
    get selectedIds() {
      return this.state.nodes.selection.ids;
    }
    get selectedNodes() {
      let e = [];
      for (let n of Array.from(this.selectedIds)) {
        const r = this.get(n);
        r && e.push(r);
      }
      return e;
    }
    focus(e, n = {}) {
      e && (this.props.selectionFollowsFocus ? this.select(e) : (this.dispatch(Cp(hc(e))), n.scroll !== false && this.scrollTo(e), this.focusedNode && Sr(this.props.onFocus, this.focusedNode)));
    }
    pageUp() {
      var e, n;
      const r = this.visibleStartIndex, s = this.visibleStopIndex - r;
      let o = (n = (e = this.focusedNode) === null || e === void 0 ? void 0 : e.rowIndex) !== null && n !== void 0 ? n : 0;
      o > r ? o = r : o = Math.max(r - s, 0), this.focus(this.at(o));
    }
    pageDown() {
      var e, n;
      const r = this.visibleStartIndex, i = this.visibleStopIndex, s = i - r;
      let o = (n = (e = this.focusedNode) === null || e === void 0 ? void 0 : e.rowIndex) !== null && n !== void 0 ? n : 0;
      o < i ? o = i : o = Math.min(o + s, this.visibleNodes.length - 1), this.focus(this.at(o));
    }
    select(e, n = {}) {
      if (!e)
        return;
      const r = n.focus !== false, i = hc(e);
      r && this.dispatch(Cp(i)), this.dispatch(ya.only(i)), this.dispatch(ya.anchor(i)), this.dispatch(ya.mostRecent(i)), this.scrollTo(i, n.align), this.focusedNode && r && Sr(this.props.onFocus, this.focusedNode), Sr(this.props.onSelect, this.selectedNodes);
    }
    deselect(e) {
      if (!e)
        return;
      const n = hc(e);
      this.dispatch(ya.remove(n)), Sr(this.props.onSelect, this.selectedNodes);
    }
    selectMulti(e) {
      const n = this.get(va(e));
      n && (this.dispatch(Cp(n.id)), this.dispatch(ya.add(n.id)), this.dispatch(ya.anchor(n.id)), this.dispatch(ya.mostRecent(n.id)), this.scrollTo(n), this.focusedNode && Sr(this.props.onFocus, this.focusedNode), Sr(this.props.onSelect, this.selectedNodes));
    }
    selectContiguous(e) {
      if (!e)
        return;
      const n = hc(e), { anchor: r, mostRecent: i } = this.state.nodes.selection;
      this.dispatch(Cp(n)), this.dispatch(ya.remove(this.nodesBetween(r, i))), this.dispatch(ya.add(this.nodesBetween(r, va(n)))), this.dispatch(ya.mostRecent(n)), this.scrollTo(n), this.focusedNode && Sr(this.props.onFocus, this.focusedNode), Sr(this.props.onSelect, this.selectedNodes);
    }
    deselectAll() {
      this.setSelection({
        ids: [],
        anchor: null,
        mostRecent: null
      }), Sr(this.props.onSelect, this.selectedNodes);
    }
    selectAll() {
      var e;
      this.setSelection({
        ids: Object.keys(this.idToIndex),
        anchor: this.firstNode,
        mostRecent: this.lastNode
      }), this.dispatch(Cp((e = this.lastNode) === null || e === void 0 ? void 0 : e.id)), this.focusedNode && Sr(this.props.onFocus, this.focusedNode), Sr(this.props.onSelect, this.selectedNodes);
    }
    setSelection(e) {
      var n;
      const r = new Set((n = e.ids) === null || n === void 0 ? void 0 : n.map(hc)), i = va(e.anchor), s = va(e.mostRecent);
      this.dispatch(ya.set({
        ids: r,
        anchor: i,
        mostRecent: s
      })), Sr(this.props.onSelect, this.selectedNodes);
    }
    get cursorParentId() {
      const { cursor: e } = this.state.dnd;
      switch (e.type) {
        case "highlight":
          return e.id;
        default:
          return null;
      }
    }
    get cursorOverFolder() {
      return this.state.dnd.cursor.type === "highlight";
    }
    get dragNodes() {
      return this.state.dnd.dragIds.map((e) => this.get(e)).filter((e) => !!e);
    }
    get dragNode() {
      return this.get(this.state.nodes.drag.id);
    }
    get dragDestinationParent() {
      return this.get(this.state.nodes.drag.destinationParentId);
    }
    get dragDestinationIndex() {
      return this.state.nodes.drag.destinationIndex;
    }
    canDrop() {
      var e;
      if (this.isFiltered)
        return false;
      const n = (e = this.get(this.state.dnd.parentId)) !== null && e !== void 0 ? e : this.root, r = this.dragNodes, i = this.props.disableDrop;
      for (const s of r)
        if (!s || !n || s.isInternal && qne(n, s))
          return false;
      return typeof i == "function" ? !i({
        parentNode: n,
        dragNodes: this.dragNodes,
        index: this.state.dnd.index || 0
      }) : typeof i == "string" ? !n.data[i] : typeof i == "boolean" ? !i : true;
    }
    hideCursor() {
      this.dispatch(Gg.cursor({
        type: "none"
      }));
    }
    showCursor(e) {
      this.dispatch(Gg.cursor(e));
    }
    open(e) {
      const n = va(e);
      n && (this.isOpen(n) || (this.dispatch(JR.open(n, this.isFiltered)), Sr(this.props.onToggle, n)));
    }
    close(e) {
      const n = va(e);
      n && this.isOpen(n) && (this.dispatch(JR.close(n, this.isFiltered)), Sr(this.props.onToggle, n));
    }
    toggle(e) {
      const n = va(e);
      if (n)
        return this.isOpen(n) ? this.close(n) : this.open(n);
    }
    openParents(e) {
      const n = va(e);
      if (!n)
        return;
      const r = nj(this.root, n);
      let i = r == null ? void 0 : r.parent;
      for (; i; )
        this.open(i.id), i = i.parent;
    }
    openSiblings(e) {
      const n = e.parent;
      if (!n)
        this.toggle(e.id);
      else if (n.children) {
        const r = e.isOpen;
        for (let i of n.children)
          i.isInternal && (r ? this.close(i.id) : this.open(i.id));
        this.scrollTo(this.focusedNode);
      }
    }
    openAll() {
      tP(this.root, (e) => {
        e.isInternal && e.open();
      });
    }
    closeAll() {
      tP(this.root, (e) => {
        e.isInternal && e.close();
      });
    }
    scrollTo(e, n = "smart") {
      if (!e)
        return;
      const r = hc(e);
      return this.openParents(r), ire(() => r in this.idToIndex).then(() => {
        var i;
        const s = this.idToIndex[r];
        s !== void 0 && ((i = this.list.current) === null || i === void 0 || i.scrollToItem(s, n));
      }).catch(() => {
      });
    }
    get isEditing() {
      return this.state.nodes.edit.id !== null;
    }
    get isFiltered() {
      var e;
      return !!(!((e = this.props.searchTerm) === null || e === void 0) && e.trim());
    }
    get hasFocus() {
      return this.state.nodes.focus.treeFocused;
    }
    get hasNoSelection() {
      return this.state.nodes.selection.ids.size === 0;
    }
    get hasOneSelection() {
      return this.state.nodes.selection.ids.size === 1;
    }
    get hasMultipleSelections() {
      return this.state.nodes.selection.ids.size > 1;
    }
    isSelected(e) {
      return e ? this.state.nodes.selection.ids.has(e) : false;
    }
    isOpen(e) {
      var n, r, i;
      if (!e)
        return false;
      if (e === cO)
        return true;
      const s = (n = this.props.openByDefault) !== null && n !== void 0 ? n : true;
      return this.isFiltered ? (r = this.state.nodes.open.filtered[e]) !== null && r !== void 0 ? r : true : (i = this.state.nodes.open.unfiltered[e]) !== null && i !== void 0 ? i : s;
    }
    isEditable(e) {
      const n = this.props.disableEdit || (() => false);
      return !b0(e, n);
    }
    isDraggable(e) {
      const n = this.props.disableDrag || (() => false);
      return !b0(e, n);
    }
    isDragging(e) {
      const n = va(e);
      return n ? this.state.nodes.drag.id === n : false;
    }
    isFocused(e) {
      return this.hasFocus && this.state.nodes.focus.id === e;
    }
    isMatch(e) {
      return this.matchFn(e);
    }
    willReceiveDrop(e) {
      const n = va(e);
      if (!n)
        return false;
      const { destinationParentId: r, destinationIndex: i } = this.state.nodes.drag;
      return n === r && i === null;
    }
    onFocus() {
      const e = this.focusedNode || this.firstNode;
      e && this.dispatch(Cp(e.id));
    }
    onBlur() {
      this.dispatch(D9e());
    }
    onItemsRendered(e) {
      this.visibleStartIndex = e.visibleStartIndex, this.visibleStopIndex = e.visibleStopIndex;
    }
    get renderContainer() {
      return this.props.renderContainer || Ere;
    }
    get renderRow() {
      return this.props.renderRow || I9e;
    }
    get renderNode() {
      return this.props.children || $9e;
    }
    get renderDragPreview() {
      return this.props.renderDragPreview || are;
    }
    get renderCursor() {
      return this.props.renderCursor || E9e;
    }
  }
  function oi(t) {
    return `Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `;
  }
  var jXe = (() => typeof Symbol == "function" && Symbol.observable || "@@observable")(), SB = jXe, XI = () => Math.random().toString(36).substring(7).split("").join("."), NXe = {
    INIT: `@@redux/INIT${XI()}`,
    REPLACE: `@@redux/REPLACE${XI()}`,
    PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${XI()}`
  }, iP = NXe;
  function QXe(t) {
    if (typeof t != "object" || t === null)
      return false;
    let e = t;
    for (; Object.getPrototypeOf(e) !== null; )
      e = Object.getPrototypeOf(e);
    return Object.getPrototypeOf(t) === e || Object.getPrototypeOf(t) === null;
  }
  function $re(t, e, n) {
    if (typeof t != "function")
      throw new Error(oi(2));
    if (typeof e == "function" && typeof n == "function" || typeof n == "function" && typeof arguments[3] == "function")
      throw new Error(oi(0));
    if (typeof e == "function" && typeof n > "u" && (n = e, e = void 0), typeof n < "u") {
      if (typeof n != "function")
        throw new Error(oi(1));
      return n($re)(t, e);
    }
    let r = t, i = e, s = /* @__PURE__ */ new Map(), o = s, a = 0, l = false;
    function c() {
      o === s && (o = /* @__PURE__ */ new Map(), s.forEach((O, S) => {
        o.set(S, O);
      }));
    }
    function u() {
      if (l)
        throw new Error(oi(3));
      return i;
    }
    function d(O) {
      if (typeof O != "function")
        throw new Error(oi(4));
      if (l)
        throw new Error(oi(5));
      let S = true;
      c();
      const w = a++;
      return o.set(w, O), function() {
        if (S) {
          if (l)
            throw new Error(oi(6));
          S = false, c(), o.delete(w), s = null;
        }
      };
    }
    function h(O) {
      if (!QXe(O))
        throw new Error(oi(7));
      if (typeof O.type > "u")
        throw new Error(oi(8));
      if (typeof O.type != "string")
        throw new Error(oi(17));
      if (l)
        throw new Error(oi(9));
      try {
        l = true, i = r(i, O);
      } finally {
        l = false;
      }
      return (s = o).forEach((w) => {
        w();
      }), O;
    }
    function f(O) {
      if (typeof O != "function")
        throw new Error(oi(10));
      r = O, h({
        type: iP.REPLACE
      });
    }
    function y() {
      const O = d;
      return {
        subscribe(S) {
          if (typeof S != "object" || S === null)
            throw new Error(oi(11));
          function w() {
            const P = S;
            P.next && P.next(u());
          }
          return w(), {
            unsubscribe: O(w)
          };
        },
        [SB]() {
          return this;
        }
      };
    }
    return h({
      type: iP.INIT
    }), {
      dispatch: h,
      subscribe: d,
      getState: u,
      replaceReducer: f,
      [SB]: y
    };
  }
  function zXe(t) {
    Object.keys(t).forEach((e) => {
      const n = t[e];
      if (typeof n(void 0, {
        type: iP.INIT
      }) > "u")
        throw new Error(oi(12));
      if (typeof n(void 0, {
        type: iP.PROBE_UNKNOWN_ACTION()
      }) > "u")
        throw new Error(oi(13));
    });
  }
  function wB(t) {
    const e = Object.keys(t), n = {};
    for (let s = 0; s < e.length; s++) {
      const o = e[s];
      typeof t[o] == "function" && (n[o] = t[o]);
    }
    const r = Object.keys(n);
    let i;
    try {
      zXe(n);
    } catch (s) {
      i = s;
    }
    return function(o = {}, a) {
      if (i)
        throw i;
      let l = false;
      const c = {};
      for (let u = 0; u < r.length; u++) {
        const d = r[u], h = n[d], f = o[d], y = h(f, a);
        if (typeof y > "u")
          throw a && a.type, new Error(oi(14));
        c[d] = y, l = l || y !== f;
      }
      return l = l || r.length !== Object.keys(o).length, l ? c : o;
    };
  }
  function FXe(t = Yg().nodes.drag, e) {
    switch (e.type) {
      case "DND_DRAG_START":
        return Object.assign(Object.assign({}, t), {
          id: e.id,
          selectedIds: e.dragIds
        });
      case "DND_DRAG_END":
        return Object.assign(Object.assign({}, t), {
          id: null,
          destinationParentId: null,
          destinationIndex: null,
          selectedIds: []
        });
      case "DND_HOVERING":
        return e.parentId !== t.destinationParentId || e.index != t.destinationIndex ? Object.assign(Object.assign({}, t), {
          destinationParentId: e.parentId,
          destinationIndex: e.index
        }) : t;
      default:
        return t;
    }
  }
  const BXe = wB({
    nodes: wB({
      focus: L9e,
      edit: M9e,
      open: j9e,
      selection: N9e,
      drag: FXe
    }),
    dnd: Q9e
  }), UXe = Yg();
  function VXe({ treeProps: t, imperativeHandle: e, children: n }) {
    const r = b.useRef(null), i = b.useRef(null), s = b.useRef($re(BXe, Yg(t))), o = p2.useSyncExternalStore(s.current.subscribe, s.current.getState, () => UXe), a = b.useMemo(() => new rv(s.current, t, r, i), []), l = b.useRef(0);
    return b.useMemo(() => {
      l.current += 1, a.update(t);
    }, [
      ...Object.values(t),
      o.nodes.open
    ]), b.useImperativeHandle(e, () => a), b.useEffect(() => {
      a.props.selection ? a.select(a.props.selection, {
        focus: false
      }) : a.deselectAll();
    }, [
      a.props.selection
    ]), b.useEffect(() => {
      a.props.searchTerm || s.current.dispatch(JR.clear(true));
    }, [
      a.props.searchTerm
    ]), m.jsx(Une.Provider, {
      value: a,
      children: m.jsx(Wne.Provider, {
        value: l.current,
        children: m.jsx(Vne.Provider, {
          value: o.nodes,
          children: m.jsx(Xne.Provider, {
            value: o.dnd,
            children: m.jsx(NUe, Object.assign({
              backend: _Xe,
              options: {
                rootElement: a.props.dndRootElement || void 0
              }
            }, t.dndManager && {
              manager: t.dndManager
            }, {
              children: n
            }))
          })
        })
      })
    });
  }
  function XXe() {
    const t = fo(), [, e] = Sre(() => ({
      accept: "NODE",
      canDrop: (n, r) => r.isOver({
        shallow: true
      }) ? t.canDrop() : false,
      hover: (n, r) => {
        if (!r.isOver({
          shallow: true
        }))
          return;
        const i = r.getClientOffset();
        if (!t.listEl.current || !i)
          return;
        const { cursor: s, drop: o } = Tre({
          element: t.listEl.current,
          offset: i,
          indent: t.indent,
          node: null,
          prevNode: t.visibleNodes[t.visibleNodes.length - 1],
          nextNode: null
        });
        o && t.dispatch(Gg.hovering(o.parentId, o.index)), r.canDrop() ? s && t.showCursor(s) : t.hideCursor();
      }
    }), [
      t
    ]);
    e(t.listEl);
  }
  function WXe(t) {
    return XXe(), t.children;
  }
  function ZXe() {
    const e = fo().props.renderContainer || Ere;
    return m.jsx(m.Fragment, {
      children: m.jsx(e, {})
    });
  }
  function HXe() {
    const t = fo(), { offset: e, mouse: n, item: r, isDragging: i } = rXe((o) => ({
      offset: o.getSourceClientOffset(),
      mouse: o.getClientOffset(),
      item: o.getItem(),
      isDragging: o.isDragging()
    })), s = t.props.renderDragPreview || are;
    return m.jsx(s, {
      offset: e,
      mouse: n,
      id: (r == null ? void 0 : r.id) || null,
      dragIds: (r == null ? void 0 : r.dragIds) || [],
      isDragging: i
    });
  }
  class YXe {
    constructor(e) {
      this.root = GXe(e);
    }
    get data() {
      var e, n;
      return (n = (e = this.root.children) === null || e === void 0 ? void 0 : e.map((r) => r.data)) !== null && n !== void 0 ? n : [];
    }
    create(e) {
      const n = e.parentId ? this.find(e.parentId) : this.root;
      if (!n)
        return null;
      n.addChild(e.data, e.index);
    }
    move(e) {
      const n = this.find(e.id), r = e.parentId ? this.find(e.parentId) : this.root;
      !n || !r || (r.addChild(n.data, e.index), n.drop());
    }
    update(e) {
      const n = this.find(e.id);
      n && n.update(e.changes);
    }
    drop(e) {
      const n = this.find(e.id);
      n && n.drop();
    }
    find(e, n = this.root) {
      if (!n)
        return null;
      if (n.id === e)
        return n;
      if (n.children) {
        for (let r of n.children) {
          const i = this.find(e, r);
          if (i)
            return i;
        }
        return null;
      }
      return null;
    }
  }
  function GXe(t) {
    const e = new Are({
      id: "ROOT"
    }, null);
    return e.children = t.map((n) => cj(n, e)), e;
  }
  function cj(t, e) {
    const n = new Are(t, e);
    return t.children && (n.children = t.children.map((r) => cj(r, n))), n;
  }
  class Are {
    constructor(e, n) {
      this.data = e, this.parent = n, this.id = e.id;
    }
    hasParent() {
      return !!this.parent;
    }
    get childIndex() {
      return this.hasParent() ? this.parent.children.indexOf(this) : -1;
    }
    addChild(e, n) {
      var r, i;
      const s = cj(e, this);
      this.children = (r = this.children) !== null && r !== void 0 ? r : [], this.children.splice(n, 0, s), this.data.children = (i = this.data.children) !== null && i !== void 0 ? i : [], this.data.children.splice(n, 0, e);
    }
    removeChild(e) {
      var n, r;
      (n = this.children) === null || n === void 0 || n.splice(e, 1), (r = this.data.children) === null || r === void 0 || r.splice(e, 1);
    }
    update(e) {
      if (this.hasParent()) {
        const n = this.childIndex;
        this.parent.addChild(Object.assign(Object.assign({}, this.data), e), n), this.drop();
      }
    }
    drop() {
      this.hasParent() && this.parent.removeChild(this.childIndex);
    }
  }
  let qXe = 0;
  function KXe(t) {
    const [e, n] = b.useState(t), r = b.useMemo(() => new YXe(e), [
      e
    ]);
    return [
      e,
      {
        onMove: (c) => {
          for (const u of c.dragIds)
            r.move({
              id: u,
              parentId: c.parentId,
              index: c.index
            });
          n(r.data);
        },
        onRename: ({ name: c, id: u }) => {
          r.update({
            id: u,
            changes: {
              name: c
            }
          }), n(r.data);
        },
        onCreate: ({ parentId: c, index: u, type: d }) => {
          const h = {
            id: `simple-tree-id-${qXe++}`,
            name: ""
          };
          return d === "internal" && (h.children = []), r.create({
            parentId: c,
            index: u,
            data: h
          }), n(r.data), h;
        },
        onDelete: (c) => {
          c.ids.forEach((u) => r.drop({
            id: u
          })), n(r.data);
        }
      }
    ];
  }
  function JXe(t) {
    if (t.initialData && t.data)
      throw new Error("React Arborist Tree => Provide either a data or initialData prop, but not both.");
    if (t.initialData && (t.onCreate || t.onDelete || t.onMove || t.onRename))
      throw new Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
Use the data prop if you want to provide your own handlers.`);
    if (t.initialData) {
      const [e, n] = KXe(t.initialData);
      return Object.assign(Object.assign(Object.assign({}, t), n), {
        data: e
      });
    } else
      return t;
  }
  function eWe(t, e) {
    const n = JXe(t);
    return m.jsxs(VXe, {
      treeProps: n,
      imperativeHandle: e,
      children: [
        m.jsx(WXe, {
          children: m.jsx(ZXe, {})
        }),
        m.jsx(HXe, {})
      ]
    });
  }
  const tWe = b.forwardRef(eWe);
  function nWe(t, e) {
    var n = b.useRef(null), r = b.useRef(null);
    r.current = e;
    var i = b.useRef(null);
    b.useEffect(function() {
      s();
    });
    var s = b.useCallback(function() {
      var o = i.current, a = r.current, l = o || (a ? a instanceof Element ? a : a.current : null);
      n.current && n.current.element === l && n.current.subscriber === t || (n.current && n.current.cleanup && n.current.cleanup(), n.current = {
        element: l,
        subscriber: t,
        cleanup: l ? t(l) : void 0
      });
    }, [
      t
    ]);
    return b.useEffect(function() {
      return function() {
        n.current && n.current.cleanup && (n.current.cleanup(), n.current = null);
      };
    }, []), b.useCallback(function(o) {
      i.current = o, s();
    }, [
      s
    ]);
  }
  function xB(t, e, n) {
    return t[e] ? t[e][0] ? t[e][0][n] : t[e][n] : e === "contentBoxSize" ? t.contentRect[n === "inlineSize" ? "width" : "height"] : void 0;
  }
  function rWe(t) {
    t === void 0 && (t = {});
    var e = t.onResize, n = b.useRef(void 0);
    n.current = e;
    var r = t.round || Math.round, i = b.useRef(), s = b.useState({
      width: void 0,
      height: void 0
    }), o = s[0], a = s[1], l = b.useRef(false);
    b.useEffect(function() {
      return l.current = false, function() {
        l.current = true;
      };
    }, []);
    var c = b.useRef({
      width: void 0,
      height: void 0
    }), u = nWe(b.useCallback(function(d) {
      return (!i.current || i.current.box !== t.box || i.current.round !== r) && (i.current = {
        box: t.box,
        round: r,
        instance: new ResizeObserver(function(h) {
          var f = h[0], y = t.box === "border-box" ? "borderBoxSize" : t.box === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize", g = xB(f, y, "inlineSize"), O = xB(f, y, "blockSize"), S = g ? r(g) : void 0, w = O ? r(O) : void 0;
          if (c.current.width !== S || c.current.height !== w) {
            var x = {
              width: S,
              height: w
            };
            c.current.width = S, c.current.height = w, n.current ? n.current(x) : l.current || a(x);
          }
        })
      }), i.current.instance.observe(d, {
        box: t.box
      }), function() {
        i.current && i.current.instance.unobserve(d);
      };
    }, [
      t.box,
      r
    ]), t.ref);
    return b.useMemo(function() {
      return {
        ref: u,
        width: o.width,
        height: o.height
      };
    }, [
      u,
      o.width,
      o.height
    ]);
  }
  function iWe(...t) {
    return (e) => {
      t.forEach((n) => {
        typeof n == "function" ? n(e) : n != null && (n.current = e);
      });
    };
  }
  const sWe = {
    flex: 1,
    width: "100%",
    height: "100%",
    minHeight: 0,
    minWidth: 0
  }, oWe = $e.forwardRef(function(e, n) {
    const { ref: r, width: i, height: s } = rWe();
    return m.jsx("div", {
      style: sWe,
      ref: iWe(r, n),
      children: i && s ? e.children({
        width: i,
        height: s
      }) : null
    });
  }), aWe = NY, WI = zwe, lWe = QY, Rre = b.forwardRef(({ className: t, ...e }, n) => m.jsx(r5, {
    ref: n,
    className: on("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", t),
    ...e
  }));
  Rre.displayName = r5.displayName;
  const Mre = b.forwardRef(({ className: t, children: e, ...n }, r) => m.jsxs(lWe, {
    children: [
      m.jsx(Rre, {}),
      m.jsxs(i5, {
        ref: r,
        className: on("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full", t),
        ...n,
        children: [
          e,
          m.jsxs(Fwe, {
            className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
            children: [
              m.jsx(H7e, {
                className: "h-4 w-4"
              }),
              m.jsx("span", {
                className: "sr-only",
                children: "Close"
              })
            ]
          })
        ]
      })
    ]
  }));
  Mre.displayName = i5.displayName;
  const Dre = ({ className: t, ...e }) => m.jsx("div", {
    className: on("flex flex-col space-y-1.5 text-center sm:text-left", t),
    ...e
  });
  Dre.displayName = "DialogHeader";
  const Lre = ({ className: t, ...e }) => m.jsx("div", {
    className: on("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", t),
    ...e
  });
  Lre.displayName = "DialogFooter";
  const cWe = b.forwardRef(({ className: t, ...e }, n) => m.jsx(zY, {
    ref: n,
    className: on("text-lg font-semibold leading-none tracking-tight", t),
    ...e
  }));
  cWe.displayName = zY.displayName;
  const uWe = b.forwardRef(({ className: t, ...e }, n) => m.jsx(FY, {
    ref: n,
    className: on("text-sm text-muted-foreground", t),
    ...e
  }));
  uWe.displayName = FY.displayName;
  const Lu = b.forwardRef(({ className: t, type: e, ...n }, r) => m.jsx("input", {
    type: e,
    className: on("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", t),
    ref: r,
    ...n
  }));
  Lu.displayName = "Input";
  var S2 = "Tabs", [dWe, sat] = Ps(S2, [
    KC
  ]), jre = KC(), [hWe, uj] = dWe(S2), Nre = b.forwardRef((t, e) => {
    const { __scopeTabs: n, value: r, onValueChange: i, defaultValue: s, orientation: o = "horizontal", dir: a, activationMode: l = "automatic", ...c } = t, u = XC(a), [d, h] = Wl({
      prop: r,
      onChange: i,
      defaultProp: s ?? "",
      caller: S2
    });
    return m.jsx(hWe, {
      scope: n,
      baseId: ja(),
      value: d,
      onValueChange: h,
      orientation: o,
      dir: u,
      activationMode: l,
      children: m.jsx(rt.div, {
        dir: u,
        "data-orientation": o,
        ...c,
        ref: e
      })
    });
  });
  Nre.displayName = S2;
  var Qre = "TabsList", zre = b.forwardRef((t, e) => {
    const { __scopeTabs: n, loop: r = true, ...i } = t, s = uj(Qre, n), o = jre(n);
    return m.jsx(ZK, {
      asChild: true,
      ...o,
      orientation: s.orientation,
      dir: s.dir,
      loop: r,
      children: m.jsx(rt.div, {
        role: "tablist",
        "aria-orientation": s.orientation,
        ...i,
        ref: e
      })
    });
  });
  zre.displayName = Qre;
  var Fre = "TabsTrigger", Bre = b.forwardRef((t, e) => {
    const { __scopeTabs: n, value: r, disabled: i = false, ...s } = t, o = uj(Fre, n), a = jre(n), l = Xre(o.baseId, r), c = Wre(o.baseId, r), u = r === o.value;
    return m.jsx(HK, {
      asChild: true,
      ...a,
      focusable: !i,
      active: u,
      children: m.jsx(rt.button, {
        type: "button",
        role: "tab",
        "aria-selected": u,
        "aria-controls": c,
        "data-state": u ? "active" : "inactive",
        "data-disabled": i ? "" : void 0,
        disabled: i,
        id: l,
        ...s,
        ref: e,
        onMouseDown: Pe(t.onMouseDown, (d) => {
          !i && d.button === 0 && d.ctrlKey === false ? o.onValueChange(r) : d.preventDefault();
        }),
        onKeyDown: Pe(t.onKeyDown, (d) => {
          [
            " ",
            "Enter"
          ].includes(d.key) && o.onValueChange(r);
        }),
        onFocus: Pe(t.onFocus, () => {
          const d = o.activationMode !== "manual";
          !u && !i && d && o.onValueChange(r);
        })
      })
    });
  });
  Bre.displayName = Fre;
  var Ure = "TabsContent", Vre = b.forwardRef((t, e) => {
    const { __scopeTabs: n, value: r, forceMount: i, children: s, ...o } = t, a = uj(Ure, n), l = Xre(a.baseId, r), c = Wre(a.baseId, r), u = r === a.value, d = b.useRef(u);
    return b.useEffect(() => {
      const h = requestAnimationFrame(() => d.current = false);
      return () => cancelAnimationFrame(h);
    }, []), m.jsx(uo, {
      present: i || u,
      children: ({ present: h }) => m.jsx(rt.div, {
        "data-state": u ? "active" : "inactive",
        "data-orientation": a.orientation,
        role: "tabpanel",
        "aria-labelledby": l,
        hidden: !h,
        id: c,
        tabIndex: 0,
        ...o,
        ref: e,
        style: {
          ...t.style,
          animationDuration: d.current ? "0s" : void 0
        },
        children: h && s
      })
    });
  });
  Vre.displayName = Ure;
  function Xre(t, e) {
    return `${t}-trigger-${e}`;
  }
  function Wre(t, e) {
    return `${t}-content-${e}`;
  }
  var fWe = Nre, Zre = zre, Hre = Bre, Yre = Vre;
  const pWe = fWe, Gre = b.forwardRef(({ className: t, ...e }, n) => m.jsx(Zre, {
    ref: n,
    className: on("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground", t),
    ...e
  }));
  Gre.displayName = Zre.displayName;
  const aM = b.forwardRef(({ className: t, ...e }, n) => m.jsx(Hre, {
    ref: n,
    className: on("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm", t),
    ...e
  }));
  aM.displayName = Hre.displayName;
  const lM = b.forwardRef(({ className: t, ...e }, n) => m.jsx(Yre, {
    ref: n,
    className: on("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", t),
    ...e
  }));
  lM.displayName = Yre.displayName;
  var gWe = "Label", qre = b.forwardRef((t, e) => m.jsx(rt.label, {
    ...t,
    ref: e,
    onMouseDown: (n) => {
      var _a3;
      n.target.closest("button, input, select, textarea") || ((_a3 = t.onMouseDown) == null ? void 0 : _a3.call(t, n), !n.defaultPrevented && n.detail > 1 && n.preventDefault());
    }
  }));
  qre.displayName = gWe;
  var Kre = qre;
  const mWe = X3("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"), wh = b.forwardRef(({ className: t, ...e }, n) => m.jsx(Kre, {
    ref: n,
    className: on(mWe(), t),
    ...e
  }));
  wh.displayName = Kre.displayName;
  var [w2, oat] = Ps("Tooltip", [
    Rm
  ]), x2 = Rm(), Jre = "TooltipProvider", yWe = 700, cM = "tooltip.open", [vWe, dj] = w2(Jre), eie = (t) => {
    const { __scopeTooltip: e, delayDuration: n = yWe, skipDelayDuration: r = 300, disableHoverableContent: i = false, children: s } = t, o = b.useRef(true), a = b.useRef(false), l = b.useRef(0);
    return b.useEffect(() => {
      const c = l.current;
      return () => window.clearTimeout(c);
    }, []), m.jsx(vWe, {
      scope: e,
      isOpenDelayedRef: o,
      delayDuration: n,
      onOpen: b.useCallback(() => {
        window.clearTimeout(l.current), o.current = false;
      }, []),
      onClose: b.useCallback(() => {
        window.clearTimeout(l.current), l.current = window.setTimeout(() => o.current = true, r);
      }, [
        r
      ]),
      isPointerInTransitRef: a,
      onPointerInTransitChange: b.useCallback((c) => {
        a.current = c;
      }, []),
      disableHoverableContent: i,
      children: s
    });
  };
  eie.displayName = Jre;
  var uO = "Tooltip", [OWe, b2] = w2(uO), tie = (t) => {
    const { __scopeTooltip: e, children: n, open: r, defaultOpen: i, onOpenChange: s, disableHoverableContent: o, delayDuration: a } = t, l = dj(uO, t.__scopeTooltip), c = x2(e), [u, d] = b.useState(null), h = ja(), f = b.useRef(0), y = o ?? l.disableHoverableContent, g = a ?? l.delayDuration, O = b.useRef(false), [S, w] = Wl({
      prop: r,
      defaultProp: i ?? false,
      onChange: (T) => {
        T ? (l.onOpen(), document.dispatchEvent(new CustomEvent(cM))) : l.onClose(), s == null ? void 0 : s(T);
      },
      caller: uO
    }), x = b.useMemo(() => S ? O.current ? "delayed-open" : "instant-open" : "closed", [
      S
    ]), P = b.useCallback(() => {
      window.clearTimeout(f.current), f.current = 0, O.current = false, w(true);
    }, [
      w
    ]), C = b.useCallback(() => {
      window.clearTimeout(f.current), f.current = 0, w(false);
    }, [
      w
    ]), _ = b.useCallback(() => {
      window.clearTimeout(f.current), f.current = window.setTimeout(() => {
        O.current = true, w(true), f.current = 0;
      }, g);
    }, [
      g,
      w
    ]);
    return b.useEffect(() => () => {
      f.current && (window.clearTimeout(f.current), f.current = 0);
    }, []), m.jsx(GC, {
      ...c,
      children: m.jsx(OWe, {
        scope: e,
        contentId: h,
        open: S,
        stateAttribute: x,
        trigger: u,
        onTriggerChange: d,
        onTriggerEnter: b.useCallback(() => {
          l.isOpenDelayedRef.current ? _() : P();
        }, [
          l.isOpenDelayedRef,
          _,
          P
        ]),
        onTriggerLeave: b.useCallback(() => {
          y ? C() : (window.clearTimeout(f.current), f.current = 0);
        }, [
          C,
          y
        ]),
        onOpen: P,
        onClose: C,
        disableHoverableContent: y,
        children: n
      })
    });
  };
  tie.displayName = uO;
  var uM = "TooltipTrigger", nie = b.forwardRef((t, e) => {
    const { __scopeTooltip: n, ...r } = t, i = b2(uM, n), s = dj(uM, n), o = x2(n), a = b.useRef(null), l = Ht(e, a, i.onTriggerChange), c = b.useRef(false), u = b.useRef(false), d = b.useCallback(() => c.current = false, []);
    return b.useEffect(() => () => document.removeEventListener("pointerup", d), [
      d
    ]), m.jsx(qC, {
      asChild: true,
      ...o,
      children: m.jsx(rt.button, {
        "aria-describedby": i.open ? i.contentId : void 0,
        "data-state": i.stateAttribute,
        ...r,
        ref: l,
        onPointerMove: Pe(t.onPointerMove, (h) => {
          h.pointerType !== "touch" && !u.current && !s.isPointerInTransitRef.current && (i.onTriggerEnter(), u.current = true);
        }),
        onPointerLeave: Pe(t.onPointerLeave, () => {
          i.onTriggerLeave(), u.current = false;
        }),
        onPointerDown: Pe(t.onPointerDown, () => {
          i.open && i.onClose(), c.current = true, document.addEventListener("pointerup", d, {
            once: true
          });
        }),
        onFocus: Pe(t.onFocus, () => {
          c.current || i.onOpen();
        }),
        onBlur: Pe(t.onBlur, i.onClose),
        onClick: Pe(t.onClick, i.onClose)
      })
    });
  });
  nie.displayName = uM;
  var SWe = "TooltipPortal", [aat, wWe] = w2(SWe, {
    forceMount: void 0
  }), qg = "TooltipContent", rie = b.forwardRef((t, e) => {
    const n = wWe(qg, t.__scopeTooltip), { forceMount: r = n.forceMount, side: i = "top", ...s } = t, o = b2(qg, t.__scopeTooltip);
    return m.jsx(uo, {
      present: r || o.open,
      children: o.disableHoverableContent ? m.jsx(iie, {
        side: i,
        ...s,
        ref: e
      }) : m.jsx(xWe, {
        side: i,
        ...s,
        ref: e
      })
    });
  }), xWe = b.forwardRef((t, e) => {
    const n = b2(qg, t.__scopeTooltip), r = dj(qg, t.__scopeTooltip), i = b.useRef(null), s = Ht(e, i), [o, a] = b.useState(null), { trigger: l, onClose: c } = n, u = i.current, { onPointerInTransitChange: d } = r, h = b.useCallback(() => {
      a(null), d(false);
    }, [
      d
    ]), f = b.useCallback((y, g) => {
      const O = y.currentTarget, S = {
        x: y.clientX,
        y: y.clientY
      }, w = _We(S, O.getBoundingClientRect()), x = TWe(S, w), P = EWe(g.getBoundingClientRect()), C = $We([
        ...x,
        ...P
      ]);
      a(C), d(true);
    }, [
      d
    ]);
    return b.useEffect(() => () => h(), [
      h
    ]), b.useEffect(() => {
      if (l && u) {
        const y = (O) => f(O, u), g = (O) => f(O, l);
        return l.addEventListener("pointerleave", y), u.addEventListener("pointerleave", g), () => {
          l.removeEventListener("pointerleave", y), u.removeEventListener("pointerleave", g);
        };
      }
    }, [
      l,
      u,
      f,
      h
    ]), b.useEffect(() => {
      if (o) {
        const y = (g) => {
          const O = g.target, S = {
            x: g.clientX,
            y: g.clientY
          }, w = (l == null ? void 0 : l.contains(O)) || (u == null ? void 0 : u.contains(O)), x = !IWe(S, o);
          w ? h() : x && (h(), c());
        };
        return document.addEventListener("pointermove", y), () => document.removeEventListener("pointermove", y);
      }
    }, [
      l,
      u,
      o,
      c,
      h
    ]), m.jsx(iie, {
      ...t,
      ref: s
    });
  }), [bWe, kWe] = w2(uO, {
    isInside: false
  }), PWe = USe("TooltipContent"), iie = b.forwardRef((t, e) => {
    const { __scopeTooltip: n, children: r, "aria-label": i, onEscapeKeyDown: s, onPointerDownOutside: o, ...a } = t, l = b2(qg, n), c = x2(n), { onClose: u } = l;
    return b.useEffect(() => (document.addEventListener(cM, u), () => document.removeEventListener(cM, u)), [
      u
    ]), b.useEffect(() => {
      if (l.trigger) {
        const d = (h) => {
          var _a3;
          ((_a3 = h.target) == null ? void 0 : _a3.contains(l.trigger)) && u();
        };
        return window.addEventListener("scroll", d, {
          capture: true
        }), () => window.removeEventListener("scroll", d, {
          capture: true
        });
      }
    }, [
      l.trigger,
      u
    ]), m.jsx(Sm, {
      asChild: true,
      disableOutsidePointerEvents: false,
      onEscapeKeyDown: s,
      onPointerDownOutside: o,
      onFocusOutside: (d) => d.preventDefault(),
      onDismiss: u,
      children: m.jsxs(lL, {
        "data-state": l.stateAttribute,
        ...c,
        ...a,
        ref: e,
        style: {
          ...a.style,
          "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
          "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
          "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
          "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
          "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
        },
        children: [
          m.jsx(PWe, {
            children: r
          }),
          m.jsx(bWe, {
            scope: n,
            isInside: true,
            children: m.jsx(sQe, {
              id: l.contentId,
              role: "tooltip",
              children: i || r
            })
          })
        ]
      })
    });
  });
  rie.displayName = qg;
  var sie = "TooltipArrow", CWe = b.forwardRef((t, e) => {
    const { __scopeTooltip: n, ...r } = t, i = x2(n);
    return kWe(sie, n).isInside ? null : m.jsx(cL, {
      ...i,
      ...r,
      ref: e
    });
  });
  CWe.displayName = sie;
  function _We(t, e) {
    const n = Math.abs(e.top - t.y), r = Math.abs(e.bottom - t.y), i = Math.abs(e.right - t.x), s = Math.abs(e.left - t.x);
    switch (Math.min(n, r, i, s)) {
      case s:
        return "left";
      case i:
        return "right";
      case n:
        return "top";
      case r:
        return "bottom";
      default:
        throw new Error("unreachable");
    }
  }
  function TWe(t, e, n = 5) {
    const r = [];
    switch (e) {
      case "top":
        r.push({
          x: t.x - n,
          y: t.y + n
        }, {
          x: t.x + n,
          y: t.y + n
        });
        break;
      case "bottom":
        r.push({
          x: t.x - n,
          y: t.y - n
        }, {
          x: t.x + n,
          y: t.y - n
        });
        break;
      case "left":
        r.push({
          x: t.x + n,
          y: t.y - n
        }, {
          x: t.x + n,
          y: t.y + n
        });
        break;
      case "right":
        r.push({
          x: t.x - n,
          y: t.y - n
        }, {
          x: t.x - n,
          y: t.y + n
        });
        break;
    }
    return r;
  }
  function EWe(t) {
    const { top: e, right: n, bottom: r, left: i } = t;
    return [
      {
        x: i,
        y: e
      },
      {
        x: n,
        y: e
      },
      {
        x: n,
        y: r
      },
      {
        x: i,
        y: r
      }
    ];
  }
  function IWe(t, e) {
    const { x: n, y: r } = t;
    let i = false;
    for (let s = 0, o = e.length - 1; s < e.length; o = s++) {
      const a = e[s], l = e[o], c = a.x, u = a.y, d = l.x, h = l.y;
      u > r != h > r && n < (d - c) * (r - u) / (h - u) + c && (i = !i);
    }
    return i;
  }
  function $We(t) {
    const e = t.slice();
    return e.sort((n, r) => n.x < r.x ? -1 : n.x > r.x ? 1 : n.y < r.y ? -1 : n.y > r.y ? 1 : 0), AWe(e);
  }
  function AWe(t) {
    if (t.length <= 1)
      return t.slice();
    const e = [];
    for (let r = 0; r < t.length; r++) {
      const i = t[r];
      for (; e.length >= 2; ) {
        const s = e[e.length - 1], o = e[e.length - 2];
        if ((s.x - o.x) * (i.y - o.y) >= (s.y - o.y) * (i.x - o.x))
          e.pop();
        else
          break;
      }
      e.push(i);
    }
    e.pop();
    const n = [];
    for (let r = t.length - 1; r >= 0; r--) {
      const i = t[r];
      for (; n.length >= 2; ) {
        const s = n[n.length - 1], o = n[n.length - 2];
        if ((s.x - o.x) * (i.y - o.y) >= (s.y - o.y) * (i.x - o.x))
          n.pop();
        else
          break;
      }
      n.push(i);
    }
    return n.pop(), e.length === 1 && n.length === 1 && e[0].x === n[0].x && e[0].y === n[0].y ? e : e.concat(n);
  }
  var RWe = eie, MWe = tie, DWe = nie, oie = rie;
  const LWe = RWe, jWe = MWe, NWe = DWe, aie = b.forwardRef(({ className: t, sideOffset: e = 4, ...n }, r) => m.jsx(oie, {
    ref: r,
    sideOffset: e,
    className: on("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", t),
    ...n
  }));
  aie.displayName = oie.displayName;
  function QWe() {
    return p2.useSyncExternalStore(zWe, () => true, () => false);
  }
  function zWe() {
    return () => {
    };
  }
  var hj = "Avatar", [FWe, lat] = Ps(hj), [BWe, lie] = FWe(hj), cie = b.forwardRef((t, e) => {
    const { __scopeAvatar: n, ...r } = t, [i, s] = b.useState("idle");
    return m.jsx(BWe, {
      scope: n,
      imageLoadingStatus: i,
      onImageLoadingStatusChange: s,
      children: m.jsx(rt.span, {
        ...r,
        ref: e
      })
    });
  });
  cie.displayName = hj;
  var uie = "AvatarImage", die = b.forwardRef((t, e) => {
    const { __scopeAvatar: n, src: r, onLoadingStatusChange: i = () => {
    }, ...s } = t, o = lie(uie, n), a = UWe(r, s), l = ki((c) => {
      i(c), o.onImageLoadingStatusChange(c);
    });
    return ta(() => {
      a !== "idle" && l(a);
    }, [
      a,
      l
    ]), a === "loaded" ? m.jsx(rt.img, {
      ...s,
      ref: e,
      src: r
    }) : null;
  });
  die.displayName = uie;
  var hie = "AvatarFallback", fie = b.forwardRef((t, e) => {
    const { __scopeAvatar: n, delayMs: r, ...i } = t, s = lie(hie, n), [o, a] = b.useState(r === void 0);
    return b.useEffect(() => {
      if (r !== void 0) {
        const l = window.setTimeout(() => a(true), r);
        return () => window.clearTimeout(l);
      }
    }, [
      r
    ]), o && s.imageLoadingStatus !== "loaded" ? m.jsx(rt.span, {
      ...i,
      ref: e
    }) : null;
  });
  fie.displayName = hie;
  function bB(t, e) {
    return t ? e ? (t.src !== e && (t.src = e), t.complete && t.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
  }
  function UWe(t, { referrerPolicy: e, crossOrigin: n }) {
    const r = QWe(), i = b.useRef(null), s = (() => r ? (i.current || (i.current = new window.Image()), i.current) : null)(), [o, a] = b.useState(() => bB(s, t));
    return ta(() => {
      a(bB(s, t));
    }, [
      s,
      t
    ]), ta(() => {
      const l = (d) => () => {
        a(d);
      };
      if (!s)
        return;
      const c = l("loaded"), u = l("error");
      return s.addEventListener("load", c), s.addEventListener("error", u), e && (s.referrerPolicy = e), typeof n == "string" && (s.crossOrigin = n), () => {
        s.removeEventListener("load", c), s.removeEventListener("error", u);
      };
    }, [
      s,
      n,
      e
    ]), o;
  }
  var pie = cie, gie = die, mie = fie;
  const VWe = X3("relative flex shrink-0 overflow-hidden rounded-full border", {
    variants: {
      size: {
        default: "h-8 w-8",
        sm: "h-6 w-6",
        lg: "h-[64px] w-[64px] text-xl"
      }
    },
    defaultVariants: {
      size: "default"
    }
  }), yie = b.forwardRef(({ className: t, size: e, ...n }, r) => m.jsx(pie, {
    ref: r,
    className: on(VWe({
      size: e,
      className: t
    })),
    ...n
  }));
  yie.displayName = pie.displayName;
  const vie = b.forwardRef(({ className: t, ...e }, n) => m.jsx(gie, {
    ref: n,
    className: on("aspect-square h-full w-full", t),
    ...e
  }));
  vie.displayName = gie.displayName;
  const Oie = b.forwardRef(({ className: t, ...e }, n) => m.jsx(mie, {
    ref: n,
    className: on("flex h-full w-full items-center justify-center rounded-full bg-muted", t),
    ...e
  }));
  Oie.displayName = mie.displayName;
  const XWe = (t) => t.split(" ").map((e) => e[0]).join(""), k0 = ({ name: t, avatar: e, url: n, showName: r = false, size: i }) => {
    const [s] = Ba(n), [o] = Ba(void 0), a = (s == null ? void 0 : s.type) === "registered" ? s : o, l = wve(a == null ? void 0 : a.avatarUrl), c = b.useMemo(() => e && URL.createObjectURL(e), [
      e
    ]), u = c || (n && (a == null ? void 0 : a.avatarUrl) ? l : void 0), d = t ?? (a == null ? void 0 : a.name);
    return m.jsxs("div", {
      className: "flex items-center gap-1.5",
      children: [
        m.jsxs(yie, {
          size: i,
          children: [
            m.jsx(vie, {
              src: u,
              alt: d
            }),
            m.jsx(Oie, {
              children: d ? XWe(d) : m.jsx(W7e, {})
            })
          ]
        }),
        r && m.jsx("span", {
          children: d ?? "Anonymous"
        })
      ]
    });
  }, WWe = 1024 * 1024, Sie = ({ showName: t, size: e = "default" }) => {
    const n = BO(), r = Tve(), [i, s] = b.useState(""), [o, a] = b.useState(), [l, c] = b.useState("signUp"), [u, d] = b.useState(false), [h, f] = b.useState(false), [y, g] = b.useState(""), O = y ? Ive(y) : void 0, [S] = Ba(O), [w] = Ba(S == null ? void 0 : S.contactUrl), x = (() => !y || y === "" ? null : O ? !S || !w ? "not-found" : "valid" : "malformed")(), P = n ? Eve(n.handle.url, i) : null;
    b.useEffect(() => {
      r && r.type === "registered" && i === "" && s(r.name);
    }, [
      r
    ]);
    const C = () => {
      switch (l) {
        case "logIn":
          n.logIn(O);
          break;
        case "signUp":
          n.signUp({
            name: i,
            avatar: o
          });
          break;
      }
    }, _ = () => {
      n.logOut();
    }, T = (M) => {
      const R = M.target.files ? M.target.files[0] : void 0;
      if (R.size > WWe) {
        alert("Avatar is too large. Please choose a file under 1MB."), M.target.value = "";
        return;
      }
      a(R);
    }, $ = () => {
      d((M) => !M);
    }, N = () => {
      navigator.clipboard.writeText(P), f(true), setTimeout(() => {
        f(false);
      }, 1e3);
    }, L = l === "signUp" && i || l === "logIn" && y && (S == null ? void 0 : S.contactUrl) && (w == null ? void 0 : w.type) === "registered", z = (r == null ? void 0 : r.type) === "registered";
    return m.jsxs(aWe, {
      children: [
        m.jsx(WI, {
          children: m.jsxs("div", {
            className: "flex flex-row  text-sm text-gray-600 hover:text-gray-800 ",
            children: [
              m.jsx(k0, {
                url: n == null ? void 0 : n.contactHandle.url,
                size: e
              }),
              t && z && m.jsx("div", {
                className: "ml-2 py-2",
                children: i
              }),
              t && !z && m.jsx("div", {
                className: "ml-2 py-2",
                children: "Sign in"
              })
            ]
          })
        }),
        m.jsxs(Mre, {
          className: "sm:max-w-[425px]",
          children: [
            m.jsx(Dre, {
              className: "items-center",
              children: z ? m.jsx(k0, {
                size: "default",
                url: n == null ? void 0 : n.contactHandle.url,
                name: i,
                avatar: o
              }) : l === "signUp" ? m.jsx(k0, {
                name: i,
                avatar: o,
                size: "lg"
              }) : m.jsx(k0, {
                url: S == null ? void 0 : S.contactUrl,
                size: "lg"
              })
            }),
            !z && m.jsxs(pWe, {
              defaultValue: "signUp",
              className: "w-full",
              onValueChange: (M) => c(M),
              value: l,
              children: [
                m.jsxs(Gre, {
                  className: "grid w-full grid-cols-2",
                  children: [
                    m.jsx(aM, {
                      value: "signUp",
                      children: "Sign up"
                    }),
                    m.jsx(aM, {
                      value: "logIn",
                      children: "Log in"
                    })
                  ]
                }),
                m.jsxs(lM, {
                  value: "signUp",
                  children: [
                    m.jsxs("div", {
                      className: "grid w-full max-w-sm items-center gap-1.5 py-4",
                      children: [
                        m.jsx(wh, {
                          htmlFor: "name",
                          children: "Name"
                        }),
                        m.jsx(Lu, {
                          id: "name",
                          value: i,
                          onChange: (M) => s(M.target.value)
                        })
                      ]
                    }),
                    m.jsxs("div", {
                      className: "grid w-full max-w-sm items-center gap-1.5",
                      children: [
                        m.jsx(wh, {
                          htmlFor: "picture",
                          children: "Avatar"
                        }),
                        m.jsx(Lu, {
                          id: "avatar",
                          type: "file",
                          accept: "image/*",
                          onChange: T
                        })
                      ]
                    })
                  ]
                }),
                m.jsx(lM, {
                  value: "logIn",
                  children: m.jsxs("form", {
                    className: "grid w-full max-w-sm items-center gap-1.5 py-4",
                    children: [
                      m.jsx(wh, {
                        htmlFor: "accountUrl",
                        children: "Account token"
                      }),
                      m.jsxs("div", {
                        className: "flex gap-1.5",
                        children: [
                          m.jsx(Lu, {
                            className: `${x === "valid" ? "bg-green-100" : ""}`,
                            id: "accountUrl",
                            value: y,
                            onChange: (M) => {
                              g(M.target.value);
                            },
                            type: u ? "text" : "password",
                            autoComplete: "current-password"
                          }),
                          m.jsx(Ea, {
                            variant: "ghost",
                            onClick: $,
                            children: u ? m.jsx(p9, {}) : m.jsx(f9, {})
                          })
                        ]
                      }),
                      m.jsxs("div", {
                        className: "h-8 text-sm text-red-500",
                        children: [
                          x === "malformed" && m.jsx("div", {
                            children: "Not a valid account token, try copy-pasting again."
                          }),
                          x === "not-found" && m.jsx("div", {
                            children: "Account not found"
                          })
                        ]
                      }),
                      m.jsx("p", {
                        className: "text-gray-500 text-justify pb-2 text-sm",
                        children: "To login, paste your account token."
                      }),
                      m.jsx("p", {
                        className: "text-gray-500 text-justify pb-2 text-sm mb-2",
                        children: "You can find your token by accessing the account dialog on any device where you are currently logged in."
                      })
                    ]
                  })
                })
              ]
            }),
            z && m.jsxs(m.Fragment, {
              children: [
                m.jsxs("div", {
                  className: "grid w-full max-w-sm items-center gap-1.5 py-4",
                  children: [
                    m.jsx(wh, {
                      htmlFor: "name",
                      children: "Name"
                    }),
                    m.jsx(Lu, {
                      id: "name",
                      value: i,
                      onChange: (M) => s(M.target.value)
                    })
                  ]
                }),
                m.jsxs("div", {
                  className: "grid w-full max-w-sm items-center gap-1.5",
                  children: [
                    m.jsx(wh, {
                      htmlFor: "picture",
                      children: "Avatar"
                    }),
                    m.jsx(Lu, {
                      id: "avatar",
                      type: "file",
                      accept: "image/*",
                      onChange: T
                    })
                  ]
                }),
                m.jsxs("form", {
                  className: "grid w-full max-w-sm items-center gap-1.5",
                  children: [
                    m.jsx(wh, {
                      htmlFor: "picture",
                      children: "Account token"
                    }),
                    m.jsxs("div", {
                      className: "flex gap-1.5",
                      children: [
                        m.jsx(Lu, {
                          onFocus: (M) => M.target.select(),
                          value: P,
                          id: "accountUrl",
                          type: u ? "text" : "password",
                          accept: "image/*",
                          onChange: T,
                          autoComplete: "off"
                        }),
                        m.jsx(Ea, {
                          variant: "ghost",
                          onClick: $,
                          type: "button",
                          children: u ? m.jsx(p9, {}) : m.jsx(f9, {})
                        }),
                        m.jsx(LWe, {
                          children: m.jsxs(jWe, {
                            open: h,
                            children: [
                              m.jsx(NWe, {
                                type: "button",
                                onClick: N,
                                onBlur: () => f(false),
                                children: m.jsx($7e, {})
                              }),
                              m.jsx(aie, {
                                children: m.jsx("p", {
                                  children: "Copied"
                                })
                              })
                            ]
                          })
                        })
                      ]
                    }),
                    m.jsx("p", {
                      className: "text-gray-500 text-justify pt-2 text-sm",
                      children: "To log in on another device, copy your account token and paste it into the login screen on the other device."
                    }),
                    m.jsx("p", {
                      className: "text-gray-500 text-justify pt-2 text-sm",
                      children: "\u26A0\uFE0F WARNING: this app has limited security, don't use it for private docs."
                    })
                  ]
                })
              ]
            }),
            m.jsxs(Lre, {
              className: "gap-1.5",
              children: [
                z && m.jsx(WI, {
                  asChild: true,
                  children: m.jsx(Ea, {
                    onClick: _,
                    variant: "secondary",
                    children: "Sign out"
                  })
                }),
                m.jsx(WI, {
                  asChild: true,
                  children: m.jsx(Ea, {
                    type: "submit",
                    onClick: C,
                    disabled: !L,
                    children: z ? "Save" : l === "signUp" ? "Sign up" : `Log in${w && w.type === "registered" ? ` as ${w.name}` : ""}`
                  })
                })
              ]
            })
          ]
        })
      ]
    });
  };
  var k2 = "Popover", [wie, cat] = Ps(k2, [
    Rm
  ]), wS = Rm(), [ZWe, Vd] = wie(k2), xie = (t) => {
    const { __scopePopover: e, children: n, open: r, defaultOpen: i, onOpenChange: s, modal: o = false } = t, a = wS(e), l = b.useRef(null), [c, u] = b.useState(false), [d, h] = Wl({
      prop: r,
      defaultProp: i ?? false,
      onChange: s,
      caller: k2
    });
    return m.jsx(GC, {
      ...a,
      children: m.jsx(ZWe, {
        scope: e,
        contentId: ja(),
        triggerRef: l,
        open: d,
        onOpenChange: h,
        onOpenToggle: b.useCallback(() => h((f) => !f), [
          h
        ]),
        hasCustomAnchor: c,
        onCustomAnchorAdd: b.useCallback(() => u(true), []),
        onCustomAnchorRemove: b.useCallback(() => u(false), []),
        modal: o,
        children: n
      })
    });
  };
  xie.displayName = k2;
  var bie = "PopoverAnchor", HWe = b.forwardRef((t, e) => {
    const { __scopePopover: n, ...r } = t, i = Vd(bie, n), s = wS(n), { onCustomAnchorAdd: o, onCustomAnchorRemove: a } = i;
    return b.useEffect(() => (o(), () => a()), [
      o,
      a
    ]), m.jsx(qC, {
      ...s,
      ...r,
      ref: e
    });
  });
  HWe.displayName = bie;
  var kie = "PopoverTrigger", Pie = b.forwardRef((t, e) => {
    const { __scopePopover: n, ...r } = t, i = Vd(kie, n), s = wS(n), o = Ht(e, i.triggerRef), a = m.jsx(rt.button, {
      type: "button",
      "aria-haspopup": "dialog",
      "aria-expanded": i.open,
      "aria-controls": i.contentId,
      "data-state": $ie(i.open),
      ...r,
      ref: o,
      onClick: Pe(t.onClick, i.onOpenToggle)
    });
    return i.hasCustomAnchor ? a : m.jsx(qC, {
      asChild: true,
      ...s,
      children: a
    });
  });
  Pie.displayName = kie;
  var fj = "PopoverPortal", [YWe, GWe] = wie(fj, {
    forceMount: void 0
  }), Cie = (t) => {
    const { __scopePopover: e, forceMount: n, children: r, container: i } = t, s = Vd(fj, e);
    return m.jsx(YWe, {
      scope: e,
      forceMount: n,
      children: m.jsx(uo, {
        present: n || s.open,
        children: m.jsx(ZO, {
          asChild: true,
          container: i,
          children: r
        })
      })
    });
  };
  Cie.displayName = fj;
  var Kg = "PopoverContent", _ie = b.forwardRef((t, e) => {
    const n = GWe(Kg, t.__scopePopover), { forceMount: r = n.forceMount, ...i } = t, s = Vd(Kg, t.__scopePopover);
    return m.jsx(uo, {
      present: r || s.open,
      children: s.modal ? m.jsx(KWe, {
        ...i,
        ref: e
      }) : m.jsx(JWe, {
        ...i,
        ref: e
      })
    });
  });
  _ie.displayName = Kg;
  var qWe = nf("PopoverContent.RemoveScroll"), KWe = b.forwardRef((t, e) => {
    const n = Vd(Kg, t.__scopePopover), r = b.useRef(null), i = Ht(e, r), s = b.useRef(false);
    return b.useEffect(() => {
      const o = r.current;
      if (o)
        return OC(o);
    }, []), m.jsx(q3, {
      as: qWe,
      allowPinchZoom: true,
      children: m.jsx(Tie, {
        ...t,
        ref: i,
        trapFocus: n.open,
        disableOutsidePointerEvents: true,
        onCloseAutoFocus: Pe(t.onCloseAutoFocus, (o) => {
          var _a3;
          o.preventDefault(), s.current || ((_a3 = n.triggerRef.current) == null ? void 0 : _a3.focus());
        }),
        onPointerDownOutside: Pe(t.onPointerDownOutside, (o) => {
          const a = o.detail.originalEvent, l = a.button === 0 && a.ctrlKey === true, c = a.button === 2 || l;
          s.current = c;
        }, {
          checkForDefaultPrevented: false
        }),
        onFocusOutside: Pe(t.onFocusOutside, (o) => o.preventDefault(), {
          checkForDefaultPrevented: false
        })
      })
    });
  }), JWe = b.forwardRef((t, e) => {
    const n = Vd(Kg, t.__scopePopover), r = b.useRef(false), i = b.useRef(false);
    return m.jsx(Tie, {
      ...t,
      ref: e,
      trapFocus: false,
      disableOutsidePointerEvents: false,
      onCloseAutoFocus: (s) => {
        var _a3, _b3;
        (_a3 = t.onCloseAutoFocus) == null ? void 0 : _a3.call(t, s), s.defaultPrevented || (r.current || ((_b3 = n.triggerRef.current) == null ? void 0 : _b3.focus()), s.preventDefault()), r.current = false, i.current = false;
      },
      onInteractOutside: (s) => {
        var _a3, _b3;
        (_a3 = t.onInteractOutside) == null ? void 0 : _a3.call(t, s), s.defaultPrevented || (r.current = true, s.detail.originalEvent.type === "pointerdown" && (i.current = true));
        const o = s.target;
        ((_b3 = n.triggerRef.current) == null ? void 0 : _b3.contains(o)) && s.preventDefault(), s.detail.originalEvent.type === "focusin" && i.current && s.preventDefault();
      }
    });
  }), Tie = b.forwardRef((t, e) => {
    const { __scopePopover: n, trapFocus: r, onOpenAutoFocus: i, onCloseAutoFocus: s, disableOutsidePointerEvents: o, onEscapeKeyDown: a, onPointerDownOutside: l, onFocusOutside: c, onInteractOutside: u, ...d } = t, h = Vd(Kg, n), f = wS(n);
    return H3(), m.jsx(yC, {
      asChild: true,
      loop: true,
      trapped: r,
      onMountAutoFocus: i,
      onUnmountAutoFocus: s,
      children: m.jsx(Sm, {
        asChild: true,
        disableOutsidePointerEvents: o,
        onInteractOutside: u,
        onEscapeKeyDown: a,
        onPointerDownOutside: l,
        onFocusOutside: c,
        onDismiss: () => h.onOpenChange(false),
        children: m.jsx(lL, {
          "data-state": $ie(h.open),
          role: "dialog",
          id: h.contentId,
          ...f,
          ...d,
          ref: e,
          style: {
            ...d.style,
            "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
            "--radix-popover-content-available-width": "var(--radix-popper-available-width)",
            "--radix-popover-content-available-height": "var(--radix-popper-available-height)",
            "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
            "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
          }
        })
      })
    });
  }), Eie = "PopoverClose", Iie = b.forwardRef((t, e) => {
    const { __scopePopover: n, ...r } = t, i = Vd(Eie, n);
    return m.jsx(rt.button, {
      type: "button",
      ...r,
      ref: e,
      onClick: Pe(t.onClick, () => i.onOpenChange(false))
    });
  });
  Iie.displayName = Eie;
  var eZe = "PopoverArrow", tZe = b.forwardRef((t, e) => {
    const { __scopePopover: n, ...r } = t, i = wS(n);
    return m.jsx(cL, {
      ...i,
      ...r,
      ref: e
    });
  });
  tZe.displayName = eZe;
  function $ie(t) {
    return t ? "open" : "closed";
  }
  var nZe = xie, rZe = Pie, iZe = Cie, Aie = _ie, sZe = Iie;
  const yg = nZe, vg = rZe, kB = sZe, Hh = b.forwardRef(({ className: t, align: e = "center", sideOffset: n = 4, ...r }, i) => m.jsx(iZe, {
    children: m.jsx(Aie, {
      ref: i,
      align: e,
      sideOffset: n,
      className: on("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", t),
      ...r
    })
  }));
  Hh.displayName = Aie.displayName;
  const oZe = (t) => {
    var _a3;
    const { node: e, style: n, dragHandle: r } = t, i = ((_a3 = ws[e.data.type]) == null ? void 0 : _a3.icon) ?? R7e;
    return m.jsxs("div", {
      style: n,
      ref: r,
      className: `cursor-pointer text-sm py-1 w-full truncate ${e.isSelected ? " bg-gray-300 hover:bg-gray-300 text-gray-900" : "text-gray-600 hover:bg-gray-200"}`,
      onDoubleClick: () => e.edit(),
      children: [
        m.jsx(i, {
          size: 14,
          className: `${e.isSelected ? "text-gray-800" : "text-gray-500"} inline-block align-top mt-[3px] ml-2 mx-2`
        }),
        !e.isEditing && m.jsx("span", {
          children: ws[e.data.type] ? e.data.name : `Unknown type: ${e.data.type}`
        }),
        e.isEditing && m.jsx(aZe, {
          ...t
        })
      ]
    });
  }, aZe = ({ node: t }) => {
    const e = b.useRef();
    return b.useEffect(() => {
      var _a3, _b3;
      (_a3 = e.current) == null ? void 0 : _a3.focus(), (_b3 = e.current) == null ? void 0 : _b3.select();
    }, []), m.jsx("input", {
      ref: e,
      defaultValue: t.data.name,
      onBlur: () => t.reset(),
      onKeyDown: (n) => {
        var _a3;
        n.key === "Escape" && t.reset(), n.key === "Enter" && t.submit(((_a3 = e.current) == null ? void 0 : _a3.value) || "");
      }
    });
  }, Rie = (t, e) => t ? t.docs.map((n) => ({
    ...n,
    folderPath: e,
    children: n.type === "folder" && n.folderContents ? Rie(n.folderContents, [
      ...e,
      n.url
    ]) : void 0
  })) : [], PB = (t) => JSON.stringify({
    url: t.url,
    folderPath: t.folderPath
  }), lZe = ({ selectedDocLink: t, selectDocLink: e, hideSidebar: n, addNewDocument: r, rootFolderDoc: i }) => {
    const s = Xl(), { doc: o, status: a, rootFolderUrl: l, flatDocLinks: c } = i, [u, d] = b.useState(false), [h, f] = b.useState(""), y = h.replace(/%3A/g, ":").match(/(automerge:[a-zA-Z0-9]*)/), g = y && y[1] && Yh(y[1]) ? y[1] : null;
    if (a === "loading")
      return m.jsx("div", {
        className: "flex items-center justify-center h-screen",
        children: m.jsx("p", {
          className: "text-gray-400 text-sm",
          children: "Loading..."
        })
      });
    const O = ({ parentNode: x, index: P, dragNodes: C }) => {
      for (const _ of C) {
        const T = _.parent.level < 0 ? l : _.parent.data.url, $ = s.find(T), N = $.docSync().docs.findIndex((F) => F.url === _.data.url), L = !x || x.level < 0 ? l : x.data.url, z = s.find(L);
        if (N === void 0)
          return;
        const M = T === L && N < P ? P - 1 : P;
        let R;
        $.change((F) => {
          const Q = F.docs.splice(N, 1);
          R = Dc({
            ...Q[0]
          });
        }), z.change((F) => {
          F.docs.splice(M, 0, R);
        });
      }
    }, S = Rie(o, [
      l
    ]), w = t ? PB(t) : null;
    return m.jsxs("div", {
      className: "flex flex-col h-screen",
      children: [
        m.jsxs("div", {
          className: "h-10 py-2 px-4 font-semibold text-gray-500 text-sm flex",
          children: [
            m.jsx("div", {
              className: "mw-40 mt-[3px]",
              children: "My Documents"
            }),
            m.jsx("div", {
              className: "ml-auto",
              children: m.jsx("div", {
                className: "text-gray-400 hover:bg-gray-300 hover:text-gray-500 cursor-pointer  transition-all p-1 m-[-4px] mr-[-8px] rounded-sm",
                onClick: n,
                children: m.jsx(E7e, {})
              })
            })
          ]
        }),
        m.jsxs("div", {
          className: "py-2  border-b border-gray-200",
          children: [
            Object.entries(ws).map(([x, P]) => m.jsxs("div", {
              children: [
                " ",
                m.jsxs("div", {
                  className: "py-1 px-2 text-sm text-gray-600 cursor-pointer hover:bg-gray-200 ",
                  onClick: () => r({
                    type: x
                  }),
                  children: [
                    m.jsx(P.icon, {
                      size: 14,
                      className: "inline-block font-bold mr-2 align-top mt-[2px]"
                    }),
                    "New ",
                    P.name
                  ]
                })
              ]
            }, P.id)),
            m.jsx("div", {
              className: "py-1 px-2 text-sm text-gray-600 cursor-pointer hover:bg-gray-200 ",
              onClick: () => d(true),
              children: m.jsxs(yg, {
                open: u,
                onOpenChange: d,
                children: [
                  m.jsxs(vg, {
                    children: [
                      m.jsx(M7e, {
                        size: 14,
                        className: "inline-block font-bold mr-2 align-top mt-[2px]"
                      }),
                      "Open document"
                    ]
                  }),
                  m.jsxs(Hh, {
                    className: "w-96 h-20",
                    side: "right",
                    children: [
                      m.jsx(Lu, {
                        value: h,
                        placeholder: "automerge:<url>",
                        onChange: (x) => f(x.target.value),
                        onKeyDown: (x) => {
                          x.key === "Enter" && g && (f(""), d(false));
                        },
                        className: `outline-none ${g ? "bg-green-100" : h.length > 0 ? "bg-red-100" : ""}`
                      }),
                      m.jsxs("div", {
                        className: "text-xs text-gray-500 text-right mt-1",
                        children: [
                          g && m.jsxs(m.Fragment, {
                            children: [
                              " ",
                              "\u23CE",
                              " Enter to open "
                            ]
                          }),
                          h.length > 0 && !g && "Not a valid Automerge URL"
                        ]
                      })
                    ]
                  })
                ]
              })
            })
          ]
        }),
        m.jsx("div", {
          className: "flex-grow overflow-auto",
          children: m.jsx(oWe, {
            children: ({ width: x, height: P }) => m.jsx(tWe, {
              data: S,
              width: x,
              height: P,
              rowHeight: 28,
              selection: w,
              idAccessor: PB,
              onSelect: (C) => {
                if (!C || C.length === 0)
                  return false;
                const _ = C[0].data;
                Yh(_.url) && e(_);
              },
              onMove: O,
              onRename: ({ node: C, name: _ }) => {
                const T = c.find((L) => L.url === C.data.url), $ = ws[T.type];
                if (!$.setTitle) {
                  alert(`${ym.capitalize($.name)} documents can only be renamed in the main editor, not the sidebar.`);
                  return;
                }
                if (!T)
                  return;
                s.find(T.folderPath[T.folderPath.length - 1]).change((L) => {
                  const z = L.docs.find((M) => M.url === T.url);
                  z && (z.name = _);
                });
              },
              children: oZe
            })
          })
        }),
        m.jsx("div", {
          className: "h-12 border-t border-gray-300 py-1 px-2 bg-gray-200",
          children: m.jsx(Sie, {
            showName: true
          })
        })
      ]
    });
  };
  var cZe = b.useLayoutEffect, uZe = {};
  var P2 = b, dZe = p2;
  function hZe(t, e) {
    return t === e && (t !== 0 || 1 / t === 1 / e) || t !== t && e !== e;
  }
  var fZe = typeof Object.is == "function" ? Object.is : hZe, pZe = dZe.useSyncExternalStore, gZe = P2.useRef, mZe = P2.useEffect, yZe = P2.useMemo, vZe = P2.useDebugValue;
  uZe.useSyncExternalStoreWithSelector = function(t, e, n, r, i) {
    var s = gZe(null);
    if (s.current === null) {
      var o = {
        hasValue: false,
        value: null
      };
      s.current = o;
    } else
      o = s.current;
    s = yZe(function() {
      function l(f) {
        if (!c) {
          if (c = true, u = f, f = r(f), i !== void 0 && o.hasValue) {
            var y = o.value;
            if (i(y, f))
              return d = y;
          }
          return d = f;
        }
        if (y = d, fZe(u, f))
          return y;
        var g = r(f);
        return i !== void 0 && i(y, g) ? (u = f, y) : (u = f, d = g);
      }
      var c = false, u, d, h = n === void 0 ? null : n;
      return [
        function() {
          return l(e());
        },
        h === null ? void 0 : function() {
          return l(h());
        }
      ];
    }, [
      e,
      n,
      r,
      i
    ]);
    var a = pZe(t, s[0], s[1]);
    return mZe(function() {
      o.hasValue = true, o.value = a;
    }, [
      a
    ]), vZe(a), a;
  };
  const Mie = (t, e) => {
    e(t);
    const n = t.getSnapshot().children;
    n && Object.values(n).forEach((r) => {
      Mie(r, e);
    });
  };
  function OZe(t) {
    var _a3, _b3;
    const e = [];
    Mie(t, (r) => {
      e.push([
        r,
        r.getSnapshot()
      ]), r.observers = /* @__PURE__ */ new Set();
    });
    const n = (_b3 = (_a3 = t.system).getSnapshot) == null ? void 0 : _b3.call(_a3);
    t.stop(), t.system._snapshot = n, e.forEach(([r, i]) => {
      r._processingStatus = 0, r._snapshot = i;
    });
  }
  function SZe(t, ...[e]) {
    let [[n, r], i] = b.useState(() => {
      const s = NQ(t, e);
      return [
        t.config,
        s
      ];
    });
    if (t.config !== n) {
      const s = NQ(t, {
        ...e,
        snapshot: r.getPersistedSnapshot({
          __unsafeAllowInlineActors: true
        })
      });
      i([
        t.config,
        s
      ]), r = s;
    }
    return cZe(() => {
      r.logic.implementations = t.implementations;
    }), r;
  }
  function wZe(t, ...[e]) {
    const n = SZe(t, e), r = b.useCallback(() => n.getSnapshot(), [
      n
    ]), i = b.useCallback((o) => {
      const { unsubscribe: a } = n.subscribe(o);
      return a;
    }, [
      n
    ]), s = p2.useSyncExternalStore(i, r, r);
    return b.useEffect(() => (n.start(), () => {
      OZe(n);
    }), [
      n
    ]), [
      s,
      n.send,
      n
    ];
  }
  function xZe(t, ...[e]) {
    return wZe(t, e);
  }
  const bZe = ({ docUrl: t }) => {
    const e = JP(t);
    return e ? m.jsx(kZe, {
      handle: e
    }, e.url) : null;
  }, kZe = ({ handle: t }) => {
    const { lastSyncUpdate: e, isInternetConnected: n, syncState: r, syncServerConnectionError: i, syncServerResponseError: s, syncServerHeads: o, ownHeads: a } = PZe(t), l = r === 0, c = b.useRef(void 0);
    b.useEffect(() => {
      c.current && c.current.url !== t.url && console.warn("Warning: do not change the handle between renders of SyncIndicator", {
        previous: c.current.url,
        current: t.url
      }), c.current = t;
    }, [
      t
    ]);
    const u = m.jsxs("div", {
      className: "mt-2 pt-2 border-t border-gray-300",
      children: [
        m.jsxs("div", {
          className: "whitespace-nowrap flex",
          children: [
            m.jsx("dt", {
              className: "font-bold inline mr-1",
              children: "Server heads:"
            }),
            m.jsx("dd", {
              className: "inline text-ellipsis flex-shrink overflow-hidden min-w-0",
              children: JSON.stringify((o ?? []).map((d) => d.slice(0, 4)))
            })
          ]
        }),
        m.jsxs("div", {
          className: "whitespace-nowrap flex",
          children: [
            m.jsx("dt", {
              className: "font-bold inline mr-1",
              children: "Local heads:"
            }),
            m.jsx("dd", {
              className: "inline text-ellipsis flex-shrink overflow-hidden min-w-0",
              children: JSON.stringify((a ?? []).map((d) => d.slice(0, 4)))
            })
          ]
        })
      ]
    });
    return n ? !i && !s ? m.jsxs(yg, {
      children: [
        m.jsx(vg, {
          className: " p-1 rounded-md text-gray-500 hover:text-gray-900 align-top",
          children: m.jsx(g9, {
            size: "20px"
          })
        }),
        m.jsx(Hh, {
          className: "flex flex-col gap-1.5 pb-2",
          children: m.jsxs("dl", {
            className: "text-sm text-gray-600",
            children: [
              m.jsxs("div", {
                children: [
                  m.jsx("dt", {
                    className: "font-bold inline mr-1",
                    children: "Connection:"
                  }),
                  m.jsx("dd", {
                    className: "inline",
                    children: "Connected to server"
                  })
                ]
              }),
              m.jsxs("div", {
                children: [
                  m.jsx("dt", {
                    className: "font-bold inline mr-1",
                    children: "Last synced:"
                  }),
                  m.jsx("dd", {
                    className: "inline",
                    children: e ? MT(e) : "-"
                  })
                ]
              }),
              m.jsxs("div", {
                children: [
                  m.jsx("dt", {
                    className: "font-bold inline mr-1",
                    children: "Sync status:"
                  }),
                  m.jsx("dd", {
                    className: "inline",
                    children: l ? "Up to date" : "Syncing..."
                  })
                ]
              }),
              u
            ]
          })
        })
      ]
    }) : m.jsxs(yg, {
      children: [
        m.jsx(vg, {
          className: "bg-red-50 border border-red-100 hover:bg-red-100 p-2 rounded-md",
          children: m.jsxs("div", {
            className: "text-red-500 flex items-center text-sm",
            children: [
              m.jsx(g9, {
                size: "20px",
                className: `inline-block ${l ? "mr-[7px]" : ""}`
              }),
              !l && m.jsx("div", {
                className: "inline text-xs",
                children: "*"
              })
            ]
          })
        }),
        m.jsxs(Hh, {
          className: "flex flex-col gap-1.5 pb-2",
          children: [
            m.jsxs("div", {
              className: "mb-2 text-sm",
              children: [
                m.jsx("p", {
                  children: "There was an unexpected error connecting to the sync server. Don't worry, your changes are saved locally."
                }),
                m.jsx("p", {
                  className: "mt-2",
                  children: "Please try reloading and see if that fixes the issue. If not, drop a note in the lab Discord with a screenshot."
                })
              ]
            }),
            m.jsxs("dl", {
              className: "text-sm text-gray-600",
              children: [
                m.jsxs("div", {
                  children: [
                    m.jsx("dt", {
                      className: "font-bold inline mr-1",
                      children: "Connection:"
                    }),
                    m.jsx("dd", {
                      className: "inline text-red-500",
                      children: i ? "Server not connected" : "Server not responding"
                    })
                  ]
                }),
                m.jsxs("div", {
                  children: [
                    m.jsx("dt", {
                      className: "font-bold inline mr-1",
                      children: "Last synced:"
                    }),
                    m.jsx("dd", {
                      className: "inline",
                      children: e ? MT(e) : "-"
                    })
                  ]
                }),
                m.jsxs("div", {
                  children: [
                    m.jsx("dt", {
                      className: "font-bold inline mr-1",
                      children: "Sync status:"
                    }),
                    m.jsx("dd", {
                      className: "inline",
                      children: r === 2 ? "-" : r === 0 ? "No unsynced changes" : m.jsx("span", {
                        className: "text-red-500",
                        children: "Unsynced changes (*)"
                      })
                    }),
                    u
                  ]
                })
              ]
            })
          ]
        })
      ]
    }) : m.jsxs(yg, {
      children: [
        m.jsx(vg, {
          className: "hover:bg-gray-100 p-2 rounded-md",
          children: m.jsxs("div", {
            className: "text-gray-500",
            children: [
              m.jsx(Z7e, {
                size: "20px",
                className: `inline-block ${l ? "mr-[7px]" : ""}`
              }),
              !l && m.jsx("div", {
                className: "inline text-xs font-bold text-red-600",
                children: "*"
              })
            ]
          })
        }),
        m.jsx(Hh, {
          children: m.jsxs("dl", {
            className: "text-sm text-gray-600",
            children: [
              m.jsxs("div", {
                children: [
                  m.jsx("dt", {
                    className: "font-bold inline mr-1",
                    children: "Connection:"
                  }),
                  m.jsx("dd", {
                    className: "inline",
                    children: "Offline"
                  })
                ]
              }),
              m.jsxs("div", {
                children: [
                  m.jsx("dt", {
                    className: "font-bold inline mr-1",
                    children: "Last synced:"
                  }),
                  m.jsx("dd", {
                    className: "inline",
                    children: e ? MT(e) : "-"
                  })
                ]
              }),
              m.jsxs("div", {
                children: [
                  m.jsx("dt", {
                    className: "font-bold inline mr-1",
                    children: "Sync status:"
                  }),
                  m.jsx("dd", {
                    className: "inline",
                    children: r === 2 ? "-" : l ? "No unsynced changes" : m.jsx("span", {
                      className: "text-red-500",
                      children: "You have unsynced changes. They are saved locally and will sync next time you have internet and you open the app."
                    })
                  })
                ]
              }),
              u
            ]
          })
        })
      ]
    });
  }, ZI = {
    BASE_URL: "./",
    MODE: "production",
    DEV: false,
    PROD: true,
    SSR: false
  }.VITE_SYNC_SERVER_STORAGE_ID ?? "3760df37-a4c6-4f66-9ecd-732039a9385d";
  function PZe(t) {
    const e = Xl(), [n, r] = b.useState(), [i, s] = b.useState(), [o, a] = b.useState();
    b.useEffect(() => {
      e.subscribeToRemotes([
        ZI
      ]);
    }, [
      e
    ]);
    const [l] = b.useState(() => CZe({
      connectionInitTimeout: 2e3,
      maxSyncMessageDelay: 1e3,
      isInternetConnected: navigator.onLine,
      isSyncServerConnected: true
    })), [c, u] = xZe(l);
    return b.useEffect(() => {
      const d = () => {
        u({
          type: "INTERNET_CONNECTED"
        });
      }, h = () => {
        u({
          type: "INTERNET_DISCONNECTED"
        });
      };
      return window.addEventListener("online", d), window.addEventListener("offline", h), () => {
        window.removeEventListener("online", d), window.removeEventListener("offline", h);
      };
    }, [
      u
    ]), b.useEffect(() => {
      if (c.matches("sync.unknown")) {
        const f = t.getRemoteHeads(ZI);
        s(f ?? []), t.doc().then((y) => {
          a(_g(y));
        });
      }
      const d = () => {
        const f = t.docSync();
        f && a(_g(f));
      }, h = ({ storageId: f, heads: y }) => {
        f === ZI && (u({
          type: "RECEIVED_SYNC_MESSAGE"
        }), s(y), r(Date.now()));
      };
      return t.on("change", d), t.on("remote-heads", h), () => {
        t.off("change", d), t.off("remote-heads", h);
      };
    }, [
      t
    ]), b.useEffect(() => {
      !o || !i || (bve(o, i) ? u({
        type: "IS_IN_SYNC"
      }) : u({
        type: "IS_OUT_OF_SYNC"
      }));
    }, [
      o,
      i
    ]), {
      ownHeads: o,
      syncServerHeads: i,
      lastSyncUpdate: n,
      isInternetConnected: c.matches("internet.connected"),
      syncState: c.matches("sync.unknown") ? 2 : c.matches("sync.inSync") ? 0 : 1,
      syncServerConnectionError: c.matches("syncServer.disconnected.error"),
      syncServerResponseError: c.matches("sync.outOfSync.error")
    };
  }
  function CZe({ connectionInitTimeout: t, maxSyncMessageDelay: e, isInternetConnected: n = false, isSyncServerConnected: r = false }) {
    return Iye({
      id: "syncIndicator",
      type: "parallel",
      states: {
        internet: {
          initial: n ? "connected" : "disconnected",
          states: {
            connected: {
              after: {
                [t]: {
                  actions: "connectionInitTimeout"
                }
              },
              on: {
                INTERNET_DISCONNECTED: "disconnected"
              }
            },
            disconnected: {
              on: {
                INTERNET_CONNECTED: "connected"
              }
            }
          }
        },
        sync: {
          initial: "unknown",
          states: {
            unknown: {
              on: {
                IS_OUT_OF_SYNC: "outOfSync",
                IS_IN_SYNC: "inSync"
              }
            },
            inSync: {
              on: {
                IS_OUT_OF_SYNC: "outOfSync"
              }
            },
            outOfSync: {
              initial: "ok",
              after: {
                [e]: {
                  target: ".error",
                  guard: Aye("internet.connected")
                }
              },
              on: {
                IS_IN_SYNC: "inSync",
                RECEIVED_SYNC_MESSAGE: "outOfSync",
                CONNECTION_INIT_TIMEOUT: "outOfSync"
              },
              states: {
                ok: {},
                error: {}
              }
            }
          }
        },
        syncServer: {
          initial: r ? "connected" : "disconnected",
          states: {
            connected: {
              on: {
                SYNC_SERVER_DISCONNECTED: "disconnected.error"
              }
            },
            disconnected: {
              initial: "ok",
              on: {
                SYNC_SERVER_CONNECTED: "connected",
                CONNECTION_INIT_TIMEOUT: ".error"
              },
              states: {
                ok: {},
                error: {}
              }
            }
          }
        }
      }
    }, {
      actions: {
        connectionInitTimeout: $ye({
          type: "CONNECTION_INIT_TIMEOUT"
        })
      }
    });
  }
  const _Ze = vL, TZe = Ug, EZe = b.forwardRef(({ className: t, inset: e, children: n, ...r }, i) => m.jsxs(SL, {
    ref: i,
    className: on("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent", e && "pl-8", t),
    ...r,
    children: [
      n,
      m.jsx(T7e, {
        className: "ml-auto h-4 w-4"
      })
    ]
  }));
  EZe.displayName = SL.displayName;
  const IZe = b.forwardRef(({ className: t, ...e }, n) => m.jsx(wL, {
    ref: n,
    className: on("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", t),
    ...e
  }));
  IZe.displayName = wL.displayName;
  const Die = b.forwardRef(({ className: t, sideOffset: e = 4, ...n }, r) => m.jsx(n2, {
    children: m.jsx(r2, {
      ref: r,
      sideOffset: e,
      className: on("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", t),
      ...n
    })
  }));
  Die.displayName = r2.displayName;
  const Ap = b.forwardRef(({ className: t, inset: e, ...n }, r) => m.jsx(Bu, {
    ref: r,
    className: on("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", e && "pl-8", t),
    ...n
  }));
  Ap.displayName = Bu.displayName;
  const $Ze = b.forwardRef(({ className: t, children: e, checked: n, ...r }, i) => m.jsxs(i2, {
    ref: i,
    className: on("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", t),
    checked: n,
    ...r,
    children: [
      m.jsx("span", {
        className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
        children: m.jsx(OL, {
          children: m.jsx(zne, {
            className: "h-4 w-4"
          })
        })
      }),
      e
    ]
  }));
  $Ze.displayName = i2.displayName;
  const AZe = b.forwardRef(({ className: t, children: e, ...n }, r) => m.jsxs(KJ, {
    ref: r,
    className: on("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", t),
    ...n,
    children: [
      m.jsx("span", {
        className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
        children: m.jsx(OL, {
          children: m.jsx(I7e, {
            className: "h-2 w-2 fill-current"
          })
        })
      }),
      e
    ]
  }));
  AZe.displayName = KJ.displayName;
  const RZe = b.forwardRef(({ className: t, inset: e, ...n }, r) => m.jsx(qJ, {
    ref: r,
    className: on("px-2 py-1.5 text-sm font-semibold", e && "pl-8", t),
    ...n
  }));
  RZe.displayName = qJ.displayName;
  const Lie = b.forwardRef(({ className: t, ...e }, n) => m.jsx(JJ, {
    ref: n,
    className: on("-mx-1 my-1 h-px bg-muted", t),
    ...e
  }));
  Lie.displayName = JJ.displayName;
  const MZe = ({ showSidebar: t, setShowSidebar: e, selectDocLink: n, selectedDocLink: r, selectedDoc: i, selectedDocHandle: s, removeDocLink: o }) => {
    const a = Xl(), l = r == null ? void 0 : r.url, c = r == null ? void 0 : r.name, u = r == null ? void 0 : r.type, d = ws[u], h = b.useCallback(() => {
      if (u !== "essay")
        throw new Error("Not supported");
      const y = n9e(i);
      s6(y, "index.md", [
        {
          accept: {
            "text/markdown": [
              ".md"
            ]
          }
        }
      ]);
    }, [
      i,
      u
    ]), f = b.useCallback(() => {
      const y = new Blob([
        Rye(i)
      ], {
        type: "application/octet-stream"
      });
      s6(y, `${l}.automerge`, [
        {
          accept: {
            "application/octet-stream": [
              ".automerge"
            ]
          }
        }
      ]);
    }, [
      l,
      i
    ]);
    return m.jsxs("div", {
      className: "h-10 bg-gray-100 flex items-center flex-shrink-0 border-b border-gray-300",
      children: [
        !t && m.jsx("div", {
          className: "ml-1 p-1 text-gray-500 bg-gray-100 hover:bg-gray-300 hover:text-gray-500 cursor-pointer  transition-all rounded-sm",
          onClick: () => e(!t),
          children: m.jsx(j7e, {
            size: 18
          })
        }),
        m.jsxs("div", {
          className: "ml-3 text-sm text-gray-700 font-bold",
          children: [
            d && m.jsx(d.icon, {
              className: "inline mr-1",
              size: 14
            }),
            c
          ]
        }),
        m.jsx("div", {
          className: "ml-3 mt-[-2px]",
          children: Yh(l) && m.jsx(bZe, {
            docUrl: l
          })
        }),
        m.jsx("div", {
          className: "ml-auto mr-4",
          children: m.jsxs(_Ze, {
            children: [
              m.jsx(TZe, {
                children: m.jsx(Q7e, {
                  size: 18,
                  className: "mt-1 mr-21 text-gray-500 hover:text-gray-800"
                })
              }),
              m.jsxs(Die, {
                className: "mr-4",
                children: [
                  m.jsxs(Ap, {
                    onClick: () => {
                      navigator.clipboard.writeText(window.location.href);
                    },
                    children: [
                      m.jsx(U7e, {
                        className: "inline-block text-gray-500 mr-2",
                        size: 14
                      }),
                      " ",
                      "Copy share URL"
                    ]
                  }),
                  m.jsxs(Ap, {
                    onClick: async () => {
                      const y = a.clone(s);
                      y.change((w) => {
                        ws[u].markCopy(w);
                      });
                      const g = {
                        url: y.url,
                        name: ws[u].getTitle(y.docSync()),
                        type: r.type
                      }, O = a.find(r.folderPath[r.folderPath.length - 1]);
                      await O.whenReady();
                      const S = O.docSync().docs.findIndex((w) => w.url === l);
                      O.change((w) => w.docs.splice(S + 1, 0, g)), n({
                        ...g,
                        folderPath: r.folderPath
                      });
                    },
                    children: [
                      m.jsx(L7e, {
                        className: "inline-block text-gray-500 mr-2",
                        size: 14
                      }),
                      " ",
                      "Make a copy"
                    ]
                  }),
                  m.jsxs(Ap, {
                    onClick: () => h(),
                    children: [
                      m.jsx(A7e, {
                        size: 14,
                        className: "inline-block text-gray-500 mr-2"
                      }),
                      " ",
                      "Export as Markdown"
                    ]
                  }),
                  m.jsxs(Ap, {
                    onClick: () => f(),
                    children: [
                      m.jsx(B7e, {
                        size: 14,
                        className: "inline-block text-gray-500 mr-2"
                      }),
                      " ",
                      "Download Automerge file"
                    ]
                  }),
                  m.jsx(Lie, {}),
                  m.jsxs(Ap, {
                    onClick: () => o(r),
                    children: [
                      m.jsx(X7e, {
                        className: "inline-block text-gray-500 mr-2",
                        size: 14
                      }),
                      " ",
                      "Remove from My Documents"
                    ]
                  })
                ]
              })
            ]
          })
        }),
        m.jsx("div", {
          className: "mr-4 mt-1",
          children: m.jsx(Sie, {})
        })
      ]
    });
  };
  var pj = "Progress", gj = 100, [DZe, uat] = Ps(pj), [LZe, jZe] = DZe(pj), jie = b.forwardRef((t, e) => {
    const { __scopeProgress: n, value: r = null, max: i, getValueLabel: s = NZe, ...o } = t;
    (i || i === 0) && !CB(i) && console.error(QZe(`${i}`, "Progress"));
    const a = CB(i) ? i : gj;
    r !== null && !_B(r, a) && console.error(zZe(`${r}`, "Progress"));
    const l = _B(r, a) ? r : null, c = sP(l) ? s(l, a) : void 0;
    return m.jsx(LZe, {
      scope: n,
      value: l,
      max: a,
      children: m.jsx(rt.div, {
        "aria-valuemax": a,
        "aria-valuemin": 0,
        "aria-valuenow": sP(l) ? l : void 0,
        "aria-valuetext": c,
        role: "progressbar",
        "data-state": zie(l, a),
        "data-value": l ?? void 0,
        "data-max": a,
        ...o,
        ref: e
      })
    });
  });
  jie.displayName = pj;
  var Nie = "ProgressIndicator", Qie = b.forwardRef((t, e) => {
    const { __scopeProgress: n, ...r } = t, i = jZe(Nie, n);
    return m.jsx(rt.div, {
      "data-state": zie(i.value, i.max),
      "data-value": i.value ?? void 0,
      "data-max": i.max,
      ...r,
      ref: e
    });
  });
  Qie.displayName = Nie;
  function NZe(t, e) {
    return `${Math.round(t / e * 100)}%`;
  }
  function zie(t, e) {
    return t == null ? "indeterminate" : t === e ? "complete" : "loading";
  }
  function sP(t) {
    return typeof t == "number";
  }
  function CB(t) {
    return sP(t) && !isNaN(t) && t > 0;
  }
  function _B(t, e) {
    return sP(t) && !isNaN(t) && t <= e && t >= 0;
  }
  function QZe(t, e) {
    return `Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${gj}\`.`;
  }
  function zZe(t, e) {
    return `Invalid prop \`value\` of value \`${t}\` supplied to \`${e}\`. The \`value\` prop must be:
  - a positive number
  - less than the value passed to \`max\` (or ${gj} if no \`max\` prop is set)
  - \`null\` or \`undefined\` if the progress is indeterminate.

Defaulting to \`null\`.`;
  }
  var Fie = jie, FZe = Qie;
  const Bie = b.forwardRef(({ className: t, value: e, ...n }, r) => m.jsx(Fie, {
    ref: r,
    className: on("relative h-4 w-full overflow-hidden rounded-full bg-secondary", t),
    ...n,
    children: m.jsx(FZe, {
      className: "h-full w-full flex-1 bg-primary transition-all",
      style: {
        transform: `translateX(-${100 - (e || 0)}%)`
      }
    })
  }));
  Bie.displayName = Fie.displayName;
  const Uie = ({ docUrl: t, handle: e }) => {
    const [n, r] = b.useState(0);
    return b.useEffect(() => {
      const i = setInterval(() => {
        r((s) => Math.min(s + 10, 100));
      }, 100);
      return () => {
        clearInterval(i);
      };
    }), m.jsx("div", {
      className: "h-screen w-full bg-gray-100 flex items-center justify-center",
      children: m.jsxs("div", {
        children: [
          m.jsxs("div", {
            className: "text-sm mb-4 font-light",
            children: [
              t && e && `Loading ${t}: ${e.state}...`,
              !t || !e && "Loading..."
            ]
          }),
          m.jsx(Bie, {
            color: "blue",
            value: n,
            className: "w-96 border bg-gray-50 h-2"
          })
        ]
      })
    });
  }, BZe = () => {
    const [t, e] = b.useState(TB());
    return b.useEffect(() => {
      const n = () => e(TB());
      return window.addEventListener("hashchange", n), () => {
        window.removeEventListener("hashchange", n);
      };
    }, []), t;
  }, TB = () => new URL(`${location.origin}/${location.hash.slice(1)}`), Vie = "%[a-f0-9]{2}", EB = new RegExp("(" + Vie + ")|([^%]+?)", "gi"), IB = new RegExp("(" + Vie + ")+", "gi");
  function dM(t, e) {
    try {
      return [
        decodeURIComponent(t.join(""))
      ];
    } catch {
    }
    if (t.length === 1)
      return t;
    e = e || 1;
    const n = t.slice(0, e), r = t.slice(e);
    return Array.prototype.concat.call([], dM(n), dM(r));
  }
  function UZe(t) {
    try {
      return decodeURIComponent(t);
    } catch {
      let e = t.match(EB) || [];
      for (let n = 1; n < e.length; n++)
        t = dM(e, n).join(""), e = t.match(EB) || [];
      return t;
    }
  }
  function VZe(t) {
    const e = {
      "%FE%FF": "\uFFFD\uFFFD",
      "%FF%FE": "\uFFFD\uFFFD"
    };
    let n = IB.exec(t);
    for (; n; ) {
      try {
        e[n[0]] = decodeURIComponent(n[0]);
      } catch {
        const i = UZe(n[0]);
        i !== n[0] && (e[n[0]] = i);
      }
      n = IB.exec(t);
    }
    e["%C2"] = "\uFFFD";
    const r = Object.keys(e);
    for (const i of r)
      t = t.replace(new RegExp(i, "g"), e[i]);
    return t;
  }
  function XZe(t) {
    if (typeof t != "string")
      throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof t + "`");
    try {
      return decodeURIComponent(t);
    } catch {
      return VZe(t);
    }
  }
  function Xie(t, e) {
    if (!(typeof t == "string" && typeof e == "string"))
      throw new TypeError("Expected the arguments to be of type `string`");
    if (t === "" || e === "")
      return [];
    const n = t.indexOf(e);
    return n === -1 ? [] : [
      t.slice(0, n),
      t.slice(n + e.length)
    ];
  }
  function WZe(t, e) {
    const n = {};
    if (Array.isArray(e))
      for (const r of e) {
        const i = Object.getOwnPropertyDescriptor(t, r);
        (i == null ? void 0 : i.enumerable) && Object.defineProperty(n, r, i);
      }
    else
      for (const r of Reflect.ownKeys(t)) {
        const i = Object.getOwnPropertyDescriptor(t, r);
        if (i.enumerable) {
          const s = t[r];
          e(r, s, t) && Object.defineProperty(n, r, i);
        }
      }
    return n;
  }
  const ZZe = (t) => t == null, HZe = (t) => encodeURIComponent(t).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`), hM = Symbol("encodeFragmentIdentifier");
  function YZe(t) {
    switch (t.arrayFormat) {
      case "index":
        return (e) => (n, r) => {
          const i = n.length;
          return r === void 0 || t.skipNull && r === null || t.skipEmptyString && r === "" ? n : r === null ? [
            ...n,
            [
              sr(e, t),
              "[",
              i,
              "]"
            ].join("")
          ] : [
            ...n,
            [
              sr(e, t),
              "[",
              sr(i, t),
              "]=",
              sr(r, t)
            ].join("")
          ];
        };
      case "bracket":
        return (e) => (n, r) => r === void 0 || t.skipNull && r === null || t.skipEmptyString && r === "" ? n : r === null ? [
          ...n,
          [
            sr(e, t),
            "[]"
          ].join("")
        ] : [
          ...n,
          [
            sr(e, t),
            "[]=",
            sr(r, t)
          ].join("")
        ];
      case "colon-list-separator":
        return (e) => (n, r) => r === void 0 || t.skipNull && r === null || t.skipEmptyString && r === "" ? n : r === null ? [
          ...n,
          [
            sr(e, t),
            ":list="
          ].join("")
        ] : [
          ...n,
          [
            sr(e, t),
            ":list=",
            sr(r, t)
          ].join("")
        ];
      case "comma":
      case "separator":
      case "bracket-separator": {
        const e = t.arrayFormat === "bracket-separator" ? "[]=" : "=";
        return (n) => (r, i) => i === void 0 || t.skipNull && i === null || t.skipEmptyString && i === "" ? r : (i = i === null ? "" : i, r.length === 0 ? [
          [
            sr(n, t),
            e,
            sr(i, t)
          ].join("")
        ] : [
          [
            r,
            sr(i, t)
          ].join(t.arrayFormatSeparator)
        ]);
      }
      default:
        return (e) => (n, r) => r === void 0 || t.skipNull && r === null || t.skipEmptyString && r === "" ? n : r === null ? [
          ...n,
          sr(e, t)
        ] : [
          ...n,
          [
            sr(e, t),
            "=",
            sr(r, t)
          ].join("")
        ];
    }
  }
  function GZe(t) {
    let e;
    switch (t.arrayFormat) {
      case "index":
        return (n, r, i) => {
          if (e = /\[(\d*)]$/.exec(n), n = n.replace(/\[\d*]$/, ""), !e) {
            i[n] = r;
            return;
          }
          i[n] === void 0 && (i[n] = {}), i[n][e[1]] = r;
        };
      case "bracket":
        return (n, r, i) => {
          if (e = /(\[])$/.exec(n), n = n.replace(/\[]$/, ""), !e) {
            i[n] = r;
            return;
          }
          if (i[n] === void 0) {
            i[n] = [
              r
            ];
            return;
          }
          i[n] = [
            ...i[n],
            r
          ];
        };
      case "colon-list-separator":
        return (n, r, i) => {
          if (e = /(:list)$/.exec(n), n = n.replace(/:list$/, ""), !e) {
            i[n] = r;
            return;
          }
          if (i[n] === void 0) {
            i[n] = [
              r
            ];
            return;
          }
          i[n] = [
            ...i[n],
            r
          ];
        };
      case "comma":
      case "separator":
        return (n, r, i) => {
          const s = typeof r == "string" && r.includes(t.arrayFormatSeparator), o = typeof r == "string" && !s && bc(r, t).includes(t.arrayFormatSeparator);
          r = o ? bc(r, t) : r;
          const a = s || o ? r.split(t.arrayFormatSeparator).map((l) => bc(l, t)) : r === null ? r : bc(r, t);
          i[n] = a;
        };
      case "bracket-separator":
        return (n, r, i) => {
          const s = /(\[])$/.test(n);
          if (n = n.replace(/\[]$/, ""), !s) {
            i[n] = r && bc(r, t);
            return;
          }
          const o = r === null ? [] : r.split(t.arrayFormatSeparator).map((a) => bc(a, t));
          if (i[n] === void 0) {
            i[n] = o;
            return;
          }
          i[n] = [
            ...i[n],
            ...o
          ];
        };
      default:
        return (n, r, i) => {
          if (i[n] === void 0) {
            i[n] = r;
            return;
          }
          i[n] = [
            ...[
              i[n]
            ].flat(),
            r
          ];
        };
    }
  }
  function Wie(t) {
    if (typeof t != "string" || t.length !== 1)
      throw new TypeError("arrayFormatSeparator must be single character string");
  }
  function sr(t, e) {
    return e.encode ? e.strict ? HZe(t) : encodeURIComponent(t) : t;
  }
  function bc(t, e) {
    return e.decode ? XZe(t) : t;
  }
  function Zie(t) {
    return Array.isArray(t) ? t.sort() : typeof t == "object" ? Zie(Object.keys(t)).sort((e, n) => Number(e) - Number(n)).map((e) => t[e]) : t;
  }
  function Hie(t) {
    const e = t.indexOf("#");
    return e !== -1 && (t = t.slice(0, e)), t;
  }
  function qZe(t) {
    let e = "";
    const n = t.indexOf("#");
    return n !== -1 && (e = t.slice(n)), e;
  }
  function $B(t, e) {
    return e.parseNumbers && !Number.isNaN(Number(t)) && typeof t == "string" && t.trim() !== "" ? t = Number(t) : e.parseBooleans && t !== null && (t.toLowerCase() === "true" || t.toLowerCase() === "false") && (t = t.toLowerCase() === "true"), t;
  }
  function mj(t) {
    t = Hie(t);
    const e = t.indexOf("?");
    return e === -1 ? "" : t.slice(e + 1);
  }
  function yj(t, e) {
    e = {
      decode: true,
      sort: true,
      arrayFormat: "none",
      arrayFormatSeparator: ",",
      parseNumbers: false,
      parseBooleans: false,
      ...e
    }, Wie(e.arrayFormatSeparator);
    const n = GZe(e), r = /* @__PURE__ */ Object.create(null);
    if (typeof t != "string" || (t = t.trim().replace(/^[?#&]/, ""), !t))
      return r;
    for (const i of t.split("&")) {
      if (i === "")
        continue;
      const s = e.decode ? i.replace(/\+/g, " ") : i;
      let [o, a] = Xie(s, "=");
      o === void 0 && (o = s), a = a === void 0 ? null : [
        "comma",
        "separator",
        "bracket-separator"
      ].includes(e.arrayFormat) ? a : bc(a, e), n(bc(o, e), a, r);
    }
    for (const [i, s] of Object.entries(r))
      if (typeof s == "object" && s !== null)
        for (const [o, a] of Object.entries(s))
          s[o] = $B(a, e);
      else
        r[i] = $B(s, e);
    return e.sort === false ? r : (e.sort === true ? Object.keys(r).sort() : Object.keys(r).sort(e.sort)).reduce((i, s) => {
      const o = r[s];
      return i[s] = o && typeof o == "object" && !Array.isArray(o) ? Zie(o) : o, i;
    }, /* @__PURE__ */ Object.create(null));
  }
  function Yie(t, e) {
    if (!t)
      return "";
    e = {
      encode: true,
      strict: true,
      arrayFormat: "none",
      arrayFormatSeparator: ",",
      ...e
    }, Wie(e.arrayFormatSeparator);
    const n = (o) => e.skipNull && ZZe(t[o]) || e.skipEmptyString && t[o] === "", r = YZe(e), i = {};
    for (const [o, a] of Object.entries(t))
      n(o) || (i[o] = a);
    const s = Object.keys(i);
    return e.sort !== false && s.sort(e.sort), s.map((o) => {
      const a = t[o];
      return a === void 0 ? "" : a === null ? sr(o, e) : Array.isArray(a) ? a.length === 0 && e.arrayFormat === "bracket-separator" ? sr(o, e) + "[]" : a.reduce(r(o), []).join("&") : sr(o, e) + "=" + sr(a, e);
    }).filter((o) => o.length > 0).join("&");
  }
  function Gie(t, e) {
    var _a3;
    e = {
      decode: true,
      ...e
    };
    let [n, r] = Xie(t, "#");
    return n === void 0 && (n = t), {
      url: ((_a3 = n == null ? void 0 : n.split("?")) == null ? void 0 : _a3[0]) ?? "",
      query: yj(mj(t), e),
      ...e && e.parseFragmentIdentifier && r ? {
        fragmentIdentifier: bc(r, e)
      } : {}
    };
  }
  function qie(t, e) {
    e = {
      encode: true,
      strict: true,
      [hM]: true,
      ...e
    };
    const n = Hie(t.url).split("?")[0] || "", r = mj(t.url), i = {
      ...yj(r, {
        sort: false
      }),
      ...t.query
    };
    let s = Yie(i, e);
    s && (s = `?${s}`);
    let o = qZe(t.url);
    if (t.fragmentIdentifier) {
      const a = new URL(n);
      a.hash = t.fragmentIdentifier, o = e[hM] ? a.hash : `#${t.fragmentIdentifier}`;
    }
    return `${n}${s}${o}`;
  }
  function Kie(t, e, n) {
    n = {
      parseFragmentIdentifier: true,
      [hM]: false,
      ...n
    };
    const { url: r, query: i, fragmentIdentifier: s } = Gie(t, n);
    return qie({
      url: r,
      query: WZe(i, e),
      fragmentIdentifier: s
    }, n);
  }
  function KZe(t, e, n) {
    const r = Array.isArray(e) ? (i) => !e.includes(i) : (i, s) => !e(i, s);
    return Kie(t, r, n);
  }
  const JZe = Object.freeze(Object.defineProperty({
    __proto__: null,
    exclude: KZe,
    extract: mj,
    parse: yj,
    parseUrl: Gie,
    pick: Kie,
    stringify: Yie,
    stringifyUrl: qie
  }, Symbol.toStringTag, {
    value: "Module"
  })), AB = (t) => {
    const e = t.url.split(":")[1];
    return `${`${t.name.trim().replace(/\s/g, "-").toLowerCase()}-`}${e}?docType=${t.type}`;
  }, Jie = (t) => Object.keys(ws).includes(t), eHe = (t) => {
    const e = t.pathname.slice(1);
    if (Yh(e))
      return {
        url: e,
        type: "essay"
      };
    const { docUrl: n, docType: r } = JZe.parse(t.pathname.slice(1));
    return typeof n != "string" || typeof r != "string" ? null : typeof n == "string" && !Yh(n) ? (alert(`Invalid Automerge URL in URL: ${n}`), null) : typeof r == "string" && !Jie(r) ? (alert(`Invalid doc type in URL: ${r}`), null) : {
      url: n,
      type: r
    };
  }, tHe = (t) => {
    const e = t.pathname.match(/^\/(?<name>.*-)?(?<docId>\w+)$/);
    if (!e)
      return;
    const { docId: n } = e.groups, r = t.searchParams.get("docType"), i = Mye(n);
    return Yh(i) ? Jie(r) ? (t.searchParams.get("patchwork") && window.location.assign(`https://patchwork.tee.inkandswitch.com/#docType=${r}&docUrl=${i}`), {
      url: i,
      type: r
    }) : (alert(`Invalid doc type in URL: ${r}`), null) : (alert(`Invalid doc id in URL: ${i}`), null);
  }, nHe = ({ folderDocWithMetadata: t, repo: e }) => {
    const n = BZe(), r = b.useMemo(() => tHe(n), [
      n
    ]), [i, s] = b.useState(), o = b.useMemo(() => {
      var _a3;
      if (!(!r || !r.url))
        return (_a3 = t == null ? void 0 : t.flatDocLinks) == null ? void 0 : _a3.find((l) => {
          const c = l.url === (r == null ? void 0 : r.url), u = !i || ym.isEqual(l.folderPath, i == null ? void 0 : i.folderPath);
          return c && u;
        });
    }, [
      r,
      t == null ? void 0 : t.flatDocLinks,
      i
    ]), a = (l) => {
      if (!l) {
        s(void 0), window.location.hash = "";
        return;
      }
      s(l), window.location.hash = AB(l);
    };
    return b.useEffect(() => {
      !t.flatDocLinks || !(r == null ? void 0 : r.url) || !(r == null ? void 0 : r.type) || t.flatDocLinks.find((l) => l.url === (r == null ? void 0 : r.url)) || e.find(t.rootFolderUrl).change((l) => l.docs.unshift({
        type: r == null ? void 0 : r.type,
        name: "Loading...",
        url: r == null ? void 0 : r.url
      }));
    }, [
      t,
      r,
      e
    ]), b.useEffect(() => {
      if (n && !r) {
        const l = eHe(n);
        if (!l)
          return;
        const { url: c, type: u } = l;
        c && (window.location.hash = AB({
          url: c,
          type: u,
          name: ""
        }));
      }
    }, [
      n,
      r
    ]), {
      selectedDocLink: o,
      selectDocLink: a
    };
  }, rHe = ({ selectedDoc: t, selectedDocLink: e, repo: n, selectedDocHandle: r, selectDocLink: i }) => {
    const s = b.useRef(null);
    b.useEffect(() => {
      var _a3;
      if (t === void 0 || e === void 0)
        return;
      const o = {
        url: e.url,
        fromDoc: ws[e.type].getTitle(t),
        fromLink: e.name
      };
      ((_a3 = s.current) == null ? void 0 : _a3.url) !== e.url && (s.current = o);
      const a = s.current;
      if (s.current = o, o.fromDoc === o.fromLink)
        return;
      if (o.fromLink !== (a == null ? void 0 : a.fromLink)) {
        if (e.name !== o.fromDoc && ws[e.type].setTitle) {
          if (!r.isReady)
            return;
          r.change((c) => {
            ws[e.type].setTitle(c, o.fromLink);
          });
        }
        i(e);
      } else {
        const c = e.folderPath[e.folderPath.length - 1];
        c || console.warn("expected to find a parent folder for selected doc", e.url), n.find(c).change((d) => {
          const h = d.docs.find((f) => f.url === e.url);
          h && h.name !== o.fromDoc && (h.name = o.fromDoc, i({
            ...e,
            name: o.fromDoc
          }));
        });
      }
    }, [
      e,
      n,
      r,
      t,
      i
    ]);
  };
  let fM = [], ese = [];
  (() => {
    let t = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e) => e ? parseInt(e, 36) : 1);
    for (let e = 0, n = 0; e < t.length; e++)
      (e % 2 ? ese : fM).push(n = n + t[e]);
  })();
  function iHe(t) {
    if (t < 768)
      return false;
    for (let e = 0, n = fM.length; ; ) {
      let r = e + n >> 1;
      if (t < fM[r])
        n = r;
      else if (t >= ese[r])
        e = r + 1;
      else
        return true;
      if (e == n)
        return false;
    }
  }
  function RB(t) {
    return t >= 127462 && t <= 127487;
  }
  const MB = 8205;
  function sHe(t, e, n = true, r = true) {
    return (n ? tse : oHe)(t, e, r);
  }
  function tse(t, e, n) {
    if (e == t.length)
      return e;
    e && nse(t.charCodeAt(e)) && rse(t.charCodeAt(e - 1)) && e--;
    let r = HI(t, e);
    for (e += DB(r); e < t.length; ) {
      let i = HI(t, e);
      if (r == MB || i == MB || n && iHe(i))
        e += DB(i), r = i;
      else if (RB(i)) {
        let s = 0, o = e - 2;
        for (; o >= 0 && RB(HI(t, o)); )
          s++, o -= 2;
        if (s % 2 == 0)
          break;
        e += 2;
      } else
        break;
    }
    return e;
  }
  function oHe(t, e, n) {
    for (; e > 0; ) {
      let r = tse(t, e - 2, n);
      if (r < e)
        return r;
      e--;
    }
    return 0;
  }
  function HI(t, e) {
    let n = t.charCodeAt(e);
    if (!rse(n) || e + 1 == t.length)
      return n;
    let r = t.charCodeAt(e + 1);
    return nse(r) ? (n - 55296 << 10) + (r - 56320) + 65536 : n;
  }
  function nse(t) {
    return t >= 56320 && t < 57344;
  }
  function rse(t) {
    return t >= 55296 && t < 56320;
  }
  function DB(t) {
    return t < 65536 ? 1 : 2;
  }
  let Qt = class ise {
    lineAt(e) {
      if (e < 0 || e > this.length)
        throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);
      return this.lineInner(e, false, 1, 0);
    }
    line(e) {
      if (e < 1 || e > this.lines)
        throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);
      return this.lineInner(e, true, 1, 0);
    }
    replace(e, n, r) {
      [e, n] = Jg(this, e, n);
      let i = [];
      return this.decompose(0, e, i, 2), r.length && r.decompose(0, r.length, i, 3), this.decompose(n, this.length, i, 1), lb.from(i, this.length - (n - e) + r.length);
    }
    append(e) {
      return this.replace(this.length, this.length, e);
    }
    slice(e, n = this.length) {
      [e, n] = Jg(this, e, n);
      let r = [];
      return this.decompose(e, n, r, 0), lb.from(r, n - e);
    }
    eq(e) {
      if (e == this)
        return true;
      if (e.length != this.length || e.lines != this.lines)
        return false;
      let n = this.scanIdentical(e, 1), r = this.length - this.scanIdentical(e, -1), i = new iv(this), s = new iv(e);
      for (let o = n, a = n; ; ) {
        if (i.next(o), s.next(o), o = 0, i.lineBreak != s.lineBreak || i.done != s.done || i.value != s.value)
          return false;
        if (a += i.value.length, i.done || a >= r)
          return true;
      }
    }
    iter(e = 1) {
      return new iv(this, e);
    }
    iterRange(e, n = this.length) {
      return new sse(this, e, n);
    }
    iterLines(e, n) {
      let r;
      if (e == null)
        r = this.iter();
      else {
        n == null && (n = this.lines + 1);
        let i = this.line(e).from;
        r = this.iterRange(i, Math.max(i, n == this.lines + 1 ? this.length : n <= 1 ? 0 : this.line(n - 1).to));
      }
      return new ose(r);
    }
    toString() {
      return this.sliceString(0);
    }
    toJSON() {
      let e = [];
      return this.flatten(e), e;
    }
    constructor() {
    }
    static of(e) {
      if (e.length == 0)
        throw new RangeError("A document must have at least one line");
      return e.length == 1 && !e[0] ? ise.empty : e.length <= 32 ? new Ma(e) : lb.from(Ma.split(e, []));
    }
  }, Ma = class dl extends Qt {
    constructor(e, n = aHe(e)) {
      super(), this.text = e, this.length = n;
    }
    get lines() {
      return this.text.length;
    }
    get children() {
      return null;
    }
    lineInner(e, n, r, i) {
      for (let s = 0; ; s++) {
        let o = this.text[s], a = i + o.length;
        if ((n ? r : a) >= e)
          return new lHe(i, a, r, o);
        i = a + 1, r++;
      }
    }
    decompose(e, n, r, i) {
      let s = e <= 0 && n >= this.length ? this : new dl(LB(this.text, e, n), Math.min(n, this.length) - Math.max(0, e));
      if (i & 1) {
        let o = r.pop(), a = cb(s.text, o.text.slice(), 0, s.length);
        if (a.length <= 32)
          r.push(new dl(a, o.length + s.length));
        else {
          let l = a.length >> 1;
          r.push(new dl(a.slice(0, l)), new dl(a.slice(l)));
        }
      } else
        r.push(s);
    }
    replace(e, n, r) {
      if (!(r instanceof dl))
        return super.replace(e, n, r);
      [e, n] = Jg(this, e, n);
      let i = cb(this.text, cb(r.text, LB(this.text, 0, e)), n), s = this.length + r.length - (n - e);
      return i.length <= 32 ? new dl(i, s) : lb.from(dl.split(i, []), s);
    }
    sliceString(e, n = this.length, r = `
`) {
      [e, n] = Jg(this, e, n);
      let i = "";
      for (let s = 0, o = 0; s <= n && o < this.text.length; o++) {
        let a = this.text[o], l = s + a.length;
        s > e && o && (i += r), e < l && n > s && (i += a.slice(Math.max(0, e - s), n - s)), s = l + 1;
      }
      return i;
    }
    flatten(e) {
      for (let n of this.text)
        e.push(n);
    }
    scanIdentical() {
      return 0;
    }
    static split(e, n) {
      let r = [], i = -1;
      for (let s of e)
        r.push(s), i += s.length + 1, r.length == 32 && (n.push(new dl(r, i)), r = [], i = -1);
      return i > -1 && n.push(new dl(r, i)), n;
    }
  }, lb = class Rp extends Qt {
    constructor(e, n) {
      super(), this.children = e, this.length = n, this.lines = 0;
      for (let r of e)
        this.lines += r.lines;
    }
    lineInner(e, n, r, i) {
      for (let s = 0; ; s++) {
        let o = this.children[s], a = i + o.length, l = r + o.lines - 1;
        if ((n ? l : a) >= e)
          return o.lineInner(e, n, r, i);
        i = a + 1, r = l + 1;
      }
    }
    decompose(e, n, r, i) {
      for (let s = 0, o = 0; o <= n && s < this.children.length; s++) {
        let a = this.children[s], l = o + a.length;
        if (e <= l && n >= o) {
          let c = i & ((o <= e ? 1 : 0) | (l >= n ? 2 : 0));
          o >= e && l <= n && !c ? r.push(a) : a.decompose(e - o, n - o, r, c);
        }
        o = l + 1;
      }
    }
    replace(e, n, r) {
      if ([e, n] = Jg(this, e, n), r.lines < this.lines)
        for (let i = 0, s = 0; i < this.children.length; i++) {
          let o = this.children[i], a = s + o.length;
          if (e >= s && n <= a) {
            let l = o.replace(e - s, n - s, r), c = this.lines - o.lines + l.lines;
            if (l.lines < c >> 5 - 1 && l.lines > c >> 5 + 1) {
              let u = this.children.slice();
              return u[i] = l, new Rp(u, this.length - (n - e) + r.length);
            }
            return super.replace(s, a, l);
          }
          s = a + 1;
        }
      return super.replace(e, n, r);
    }
    sliceString(e, n = this.length, r = `
`) {
      [e, n] = Jg(this, e, n);
      let i = "";
      for (let s = 0, o = 0; s < this.children.length && o <= n; s++) {
        let a = this.children[s], l = o + a.length;
        o > e && s && (i += r), e < l && n > o && (i += a.sliceString(e - o, n - o, r)), o = l + 1;
      }
      return i;
    }
    flatten(e) {
      for (let n of this.children)
        n.flatten(e);
    }
    scanIdentical(e, n) {
      if (!(e instanceof Rp))
        return 0;
      let r = 0, [i, s, o, a] = n > 0 ? [
        0,
        0,
        this.children.length,
        e.children.length
      ] : [
        this.children.length - 1,
        e.children.length - 1,
        -1,
        -1
      ];
      for (; ; i += n, s += n) {
        if (i == o || s == a)
          return r;
        let l = this.children[i], c = e.children[s];
        if (l != c)
          return r + l.scanIdentical(c, n);
        r += l.length + 1;
      }
    }
    static from(e, n = e.reduce((r, i) => r + i.length + 1, -1)) {
      let r = 0;
      for (let f of e)
        r += f.lines;
      if (r < 32) {
        let f = [];
        for (let y of e)
          y.flatten(f);
        return new Ma(f, n);
      }
      let i = Math.max(32, r >> 5), s = i << 1, o = i >> 1, a = [], l = 0, c = -1, u = [];
      function d(f) {
        let y;
        if (f.lines > s && f instanceof Rp)
          for (let g of f.children)
            d(g);
        else
          f.lines > o && (l > o || !l) ? (h(), a.push(f)) : f instanceof Ma && l && (y = u[u.length - 1]) instanceof Ma && f.lines + y.lines <= 32 ? (l += f.lines, c += f.length + 1, u[u.length - 1] = new Ma(y.text.concat(f.text), y.length + 1 + f.length)) : (l + f.lines > i && h(), l += f.lines, c += f.length + 1, u.push(f));
      }
      function h() {
        l != 0 && (a.push(u.length == 1 ? u[0] : Rp.from(u, c)), c = -1, l = u.length = 0);
      }
      for (let f of e)
        d(f);
      return h(), a.length == 1 ? a[0] : new Rp(a, n);
    }
  };
  Qt.empty = new Ma([
    ""
  ], 0);
  function aHe(t) {
    let e = -1;
    for (let n of t)
      e += n.length + 1;
    return e;
  }
  function cb(t, e, n = 0, r = 1e9) {
    for (let i = 0, s = 0, o = true; s < t.length && i <= r; s++) {
      let a = t[s], l = i + a.length;
      l >= n && (l > r && (a = a.slice(0, r - i)), i < n && (a = a.slice(n - i)), o ? (e[e.length - 1] += a, o = false) : e.push(a)), i = l + 1;
    }
    return e;
  }
  function LB(t, e, n) {
    return cb(t, [
      ""
    ], e, n);
  }
  let iv = class {
    constructor(e, n = 1) {
      this.dir = n, this.done = false, this.lineBreak = false, this.value = "", this.nodes = [
        e
      ], this.offsets = [
        n > 0 ? 1 : (e instanceof Ma ? e.text.length : e.children.length) << 1
      ];
    }
    nextInner(e, n) {
      for (this.done = this.lineBreak = false; ; ) {
        let r = this.nodes.length - 1, i = this.nodes[r], s = this.offsets[r], o = s >> 1, a = i instanceof Ma ? i.text.length : i.children.length;
        if (o == (n > 0 ? a : 0)) {
          if (r == 0)
            return this.done = true, this.value = "", this;
          n > 0 && this.offsets[r - 1]++, this.nodes.pop(), this.offsets.pop();
        } else if ((s & 1) == (n > 0 ? 0 : 1)) {
          if (this.offsets[r] += n, e == 0)
            return this.lineBreak = true, this.value = `
`, this;
          e--;
        } else if (i instanceof Ma) {
          let l = i.text[o + (n < 0 ? -1 : 0)];
          if (this.offsets[r] += n, l.length > Math.max(0, e))
            return this.value = e == 0 ? l : n > 0 ? l.slice(e) : l.slice(0, l.length - e), this;
          e -= l.length;
        } else {
          let l = i.children[o + (n < 0 ? -1 : 0)];
          e > l.length ? (e -= l.length, this.offsets[r] += n) : (n < 0 && this.offsets[r]--, this.nodes.push(l), this.offsets.push(n > 0 ? 1 : (l instanceof Ma ? l.text.length : l.children.length) << 1));
        }
      }
    }
    next(e = 0) {
      return e < 0 && (this.nextInner(-e, -this.dir), e = this.value.length), this.nextInner(e, this.dir);
    }
  }, sse = class {
    constructor(e, n, r) {
      this.value = "", this.done = false, this.cursor = new iv(e, n > r ? -1 : 1), this.pos = n > r ? e.length : 0, this.from = Math.min(n, r), this.to = Math.max(n, r);
    }
    nextInner(e, n) {
      if (n < 0 ? this.pos <= this.from : this.pos >= this.to)
        return this.value = "", this.done = true, this;
      e += Math.max(0, n < 0 ? this.pos - this.to : this.from - this.pos);
      let r = n < 0 ? this.pos - this.from : this.to - this.pos;
      e > r && (e = r), r -= e;
      let { value: i } = this.cursor.next(e);
      return this.pos += (i.length + e) * n, this.value = i.length <= r ? i : n < 0 ? i.slice(i.length - r) : i.slice(0, r), this.done = !this.value, this;
    }
    next(e = 0) {
      return e < 0 ? e = Math.max(e, this.from - this.pos) : e > 0 && (e = Math.min(e, this.to - this.pos)), this.nextInner(e, this.cursor.dir);
    }
    get lineBreak() {
      return this.cursor.lineBreak && this.value != "";
    }
  }, ose = class {
    constructor(e) {
      this.inner = e, this.afterBreak = true, this.value = "", this.done = false;
    }
    next(e = 0) {
      let { done: n, lineBreak: r, value: i } = this.inner.next(e);
      return n && this.afterBreak ? (this.value = "", this.afterBreak = false) : n ? (this.done = true, this.value = "") : r ? this.afterBreak ? this.value = "" : (this.afterBreak = true, this.next()) : (this.value = i, this.afterBreak = false), this;
    }
    get lineBreak() {
      return false;
    }
  };
  typeof Symbol < "u" && (Qt.prototype[Symbol.iterator] = function() {
    return this.iter();
  }, iv.prototype[Symbol.iterator] = sse.prototype[Symbol.iterator] = ose.prototype[Symbol.iterator] = function() {
    return this;
  });
  let lHe = class {
    constructor(e, n, r, i) {
      this.from = e, this.to = n, this.number = r, this.text = i;
    }
    get length() {
      return this.to - this.from;
    }
  };
  function Jg(t, e, n) {
    return e = Math.max(0, Math.min(t.length, e)), [
      e,
      Math.max(e, Math.min(t.length, n))
    ];
  }
  function Tl(t, e, n = true, r = true) {
    return sHe(t, e, n, r);
  }
  function cHe(t) {
    return t >= 56320 && t < 57344;
  }
  function uHe(t) {
    return t >= 55296 && t < 56320;
  }
  function dHe(t, e) {
    let n = t.charCodeAt(e);
    if (!uHe(n) || e + 1 == t.length)
      return n;
    let r = t.charCodeAt(e + 1);
    return cHe(r) ? (n - 55296 << 10) + (r - 56320) + 65536 : n;
  }
  function hHe(t) {
    return t < 65536 ? 1 : 2;
  }
  const pM = /\r\n?|\n/;
  var yi = function(t) {
    return t[t.Simple = 0] = "Simple", t[t.TrackDel = 1] = "TrackDel", t[t.TrackBefore = 2] = "TrackBefore", t[t.TrackAfter = 3] = "TrackAfter", t;
  }(yi || (yi = {}));
  let sv = class ub {
    constructor(e) {
      this.sections = e;
    }
    get length() {
      let e = 0;
      for (let n = 0; n < this.sections.length; n += 2)
        e += this.sections[n];
      return e;
    }
    get newLength() {
      let e = 0;
      for (let n = 0; n < this.sections.length; n += 2) {
        let r = this.sections[n + 1];
        e += r < 0 ? this.sections[n] : r;
      }
      return e;
    }
    get empty() {
      return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0;
    }
    iterGaps(e) {
      for (let n = 0, r = 0, i = 0; n < this.sections.length; ) {
        let s = this.sections[n++], o = this.sections[n++];
        o < 0 ? (e(r, i, s), i += s) : i += o, r += s;
      }
    }
    iterChangedRanges(e, n = false) {
      gM(this, e, n);
    }
    get invertedDesc() {
      let e = [];
      for (let n = 0; n < this.sections.length; ) {
        let r = this.sections[n++], i = this.sections[n++];
        i < 0 ? e.push(r, i) : e.push(i, r);
      }
      return new ub(e);
    }
    composeDesc(e) {
      return this.empty ? e : e.empty ? this : ase(this, e);
    }
    mapDesc(e, n = false) {
      return e.empty ? this : mM(this, e, n);
    }
    mapPos(e, n = -1, r = yi.Simple) {
      let i = 0, s = 0;
      for (let o = 0; o < this.sections.length; ) {
        let a = this.sections[o++], l = this.sections[o++], c = i + a;
        if (l < 0) {
          if (c > e)
            return s + (e - i);
          s += a;
        } else {
          if (r != yi.Simple && c >= e && (r == yi.TrackDel && i < e && c > e || r == yi.TrackBefore && i < e || r == yi.TrackAfter && c > e))
            return null;
          if (c > e || c == e && n < 0 && !a)
            return e == i || n < 0 ? s : s + l;
          s += l;
        }
        i = c;
      }
      if (e > i)
        throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);
      return s;
    }
    touchesRange(e, n = e) {
      for (let r = 0, i = 0; r < this.sections.length && i <= n; ) {
        let s = this.sections[r++], o = this.sections[r++], a = i + s;
        if (o >= 0 && i <= n && a >= e)
          return i < e && a > n ? "cover" : true;
        i = a;
      }
      return false;
    }
    toString() {
      let e = "";
      for (let n = 0; n < this.sections.length; ) {
        let r = this.sections[n++], i = this.sections[n++];
        e += (e ? " " : "") + r + (i >= 0 ? ":" + i : "");
      }
      return e;
    }
    toJSON() {
      return this.sections;
    }
    static fromJSON(e) {
      if (!Array.isArray(e) || e.length % 2 || e.some((n) => typeof n != "number"))
        throw new RangeError("Invalid JSON representation of ChangeDesc");
      return new ub(e);
    }
    static create(e) {
      return new ub(e);
    }
  }, Za = class Iu extends sv {
    constructor(e, n) {
      super(e), this.inserted = n;
    }
    apply(e) {
      if (this.length != e.length)
        throw new RangeError("Applying change set to a document with the wrong length");
      return gM(this, (n, r, i, s, o) => e = e.replace(i, i + (r - n), o), false), e;
    }
    mapDesc(e, n = false) {
      return mM(this, e, n, true);
    }
    invert(e) {
      let n = this.sections.slice(), r = [];
      for (let i = 0, s = 0; i < n.length; i += 2) {
        let o = n[i], a = n[i + 1];
        if (a >= 0) {
          n[i] = a, n[i + 1] = o;
          let l = i >> 1;
          for (; r.length < l; )
            r.push(Qt.empty);
          r.push(o ? e.slice(s, s + o) : Qt.empty);
        }
        s += o;
      }
      return new Iu(n, r);
    }
    compose(e) {
      return this.empty ? e : e.empty ? this : ase(this, e, true);
    }
    map(e, n = false) {
      return e.empty ? this : mM(this, e, n, true);
    }
    iterChanges(e, n = false) {
      gM(this, e, n);
    }
    get desc() {
      return sv.create(this.sections);
    }
    filter(e) {
      let n = [], r = [], i = [], s = new dO(this);
      e:
        for (let o = 0, a = 0; ; ) {
          let l = o == e.length ? 1e9 : e[o++];
          for (; a < l || a == l && s.len == 0; ) {
            if (s.done)
              break e;
            let u = Math.min(s.len, l - a);
            ci(i, u, -1);
            let d = s.ins == -1 ? -1 : s.off == 0 ? s.ins : 0;
            ci(n, u, d), d > 0 && Ju(r, n, s.text), s.forward(u), a += u;
          }
          let c = e[o++];
          for (; a < c; ) {
            if (s.done)
              break e;
            let u = Math.min(s.len, c - a);
            ci(n, u, -1), ci(i, u, s.ins == -1 ? -1 : s.off == 0 ? s.ins : 0), s.forward(u), a += u;
          }
        }
      return {
        changes: new Iu(n, r),
        filtered: sv.create(i)
      };
    }
    toJSON() {
      let e = [];
      for (let n = 0; n < this.sections.length; n += 2) {
        let r = this.sections[n], i = this.sections[n + 1];
        i < 0 ? e.push(r) : i == 0 ? e.push([
          r
        ]) : e.push([
          r
        ].concat(this.inserted[n >> 1].toJSON()));
      }
      return e;
    }
    static of(e, n, r) {
      let i = [], s = [], o = 0, a = null;
      function l(u = false) {
        if (!u && !i.length)
          return;
        o < n && ci(i, n - o, -1);
        let d = new Iu(i, s);
        a = a ? a.compose(d.map(a)) : d, i = [], s = [], o = 0;
      }
      function c(u) {
        if (Array.isArray(u))
          for (let d of u)
            c(d);
        else if (u instanceof Iu) {
          if (u.length != n)
            throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);
          l(), a = a ? a.compose(u.map(a)) : u;
        } else {
          let { from: d, to: h = d, insert: f } = u;
          if (d > h || d < 0 || h > n)
            throw new RangeError(`Invalid change range ${d} to ${h} (in doc of length ${n})`);
          let y = f ? typeof f == "string" ? Qt.of(f.split(r || pM)) : f : Qt.empty, g = y.length;
          if (d == h && g == 0)
            return;
          d < o && l(), d > o && ci(i, d - o, -1), ci(i, h - d, g), Ju(s, i, y), o = h;
        }
      }
      return c(e), l(!a), a;
    }
    static empty(e) {
      return new Iu(e ? [
        e,
        -1
      ] : [], []);
    }
    static fromJSON(e) {
      if (!Array.isArray(e))
        throw new RangeError("Invalid JSON representation of ChangeSet");
      let n = [], r = [];
      for (let i = 0; i < e.length; i++) {
        let s = e[i];
        if (typeof s == "number")
          n.push(s, -1);
        else {
          if (!Array.isArray(s) || typeof s[0] != "number" || s.some((o, a) => a && typeof o != "string"))
            throw new RangeError("Invalid JSON representation of ChangeSet");
          if (s.length == 1)
            n.push(s[0], 0);
          else {
            for (; r.length < i; )
              r.push(Qt.empty);
            r[i] = Qt.of(s.slice(1)), n.push(s[0], r[i].length);
          }
        }
      }
      return new Iu(n, r);
    }
    static createSet(e, n) {
      return new Iu(e, n);
    }
  };
  function ci(t, e, n, r = false) {
    if (e == 0 && n <= 0)
      return;
    let i = t.length - 2;
    i >= 0 && n <= 0 && n == t[i + 1] ? t[i] += e : i >= 0 && e == 0 && t[i] == 0 ? t[i + 1] += n : r ? (t[i] += e, t[i + 1] += n) : t.push(e, n);
  }
  function Ju(t, e, n) {
    if (n.length == 0)
      return;
    let r = e.length - 2 >> 1;
    if (r < t.length)
      t[t.length - 1] = t[t.length - 1].append(n);
    else {
      for (; t.length < r; )
        t.push(Qt.empty);
      t.push(n);
    }
  }
  function gM(t, e, n) {
    let r = t.inserted;
    for (let i = 0, s = 0, o = 0; o < t.sections.length; ) {
      let a = t.sections[o++], l = t.sections[o++];
      if (l < 0)
        i += a, s += a;
      else {
        let c = i, u = s, d = Qt.empty;
        for (; c += a, u += l, l && r && (d = d.append(r[o - 2 >> 1])), !(n || o == t.sections.length || t.sections[o + 1] < 0); )
          a = t.sections[o++], l = t.sections[o++];
        e(i, c, s, u, d), i = c, s = u;
      }
    }
  }
  function mM(t, e, n, r = false) {
    let i = [], s = r ? [] : null, o = new dO(t), a = new dO(e);
    for (let l = -1; ; ) {
      if (o.done && a.len || a.done && o.len)
        throw new Error("Mismatched change set lengths");
      if (o.ins == -1 && a.ins == -1) {
        let c = Math.min(o.len, a.len);
        ci(i, c, -1), o.forward(c), a.forward(c);
      } else if (a.ins >= 0 && (o.ins < 0 || l == o.i || o.off == 0 && (a.len < o.len || a.len == o.len && !n))) {
        let c = a.len;
        for (ci(i, a.ins, -1); c; ) {
          let u = Math.min(o.len, c);
          o.ins >= 0 && l < o.i && o.len <= u && (ci(i, 0, o.ins), s && Ju(s, i, o.text), l = o.i), o.forward(u), c -= u;
        }
        a.next();
      } else if (o.ins >= 0) {
        let c = 0, u = o.len;
        for (; u; )
          if (a.ins == -1) {
            let d = Math.min(u, a.len);
            c += d, u -= d, a.forward(d);
          } else if (a.ins == 0 && a.len < u)
            u -= a.len, a.next();
          else
            break;
        ci(i, c, l < o.i ? o.ins : 0), s && l < o.i && Ju(s, i, o.text), l = o.i, o.forward(o.len - u);
      } else {
        if (o.done && a.done)
          return s ? Za.createSet(i, s) : sv.create(i);
        throw new Error("Mismatched change set lengths");
      }
    }
  }
  function ase(t, e, n = false) {
    let r = [], i = n ? [] : null, s = new dO(t), o = new dO(e);
    for (let a = false; ; ) {
      if (s.done && o.done)
        return i ? Za.createSet(r, i) : sv.create(r);
      if (s.ins == 0)
        ci(r, s.len, 0, a), s.next();
      else if (o.len == 0 && !o.done)
        ci(r, 0, o.ins, a), i && Ju(i, r, o.text), o.next();
      else {
        if (s.done || o.done)
          throw new Error("Mismatched change set lengths");
        {
          let l = Math.min(s.len2, o.len), c = r.length;
          if (s.ins == -1) {
            let u = o.ins == -1 ? -1 : o.off ? 0 : o.ins;
            ci(r, l, u, a), i && u && Ju(i, r, o.text);
          } else
            o.ins == -1 ? (ci(r, s.off ? 0 : s.len, l, a), i && Ju(i, r, s.textBit(l))) : (ci(r, s.off ? 0 : s.len, o.off ? 0 : o.ins, a), i && !o.off && Ju(i, r, o.text));
          a = (s.ins > l || o.ins >= 0 && o.len > l) && (a || r.length > c), s.forward2(l), o.forward(l);
        }
      }
    }
  }
  let dO, Hw;
  dO = class {
    constructor(e) {
      this.set = e, this.i = 0, this.next();
    }
    next() {
      let { sections: e } = this.set;
      this.i < e.length ? (this.len = e[this.i++], this.ins = e[this.i++]) : (this.len = 0, this.ins = -2), this.off = 0;
    }
    get done() {
      return this.ins == -2;
    }
    get len2() {
      return this.ins < 0 ? this.len : this.ins;
    }
    get text() {
      let { inserted: e } = this.set, n = this.i - 2 >> 1;
      return n >= e.length ? Qt.empty : e[n];
    }
    textBit(e) {
      let { inserted: n } = this.set, r = this.i - 2 >> 1;
      return r >= n.length && !e ? Qt.empty : n[r].slice(this.off, e == null ? void 0 : this.off + e);
    }
    forward(e) {
      e == this.len ? this.next() : (this.len -= e, this.off += e);
    }
    forward2(e) {
      this.ins == -1 ? this.forward(e) : e == this.ins ? this.next() : (this.ins -= e, this.off += e);
    }
  };
  Hw = class yM {
    constructor(e, n, r) {
      this.from = e, this.to = n, this.flags = r;
    }
    get anchor() {
      return this.flags & 32 ? this.to : this.from;
    }
    get head() {
      return this.flags & 32 ? this.from : this.to;
    }
    get empty() {
      return this.from == this.to;
    }
    get assoc() {
      return this.flags & 8 ? -1 : this.flags & 16 ? 1 : 0;
    }
    get bidiLevel() {
      let e = this.flags & 7;
      return e == 7 ? null : e;
    }
    get goalColumn() {
      let e = this.flags >> 6;
      return e == 16777215 ? void 0 : e;
    }
    map(e, n = -1) {
      let r, i;
      return this.empty ? r = i = e.mapPos(this.from, n) : (r = e.mapPos(this.from, 1), i = e.mapPos(this.to, -1)), r == this.from && i == this.to ? this : new yM(r, i, this.flags);
    }
    extend(e, n = e) {
      if (e <= this.anchor && n >= this.anchor)
        return Ve.range(e, n);
      let r = Math.abs(e - this.anchor) > Math.abs(n - this.anchor) ? e : n;
      return Ve.range(this.anchor, r);
    }
    eq(e, n = false) {
      return this.anchor == e.anchor && this.head == e.head && (!n || !this.empty || this.assoc == e.assoc);
    }
    toJSON() {
      return {
        anchor: this.anchor,
        head: this.head
      };
    }
    static fromJSON(e) {
      if (!e || typeof e.anchor != "number" || typeof e.head != "number")
        throw new RangeError("Invalid JSON representation for SelectionRange");
      return Ve.range(e.anchor, e.head);
    }
    static create(e, n, r) {
      return new yM(e, n, r);
    }
  };
  Ve = class Qs {
    constructor(e, n) {
      this.ranges = e, this.mainIndex = n;
    }
    map(e, n = -1) {
      return e.empty ? this : Qs.create(this.ranges.map((r) => r.map(e, n)), this.mainIndex);
    }
    eq(e, n = false) {
      if (this.ranges.length != e.ranges.length || this.mainIndex != e.mainIndex)
        return false;
      for (let r = 0; r < this.ranges.length; r++)
        if (!this.ranges[r].eq(e.ranges[r], n))
          return false;
      return true;
    }
    get main() {
      return this.ranges[this.mainIndex];
    }
    asSingle() {
      return this.ranges.length == 1 ? this : new Qs([
        this.main
      ], 0);
    }
    addRange(e, n = true) {
      return Qs.create([
        e
      ].concat(this.ranges), n ? 0 : this.mainIndex + 1);
    }
    replaceRange(e, n = this.mainIndex) {
      let r = this.ranges.slice();
      return r[n] = e, Qs.create(r, this.mainIndex);
    }
    toJSON() {
      return {
        ranges: this.ranges.map((e) => e.toJSON()),
        main: this.mainIndex
      };
    }
    static fromJSON(e) {
      if (!e || !Array.isArray(e.ranges) || typeof e.main != "number" || e.main >= e.ranges.length)
        throw new RangeError("Invalid JSON representation for EditorSelection");
      return new Qs(e.ranges.map((n) => Hw.fromJSON(n)), e.main);
    }
    static single(e, n = e) {
      return new Qs([
        Qs.range(e, n)
      ], 0);
    }
    static create(e, n = 0) {
      if (e.length == 0)
        throw new RangeError("A selection needs at least one range");
      for (let r = 0, i = 0; i < e.length; i++) {
        let s = e[i];
        if (s.empty ? s.from <= r : s.from < r)
          return Qs.normalized(e.slice(), n);
        r = s.to;
      }
      return new Qs(e, n);
    }
    static cursor(e, n = 0, r, i) {
      return Hw.create(e, e, (n == 0 ? 0 : n < 0 ? 8 : 16) | (r == null ? 7 : Math.min(6, r)) | (i ?? 16777215) << 6);
    }
    static range(e, n, r, i) {
      let s = (r ?? 16777215) << 6 | (i == null ? 7 : Math.min(6, i));
      return n < e ? Hw.create(n, e, 48 | s) : Hw.create(e, n, (n > e ? 8 : 0) | s);
    }
    static normalized(e, n = 0) {
      let r = e[n];
      e.sort((i, s) => i.from - s.from), n = e.indexOf(r);
      for (let i = 1; i < e.length; i++) {
        let s = e[i], o = e[i - 1];
        if (s.empty ? s.from <= o.to : s.from < o.to) {
          let a = o.from, l = Math.max(s.to, o.to);
          i <= n && n--, e.splice(--i, 2, s.anchor > s.head ? Qs.range(l, a) : Qs.range(a, l));
        }
      }
      return new Qs(e, n);
    }
  };
  function lse(t, e) {
    for (let n of t.ranges)
      if (n.to > e)
        throw new RangeError("Selection points outside of document");
  }
  let vj = 0, Ge = class cse {
    constructor(e, n, r, i, s) {
      this.combine = e, this.compareInput = n, this.compare = r, this.isStatic = i, this.id = vj++, this.default = e([]), this.extensions = typeof s == "function" ? s(this) : s;
    }
    get reader() {
      return this;
    }
    static define(e = {}) {
      return new cse(e.combine || ((n) => n), e.compareInput || ((n, r) => n === r), e.compare || (e.combine ? (n, r) => n === r : Oj), !!e.static, e.enables);
    }
    of(e) {
      return new db([], this, 0, e);
    }
    compute(e, n) {
      if (this.isStatic)
        throw new Error("Can't compute a static facet");
      return new db(e, this, 1, n);
    }
    computeN(e, n) {
      if (this.isStatic)
        throw new Error("Can't compute a static facet");
      return new db(e, this, 2, n);
    }
    from(e, n) {
      return n || (n = (r) => r), this.compute([
        e
      ], (r) => n(r.field(e)));
    }
  };
  function Oj(t, e) {
    return t == e || t.length == e.length && t.every((n, r) => n === e[r]);
  }
  let db = class {
    constructor(e, n, r, i) {
      this.dependencies = e, this.facet = n, this.type = r, this.value = i, this.id = vj++;
    }
    dynamicSlot(e) {
      var n;
      let r = this.value, i = this.facet.compareInput, s = this.id, o = e[s] >> 1, a = this.type == 2, l = false, c = false, u = [];
      for (let d of this.dependencies)
        d == "doc" ? l = true : d == "selection" ? c = true : ((n = e[d.id]) !== null && n !== void 0 ? n : 1) & 1 || u.push(e[d.id]);
      return {
        create(d) {
          return d.values[o] = r(d), 1;
        },
        update(d, h) {
          if (l && h.docChanged || c && (h.docChanged || h.selection) || vM(d, u)) {
            let f = r(d);
            if (a ? !jB(f, d.values[o], i) : !i(f, d.values[o]))
              return d.values[o] = f, 1;
          }
          return 0;
        },
        reconfigure: (d, h) => {
          let f, y = h.config.address[s];
          if (y != null) {
            let g = oP(h, y);
            if (this.dependencies.every((O) => O instanceof Ge ? h.facet(O) === d.facet(O) : O instanceof Xd ? h.field(O, false) == d.field(O, false) : true) || (a ? jB(f = r(d), g, i) : i(f = r(d), g)))
              return d.values[o] = g, 0;
          } else
            f = r(d);
          return d.values[o] = f, 1;
        }
      };
    }
  };
  function jB(t, e, n) {
    if (t.length != e.length)
      return false;
    for (let r = 0; r < t.length; r++)
      if (!n(t[r], e[r]))
        return false;
    return true;
  }
  function vM(t, e) {
    let n = false;
    for (let r of e)
      ov(t, r) & 1 && (n = true);
    return n;
  }
  function fHe(t, e, n) {
    let r = n.map((l) => t[l.id]), i = n.map((l) => l.type), s = r.filter((l) => !(l & 1)), o = t[e.id] >> 1;
    function a(l) {
      let c = [];
      for (let u = 0; u < r.length; u++) {
        let d = oP(l, r[u]);
        if (i[u] == 2)
          for (let h of d)
            c.push(h);
        else
          c.push(d);
      }
      return e.combine(c);
    }
    return {
      create(l) {
        for (let c of r)
          ov(l, c);
        return l.values[o] = a(l), 1;
      },
      update(l, c) {
        if (!vM(l, s))
          return 0;
        let u = a(l);
        return e.compare(u, l.values[o]) ? 0 : (l.values[o] = u, 1);
      },
      reconfigure(l, c) {
        let u = vM(l, r), d = c.config.facets[e.id], h = c.facet(e);
        if (d && !u && Oj(n, d))
          return l.values[o] = h, 0;
        let f = a(l);
        return e.compare(f, h) ? (l.values[o] = h, 0) : (l.values[o] = f, 1);
      }
    };
  }
  const Yw = Ge.define({
    static: true
  });
  let Xd = class use {
    constructor(e, n, r, i, s) {
      this.id = e, this.createF = n, this.updateF = r, this.compareF = i, this.spec = s, this.provides = void 0;
    }
    static define(e) {
      let n = new use(vj++, e.create, e.update, e.compare || ((r, i) => r === i), e);
      return e.provide && (n.provides = e.provide(n)), n;
    }
    create(e) {
      let n = e.facet(Yw).find((r) => r.field == this);
      return ((n == null ? void 0 : n.create) || this.createF)(e);
    }
    slot(e) {
      let n = e[this.id] >> 1;
      return {
        create: (r) => (r.values[n] = this.create(r), 1),
        update: (r, i) => {
          let s = r.values[n], o = this.updateF(s, i);
          return this.compareF(s, o) ? 0 : (r.values[n] = o, 1);
        },
        reconfigure: (r, i) => {
          let s = r.facet(Yw), o = i.facet(Yw), a;
          return (a = s.find((l) => l.field == this)) && a != o.find((l) => l.field == this) ? (r.values[n] = a.create(r), 1) : i.config.address[this.id] != null ? (r.values[n] = i.field(this), 0) : (r.values[n] = this.create(r), 1);
        }
      };
    }
    init(e) {
      return [
        this,
        Yw.of({
          field: this,
          create: e
        })
      ];
    }
    get extension() {
      return this;
    }
  };
  const bh = {
    lowest: 4,
    low: 3,
    default: 2,
    high: 1,
    highest: 0
  };
  function n0(t) {
    return (e) => new dse(e, t);
  }
  const xS = {
    highest: n0(bh.highest),
    high: n0(bh.high),
    default: n0(bh.default),
    low: n0(bh.low),
    lowest: n0(bh.lowest)
  };
  let dse = class {
    constructor(e, n) {
      this.inner = e, this.prec = n;
    }
  }, hse = class fse {
    of(e) {
      return new OM(this, e);
    }
    reconfigure(e) {
      return fse.reconfigure.of({
        compartment: this,
        extension: e
      });
    }
    get(e) {
      return e.config.compartments.get(this);
    }
  }, OM = class {
    constructor(e, n) {
      this.compartment = e, this.inner = n;
    }
  }, NB = class pse {
    constructor(e, n, r, i, s, o) {
      for (this.base = e, this.compartments = n, this.dynamicSlots = r, this.address = i, this.staticValues = s, this.facets = o, this.statusTemplate = []; this.statusTemplate.length < r.length; )
        this.statusTemplate.push(0);
    }
    staticFacet(e) {
      let n = this.address[e.id];
      return n == null ? e.default : this.staticValues[n >> 1];
    }
    static resolve(e, n, r) {
      let i = [], s = /* @__PURE__ */ Object.create(null), o = /* @__PURE__ */ new Map();
      for (let h of pHe(e, n, o))
        h instanceof Xd ? i.push(h) : (s[h.facet.id] || (s[h.facet.id] = [])).push(h);
      let a = /* @__PURE__ */ Object.create(null), l = [], c = [];
      for (let h of i)
        a[h.id] = c.length << 1, c.push((f) => h.slot(f));
      let u = r == null ? void 0 : r.config.facets;
      for (let h in s) {
        let f = s[h], y = f[0].facet, g = u && u[h] || [];
        if (f.every((O) => O.type == 0))
          if (a[y.id] = l.length << 1 | 1, Oj(g, f))
            l.push(r.facet(y));
          else {
            let O = y.combine(f.map((S) => S.value));
            l.push(r && y.compare(O, r.facet(y)) ? r.facet(y) : O);
          }
        else {
          for (let O of f)
            O.type == 0 ? (a[O.id] = l.length << 1 | 1, l.push(O.value)) : (a[O.id] = c.length << 1, c.push((S) => O.dynamicSlot(S)));
          a[y.id] = c.length << 1, c.push((O) => fHe(O, y, f));
        }
      }
      let d = c.map((h) => h(a));
      return new pse(e, o, d, a, l, s);
    }
  };
  function pHe(t, e, n) {
    let r = [
      [],
      [],
      [],
      [],
      []
    ], i = /* @__PURE__ */ new Map();
    function s(o, a) {
      let l = i.get(o);
      if (l != null) {
        if (l <= a)
          return;
        let c = r[l].indexOf(o);
        c > -1 && r[l].splice(c, 1), o instanceof OM && n.delete(o.compartment);
      }
      if (i.set(o, a), Array.isArray(o))
        for (let c of o)
          s(c, a);
      else if (o instanceof OM) {
        if (n.has(o.compartment))
          throw new RangeError("Duplicate use of compartment in extensions");
        let c = e.get(o.compartment) || o.inner;
        n.set(o.compartment, c), s(c, a);
      } else if (o instanceof dse)
        s(o.inner, o.prec);
      else if (o instanceof Xd)
        r[a].push(o), o.provides && s(o.provides, a);
      else if (o instanceof db)
        r[a].push(o), o.facet.extensions && s(o.facet.extensions, bh.default);
      else {
        let c = o.extension;
        if (!c)
          throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
        s(c, a);
      }
    }
    return s(t, bh.default), r.reduce((o, a) => o.concat(a));
  }
  function ov(t, e) {
    if (e & 1)
      return 2;
    let n = e >> 1, r = t.status[n];
    if (r == 4)
      throw new Error("Cyclic dependency between fields and/or facets");
    if (r & 2)
      return r;
    t.status[n] = 4;
    let i = t.computeSlot(t, t.config.dynamicSlots[n]);
    return t.status[n] = 2 | i;
  }
  function oP(t, e) {
    return e & 1 ? t.config.staticValues[e >> 1] : t.values[e >> 1];
  }
  const gse = Ge.define(), SM = Ge.define({
    combine: (t) => t.some((e) => e),
    static: true
  }), mse = Ge.define({
    combine: (t) => t.length ? t[0] : void 0,
    static: true
  }), yse = Ge.define(), vse = Ge.define(), Ose = Ge.define(), Sse = Ge.define({
    combine: (t) => t.length ? t[0] : false
  });
  let Wd = class {
    constructor(e, n) {
      this.type = e, this.value = n;
    }
    static define() {
      return new gHe();
    }
  }, gHe = class {
    of(e) {
      return new Wd(this, e);
    }
  }, mHe = class {
    constructor(e) {
      this.map = e;
    }
    of(e) {
      return new kn(this, e);
    }
  }, kn = class wse {
    constructor(e, n) {
      this.type = e, this.value = n;
    }
    map(e) {
      let n = this.type.map(this.value, e);
      return n === void 0 ? void 0 : n == this.value ? this : new wse(this.type, n);
    }
    is(e) {
      return this.type == e;
    }
    static define(e = {}) {
      return new mHe(e.map || ((n) => n));
    }
    static mapEffects(e, n) {
      if (!e.length)
        return e;
      let r = [];
      for (let i of e) {
        let s = i.map(n);
        s && r.push(s);
      }
      return r;
    }
  };
  kn.reconfigure = kn.define();
  kn.appendConfig = kn.define();
  let Yo = class P0 {
    constructor(e, n, r, i, s, o) {
      this.startState = e, this.changes = n, this.selection = r, this.effects = i, this.annotations = s, this.scrollIntoView = o, this._doc = null, this._state = null, r && lse(r, n.newLength), s.some((a) => a.type == P0.time) || (this.annotations = s.concat(P0.time.of(Date.now())));
    }
    static create(e, n, r, i, s, o) {
      return new P0(e, n, r, i, s, o);
    }
    get newDoc() {
      return this._doc || (this._doc = this.changes.apply(this.startState.doc));
    }
    get newSelection() {
      return this.selection || this.startState.selection.map(this.changes);
    }
    get state() {
      return this._state || this.startState.applyTransaction(this), this._state;
    }
    annotation(e) {
      for (let n of this.annotations)
        if (n.type == e)
          return n.value;
    }
    get docChanged() {
      return !this.changes.empty;
    }
    get reconfigured() {
      return this.startState.config != this.state.config;
    }
    isUserEvent(e) {
      let n = this.annotation(P0.userEvent);
      return !!(n && (n == e || n.length > e.length && n.slice(0, e.length) == e && n[e.length] == "."));
    }
  };
  Yo.time = Wd.define();
  Yo.userEvent = Wd.define();
  Yo.addToHistory = Wd.define();
  Yo.remote = Wd.define();
  function yHe(t, e) {
    let n = [];
    for (let r = 0, i = 0; ; ) {
      let s, o;
      if (r < t.length && (i == e.length || e[i] >= t[r]))
        s = t[r++], o = t[r++];
      else if (i < e.length)
        s = e[i++], o = e[i++];
      else
        return n;
      !n.length || n[n.length - 1] < s ? n.push(s, o) : n[n.length - 1] < o && (n[n.length - 1] = o);
    }
  }
  function xse(t, e, n) {
    var r;
    let i, s, o;
    return n ? (i = e.changes, s = Za.empty(e.changes.length), o = t.changes.compose(e.changes)) : (i = e.changes.map(t.changes), s = t.changes.mapDesc(e.changes, true), o = t.changes.compose(i)), {
      changes: o,
      selection: e.selection ? e.selection.map(s) : (r = t.selection) === null || r === void 0 ? void 0 : r.map(i),
      effects: kn.mapEffects(t.effects, i).concat(kn.mapEffects(e.effects, s)),
      annotations: t.annotations.length ? t.annotations.concat(e.annotations) : e.annotations,
      scrollIntoView: t.scrollIntoView || e.scrollIntoView
    };
  }
  function wM(t, e, n) {
    let r = e.selection, i = Og(e.annotations);
    return e.userEvent && (i = i.concat(Yo.userEvent.of(e.userEvent))), {
      changes: e.changes instanceof Za ? e.changes : Za.of(e.changes || [], n, t.facet(mse)),
      selection: r && (r instanceof Ve ? r : Ve.single(r.anchor, r.head)),
      effects: Og(e.effects),
      annotations: i,
      scrollIntoView: !!e.scrollIntoView
    };
  }
  function bse(t, e, n) {
    let r = wM(t, e.length ? e[0] : {}, t.doc.length);
    e.length && e[0].filter === false && (n = false);
    for (let s = 1; s < e.length; s++) {
      e[s].filter === false && (n = false);
      let o = !!e[s].sequential;
      r = xse(r, wM(t, e[s], o ? r.changes.newLength : t.doc.length), o);
    }
    let i = Yo.create(t, r.changes, r.selection, r.effects, r.annotations, r.scrollIntoView);
    return OHe(n ? vHe(i) : i);
  }
  function vHe(t) {
    let e = t.startState, n = true;
    for (let i of e.facet(yse)) {
      let s = i(t);
      if (s === false) {
        n = false;
        break;
      }
      Array.isArray(s) && (n = n === true ? s : yHe(n, s));
    }
    if (n !== true) {
      let i, s;
      if (n === false)
        s = t.changes.invertedDesc, i = Za.empty(e.doc.length);
      else {
        let o = t.changes.filter(n);
        i = o.changes, s = o.filtered.mapDesc(o.changes).invertedDesc;
      }
      t = Yo.create(e, i, t.selection && t.selection.map(s), kn.mapEffects(t.effects, s), t.annotations, t.scrollIntoView);
    }
    let r = e.facet(vse);
    for (let i = r.length - 1; i >= 0; i--) {
      let s = r[i](t);
      s instanceof Yo ? t = s : Array.isArray(s) && s.length == 1 && s[0] instanceof Yo ? t = s[0] : t = bse(e, Og(s), false);
    }
    return t;
  }
  function OHe(t) {
    let e = t.startState, n = e.facet(Ose), r = t;
    for (let i = n.length - 1; i >= 0; i--) {
      let s = n[i](t);
      s && Object.keys(s).length && (r = xse(r, wM(e, s, t.changes.newLength), true));
    }
    return r == t ? t : Yo.create(e, t.changes, t.selection, r.effects, r.annotations, r.scrollIntoView);
  }
  const SHe = [];
  function Og(t) {
    return t == null ? SHe : Array.isArray(t) ? t : [
      t
    ];
  }
  var $c = function(t) {
    return t[t.Word = 0] = "Word", t[t.Space = 1] = "Space", t[t.Other = 2] = "Other", t;
  }($c || ($c = {}));
  const wHe = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  let xM;
  try {
    xM = new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
  } catch {
  }
  function xHe(t) {
    if (xM)
      return xM.test(t);
    for (let e = 0; e < t.length; e++) {
      let n = t[e];
      if (/\w/.test(n) || n > "\x80" && (n.toUpperCase() != n.toLowerCase() || wHe.test(n)))
        return true;
    }
    return false;
  }
  function bHe(t) {
    return (e) => {
      if (!/\S/.test(e))
        return $c.Space;
      if (xHe(e))
        return $c.Word;
      for (let n = 0; n < t.length; n++)
        if (e.indexOf(t[n]) > -1)
          return $c.Word;
      return $c.Other;
    };
  }
  let lr = class Sa {
    constructor(e, n, r, i, s, o) {
      this.config = e, this.doc = n, this.selection = r, this.values = i, this.status = e.statusTemplate.slice(), this.computeSlot = s, o && (o._state = this);
      for (let a = 0; a < this.config.dynamicSlots.length; a++)
        ov(this, a << 1);
      this.computeSlot = null;
    }
    field(e, n = true) {
      let r = this.config.address[e.id];
      if (r == null) {
        if (n)
          throw new RangeError("Field is not present in this state");
        return;
      }
      return ov(this, r), oP(this, r);
    }
    update(...e) {
      return bse(this, e, true);
    }
    applyTransaction(e) {
      let n = this.config, { base: r, compartments: i } = n;
      for (let a of e.effects)
        a.is(hse.reconfigure) ? (n && (i = /* @__PURE__ */ new Map(), n.compartments.forEach((l, c) => i.set(c, l)), n = null), i.set(a.value.compartment, a.value.extension)) : a.is(kn.reconfigure) ? (n = null, r = a.value) : a.is(kn.appendConfig) && (n = null, r = Og(r).concat(a.value));
      let s;
      n ? s = e.startState.values.slice() : (n = NB.resolve(r, i, this), s = new Sa(n, this.doc, this.selection, n.dynamicSlots.map(() => null), (l, c) => c.reconfigure(l, this), null).values);
      let o = e.startState.facet(SM) ? e.newSelection : e.newSelection.asSingle();
      new Sa(n, e.newDoc, o, s, (a, l) => l.update(a, e), e);
    }
    replaceSelection(e) {
      return typeof e == "string" && (e = this.toText(e)), this.changeByRange((n) => ({
        changes: {
          from: n.from,
          to: n.to,
          insert: e
        },
        range: Ve.cursor(n.from + e.length)
      }));
    }
    changeByRange(e) {
      let n = this.selection, r = e(n.ranges[0]), i = this.changes(r.changes), s = [
        r.range
      ], o = Og(r.effects);
      for (let a = 1; a < n.ranges.length; a++) {
        let l = e(n.ranges[a]), c = this.changes(l.changes), u = c.map(i);
        for (let h = 0; h < a; h++)
          s[h] = s[h].map(u);
        let d = i.mapDesc(c, true);
        s.push(l.range.map(d)), i = i.compose(u), o = kn.mapEffects(o, u).concat(kn.mapEffects(Og(l.effects), d));
      }
      return {
        changes: i,
        selection: Ve.create(s, n.mainIndex),
        effects: o
      };
    }
    changes(e = []) {
      return e instanceof Za ? e : Za.of(e, this.doc.length, this.facet(Sa.lineSeparator));
    }
    toText(e) {
      return Qt.of(e.split(this.facet(Sa.lineSeparator) || pM));
    }
    sliceDoc(e = 0, n = this.doc.length) {
      return this.doc.sliceString(e, n, this.lineBreak);
    }
    facet(e) {
      let n = this.config.address[e.id];
      return n == null ? e.default : (ov(this, n), oP(this, n));
    }
    toJSON(e) {
      let n = {
        doc: this.sliceDoc(),
        selection: this.selection.toJSON()
      };
      if (e)
        for (let r in e) {
          let i = e[r];
          i instanceof Xd && this.config.address[i.id] != null && (n[r] = i.spec.toJSON(this.field(e[r]), this));
        }
      return n;
    }
    static fromJSON(e, n = {}, r) {
      if (!e || typeof e.doc != "string")
        throw new RangeError("Invalid JSON representation for EditorState");
      let i = [];
      if (r) {
        for (let s in r)
          if (Object.prototype.hasOwnProperty.call(e, s)) {
            let o = r[s], a = e[s];
            i.push(o.init((l) => o.spec.fromJSON(a, l)));
          }
      }
      return Sa.create({
        doc: e.doc,
        selection: Ve.fromJSON(e.selection),
        extensions: n.extensions ? i.concat([
          n.extensions
        ]) : i
      });
    }
    static create(e = {}) {
      let n = NB.resolve(e.extensions || [], /* @__PURE__ */ new Map()), r = e.doc instanceof Qt ? e.doc : Qt.of((e.doc || "").split(n.staticFacet(Sa.lineSeparator) || pM)), i = e.selection ? e.selection instanceof Ve ? e.selection : Ve.single(e.selection.anchor, e.selection.head) : Ve.single(0);
      return lse(i, r.length), n.staticFacet(SM) || (i = i.asSingle()), new Sa(n, r, i, n.dynamicSlots.map(() => null), (s, o) => o.create(s), null);
    }
    get tabSize() {
      return this.facet(Sa.tabSize);
    }
    get lineBreak() {
      return this.facet(Sa.lineSeparator) || `
`;
    }
    get readOnly() {
      return this.facet(Sse);
    }
    phrase(e, ...n) {
      for (let r of this.facet(Sa.phrases))
        if (Object.prototype.hasOwnProperty.call(r, e)) {
          e = r[e];
          break;
        }
      return n.length && (e = e.replace(/\$(\$|\d*)/g, (r, i) => {
        if (i == "$")
          return "$";
        let s = +(i || 1);
        return !s || s > n.length ? r : n[s - 1];
      })), e;
    }
    languageDataAt(e, n, r = -1) {
      let i = [];
      for (let s of this.facet(gse))
        for (let o of s(this, n, r))
          Object.prototype.hasOwnProperty.call(o, e) && i.push(o[e]);
      return i;
    }
    charCategorizer(e) {
      return bHe(this.languageDataAt("wordChars", e).join(""));
    }
    wordAt(e) {
      let { text: n, from: r, length: i } = this.doc.lineAt(e), s = this.charCategorizer(e), o = e - r, a = e - r;
      for (; o > 0; ) {
        let l = Tl(n, o, false);
        if (s(n.slice(l, o)) != $c.Word)
          break;
        o = l;
      }
      for (; a < i; ) {
        let l = Tl(n, a);
        if (s(n.slice(a, l)) != $c.Word)
          break;
        a = l;
      }
      return o == a ? null : Ve.range(o + r, a + r);
    }
  };
  lr.allowMultipleSelections = SM;
  lr.tabSize = Ge.define({
    combine: (t) => t.length ? t[0] : 4
  });
  lr.lineSeparator = mse;
  lr.readOnly = Sse;
  lr.phrases = Ge.define({
    compare(t, e) {
      let n = Object.keys(t), r = Object.keys(e);
      return n.length == r.length && n.every((i) => t[i] == e[i]);
    }
  });
  lr.languageData = gse;
  lr.changeFilter = yse;
  lr.transactionFilter = vse;
  lr.transactionExtender = Ose;
  hse.reconfigure = kn.define();
  function kHe(t, e, n = {}) {
    let r = {};
    for (let i of t)
      for (let s of Object.keys(i)) {
        let o = i[s], a = r[s];
        if (a === void 0)
          r[s] = o;
        else if (!(a === o || o === void 0))
          if (Object.hasOwnProperty.call(n, s))
            r[s] = n[s](a, o);
          else
            throw new Error("Config merge conflict for field " + s);
      }
    for (let i in e)
      r[i] === void 0 && (r[i] = e[i]);
    return r;
  }
  let uf = class {
    eq(e) {
      return this == e;
    }
    range(e, n = e) {
      return bM.create(e, n, this);
    }
  };
  uf.prototype.startSide = uf.prototype.endSide = 0;
  uf.prototype.point = false;
  uf.prototype.mapMode = yi.TrackDel;
  let bM = class kse {
    constructor(e, n, r) {
      this.from = e, this.to = n, this.value = r;
    }
    static create(e, n, r) {
      return new kse(e, n, r);
    }
  };
  function kM(t, e) {
    return t.from - e.from || t.value.startSide - e.value.startSide;
  }
  let PHe = class Pse {
    constructor(e, n, r, i) {
      this.from = e, this.to = n, this.value = r, this.maxPoint = i;
    }
    get length() {
      return this.to[this.to.length - 1];
    }
    findIndex(e, n, r, i = 0) {
      let s = r ? this.to : this.from;
      for (let o = i, a = s.length; ; ) {
        if (o == a)
          return o;
        let l = o + a >> 1, c = s[l] - e || (r ? this.value[l].endSide : this.value[l].startSide) - n;
        if (l == o)
          return c >= 0 ? o : a;
        c >= 0 ? a = l : o = l + 1;
      }
    }
    between(e, n, r, i) {
      for (let s = this.findIndex(n, -1e9, true), o = this.findIndex(r, 1e9, false, s); s < o; s++)
        if (i(this.from[s] + e, this.to[s] + e, this.value[s]) === false)
          return false;
    }
    map(e, n) {
      let r = [], i = [], s = [], o = -1, a = -1;
      for (let l = 0; l < this.value.length; l++) {
        let c = this.value[l], u = this.from[l] + e, d = this.to[l] + e, h, f;
        if (u == d) {
          let y = n.mapPos(u, c.startSide, c.mapMode);
          if (y == null || (h = f = y, c.startSide != c.endSide && (f = n.mapPos(u, c.endSide), f < h)))
            continue;
        } else if (h = n.mapPos(u, c.startSide), f = n.mapPos(d, c.endSide), h > f || h == f && c.startSide > 0 && c.endSide <= 0)
          continue;
        (f - h || c.endSide - c.startSide) < 0 || (o < 0 && (o = h), c.point && (a = Math.max(a, f - h)), r.push(c), i.push(h - o), s.push(f - o));
      }
      return {
        mapped: r.length ? new Pse(i, s, r, a) : null,
        pos: o
      };
    }
  }, Pi = class yc {
    constructor(e, n, r, i) {
      this.chunkPos = e, this.chunk = n, this.nextLayer = r, this.maxPoint = i;
    }
    static create(e, n, r, i) {
      return new yc(e, n, r, i);
    }
    get length() {
      let e = this.chunk.length - 1;
      return e < 0 ? 0 : Math.max(this.chunkEnd(e), this.nextLayer.length);
    }
    get size() {
      if (this.isEmpty)
        return 0;
      let e = this.nextLayer.size;
      for (let n of this.chunk)
        e += n.value.length;
      return e;
    }
    chunkEnd(e) {
      return this.chunkPos[e] + this.chunk[e].length;
    }
    update(e) {
      let { add: n = [], sort: r = false, filterFrom: i = 0, filterTo: s = this.length } = e, o = e.filter;
      if (n.length == 0 && !o)
        return this;
      if (r && (n = n.slice().sort(kM)), this.isEmpty)
        return n.length ? yc.of(n) : this;
      let a = new _se(this, null, -1).goto(0), l = 0, c = [], u = new PM();
      for (; a.value || l < n.length; )
        if (l < n.length && (a.from - n[l].from || a.startSide - n[l].value.startSide) >= 0) {
          let d = n[l++];
          u.addInner(d.from, d.to, d.value) || c.push(d);
        } else
          a.rangeIndex == 1 && a.chunkIndex < this.chunk.length && (l == n.length || this.chunkEnd(a.chunkIndex) < n[l].from) && (!o || i > this.chunkEnd(a.chunkIndex) || s < this.chunkPos[a.chunkIndex]) && u.addChunk(this.chunkPos[a.chunkIndex], this.chunk[a.chunkIndex]) ? a.nextChunk() : ((!o || i > a.to || s < a.from || o(a.from, a.to, a.value)) && (u.addInner(a.from, a.to, a.value) || c.push(bM.create(a.from, a.to, a.value))), a.next());
      return u.finishInner(this.nextLayer.isEmpty && !c.length ? yc.empty : this.nextLayer.update({
        add: c,
        filter: o,
        filterFrom: i,
        filterTo: s
      }));
    }
    map(e) {
      if (e.empty || this.isEmpty)
        return this;
      let n = [], r = [], i = -1;
      for (let o = 0; o < this.chunk.length; o++) {
        let a = this.chunkPos[o], l = this.chunk[o], c = e.touchesRange(a, a + l.length);
        if (c === false)
          i = Math.max(i, l.maxPoint), n.push(l), r.push(e.mapPos(a));
        else if (c === true) {
          let { mapped: u, pos: d } = l.map(a, e);
          u && (i = Math.max(i, u.maxPoint), n.push(u), r.push(d));
        }
      }
      let s = this.nextLayer.map(e);
      return n.length == 0 ? s : new yc(r, n, s || yc.empty, i);
    }
    between(e, n, r) {
      if (!this.isEmpty) {
        for (let i = 0; i < this.chunk.length; i++) {
          let s = this.chunkPos[i], o = this.chunk[i];
          if (n >= s && e <= s + o.length && o.between(s, e - s, n - s, r) === false)
            return;
        }
        this.nextLayer.between(e, n, r);
      }
    }
    iter(e = 0) {
      return CM.from([
        this
      ]).goto(e);
    }
    get isEmpty() {
      return this.nextLayer == this;
    }
    static iter(e, n = 0) {
      return CM.from(e).goto(n);
    }
    static compare(e, n, r, i, s = -1) {
      let o = e.filter((d) => d.maxPoint > 0 || !d.isEmpty && d.maxPoint >= s), a = n.filter((d) => d.maxPoint > 0 || !d.isEmpty && d.maxPoint >= s), l = QB(o, a, r), c = new r0(o, l, s), u = new r0(a, l, s);
      r.iterGaps((d, h, f) => zB(c, d, u, h, f, i)), r.empty && r.length == 0 && zB(c, 0, u, 0, 0, i);
    }
    static eq(e, n, r = 0, i) {
      i == null && (i = 1e9 - 1);
      let s = e.filter((u) => !u.isEmpty && n.indexOf(u) < 0), o = n.filter((u) => !u.isEmpty && e.indexOf(u) < 0);
      if (s.length != o.length)
        return false;
      if (!s.length)
        return true;
      let a = QB(s, o), l = new r0(s, a, 0).goto(r), c = new r0(o, a, 0).goto(r);
      for (; ; ) {
        if (l.to != c.to || !_M(l.active, c.active) || l.point && (!c.point || !l.point.eq(c.point)))
          return false;
        if (l.to > i)
          return true;
        l.next(), c.next();
      }
    }
    static spans(e, n, r, i, s = -1) {
      let o = new r0(e, null, s).goto(n), a = n, l = o.openStart;
      for (; ; ) {
        let c = Math.min(o.to, r);
        if (o.point) {
          let u = o.activeForPoint(o.to), d = o.pointFrom < n ? u.length + 1 : o.point.startSide < 0 ? u.length : Math.min(u.length, l);
          i.point(a, c, o.point, u, d, o.pointRank), l = Math.min(o.openEnd(c), u.length);
        } else
          c > a && (i.span(a, c, o.active, l), l = o.openEnd(c));
        if (o.to > r)
          return l + (o.point && o.to > r ? 1 : 0);
        a = o.to, o.next();
      }
    }
    static of(e, n = false) {
      let r = new PM();
      for (let i of e instanceof bM ? [
        e
      ] : n ? CHe(e) : e)
        r.add(i.from, i.to, i.value);
      return r.finish();
    }
    static join(e) {
      if (!e.length)
        return yc.empty;
      let n = e[e.length - 1];
      for (let r = e.length - 2; r >= 0; r--)
        for (let i = e[r]; i != yc.empty; i = i.nextLayer)
          n = new yc(i.chunkPos, i.chunk, n, Math.max(i.maxPoint, n.maxPoint));
      return n;
    }
  };
  Pi.empty = new Pi([], [], null, -1);
  function CHe(t) {
    if (t.length > 1)
      for (let e = t[0], n = 1; n < t.length; n++) {
        let r = t[n];
        if (kM(e, r) > 0)
          return t.slice().sort(kM);
        e = r;
      }
    return t;
  }
  Pi.empty.nextLayer = Pi.empty;
  let PM = class Cse {
    finishChunk(e) {
      this.chunks.push(new PHe(this.from, this.to, this.value, this.maxPoint)), this.chunkPos.push(this.chunkStart), this.chunkStart = -1, this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint), this.maxPoint = -1, e && (this.from = [], this.to = [], this.value = []);
    }
    constructor() {
      this.chunks = [], this.chunkPos = [], this.chunkStart = -1, this.last = null, this.lastFrom = -1e9, this.lastTo = -1e9, this.from = [], this.to = [], this.value = [], this.maxPoint = -1, this.setMaxPoint = -1, this.nextLayer = null;
    }
    add(e, n, r) {
      this.addInner(e, n, r) || (this.nextLayer || (this.nextLayer = new Cse())).add(e, n, r);
    }
    addInner(e, n, r) {
      let i = e - this.lastTo || r.startSide - this.last.endSide;
      if (i <= 0 && (e - this.lastFrom || r.startSide - this.last.startSide) < 0)
        throw new Error("Ranges must be added sorted by `from` position and `startSide`");
      return i < 0 ? false : (this.from.length == 250 && this.finishChunk(true), this.chunkStart < 0 && (this.chunkStart = e), this.from.push(e - this.chunkStart), this.to.push(n - this.chunkStart), this.last = r, this.lastFrom = e, this.lastTo = n, this.value.push(r), r.point && (this.maxPoint = Math.max(this.maxPoint, n - e)), true);
    }
    addChunk(e, n) {
      if ((e - this.lastTo || n.value[0].startSide - this.last.endSide) < 0)
        return false;
      this.from.length && this.finishChunk(true), this.setMaxPoint = Math.max(this.setMaxPoint, n.maxPoint), this.chunks.push(n), this.chunkPos.push(e);
      let r = n.value.length - 1;
      return this.last = n.value[r], this.lastFrom = n.from[r] + e, this.lastTo = n.to[r] + e, true;
    }
    finish() {
      return this.finishInner(Pi.empty);
    }
    finishInner(e) {
      if (this.from.length && this.finishChunk(false), this.chunks.length == 0)
        return e;
      let n = Pi.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(e) : e, this.setMaxPoint);
      return this.from = null, n;
    }
  };
  function QB(t, e, n) {
    let r = /* @__PURE__ */ new Map();
    for (let s of t)
      for (let o = 0; o < s.chunk.length; o++)
        s.chunk[o].maxPoint <= 0 && r.set(s.chunk[o], s.chunkPos[o]);
    let i = /* @__PURE__ */ new Set();
    for (let s of e)
      for (let o = 0; o < s.chunk.length; o++) {
        let a = r.get(s.chunk[o]);
        a != null && (n ? n.mapPos(a) : a) == s.chunkPos[o] && !(n == null ? void 0 : n.touchesRange(a, a + s.chunk[o].length)) && i.add(s.chunk[o]);
      }
    return i;
  }
  let _se = class {
    constructor(e, n, r, i = 0) {
      this.layer = e, this.skip = n, this.minPoint = r, this.rank = i;
    }
    get startSide() {
      return this.value ? this.value.startSide : 0;
    }
    get endSide() {
      return this.value ? this.value.endSide : 0;
    }
    goto(e, n = -1e9) {
      return this.chunkIndex = this.rangeIndex = 0, this.gotoInner(e, n, false), this;
    }
    gotoInner(e, n, r) {
      for (; this.chunkIndex < this.layer.chunk.length; ) {
        let i = this.layer.chunk[this.chunkIndex];
        if (!(this.skip && this.skip.has(i) || this.layer.chunkEnd(this.chunkIndex) < e || i.maxPoint < this.minPoint))
          break;
        this.chunkIndex++, r = false;
      }
      if (this.chunkIndex < this.layer.chunk.length) {
        let i = this.layer.chunk[this.chunkIndex].findIndex(e - this.layer.chunkPos[this.chunkIndex], n, true);
        (!r || this.rangeIndex < i) && this.setRangeIndex(i);
      }
      this.next();
    }
    forward(e, n) {
      (this.to - e || this.endSide - n) < 0 && this.gotoInner(e, n, true);
    }
    next() {
      for (; ; )
        if (this.chunkIndex == this.layer.chunk.length) {
          this.from = this.to = 1e9, this.value = null;
          break;
        } else {
          let e = this.layer.chunkPos[this.chunkIndex], n = this.layer.chunk[this.chunkIndex], r = e + n.from[this.rangeIndex];
          if (this.from = r, this.to = e + n.to[this.rangeIndex], this.value = n.value[this.rangeIndex], this.setRangeIndex(this.rangeIndex + 1), this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
            break;
        }
    }
    setRangeIndex(e) {
      if (e == this.layer.chunk[this.chunkIndex].value.length) {
        if (this.chunkIndex++, this.skip)
          for (; this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]); )
            this.chunkIndex++;
        this.rangeIndex = 0;
      } else
        this.rangeIndex = e;
    }
    nextChunk() {
      this.chunkIndex++, this.rangeIndex = 0, this.next();
    }
    compare(e) {
      return this.from - e.from || this.startSide - e.startSide || this.rank - e.rank || this.to - e.to || this.endSide - e.endSide;
    }
  }, CM = class Tse {
    constructor(e) {
      this.heap = e;
    }
    static from(e, n = null, r = -1) {
      let i = [];
      for (let s = 0; s < e.length; s++)
        for (let o = e[s]; !o.isEmpty; o = o.nextLayer)
          o.maxPoint >= r && i.push(new _se(o, n, r, s));
      return i.length == 1 ? i[0] : new Tse(i);
    }
    get startSide() {
      return this.value ? this.value.startSide : 0;
    }
    goto(e, n = -1e9) {
      for (let r of this.heap)
        r.goto(e, n);
      for (let r = this.heap.length >> 1; r >= 0; r--)
        YI(this.heap, r);
      return this.next(), this;
    }
    forward(e, n) {
      for (let r of this.heap)
        r.forward(e, n);
      for (let r = this.heap.length >> 1; r >= 0; r--)
        YI(this.heap, r);
      (this.to - e || this.value.endSide - n) < 0 && this.next();
    }
    next() {
      if (this.heap.length == 0)
        this.from = this.to = 1e9, this.value = null, this.rank = -1;
      else {
        let e = this.heap[0];
        this.from = e.from, this.to = e.to, this.value = e.value, this.rank = e.rank, e.value && e.next(), YI(this.heap, 0);
      }
    }
  };
  function YI(t, e) {
    for (let n = t[e]; ; ) {
      let r = (e << 1) + 1;
      if (r >= t.length)
        break;
      let i = t[r];
      if (r + 1 < t.length && i.compare(t[r + 1]) >= 0 && (i = t[r + 1], r++), n.compare(i) < 0)
        break;
      t[r] = n, t[e] = i, e = r;
    }
  }
  let r0 = class {
    constructor(e, n, r) {
      this.minPoint = r, this.active = [], this.activeTo = [], this.activeRank = [], this.minActive = -1, this.point = null, this.pointFrom = 0, this.pointRank = 0, this.to = -1e9, this.endSide = 0, this.openStart = -1, this.cursor = CM.from(e, n, r);
    }
    goto(e, n = -1e9) {
      return this.cursor.goto(e, n), this.active.length = this.activeTo.length = this.activeRank.length = 0, this.minActive = -1, this.to = e, this.endSide = n, this.openStart = -1, this.next(), this;
    }
    forward(e, n) {
      for (; this.minActive > -1 && (this.activeTo[this.minActive] - e || this.active[this.minActive].endSide - n) < 0; )
        this.removeActive(this.minActive);
      this.cursor.forward(e, n);
    }
    removeActive(e) {
      Gw(this.active, e), Gw(this.activeTo, e), Gw(this.activeRank, e), this.minActive = FB(this.active, this.activeTo);
    }
    addActive(e) {
      let n = 0, { value: r, to: i, rank: s } = this.cursor;
      for (; n < this.activeRank.length && (s - this.activeRank[n] || i - this.activeTo[n]) > 0; )
        n++;
      qw(this.active, n, r), qw(this.activeTo, n, i), qw(this.activeRank, n, s), e && qw(e, n, this.cursor.from), this.minActive = FB(this.active, this.activeTo);
    }
    next() {
      let e = this.to, n = this.point;
      this.point = null;
      let r = this.openStart < 0 ? [] : null;
      for (; ; ) {
        let i = this.minActive;
        if (i > -1 && (this.activeTo[i] - this.cursor.from || this.active[i].endSide - this.cursor.startSide) < 0) {
          if (this.activeTo[i] > e) {
            this.to = this.activeTo[i], this.endSide = this.active[i].endSide;
            break;
          }
          this.removeActive(i), r && Gw(r, i);
        } else if (this.cursor.value)
          if (this.cursor.from > e) {
            this.to = this.cursor.from, this.endSide = this.cursor.startSide;
            break;
          } else {
            let s = this.cursor.value;
            if (!s.point)
              this.addActive(r), this.cursor.next();
            else if (n && this.cursor.to == this.to && this.cursor.from < this.cursor.to)
              this.cursor.next();
            else {
              this.point = s, this.pointFrom = this.cursor.from, this.pointRank = this.cursor.rank, this.to = this.cursor.to, this.endSide = s.endSide, this.cursor.next(), this.forward(this.to, this.endSide);
              break;
            }
          }
        else {
          this.to = this.endSide = 1e9;
          break;
        }
      }
      if (r) {
        this.openStart = 0;
        for (let i = r.length - 1; i >= 0 && r[i] < e; i--)
          this.openStart++;
      }
    }
    activeForPoint(e) {
      if (!this.active.length)
        return this.active;
      let n = [];
      for (let r = this.active.length - 1; r >= 0 && !(this.activeRank[r] < this.pointRank); r--)
        (this.activeTo[r] > e || this.activeTo[r] == e && this.active[r].endSide >= this.point.endSide) && n.push(this.active[r]);
      return n.reverse();
    }
    openEnd(e) {
      let n = 0;
      for (let r = this.activeTo.length - 1; r >= 0 && this.activeTo[r] > e; r--)
        n++;
      return n;
    }
  };
  function zB(t, e, n, r, i, s) {
    t.goto(e), n.goto(r);
    let o = r + i, a = r, l = r - e;
    for (; ; ) {
      let c = t.to + l - n.to, u = c || t.endSide - n.endSide, d = u < 0 ? t.to + l : n.to, h = Math.min(d, o);
      if (t.point || n.point ? t.point && n.point && (t.point == n.point || t.point.eq(n.point)) && _M(t.activeForPoint(t.to), n.activeForPoint(n.to)) || s.comparePoint(a, h, t.point, n.point) : h > a && !_M(t.active, n.active) && s.compareRange(a, h, t.active, n.active), d > o)
        break;
      (c || t.openEnd != n.openEnd) && s.boundChange && s.boundChange(d), a = d, u <= 0 && t.next(), u >= 0 && n.next();
    }
  }
  function _M(t, e) {
    if (t.length != e.length)
      return false;
    for (let n = 0; n < t.length; n++)
      if (t[n] != e[n] && !t[n].eq(e[n]))
        return false;
    return true;
  }
  function Gw(t, e) {
    for (let n = e, r = t.length - 1; n < r; n++)
      t[n] = t[n + 1];
    t.pop();
  }
  function qw(t, e, n) {
    for (let r = t.length - 1; r >= e; r--)
      t[r + 1] = t[r];
    t[e] = n;
  }
  function FB(t, e) {
    let n = -1, r = 1e9;
    for (let i = 0; i < e.length; i++)
      (e[i] - r || t[i].endSide - t[n].endSide) < 0 && (n = i, r = e[i]);
    return n;
  }
  function em(t, e, n = t.length) {
    let r = 0;
    for (let i = 0; i < n && i < t.length; )
      t.charCodeAt(i) == 9 ? (r += e - r % e, i++) : (r++, i = Tl(t, i));
    return r;
  }
  function _He(t, e, n, r) {
    for (let i = 0, s = 0; ; ) {
      if (s >= e)
        return i;
      if (i == t.length)
        break;
      s += t.charCodeAt(i) == 9 ? n - s % n : 1, i = Tl(t, i);
    }
    return r === true ? -1 : t.length;
  }
  const TM = "\u037C", BB = typeof Symbol > "u" ? "__" + TM : Symbol.for(TM), EM = typeof Symbol > "u" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet"), UB = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : {};
  class Ed {
    constructor(e, n) {
      this.rules = [];
      let { finish: r } = n || {};
      function i(o) {
        return /^@/.test(o) ? [
          o
        ] : o.split(/,\s*/);
      }
      function s(o, a, l, c) {
        let u = [], d = /^@(\w+)\b/.exec(o[0]), h = d && d[1] == "keyframes";
        if (d && a == null)
          return l.push(o[0] + ";");
        for (let f in a) {
          let y = a[f];
          if (/&/.test(f))
            s(f.split(/,\s*/).map((g) => o.map((O) => g.replace(/&/, O))).reduce((g, O) => g.concat(O)), y, l);
          else if (y && typeof y == "object") {
            if (!d)
              throw new RangeError("The value of a property (" + f + ") should be a primitive value.");
            s(i(f), y, u, h);
          } else
            y != null && u.push(f.replace(/_.*/, "").replace(/[A-Z]/g, (g) => "-" + g.toLowerCase()) + ": " + y + ";");
        }
        (u.length || h) && l.push((r && !d && !c ? o.map(r) : o).join(", ") + " {" + u.join(" ") + "}");
      }
      for (let o in e)
        s(i(o), e[o], this.rules);
    }
    getRules() {
      return this.rules.join(`
`);
    }
    static newName() {
      let e = UB[BB] || 1;
      return UB[BB] = e + 1, TM + e.toString(36);
    }
    static mount(e, n, r) {
      let i = e[EM], s = r && r.nonce;
      i ? s && i.setNonce(s) : i = new THe(e, s), i.mount(Array.isArray(n) ? n : [
        n
      ], e);
    }
  }
  let VB = /* @__PURE__ */ new Map();
  class THe {
    constructor(e, n) {
      let r = e.ownerDocument || e, i = r.defaultView;
      if (!e.head && e.adoptedStyleSheets && i.CSSStyleSheet) {
        let s = VB.get(r);
        if (s)
          return e[EM] = s;
        this.sheet = new i.CSSStyleSheet(), VB.set(r, this);
      } else
        this.styleTag = r.createElement("style"), n && this.styleTag.setAttribute("nonce", n);
      this.modules = [], e[EM] = this;
    }
    mount(e, n) {
      let r = this.sheet, i = 0, s = 0;
      for (let o = 0; o < e.length; o++) {
        let a = e[o], l = this.modules.indexOf(a);
        if (l < s && l > -1 && (this.modules.splice(l, 1), s--, l = -1), l == -1) {
          if (this.modules.splice(s++, 0, a), r)
            for (let c = 0; c < a.rules.length; c++)
              r.insertRule(a.rules[c], i++);
        } else {
          for (; s < l; )
            i += this.modules[s++].rules.length;
          i += a.rules.length, s++;
        }
      }
      if (r)
        n.adoptedStyleSheets.indexOf(this.sheet) < 0 && (n.adoptedStyleSheets = [
          this.sheet,
          ...n.adoptedStyleSheets
        ]);
      else {
        let o = "";
        for (let l = 0; l < this.modules.length; l++)
          o += this.modules[l].getRules() + `
`;
        this.styleTag.textContent = o;
        let a = n.head || n;
        this.styleTag.parentNode != a && a.insertBefore(this.styleTag, a.firstChild);
      }
    }
    setNonce(e) {
      this.styleTag && this.styleTag.getAttribute("nonce") != e && this.styleTag.setAttribute("nonce", e);
    }
  }
  var Id = {
    8: "Backspace",
    9: "Tab",
    10: "Enter",
    12: "NumLock",
    13: "Enter",
    16: "Shift",
    17: "Control",
    18: "Alt",
    20: "CapsLock",
    27: "Escape",
    32: " ",
    33: "PageUp",
    34: "PageDown",
    35: "End",
    36: "Home",
    37: "ArrowLeft",
    38: "ArrowUp",
    39: "ArrowRight",
    40: "ArrowDown",
    44: "PrintScreen",
    45: "Insert",
    46: "Delete",
    59: ";",
    61: "=",
    91: "Meta",
    92: "Meta",
    106: "*",
    107: "+",
    108: ",",
    109: "-",
    110: ".",
    111: "/",
    144: "NumLock",
    145: "ScrollLock",
    160: "Shift",
    161: "Shift",
    162: "Control",
    163: "Control",
    164: "Alt",
    165: "Alt",
    173: "-",
    186: ";",
    187: "=",
    188: ",",
    189: "-",
    190: ".",
    191: "/",
    192: "`",
    219: "[",
    220: "\\",
    221: "]",
    222: "'"
  }, hO = {
    48: ")",
    49: "!",
    50: "@",
    51: "#",
    52: "$",
    53: "%",
    54: "^",
    55: "&",
    56: "*",
    57: "(",
    59: ":",
    61: "+",
    173: "_",
    186: ":",
    187: "+",
    188: "<",
    189: "_",
    190: ">",
    191: "?",
    192: "~",
    219: "{",
    220: "|",
    221: "}",
    222: '"'
  }, EHe = typeof navigator < "u" && /Mac/.test(navigator.platform), IHe = typeof navigator < "u" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
  for (var Ur = 0; Ur < 10; Ur++)
    Id[48 + Ur] = Id[96 + Ur] = String(Ur);
  for (var Ur = 1; Ur <= 24; Ur++)
    Id[Ur + 111] = "F" + Ur;
  for (var Ur = 65; Ur <= 90; Ur++)
    Id[Ur] = String.fromCharCode(Ur + 32), hO[Ur] = String.fromCharCode(Ur);
  for (var GI in Id)
    hO.hasOwnProperty(GI) || (hO[GI] = Id[GI]);
  function $He(t) {
    var e = EHe && t.metaKey && t.shiftKey && !t.ctrlKey && !t.altKey || IHe && t.shiftKey && t.key && t.key.length == 1 || t.key == "Unidentified", n = !e && t.key || (t.shiftKey ? hO : Id)[t.keyCode] || t.key || "Unidentified";
    return n == "Esc" && (n = "Escape"), n == "Del" && (n = "Delete"), n == "Left" && (n = "ArrowLeft"), n == "Up" && (n = "ArrowUp"), n == "Right" && (n = "ArrowRight"), n == "Down" && (n = "ArrowDown"), n;
  }
  function fO(t) {
    let e;
    return t.nodeType == 11 ? e = t.getSelection ? t : t.ownerDocument : e = t, e.getSelection();
  }
  function IM(t, e) {
    return e ? t == e || t.contains(e.nodeType != 1 ? e.parentNode : e) : false;
  }
  function hb(t, e) {
    if (!e.anchorNode)
      return false;
    try {
      return IM(t, e.anchorNode);
    } catch {
      return false;
    }
  }
  function pO(t) {
    return t.nodeType == 3 ? hf(t, 0, t.nodeValue.length).getClientRects() : t.nodeType == 1 ? t.getClientRects() : [];
  }
  function av(t, e, n, r) {
    return n ? XB(t, e, n, r, -1) || XB(t, e, n, r, 1) : false;
  }
  function df(t) {
    for (var e = 0; ; e++)
      if (t = t.previousSibling, !t)
        return e;
  }
  function aP(t) {
    return t.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName);
  }
  function XB(t, e, n, r, i) {
    for (; ; ) {
      if (t == n && e == r)
        return true;
      if (e == (i < 0 ? 0 : Ul(t))) {
        if (t.nodeName == "DIV")
          return false;
        let s = t.parentNode;
        if (!s || s.nodeType != 1)
          return false;
        e = df(t) + (i < 0 ? 0 : 1), t = s;
      } else if (t.nodeType == 1) {
        if (t = t.childNodes[e + (i < 0 ? -1 : 0)], t.nodeType == 1 && t.contentEditable == "false")
          return false;
        e = i < 0 ? Ul(t) : 0;
      } else
        return false;
    }
  }
  function Ul(t) {
    return t.nodeType == 3 ? t.nodeValue.length : t.childNodes.length;
  }
  function C2(t, e) {
    let n = e ? t.left : t.right;
    return {
      left: n,
      right: n,
      top: t.top,
      bottom: t.bottom
    };
  }
  function AHe(t) {
    let e = t.visualViewport;
    return e ? {
      left: 0,
      right: e.width,
      top: 0,
      bottom: e.height
    } : {
      left: 0,
      right: t.innerWidth,
      top: 0,
      bottom: t.innerHeight
    };
  }
  function Ese(t, e) {
    let n = e.width / t.offsetWidth, r = e.height / t.offsetHeight;
    return (n > 0.995 && n < 1.005 || !isFinite(n) || Math.abs(e.width - t.offsetWidth) < 1) && (n = 1), (r > 0.995 && r < 1.005 || !isFinite(r) || Math.abs(e.height - t.offsetHeight) < 1) && (r = 1), {
      scaleX: n,
      scaleY: r
    };
  }
  function RHe(t, e, n, r, i, s, o, a) {
    let l = t.ownerDocument, c = l.defaultView || window;
    for (let u = t, d = false; u && !d; )
      if (u.nodeType == 1) {
        let h, f = u == l.body, y = 1, g = 1;
        if (f)
          h = AHe(c);
        else {
          if (/^(fixed|sticky)$/.test(getComputedStyle(u).position) && (d = true), u.scrollHeight <= u.clientHeight && u.scrollWidth <= u.clientWidth) {
            u = u.assignedSlot || u.parentNode;
            continue;
          }
          let w = u.getBoundingClientRect();
          ({ scaleX: y, scaleY: g } = Ese(u, w)), h = {
            left: w.left,
            right: w.left + u.clientWidth * y,
            top: w.top,
            bottom: w.top + u.clientHeight * g
          };
        }
        let O = 0, S = 0;
        if (i == "nearest")
          e.top < h.top ? (S = e.top - (h.top + o), n > 0 && e.bottom > h.bottom + S && (S = e.bottom - h.bottom + o)) : e.bottom > h.bottom && (S = e.bottom - h.bottom + o, n < 0 && e.top - S < h.top && (S = e.top - (h.top + o)));
        else {
          let w = e.bottom - e.top, x = h.bottom - h.top;
          S = (i == "center" && w <= x ? e.top + w / 2 - x / 2 : i == "start" || i == "center" && n < 0 ? e.top - o : e.bottom - x + o) - h.top;
        }
        if (r == "nearest" ? e.left < h.left ? (O = e.left - (h.left + s), n > 0 && e.right > h.right + O && (O = e.right - h.right + s)) : e.right > h.right && (O = e.right - h.right + s, n < 0 && e.left < h.left + O && (O = e.left - (h.left + s))) : O = (r == "center" ? e.left + (e.right - e.left) / 2 - (h.right - h.left) / 2 : r == "start" == a ? e.left - s : e.right - (h.right - h.left) + s) - h.left, O || S)
          if (f)
            c.scrollBy(O, S);
          else {
            let w = 0, x = 0;
            if (S) {
              let P = u.scrollTop;
              u.scrollTop += S / g, x = (u.scrollTop - P) * g;
            }
            if (O) {
              let P = u.scrollLeft;
              u.scrollLeft += O / y, w = (u.scrollLeft - P) * y;
            }
            e = {
              left: e.left - w,
              top: e.top - x,
              right: e.right - w,
              bottom: e.bottom - x
            }, w && Math.abs(w - O) < 1 && (r = "nearest"), x && Math.abs(x - S) < 1 && (i = "nearest");
          }
        if (f)
          break;
        (e.top < h.top || e.bottom > h.bottom || e.left < h.left || e.right > h.right) && (e = {
          left: Math.max(e.left, h.left),
          right: Math.min(e.right, h.right),
          top: Math.max(e.top, h.top),
          bottom: Math.min(e.bottom, h.bottom)
        }), u = u.assignedSlot || u.parentNode;
      } else if (u.nodeType == 11)
        u = u.host;
      else
        break;
  }
  function MHe(t) {
    let e = t.ownerDocument, n, r;
    for (let i = t.parentNode; i && !(i == e.body || n && r); )
      if (i.nodeType == 1)
        !r && i.scrollHeight > i.clientHeight && (r = i), !n && i.scrollWidth > i.clientWidth && (n = i), i = i.assignedSlot || i.parentNode;
      else if (i.nodeType == 11)
        i = i.host;
      else
        break;
    return {
      x: n,
      y: r
    };
  }
  class DHe {
    constructor() {
      this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0;
    }
    eq(e) {
      return this.anchorNode == e.anchorNode && this.anchorOffset == e.anchorOffset && this.focusNode == e.focusNode && this.focusOffset == e.focusOffset;
    }
    setRange(e) {
      let { anchorNode: n, focusNode: r } = e;
      this.set(n, Math.min(e.anchorOffset, n ? Ul(n) : 0), r, Math.min(e.focusOffset, r ? Ul(r) : 0));
    }
    set(e, n, r, i) {
      this.anchorNode = e, this.anchorOffset = n, this.focusNode = r, this.focusOffset = i;
    }
  }
  let $p = null;
  function Ise(t) {
    if (t.setActive)
      return t.setActive();
    if ($p)
      return t.focus($p);
    let e = [];
    for (let n = t; n && (e.push(n, n.scrollTop, n.scrollLeft), n != n.ownerDocument); n = n.parentNode)
      ;
    if (t.focus($p == null ? {
      get preventScroll() {
        return $p = {
          preventScroll: true
        }, true;
      }
    } : void 0), !$p) {
      $p = false;
      for (let n = 0; n < e.length; ) {
        let r = e[n++], i = e[n++], s = e[n++];
        r.scrollTop != i && (r.scrollTop = i), r.scrollLeft != s && (r.scrollLeft = s);
      }
    }
  }
  let WB;
  function hf(t, e, n = e) {
    let r = WB || (WB = document.createRange());
    return r.setEnd(t, n), r.setStart(t, e), r;
  }
  function Sg(t, e, n, r) {
    let i = {
      key: e,
      code: e,
      keyCode: n,
      which: n,
      cancelable: true
    };
    r && ({ altKey: i.altKey, ctrlKey: i.ctrlKey, shiftKey: i.shiftKey, metaKey: i.metaKey } = r);
    let s = new KeyboardEvent("keydown", i);
    s.synthetic = true, t.dispatchEvent(s);
    let o = new KeyboardEvent("keyup", i);
    return o.synthetic = true, t.dispatchEvent(o), s.defaultPrevented || o.defaultPrevented;
  }
  function LHe(t) {
    for (; t; ) {
      if (t && (t.nodeType == 9 || t.nodeType == 11 && t.host))
        return t;
      t = t.assignedSlot || t.parentNode;
    }
    return null;
  }
  function $se(t) {
    for (; t.attributes.length; )
      t.removeAttributeNode(t.attributes[0]);
  }
  function jHe(t, e) {
    let n = e.focusNode, r = e.focusOffset;
    if (!n || e.anchorNode != n || e.anchorOffset != r)
      return false;
    for (r = Math.min(r, Ul(n)); ; )
      if (r) {
        if (n.nodeType != 1)
          return false;
        let i = n.childNodes[r - 1];
        i.contentEditable == "false" ? r-- : (n = i, r = Ul(n));
      } else {
        if (n == t)
          return true;
        r = df(n), n = n.parentNode;
      }
  }
  function Ase(t) {
    return t.scrollTop > Math.max(1, t.scrollHeight - t.clientHeight - 4);
  }
  function Rse(t, e) {
    for (let n = t, r = e; ; ) {
      if (n.nodeType == 3 && r > 0)
        return {
          node: n,
          offset: r
        };
      if (n.nodeType == 1 && r > 0) {
        if (n.contentEditable == "false")
          return null;
        n = n.childNodes[r - 1], r = Ul(n);
      } else if (n.parentNode && !aP(n))
        r = df(n), n = n.parentNode;
      else
        return null;
    }
  }
  function Mse(t, e) {
    for (let n = t, r = e; ; ) {
      if (n.nodeType == 3 && r < n.nodeValue.length)
        return {
          node: n,
          offset: r
        };
      if (n.nodeType == 1 && r < n.childNodes.length) {
        if (n.contentEditable == "false")
          return null;
        n = n.childNodes[r], r = 0;
      } else if (n.parentNode && !aP(n))
        r = df(n) + 1, n = n.parentNode;
      else
        return null;
    }
  }
  class vi {
    constructor(e, n, r = true) {
      this.node = e, this.offset = n, this.precise = r;
    }
    static before(e, n) {
      return new vi(e.parentNode, df(e), n);
    }
    static after(e, n) {
      return new vi(e.parentNode, df(e) + 1, n);
    }
  }
  const Sj = [];
  class sn {
    constructor() {
      this.parent = null, this.dom = null, this.flags = 2;
    }
    get overrideDOMText() {
      return null;
    }
    get posAtStart() {
      return this.parent ? this.parent.posBefore(this) : 0;
    }
    get posAtEnd() {
      return this.posAtStart + this.length;
    }
    posBefore(e) {
      let n = this.posAtStart;
      for (let r of this.children) {
        if (r == e)
          return n;
        n += r.length + r.breakAfter;
      }
      throw new RangeError("Invalid child in posBefore");
    }
    posAfter(e) {
      return this.posBefore(e) + e.length;
    }
    sync(e, n) {
      if (this.flags & 2) {
        let r = this.dom, i = null, s;
        for (let o of this.children) {
          if (o.flags & 7) {
            if (!o.dom && (s = i ? i.nextSibling : r.firstChild)) {
              let a = sn.get(s);
              (!a || !a.parent && a.canReuseDOM(o)) && o.reuseDOM(s);
            }
            o.sync(e, n), o.flags &= -8;
          }
          if (s = i ? i.nextSibling : r.firstChild, n && !n.written && n.node == r && s != o.dom && (n.written = true), o.dom.parentNode == r)
            for (; s && s != o.dom; )
              s = ZB(s);
          else
            r.insertBefore(o.dom, s);
          i = o.dom;
        }
        for (s = i ? i.nextSibling : r.firstChild, s && n && n.node == r && (n.written = true); s; )
          s = ZB(s);
      } else if (this.flags & 1)
        for (let r of this.children)
          r.flags & 7 && (r.sync(e, n), r.flags &= -8);
    }
    reuseDOM(e) {
    }
    localPosFromDOM(e, n) {
      let r;
      if (e == this.dom)
        r = this.dom.childNodes[n];
      else {
        let i = Ul(e) == 0 ? 0 : n == 0 ? -1 : 1;
        for (; ; ) {
          let s = e.parentNode;
          if (s == this.dom)
            break;
          i == 0 && s.firstChild != s.lastChild && (e == s.firstChild ? i = -1 : i = 1), e = s;
        }
        i < 0 ? r = e : r = e.nextSibling;
      }
      if (r == this.dom.firstChild)
        return 0;
      for (; r && !sn.get(r); )
        r = r.nextSibling;
      if (!r)
        return this.length;
      for (let i = 0, s = 0; ; i++) {
        let o = this.children[i];
        if (o.dom == r)
          return s;
        s += o.length + o.breakAfter;
      }
    }
    domBoundsAround(e, n, r = 0) {
      let i = -1, s = -1, o = -1, a = -1;
      for (let l = 0, c = r, u = r; l < this.children.length; l++) {
        let d = this.children[l], h = c + d.length;
        if (c < e && h > n)
          return d.domBoundsAround(e, n, c);
        if (h >= e && i == -1 && (i = l, s = c), c > n && d.dom.parentNode == this.dom) {
          o = l, a = u;
          break;
        }
        u = h, c = h + d.breakAfter;
      }
      return {
        from: s,
        to: a < 0 ? r + this.length : a,
        startDOM: (i ? this.children[i - 1].dom.nextSibling : null) || this.dom.firstChild,
        endDOM: o < this.children.length && o >= 0 ? this.children[o].dom : null
      };
    }
    markDirty(e = false) {
      this.flags |= 2, this.markParentsDirty(e);
    }
    markParentsDirty(e) {
      for (let n = this.parent; n; n = n.parent) {
        if (e && (n.flags |= 2), n.flags & 1)
          return;
        n.flags |= 1, e = false;
      }
    }
    setParent(e) {
      this.parent != e && (this.parent = e, this.flags & 7 && this.markParentsDirty(true));
    }
    setDOM(e) {
      this.dom != e && (this.dom && (this.dom.cmView = null), this.dom = e, e.cmView = this);
    }
    get rootView() {
      for (let e = this; ; ) {
        let n = e.parent;
        if (!n)
          return e;
        e = n;
      }
    }
    replaceChildren(e, n, r = Sj) {
      this.markDirty();
      for (let i = e; i < n; i++) {
        let s = this.children[i];
        s.parent == this && r.indexOf(s) < 0 && s.destroy();
      }
      r.length < 250 ? this.children.splice(e, n - e, ...r) : this.children = [].concat(this.children.slice(0, e), r, this.children.slice(n));
      for (let i = 0; i < r.length; i++)
        r[i].setParent(this);
    }
    ignoreMutation(e) {
      return false;
    }
    ignoreEvent(e) {
      return false;
    }
    childCursor(e = this.length) {
      return new Dse(this.children, e, this.children.length);
    }
    childPos(e, n = 1) {
      return this.childCursor().findPos(e, n);
    }
    toString() {
      let e = this.constructor.name.replace("View", "");
      return e + (this.children.length ? "(" + this.children.join() + ")" : this.length ? "[" + (e == "Text" ? this.text : this.length) + "]" : "") + (this.breakAfter ? "#" : "");
    }
    static get(e) {
      return e.cmView;
    }
    get isEditable() {
      return true;
    }
    get isWidget() {
      return false;
    }
    get isHidden() {
      return false;
    }
    merge(e, n, r, i, s, o) {
      return false;
    }
    become(e) {
      return false;
    }
    canReuseDOM(e) {
      return e.constructor == this.constructor && !((this.flags | e.flags) & 8);
    }
    getSide() {
      return 0;
    }
    destroy() {
      for (let e of this.children)
        e.parent == this && e.destroy();
      this.parent = null;
    }
  }
  sn.prototype.breakAfter = 0;
  function ZB(t) {
    let e = t.nextSibling;
    return t.parentNode.removeChild(t), e;
  }
  class Dse {
    constructor(e, n, r) {
      this.children = e, this.pos = n, this.i = r, this.off = 0;
    }
    findPos(e, n = 1) {
      for (; ; ) {
        if (e > this.pos || e == this.pos && (n > 0 || this.i == 0 || this.children[this.i - 1].breakAfter))
          return this.off = e - this.pos, this;
        let r = this.children[--this.i];
        this.pos -= r.length + r.breakAfter;
      }
    }
  }
  function Lse(t, e, n, r, i, s, o, a, l) {
    let { children: c } = t, u = c.length ? c[e] : null, d = s.length ? s[s.length - 1] : null, h = d ? d.breakAfter : o;
    if (!(e == r && u && !o && !h && s.length < 2 && u.merge(n, i, s.length ? d : null, n == 0, a, l))) {
      if (r < c.length) {
        let f = c[r];
        f && (i < f.length || f.breakAfter && (d == null ? void 0 : d.breakAfter)) ? (e == r && (f = f.split(i), i = 0), !h && d && f.merge(0, i, d, true, 0, l) ? s[s.length - 1] = f : ((i || f.children.length && !f.children[0].length) && f.merge(0, i, null, false, 0, l), s.push(f))) : (f == null ? void 0 : f.breakAfter) && (d ? d.breakAfter = 1 : o = 1), r++;
      }
      for (u && (u.breakAfter = o, n > 0 && (!o && s.length && u.merge(n, u.length, s[0], false, a, 0) ? u.breakAfter = s.shift().breakAfter : (n < u.length || u.children.length && u.children[u.children.length - 1].length == 0) && u.merge(n, u.length, null, false, a, 0), e++)); e < r && s.length; )
        if (c[r - 1].become(s[s.length - 1]))
          r--, s.pop(), l = s.length ? 0 : a;
        else if (c[e].become(s[0]))
          e++, s.shift(), a = s.length ? 0 : l;
        else
          break;
      !s.length && e && r < c.length && !c[e - 1].breakAfter && c[r].merge(0, 0, c[e - 1], false, a, l) && e--, (e < r || s.length) && t.replaceChildren(e, r, s);
    }
  }
  function jse(t, e, n, r, i, s) {
    let o = t.childCursor(), { i: a, off: l } = o.findPos(n, 1), { i: c, off: u } = o.findPos(e, -1), d = e - n;
    for (let h of r)
      d += h.length;
    t.length += d, Lse(t, c, u, a, l, r, 0, i, s);
  }
  let cs = typeof navigator < "u" ? navigator : {
    userAgent: "",
    vendor: "",
    platform: ""
  }, $M = typeof document < "u" ? document : {
    documentElement: {
      style: {}
    }
  };
  const AM = /Edge\/(\d+)/.exec(cs.userAgent), Nse = /MSIE \d/.test(cs.userAgent), RM = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(cs.userAgent), _2 = !!(Nse || RM || AM), HB = !_2 && /gecko\/(\d+)/i.test(cs.userAgent), qI = !_2 && /Chrome\/(\d+)/.exec(cs.userAgent), YB = "webkitFontSmoothing" in $M.documentElement.style, Qse = !_2 && /Apple Computer/.test(cs.vendor), GB = Qse && (/Mobile\/\w+/.test(cs.userAgent) || cs.maxTouchPoints > 2);
  var Ee = {
    mac: GB || /Mac/.test(cs.platform),
    windows: /Win/.test(cs.platform),
    linux: /Linux|X11/.test(cs.platform),
    ie: _2,
    ie_version: Nse ? $M.documentMode || 6 : RM ? +RM[1] : AM ? +AM[1] : 0,
    gecko: HB,
    gecko_version: HB ? +(/Firefox\/(\d+)/.exec(cs.userAgent) || [
      0,
      0
    ])[1] : 0,
    chrome: !!qI,
    chrome_version: qI ? +qI[1] : 0,
    ios: GB,
    android: /Android\b/.test(cs.userAgent),
    webkit: YB,
    safari: Qse,
    webkit_version: YB ? +(/\bAppleWebKit\/(\d+)/.exec(cs.userAgent) || [
      0,
      0
    ])[1] : 0,
    tabSize: $M.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
  };
  const NHe = 256;
  class Ha extends sn {
    constructor(e) {
      super(), this.text = e;
    }
    get length() {
      return this.text.length;
    }
    createDOM(e) {
      this.setDOM(e || document.createTextNode(this.text));
    }
    sync(e, n) {
      this.dom || this.createDOM(), this.dom.nodeValue != this.text && (n && n.node == this.dom && (n.written = true), this.dom.nodeValue = this.text);
    }
    reuseDOM(e) {
      e.nodeType == 3 && this.createDOM(e);
    }
    merge(e, n, r) {
      return this.flags & 8 || r && (!(r instanceof Ha) || this.length - (n - e) + r.length > NHe || r.flags & 8) ? false : (this.text = this.text.slice(0, e) + (r ? r.text : "") + this.text.slice(n), this.markDirty(), true);
    }
    split(e) {
      let n = new Ha(this.text.slice(e));
      return this.text = this.text.slice(0, e), this.markDirty(), n.flags |= this.flags & 8, n;
    }
    localPosFromDOM(e, n) {
      return e == this.dom ? n : n ? this.text.length : 0;
    }
    domAtPos(e) {
      return new vi(this.dom, e);
    }
    domBoundsAround(e, n, r) {
      return {
        from: r,
        to: r + this.length,
        startDOM: this.dom,
        endDOM: this.dom.nextSibling
      };
    }
    coordsAt(e, n) {
      return QHe(this.dom, e, n);
    }
  }
  class Gc extends sn {
    constructor(e, n = [], r = 0) {
      super(), this.mark = e, this.children = n, this.length = r;
      for (let i of n)
        i.setParent(this);
    }
    setAttrs(e) {
      if ($se(e), this.mark.class && (e.className = this.mark.class), this.mark.attrs)
        for (let n in this.mark.attrs)
          e.setAttribute(n, this.mark.attrs[n]);
      return e;
    }
    canReuseDOM(e) {
      return super.canReuseDOM(e) && !((this.flags | e.flags) & 8);
    }
    reuseDOM(e) {
      e.nodeName == this.mark.tagName.toUpperCase() && (this.setDOM(e), this.flags |= 6);
    }
    sync(e, n) {
      this.dom ? this.flags & 4 && this.setAttrs(this.dom) : this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))), super.sync(e, n);
    }
    merge(e, n, r, i, s, o) {
      return r && (!(r instanceof Gc && r.mark.eq(this.mark)) || e && s <= 0 || n < this.length && o <= 0) ? false : (jse(this, e, n, r ? r.children.slice() : [], s - 1, o - 1), this.markDirty(), true);
    }
    split(e) {
      let n = [], r = 0, i = -1, s = 0;
      for (let a of this.children) {
        let l = r + a.length;
        l > e && n.push(r < e ? a.split(e - r) : a), i < 0 && r >= e && (i = s), r = l, s++;
      }
      let o = this.length - e;
      return this.length = e, i > -1 && (this.children.length = i, this.markDirty()), new Gc(this.mark, n, o);
    }
    domAtPos(e) {
      return zse(this, e);
    }
    coordsAt(e, n) {
      return Bse(this, e, n);
    }
  }
  function QHe(t, e, n) {
    let r = t.nodeValue.length;
    e > r && (e = r);
    let i = e, s = e, o = 0;
    e == 0 && n < 0 || e == r && n >= 0 ? Ee.chrome || Ee.gecko || (e ? (i--, o = 1) : s < r && (s++, o = -1)) : n < 0 ? i-- : s < r && s++;
    let a = hf(t, i, s).getClientRects();
    if (!a.length)
      return null;
    let l = a[(o ? o < 0 : n >= 0) ? 0 : a.length - 1];
    return Ee.safari && !o && l.width == 0 && (l = Array.prototype.find.call(a, (c) => c.width) || l), o ? C2(l, o < 0) : l || null;
  }
  class ed extends sn {
    static create(e, n, r) {
      return new ed(e, n, r);
    }
    constructor(e, n, r) {
      super(), this.widget = e, this.length = n, this.side = r, this.prevWidget = null;
    }
    split(e) {
      let n = ed.create(this.widget, this.length - e, this.side);
      return this.length -= e, n;
    }
    sync(e) {
      (!this.dom || !this.widget.updateDOM(this.dom, e)) && (this.dom && this.prevWidget && this.prevWidget.destroy(this.dom), this.prevWidget = null, this.setDOM(this.widget.toDOM(e)), this.widget.editable || (this.dom.contentEditable = "false"));
    }
    getSide() {
      return this.side;
    }
    merge(e, n, r, i, s, o) {
      return r && (!(r instanceof ed) || !this.widget.compare(r.widget) || e > 0 && s <= 0 || n < this.length && o <= 0) ? false : (this.length = e + (r ? r.length : 0) + (this.length - n), true);
    }
    become(e) {
      return e instanceof ed && e.side == this.side && this.widget.constructor == e.widget.constructor ? (this.widget.compare(e.widget) || this.markDirty(true), this.dom && !this.prevWidget && (this.prevWidget = this.widget), this.widget = e.widget, this.length = e.length, true) : false;
    }
    ignoreMutation() {
      return true;
    }
    ignoreEvent(e) {
      return this.widget.ignoreEvent(e);
    }
    get overrideDOMText() {
      if (this.length == 0)
        return Qt.empty;
      let e = this;
      for (; e.parent; )
        e = e.parent;
      let { view: n } = e, r = n && n.state.doc, i = this.posAtStart;
      return r ? r.slice(i, i + this.length) : Qt.empty;
    }
    domAtPos(e) {
      return (this.length ? e == 0 : this.side > 0) ? vi.before(this.dom) : vi.after(this.dom, e == this.length);
    }
    domBoundsAround() {
      return null;
    }
    coordsAt(e, n) {
      let r = this.widget.coordsAt(this.dom, e, n);
      if (r)
        return r;
      let i = this.dom.getClientRects(), s = null;
      if (!i.length)
        return null;
      let o = this.side ? this.side < 0 : e > 0;
      for (let a = o ? i.length - 1 : 0; s = i[a], !(e > 0 ? a == 0 : a == i.length - 1 || s.top < s.bottom); a += o ? -1 : 1)
        ;
      return C2(s, !o);
    }
    get isEditable() {
      return false;
    }
    get isWidget() {
      return true;
    }
    get isHidden() {
      return this.widget.isHidden;
    }
    destroy() {
      super.destroy(), this.dom && this.widget.destroy(this.dom);
    }
  }
  class tm extends sn {
    constructor(e) {
      super(), this.side = e;
    }
    get length() {
      return 0;
    }
    merge() {
      return false;
    }
    become(e) {
      return e instanceof tm && e.side == this.side;
    }
    split() {
      return new tm(this.side);
    }
    sync() {
      if (!this.dom) {
        let e = document.createElement("img");
        e.className = "cm-widgetBuffer", e.setAttribute("aria-hidden", "true"), this.setDOM(e);
      }
    }
    getSide() {
      return this.side;
    }
    domAtPos(e) {
      return this.side > 0 ? vi.before(this.dom) : vi.after(this.dom);
    }
    localPosFromDOM() {
      return 0;
    }
    domBoundsAround() {
      return null;
    }
    coordsAt(e) {
      return this.dom.getBoundingClientRect();
    }
    get overrideDOMText() {
      return Qt.empty;
    }
    get isHidden() {
      return true;
    }
  }
  Ha.prototype.children = ed.prototype.children = tm.prototype.children = Sj;
  function zse(t, e) {
    let n = t.dom, { children: r } = t, i = 0;
    for (let s = 0; i < r.length; i++) {
      let o = r[i], a = s + o.length;
      if (!(a == s && o.getSide() <= 0)) {
        if (e > s && e < a && o.dom.parentNode == n)
          return o.domAtPos(e - s);
        if (e <= s)
          break;
        s = a;
      }
    }
    for (let s = i; s > 0; s--) {
      let o = r[s - 1];
      if (o.dom.parentNode == n)
        return o.domAtPos(o.length);
    }
    for (let s = i; s < r.length; s++) {
      let o = r[s];
      if (o.dom.parentNode == n)
        return o.domAtPos(0);
    }
    return new vi(n, 0);
  }
  function Fse(t, e, n) {
    let r, { children: i } = t;
    n > 0 && e instanceof Gc && i.length && (r = i[i.length - 1]) instanceof Gc && r.mark.eq(e.mark) ? Fse(r, e.children[0], n - 1) : (i.push(e), e.setParent(t)), t.length += e.length;
  }
  function Bse(t, e, n) {
    let r = null, i = -1, s = null, o = -1;
    function a(c, u) {
      for (let d = 0, h = 0; d < c.children.length && h <= u; d++) {
        let f = c.children[d], y = h + f.length;
        y >= u && (f.children.length ? a(f, u - h) : (!s || s.isHidden && (n > 0 || FHe(s, f))) && (y > u || h == y && f.getSide() > 0) ? (s = f, o = u - h) : (h < u || h == y && f.getSide() < 0 && !f.isHidden) && (r = f, i = u - h)), h = y;
      }
    }
    a(t, e);
    let l = (n < 0 ? r : s) || r || s;
    return l ? l.coordsAt(Math.max(0, l == r ? i : o), n) : zHe(t);
  }
  function zHe(t) {
    let e = t.dom.lastChild;
    if (!e)
      return t.dom.getBoundingClientRect();
    let n = pO(e);
    return n[n.length - 1] || null;
  }
  function FHe(t, e) {
    let n = t.coordsAt(0, 1), r = e.coordsAt(0, 1);
    return n && r && r.top < n.bottom;
  }
  function MM(t, e) {
    for (let n in t)
      n == "class" && e.class ? e.class += " " + t.class : n == "style" && e.style ? e.style += ";" + t.style : e[n] = t[n];
    return e;
  }
  const qB = /* @__PURE__ */ Object.create(null);
  function lP(t, e, n) {
    if (t == e)
      return true;
    t || (t = qB), e || (e = qB);
    let r = Object.keys(t), i = Object.keys(e);
    if (r.length - (n && r.indexOf(n) > -1 ? 1 : 0) != i.length - (n && i.indexOf(n) > -1 ? 1 : 0))
      return false;
    for (let s of r)
      if (s != n && (i.indexOf(s) == -1 || t[s] !== e[s]))
        return false;
    return true;
  }
  function DM(t, e, n) {
    let r = false;
    if (e)
      for (let i in e)
        n && i in n || (r = true, i == "style" ? t.style.cssText = "" : t.removeAttribute(i));
    if (n)
      for (let i in n)
        e && e[i] == n[i] || (r = true, i == "style" ? t.style.cssText = n[i] : t.setAttribute(i, n[i]));
    return r;
  }
  function BHe(t) {
    let e = /* @__PURE__ */ Object.create(null);
    for (let n = 0; n < t.attributes.length; n++) {
      let r = t.attributes[n];
      e[r.name] = r.value;
    }
    return e;
  }
  class Yl {
    eq(e) {
      return false;
    }
    updateDOM(e, n) {
      return false;
    }
    compare(e) {
      return this == e || this.constructor == e.constructor && this.eq(e);
    }
    get estimatedHeight() {
      return -1;
    }
    get lineBreaks() {
      return 0;
    }
    ignoreEvent(e) {
      return true;
    }
    coordsAt(e, n, r) {
      return null;
    }
    get isHidden() {
      return false;
    }
    get editable() {
      return false;
    }
    destroy(e) {
    }
  }
  var Ml = function(t) {
    return t[t.Text = 0] = "Text", t[t.WidgetBefore = 1] = "WidgetBefore", t[t.WidgetAfter = 2] = "WidgetAfter", t[t.WidgetRange = 3] = "WidgetRange", t;
  }(Ml || (Ml = {}));
  class Qe extends uf {
    constructor(e, n, r, i) {
      super(), this.startSide = e, this.endSide = n, this.widget = r, this.spec = i;
    }
    get heightRelevant() {
      return false;
    }
    static mark(e) {
      return new bS(e);
    }
    static widget(e) {
      let n = Math.max(-1e4, Math.min(1e4, e.side || 0)), r = !!e.block;
      return n += r && !e.inlineOrder ? n > 0 ? 3e8 : -4e8 : n > 0 ? 1e8 : -1e8, new $d(e, n, n, r, e.widget || null, false);
    }
    static replace(e) {
      let n = !!e.block, r, i;
      if (e.isBlockGap)
        r = -5e8, i = 4e8;
      else {
        let { start: s, end: o } = Use(e, n);
        r = (s ? n ? -3e8 : -1 : 5e8) - 1, i = (o ? n ? 2e8 : 1 : -6e8) + 1;
      }
      return new $d(e, r, i, n, e.widget || null, true);
    }
    static line(e) {
      return new kS(e);
    }
    static set(e, n = false) {
      return Pi.of(e, n);
    }
    hasHeight() {
      return this.widget ? this.widget.estimatedHeight > -1 : false;
    }
  }
  Qe.none = Pi.empty;
  class bS extends Qe {
    constructor(e) {
      let { start: n, end: r } = Use(e);
      super(n ? -1 : 5e8, r ? 1 : -6e8, null, e), this.tagName = e.tagName || "span", this.class = e.class || "", this.attrs = e.attributes || null;
    }
    eq(e) {
      var n, r;
      return this == e || e instanceof bS && this.tagName == e.tagName && (this.class || ((n = this.attrs) === null || n === void 0 ? void 0 : n.class)) == (e.class || ((r = e.attrs) === null || r === void 0 ? void 0 : r.class)) && lP(this.attrs, e.attrs, "class");
    }
    range(e, n = e) {
      if (e >= n)
        throw new RangeError("Mark decorations may not be empty");
      return super.range(e, n);
    }
  }
  bS.prototype.point = false;
  class kS extends Qe {
    constructor(e) {
      super(-2e8, -2e8, null, e);
    }
    eq(e) {
      return e instanceof kS && this.spec.class == e.spec.class && lP(this.spec.attributes, e.spec.attributes);
    }
    range(e, n = e) {
      if (n != e)
        throw new RangeError("Line decoration ranges must be zero-length");
      return super.range(e, n);
    }
  }
  kS.prototype.mapMode = yi.TrackBefore;
  kS.prototype.point = true;
  class $d extends Qe {
    constructor(e, n, r, i, s, o) {
      super(n, r, s, e), this.block = i, this.isReplace = o, this.mapMode = i ? n <= 0 ? yi.TrackBefore : yi.TrackAfter : yi.TrackDel;
    }
    get type() {
      return this.startSide != this.endSide ? Ml.WidgetRange : this.startSide <= 0 ? Ml.WidgetBefore : Ml.WidgetAfter;
    }
    get heightRelevant() {
      return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);
    }
    eq(e) {
      return e instanceof $d && UHe(this.widget, e.widget) && this.block == e.block && this.startSide == e.startSide && this.endSide == e.endSide;
    }
    range(e, n = e) {
      if (this.isReplace && (e > n || e == n && this.startSide > 0 && this.endSide <= 0))
        throw new RangeError("Invalid range for replacement decoration");
      if (!this.isReplace && n != e)
        throw new RangeError("Widget decorations can only have zero-length ranges");
      return super.range(e, n);
    }
  }
  $d.prototype.point = true;
  function Use(t, e = false) {
    let { inclusiveStart: n, inclusiveEnd: r } = t;
    return n == null && (n = t.inclusive), r == null && (r = t.inclusive), {
      start: n ?? e,
      end: r ?? e
    };
  }
  function UHe(t, e) {
    return t == e || !!(t && e && t.compare(e));
  }
  function fb(t, e, n, r = 0) {
    let i = n.length - 1;
    i >= 0 && n[i] + r >= t ? n[i] = Math.max(n[i], e) : n.push(t, e);
  }
  class or extends sn {
    constructor() {
      super(...arguments), this.children = [], this.length = 0, this.prevAttrs = void 0, this.attrs = null, this.breakAfter = 0;
    }
    merge(e, n, r, i, s, o) {
      if (r) {
        if (!(r instanceof or))
          return false;
        this.dom || r.transferDOM(this);
      }
      return i && this.setDeco(r ? r.attrs : null), jse(this, e, n, r ? r.children.slice() : [], s, o), true;
    }
    split(e) {
      let n = new or();
      if (n.breakAfter = this.breakAfter, this.length == 0)
        return n;
      let { i: r, off: i } = this.childPos(e);
      i && (n.append(this.children[r].split(i), 0), this.children[r].merge(i, this.children[r].length, null, false, 0, 0), r++);
      for (let s = r; s < this.children.length; s++)
        n.append(this.children[s], 0);
      for (; r > 0 && this.children[r - 1].length == 0; )
        this.children[--r].destroy();
      return this.children.length = r, this.markDirty(), this.length = e, n;
    }
    transferDOM(e) {
      this.dom && (this.markDirty(), e.setDOM(this.dom), e.prevAttrs = this.prevAttrs === void 0 ? this.attrs : this.prevAttrs, this.prevAttrs = void 0, this.dom = null);
    }
    setDeco(e) {
      lP(this.attrs, e) || (this.dom && (this.prevAttrs = this.attrs, this.markDirty()), this.attrs = e);
    }
    append(e, n) {
      Fse(this, e, n);
    }
    addLineDeco(e) {
      let n = e.spec.attributes, r = e.spec.class;
      n && (this.attrs = MM(n, this.attrs || {})), r && (this.attrs = MM({
        class: r
      }, this.attrs || {}));
    }
    domAtPos(e) {
      return zse(this, e);
    }
    reuseDOM(e) {
      e.nodeName == "DIV" && (this.setDOM(e), this.flags |= 6);
    }
    sync(e, n) {
      var r;
      this.dom ? this.flags & 4 && ($se(this.dom), this.dom.className = "cm-line", this.prevAttrs = this.attrs ? null : void 0) : (this.setDOM(document.createElement("div")), this.dom.className = "cm-line", this.prevAttrs = this.attrs ? null : void 0), this.prevAttrs !== void 0 && (DM(this.dom, this.prevAttrs, this.attrs), this.dom.classList.add("cm-line"), this.prevAttrs = void 0), super.sync(e, n);
      let i = this.dom.lastChild;
      for (; i && sn.get(i) instanceof Gc; )
        i = i.lastChild;
      if (!i || !this.length || i.nodeName != "BR" && ((r = sn.get(i)) === null || r === void 0 ? void 0 : r.isEditable) == false && (!Ee.ios || !this.children.some((s) => s instanceof Ha))) {
        let s = document.createElement("BR");
        s.cmIgnore = true, this.dom.appendChild(s);
      }
    }
    measureTextSize() {
      if (this.children.length == 0 || this.length > 20)
        return null;
      let e = 0, n;
      for (let r of this.children) {
        if (!(r instanceof Ha) || /[^ -~]/.test(r.text))
          return null;
        let i = pO(r.dom);
        if (i.length != 1)
          return null;
        e += i[0].width, n = i[0].height;
      }
      return e ? {
        lineHeight: this.dom.getBoundingClientRect().height,
        charWidth: e / this.length,
        textHeight: n
      } : null;
    }
    coordsAt(e, n) {
      let r = Bse(this, e, n);
      if (!this.children.length && r && this.parent) {
        let { heightOracle: i } = this.parent.view.viewState, s = r.bottom - r.top;
        if (Math.abs(s - i.lineHeight) < 2 && i.textHeight < s) {
          let o = (s - i.textHeight) / 2;
          return {
            top: r.top + o,
            bottom: r.bottom - o,
            left: r.left,
            right: r.left
          };
        }
      }
      return r;
    }
    become(e) {
      return e instanceof or && this.children.length == 0 && e.children.length == 0 && lP(this.attrs, e.attrs) && this.breakAfter == e.breakAfter;
    }
    covers() {
      return true;
    }
    static find(e, n) {
      for (let r = 0, i = 0; r < e.children.length; r++) {
        let s = e.children[r], o = i + s.length;
        if (o >= n) {
          if (s instanceof or)
            return s;
          if (o > n)
            break;
        }
        i = o + s.breakAfter;
      }
      return null;
    }
  }
  class Fc extends sn {
    constructor(e, n, r) {
      super(), this.widget = e, this.length = n, this.deco = r, this.breakAfter = 0, this.prevWidget = null;
    }
    merge(e, n, r, i, s, o) {
      return r && (!(r instanceof Fc) || !this.widget.compare(r.widget) || e > 0 && s <= 0 || n < this.length && o <= 0) ? false : (this.length = e + (r ? r.length : 0) + (this.length - n), true);
    }
    domAtPos(e) {
      return e == 0 ? vi.before(this.dom) : vi.after(this.dom, e == this.length);
    }
    split(e) {
      let n = this.length - e;
      this.length = e;
      let r = new Fc(this.widget, n, this.deco);
      return r.breakAfter = this.breakAfter, r;
    }
    get children() {
      return Sj;
    }
    sync(e) {
      (!this.dom || !this.widget.updateDOM(this.dom, e)) && (this.dom && this.prevWidget && this.prevWidget.destroy(this.dom), this.prevWidget = null, this.setDOM(this.widget.toDOM(e)), this.widget.editable || (this.dom.contentEditable = "false"));
    }
    get overrideDOMText() {
      return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Qt.empty;
    }
    domBoundsAround() {
      return null;
    }
    become(e) {
      return e instanceof Fc && e.widget.constructor == this.widget.constructor ? (e.widget.compare(this.widget) || this.markDirty(true), this.dom && !this.prevWidget && (this.prevWidget = this.widget), this.widget = e.widget, this.length = e.length, this.deco = e.deco, this.breakAfter = e.breakAfter, true) : false;
    }
    ignoreMutation() {
      return true;
    }
    ignoreEvent(e) {
      return this.widget.ignoreEvent(e);
    }
    get isEditable() {
      return false;
    }
    get isWidget() {
      return true;
    }
    coordsAt(e, n) {
      let r = this.widget.coordsAt(this.dom, e, n);
      return r || (this.widget instanceof LM ? null : C2(this.dom.getBoundingClientRect(), this.length ? e == 0 : n <= 0));
    }
    destroy() {
      super.destroy(), this.dom && this.widget.destroy(this.dom);
    }
    covers(e) {
      let { startSide: n, endSide: r } = this.deco;
      return n == r ? false : e < 0 ? n < 0 : r > 0;
    }
  }
  class LM extends Yl {
    constructor(e) {
      super(), this.height = e;
    }
    toDOM() {
      let e = document.createElement("div");
      return e.className = "cm-gap", this.updateDOM(e), e;
    }
    eq(e) {
      return e.height == this.height;
    }
    updateDOM(e) {
      return e.style.height = this.height + "px", true;
    }
    get editable() {
      return true;
    }
    get estimatedHeight() {
      return this.height;
    }
    ignoreEvent() {
      return false;
    }
  }
  class lv {
    constructor(e, n, r, i) {
      this.doc = e, this.pos = n, this.end = r, this.disallowBlockEffectsFor = i, this.content = [], this.curLine = null, this.breakAtStart = 0, this.pendingBuffer = 0, this.bufferMarks = [], this.atCursorPos = true, this.openStart = -1, this.openEnd = -1, this.text = "", this.textOff = 0, this.cursor = e.iter(), this.skip = n;
    }
    posCovered() {
      if (this.content.length == 0)
        return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
      let e = this.content[this.content.length - 1];
      return !(e.breakAfter || e instanceof Fc && e.deco.endSide < 0);
    }
    getLine() {
      return this.curLine || (this.content.push(this.curLine = new or()), this.atCursorPos = true), this.curLine;
    }
    flushBuffer(e = this.bufferMarks) {
      this.pendingBuffer && (this.curLine.append(Kw(new tm(-1), e), e.length), this.pendingBuffer = 0);
    }
    addBlockWidget(e) {
      this.flushBuffer(), this.curLine = null, this.content.push(e);
    }
    finish(e) {
      this.pendingBuffer && e <= this.bufferMarks.length ? this.flushBuffer() : this.pendingBuffer = 0, !this.posCovered() && !(e && this.content.length && this.content[this.content.length - 1] instanceof Fc) && this.getLine();
    }
    buildText(e, n, r) {
      for (; e > 0; ) {
        if (this.textOff == this.text.length) {
          let { value: o, lineBreak: a, done: l } = this.cursor.next(this.skip);
          if (this.skip = 0, l)
            throw new Error("Ran out of text content when drawing inline views");
          if (a) {
            this.posCovered() || this.getLine(), this.content.length ? this.content[this.content.length - 1].breakAfter = 1 : this.breakAtStart = 1, this.flushBuffer(), this.curLine = null, this.atCursorPos = true, e--;
            continue;
          } else
            this.text = o, this.textOff = 0;
        }
        let i = Math.min(this.text.length - this.textOff, e), s = Math.min(i, 512);
        this.flushBuffer(n.slice(n.length - r)), this.getLine().append(Kw(new Ha(this.text.slice(this.textOff, this.textOff + s)), n), r), this.atCursorPos = true, this.textOff += s, e -= s, r = i <= s ? 0 : n.length;
      }
    }
    span(e, n, r, i) {
      this.buildText(n - e, r, i), this.pos = n, this.openStart < 0 && (this.openStart = i);
    }
    point(e, n, r, i, s, o) {
      if (this.disallowBlockEffectsFor[o] && r instanceof $d) {
        if (r.block)
          throw new RangeError("Block decorations may not be specified via plugins");
        if (n > this.doc.lineAt(this.pos).to)
          throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
      }
      let a = n - e;
      if (r instanceof $d)
        if (r.block)
          r.startSide > 0 && !this.posCovered() && this.getLine(), this.addBlockWidget(new Fc(r.widget || nm.block, a, r));
        else {
          let l = ed.create(r.widget || nm.inline, a, a ? 0 : r.startSide), c = this.atCursorPos && !l.isEditable && s <= i.length && (e < n || r.startSide > 0), u = !l.isEditable && (e < n || s > i.length || r.startSide <= 0), d = this.getLine();
          this.pendingBuffer == 2 && !c && !l.isEditable && (this.pendingBuffer = 0), this.flushBuffer(i), c && (d.append(Kw(new tm(1), i), s), s = i.length + Math.max(0, s - i.length)), d.append(Kw(l, i), s), this.atCursorPos = u, this.pendingBuffer = u ? e < n || s > i.length ? 1 : 2 : 0, this.pendingBuffer && (this.bufferMarks = i.slice());
        }
      else
        this.doc.lineAt(this.pos).from == this.pos && this.getLine().addLineDeco(r);
      a && (this.textOff + a <= this.text.length ? this.textOff += a : (this.skip += a - (this.text.length - this.textOff), this.text = "", this.textOff = 0), this.pos = n), this.openStart < 0 && (this.openStart = s);
    }
    static build(e, n, r, i, s) {
      let o = new lv(e, n, r, s);
      return o.openEnd = Pi.spans(i, n, r, o), o.openStart < 0 && (o.openStart = o.openEnd), o.finish(o.openEnd), o;
    }
  }
  function Kw(t, e) {
    for (let n of e)
      t = new Gc(n, [
        t
      ], t.length);
    return t;
  }
  class nm extends Yl {
    constructor(e) {
      super(), this.tag = e;
    }
    eq(e) {
      return e.tag == this.tag;
    }
    toDOM() {
      return document.createElement(this.tag);
    }
    updateDOM(e) {
      return e.nodeName.toLowerCase() == this.tag;
    }
    get isHidden() {
      return true;
    }
  }
  nm.inline = new nm("span");
  nm.block = new nm("div");
  var er = function(t) {
    return t[t.LTR = 0] = "LTR", t[t.RTL = 1] = "RTL", t;
  }(er || (er = {}));
  const ff = er.LTR, wj = er.RTL;
  function Vse(t) {
    let e = [];
    for (let n = 0; n < t.length; n++)
      e.push(1 << +t[n]);
    return e;
  }
  const VHe = Vse("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"), XHe = Vse("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"), jM = /* @__PURE__ */ Object.create(null), al = [];
  for (let t of [
    "()",
    "[]",
    "{}"
  ]) {
    let e = t.charCodeAt(0), n = t.charCodeAt(1);
    jM[e] = n, jM[n] = -e;
  }
  function Xse(t) {
    return t <= 247 ? VHe[t] : 1424 <= t && t <= 1524 ? 2 : 1536 <= t && t <= 1785 ? XHe[t - 1536] : 1774 <= t && t <= 2220 ? 4 : 8192 <= t && t <= 8204 ? 256 : 64336 <= t && t <= 65023 ? 4 : 1;
  }
  const WHe = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
  class td {
    get dir() {
      return this.level % 2 ? wj : ff;
    }
    constructor(e, n, r) {
      this.from = e, this.to = n, this.level = r;
    }
    side(e, n) {
      return this.dir == n == e ? this.to : this.from;
    }
    forward(e, n) {
      return e == (this.dir == n);
    }
    static find(e, n, r, i) {
      let s = -1;
      for (let o = 0; o < e.length; o++) {
        let a = e[o];
        if (a.from <= n && a.to >= n) {
          if (a.level == r)
            return o;
          (s < 0 || (i != 0 ? i < 0 ? a.from < n : a.to > n : e[s].level > a.level)) && (s = o);
        }
      }
      if (s < 0)
        throw new RangeError("Index out of range");
      return s;
    }
  }
  function Wse(t, e) {
    if (t.length != e.length)
      return false;
    for (let n = 0; n < t.length; n++) {
      let r = t[n], i = e[n];
      if (r.from != i.from || r.to != i.to || r.direction != i.direction || !Wse(r.inner, i.inner))
        return false;
    }
    return true;
  }
  const rn = [];
  function ZHe(t, e, n, r, i) {
    for (let s = 0; s <= r.length; s++) {
      let o = s ? r[s - 1].to : e, a = s < r.length ? r[s].from : n, l = s ? 256 : i;
      for (let c = o, u = l, d = l; c < a; c++) {
        let h = Xse(t.charCodeAt(c));
        h == 512 ? h = u : h == 8 && d == 4 && (h = 16), rn[c] = h == 4 ? 2 : h, h & 7 && (d = h), u = h;
      }
      for (let c = o, u = l, d = l; c < a; c++) {
        let h = rn[c];
        if (h == 128)
          c < a - 1 && u == rn[c + 1] && u & 24 ? h = rn[c] = u : rn[c] = 256;
        else if (h == 64) {
          let f = c + 1;
          for (; f < a && rn[f] == 64; )
            f++;
          let y = c && u == 8 || f < n && rn[f] == 8 ? d == 1 ? 1 : 8 : 256;
          for (let g = c; g < f; g++)
            rn[g] = y;
          c = f - 1;
        } else
          h == 8 && d == 1 && (rn[c] = 1);
        u = h, h & 7 && (d = h);
      }
    }
  }
  function HHe(t, e, n, r, i) {
    let s = i == 1 ? 2 : 1;
    for (let o = 0, a = 0, l = 0; o <= r.length; o++) {
      let c = o ? r[o - 1].to : e, u = o < r.length ? r[o].from : n;
      for (let d = c, h, f, y; d < u; d++)
        if (f = jM[h = t.charCodeAt(d)])
          if (f < 0) {
            for (let g = a - 3; g >= 0; g -= 3)
              if (al[g + 1] == -f) {
                let O = al[g + 2], S = O & 2 ? i : O & 4 ? O & 1 ? s : i : 0;
                S && (rn[d] = rn[al[g]] = S), a = g;
                break;
              }
          } else {
            if (al.length == 189)
              break;
            al[a++] = d, al[a++] = h, al[a++] = l;
          }
        else if ((y = rn[d]) == 2 || y == 1) {
          let g = y == i;
          l = g ? 0 : 1;
          for (let O = a - 3; O >= 0; O -= 3) {
            let S = al[O + 2];
            if (S & 2)
              break;
            if (g)
              al[O + 2] |= 2;
            else {
              if (S & 4)
                break;
              al[O + 2] |= 4;
            }
          }
        }
    }
  }
  function YHe(t, e, n, r) {
    for (let i = 0, s = r; i <= n.length; i++) {
      let o = i ? n[i - 1].to : t, a = i < n.length ? n[i].from : e;
      for (let l = o; l < a; ) {
        let c = rn[l];
        if (c == 256) {
          let u = l + 1;
          for (; ; )
            if (u == a) {
              if (i == n.length)
                break;
              u = n[i++].to, a = i < n.length ? n[i].from : e;
            } else if (rn[u] == 256)
              u++;
            else
              break;
          let d = s == 1, h = (u < e ? rn[u] : r) == 1, f = d == h ? d ? 1 : 2 : r;
          for (let y = u, g = i, O = g ? n[g - 1].to : t; y > l; )
            y == O && (y = n[--g].from, O = g ? n[g - 1].to : t), rn[--y] = f;
          l = u;
        } else
          s = c, l++;
      }
    }
  }
  function NM(t, e, n, r, i, s, o) {
    let a = r % 2 ? 2 : 1;
    if (r % 2 == i % 2)
      for (let l = e, c = 0; l < n; ) {
        let u = true, d = false;
        if (c == s.length || l < s[c].from) {
          let g = rn[l];
          g != a && (u = false, d = g == 16);
        }
        let h = !u && a == 1 ? [] : null, f = u ? r : r + 1, y = l;
        e:
          for (; ; )
            if (c < s.length && y == s[c].from) {
              if (d)
                break e;
              let g = s[c];
              if (!u)
                for (let O = g.to, S = c + 1; ; ) {
                  if (O == n)
                    break e;
                  if (S < s.length && s[S].from == O)
                    O = s[S++].to;
                  else {
                    if (rn[O] == a)
                      break e;
                    break;
                  }
                }
              if (c++, h)
                h.push(g);
              else {
                g.from > l && o.push(new td(l, g.from, f));
                let O = g.direction == ff != !(f % 2);
                QM(t, O ? r + 1 : r, i, g.inner, g.from, g.to, o), l = g.to;
              }
              y = g.to;
            } else {
              if (y == n || (u ? rn[y] != a : rn[y] == a))
                break;
              y++;
            }
        h ? NM(t, l, y, r + 1, i, h, o) : l < y && o.push(new td(l, y, f)), l = y;
      }
    else
      for (let l = n, c = s.length; l > e; ) {
        let u = true, d = false;
        if (!c || l > s[c - 1].to) {
          let g = rn[l - 1];
          g != a && (u = false, d = g == 16);
        }
        let h = !u && a == 1 ? [] : null, f = u ? r : r + 1, y = l;
        e:
          for (; ; )
            if (c && y == s[c - 1].to) {
              if (d)
                break e;
              let g = s[--c];
              if (!u)
                for (let O = g.from, S = c; ; ) {
                  if (O == e)
                    break e;
                  if (S && s[S - 1].to == O)
                    O = s[--S].from;
                  else {
                    if (rn[O - 1] == a)
                      break e;
                    break;
                  }
                }
              if (h)
                h.push(g);
              else {
                g.to < l && o.push(new td(g.to, l, f));
                let O = g.direction == ff != !(f % 2);
                QM(t, O ? r + 1 : r, i, g.inner, g.from, g.to, o), l = g.from;
              }
              y = g.from;
            } else {
              if (y == e || (u ? rn[y - 1] != a : rn[y - 1] == a))
                break;
              y--;
            }
        h ? NM(t, y, l, r + 1, i, h, o) : y < l && o.push(new td(y, l, f)), l = y;
      }
  }
  function QM(t, e, n, r, i, s, o) {
    let a = e % 2 ? 2 : 1;
    ZHe(t, i, s, r, a), HHe(t, i, s, r, a), YHe(i, s, r, a), NM(t, i, s, e, n, r, o);
  }
  function GHe(t, e, n) {
    if (!t)
      return [
        new td(0, 0, e == wj ? 1 : 0)
      ];
    if (e == ff && !n.length && !WHe.test(t))
      return Zse(t.length);
    if (n.length)
      for (; t.length > rn.length; )
        rn[rn.length] = 256;
    let r = [], i = e == ff ? 0 : 1;
    return QM(t, i, i, n, 0, t.length, r), r;
  }
  function Zse(t) {
    return [
      new td(0, t, 0)
    ];
  }
  let Hse = "";
  function qHe(t, e, n, r, i) {
    var s;
    let o = r.head - t.from, a = td.find(e, o, (s = r.bidiLevel) !== null && s !== void 0 ? s : -1, r.assoc), l = e[a], c = l.side(i, n);
    if (o == c) {
      let h = a += i ? 1 : -1;
      if (h < 0 || h >= e.length)
        return null;
      l = e[a = h], o = l.side(!i, n), c = l.side(i, n);
    }
    let u = Tl(t.text, o, l.forward(i, n));
    (u < l.from || u > l.to) && (u = c), Hse = t.text.slice(Math.min(o, u), Math.max(o, u));
    let d = a == (i ? e.length - 1 : 0) ? null : e[a + (i ? 1 : -1)];
    return d && u == c && d.level + (i ? 0 : 1) < l.level ? Ve.cursor(d.side(!i, n) + t.from, d.forward(i, n) ? 1 : -1, d.level) : Ve.cursor(u + t.from, l.forward(i, n) ? -1 : 1, l.level);
  }
  function KHe(t, e, n) {
    for (let r = e; r < n; r++) {
      let i = Xse(t.charCodeAt(r));
      if (i == 1)
        return ff;
      if (i == 2 || i == 4)
        return wj;
    }
    return ff;
  }
  const Yse = Ge.define(), Gse = Ge.define(), qse = Ge.define(), Kse = Ge.define(), zM = Ge.define(), Jse = Ge.define(), eoe = Ge.define(), xj = Ge.define(), bj = Ge.define(), toe = Ge.define({
    combine: (t) => t.some((e) => e)
  }), JHe = Ge.define({
    combine: (t) => t.some((e) => e)
  }), noe = Ge.define();
  class wg {
    constructor(e, n = "nearest", r = "nearest", i = 5, s = 5, o = false) {
      this.range = e, this.y = n, this.x = r, this.yMargin = i, this.xMargin = s, this.isSnapshot = o;
    }
    map(e) {
      return e.empty ? this : new wg(this.range.map(e), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
    }
    clip(e) {
      return this.range.to <= e.doc.length ? this : new wg(Ve.cursor(e.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
    }
  }
  const Jw = kn.define({
    map: (t, e) => t.map(e)
  }), roe = kn.define();
  function Vo(t, e, n) {
    let r = t.facet(Kse);
    r.length ? r[0](e) : window.onerror && window.onerror(String(e), n, void 0, void 0, e) || (n ? console.error(n + ":", e) : console.error(e));
  }
  const _c = Ge.define({
    combine: (t) => t.length ? t[0] : true
  });
  let eYe = 0;
  const sg = Ge.define({
    combine(t) {
      return t.filter((e, n) => {
        for (let r = 0; r < n; r++)
          if (t[r].plugin == e.plugin)
            return false;
        return true;
      });
    }
  });
  class ur {
    constructor(e, n, r, i, s) {
      this.id = e, this.create = n, this.domEventHandlers = r, this.domEventObservers = i, this.baseExtensions = s(this), this.extension = this.baseExtensions.concat(sg.of({
        plugin: this,
        arg: void 0
      }));
    }
    of(e) {
      return this.baseExtensions.concat(sg.of({
        plugin: this,
        arg: e
      }));
    }
    static define(e, n) {
      const { eventHandlers: r, eventObservers: i, provide: s, decorations: o } = n || {};
      return new ur(eYe++, e, r, i, (a) => {
        let l = [];
        return o && l.push(gO.of((c) => {
          let u = c.plugin(a);
          return u ? o(u) : Qe.none;
        })), s && l.push(s(a)), l;
      });
    }
    static fromClass(e, n) {
      return ur.define((r, i) => new e(r, i), n);
    }
  }
  class KI {
    constructor(e) {
      this.spec = e, this.mustUpdate = null, this.value = null;
    }
    get plugin() {
      return this.spec && this.spec.plugin;
    }
    update(e) {
      if (this.value) {
        if (this.mustUpdate) {
          let n = this.mustUpdate;
          if (this.mustUpdate = null, this.value.update)
            try {
              this.value.update(n);
            } catch (r) {
              if (Vo(n.state, r, "CodeMirror plugin crashed"), this.value.destroy)
                try {
                  this.value.destroy();
                } catch {
                }
              this.deactivate();
            }
        }
      } else if (this.spec)
        try {
          this.value = this.spec.plugin.create(e, this.spec.arg);
        } catch (n) {
          Vo(e.state, n, "CodeMirror plugin crashed"), this.deactivate();
        }
      return this;
    }
    destroy(e) {
      var n;
      if (!((n = this.value) === null || n === void 0) && n.destroy)
        try {
          this.value.destroy();
        } catch (r) {
          Vo(e.state, r, "CodeMirror plugin crashed");
        }
    }
    deactivate() {
      this.spec = this.value = null;
    }
  }
  const ioe = Ge.define(), kj = Ge.define(), gO = Ge.define(), soe = Ge.define(), PS = Ge.define(), ooe = Ge.define();
  function KB(t, e) {
    let n = t.state.facet(ooe);
    if (!n.length)
      return n;
    let r = n.map((s) => s instanceof Function ? s(t) : s), i = [];
    return Pi.spans(r, e.from, e.to, {
      point() {
      },
      span(s, o, a, l) {
        let c = s - e.from, u = o - e.from, d = i;
        for (let h = a.length - 1; h >= 0; h--, l--) {
          let f = a[h].spec.bidiIsolate, y;
          if (f == null && (f = KHe(e.text, c, u)), l > 0 && d.length && (y = d[d.length - 1]).to == c && y.direction == f)
            y.to = u, d = y.inner;
          else {
            let g = {
              from: c,
              to: u,
              direction: f,
              inner: []
            };
            d.push(g), d = g.inner;
          }
        }
      }
    }), i;
  }
  const aoe = Ge.define();
  function Pj(t) {
    let e = 0, n = 0, r = 0, i = 0;
    for (let s of t.state.facet(aoe)) {
      let o = s(t);
      o && (o.left != null && (e = Math.max(e, o.left)), o.right != null && (n = Math.max(n, o.right)), o.top != null && (r = Math.max(r, o.top)), o.bottom != null && (i = Math.max(i, o.bottom)));
    }
    return {
      left: e,
      right: n,
      top: r,
      bottom: i
    };
  }
  const C0 = Ge.define();
  class Go {
    constructor(e, n, r, i) {
      this.fromA = e, this.toA = n, this.fromB = r, this.toB = i;
    }
    join(e) {
      return new Go(Math.min(this.fromA, e.fromA), Math.max(this.toA, e.toA), Math.min(this.fromB, e.fromB), Math.max(this.toB, e.toB));
    }
    addToSet(e) {
      let n = e.length, r = this;
      for (; n > 0; n--) {
        let i = e[n - 1];
        if (!(i.fromA > r.toA)) {
          if (i.toA < r.fromA)
            break;
          r = r.join(i), e.splice(n - 1, 1);
        }
      }
      return e.splice(n, 0, r), e;
    }
    static extendWithRanges(e, n) {
      if (n.length == 0)
        return e;
      let r = [];
      for (let i = 0, s = 0, o = 0, a = 0; ; i++) {
        let l = i == e.length ? null : e[i], c = o - a, u = l ? l.fromB : 1e9;
        for (; s < n.length && n[s] < u; ) {
          let d = n[s], h = n[s + 1], f = Math.max(a, d), y = Math.min(u, h);
          if (f <= y && new Go(f + c, y + c, f, y).addToSet(r), h > u)
            break;
          s += 2;
        }
        if (!l)
          return r;
        new Go(l.fromA, l.toA, l.fromB, l.toB).addToSet(r), o = l.toA, a = l.toB;
      }
    }
  }
  class cP {
    constructor(e, n, r) {
      this.view = e, this.state = n, this.transactions = r, this.flags = 0, this.startState = e.state, this.changes = Za.empty(this.startState.doc.length);
      for (let s of r)
        this.changes = this.changes.compose(s.changes);
      let i = [];
      this.changes.iterChangedRanges((s, o, a, l) => i.push(new Go(s, o, a, l))), this.changedRanges = i;
    }
    static create(e, n, r) {
      return new cP(e, n, r);
    }
    get viewportChanged() {
      return (this.flags & 4) > 0;
    }
    get viewportMoved() {
      return (this.flags & 8) > 0;
    }
    get heightChanged() {
      return (this.flags & 2) > 0;
    }
    get geometryChanged() {
      return this.docChanged || (this.flags & 18) > 0;
    }
    get focusChanged() {
      return (this.flags & 1) > 0;
    }
    get docChanged() {
      return !this.changes.empty;
    }
    get selectionSet() {
      return this.transactions.some((e) => e.selection);
    }
    get empty() {
      return this.flags == 0 && this.transactions.length == 0;
    }
  }
  class JB extends sn {
    get length() {
      return this.view.state.doc.length;
    }
    constructor(e) {
      super(), this.view = e, this.decorations = [], this.dynamicDecorationMap = [
        false
      ], this.domChanged = null, this.hasComposition = null, this.markedForComposition = /* @__PURE__ */ new Set(), this.editContextFormatting = Qe.none, this.lastCompositionAfterCursor = false, this.minWidth = 0, this.minWidthFrom = 0, this.minWidthTo = 0, this.impreciseAnchor = null, this.impreciseHead = null, this.forceSelection = false, this.lastUpdate = Date.now(), this.setDOM(e.contentDOM), this.children = [
        new or()
      ], this.children[0].setParent(this), this.updateDeco(), this.updateInner([
        new Go(0, 0, 0, e.state.doc.length)
      ], 0, null);
    }
    update(e) {
      var n;
      let r = e.changedRanges;
      this.minWidth > 0 && r.length && (r.every(({ fromA: c, toA: u }) => u < this.minWidthFrom || c > this.minWidthTo) ? (this.minWidthFrom = e.changes.mapPos(this.minWidthFrom, 1), this.minWidthTo = e.changes.mapPos(this.minWidthTo, 1)) : this.minWidth = this.minWidthFrom = this.minWidthTo = 0), this.updateEditContextFormatting(e);
      let i = -1;
      this.view.inputState.composing >= 0 && !this.view.observer.editContext && (!((n = this.domChanged) === null || n === void 0) && n.newSel ? i = this.domChanged.newSel.head : !aYe(e.changes, this.hasComposition) && !e.selectionSet && (i = e.state.selection.main.head));
      let s = i > -1 ? nYe(this.view, e.changes, i) : null;
      if (this.domChanged = null, this.hasComposition) {
        this.markedForComposition.clear();
        let { from: c, to: u } = this.hasComposition;
        r = new Go(c, u, e.changes.mapPos(c, -1), e.changes.mapPos(u, 1)).addToSet(r.slice());
      }
      this.hasComposition = s ? {
        from: s.range.fromB,
        to: s.range.toB
      } : null, (Ee.ie || Ee.chrome) && !s && e && e.state.doc.lines != e.startState.doc.lines && (this.forceSelection = true);
      let o = this.decorations, a = this.updateDeco(), l = sYe(o, a, e.changes);
      return r = Go.extendWithRanges(r, l), !(this.flags & 7) && r.length == 0 ? false : (this.updateInner(r, e.startState.doc.length, s), e.transactions.length && (this.lastUpdate = Date.now()), true);
    }
    updateInner(e, n, r) {
      this.view.viewState.mustMeasureContent = true, this.updateChildren(e, n, r);
      let { observer: i } = this.view;
      i.ignore(() => {
        this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + "px", this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
        let o = Ee.chrome || Ee.ios ? {
          node: i.selectionRange.focusNode,
          written: false
        } : void 0;
        this.sync(this.view, o), this.flags &= -8, o && (o.written || i.selectionRange.focusNode != o.node) && (this.forceSelection = true), this.dom.style.height = "";
      }), this.markedForComposition.forEach((o) => o.flags &= -9);
      let s = [];
      if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
        for (let o of this.children)
          o instanceof Fc && o.widget instanceof LM && s.push(o.dom);
      i.updateGaps(s);
    }
    updateChildren(e, n, r) {
      let i = r ? r.range.addToSet(e.slice()) : e, s = this.childCursor(n);
      for (let o = i.length - 1; ; o--) {
        let a = o >= 0 ? i[o] : null;
        if (!a)
          break;
        let { fromA: l, toA: c, fromB: u, toB: d } = a, h, f, y, g;
        if (r && r.range.fromB < d && r.range.toB > u) {
          let P = lv.build(this.view.state.doc, u, r.range.fromB, this.decorations, this.dynamicDecorationMap), C = lv.build(this.view.state.doc, r.range.toB, d, this.decorations, this.dynamicDecorationMap);
          f = P.breakAtStart, y = P.openStart, g = C.openEnd;
          let _ = this.compositionView(r);
          C.breakAtStart ? _.breakAfter = 1 : C.content.length && _.merge(_.length, _.length, C.content[0], false, C.openStart, 0) && (_.breakAfter = C.content[0].breakAfter, C.content.shift()), P.content.length && _.merge(0, 0, P.content[P.content.length - 1], true, 0, P.openEnd) && P.content.pop(), h = P.content.concat(_).concat(C.content);
        } else
          ({ content: h, breakAtStart: f, openStart: y, openEnd: g } = lv.build(this.view.state.doc, u, d, this.decorations, this.dynamicDecorationMap));
        let { i: O, off: S } = s.findPos(c, 1), { i: w, off: x } = s.findPos(l, -1);
        Lse(this, w, x, O, S, h, f, y, g);
      }
      r && this.fixCompositionDOM(r);
    }
    updateEditContextFormatting(e) {
      this.editContextFormatting = this.editContextFormatting.map(e.changes);
      for (let n of e.transactions)
        for (let r of n.effects)
          r.is(roe) && (this.editContextFormatting = r.value);
    }
    compositionView(e) {
      let n = new Ha(e.text.nodeValue);
      n.flags |= 8;
      for (let { deco: i } of e.marks)
        n = new Gc(i, [
          n
        ], n.length);
      let r = new or();
      return r.append(n, 0), r;
    }
    fixCompositionDOM(e) {
      let n = (s, o) => {
        o.flags |= 8 | (o.children.some((l) => l.flags & 7) ? 1 : 0), this.markedForComposition.add(o);
        let a = sn.get(s);
        a && a != o && (a.dom = null), o.setDOM(s);
      }, r = this.childPos(e.range.fromB, 1), i = this.children[r.i];
      n(e.line, i);
      for (let s = e.marks.length - 1; s >= -1; s--)
        r = i.childPos(r.off, 1), i = i.children[r.i], n(s >= 0 ? e.marks[s].node : e.text, i);
    }
    updateSelection(e = false, n = false) {
      (e || !this.view.observer.selectionRange.focusNode) && this.view.observer.readSelectionRange();
      let r = this.view.root.activeElement, i = r == this.dom, s = !i && !(this.view.state.facet(_c) || this.dom.tabIndex > -1) && hb(this.dom, this.view.observer.selectionRange) && !(r && this.dom.contains(r));
      if (!(i || n || s))
        return;
      let o = this.forceSelection;
      this.forceSelection = false;
      let a = this.view.state.selection.main, l = this.moveToLine(this.domAtPos(a.anchor)), c = a.empty ? l : this.moveToLine(this.domAtPos(a.head));
      if (Ee.gecko && a.empty && !this.hasComposition && tYe(l)) {
        let d = document.createTextNode("");
        this.view.observer.ignore(() => l.node.insertBefore(d, l.node.childNodes[l.offset] || null)), l = c = new vi(d, 0), o = true;
      }
      let u = this.view.observer.selectionRange;
      (o || !u.focusNode || (!av(l.node, l.offset, u.anchorNode, u.anchorOffset) || !av(c.node, c.offset, u.focusNode, u.focusOffset)) && !this.suppressWidgetCursorChange(u, a)) && (this.view.observer.ignore(() => {
        Ee.android && Ee.chrome && this.dom.contains(u.focusNode) && oYe(u.focusNode, this.dom) && (this.dom.blur(), this.dom.focus({
          preventScroll: true
        }));
        let d = fO(this.view.root);
        if (d)
          if (a.empty) {
            if (Ee.gecko) {
              let h = rYe(l.node, l.offset);
              if (h && h != 3) {
                let f = (h == 1 ? Rse : Mse)(l.node, l.offset);
                f && (l = new vi(f.node, f.offset));
              }
            }
            d.collapse(l.node, l.offset), a.bidiLevel != null && d.caretBidiLevel !== void 0 && (d.caretBidiLevel = a.bidiLevel);
          } else if (d.extend) {
            d.collapse(l.node, l.offset);
            try {
              d.extend(c.node, c.offset);
            } catch {
            }
          } else {
            let h = document.createRange();
            a.anchor > a.head && ([l, c] = [
              c,
              l
            ]), h.setEnd(c.node, c.offset), h.setStart(l.node, l.offset), d.removeAllRanges(), d.addRange(h);
          }
        s && this.view.root.activeElement == this.dom && (this.dom.blur(), r && r.focus());
      }), this.view.observer.setSelectionRange(l, c)), this.impreciseAnchor = l.precise ? null : new vi(u.anchorNode, u.anchorOffset), this.impreciseHead = c.precise ? null : new vi(u.focusNode, u.focusOffset);
    }
    suppressWidgetCursorChange(e, n) {
      return this.hasComposition && n.empty && av(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset) && this.posFromDOM(e.focusNode, e.focusOffset) == n.head;
    }
    enforceCursorAssoc() {
      if (this.hasComposition)
        return;
      let { view: e } = this, n = e.state.selection.main, r = fO(e.root), { anchorNode: i, anchorOffset: s } = e.observer.selectionRange;
      if (!r || !n.empty || !n.assoc || !r.modify)
        return;
      let o = or.find(this, n.head);
      if (!o)
        return;
      let a = o.posAtStart;
      if (n.head == a || n.head == a + o.length)
        return;
      let l = this.coordsAt(n.head, -1), c = this.coordsAt(n.head, 1);
      if (!l || !c || l.bottom > c.top)
        return;
      let u = this.domAtPos(n.head + n.assoc);
      r.collapse(u.node, u.offset), r.modify("move", n.assoc < 0 ? "forward" : "backward", "lineboundary"), e.observer.readSelectionRange();
      let d = e.observer.selectionRange;
      e.docView.posFromDOM(d.anchorNode, d.anchorOffset) != n.from && r.collapse(i, s);
    }
    moveToLine(e) {
      let n = this.dom, r;
      if (e.node != n)
        return e;
      for (let i = e.offset; !r && i < n.childNodes.length; i++) {
        let s = sn.get(n.childNodes[i]);
        s instanceof or && (r = s.domAtPos(0));
      }
      for (let i = e.offset - 1; !r && i >= 0; i--) {
        let s = sn.get(n.childNodes[i]);
        s instanceof or && (r = s.domAtPos(s.length));
      }
      return r ? new vi(r.node, r.offset, true) : e;
    }
    nearest(e) {
      for (let n = e; n; ) {
        let r = sn.get(n);
        if (r && r.rootView == this)
          return r;
        n = n.parentNode;
      }
      return null;
    }
    posFromDOM(e, n) {
      let r = this.nearest(e);
      if (!r)
        throw new RangeError("Trying to find position for a DOM position outside of the document");
      return r.localPosFromDOM(e, n) + r.posAtStart;
    }
    domAtPos(e) {
      let { i: n, off: r } = this.childCursor().findPos(e, -1);
      for (; n < this.children.length - 1; ) {
        let i = this.children[n];
        if (r < i.length || i instanceof or)
          break;
        n++, r = 0;
      }
      return this.children[n].domAtPos(r);
    }
    coordsAt(e, n) {
      let r = null, i = 0;
      for (let s = this.length, o = this.children.length - 1; o >= 0; o--) {
        let a = this.children[o], l = s - a.breakAfter, c = l - a.length;
        if (l < e)
          break;
        if (c <= e && (c < e || a.covers(-1)) && (l > e || a.covers(1)) && (!r || a instanceof or && !(r instanceof or && n >= 0)))
          r = a, i = c;
        else if (r && c == e && l == e && a instanceof Fc && Math.abs(n) < 2) {
          if (a.deco.startSide < 0)
            break;
          o && (r = null);
        }
        s = c;
      }
      return r ? r.coordsAt(e - i, n) : null;
    }
    coordsForChar(e) {
      let { i: n, off: r } = this.childPos(e, 1), i = this.children[n];
      if (!(i instanceof or))
        return null;
      for (; i.children.length; ) {
        let { i: a, off: l } = i.childPos(r, 1);
        for (; ; a++) {
          if (a == i.children.length)
            return null;
          if ((i = i.children[a]).length)
            break;
        }
        r = l;
      }
      if (!(i instanceof Ha))
        return null;
      let s = Tl(i.text, r);
      if (s == r)
        return null;
      let o = hf(i.dom, r, s).getClientRects();
      for (let a = 0; a < o.length; a++) {
        let l = o[a];
        if (a == o.length - 1 || l.top < l.bottom && l.left < l.right)
          return l;
      }
      return null;
    }
    measureVisibleLineHeights(e) {
      let n = [], { from: r, to: i } = e, s = this.view.contentDOM.clientWidth, o = s > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1, a = -1, l = this.view.textDirection == er.LTR;
      for (let c = 0, u = 0; u < this.children.length; u++) {
        let d = this.children[u], h = c + d.length;
        if (h > i)
          break;
        if (c >= r) {
          let f = d.dom.getBoundingClientRect();
          if (n.push(f.height), o) {
            let y = d.dom.lastChild, g = y ? pO(y) : [];
            if (g.length) {
              let O = g[g.length - 1], S = l ? O.right - f.left : f.right - O.left;
              S > a && (a = S, this.minWidth = s, this.minWidthFrom = c, this.minWidthTo = h);
            }
          }
        }
        c = h + d.breakAfter;
      }
      return n;
    }
    textDirectionAt(e) {
      let { i: n } = this.childPos(e, 1);
      return getComputedStyle(this.children[n].dom).direction == "rtl" ? er.RTL : er.LTR;
    }
    measureTextSize() {
      for (let s of this.children)
        if (s instanceof or) {
          let o = s.measureTextSize();
          if (o)
            return o;
        }
      let e = document.createElement("div"), n, r, i;
      return e.className = "cm-line", e.style.width = "99999px", e.style.position = "absolute", e.textContent = "abc def ghi jkl mno pqr stu", this.view.observer.ignore(() => {
        this.dom.appendChild(e);
        let s = pO(e.firstChild)[0];
        n = e.getBoundingClientRect().height, r = s ? s.width / 27 : 7, i = s ? s.height : n, e.remove();
      }), {
        lineHeight: n,
        charWidth: r,
        textHeight: i
      };
    }
    childCursor(e = this.length) {
      let n = this.children.length;
      return n && (e -= this.children[--n].length), new Dse(this.children, e, n);
    }
    computeBlockGapDeco() {
      let e = [], n = this.view.viewState;
      for (let r = 0, i = 0; ; i++) {
        let s = i == n.viewports.length ? null : n.viewports[i], o = s ? s.from - 1 : this.length;
        if (o > r) {
          let a = (n.lineBlockAt(o).bottom - n.lineBlockAt(r).top) / this.view.scaleY;
          e.push(Qe.replace({
            widget: new LM(a),
            block: true,
            inclusive: true,
            isBlockGap: true
          }).range(r, o));
        }
        if (!s)
          break;
        r = s.to + 1;
      }
      return Qe.set(e);
    }
    updateDeco() {
      let e = 1, n = this.view.state.facet(gO).map((s) => (this.dynamicDecorationMap[e++] = typeof s == "function") ? s(this.view) : s), r = false, i = this.view.state.facet(soe).map((s, o) => {
        let a = typeof s == "function";
        return a && (r = true), a ? s(this.view) : s;
      });
      for (i.length && (this.dynamicDecorationMap[e++] = r, n.push(Pi.join(i))), this.decorations = [
        this.editContextFormatting,
        ...n,
        this.computeBlockGapDeco(),
        this.view.viewState.lineGapDeco
      ]; e < this.decorations.length; )
        this.dynamicDecorationMap[e++] = false;
      return this.decorations;
    }
    scrollIntoView(e) {
      if (e.isSnapshot) {
        let c = this.view.viewState.lineBlockAt(e.range.head);
        this.view.scrollDOM.scrollTop = c.top - e.yMargin, this.view.scrollDOM.scrollLeft = e.xMargin;
        return;
      }
      for (let c of this.view.state.facet(noe))
        try {
          if (c(this.view, e.range, e))
            return true;
        } catch (u) {
          Vo(this.view.state, u, "scroll handler");
        }
      let { range: n } = e, r = this.coordsAt(n.head, n.empty ? n.assoc : n.head > n.anchor ? -1 : 1), i;
      if (!r)
        return;
      !n.empty && (i = this.coordsAt(n.anchor, n.anchor > n.head ? -1 : 1)) && (r = {
        left: Math.min(r.left, i.left),
        top: Math.min(r.top, i.top),
        right: Math.max(r.right, i.right),
        bottom: Math.max(r.bottom, i.bottom)
      });
      let s = Pj(this.view), o = {
        left: r.left - s.left,
        top: r.top - s.top,
        right: r.right + s.right,
        bottom: r.bottom + s.bottom
      }, { offsetWidth: a, offsetHeight: l } = this.view.scrollDOM;
      RHe(this.view.scrollDOM, o, n.head < n.anchor ? -1 : 1, e.x, e.y, Math.max(Math.min(e.xMargin, a), -a), Math.max(Math.min(e.yMargin, l), -l), this.view.textDirection == er.LTR);
    }
  }
  function tYe(t) {
    return t.node.nodeType == 1 && t.node.firstChild && (t.offset == 0 || t.node.childNodes[t.offset - 1].contentEditable == "false") && (t.offset == t.node.childNodes.length || t.node.childNodes[t.offset].contentEditable == "false");
  }
  function loe(t, e) {
    let n = t.observer.selectionRange;
    if (!n.focusNode)
      return null;
    let r = Rse(n.focusNode, n.focusOffset), i = Mse(n.focusNode, n.focusOffset), s = r || i;
    if (i && r && i.node != r.node) {
      let a = sn.get(i.node);
      if (!a || a instanceof Ha && a.text != i.node.nodeValue)
        s = i;
      else if (t.docView.lastCompositionAfterCursor) {
        let l = sn.get(r.node);
        !l || l instanceof Ha && l.text != r.node.nodeValue || (s = i);
      }
    }
    if (t.docView.lastCompositionAfterCursor = s != r, !s)
      return null;
    let o = e - s.offset;
    return {
      from: o,
      to: o + s.node.nodeValue.length,
      node: s.node
    };
  }
  function nYe(t, e, n) {
    let r = loe(t, n);
    if (!r)
      return null;
    let { node: i, from: s, to: o } = r, a = i.nodeValue;
    if (/[\n\r]/.test(a) || t.state.doc.sliceString(r.from, r.to) != a)
      return null;
    let l = e.invertedDesc, c = new Go(l.mapPos(s), l.mapPos(o), s, o), u = [];
    for (let d = i.parentNode; ; d = d.parentNode) {
      let h = sn.get(d);
      if (h instanceof Gc)
        u.push({
          node: d,
          deco: h.mark
        });
      else {
        if (h instanceof or || d.nodeName == "DIV" && d.parentNode == t.contentDOM)
          return {
            range: c,
            text: i,
            marks: u,
            line: d
          };
        if (d != t.contentDOM)
          u.push({
            node: d,
            deco: new bS({
              inclusive: true,
              attributes: BHe(d),
              tagName: d.tagName.toLowerCase()
            })
          });
        else
          return null;
      }
    }
  }
  function rYe(t, e) {
    return t.nodeType != 1 ? 0 : (e && t.childNodes[e - 1].contentEditable == "false" ? 1 : 0) | (e < t.childNodes.length && t.childNodes[e].contentEditable == "false" ? 2 : 0);
  }
  let iYe = class {
    constructor() {
      this.changes = [];
    }
    compareRange(e, n) {
      fb(e, n, this.changes);
    }
    comparePoint(e, n) {
      fb(e, n, this.changes);
    }
    boundChange(e) {
      fb(e, e, this.changes);
    }
  };
  function sYe(t, e, n) {
    let r = new iYe();
    return Pi.compare(t, e, n, r), r.changes;
  }
  function oYe(t, e) {
    for (let n = t; n && n != e; n = n.assignedSlot || n.parentNode)
      if (n.nodeType == 1 && n.contentEditable == "false")
        return true;
    return false;
  }
  function aYe(t, e) {
    let n = false;
    return e && t.iterChangedRanges((r, i) => {
      r < e.to && i > e.from && (n = true);
    }), n;
  }
  function lYe(t, e, n = 1) {
    let r = t.charCategorizer(e), i = t.doc.lineAt(e), s = e - i.from;
    if (i.length == 0)
      return Ve.cursor(e);
    s == 0 ? n = 1 : s == i.length && (n = -1);
    let o = s, a = s;
    n < 0 ? o = Tl(i.text, s, false) : a = Tl(i.text, s);
    let l = r(i.text.slice(o, a));
    for (; o > 0; ) {
      let c = Tl(i.text, o, false);
      if (r(i.text.slice(c, o)) != l)
        break;
      o = c;
    }
    for (; a < i.length; ) {
      let c = Tl(i.text, a);
      if (r(i.text.slice(a, c)) != l)
        break;
      a = c;
    }
    return Ve.range(o + i.from, a + i.from);
  }
  function cYe(t, e) {
    return e.left > t ? e.left - t : Math.max(0, t - e.right);
  }
  function uYe(t, e) {
    return e.top > t ? e.top - t : Math.max(0, t - e.bottom);
  }
  function JI(t, e) {
    return t.top < e.bottom - 1 && t.bottom > e.top + 1;
  }
  function eU(t, e) {
    return e < t.top ? {
      top: e,
      left: t.left,
      right: t.right,
      bottom: t.bottom
    } : t;
  }
  function tU(t, e) {
    return e > t.bottom ? {
      top: t.top,
      left: t.left,
      right: t.right,
      bottom: e
    } : t;
  }
  function FM(t, e, n) {
    let r, i, s, o, a = false, l, c, u, d;
    for (let y = t.firstChild; y; y = y.nextSibling) {
      let g = pO(y);
      for (let O = 0; O < g.length; O++) {
        let S = g[O];
        i && JI(i, S) && (S = eU(tU(S, i.bottom), i.top));
        let w = cYe(e, S), x = uYe(n, S);
        if (w == 0 && x == 0)
          return y.nodeType == 3 ? nU(y, e, n) : FM(y, e, n);
        (!r || o > x || o == x && s > w) && (r = y, i = S, s = w, o = x, a = w ? e < S.left ? O > 0 : O < g.length - 1 : true), w == 0 ? n > S.bottom && (!u || u.bottom < S.bottom) ? (l = y, u = S) : n < S.top && (!d || d.top > S.top) && (c = y, d = S) : u && JI(u, S) ? u = tU(u, S.bottom) : d && JI(d, S) && (d = eU(d, S.top));
      }
    }
    if (u && u.bottom >= n ? (r = l, i = u) : d && d.top <= n && (r = c, i = d), !r)
      return {
        node: t,
        offset: 0
      };
    let h = Math.max(i.left, Math.min(i.right, e));
    if (r.nodeType == 3)
      return nU(r, h, n);
    if (a && r.contentEditable != "false")
      return FM(r, h, n);
    let f = Array.prototype.indexOf.call(t.childNodes, r) + (e >= (i.left + i.right) / 2 ? 1 : 0);
    return {
      node: t,
      offset: f
    };
  }
  function nU(t, e, n) {
    let r = t.nodeValue.length, i = -1, s = 1e9, o = 0;
    for (let a = 0; a < r; a++) {
      let l = hf(t, a, a + 1).getClientRects();
      for (let c = 0; c < l.length; c++) {
        let u = l[c];
        if (u.top == u.bottom)
          continue;
        o || (o = e - u.left);
        let d = (u.top > n ? u.top - n : n - u.bottom) - 1;
        if (u.left - 1 <= e && u.right + 1 >= e && d < s) {
          let h = e >= (u.left + u.right) / 2, f = h;
          if ((Ee.chrome || Ee.gecko) && hf(t, a).getBoundingClientRect().left == u.right && (f = !h), d <= 0)
            return {
              node: t,
              offset: a + (f ? 1 : 0)
            };
          i = a + (f ? 1 : 0), s = d;
        }
      }
    }
    return {
      node: t,
      offset: i > -1 ? i : o > 0 ? t.nodeValue.length : 0
    };
  }
  function coe(t, e, n, r = -1) {
    var i, s;
    let o = t.contentDOM.getBoundingClientRect(), a = o.top + t.viewState.paddingTop, l, { docHeight: c } = t.viewState, { x: u, y: d } = e, h = d - a;
    if (h < 0)
      return 0;
    if (h > c)
      return t.state.doc.length;
    for (let P = t.viewState.heightOracle.textHeight / 2, C = false; l = t.elementAtHeight(h), l.type != Ml.Text; )
      for (; h = r > 0 ? l.bottom + P : l.top - P, !(h >= 0 && h <= c); ) {
        if (C)
          return n ? null : 0;
        C = true, r = -r;
      }
    d = a + h;
    let f = l.from;
    if (f < t.viewport.from)
      return t.viewport.from == 0 ? 0 : n ? null : rU(t, o, l, u, d);
    if (f > t.viewport.to)
      return t.viewport.to == t.state.doc.length ? t.state.doc.length : n ? null : rU(t, o, l, u, d);
    let y = t.dom.ownerDocument, g = t.root.elementFromPoint ? t.root : y, O = g.elementFromPoint(u, d);
    O && !t.contentDOM.contains(O) && (O = null), O || (u = Math.max(o.left + 1, Math.min(o.right - 1, u)), O = g.elementFromPoint(u, d), O && !t.contentDOM.contains(O) && (O = null));
    let S, w = -1;
    if (O && ((i = t.docView.nearest(O)) === null || i === void 0 ? void 0 : i.isEditable) != false) {
      if (y.caretPositionFromPoint) {
        let P = y.caretPositionFromPoint(u, d);
        P && ({ offsetNode: S, offset: w } = P);
      } else if (y.caretRangeFromPoint) {
        let P = y.caretRangeFromPoint(u, d);
        P && ({ startContainer: S, startOffset: w } = P);
      }
      S && (!t.contentDOM.contains(S) || Ee.safari && dYe(S, w, u) || Ee.chrome && hYe(S, w, u)) && (S = void 0), S && (w = Math.min(Ul(S), w));
    }
    if (!S || !t.docView.dom.contains(S)) {
      let P = or.find(t.docView, f);
      if (!P)
        return h > l.top + l.height / 2 ? l.to : l.from;
      ({ node: S, offset: w } = FM(P.dom, u, d));
    }
    let x = t.docView.nearest(S);
    if (!x)
      return null;
    if (x.isWidget && ((s = x.dom) === null || s === void 0 ? void 0 : s.nodeType) == 1) {
      let P = x.dom.getBoundingClientRect();
      return e.y < P.top || e.y <= P.bottom && e.x <= (P.left + P.right) / 2 ? x.posAtStart : x.posAtEnd;
    } else
      return x.localPosFromDOM(S, w) + x.posAtStart;
  }
  function rU(t, e, n, r, i) {
    let s = Math.round((r - e.left) * t.defaultCharacterWidth);
    if (t.lineWrapping && n.height > t.defaultLineHeight * 1.5) {
      let a = t.viewState.heightOracle.textHeight, l = Math.floor((i - n.top - (t.defaultLineHeight - a) * 0.5) / a);
      s += l * t.viewState.heightOracle.lineLength;
    }
    let o = t.state.sliceDoc(n.from, n.to);
    return n.from + _He(o, s, t.state.tabSize);
  }
  function uoe(t, e, n) {
    let r, i = t;
    if (t.nodeType != 3 || e != (r = t.nodeValue.length))
      return false;
    for (; ; ) {
      let s = i.nextSibling;
      if (s) {
        if (s.nodeName == "BR")
          break;
        return false;
      } else {
        let o = i.parentNode;
        if (!o || o.nodeName == "DIV")
          break;
        i = o;
      }
    }
    return hf(t, r - 1, r).getBoundingClientRect().right > n;
  }
  function dYe(t, e, n) {
    return uoe(t, e, n);
  }
  function hYe(t, e, n) {
    if (e != 0)
      return uoe(t, e, n);
    for (let i = t; ; ) {
      let s = i.parentNode;
      if (!s || s.nodeType != 1 || s.firstChild != i)
        return false;
      if (s.classList.contains("cm-line"))
        break;
      i = s;
    }
    let r = t.nodeType == 1 ? t.getBoundingClientRect() : hf(t, 0, Math.max(t.nodeValue.length, 1)).getBoundingClientRect();
    return n - r.left > 5;
  }
  function fYe(t, e, n) {
    let r = t.lineBlockAt(e);
    if (Array.isArray(r.type)) {
      let i;
      for (let s of r.type) {
        if (s.from > e)
          break;
        if (!(s.to < e)) {
          if (s.from < e && s.to > e)
            return s;
          (!i || s.type == Ml.Text && (i.type != s.type || (n < 0 ? s.from < e : s.to > e))) && (i = s);
        }
      }
      return i || r;
    }
    return r;
  }
  function pYe(t, e, n, r) {
    let i = fYe(t, e.head, e.assoc || -1), s = !r || i.type != Ml.Text || !(t.lineWrapping || i.widgetLineBreaks) ? null : t.coordsAtPos(e.assoc < 0 && e.head > i.from ? e.head - 1 : e.head);
    if (s) {
      let o = t.dom.getBoundingClientRect(), a = t.textDirectionAt(i.from), l = t.posAtCoords({
        x: n == (a == er.LTR) ? o.right - 1 : o.left + 1,
        y: (s.top + s.bottom) / 2
      });
      if (l != null)
        return Ve.cursor(l, n ? -1 : 1);
    }
    return Ve.cursor(n ? i.to : i.from, n ? -1 : 1);
  }
  function iU(t, e, n, r) {
    let i = t.state.doc.lineAt(e.head), s = t.bidiSpans(i), o = t.textDirectionAt(i.from);
    for (let a = e, l = null; ; ) {
      let c = qHe(i, s, o, a, n), u = Hse;
      if (!c) {
        if (i.number == (n ? t.state.doc.lines : 1))
          return a;
        u = `
`, i = t.state.doc.line(i.number + (n ? 1 : -1)), s = t.bidiSpans(i), c = t.visualLineSide(i, !n);
      }
      if (l) {
        if (!l(u))
          return a;
      } else {
        if (!r)
          return c;
        l = r(u);
      }
      a = c;
    }
  }
  function gYe(t, e, n) {
    let r = t.state.charCategorizer(e), i = r(n);
    return (s) => {
      let o = r(s);
      return i == $c.Space && (i = o), i == o;
    };
  }
  function mYe(t, e, n, r) {
    let i = e.head, s = n ? 1 : -1;
    if (i == (n ? t.state.doc.length : 0))
      return Ve.cursor(i, e.assoc);
    let o = e.goalColumn, a, l = t.contentDOM.getBoundingClientRect(), c = t.coordsAtPos(i, e.assoc || -1), u = t.documentTop;
    if (c)
      o == null && (o = c.left - l.left), a = s < 0 ? c.top : c.bottom;
    else {
      let f = t.viewState.lineBlockAt(i);
      o == null && (o = Math.min(l.right - l.left, t.defaultCharacterWidth * (i - f.from))), a = (s < 0 ? f.top : f.bottom) + u;
    }
    let d = l.left + o, h = r ?? t.viewState.heightOracle.textHeight >> 1;
    for (let f = 0; ; f += 10) {
      let y = a + (h + f) * s, g = coe(t, {
        x: d,
        y
      }, false, s);
      if (y < l.top || y > l.bottom || (s < 0 ? g < i : g > i)) {
        let O = t.docView.coordsForChar(g), S = !O || y < O.top ? -1 : 1;
        return Ve.cursor(g, S, void 0, o);
      }
    }
  }
  function cv(t, e, n) {
    for (; ; ) {
      let r = 0;
      for (let i of t)
        i.between(e - 1, e + 1, (s, o, a) => {
          if (e > s && e < o) {
            let l = r || n || (e - s < o - e ? -1 : 1);
            e = l < 0 ? s : o, r = l;
          }
        });
      if (!r)
        return e;
    }
  }
  function doe(t, e) {
    let n = null;
    for (let r = 0; r < e.ranges.length; r++) {
      let i = e.ranges[r], s = null;
      if (i.empty) {
        let o = cv(t, i.from, 0);
        o != i.from && (s = Ve.cursor(o, -1));
      } else {
        let o = cv(t, i.from, -1), a = cv(t, i.to, 1);
        (o != i.from || a != i.to) && (s = Ve.range(i.from == i.anchor ? o : a, i.from == i.head ? o : a));
      }
      s && (n || (n = e.ranges.slice()), n[r] = s);
    }
    return n ? Ve.create(n, e.mainIndex) : e;
  }
  function e$(t, e, n) {
    let r = cv(t.state.facet(PS).map((i) => i(t)), n.from, e.head > n.from ? -1 : 1);
    return r == n.from ? n : Ve.cursor(r, r < n.from ? 1 : -1);
  }
  const _0 = "\uFFFF";
  class yYe {
    constructor(e, n) {
      this.points = e, this.text = "", this.lineSeparator = n.facet(lr.lineSeparator);
    }
    append(e) {
      this.text += e;
    }
    lineBreak() {
      this.text += _0;
    }
    readRange(e, n) {
      if (!e)
        return this;
      let r = e.parentNode;
      for (let i = e; ; ) {
        this.findPointBefore(r, i);
        let s = this.text.length;
        this.readNode(i);
        let o = i.nextSibling;
        if (o == n)
          break;
        let a = sn.get(i), l = sn.get(o);
        (a && l ? a.breakAfter : (a ? a.breakAfter : aP(i)) || aP(o) && (i.nodeName != "BR" || i.cmIgnore) && this.text.length > s) && this.lineBreak(), i = o;
      }
      return this.findPointBefore(r, n), this;
    }
    readTextNode(e) {
      let n = e.nodeValue;
      for (let r of this.points)
        r.node == e && (r.pos = this.text.length + Math.min(r.offset, n.length));
      for (let r = 0, i = this.lineSeparator ? null : /\r\n?|\n/g; ; ) {
        let s = -1, o = 1, a;
        if (this.lineSeparator ? (s = n.indexOf(this.lineSeparator, r), o = this.lineSeparator.length) : (a = i.exec(n)) && (s = a.index, o = a[0].length), this.append(n.slice(r, s < 0 ? n.length : s)), s < 0)
          break;
        if (this.lineBreak(), o > 1)
          for (let l of this.points)
            l.node == e && l.pos > this.text.length && (l.pos -= o - 1);
        r = s + o;
      }
    }
    readNode(e) {
      if (e.cmIgnore)
        return;
      let n = sn.get(e), r = n && n.overrideDOMText;
      if (r != null) {
        this.findPointInside(e, r.length);
        for (let i = r.iter(); !i.next().done; )
          i.lineBreak ? this.lineBreak() : this.append(i.value);
      } else
        e.nodeType == 3 ? this.readTextNode(e) : e.nodeName == "BR" ? e.nextSibling && this.lineBreak() : e.nodeType == 1 && this.readRange(e.firstChild, null);
    }
    findPointBefore(e, n) {
      for (let r of this.points)
        r.node == e && e.childNodes[r.offset] == n && (r.pos = this.text.length);
    }
    findPointInside(e, n) {
      for (let r of this.points)
        (e.nodeType == 3 ? r.node == e : e.contains(r.node)) && (r.pos = this.text.length + (vYe(e, r.node, r.offset) ? n : 0));
    }
  }
  function vYe(t, e, n) {
    for (; ; ) {
      if (!e || n < Ul(e))
        return false;
      if (e == t)
        return true;
      n = df(e) + 1, e = e.parentNode;
    }
  }
  class sU {
    constructor(e, n) {
      this.node = e, this.offset = n, this.pos = -1;
    }
  }
  class OYe {
    constructor(e, n, r, i) {
      this.typeOver = i, this.bounds = null, this.text = "", this.domChanged = n > -1;
      let { impreciseHead: s, impreciseAnchor: o } = e.docView;
      if (e.state.readOnly && n > -1)
        this.newSel = null;
      else if (n > -1 && (this.bounds = e.docView.domBoundsAround(n, r, 0))) {
        let a = s || o ? [] : xYe(e), l = new yYe(a, e.state);
        l.readRange(this.bounds.startDOM, this.bounds.endDOM), this.text = l.text, this.newSel = bYe(a, this.bounds.from);
      } else {
        let a = e.observer.selectionRange, l = s && s.node == a.focusNode && s.offset == a.focusOffset || !IM(e.contentDOM, a.focusNode) ? e.state.selection.main.head : e.docView.posFromDOM(a.focusNode, a.focusOffset), c = o && o.node == a.anchorNode && o.offset == a.anchorOffset || !IM(e.contentDOM, a.anchorNode) ? e.state.selection.main.anchor : e.docView.posFromDOM(a.anchorNode, a.anchorOffset), u = e.viewport;
        if ((Ee.ios || Ee.chrome) && e.state.selection.main.empty && l != c && (u.from > 0 || u.to < e.state.doc.length)) {
          let d = Math.min(l, c), h = Math.max(l, c), f = u.from - d, y = u.to - h;
          (f == 0 || f == 1 || d == 0) && (y == 0 || y == -1 || h == e.state.doc.length) && (l = 0, c = e.state.doc.length);
        }
        this.newSel = Ve.single(c, l);
      }
    }
  }
  function hoe(t, e) {
    let n, { newSel: r } = e, i = t.state.selection.main, s = t.inputState.lastKeyTime > Date.now() - 100 ? t.inputState.lastKeyCode : -1;
    if (e.bounds) {
      let { from: o, to: a } = e.bounds, l = i.from, c = null;
      (s === 8 || Ee.android && e.text.length < a - o) && (l = i.to, c = "end");
      let u = wYe(t.state.doc.sliceString(o, a, _0), e.text, l - o, c);
      u && (Ee.chrome && s == 13 && u.toB == u.from + 2 && e.text.slice(u.from, u.toB) == _0 + _0 && u.toB--, n = {
        from: o + u.from,
        to: o + u.toA,
        insert: Qt.of(e.text.slice(u.from, u.toB).split(_0))
      });
    } else
      r && (!t.hasFocus && t.state.facet(_c) || r.main.eq(i)) && (r = null);
    if (!n && !r)
      return false;
    if (!n && e.typeOver && !i.empty && r && r.main.empty ? n = {
      from: i.from,
      to: i.to,
      insert: t.state.doc.slice(i.from, i.to)
    } : (Ee.mac || Ee.android) && n && n.from == n.to && n.from == i.head - 1 && /^\. ?$/.test(n.insert.toString()) && t.contentDOM.getAttribute("autocorrect") == "off" ? (r && n.insert.length == 2 && (r = Ve.single(r.main.anchor - 1, r.main.head - 1)), n = {
      from: n.from,
      to: n.to,
      insert: Qt.of([
        n.insert.toString().replace(".", " ")
      ])
    }) : n && n.from >= i.from && n.to <= i.to && (n.from != i.from || n.to != i.to) && i.to - i.from - (n.to - n.from) <= 4 ? n = {
      from: i.from,
      to: i.to,
      insert: t.state.doc.slice(i.from, n.from).append(n.insert).append(t.state.doc.slice(n.to, i.to))
    } : Ee.chrome && n && n.from == n.to && n.from == i.head && n.insert.toString() == `
 ` && t.lineWrapping && (r && (r = Ve.single(r.main.anchor - 1, r.main.head - 1)), n = {
      from: i.from,
      to: i.to,
      insert: Qt.of([
        " "
      ])
    }), n)
      return Cj(t, n, r, s);
    if (r && !r.main.eq(i)) {
      let o = false, a = "select";
      return t.inputState.lastSelectionTime > Date.now() - 50 && (t.inputState.lastSelectionOrigin == "select" && (o = true), a = t.inputState.lastSelectionOrigin, a == "select.pointer" && (r = doe(t.state.facet(PS).map((l) => l(t)), r))), t.dispatch({
        selection: r,
        scrollIntoView: o,
        userEvent: a
      }), true;
    } else
      return false;
  }
  function Cj(t, e, n, r = -1) {
    if (Ee.ios && t.inputState.flushIOSKey(e))
      return true;
    let i = t.state.selection.main;
    if (Ee.android && (e.to == i.to && (e.from == i.from || e.from == i.from - 1 && t.state.sliceDoc(e.from, i.from) == " ") && e.insert.length == 1 && e.insert.lines == 2 && Sg(t.contentDOM, "Enter", 13) || (e.from == i.from - 1 && e.to == i.to && e.insert.length == 0 || r == 8 && e.insert.length < e.to - e.from && e.to > i.head) && Sg(t.contentDOM, "Backspace", 8) || e.from == i.from && e.to == i.to + 1 && e.insert.length == 0 && Sg(t.contentDOM, "Delete", 46)))
      return true;
    let s = e.insert.toString();
    t.inputState.composing >= 0 && t.inputState.composing++;
    let o, a = () => o || (o = SYe(t, e, n));
    return t.state.facet(Jse).some((l) => l(t, e.from, e.to, s, a)) || t.dispatch(a()), true;
  }
  function SYe(t, e, n) {
    let r, i = t.state, s = i.selection.main, o = -1;
    if (e.from == e.to && e.from < s.from || e.from > s.to) {
      let l = e.from < s.from ? -1 : 1, c = l < 0 ? s.from : s.to, u = cv(i.facet(PS).map((d) => d(t)), c, l);
      e.from == u && (o = u);
    }
    if (o > -1)
      r = {
        changes: e,
        selection: Ve.cursor(e.from + e.insert.length, -1)
      };
    else if (e.from >= s.from && e.to <= s.to && e.to - e.from >= (s.to - s.from) / 3 && (!n || n.main.empty && n.main.from == e.from + e.insert.length) && t.inputState.composing < 0) {
      let l = s.from < e.from ? i.sliceDoc(s.from, e.from) : "", c = s.to > e.to ? i.sliceDoc(e.to, s.to) : "";
      r = i.replaceSelection(t.state.toText(l + e.insert.sliceString(0, void 0, t.state.lineBreak) + c));
    } else {
      let l = i.changes(e), c = n && n.main.to <= l.newLength ? n.main : void 0;
      if (i.selection.ranges.length > 1 && t.inputState.composing >= 0 && e.to <= s.to && e.to >= s.to - 10) {
        let u = t.state.sliceDoc(e.from, e.to), d, h = n && loe(t, n.main.head);
        if (h) {
          let g = e.insert.length - (e.to - e.from);
          d = {
            from: h.from,
            to: h.to - g
          };
        } else
          d = t.state.doc.lineAt(s.head);
        let f = s.to - e.to, y = s.to - s.from;
        r = i.changeByRange((g) => {
          if (g.from == s.from && g.to == s.to)
            return {
              changes: l,
              range: c || g.map(l)
            };
          let O = g.to - f, S = O - u.length;
          if (g.to - g.from != y || t.state.sliceDoc(S, O) != u || g.to >= d.from && g.from <= d.to)
            return {
              range: g
            };
          let w = i.changes({
            from: S,
            to: O,
            insert: e.insert
          }), x = g.to - s.to;
          return {
            changes: w,
            range: c ? Ve.range(Math.max(0, c.anchor + x), Math.max(0, c.head + x)) : g.map(w)
          };
        });
      } else
        r = {
          changes: l,
          selection: c && i.selection.replaceRange(c)
        };
    }
    let a = "input.type";
    return (t.composing || t.inputState.compositionPendingChange && t.inputState.compositionEndedAt > Date.now() - 50) && (t.inputState.compositionPendingChange = false, a += ".compose", t.inputState.compositionFirstChange && (a += ".start", t.inputState.compositionFirstChange = false)), i.update(r, {
      userEvent: a,
      scrollIntoView: true
    });
  }
  function wYe(t, e, n, r) {
    let i = Math.min(t.length, e.length), s = 0;
    for (; s < i && t.charCodeAt(s) == e.charCodeAt(s); )
      s++;
    if (s == i && t.length == e.length)
      return null;
    let o = t.length, a = e.length;
    for (; o > 0 && a > 0 && t.charCodeAt(o - 1) == e.charCodeAt(a - 1); )
      o--, a--;
    if (r == "end") {
      let l = Math.max(0, s - Math.min(o, a));
      n -= o + l - s;
    }
    if (o < s && t.length < e.length) {
      let l = n <= s && n >= o ? s - n : 0;
      s -= l, a = s + (a - o), o = s;
    } else if (a < s) {
      let l = n <= s && n >= a ? s - n : 0;
      s -= l, o = s + (o - a), a = s;
    }
    return {
      from: s,
      toA: o,
      toB: a
    };
  }
  function xYe(t) {
    let e = [];
    if (t.root.activeElement != t.contentDOM)
      return e;
    let { anchorNode: n, anchorOffset: r, focusNode: i, focusOffset: s } = t.observer.selectionRange;
    return n && (e.push(new sU(n, r)), (i != n || s != r) && e.push(new sU(i, s))), e;
  }
  function bYe(t, e) {
    if (t.length == 0)
      return null;
    let n = t[0].pos, r = t.length == 2 ? t[1].pos : n;
    return n > -1 && r > -1 ? Ve.single(n + e, r + e) : null;
  }
  class kYe {
    setSelectionOrigin(e) {
      this.lastSelectionOrigin = e, this.lastSelectionTime = Date.now();
    }
    constructor(e) {
      this.view = e, this.lastKeyCode = 0, this.lastKeyTime = 0, this.lastTouchTime = 0, this.lastFocusTime = 0, this.lastScrollTop = 0, this.lastScrollLeft = 0, this.pendingIOSKey = void 0, this.tabFocusMode = -1, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastContextMenu = 0, this.scrollHandlers = [], this.handlers = /* @__PURE__ */ Object.create(null), this.composing = -1, this.compositionFirstChange = null, this.compositionEndedAt = 0, this.compositionPendingKey = false, this.compositionPendingChange = false, this.mouseSelection = null, this.draggedContent = null, this.handleEvent = this.handleEvent.bind(this), this.notifiedFocused = e.hasFocus, Ee.safari && e.contentDOM.addEventListener("input", () => null), Ee.gecko && zYe(e.contentDOM.ownerDocument);
    }
    handleEvent(e) {
      !AYe(this.view, e) || this.ignoreDuringComposition(e) || e.type == "keydown" && this.keydown(e) || (this.view.updateState != 0 ? Promise.resolve().then(() => this.runHandlers(e.type, e)) : this.runHandlers(e.type, e));
    }
    runHandlers(e, n) {
      let r = this.handlers[e];
      if (r) {
        for (let i of r.observers)
          i(this.view, n);
        for (let i of r.handlers) {
          if (n.defaultPrevented)
            break;
          if (i(this.view, n)) {
            n.preventDefault();
            break;
          }
        }
      }
    }
    ensureHandlers(e) {
      let n = PYe(e), r = this.handlers, i = this.view.contentDOM;
      for (let s in n)
        if (s != "scroll") {
          let o = !n[s].handlers.length, a = r[s];
          a && o != !a.handlers.length && (i.removeEventListener(s, this.handleEvent), a = null), a || i.addEventListener(s, this.handleEvent, {
            passive: o
          });
        }
      for (let s in r)
        s != "scroll" && !n[s] && i.removeEventListener(s, this.handleEvent);
      this.handlers = n;
    }
    keydown(e) {
      if (this.lastKeyCode = e.keyCode, this.lastKeyTime = Date.now(), e.keyCode == 9 && this.tabFocusMode > -1 && (!this.tabFocusMode || Date.now() <= this.tabFocusMode))
        return true;
      if (this.tabFocusMode > 0 && e.keyCode != 27 && poe.indexOf(e.keyCode) < 0 && (this.tabFocusMode = -1), Ee.android && Ee.chrome && !e.synthetic && (e.keyCode == 13 || e.keyCode == 8))
        return this.view.observer.delayAndroidKey(e.key, e.keyCode), true;
      let n;
      return Ee.ios && !e.synthetic && !e.altKey && !e.metaKey && ((n = foe.find((r) => r.keyCode == e.keyCode)) && !e.ctrlKey || CYe.indexOf(e.key) > -1 && e.ctrlKey && !e.shiftKey) ? (this.pendingIOSKey = n || e, setTimeout(() => this.flushIOSKey(), 250), true) : (e.keyCode != 229 && this.view.observer.forceFlush(), false);
    }
    flushIOSKey(e) {
      let n = this.pendingIOSKey;
      return !n || n.key == "Enter" && e && e.from < e.to && /^\S+$/.test(e.insert.toString()) ? false : (this.pendingIOSKey = void 0, Sg(this.view.contentDOM, n.key, n.keyCode, n instanceof KeyboardEvent ? n : void 0));
    }
    ignoreDuringComposition(e) {
      return /^key/.test(e.type) ? this.composing > 0 ? true : Ee.safari && !Ee.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100 ? (this.compositionPendingKey = false, true) : false : false;
    }
    startMouseSelection(e) {
      this.mouseSelection && this.mouseSelection.destroy(), this.mouseSelection = e;
    }
    update(e) {
      this.view.observer.update(e), this.mouseSelection && this.mouseSelection.update(e), this.draggedContent && e.docChanged && (this.draggedContent = this.draggedContent.map(e.changes)), e.transactions.length && (this.lastKeyCode = this.lastSelectionTime = 0);
    }
    destroy() {
      this.mouseSelection && this.mouseSelection.destroy();
    }
  }
  function oU(t, e) {
    return (n, r) => {
      try {
        return e.call(t, r, n);
      } catch (i) {
        Vo(n.state, i);
      }
    };
  }
  function PYe(t) {
    let e = /* @__PURE__ */ Object.create(null);
    function n(r) {
      return e[r] || (e[r] = {
        observers: [],
        handlers: []
      });
    }
    for (let r of t) {
      let i = r.spec, s = i && i.plugin.domEventHandlers, o = i && i.plugin.domEventObservers;
      if (s)
        for (let a in s) {
          let l = s[a];
          l && n(a).handlers.push(oU(r.value, l));
        }
      if (o)
        for (let a in o) {
          let l = o[a];
          l && n(a).observers.push(oU(r.value, l));
        }
    }
    for (let r in Ya)
      n(r).handlers.push(Ya[r]);
    for (let r in ra)
      n(r).observers.push(ra[r]);
    return e;
  }
  const foe = [
    {
      key: "Backspace",
      keyCode: 8,
      inputType: "deleteContentBackward"
    },
    {
      key: "Enter",
      keyCode: 13,
      inputType: "insertParagraph"
    },
    {
      key: "Enter",
      keyCode: 13,
      inputType: "insertLineBreak"
    },
    {
      key: "Delete",
      keyCode: 46,
      inputType: "deleteContentForward"
    }
  ], CYe = "dthko", poe = [
    16,
    17,
    18,
    20,
    91,
    92,
    224,
    225
  ], ex = 6;
  function tx(t) {
    return Math.max(0, t) * 0.7 + 8;
  }
  function _Ye(t, e) {
    return Math.max(Math.abs(t.clientX - e.clientX), Math.abs(t.clientY - e.clientY));
  }
  class TYe {
    constructor(e, n, r, i) {
      this.view = e, this.startEvent = n, this.style = r, this.mustSelect = i, this.scrollSpeed = {
        x: 0,
        y: 0
      }, this.scrolling = -1, this.lastEvent = n, this.scrollParents = MHe(e.contentDOM), this.atoms = e.state.facet(PS).map((o) => o(e));
      let s = e.contentDOM.ownerDocument;
      s.addEventListener("mousemove", this.move = this.move.bind(this)), s.addEventListener("mouseup", this.up = this.up.bind(this)), this.extend = n.shiftKey, this.multiple = e.state.facet(lr.allowMultipleSelections) && EYe(e, n), this.dragging = $Ye(e, n) && yoe(n) == 1 ? null : false;
    }
    start(e) {
      this.dragging === false && this.select(e);
    }
    move(e) {
      if (e.buttons == 0)
        return this.destroy();
      if (this.dragging || this.dragging == null && _Ye(this.startEvent, e) < 10)
        return;
      this.select(this.lastEvent = e);
      let n = 0, r = 0, i = 0, s = 0, o = this.view.win.innerWidth, a = this.view.win.innerHeight;
      this.scrollParents.x && ({ left: i, right: o } = this.scrollParents.x.getBoundingClientRect()), this.scrollParents.y && ({ top: s, bottom: a } = this.scrollParents.y.getBoundingClientRect());
      let l = Pj(this.view);
      e.clientX - l.left <= i + ex ? n = -tx(i - e.clientX) : e.clientX + l.right >= o - ex && (n = tx(e.clientX - o)), e.clientY - l.top <= s + ex ? r = -tx(s - e.clientY) : e.clientY + l.bottom >= a - ex && (r = tx(e.clientY - a)), this.setScrollSpeed(n, r);
    }
    up(e) {
      this.dragging == null && this.select(this.lastEvent), this.dragging || e.preventDefault(), this.destroy();
    }
    destroy() {
      this.setScrollSpeed(0, 0);
      let e = this.view.contentDOM.ownerDocument;
      e.removeEventListener("mousemove", this.move), e.removeEventListener("mouseup", this.up), this.view.inputState.mouseSelection = this.view.inputState.draggedContent = null;
    }
    setScrollSpeed(e, n) {
      this.scrollSpeed = {
        x: e,
        y: n
      }, e || n ? this.scrolling < 0 && (this.scrolling = setInterval(() => this.scroll(), 50)) : this.scrolling > -1 && (clearInterval(this.scrolling), this.scrolling = -1);
    }
    scroll() {
      let { x: e, y: n } = this.scrollSpeed;
      e && this.scrollParents.x && (this.scrollParents.x.scrollLeft += e, e = 0), n && this.scrollParents.y && (this.scrollParents.y.scrollTop += n, n = 0), (e || n) && this.view.win.scrollBy(e, n), this.dragging === false && this.select(this.lastEvent);
    }
    select(e) {
      let { view: n } = this, r = doe(this.atoms, this.style.get(e, this.extend, this.multiple));
      (this.mustSelect || !r.eq(n.state.selection, this.dragging === false)) && this.view.dispatch({
        selection: r,
        userEvent: "select.pointer"
      }), this.mustSelect = false;
    }
    update(e) {
      e.transactions.some((n) => n.isUserEvent("input.type")) ? this.destroy() : this.style.update(e) && setTimeout(() => this.select(this.lastEvent), 20);
    }
  }
  function EYe(t, e) {
    let n = t.state.facet(Yse);
    return n.length ? n[0](e) : Ee.mac ? e.metaKey : e.ctrlKey;
  }
  function IYe(t, e) {
    let n = t.state.facet(Gse);
    return n.length ? n[0](e) : Ee.mac ? !e.altKey : !e.ctrlKey;
  }
  function $Ye(t, e) {
    let { main: n } = t.state.selection;
    if (n.empty)
      return false;
    let r = fO(t.root);
    if (!r || r.rangeCount == 0)
      return true;
    let i = r.getRangeAt(0).getClientRects();
    for (let s = 0; s < i.length; s++) {
      let o = i[s];
      if (o.left <= e.clientX && o.right >= e.clientX && o.top <= e.clientY && o.bottom >= e.clientY)
        return true;
    }
    return false;
  }
  function AYe(t, e) {
    if (!e.bubbles)
      return true;
    if (e.defaultPrevented)
      return false;
    for (let n = e.target, r; n != t.contentDOM; n = n.parentNode)
      if (!n || n.nodeType == 11 || (r = sn.get(n)) && r.ignoreEvent(e))
        return false;
    return true;
  }
  const Ya = /* @__PURE__ */ Object.create(null), ra = /* @__PURE__ */ Object.create(null), goe = Ee.ie && Ee.ie_version < 15 || Ee.ios && Ee.webkit_version < 604;
  function RYe(t) {
    let e = t.dom.parentNode;
    if (!e)
      return;
    let n = e.appendChild(document.createElement("textarea"));
    n.style.cssText = "position: fixed; left: -10000px; top: 10px", n.focus(), setTimeout(() => {
      t.focus(), n.remove(), moe(t, n.value);
    }, 50);
  }
  function T2(t, e, n) {
    for (let r of t.facet(e))
      n = r(n, t);
    return n;
  }
  function moe(t, e) {
    e = T2(t.state, xj, e);
    let { state: n } = t, r, i = 1, s = n.toText(e), o = s.lines == n.selection.ranges.length;
    if (BM != null && n.selection.ranges.every((l) => l.empty) && BM == s.toString()) {
      let l = -1;
      r = n.changeByRange((c) => {
        let u = n.doc.lineAt(c.from);
        if (u.from == l)
          return {
            range: c
          };
        l = u.from;
        let d = n.toText((o ? s.line(i++).text : e) + n.lineBreak);
        return {
          changes: {
            from: u.from,
            insert: d
          },
          range: Ve.cursor(c.from + d.length)
        };
      });
    } else
      o ? r = n.changeByRange((l) => {
        let c = s.line(i++);
        return {
          changes: {
            from: l.from,
            to: l.to,
            insert: c.text
          },
          range: Ve.cursor(l.from + c.length)
        };
      }) : r = n.replaceSelection(s);
    t.dispatch(r, {
      userEvent: "input.paste",
      scrollIntoView: true
    });
  }
  ra.scroll = (t) => {
    t.inputState.lastScrollTop = t.scrollDOM.scrollTop, t.inputState.lastScrollLeft = t.scrollDOM.scrollLeft;
  };
  Ya.keydown = (t, e) => (t.inputState.setSelectionOrigin("select"), e.keyCode == 27 && t.inputState.tabFocusMode != 0 && (t.inputState.tabFocusMode = Date.now() + 2e3), false);
  ra.touchstart = (t, e) => {
    t.inputState.lastTouchTime = Date.now(), t.inputState.setSelectionOrigin("select.pointer");
  };
  ra.touchmove = (t) => {
    t.inputState.setSelectionOrigin("select.pointer");
  };
  Ya.mousedown = (t, e) => {
    if (t.observer.flush(), t.inputState.lastTouchTime > Date.now() - 2e3)
      return false;
    let n = null;
    for (let r of t.state.facet(qse))
      if (n = r(t, e), n)
        break;
    if (!n && e.button == 0 && (n = LYe(t, e)), n) {
      let r = !t.hasFocus;
      t.inputState.startMouseSelection(new TYe(t, e, n, r)), r && t.observer.ignore(() => {
        Ise(t.contentDOM);
        let s = t.root.activeElement;
        s && !s.contains(t.contentDOM) && s.blur();
      });
      let i = t.inputState.mouseSelection;
      if (i)
        return i.start(e), i.dragging === false;
    } else
      t.inputState.setSelectionOrigin("select.pointer");
    return false;
  };
  function aU(t, e, n, r) {
    if (r == 1)
      return Ve.cursor(e, n);
    if (r == 2)
      return lYe(t.state, e, n);
    {
      let i = or.find(t.docView, e), s = t.state.doc.lineAt(i ? i.posAtEnd : e), o = i ? i.posAtStart : s.from, a = i ? i.posAtEnd : s.to;
      return a < t.state.doc.length && a == s.to && a++, Ve.range(o, a);
    }
  }
  let lU = (t, e, n) => e >= n.top && e <= n.bottom && t >= n.left && t <= n.right;
  function MYe(t, e, n, r) {
    let i = or.find(t.docView, e);
    if (!i)
      return 1;
    let s = e - i.posAtStart;
    if (s == 0)
      return 1;
    if (s == i.length)
      return -1;
    let o = i.coordsAt(s, -1);
    if (o && lU(n, r, o))
      return -1;
    let a = i.coordsAt(s, 1);
    return a && lU(n, r, a) ? 1 : o && o.bottom >= r ? -1 : 1;
  }
  function cU(t, e) {
    let n = t.posAtCoords({
      x: e.clientX,
      y: e.clientY
    }, false);
    return {
      pos: n,
      bias: MYe(t, n, e.clientX, e.clientY)
    };
  }
  const DYe = Ee.ie && Ee.ie_version <= 11;
  let uU = null, dU = 0, hU = 0;
  function yoe(t) {
    if (!DYe)
      return t.detail;
    let e = uU, n = hU;
    return uU = t, hU = Date.now(), dU = !e || n > Date.now() - 400 && Math.abs(e.clientX - t.clientX) < 2 && Math.abs(e.clientY - t.clientY) < 2 ? (dU + 1) % 3 : 1;
  }
  function LYe(t, e) {
    let n = cU(t, e), r = yoe(e), i = t.state.selection;
    return {
      update(s) {
        s.docChanged && (n.pos = s.changes.mapPos(n.pos), i = i.map(s.changes));
      },
      get(s, o, a) {
        let l = cU(t, s), c, u = aU(t, l.pos, l.bias, r);
        if (n.pos != l.pos && !o) {
          let d = aU(t, n.pos, n.bias, r), h = Math.min(d.from, u.from), f = Math.max(d.to, u.to);
          u = h < u.from ? Ve.range(h, f) : Ve.range(f, h);
        }
        return o ? i.replaceRange(i.main.extend(u.from, u.to)) : a && r == 1 && i.ranges.length > 1 && (c = jYe(i, l.pos)) ? c : a ? i.addRange(u) : Ve.create([
          u
        ]);
      }
    };
  }
  function jYe(t, e) {
    for (let n = 0; n < t.ranges.length; n++) {
      let { from: r, to: i } = t.ranges[n];
      if (r <= e && i >= e)
        return Ve.create(t.ranges.slice(0, n).concat(t.ranges.slice(n + 1)), t.mainIndex == n ? 0 : t.mainIndex - (t.mainIndex > n ? 1 : 0));
    }
    return null;
  }
  Ya.dragstart = (t, e) => {
    let { selection: { main: n } } = t.state;
    if (e.target.draggable) {
      let i = t.docView.nearest(e.target);
      if (i && i.isWidget) {
        let s = i.posAtStart, o = s + i.length;
        (s >= n.to || o <= n.from) && (n = Ve.range(s, o));
      }
    }
    let { inputState: r } = t;
    return r.mouseSelection && (r.mouseSelection.dragging = true), r.draggedContent = n, e.dataTransfer && (e.dataTransfer.setData("Text", T2(t.state, bj, t.state.sliceDoc(n.from, n.to))), e.dataTransfer.effectAllowed = "copyMove"), false;
  };
  Ya.dragend = (t) => (t.inputState.draggedContent = null, false);
  function fU(t, e, n, r) {
    if (n = T2(t.state, xj, n), !n)
      return;
    let i = t.posAtCoords({
      x: e.clientX,
      y: e.clientY
    }, false), { draggedContent: s } = t.inputState, o = r && s && IYe(t, e) ? {
      from: s.from,
      to: s.to
    } : null, a = {
      from: i,
      insert: n
    }, l = t.state.changes(o ? [
      o,
      a
    ] : a);
    t.focus(), t.dispatch({
      changes: l,
      selection: {
        anchor: l.mapPos(i, -1),
        head: l.mapPos(i, 1)
      },
      userEvent: o ? "move.drop" : "input.drop"
    }), t.inputState.draggedContent = null;
  }
  Ya.drop = (t, e) => {
    if (!e.dataTransfer)
      return false;
    if (t.state.readOnly)
      return true;
    let n = e.dataTransfer.files;
    if (n && n.length) {
      let r = Array(n.length), i = 0, s = () => {
        ++i == n.length && fU(t, e, r.filter((o) => o != null).join(t.state.lineBreak), false);
      };
      for (let o = 0; o < n.length; o++) {
        let a = new FileReader();
        a.onerror = s, a.onload = () => {
          /[\x00-\x08\x0e-\x1f]{2}/.test(a.result) || (r[o] = a.result), s();
        }, a.readAsText(n[o]);
      }
      return true;
    } else {
      let r = e.dataTransfer.getData("Text");
      if (r)
        return fU(t, e, r, true), true;
    }
    return false;
  };
  Ya.paste = (t, e) => {
    if (t.state.readOnly)
      return true;
    t.observer.flush();
    let n = goe ? null : e.clipboardData;
    return n ? (moe(t, n.getData("text/plain") || n.getData("text/uri-list")), true) : (RYe(t), false);
  };
  function NYe(t, e) {
    let n = t.dom.parentNode;
    if (!n)
      return;
    let r = n.appendChild(document.createElement("textarea"));
    r.style.cssText = "position: fixed; left: -10000px; top: 10px", r.value = e, r.focus(), r.selectionEnd = e.length, r.selectionStart = 0, setTimeout(() => {
      r.remove(), t.focus();
    }, 50);
  }
  function QYe(t) {
    let e = [], n = [], r = false;
    for (let i of t.selection.ranges)
      i.empty || (e.push(t.sliceDoc(i.from, i.to)), n.push(i));
    if (!e.length) {
      let i = -1;
      for (let { from: s } of t.selection.ranges) {
        let o = t.doc.lineAt(s);
        o.number > i && (e.push(o.text), n.push({
          from: o.from,
          to: Math.min(t.doc.length, o.to + 1)
        })), i = o.number;
      }
      r = true;
    }
    return {
      text: T2(t, bj, e.join(t.lineBreak)),
      ranges: n,
      linewise: r
    };
  }
  let BM = null;
  Ya.copy = Ya.cut = (t, e) => {
    let { text: n, ranges: r, linewise: i } = QYe(t.state);
    if (!n && !i)
      return false;
    BM = i ? n : null, e.type == "cut" && !t.state.readOnly && t.dispatch({
      changes: r,
      scrollIntoView: true,
      userEvent: "delete.cut"
    });
    let s = goe ? null : e.clipboardData;
    return s ? (s.clearData(), s.setData("text/plain", n), true) : (NYe(t, n), false);
  };
  const voe = Wd.define();
  function Ooe(t, e) {
    let n = [];
    for (let r of t.facet(eoe)) {
      let i = r(t, e);
      i && n.push(i);
    }
    return n.length ? t.update({
      effects: n,
      annotations: voe.of(true)
    }) : null;
  }
  function Soe(t) {
    setTimeout(() => {
      let e = t.hasFocus;
      if (e != t.inputState.notifiedFocused) {
        let n = Ooe(t.state, e);
        n ? t.dispatch(n) : t.update([]);
      }
    }, 10);
  }
  ra.focus = (t) => {
    t.inputState.lastFocusTime = Date.now(), !t.scrollDOM.scrollTop && (t.inputState.lastScrollTop || t.inputState.lastScrollLeft) && (t.scrollDOM.scrollTop = t.inputState.lastScrollTop, t.scrollDOM.scrollLeft = t.inputState.lastScrollLeft), Soe(t);
  };
  ra.blur = (t) => {
    t.observer.clearSelectionRange(), Soe(t);
  };
  ra.compositionstart = ra.compositionupdate = (t) => {
    t.observer.editContext || (t.inputState.compositionFirstChange == null && (t.inputState.compositionFirstChange = true), t.inputState.composing < 0 && (t.inputState.composing = 0));
  };
  ra.compositionend = (t) => {
    t.observer.editContext || (t.inputState.composing = -1, t.inputState.compositionEndedAt = Date.now(), t.inputState.compositionPendingKey = true, t.inputState.compositionPendingChange = t.observer.pendingRecords().length > 0, t.inputState.compositionFirstChange = null, Ee.chrome && Ee.android ? t.observer.flushSoon() : t.inputState.compositionPendingChange ? Promise.resolve().then(() => t.observer.flush()) : setTimeout(() => {
      t.inputState.composing < 0 && t.docView.hasComposition && t.update([]);
    }, 50));
  };
  ra.contextmenu = (t) => {
    t.inputState.lastContextMenu = Date.now();
  };
  Ya.beforeinput = (t, e) => {
    var n, r;
    if (e.inputType == "insertReplacementText" && t.observer.editContext) {
      let s = (n = e.dataTransfer) === null || n === void 0 ? void 0 : n.getData("text/plain"), o = e.getTargetRanges();
      if (s && o.length) {
        let a = o[0], l = t.posAtDOM(a.startContainer, a.startOffset), c = t.posAtDOM(a.endContainer, a.endOffset);
        return Cj(t, {
          from: l,
          to: c,
          insert: t.state.toText(s)
        }, null), true;
      }
    }
    let i;
    if (Ee.chrome && Ee.android && (i = foe.find((s) => s.inputType == e.inputType)) && (t.observer.delayAndroidKey(i.key, i.keyCode), i.key == "Backspace" || i.key == "Delete")) {
      let s = ((r = window.visualViewport) === null || r === void 0 ? void 0 : r.height) || 0;
      setTimeout(() => {
        var o;
        (((o = window.visualViewport) === null || o === void 0 ? void 0 : o.height) || 0) > s + 10 && t.hasFocus && (t.contentDOM.blur(), t.focus());
      }, 100);
    }
    return Ee.ios && e.inputType == "deleteContentForward" && t.observer.flushSoon(), Ee.safari && e.inputType == "insertText" && t.inputState.composing >= 0 && setTimeout(() => ra.compositionend(t, e), 20), false;
  };
  const pU = /* @__PURE__ */ new Set();
  function zYe(t) {
    pU.has(t) || (pU.add(t), t.addEventListener("copy", () => {
    }), t.addEventListener("cut", () => {
    }));
  }
  const gU = [
    "pre-wrap",
    "normal",
    "pre-line",
    "break-spaces"
  ];
  let rm = false;
  function mU() {
    rm = false;
  }
  class FYe {
    constructor(e) {
      this.lineWrapping = e, this.doc = Qt.empty, this.heightSamples = {}, this.lineHeight = 14, this.charWidth = 7, this.textHeight = 14, this.lineLength = 30;
    }
    heightForGap(e, n) {
      let r = this.doc.lineAt(n).number - this.doc.lineAt(e).number + 1;
      return this.lineWrapping && (r += Math.max(0, Math.ceil((n - e - r * this.lineLength * 0.5) / this.lineLength))), this.lineHeight * r;
    }
    heightForLine(e) {
      return this.lineWrapping ? (1 + Math.max(0, Math.ceil((e - this.lineLength) / Math.max(1, this.lineLength - 5)))) * this.lineHeight : this.lineHeight;
    }
    setDoc(e) {
      return this.doc = e, this;
    }
    mustRefreshForWrapping(e) {
      return gU.indexOf(e) > -1 != this.lineWrapping;
    }
    mustRefreshForHeights(e) {
      let n = false;
      for (let r = 0; r < e.length; r++) {
        let i = e[r];
        i < 0 ? r++ : this.heightSamples[Math.floor(i * 10)] || (n = true, this.heightSamples[Math.floor(i * 10)] = true);
      }
      return n;
    }
    refresh(e, n, r, i, s, o) {
      let a = gU.indexOf(e) > -1, l = Math.round(n) != Math.round(this.lineHeight) || this.lineWrapping != a;
      if (this.lineWrapping = a, this.lineHeight = n, this.charWidth = r, this.textHeight = i, this.lineLength = s, l) {
        this.heightSamples = {};
        for (let c = 0; c < o.length; c++) {
          let u = o[c];
          u < 0 ? c++ : this.heightSamples[Math.floor(u * 10)] = true;
        }
      }
      return l;
    }
  }
  class BYe {
    constructor(e, n) {
      this.from = e, this.heights = n, this.index = 0;
    }
    get more() {
      return this.index < this.heights.length;
    }
  }
  class kl {
    constructor(e, n, r, i, s) {
      this.from = e, this.length = n, this.top = r, this.height = i, this._content = s;
    }
    get type() {
      return typeof this._content == "number" ? Ml.Text : Array.isArray(this._content) ? this._content : this._content.type;
    }
    get to() {
      return this.from + this.length;
    }
    get bottom() {
      return this.top + this.height;
    }
    get widget() {
      return this._content instanceof $d ? this._content.widget : null;
    }
    get widgetLineBreaks() {
      return typeof this._content == "number" ? this._content : 0;
    }
    join(e) {
      let n = (Array.isArray(this._content) ? this._content : [
        this
      ]).concat(Array.isArray(e._content) ? e._content : [
        e
      ]);
      return new kl(this.from, this.length + e.length, this.top, this.height + e.height, n);
    }
  }
  var On = function(t) {
    return t[t.ByPos = 0] = "ByPos", t[t.ByHeight = 1] = "ByHeight", t[t.ByPosNoHeight = 2] = "ByPosNoHeight", t;
  }(On || (On = {}));
  const pb = 1e-3;
  class Ui {
    constructor(e, n, r = 2) {
      this.length = e, this.height = n, this.flags = r;
    }
    get outdated() {
      return (this.flags & 2) > 0;
    }
    set outdated(e) {
      this.flags = (e ? 2 : 0) | this.flags & -3;
    }
    setHeight(e) {
      this.height != e && (Math.abs(this.height - e) > pb && (rm = true), this.height = e);
    }
    replace(e, n, r) {
      return Ui.of(r);
    }
    decomposeLeft(e, n) {
      n.push(this);
    }
    decomposeRight(e, n) {
      n.push(this);
    }
    applyChanges(e, n, r, i) {
      let s = this, o = r.doc;
      for (let a = i.length - 1; a >= 0; a--) {
        let { fromA: l, toA: c, fromB: u, toB: d } = i[a], h = s.lineAt(l, On.ByPosNoHeight, r.setDoc(n), 0, 0), f = h.to >= c ? h : s.lineAt(c, On.ByPosNoHeight, r, 0, 0);
        for (d += f.to - c, c = f.to; a > 0 && h.from <= i[a - 1].toA; )
          l = i[a - 1].fromA, u = i[a - 1].fromB, a--, l < h.from && (h = s.lineAt(l, On.ByPosNoHeight, r, 0, 0));
        u += h.from - l, l = h.from;
        let y = _j.build(r.setDoc(o), e, u, d);
        s = uP(s, s.replace(l, c, y));
      }
      return s.updateHeight(r, 0);
    }
    static empty() {
      return new Vs(0, 0);
    }
    static of(e) {
      if (e.length == 1)
        return e[0];
      let n = 0, r = e.length, i = 0, s = 0;
      for (; ; )
        if (n == r)
          if (i > s * 2) {
            let a = e[n - 1];
            a.break ? e.splice(--n, 1, a.left, null, a.right) : e.splice(--n, 1, a.left, a.right), r += 1 + a.break, i -= a.size;
          } else if (s > i * 2) {
            let a = e[r];
            a.break ? e.splice(r, 1, a.left, null, a.right) : e.splice(r, 1, a.left, a.right), r += 2 + a.break, s -= a.size;
          } else
            break;
        else if (i < s) {
          let a = e[n++];
          a && (i += a.size);
        } else {
          let a = e[--r];
          a && (s += a.size);
        }
      let o = 0;
      return e[n - 1] == null ? (o = 1, n--) : e[n] == null && (o = 1, r++), new UYe(Ui.of(e.slice(0, n)), o, Ui.of(e.slice(r)));
    }
  }
  function uP(t, e) {
    return t == e ? t : (t.constructor != e.constructor && (rm = true), e);
  }
  Ui.prototype.size = 1;
  class woe extends Ui {
    constructor(e, n, r) {
      super(e, n), this.deco = r;
    }
    blockAt(e, n, r, i) {
      return new kl(i, this.length, r, this.height, this.deco || 0);
    }
    lineAt(e, n, r, i, s) {
      return this.blockAt(0, r, i, s);
    }
    forEachLine(e, n, r, i, s, o) {
      e <= s + this.length && n >= s && o(this.blockAt(0, r, i, s));
    }
    updateHeight(e, n = 0, r = false, i) {
      return i && i.from <= n && i.more && this.setHeight(i.heights[i.index++]), this.outdated = false, this;
    }
    toString() {
      return `block(${this.length})`;
    }
  }
  class Vs extends woe {
    constructor(e, n) {
      super(e, n, null), this.collapsed = 0, this.widgetHeight = 0, this.breaks = 0;
    }
    blockAt(e, n, r, i) {
      return new kl(i, this.length, r, this.height, this.breaks);
    }
    replace(e, n, r) {
      let i = r[0];
      return r.length == 1 && (i instanceof Vs || i instanceof jr && i.flags & 4) && Math.abs(this.length - i.length) < 10 ? (i instanceof jr ? i = new Vs(i.length, this.height) : i.height = this.height, this.outdated || (i.outdated = false), i) : Ui.of(r);
    }
    updateHeight(e, n = 0, r = false, i) {
      return i && i.from <= n && i.more ? this.setHeight(i.heights[i.index++]) : (r || this.outdated) && this.setHeight(Math.max(this.widgetHeight, e.heightForLine(this.length - this.collapsed)) + this.breaks * e.lineHeight), this.outdated = false, this;
    }
    toString() {
      return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
    }
  }
  class jr extends Ui {
    constructor(e) {
      super(e, 0);
    }
    heightMetrics(e, n) {
      let r = e.doc.lineAt(n).number, i = e.doc.lineAt(n + this.length).number, s = i - r + 1, o, a = 0;
      if (e.lineWrapping) {
        let l = Math.min(this.height, e.lineHeight * s);
        o = l / s, this.length > s + 1 && (a = (this.height - l) / (this.length - s - 1));
      } else
        o = this.height / s;
      return {
        firstLine: r,
        lastLine: i,
        perLine: o,
        perChar: a
      };
    }
    blockAt(e, n, r, i) {
      let { firstLine: s, lastLine: o, perLine: a, perChar: l } = this.heightMetrics(n, i);
      if (n.lineWrapping) {
        let c = i + (e < n.lineHeight ? 0 : Math.round(Math.max(0, Math.min(1, (e - r) / this.height)) * this.length)), u = n.doc.lineAt(c), d = a + u.length * l, h = Math.max(r, e - d / 2);
        return new kl(u.from, u.length, h, d, 0);
      } else {
        let c = Math.max(0, Math.min(o - s, Math.floor((e - r) / a))), { from: u, length: d } = n.doc.line(s + c);
        return new kl(u, d, r + a * c, a, 0);
      }
    }
    lineAt(e, n, r, i, s) {
      if (n == On.ByHeight)
        return this.blockAt(e, r, i, s);
      if (n == On.ByPosNoHeight) {
        let { from: f, to: y } = r.doc.lineAt(e);
        return new kl(f, y - f, 0, 0, 0);
      }
      let { firstLine: o, perLine: a, perChar: l } = this.heightMetrics(r, s), c = r.doc.lineAt(e), u = a + c.length * l, d = c.number - o, h = i + a * d + l * (c.from - s - d);
      return new kl(c.from, c.length, Math.max(i, Math.min(h, i + this.height - u)), u, 0);
    }
    forEachLine(e, n, r, i, s, o) {
      e = Math.max(e, s), n = Math.min(n, s + this.length);
      let { firstLine: a, perLine: l, perChar: c } = this.heightMetrics(r, s);
      for (let u = e, d = i; u <= n; ) {
        let h = r.doc.lineAt(u);
        if (u == e) {
          let y = h.number - a;
          d += l * y + c * (e - s - y);
        }
        let f = l + c * h.length;
        o(new kl(h.from, h.length, d, f, 0)), d += f, u = h.to + 1;
      }
    }
    replace(e, n, r) {
      let i = this.length - n;
      if (i > 0) {
        let s = r[r.length - 1];
        s instanceof jr ? r[r.length - 1] = new jr(s.length + i) : r.push(null, new jr(i - 1));
      }
      if (e > 0) {
        let s = r[0];
        s instanceof jr ? r[0] = new jr(e + s.length) : r.unshift(new jr(e - 1), null);
      }
      return Ui.of(r);
    }
    decomposeLeft(e, n) {
      n.push(new jr(e - 1), null);
    }
    decomposeRight(e, n) {
      n.push(null, new jr(this.length - e - 1));
    }
    updateHeight(e, n = 0, r = false, i) {
      let s = n + this.length;
      if (i && i.from <= n + this.length && i.more) {
        let o = [], a = Math.max(n, i.from), l = -1;
        for (i.from > n && o.push(new jr(i.from - n - 1).updateHeight(e, n)); a <= s && i.more; ) {
          let u = e.doc.lineAt(a).length;
          o.length && o.push(null);
          let d = i.heights[i.index++];
          l == -1 ? l = d : Math.abs(d - l) >= pb && (l = -2);
          let h = new Vs(u, d);
          h.outdated = false, o.push(h), a += u + 1;
        }
        a <= s && o.push(null, new jr(s - a).updateHeight(e, a));
        let c = Ui.of(o);
        return (l < 0 || Math.abs(c.height - this.height) >= pb || Math.abs(l - this.heightMetrics(e, n).perLine) >= pb) && (rm = true), uP(this, c);
      } else
        (r || this.outdated) && (this.setHeight(e.heightForGap(n, n + this.length)), this.outdated = false);
      return this;
    }
    toString() {
      return `gap(${this.length})`;
    }
  }
  class UYe extends Ui {
    constructor(e, n, r) {
      super(e.length + n + r.length, e.height + r.height, n | (e.outdated || r.outdated ? 2 : 0)), this.left = e, this.right = r, this.size = e.size + r.size;
    }
    get break() {
      return this.flags & 1;
    }
    blockAt(e, n, r, i) {
      let s = r + this.left.height;
      return e < s ? this.left.blockAt(e, n, r, i) : this.right.blockAt(e, n, s, i + this.left.length + this.break);
    }
    lineAt(e, n, r, i, s) {
      let o = i + this.left.height, a = s + this.left.length + this.break, l = n == On.ByHeight ? e < o : e < a, c = l ? this.left.lineAt(e, n, r, i, s) : this.right.lineAt(e, n, r, o, a);
      if (this.break || (l ? c.to < a : c.from > a))
        return c;
      let u = n == On.ByPosNoHeight ? On.ByPosNoHeight : On.ByPos;
      return l ? c.join(this.right.lineAt(a, u, r, o, a)) : this.left.lineAt(a, u, r, i, s).join(c);
    }
    forEachLine(e, n, r, i, s, o) {
      let a = i + this.left.height, l = s + this.left.length + this.break;
      if (this.break)
        e < l && this.left.forEachLine(e, n, r, i, s, o), n >= l && this.right.forEachLine(e, n, r, a, l, o);
      else {
        let c = this.lineAt(l, On.ByPos, r, i, s);
        e < c.from && this.left.forEachLine(e, c.from - 1, r, i, s, o), c.to >= e && c.from <= n && o(c), n > c.to && this.right.forEachLine(c.to + 1, n, r, a, l, o);
      }
    }
    replace(e, n, r) {
      let i = this.left.length + this.break;
      if (n < i)
        return this.balanced(this.left.replace(e, n, r), this.right);
      if (e > this.left.length)
        return this.balanced(this.left, this.right.replace(e - i, n - i, r));
      let s = [];
      e > 0 && this.decomposeLeft(e, s);
      let o = s.length;
      for (let a of r)
        s.push(a);
      if (e > 0 && yU(s, o - 1), n < this.length) {
        let a = s.length;
        this.decomposeRight(n, s), yU(s, a);
      }
      return Ui.of(s);
    }
    decomposeLeft(e, n) {
      let r = this.left.length;
      if (e <= r)
        return this.left.decomposeLeft(e, n);
      n.push(this.left), this.break && (r++, e >= r && n.push(null)), e > r && this.right.decomposeLeft(e - r, n);
    }
    decomposeRight(e, n) {
      let r = this.left.length, i = r + this.break;
      if (e >= i)
        return this.right.decomposeRight(e - i, n);
      e < r && this.left.decomposeRight(e, n), this.break && e < i && n.push(null), n.push(this.right);
    }
    balanced(e, n) {
      return e.size > 2 * n.size || n.size > 2 * e.size ? Ui.of(this.break ? [
        e,
        null,
        n
      ] : [
        e,
        n
      ]) : (this.left = uP(this.left, e), this.right = uP(this.right, n), this.setHeight(e.height + n.height), this.outdated = e.outdated || n.outdated, this.size = e.size + n.size, this.length = e.length + this.break + n.length, this);
    }
    updateHeight(e, n = 0, r = false, i) {
      let { left: s, right: o } = this, a = n + s.length + this.break, l = null;
      return i && i.from <= n + s.length && i.more ? l = s = s.updateHeight(e, n, r, i) : s.updateHeight(e, n, r), i && i.from <= a + o.length && i.more ? l = o = o.updateHeight(e, a, r, i) : o.updateHeight(e, a, r), l ? this.balanced(s, o) : (this.height = this.left.height + this.right.height, this.outdated = false, this);
    }
    toString() {
      return this.left + (this.break ? " " : "-") + this.right;
    }
  }
  function yU(t, e) {
    let n, r;
    t[e] == null && (n = t[e - 1]) instanceof jr && (r = t[e + 1]) instanceof jr && t.splice(e - 1, 3, new jr(n.length + 1 + r.length));
  }
  const VYe = 5;
  class _j {
    constructor(e, n) {
      this.pos = e, this.oracle = n, this.nodes = [], this.lineStart = -1, this.lineEnd = -1, this.covering = null, this.writtenTo = e;
    }
    get isCovered() {
      return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
    }
    span(e, n) {
      if (this.lineStart > -1) {
        let r = Math.min(n, this.lineEnd), i = this.nodes[this.nodes.length - 1];
        i instanceof Vs ? i.length += r - this.pos : (r > this.pos || !this.isCovered) && this.nodes.push(new Vs(r - this.pos, -1)), this.writtenTo = r, n > r && (this.nodes.push(null), this.writtenTo++, this.lineStart = -1);
      }
      this.pos = n;
    }
    point(e, n, r) {
      if (e < n || r.heightRelevant) {
        let i = r.widget ? r.widget.estimatedHeight : 0, s = r.widget ? r.widget.lineBreaks : 0;
        i < 0 && (i = this.oracle.lineHeight);
        let o = n - e;
        r.block ? this.addBlock(new woe(o, i, r)) : (o || s || i >= VYe) && this.addLineDeco(i, s, o);
      } else
        n > e && this.span(e, n);
      this.lineEnd > -1 && this.lineEnd < this.pos && (this.lineEnd = this.oracle.doc.lineAt(this.pos).to);
    }
    enterLine() {
      if (this.lineStart > -1)
        return;
      let { from: e, to: n } = this.oracle.doc.lineAt(this.pos);
      this.lineStart = e, this.lineEnd = n, this.writtenTo < e && ((this.writtenTo < e - 1 || this.nodes[this.nodes.length - 1] == null) && this.nodes.push(this.blankContent(this.writtenTo, e - 1)), this.nodes.push(null)), this.pos > e && this.nodes.push(new Vs(this.pos - e, -1)), this.writtenTo = this.pos;
    }
    blankContent(e, n) {
      let r = new jr(n - e);
      return this.oracle.doc.lineAt(e).to == n && (r.flags |= 4), r;
    }
    ensureLine() {
      this.enterLine();
      let e = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
      if (e instanceof Vs)
        return e;
      let n = new Vs(0, -1);
      return this.nodes.push(n), n;
    }
    addBlock(e) {
      this.enterLine();
      let n = e.deco;
      n && n.startSide > 0 && !this.isCovered && this.ensureLine(), this.nodes.push(e), this.writtenTo = this.pos = this.pos + e.length, n && n.endSide > 0 && (this.covering = e);
    }
    addLineDeco(e, n, r) {
      let i = this.ensureLine();
      i.length += r, i.collapsed += r, i.widgetHeight = Math.max(i.widgetHeight, e), i.breaks += n, this.writtenTo = this.pos = this.pos + r;
    }
    finish(e) {
      let n = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
      this.lineStart > -1 && !(n instanceof Vs) && !this.isCovered ? this.nodes.push(new Vs(0, -1)) : (this.writtenTo < this.pos || n == null) && this.nodes.push(this.blankContent(this.writtenTo, this.pos));
      let r = e;
      for (let i of this.nodes)
        i instanceof Vs && i.updateHeight(this.oracle, r), r += i ? i.length : 1;
      return this.nodes;
    }
    static build(e, n, r, i) {
      let s = new _j(r, e);
      return Pi.spans(n, r, i, s, 0), s.finish(r);
    }
  }
  function XYe(t, e, n) {
    let r = new WYe();
    return Pi.compare(t, e, n, r, 0), r.changes;
  }
  class WYe {
    constructor() {
      this.changes = [];
    }
    compareRange() {
    }
    comparePoint(e, n, r, i) {
      (e < n || r && r.heightRelevant || i && i.heightRelevant) && fb(e, n, this.changes, 5);
    }
  }
  function ZYe(t, e) {
    let n = t.getBoundingClientRect(), r = t.ownerDocument, i = r.defaultView || window, s = Math.max(0, n.left), o = Math.min(i.innerWidth, n.right), a = Math.max(0, n.top), l = Math.min(i.innerHeight, n.bottom);
    for (let c = t.parentNode; c && c != r.body; )
      if (c.nodeType == 1) {
        let u = c, d = window.getComputedStyle(u);
        if ((u.scrollHeight > u.clientHeight || u.scrollWidth > u.clientWidth) && d.overflow != "visible") {
          let h = u.getBoundingClientRect();
          s = Math.max(s, h.left), o = Math.min(o, h.right), a = Math.max(a, h.top), l = Math.min(c == t.parentNode ? i.innerHeight : l, h.bottom);
        }
        c = d.position == "absolute" || d.position == "fixed" ? u.offsetParent : u.parentNode;
      } else if (c.nodeType == 11)
        c = c.host;
      else
        break;
    return {
      left: s - n.left,
      right: Math.max(s, o) - n.left,
      top: a - (n.top + e),
      bottom: Math.max(a, l) - (n.top + e)
    };
  }
  function HYe(t) {
    let e = t.getBoundingClientRect(), n = t.ownerDocument.defaultView || window;
    return e.left < n.innerWidth && e.right > 0 && e.top < n.innerHeight && e.bottom > 0;
  }
  function YYe(t, e) {
    let n = t.getBoundingClientRect();
    return {
      left: 0,
      right: n.right - n.left,
      top: e,
      bottom: n.bottom - (n.top + e)
    };
  }
  class t$ {
    constructor(e, n, r, i) {
      this.from = e, this.to = n, this.size = r, this.displaySize = i;
    }
    static same(e, n) {
      if (e.length != n.length)
        return false;
      for (let r = 0; r < e.length; r++) {
        let i = e[r], s = n[r];
        if (i.from != s.from || i.to != s.to || i.size != s.size)
          return false;
      }
      return true;
    }
    draw(e, n) {
      return Qe.replace({
        widget: new GYe(this.displaySize * (n ? e.scaleY : e.scaleX), n)
      }).range(this.from, this.to);
    }
  }
  class GYe extends Yl {
    constructor(e, n) {
      super(), this.size = e, this.vertical = n;
    }
    eq(e) {
      return e.size == this.size && e.vertical == this.vertical;
    }
    toDOM() {
      let e = document.createElement("div");
      return this.vertical ? e.style.height = this.size + "px" : (e.style.width = this.size + "px", e.style.height = "2px", e.style.display = "inline-block"), e;
    }
    get estimatedHeight() {
      return this.vertical ? this.size : -1;
    }
  }
  class vU {
    constructor(e) {
      this.state = e, this.pixelViewport = {
        left: 0,
        right: window.innerWidth,
        top: 0,
        bottom: 0
      }, this.inView = true, this.paddingTop = 0, this.paddingBottom = 0, this.contentDOMWidth = 0, this.contentDOMHeight = 0, this.editorHeight = 0, this.editorWidth = 0, this.scrollTop = 0, this.scrolledToBottom = false, this.scaleX = 1, this.scaleY = 1, this.scrollAnchorPos = 0, this.scrollAnchorHeight = -1, this.scaler = OU, this.scrollTarget = null, this.printing = false, this.mustMeasureContent = true, this.defaultTextDirection = er.LTR, this.visibleRanges = [], this.mustEnforceCursorAssoc = false;
      let n = e.facet(kj).some((r) => typeof r != "function" && r.class == "cm-lineWrapping");
      this.heightOracle = new FYe(n), this.stateDeco = e.facet(gO).filter((r) => typeof r != "function"), this.heightMap = Ui.empty().applyChanges(this.stateDeco, Qt.empty, this.heightOracle.setDoc(e.doc), [
        new Go(0, 0, 0, e.doc.length)
      ]);
      for (let r = 0; r < 2 && (this.viewport = this.getViewport(0, null), !!this.updateForViewport()); r++)
        ;
      this.updateViewportLines(), this.lineGaps = this.ensureLineGaps([]), this.lineGapDeco = Qe.set(this.lineGaps.map((r) => r.draw(this, false))), this.computeVisibleRanges();
    }
    updateForViewport() {
      let e = [
        this.viewport
      ], { main: n } = this.state.selection;
      for (let r = 0; r <= 1; r++) {
        let i = r ? n.head : n.anchor;
        if (!e.some(({ from: s, to: o }) => i >= s && i <= o)) {
          let { from: s, to: o } = this.lineBlockAt(i);
          e.push(new nx(s, o));
        }
      }
      return this.viewports = e.sort((r, i) => r.from - i.from), this.updateScaler();
    }
    updateScaler() {
      let e = this.scaler;
      return this.scaler = this.heightMap.height <= 7e6 ? OU : new Tj(this.heightOracle, this.heightMap, this.viewports), e.eq(this.scaler) ? 0 : 2;
    }
    updateViewportLines() {
      this.viewportLines = [], this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, (e) => {
        this.viewportLines.push(T0(e, this.scaler));
      });
    }
    update(e, n = null) {
      this.state = e.state;
      let r = this.stateDeco;
      this.stateDeco = this.state.facet(gO).filter((u) => typeof u != "function");
      let i = e.changedRanges, s = Go.extendWithRanges(i, XYe(r, this.stateDeco, e ? e.changes : Za.empty(this.state.doc.length))), o = this.heightMap.height, a = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);
      mU(), this.heightMap = this.heightMap.applyChanges(this.stateDeco, e.startState.doc, this.heightOracle.setDoc(this.state.doc), s), (this.heightMap.height != o || rm) && (e.flags |= 2), a ? (this.scrollAnchorPos = e.changes.mapPos(a.from, -1), this.scrollAnchorHeight = a.top) : (this.scrollAnchorPos = -1, this.scrollAnchorHeight = o);
      let l = s.length ? this.mapViewport(this.viewport, e.changes) : this.viewport;
      (n && (n.range.head < l.from || n.range.head > l.to) || !this.viewportIsAppropriate(l)) && (l = this.getViewport(0, n));
      let c = l.from != this.viewport.from || l.to != this.viewport.to;
      this.viewport = l, e.flags |= this.updateForViewport(), (c || !e.changes.empty || e.flags & 2) && this.updateViewportLines(), (this.lineGaps.length || this.viewport.to - this.viewport.from > 4e3) && this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, e.changes))), e.flags |= this.computeVisibleRanges(e.changes), n && (this.scrollTarget = n), !this.mustEnforceCursorAssoc && e.selectionSet && e.view.lineWrapping && e.state.selection.main.empty && e.state.selection.main.assoc && !e.state.facet(JHe) && (this.mustEnforceCursorAssoc = true);
    }
    measure(e) {
      let n = e.contentDOM, r = window.getComputedStyle(n), i = this.heightOracle, s = r.whiteSpace;
      this.defaultTextDirection = r.direction == "rtl" ? er.RTL : er.LTR;
      let o = this.heightOracle.mustRefreshForWrapping(s), a = n.getBoundingClientRect(), l = o || this.mustMeasureContent || this.contentDOMHeight != a.height;
      this.contentDOMHeight = a.height, this.mustMeasureContent = false;
      let c = 0, u = 0;
      if (a.width && a.height) {
        let { scaleX: P, scaleY: C } = Ese(n, a);
        (P > 5e-3 && Math.abs(this.scaleX - P) > 5e-3 || C > 5e-3 && Math.abs(this.scaleY - C) > 5e-3) && (this.scaleX = P, this.scaleY = C, c |= 16, o = l = true);
      }
      let d = (parseInt(r.paddingTop) || 0) * this.scaleY, h = (parseInt(r.paddingBottom) || 0) * this.scaleY;
      (this.paddingTop != d || this.paddingBottom != h) && (this.paddingTop = d, this.paddingBottom = h, c |= 18), this.editorWidth != e.scrollDOM.clientWidth && (i.lineWrapping && (l = true), this.editorWidth = e.scrollDOM.clientWidth, c |= 16);
      let f = e.scrollDOM.scrollTop * this.scaleY;
      this.scrollTop != f && (this.scrollAnchorHeight = -1, this.scrollTop = f), this.scrolledToBottom = Ase(e.scrollDOM);
      let y = (this.printing ? YYe : ZYe)(n, this.paddingTop), g = y.top - this.pixelViewport.top, O = y.bottom - this.pixelViewport.bottom;
      this.pixelViewport = y;
      let S = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
      if (S != this.inView && (this.inView = S, S && (l = true)), !this.inView && !this.scrollTarget && !HYe(e.dom))
        return 0;
      let w = a.width;
      if ((this.contentDOMWidth != w || this.editorHeight != e.scrollDOM.clientHeight) && (this.contentDOMWidth = a.width, this.editorHeight = e.scrollDOM.clientHeight, c |= 16), l) {
        let P = e.docView.measureVisibleLineHeights(this.viewport);
        if (i.mustRefreshForHeights(P) && (o = true), o || i.lineWrapping && Math.abs(w - this.contentDOMWidth) > i.charWidth) {
          let { lineHeight: C, charWidth: _, textHeight: T } = e.docView.measureTextSize();
          o = C > 0 && i.refresh(s, C, _, T, Math.max(5, w / _), P), o && (e.docView.minWidth = 0, c |= 16);
        }
        g > 0 && O > 0 ? u = Math.max(g, O) : g < 0 && O < 0 && (u = Math.min(g, O)), mU();
        for (let C of this.viewports) {
          let _ = C.from == this.viewport.from ? P : e.docView.measureVisibleLineHeights(C);
          this.heightMap = (o ? Ui.empty().applyChanges(this.stateDeco, Qt.empty, this.heightOracle, [
            new Go(0, 0, 0, e.state.doc.length)
          ]) : this.heightMap).updateHeight(i, 0, o, new BYe(C.from, _));
        }
        rm && (c |= 2);
      }
      let x = !this.viewportIsAppropriate(this.viewport, u) || this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
      return x && (c & 2 && (c |= this.updateScaler()), this.viewport = this.getViewport(u, this.scrollTarget), c |= this.updateForViewport()), (c & 2 || x) && this.updateViewportLines(), (this.lineGaps.length || this.viewport.to - this.viewport.from > 4e3) && this.updateLineGaps(this.ensureLineGaps(o ? [] : this.lineGaps, e)), c |= this.computeVisibleRanges(), this.mustEnforceCursorAssoc && (this.mustEnforceCursorAssoc = false, e.docView.enforceCursorAssoc()), c;
    }
    get visibleTop() {
      return this.scaler.fromDOM(this.pixelViewport.top);
    }
    get visibleBottom() {
      return this.scaler.fromDOM(this.pixelViewport.bottom);
    }
    getViewport(e, n) {
      let r = 0.5 - Math.max(-0.5, Math.min(0.5, e / 1e3 / 2)), i = this.heightMap, s = this.heightOracle, { visibleTop: o, visibleBottom: a } = this, l = new nx(i.lineAt(o - r * 1e3, On.ByHeight, s, 0, 0).from, i.lineAt(a + (1 - r) * 1e3, On.ByHeight, s, 0, 0).to);
      if (n) {
        let { head: c } = n.range;
        if (c < l.from || c > l.to) {
          let u = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top), d = i.lineAt(c, On.ByPos, s, 0, 0), h;
          n.y == "center" ? h = (d.top + d.bottom) / 2 - u / 2 : n.y == "start" || n.y == "nearest" && c < l.from ? h = d.top : h = d.bottom - u, l = new nx(i.lineAt(h - 1e3 / 2, On.ByHeight, s, 0, 0).from, i.lineAt(h + u + 1e3 / 2, On.ByHeight, s, 0, 0).to);
        }
      }
      return l;
    }
    mapViewport(e, n) {
      let r = n.mapPos(e.from, -1), i = n.mapPos(e.to, 1);
      return new nx(this.heightMap.lineAt(r, On.ByPos, this.heightOracle, 0, 0).from, this.heightMap.lineAt(i, On.ByPos, this.heightOracle, 0, 0).to);
    }
    viewportIsAppropriate({ from: e, to: n }, r = 0) {
      if (!this.inView)
        return true;
      let { top: i } = this.heightMap.lineAt(e, On.ByPos, this.heightOracle, 0, 0), { bottom: s } = this.heightMap.lineAt(n, On.ByPos, this.heightOracle, 0, 0), { visibleTop: o, visibleBottom: a } = this;
      return (e == 0 || i <= o - Math.max(10, Math.min(-r, 250))) && (n == this.state.doc.length || s >= a + Math.max(10, Math.min(r, 250))) && i > o - 2 * 1e3 && s < a + 2 * 1e3;
    }
    mapLineGaps(e, n) {
      if (!e.length || n.empty)
        return e;
      let r = [];
      for (let i of e)
        n.touchesRange(i.from, i.to) || r.push(new t$(n.mapPos(i.from), n.mapPos(i.to), i.size, i.displaySize));
      return r;
    }
    ensureLineGaps(e, n) {
      let r = this.heightOracle.lineWrapping, i = r ? 1e4 : 2e3, s = i >> 1, o = i << 1;
      if (this.defaultTextDirection != er.LTR && !r)
        return [];
      let a = [], l = (u, d, h, f) => {
        if (d - u < s)
          return;
        let y = this.state.selection.main, g = [
          y.from
        ];
        y.empty || g.push(y.to);
        for (let S of g)
          if (S > u && S < d) {
            l(u, S - 10, h, f), l(S + 10, d, h, f);
            return;
          }
        let O = KYe(e, (S) => S.from >= h.from && S.to <= h.to && Math.abs(S.from - u) < s && Math.abs(S.to - d) < s && !g.some((w) => S.from < w && S.to > w));
        if (!O) {
          if (d < h.to && n && r && n.visibleRanges.some((x) => x.from <= d && x.to >= d)) {
            let x = n.moveToLineBoundary(Ve.cursor(d), false, true).head;
            x > u && (d = x);
          }
          let S = this.gapSize(h, u, d, f), w = r || S < 2e6 ? S : 2e6;
          O = new t$(u, d, S, w);
        }
        a.push(O);
      }, c = (u) => {
        if (u.length < o || u.type != Ml.Text)
          return;
        let d = qYe(u.from, u.to, this.stateDeco);
        if (d.total < o)
          return;
        let h = this.scrollTarget ? this.scrollTarget.range.head : null, f, y;
        if (r) {
          let g = i / this.heightOracle.lineLength * this.heightOracle.lineHeight, O, S;
          if (h != null) {
            let w = ix(d, h), x = ((this.visibleBottom - this.visibleTop) / 2 + g) / u.height;
            O = w - x, S = w + x;
          } else
            O = (this.visibleTop - u.top - g) / u.height, S = (this.visibleBottom - u.top + g) / u.height;
          f = rx(d, O), y = rx(d, S);
        } else {
          let g = d.total * this.heightOracle.charWidth, O = i * this.heightOracle.charWidth, S = 0;
          if (g > 2e6)
            for (let _ of e)
              _.from >= u.from && _.from < u.to && _.size != _.displaySize && _.from * this.heightOracle.charWidth + S < this.pixelViewport.left && (S = _.size - _.displaySize);
          let w = this.pixelViewport.left + S, x = this.pixelViewport.right + S, P, C;
          if (h != null) {
            let _ = ix(d, h), T = ((x - w) / 2 + O) / g;
            P = _ - T, C = _ + T;
          } else
            P = (w - O) / g, C = (x + O) / g;
          f = rx(d, P), y = rx(d, C);
        }
        f > u.from && l(u.from, f, u, d), y < u.to && l(y, u.to, u, d);
      };
      for (let u of this.viewportLines)
        Array.isArray(u.type) ? u.type.forEach(c) : c(u);
      return a;
    }
    gapSize(e, n, r, i) {
      let s = ix(i, r) - ix(i, n);
      return this.heightOracle.lineWrapping ? e.height * s : i.total * this.heightOracle.charWidth * s;
    }
    updateLineGaps(e) {
      t$.same(e, this.lineGaps) || (this.lineGaps = e, this.lineGapDeco = Qe.set(e.map((n) => n.draw(this, this.heightOracle.lineWrapping))));
    }
    computeVisibleRanges(e) {
      let n = this.stateDeco;
      this.lineGaps.length && (n = n.concat(this.lineGapDeco));
      let r = [];
      Pi.spans(n, this.viewport.from, this.viewport.to, {
        span(s, o) {
          r.push({
            from: s,
            to: o
          });
        },
        point() {
        }
      }, 20);
      let i = 0;
      if (r.length != this.visibleRanges.length)
        i = 12;
      else
        for (let s = 0; s < r.length && !(i & 8); s++) {
          let o = this.visibleRanges[s], a = r[s];
          (o.from != a.from || o.to != a.to) && (i |= 4, e && e.mapPos(o.from, -1) == a.from && e.mapPos(o.to, 1) == a.to || (i |= 8));
        }
      return this.visibleRanges = r, i;
    }
    lineBlockAt(e) {
      return e >= this.viewport.from && e <= this.viewport.to && this.viewportLines.find((n) => n.from <= e && n.to >= e) || T0(this.heightMap.lineAt(e, On.ByPos, this.heightOracle, 0, 0), this.scaler);
    }
    lineBlockAtHeight(e) {
      return e >= this.viewportLines[0].top && e <= this.viewportLines[this.viewportLines.length - 1].bottom && this.viewportLines.find((n) => n.top <= e && n.bottom >= e) || T0(this.heightMap.lineAt(this.scaler.fromDOM(e), On.ByHeight, this.heightOracle, 0, 0), this.scaler);
    }
    scrollAnchorAt(e) {
      let n = this.lineBlockAtHeight(e + 8);
      return n.from >= this.viewport.from || this.viewportLines[0].top - e > 200 ? n : this.viewportLines[0];
    }
    elementAtHeight(e) {
      return T0(this.heightMap.blockAt(this.scaler.fromDOM(e), this.heightOracle, 0, 0), this.scaler);
    }
    get docHeight() {
      return this.scaler.toDOM(this.heightMap.height);
    }
    get contentHeight() {
      return this.docHeight + this.paddingTop + this.paddingBottom;
    }
  }
  class nx {
    constructor(e, n) {
      this.from = e, this.to = n;
    }
  }
  function qYe(t, e, n) {
    let r = [], i = t, s = 0;
    return Pi.spans(n, t, e, {
      span() {
      },
      point(o, a) {
        o > i && (r.push({
          from: i,
          to: o
        }), s += o - i), i = a;
      }
    }, 20), i < e && (r.push({
      from: i,
      to: e
    }), s += e - i), {
      total: s,
      ranges: r
    };
  }
  function rx({ total: t, ranges: e }, n) {
    if (n <= 0)
      return e[0].from;
    if (n >= 1)
      return e[e.length - 1].to;
    let r = Math.floor(t * n);
    for (let i = 0; ; i++) {
      let { from: s, to: o } = e[i], a = o - s;
      if (r <= a)
        return s + r;
      r -= a;
    }
  }
  function ix(t, e) {
    let n = 0;
    for (let { from: r, to: i } of t.ranges) {
      if (e <= i) {
        n += e - r;
        break;
      }
      n += i - r;
    }
    return n / t.total;
  }
  function KYe(t, e) {
    for (let n of t)
      if (e(n))
        return n;
  }
  const OU = {
    toDOM(t) {
      return t;
    },
    fromDOM(t) {
      return t;
    },
    scale: 1,
    eq(t) {
      return t == this;
    }
  };
  class Tj {
    constructor(e, n, r) {
      let i = 0, s = 0, o = 0;
      this.viewports = r.map(({ from: a, to: l }) => {
        let c = n.lineAt(a, On.ByPos, e, 0, 0).top, u = n.lineAt(l, On.ByPos, e, 0, 0).bottom;
        return i += u - c, {
          from: a,
          to: l,
          top: c,
          bottom: u,
          domTop: 0,
          domBottom: 0
        };
      }), this.scale = (7e6 - i) / (n.height - i);
      for (let a of this.viewports)
        a.domTop = o + (a.top - s) * this.scale, o = a.domBottom = a.domTop + (a.bottom - a.top), s = a.bottom;
    }
    toDOM(e) {
      for (let n = 0, r = 0, i = 0; ; n++) {
        let s = n < this.viewports.length ? this.viewports[n] : null;
        if (!s || e < s.top)
          return i + (e - r) * this.scale;
        if (e <= s.bottom)
          return s.domTop + (e - s.top);
        r = s.bottom, i = s.domBottom;
      }
    }
    fromDOM(e) {
      for (let n = 0, r = 0, i = 0; ; n++) {
        let s = n < this.viewports.length ? this.viewports[n] : null;
        if (!s || e < s.domTop)
          return r + (e - i) / this.scale;
        if (e <= s.domBottom)
          return s.top + (e - s.domTop);
        r = s.bottom, i = s.domBottom;
      }
    }
    eq(e) {
      return e instanceof Tj ? this.scale == e.scale && this.viewports.length == e.viewports.length && this.viewports.every((n, r) => n.from == e.viewports[r].from && n.to == e.viewports[r].to) : false;
    }
  }
  function T0(t, e) {
    if (e.scale == 1)
      return t;
    let n = e.toDOM(t.top), r = e.toDOM(t.bottom);
    return new kl(t.from, t.length, n, r - n, Array.isArray(t._content) ? t._content.map((i) => T0(i, e)) : t._content);
  }
  const sx = Ge.define({
    combine: (t) => t.join(" ")
  }), UM = Ge.define({
    combine: (t) => t.indexOf(true) > -1
  }), VM = Ed.newName(), xoe = Ed.newName(), boe = Ed.newName(), koe = {
    "&light": "." + xoe,
    "&dark": "." + boe
  };
  function XM(t, e, n) {
    return new Ed(e, {
      finish(r) {
        return /&/.test(r) ? r.replace(/&\w*/, (i) => {
          if (i == "&")
            return t;
          if (!n || !n[i])
            throw new RangeError(`Unsupported selector: ${i}`);
          return n[i];
        }) : t + " " + r;
      }
    });
  }
  const JYe = XM("." + VM, {
    "&": {
      position: "relative !important",
      boxSizing: "border-box",
      "&.cm-focused": {
        outline: "1px dotted #212121"
      },
      display: "flex !important",
      flexDirection: "column"
    },
    ".cm-scroller": {
      display: "flex !important",
      alignItems: "flex-start !important",
      fontFamily: "monospace",
      lineHeight: 1.4,
      height: "100%",
      overflowX: "auto",
      position: "relative",
      zIndex: 0,
      overflowAnchor: "none"
    },
    ".cm-content": {
      margin: 0,
      flexGrow: 2,
      flexShrink: 0,
      display: "block",
      whiteSpace: "pre",
      wordWrap: "normal",
      boxSizing: "border-box",
      minHeight: "100%",
      padding: "4px 0",
      outline: "none",
      "&[contenteditable=true]": {
        WebkitUserModify: "read-write-plaintext-only"
      }
    },
    ".cm-lineWrapping": {
      whiteSpace_fallback: "pre-wrap",
      whiteSpace: "break-spaces",
      wordBreak: "break-word",
      overflowWrap: "anywhere",
      flexShrink: 1
    },
    "&light .cm-content": {
      caretColor: "black"
    },
    "&dark .cm-content": {
      caretColor: "white"
    },
    ".cm-line": {
      display: "block",
      padding: "0 2px 0 6px"
    },
    ".cm-layer": {
      position: "absolute",
      left: 0,
      top: 0,
      contain: "size style",
      "& > *": {
        position: "absolute"
      }
    },
    "&light .cm-selectionBackground": {
      background: "#d9d9d9"
    },
    "&dark .cm-selectionBackground": {
      background: "#222"
    },
    "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
      background: "#d7d4f0"
    },
    "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
      background: "#233"
    },
    ".cm-cursorLayer": {
      pointerEvents: "none"
    },
    "&.cm-focused > .cm-scroller > .cm-cursorLayer": {
      animation: "steps(1) cm-blink 1.2s infinite"
    },
    "@keyframes cm-blink": {
      "0%": {},
      "50%": {
        opacity: 0
      },
      "100%": {}
    },
    "@keyframes cm-blink2": {
      "0%": {},
      "50%": {
        opacity: 0
      },
      "100%": {}
    },
    ".cm-cursor, .cm-dropCursor": {
      borderLeft: "1.2px solid black",
      marginLeft: "-0.6px",
      pointerEvents: "none"
    },
    ".cm-cursor": {
      display: "none"
    },
    "&dark .cm-cursor": {
      borderLeftColor: "#ddd"
    },
    ".cm-dropCursor": {
      position: "absolute"
    },
    "&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": {
      display: "block"
    },
    ".cm-iso": {
      unicodeBidi: "isolate"
    },
    ".cm-announced": {
      position: "fixed",
      top: "-10000px"
    },
    "@media print": {
      ".cm-announced": {
        display: "none"
      }
    },
    "&light .cm-activeLine": {
      backgroundColor: "#cceeff44"
    },
    "&dark .cm-activeLine": {
      backgroundColor: "#99eeff33"
    },
    "&light .cm-specialChar": {
      color: "red"
    },
    "&dark .cm-specialChar": {
      color: "#f78"
    },
    ".cm-gutters": {
      flexShrink: 0,
      display: "flex",
      height: "100%",
      boxSizing: "border-box",
      zIndex: 200
    },
    ".cm-gutters-before": {
      insetInlineStart: 0
    },
    ".cm-gutters-after": {
      insetInlineEnd: 0
    },
    "&light .cm-gutters": {
      backgroundColor: "#f5f5f5",
      color: "#6c6c6c",
      border: "0px solid #ddd",
      "&.cm-gutters-before": {
        borderRightWidth: "1px"
      },
      "&.cm-gutters-after": {
        borderLeftWidth: "1px"
      }
    },
    "&dark .cm-gutters": {
      backgroundColor: "#333338",
      color: "#ccc"
    },
    ".cm-gutter": {
      display: "flex !important",
      flexDirection: "column",
      flexShrink: 0,
      boxSizing: "border-box",
      minHeight: "100%",
      overflow: "hidden"
    },
    ".cm-gutterElement": {
      boxSizing: "border-box"
    },
    ".cm-lineNumbers .cm-gutterElement": {
      padding: "0 3px 0 5px",
      minWidth: "20px",
      textAlign: "right",
      whiteSpace: "nowrap"
    },
    "&light .cm-activeLineGutter": {
      backgroundColor: "#e2f2ff"
    },
    "&dark .cm-activeLineGutter": {
      backgroundColor: "#222227"
    },
    ".cm-panels": {
      boxSizing: "border-box",
      position: "sticky",
      left: 0,
      right: 0,
      zIndex: 300
    },
    "&light .cm-panels": {
      backgroundColor: "#f5f5f5",
      color: "black"
    },
    "&light .cm-panels-top": {
      borderBottom: "1px solid #ddd"
    },
    "&light .cm-panels-bottom": {
      borderTop: "1px solid #ddd"
    },
    "&dark .cm-panels": {
      backgroundColor: "#333338",
      color: "white"
    },
    ".cm-dialog": {
      padding: "2px 19px 4px 6px",
      position: "relative",
      "& label": {
        fontSize: "80%"
      }
    },
    ".cm-dialog-close": {
      position: "absolute",
      top: "3px",
      right: "4px",
      backgroundColor: "inherit",
      border: "none",
      font: "inherit",
      fontSize: "14px",
      padding: "0"
    },
    ".cm-tab": {
      display: "inline-block",
      overflow: "hidden",
      verticalAlign: "bottom"
    },
    ".cm-widgetBuffer": {
      verticalAlign: "text-top",
      height: "1em",
      width: 0,
      display: "inline"
    },
    ".cm-placeholder": {
      color: "#888",
      display: "inline-block",
      verticalAlign: "top",
      userSelect: "none"
    },
    ".cm-highlightSpace": {
      backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
      backgroundPosition: "center"
    },
    ".cm-highlightTab": {
      backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
      backgroundSize: "auto 100%",
      backgroundPosition: "right 90%",
      backgroundRepeat: "no-repeat"
    },
    ".cm-trailingSpace": {
      backgroundColor: "#ff332255"
    },
    ".cm-button": {
      verticalAlign: "middle",
      color: "inherit",
      fontSize: "70%",
      padding: ".2em 1em",
      borderRadius: "1px"
    },
    "&light .cm-button": {
      backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
      border: "1px solid #888",
      "&:active": {
        backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
      }
    },
    "&dark .cm-button": {
      backgroundImage: "linear-gradient(#393939, #111)",
      border: "1px solid #888",
      "&:active": {
        backgroundImage: "linear-gradient(#111, #333)"
      }
    },
    ".cm-textfield": {
      verticalAlign: "middle",
      color: "inherit",
      fontSize: "70%",
      border: "1px solid silver",
      padding: ".2em .5em"
    },
    "&light .cm-textfield": {
      backgroundColor: "white"
    },
    "&dark .cm-textfield": {
      border: "1px solid #555",
      backgroundColor: "inherit"
    }
  }, koe), eGe = {
    childList: true,
    characterData: true,
    subtree: true,
    attributes: true,
    characterDataOldValue: true
  }, n$ = Ee.ie && Ee.ie_version <= 11;
  class tGe {
    constructor(e) {
      this.view = e, this.active = false, this.editContext = null, this.selectionRange = new DHe(), this.selectionChanged = false, this.delayedFlush = -1, this.resizeTimeout = -1, this.queue = [], this.delayedAndroidKey = null, this.flushingAndroidKey = -1, this.lastChange = 0, this.scrollTargets = [], this.intersection = null, this.resizeScroll = null, this.intersecting = false, this.gapIntersection = null, this.gaps = [], this.printQuery = null, this.parentCheck = -1, this.dom = e.contentDOM, this.observer = new MutationObserver((n) => {
        for (let r of n)
          this.queue.push(r);
        (Ee.ie && Ee.ie_version <= 11 || Ee.ios && e.composing) && n.some((r) => r.type == "childList" && r.removedNodes.length || r.type == "characterData" && r.oldValue.length > r.target.nodeValue.length) ? this.flushSoon() : this.flush();
      }), window.EditContext && Ee.android && e.constructor.EDIT_CONTEXT !== false && !(Ee.chrome && Ee.chrome_version < 126) && (this.editContext = new rGe(e), e.state.facet(_c) && (e.contentDOM.editContext = this.editContext.editContext)), n$ && (this.onCharData = (n) => {
        this.queue.push({
          target: n.target,
          type: "characterData",
          oldValue: n.prevValue
        }), this.flushSoon();
      }), this.onSelectionChange = this.onSelectionChange.bind(this), this.onResize = this.onResize.bind(this), this.onPrint = this.onPrint.bind(this), this.onScroll = this.onScroll.bind(this), window.matchMedia && (this.printQuery = window.matchMedia("print")), typeof ResizeObserver == "function" && (this.resizeScroll = new ResizeObserver(() => {
        var n;
        ((n = this.view.docView) === null || n === void 0 ? void 0 : n.lastUpdate) < Date.now() - 75 && this.onResize();
      }), this.resizeScroll.observe(e.scrollDOM)), this.addWindowListeners(this.win = e.win), this.start(), typeof IntersectionObserver == "function" && (this.intersection = new IntersectionObserver((n) => {
        this.parentCheck < 0 && (this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1e3)), n.length > 0 && n[n.length - 1].intersectionRatio > 0 != this.intersecting && (this.intersecting = !this.intersecting, this.intersecting != this.view.inView && this.onScrollChanged(document.createEvent("Event")));
      }, {
        threshold: [
          0,
          1e-3
        ]
      }), this.intersection.observe(this.dom), this.gapIntersection = new IntersectionObserver((n) => {
        n.length > 0 && n[n.length - 1].intersectionRatio > 0 && this.onScrollChanged(document.createEvent("Event"));
      }, {})), this.listenForScroll(), this.readSelectionRange();
    }
    onScrollChanged(e) {
      this.view.inputState.runHandlers("scroll", e), this.intersecting && this.view.measure();
    }
    onScroll(e) {
      this.intersecting && this.flush(false), this.editContext && this.view.requestMeasure(this.editContext.measureReq), this.onScrollChanged(e);
    }
    onResize() {
      this.resizeTimeout < 0 && (this.resizeTimeout = setTimeout(() => {
        this.resizeTimeout = -1, this.view.requestMeasure();
      }, 50));
    }
    onPrint(e) {
      (e.type == "change" || !e.type) && !e.matches || (this.view.viewState.printing = true, this.view.measure(), setTimeout(() => {
        this.view.viewState.printing = false, this.view.requestMeasure();
      }, 500));
    }
    updateGaps(e) {
      if (this.gapIntersection && (e.length != this.gaps.length || this.gaps.some((n, r) => n != e[r]))) {
        this.gapIntersection.disconnect();
        for (let n of e)
          this.gapIntersection.observe(n);
        this.gaps = e;
      }
    }
    onSelectionChange(e) {
      let n = this.selectionChanged;
      if (!this.readSelectionRange() || this.delayedAndroidKey)
        return;
      let { view: r } = this, i = this.selectionRange;
      if (r.state.facet(_c) ? r.root.activeElement != this.dom : !hb(this.dom, i))
        return;
      let s = i.anchorNode && r.docView.nearest(i.anchorNode);
      if (s && s.ignoreEvent(e)) {
        n || (this.selectionChanged = false);
        return;
      }
      (Ee.ie && Ee.ie_version <= 11 || Ee.android && Ee.chrome) && !r.state.selection.main.empty && i.focusNode && av(i.focusNode, i.focusOffset, i.anchorNode, i.anchorOffset) ? this.flushSoon() : this.flush(false);
    }
    readSelectionRange() {
      let { view: e } = this, n = fO(e.root);
      if (!n)
        return false;
      let r = Ee.safari && e.root.nodeType == 11 && e.root.activeElement == this.dom && nGe(this.view, n) || n;
      if (!r || this.selectionRange.eq(r))
        return false;
      let i = hb(this.dom, r);
      return i && !this.selectionChanged && e.inputState.lastFocusTime > Date.now() - 200 && e.inputState.lastTouchTime < Date.now() - 300 && jHe(this.dom, r) ? (this.view.inputState.lastFocusTime = 0, e.docView.updateSelection(), false) : (this.selectionRange.setRange(r), i && (this.selectionChanged = true), true);
    }
    setSelectionRange(e, n) {
      this.selectionRange.set(e.node, e.offset, n.node, n.offset), this.selectionChanged = false;
    }
    clearSelectionRange() {
      this.selectionRange.set(null, 0, null, 0);
    }
    listenForScroll() {
      this.parentCheck = -1;
      let e = 0, n = null;
      for (let r = this.dom; r; )
        if (r.nodeType == 1)
          !n && e < this.scrollTargets.length && this.scrollTargets[e] == r ? e++ : n || (n = this.scrollTargets.slice(0, e)), n && n.push(r), r = r.assignedSlot || r.parentNode;
        else if (r.nodeType == 11)
          r = r.host;
        else
          break;
      if (e < this.scrollTargets.length && !n && (n = this.scrollTargets.slice(0, e)), n) {
        for (let r of this.scrollTargets)
          r.removeEventListener("scroll", this.onScroll);
        for (let r of this.scrollTargets = n)
          r.addEventListener("scroll", this.onScroll);
      }
    }
    ignore(e) {
      if (!this.active)
        return e();
      try {
        return this.stop(), e();
      } finally {
        this.start(), this.clear();
      }
    }
    start() {
      this.active || (this.observer.observe(this.dom, eGe), n$ && this.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.active = true);
    }
    stop() {
      this.active && (this.active = false, this.observer.disconnect(), n$ && this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData));
    }
    clear() {
      this.processRecords(), this.queue.length = 0, this.selectionChanged = false;
    }
    delayAndroidKey(e, n) {
      var r;
      if (!this.delayedAndroidKey) {
        let i = () => {
          let s = this.delayedAndroidKey;
          s && (this.clearDelayedAndroidKey(), this.view.inputState.lastKeyCode = s.keyCode, this.view.inputState.lastKeyTime = Date.now(), !this.flush() && s.force && Sg(this.dom, s.key, s.keyCode));
        };
        this.flushingAndroidKey = this.view.win.requestAnimationFrame(i);
      }
      (!this.delayedAndroidKey || e == "Enter") && (this.delayedAndroidKey = {
        key: e,
        keyCode: n,
        force: this.lastChange < Date.now() - 50 || !!(!((r = this.delayedAndroidKey) === null || r === void 0) && r.force)
      });
    }
    clearDelayedAndroidKey() {
      this.win.cancelAnimationFrame(this.flushingAndroidKey), this.delayedAndroidKey = null, this.flushingAndroidKey = -1;
    }
    flushSoon() {
      this.delayedFlush < 0 && (this.delayedFlush = this.view.win.requestAnimationFrame(() => {
        this.delayedFlush = -1, this.flush();
      }));
    }
    forceFlush() {
      this.delayedFlush >= 0 && (this.view.win.cancelAnimationFrame(this.delayedFlush), this.delayedFlush = -1), this.flush();
    }
    pendingRecords() {
      for (let e of this.observer.takeRecords())
        this.queue.push(e);
      return this.queue;
    }
    processRecords() {
      let e = this.pendingRecords();
      e.length && (this.queue = []);
      let n = -1, r = -1, i = false;
      for (let s of e) {
        let o = this.readMutation(s);
        o && (o.typeOver && (i = true), n == -1 ? { from: n, to: r } = o : (n = Math.min(o.from, n), r = Math.max(o.to, r)));
      }
      return {
        from: n,
        to: r,
        typeOver: i
      };
    }
    readChange() {
      let { from: e, to: n, typeOver: r } = this.processRecords(), i = this.selectionChanged && hb(this.dom, this.selectionRange);
      if (e < 0 && !i)
        return null;
      e > -1 && (this.lastChange = Date.now()), this.view.inputState.lastFocusTime = 0, this.selectionChanged = false;
      let s = new OYe(this.view, e, n, r);
      return this.view.docView.domChanged = {
        newSel: s.newSel ? s.newSel.main : null
      }, s;
    }
    flush(e = true) {
      if (this.delayedFlush >= 0 || this.delayedAndroidKey)
        return false;
      e && this.readSelectionRange();
      let n = this.readChange();
      if (!n)
        return this.view.requestMeasure(), false;
      let r = this.view.state, i = hoe(this.view, n);
      return this.view.state == r && (n.domChanged || n.newSel && !n.newSel.main.eq(this.view.state.selection.main)) && this.view.update([]), i;
    }
    readMutation(e) {
      let n = this.view.docView.nearest(e.target);
      if (!n || n.ignoreMutation(e))
        return null;
      if (n.markDirty(e.type == "attributes"), e.type == "attributes" && (n.flags |= 4), e.type == "childList") {
        let r = SU(n, e.previousSibling || e.target.previousSibling, -1), i = SU(n, e.nextSibling || e.target.nextSibling, 1);
        return {
          from: r ? n.posAfter(r) : n.posAtStart,
          to: i ? n.posBefore(i) : n.posAtEnd,
          typeOver: false
        };
      } else
        return e.type == "characterData" ? {
          from: n.posAtStart,
          to: n.posAtEnd,
          typeOver: e.target.nodeValue == e.oldValue
        } : null;
    }
    setWindow(e) {
      e != this.win && (this.removeWindowListeners(this.win), this.win = e, this.addWindowListeners(this.win));
    }
    addWindowListeners(e) {
      e.addEventListener("resize", this.onResize), this.printQuery ? this.printQuery.addEventListener ? this.printQuery.addEventListener("change", this.onPrint) : this.printQuery.addListener(this.onPrint) : e.addEventListener("beforeprint", this.onPrint), e.addEventListener("scroll", this.onScroll), e.document.addEventListener("selectionchange", this.onSelectionChange);
    }
    removeWindowListeners(e) {
      e.removeEventListener("scroll", this.onScroll), e.removeEventListener("resize", this.onResize), this.printQuery ? this.printQuery.removeEventListener ? this.printQuery.removeEventListener("change", this.onPrint) : this.printQuery.removeListener(this.onPrint) : e.removeEventListener("beforeprint", this.onPrint), e.document.removeEventListener("selectionchange", this.onSelectionChange);
    }
    update(e) {
      this.editContext && (this.editContext.update(e), e.startState.facet(_c) != e.state.facet(_c) && (e.view.contentDOM.editContext = e.state.facet(_c) ? this.editContext.editContext : null));
    }
    destroy() {
      var e, n, r;
      this.stop(), (e = this.intersection) === null || e === void 0 || e.disconnect(), (n = this.gapIntersection) === null || n === void 0 || n.disconnect(), (r = this.resizeScroll) === null || r === void 0 || r.disconnect();
      for (let i of this.scrollTargets)
        i.removeEventListener("scroll", this.onScroll);
      this.removeWindowListeners(this.win), clearTimeout(this.parentCheck), clearTimeout(this.resizeTimeout), this.win.cancelAnimationFrame(this.delayedFlush), this.win.cancelAnimationFrame(this.flushingAndroidKey), this.editContext && (this.view.contentDOM.editContext = null, this.editContext.destroy());
    }
  }
  function SU(t, e, n) {
    for (; e; ) {
      let r = sn.get(e);
      if (r && r.parent == t)
        return r;
      let i = e.parentNode;
      e = i != t.dom ? i : n > 0 ? e.nextSibling : e.previousSibling;
    }
    return null;
  }
  function wU(t, e) {
    let n = e.startContainer, r = e.startOffset, i = e.endContainer, s = e.endOffset, o = t.docView.domAtPos(t.state.selection.main.anchor);
    return av(o.node, o.offset, i, s) && ([n, r, i, s] = [
      i,
      s,
      n,
      r
    ]), {
      anchorNode: n,
      anchorOffset: r,
      focusNode: i,
      focusOffset: s
    };
  }
  function nGe(t, e) {
    if (e.getComposedRanges) {
      let i = e.getComposedRanges(t.root)[0];
      if (i)
        return wU(t, i);
    }
    let n = null;
    function r(i) {
      i.preventDefault(), i.stopImmediatePropagation(), n = i.getTargetRanges()[0];
    }
    return t.contentDOM.addEventListener("beforeinput", r, true), t.dom.ownerDocument.execCommand("indent"), t.contentDOM.removeEventListener("beforeinput", r, true), n ? wU(t, n) : null;
  }
  class rGe {
    constructor(e) {
      this.from = 0, this.to = 0, this.pendingContextChange = null, this.handlers = /* @__PURE__ */ Object.create(null), this.composing = null, this.resetRange(e.state);
      let n = this.editContext = new window.EditContext({
        text: e.state.doc.sliceString(this.from, this.to),
        selectionStart: this.toContextPos(Math.max(this.from, Math.min(this.to, e.state.selection.main.anchor))),
        selectionEnd: this.toContextPos(e.state.selection.main.head)
      });
      this.handlers.textupdate = (r) => {
        let i = e.state.selection.main, { anchor: s, head: o } = i, a = this.toEditorPos(r.updateRangeStart), l = this.toEditorPos(r.updateRangeEnd);
        e.inputState.composing >= 0 && !this.composing && (this.composing = {
          contextBase: r.updateRangeStart,
          editorBase: a,
          drifted: false
        });
        let c = {
          from: a,
          to: l,
          insert: Qt.of(r.text.split(`
`))
        };
        if (c.from == this.from && s < this.from ? c.from = s : c.to == this.to && s > this.to && (c.to = s), c.from == c.to && !c.insert.length) {
          let u = Ve.single(this.toEditorPos(r.selectionStart), this.toEditorPos(r.selectionEnd));
          u.main.eq(i) || e.dispatch({
            selection: u,
            userEvent: "select"
          });
          return;
        }
        if ((Ee.mac || Ee.android) && c.from == o - 1 && /^\. ?$/.test(r.text) && e.contentDOM.getAttribute("autocorrect") == "off" && (c = {
          from: a,
          to: l,
          insert: Qt.of([
            r.text.replace(".", " ")
          ])
        }), this.pendingContextChange = c, !e.state.readOnly) {
          let u = this.to - this.from + (c.to - c.from + c.insert.length);
          Cj(e, c, Ve.single(this.toEditorPos(r.selectionStart, u), this.toEditorPos(r.selectionEnd, u)));
        }
        this.pendingContextChange && (this.revertPending(e.state), this.setSelection(e.state)), c.from < c.to && !c.insert.length && e.inputState.composing >= 0 && !/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0, r.updateRangeStart - 1), Math.min(n.text.length, r.updateRangeStart + 1))) && this.handlers.compositionend(r);
      }, this.handlers.characterboundsupdate = (r) => {
        let i = [], s = null;
        for (let o = this.toEditorPos(r.rangeStart), a = this.toEditorPos(r.rangeEnd); o < a; o++) {
          let l = e.coordsForChar(o);
          s = l && new DOMRect(l.left, l.top, l.right - l.left, l.bottom - l.top) || s || new DOMRect(), i.push(s);
        }
        n.updateCharacterBounds(r.rangeStart, i);
      }, this.handlers.textformatupdate = (r) => {
        let i = [];
        for (let s of r.getTextFormats()) {
          let o = s.underlineStyle, a = s.underlineThickness;
          if (!/none/i.test(o) && !/none/i.test(a)) {
            let l = this.toEditorPos(s.rangeStart), c = this.toEditorPos(s.rangeEnd);
            if (l < c) {
              let u = `text-decoration: underline ${/^[a-z]/.test(o) ? o + " " : o == "Dashed" ? "dashed " : o == "Squiggle" ? "wavy " : ""}${/thin/i.test(a) ? 1 : 2}px`;
              i.push(Qe.mark({
                attributes: {
                  style: u
                }
              }).range(l, c));
            }
          }
        }
        e.dispatch({
          effects: roe.of(Qe.set(i))
        });
      }, this.handlers.compositionstart = () => {
        e.inputState.composing < 0 && (e.inputState.composing = 0, e.inputState.compositionFirstChange = true);
      }, this.handlers.compositionend = () => {
        if (e.inputState.composing = -1, e.inputState.compositionFirstChange = null, this.composing) {
          let { drifted: r } = this.composing;
          this.composing = null, r && this.reset(e.state);
        }
      };
      for (let r in this.handlers)
        n.addEventListener(r, this.handlers[r]);
      this.measureReq = {
        read: (r) => {
          this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());
          let i = fO(r.root);
          i && i.rangeCount && this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect());
        }
      };
    }
    applyEdits(e) {
      let n = 0, r = false, i = this.pendingContextChange;
      return e.changes.iterChanges((s, o, a, l, c) => {
        if (r)
          return;
        let u = c.length - (o - s);
        if (i && o >= i.to)
          if (i.from == s && i.to == o && i.insert.eq(c)) {
            i = this.pendingContextChange = null, n += u, this.to += u;
            return;
          } else
            i = null, this.revertPending(e.state);
        if (s += n, o += n, o <= this.from)
          this.from += u, this.to += u;
        else if (s < this.to) {
          if (s < this.from || o > this.to || this.to - this.from + c.length > 3e4) {
            r = true;
            return;
          }
          this.editContext.updateText(this.toContextPos(s), this.toContextPos(o), c.toString()), this.to += u;
        }
        n += u;
      }), i && !r && this.revertPending(e.state), !r;
    }
    update(e) {
      let n = this.pendingContextChange, r = e.startState.selection.main;
      this.composing && (this.composing.drifted || !e.changes.touchesRange(r.from, r.to) && e.transactions.some((i) => !i.isUserEvent("input.type") && i.changes.touchesRange(this.from, this.to))) ? (this.composing.drifted = true, this.composing.editorBase = e.changes.mapPos(this.composing.editorBase)) : !this.applyEdits(e) || !this.rangeIsValid(e.state) ? (this.pendingContextChange = null, this.reset(e.state)) : (e.docChanged || e.selectionSet || n) && this.setSelection(e.state), (e.geometryChanged || e.docChanged || e.selectionSet) && e.view.requestMeasure(this.measureReq);
    }
    resetRange(e) {
      let { head: n } = e.selection.main;
      this.from = Math.max(0, n - 1e4), this.to = Math.min(e.doc.length, n + 1e4);
    }
    reset(e) {
      this.resetRange(e), this.editContext.updateText(0, this.editContext.text.length, e.doc.sliceString(this.from, this.to)), this.setSelection(e);
    }
    revertPending(e) {
      let n = this.pendingContextChange;
      this.pendingContextChange = null, this.editContext.updateText(this.toContextPos(n.from), this.toContextPos(n.from + n.insert.length), e.doc.sliceString(n.from, n.to));
    }
    setSelection(e) {
      let { main: n } = e.selection, r = this.toContextPos(Math.max(this.from, Math.min(this.to, n.anchor))), i = this.toContextPos(n.head);
      (this.editContext.selectionStart != r || this.editContext.selectionEnd != i) && this.editContext.updateSelection(r, i);
    }
    rangeIsValid(e) {
      let { head: n } = e.selection.main;
      return !(this.from > 0 && n - this.from < 500 || this.to < e.doc.length && this.to - n < 500 || this.to - this.from > 1e4 * 3);
    }
    toEditorPos(e, n = this.to - this.from) {
      e = Math.min(e, n);
      let r = this.composing;
      return r && r.drifted ? r.editorBase + (e - r.contextBase) : e + this.from;
    }
    toContextPos(e) {
      let n = this.composing;
      return n && n.drifted ? n.contextBase + (e - n.editorBase) : e - this.from;
    }
    destroy() {
      for (let e in this.handlers)
        this.editContext.removeEventListener(e, this.handlers[e]);
    }
  }
  Re = class {
    get state() {
      return this.viewState.state;
    }
    get viewport() {
      return this.viewState.viewport;
    }
    get visibleRanges() {
      return this.viewState.visibleRanges;
    }
    get inView() {
      return this.viewState.inView;
    }
    get composing() {
      return !!this.inputState && this.inputState.composing > 0;
    }
    get compositionStarted() {
      return !!this.inputState && this.inputState.composing >= 0;
    }
    get root() {
      return this._root;
    }
    get win() {
      return this.dom.ownerDocument.defaultView || window;
    }
    constructor(e = {}) {
      var n;
      this.plugins = [], this.pluginMap = /* @__PURE__ */ new Map(), this.editorAttrs = {}, this.contentAttrs = {}, this.bidiCache = [], this.destroyed = false, this.updateState = 2, this.measureScheduled = -1, this.measureRequests = [], this.contentDOM = document.createElement("div"), this.scrollDOM = document.createElement("div"), this.scrollDOM.tabIndex = -1, this.scrollDOM.className = "cm-scroller", this.scrollDOM.appendChild(this.contentDOM), this.announceDOM = document.createElement("div"), this.announceDOM.className = "cm-announced", this.announceDOM.setAttribute("aria-live", "polite"), this.dom = document.createElement("div"), this.dom.appendChild(this.announceDOM), this.dom.appendChild(this.scrollDOM), e.parent && e.parent.appendChild(this.dom);
      let { dispatch: r } = e;
      this.dispatchTransactions = e.dispatchTransactions || r && ((i) => i.forEach((s) => r(s, this))) || ((i) => this.update(i)), this.dispatch = this.dispatch.bind(this), this._root = e.root || LHe(e.parent) || document, this.viewState = new vU(e.state || lr.create(e)), e.scrollTo && e.scrollTo.is(Jw) && (this.viewState.scrollTarget = e.scrollTo.value.clip(this.viewState.state)), this.plugins = this.state.facet(sg).map((i) => new KI(i));
      for (let i of this.plugins)
        i.update(this);
      this.observer = new tGe(this), this.inputState = new kYe(this), this.inputState.ensureHandlers(this.plugins), this.docView = new JB(this), this.mountStyles(), this.updateAttrs(), this.updateState = 0, this.requestMeasure(), !((n = document.fonts) === null || n === void 0) && n.ready && document.fonts.ready.then(() => this.requestMeasure());
    }
    dispatch(...e) {
      let n = e.length == 1 && e[0] instanceof Yo ? e : e.length == 1 && Array.isArray(e[0]) ? e[0] : [
        this.state.update(...e)
      ];
      this.dispatchTransactions(n, this);
    }
    update(e) {
      if (this.updateState != 0)
        throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
      let n = false, r = false, i, s = this.state;
      for (let h of e) {
        if (h.startState != s)
          throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
        s = h.state;
      }
      if (this.destroyed) {
        this.viewState.state = s;
        return;
      }
      let o = this.hasFocus, a = 0, l = null;
      e.some((h) => h.annotation(voe)) ? (this.inputState.notifiedFocused = o, a = 1) : o != this.inputState.notifiedFocused && (this.inputState.notifiedFocused = o, l = Ooe(s, o), l || (a = 1));
      let c = this.observer.delayedAndroidKey, u = null;
      if (c ? (this.observer.clearDelayedAndroidKey(), u = this.observer.readChange(), (u && !this.state.doc.eq(s.doc) || !this.state.selection.eq(s.selection)) && (u = null)) : this.observer.clear(), s.facet(lr.phrases) != this.state.facet(lr.phrases))
        return this.setState(s);
      i = cP.create(this, s, e), i.flags |= a;
      let d = this.viewState.scrollTarget;
      try {
        this.updateState = 2;
        for (let h of e) {
          if (d && (d = d.map(h.changes)), h.scrollIntoView) {
            let { main: f } = h.state.selection;
            d = new wg(f.empty ? f : Ve.cursor(f.head, f.head > f.anchor ? -1 : 1));
          }
          for (let f of h.effects)
            f.is(Jw) && (d = f.value.clip(this.state));
        }
        this.viewState.update(i, d), this.bidiCache = dP.update(this.bidiCache, i.changes), i.empty || (this.updatePlugins(i), this.inputState.update(i)), n = this.docView.update(i), this.state.facet(C0) != this.styleModules && this.mountStyles(), r = this.updateAttrs(), this.showAnnouncements(e), this.docView.updateSelection(n, e.some((h) => h.isUserEvent("select.pointer")));
      } finally {
        this.updateState = 0;
      }
      if (i.startState.facet(sx) != i.state.facet(sx) && (this.viewState.mustMeasureContent = true), (n || r || d || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent) && this.requestMeasure(), n && this.docViewUpdate(), !i.empty)
        for (let h of this.state.facet(zM))
          try {
            h(i);
          } catch (f) {
            Vo(this.state, f, "update listener");
          }
      (l || u) && Promise.resolve().then(() => {
        l && this.state == l.startState && this.dispatch(l), u && !hoe(this, u) && c.force && Sg(this.contentDOM, c.key, c.keyCode);
      });
    }
    setState(e) {
      if (this.updateState != 0)
        throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
      if (this.destroyed) {
        this.viewState.state = e;
        return;
      }
      this.updateState = 2;
      let n = this.hasFocus;
      try {
        for (let r of this.plugins)
          r.destroy(this);
        this.viewState = new vU(e), this.plugins = e.facet(sg).map((r) => new KI(r)), this.pluginMap.clear();
        for (let r of this.plugins)
          r.update(this);
        this.docView.destroy(), this.docView = new JB(this), this.inputState.ensureHandlers(this.plugins), this.mountStyles(), this.updateAttrs(), this.bidiCache = [];
      } finally {
        this.updateState = 0;
      }
      n && this.focus(), this.requestMeasure();
    }
    updatePlugins(e) {
      let n = e.startState.facet(sg), r = e.state.facet(sg);
      if (n != r) {
        let i = [];
        for (let s of r) {
          let o = n.indexOf(s);
          if (o < 0)
            i.push(new KI(s));
          else {
            let a = this.plugins[o];
            a.mustUpdate = e, i.push(a);
          }
        }
        for (let s of this.plugins)
          s.mustUpdate != e && s.destroy(this);
        this.plugins = i, this.pluginMap.clear();
      } else
        for (let i of this.plugins)
          i.mustUpdate = e;
      for (let i = 0; i < this.plugins.length; i++)
        this.plugins[i].update(this);
      n != r && this.inputState.ensureHandlers(this.plugins);
    }
    docViewUpdate() {
      for (let e of this.plugins) {
        let n = e.value;
        if (n && n.docViewUpdate)
          try {
            n.docViewUpdate(this);
          } catch (r) {
            Vo(this.state, r, "doc view update listener");
          }
      }
    }
    measure(e = true) {
      if (this.destroyed)
        return;
      if (this.measureScheduled > -1 && this.win.cancelAnimationFrame(this.measureScheduled), this.observer.delayedAndroidKey) {
        this.measureScheduled = -1, this.requestMeasure();
        return;
      }
      this.measureScheduled = 0, e && this.observer.forceFlush();
      let n = null, r = this.scrollDOM, i = r.scrollTop * this.scaleY, { scrollAnchorPos: s, scrollAnchorHeight: o } = this.viewState;
      Math.abs(i - this.viewState.scrollTop) > 1 && (o = -1), this.viewState.scrollAnchorHeight = -1;
      try {
        for (let a = 0; ; a++) {
          if (o < 0)
            if (Ase(r))
              s = -1, o = this.viewState.heightMap.height;
            else {
              let f = this.viewState.scrollAnchorAt(i);
              s = f.from, o = f.top;
            }
          this.updateState = 1;
          let l = this.viewState.measure(this);
          if (!l && !this.measureRequests.length && this.viewState.scrollTarget == null)
            break;
          if (a > 5) {
            console.warn(this.measureRequests.length ? "Measure loop restarted more than 5 times" : "Viewport failed to stabilize");
            break;
          }
          let c = [];
          l & 4 || ([this.measureRequests, c] = [
            c,
            this.measureRequests
          ]);
          let u = c.map((f) => {
            try {
              return f.read(this);
            } catch (y) {
              return Vo(this.state, y), xU;
            }
          }), d = cP.create(this, this.state, []), h = false;
          d.flags |= l, n ? n.flags |= l : n = d, this.updateState = 2, d.empty || (this.updatePlugins(d), this.inputState.update(d), this.updateAttrs(), h = this.docView.update(d), h && this.docViewUpdate());
          for (let f = 0; f < c.length; f++)
            if (u[f] != xU)
              try {
                let y = c[f];
                y.write && y.write(u[f], this);
              } catch (y) {
                Vo(this.state, y);
              }
          if (h && this.docView.updateSelection(true), !d.viewportChanged && this.measureRequests.length == 0) {
            if (this.viewState.editorHeight)
              if (this.viewState.scrollTarget) {
                this.docView.scrollIntoView(this.viewState.scrollTarget), this.viewState.scrollTarget = null, o = -1;
                continue;
              } else {
                let y = (s < 0 ? this.viewState.heightMap.height : this.viewState.lineBlockAt(s).top) - o;
                if (y > 1 || y < -1) {
                  i = i + y, r.scrollTop = i / this.scaleY, o = -1;
                  continue;
                }
              }
            break;
          }
        }
      } finally {
        this.updateState = 0, this.measureScheduled = -1;
      }
      if (n && !n.empty)
        for (let a of this.state.facet(zM))
          a(n);
    }
    get themeClasses() {
      return VM + " " + (this.state.facet(UM) ? boe : xoe) + " " + this.state.facet(sx);
    }
    updateAttrs() {
      let e = bU(this, ioe, {
        class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
      }), n = {
        spellcheck: "false",
        autocorrect: "off",
        autocapitalize: "off",
        writingsuggestions: "false",
        translate: "no",
        contenteditable: this.state.facet(_c) ? "true" : "false",
        class: "cm-content",
        style: `${Ee.tabSize}: ${this.state.tabSize}`,
        role: "textbox",
        "aria-multiline": "true"
      };
      this.state.readOnly && (n["aria-readonly"] = "true"), bU(this, kj, n);
      let r = this.observer.ignore(() => {
        let i = DM(this.contentDOM, this.contentAttrs, n), s = DM(this.dom, this.editorAttrs, e);
        return i || s;
      });
      return this.editorAttrs = e, this.contentAttrs = n, r;
    }
    showAnnouncements(e) {
      let n = true;
      for (let r of e)
        for (let i of r.effects)
          if (i.is(Re.announce)) {
            n && (this.announceDOM.textContent = ""), n = false;
            let s = this.announceDOM.appendChild(document.createElement("div"));
            s.textContent = i.value;
          }
    }
    mountStyles() {
      this.styleModules = this.state.facet(C0);
      let e = this.state.facet(Re.cspNonce);
      Ed.mount(this.root, this.styleModules.concat(JYe).reverse(), e ? {
        nonce: e
      } : void 0);
    }
    readMeasured() {
      if (this.updateState == 2)
        throw new Error("Reading the editor layout isn't allowed during an update");
      this.updateState == 0 && this.measureScheduled > -1 && this.measure(false);
    }
    requestMeasure(e) {
      if (this.measureScheduled < 0 && (this.measureScheduled = this.win.requestAnimationFrame(() => this.measure())), e) {
        if (this.measureRequests.indexOf(e) > -1)
          return;
        if (e.key != null) {
          for (let n = 0; n < this.measureRequests.length; n++)
            if (this.measureRequests[n].key === e.key) {
              this.measureRequests[n] = e;
              return;
            }
        }
        this.measureRequests.push(e);
      }
    }
    plugin(e) {
      let n = this.pluginMap.get(e);
      return (n === void 0 || n && n.plugin != e) && this.pluginMap.set(e, n = this.plugins.find((r) => r.plugin == e) || null), n && n.update(this).value;
    }
    get documentTop() {
      return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
    }
    get documentPadding() {
      return {
        top: this.viewState.paddingTop,
        bottom: this.viewState.paddingBottom
      };
    }
    get scaleX() {
      return this.viewState.scaleX;
    }
    get scaleY() {
      return this.viewState.scaleY;
    }
    elementAtHeight(e) {
      return this.readMeasured(), this.viewState.elementAtHeight(e);
    }
    lineBlockAtHeight(e) {
      return this.readMeasured(), this.viewState.lineBlockAtHeight(e);
    }
    get viewportLineBlocks() {
      return this.viewState.viewportLines;
    }
    lineBlockAt(e) {
      return this.viewState.lineBlockAt(e);
    }
    get contentHeight() {
      return this.viewState.contentHeight;
    }
    moveByChar(e, n, r) {
      return e$(this, e, iU(this, e, n, r));
    }
    moveByGroup(e, n) {
      return e$(this, e, iU(this, e, n, (r) => gYe(this, e.head, r)));
    }
    visualLineSide(e, n) {
      let r = this.bidiSpans(e), i = this.textDirectionAt(e.from), s = r[n ? r.length - 1 : 0];
      return Ve.cursor(s.side(n, i) + e.from, s.forward(!n, i) ? 1 : -1);
    }
    moveToLineBoundary(e, n, r = true) {
      return pYe(this, e, n, r);
    }
    moveVertically(e, n, r) {
      return e$(this, e, mYe(this, e, n, r));
    }
    domAtPos(e) {
      return this.docView.domAtPos(e);
    }
    posAtDOM(e, n = 0) {
      return this.docView.posFromDOM(e, n);
    }
    posAtCoords(e, n = true) {
      return this.readMeasured(), coe(this, e, n);
    }
    coordsAtPos(e, n = 1) {
      this.readMeasured();
      let r = this.docView.coordsAt(e, n);
      if (!r || r.left == r.right)
        return r;
      let i = this.state.doc.lineAt(e), s = this.bidiSpans(i), o = s[td.find(s, e - i.from, -1, n)];
      return C2(r, o.dir == er.LTR == n > 0);
    }
    coordsForChar(e) {
      return this.readMeasured(), this.docView.coordsForChar(e);
    }
    get defaultCharacterWidth() {
      return this.viewState.heightOracle.charWidth;
    }
    get defaultLineHeight() {
      return this.viewState.heightOracle.lineHeight;
    }
    get textDirection() {
      return this.viewState.defaultTextDirection;
    }
    textDirectionAt(e) {
      return !this.state.facet(toe) || e < this.viewport.from || e > this.viewport.to ? this.textDirection : (this.readMeasured(), this.docView.textDirectionAt(e));
    }
    get lineWrapping() {
      return this.viewState.heightOracle.lineWrapping;
    }
    bidiSpans(e) {
      if (e.length > iGe)
        return Zse(e.length);
      let n = this.textDirectionAt(e.from), r;
      for (let s of this.bidiCache)
        if (s.from == e.from && s.dir == n && (s.fresh || Wse(s.isolates, r = KB(this, e))))
          return s.order;
      r || (r = KB(this, e));
      let i = GHe(e.text, n, r);
      return this.bidiCache.push(new dP(e.from, e.to, n, r, true, i)), i;
    }
    get hasFocus() {
      var e;
      return (this.dom.ownerDocument.hasFocus() || Ee.safari && ((e = this.inputState) === null || e === void 0 ? void 0 : e.lastContextMenu) > Date.now() - 3e4) && this.root.activeElement == this.contentDOM;
    }
    focus() {
      this.observer.ignore(() => {
        Ise(this.contentDOM), this.docView.updateSelection();
      });
    }
    setRoot(e) {
      this._root != e && (this._root = e, this.observer.setWindow((e.nodeType == 9 ? e : e.ownerDocument).defaultView || window), this.mountStyles());
    }
    destroy() {
      this.root.activeElement == this.contentDOM && this.contentDOM.blur();
      for (let e of this.plugins)
        e.destroy(this);
      this.plugins = [], this.inputState.destroy(), this.docView.destroy(), this.dom.remove(), this.observer.destroy(), this.measureScheduled > -1 && this.win.cancelAnimationFrame(this.measureScheduled), this.destroyed = true;
    }
    static scrollIntoView(e, n = {}) {
      return Jw.of(new wg(typeof e == "number" ? Ve.cursor(e) : e, n.y, n.x, n.yMargin, n.xMargin));
    }
    scrollSnapshot() {
      let { scrollTop: e, scrollLeft: n } = this.scrollDOM, r = this.viewState.scrollAnchorAt(e);
      return Jw.of(new wg(Ve.cursor(r.from), "start", "start", r.top - e, n, true));
    }
    setTabFocusMode(e) {
      e == null ? this.inputState.tabFocusMode = this.inputState.tabFocusMode < 0 ? 0 : -1 : typeof e == "boolean" ? this.inputState.tabFocusMode = e ? 0 : -1 : this.inputState.tabFocusMode != 0 && (this.inputState.tabFocusMode = Date.now() + e);
    }
    static domEventHandlers(e) {
      return ur.define(() => ({}), {
        eventHandlers: e
      });
    }
    static domEventObservers(e) {
      return ur.define(() => ({}), {
        eventObservers: e
      });
    }
    static theme(e, n) {
      let r = Ed.newName(), i = [
        sx.of(r),
        C0.of(XM(`.${r}`, e))
      ];
      return n && n.dark && i.push(UM.of(true)), i;
    }
    static baseTheme(e) {
      return xS.lowest(C0.of(XM("." + VM, e, koe)));
    }
    static findFromDOM(e) {
      var n;
      let r = e.querySelector(".cm-content"), i = r && sn.get(r) || sn.get(e);
      return ((n = i == null ? void 0 : i.rootView) === null || n === void 0 ? void 0 : n.view) || null;
    }
  };
  Re.styleModule = C0;
  Re.inputHandler = Jse;
  Re.clipboardInputFilter = xj;
  Re.clipboardOutputFilter = bj;
  Re.scrollHandler = noe;
  Re.focusChangeEffect = eoe;
  Re.perLineTextDirection = toe;
  Re.exceptionSink = Kse;
  Re.updateListener = zM;
  Re.editable = _c;
  Re.mouseSelectionStyle = qse;
  Re.dragMovesSelection = Gse;
  Re.clickAddsSelectionRange = Yse;
  Re.decorations = gO;
  Re.outerDecorations = soe;
  Re.atomicRanges = PS;
  Re.bidiIsolatedRanges = ooe;
  Re.scrollMargins = aoe;
  Re.darkTheme = UM;
  Re.cspNonce = Ge.define({
    combine: (t) => t.length ? t[0] : ""
  });
  Re.contentAttributes = kj;
  Re.editorAttributes = ioe;
  Re.lineWrapping = Re.contentAttributes.of({
    class: "cm-lineWrapping"
  });
  Re.announce = kn.define();
  const iGe = 4096, xU = {};
  class dP {
    constructor(e, n, r, i, s, o) {
      this.from = e, this.to = n, this.dir = r, this.isolates = i, this.fresh = s, this.order = o;
    }
    static update(e, n) {
      if (n.empty && !e.some((s) => s.fresh))
        return e;
      let r = [], i = e.length ? e[e.length - 1].dir : er.LTR;
      for (let s = Math.max(0, e.length - 10); s < e.length; s++) {
        let o = e[s];
        o.dir == i && !n.touchesRange(o.from, o.to) && r.push(new dP(n.mapPos(o.from, 1), n.mapPos(o.to, -1), o.dir, o.isolates, false, o.order));
      }
      return r;
    }
  }
  function bU(t, e, n) {
    for (let r = t.state.facet(e), i = r.length - 1; i >= 0; i--) {
      let s = r[i], o = typeof s == "function" ? s(t) : s;
      o && MM(o, n);
    }
    return n;
  }
  const sGe = Ee.mac ? "mac" : Ee.windows ? "win" : Ee.linux ? "linux" : "key";
  function oGe(t, e) {
    const n = t.split(/-(?!$)/);
    let r = n[n.length - 1];
    r == "Space" && (r = " ");
    let i, s, o, a;
    for (let l = 0; l < n.length - 1; ++l) {
      const c = n[l];
      if (/^(cmd|meta|m)$/i.test(c))
        a = true;
      else if (/^a(lt)?$/i.test(c))
        i = true;
      else if (/^(c|ctrl|control)$/i.test(c))
        s = true;
      else if (/^s(hift)?$/i.test(c))
        o = true;
      else if (/^mod$/i.test(c))
        e == "mac" ? a = true : s = true;
      else
        throw new Error("Unrecognized modifier name: " + c);
    }
    return i && (r = "Alt-" + r), s && (r = "Ctrl-" + r), a && (r = "Meta-" + r), o && (r = "Shift-" + r), r;
  }
  function ox(t, e, n) {
    return e.altKey && (t = "Alt-" + t), e.ctrlKey && (t = "Ctrl-" + t), e.metaKey && (t = "Meta-" + t), n !== false && e.shiftKey && (t = "Shift-" + t), t;
  }
  const aGe = xS.default(Re.domEventHandlers({
    keydown(t, e) {
      return Coe(Poe(e.state), t, e, "editor");
    }
  })), E2 = Ge.define({
    enables: aGe
  }), kU = /* @__PURE__ */ new WeakMap();
  function Poe(t) {
    let e = t.facet(E2), n = kU.get(e);
    return n || kU.set(e, n = uGe(e.reduce((r, i) => r.concat(i), []))), n;
  }
  function lGe(t, e, n) {
    return Coe(Poe(t.state), e, t, n);
  }
  let Uu = null;
  const cGe = 4e3;
  function uGe(t, e = sGe) {
    let n = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ Object.create(null), i = (o, a) => {
      let l = r[o];
      if (l == null)
        r[o] = a;
      else if (l != a)
        throw new Error("Key binding " + o + " is used both as a regular binding and as a multi-stroke prefix");
    }, s = (o, a, l, c, u) => {
      var d, h;
      let f = n[o] || (n[o] = /* @__PURE__ */ Object.create(null)), y = a.split(/ (?!$)/).map((S) => oGe(S, e));
      for (let S = 1; S < y.length; S++) {
        let w = y.slice(0, S).join(" ");
        i(w, true), f[w] || (f[w] = {
          preventDefault: true,
          stopPropagation: false,
          run: [
            (x) => {
              let P = Uu = {
                view: x,
                prefix: w,
                scope: o
              };
              return setTimeout(() => {
                Uu == P && (Uu = null);
              }, cGe), true;
            }
          ]
        });
      }
      let g = y.join(" ");
      i(g, false);
      let O = f[g] || (f[g] = {
        preventDefault: false,
        stopPropagation: false,
        run: ((h = (d = f._any) === null || d === void 0 ? void 0 : d.run) === null || h === void 0 ? void 0 : h.slice()) || []
      });
      l && O.run.push(l), c && (O.preventDefault = true), u && (O.stopPropagation = true);
    };
    for (let o of t) {
      let a = o.scope ? o.scope.split(" ") : [
        "editor"
      ];
      if (o.any)
        for (let c of a) {
          let u = n[c] || (n[c] = /* @__PURE__ */ Object.create(null));
          u._any || (u._any = {
            preventDefault: false,
            stopPropagation: false,
            run: []
          });
          let { any: d } = o;
          for (let h in u)
            u[h].run.push((f) => d(f, WM));
        }
      let l = o[e] || o.key;
      if (l)
        for (let c of a)
          s(c, l, o.run, o.preventDefault, o.stopPropagation), o.shift && s(c, "Shift-" + l, o.shift, o.preventDefault, o.stopPropagation);
    }
    return n;
  }
  let WM = null;
  function Coe(t, e, n, r) {
    WM = e;
    let i = $He(e), s = dHe(i, 0), o = hHe(s) == i.length && i != " ", a = "", l = false, c = false, u = false;
    Uu && Uu.view == n && Uu.scope == r && (a = Uu.prefix + " ", poe.indexOf(e.keyCode) < 0 && (c = true, Uu = null));
    let d = /* @__PURE__ */ new Set(), h = (O) => {
      if (O) {
        for (let S of O.run)
          if (!d.has(S) && (d.add(S), S(n)))
            return O.stopPropagation && (u = true), true;
        O.preventDefault && (O.stopPropagation && (u = true), c = true);
      }
      return false;
    }, f = t[r], y, g;
    return f && (h(f[a + ox(i, e, !o)]) ? l = true : o && (e.altKey || e.metaKey || e.ctrlKey) && !(Ee.windows && e.ctrlKey && e.altKey) && !(Ee.mac && e.altKey && !(e.ctrlKey || e.metaKey)) && (y = Id[e.keyCode]) && y != i ? (h(f[a + ox(y, e, true)]) || e.shiftKey && (g = hO[e.keyCode]) != i && g != y && h(f[a + ox(g, e, false)])) && (l = true) : o && e.shiftKey && h(f[a + ox(i, e, true)]) && (l = true), !l && h(f._any) && (l = true)), c && (l = true), l && u && e.stopPropagation(), WM = null, l;
  }
  const i0 = "-10000px";
  class _oe {
    constructor(e, n, r, i) {
      this.facet = n, this.createTooltipView = r, this.removeTooltipView = i, this.input = e.state.facet(n), this.tooltips = this.input.filter((o) => o);
      let s = null;
      this.tooltipViews = this.tooltips.map((o) => s = r(o, s));
    }
    update(e, n) {
      var r;
      let i = e.state.facet(this.facet), s = i.filter((l) => l);
      if (i === this.input) {
        for (let l of this.tooltipViews)
          l.update && l.update(e);
        return false;
      }
      let o = [], a = n ? [] : null;
      for (let l = 0; l < s.length; l++) {
        let c = s[l], u = -1;
        if (c) {
          for (let d = 0; d < this.tooltips.length; d++) {
            let h = this.tooltips[d];
            h && h.create == c.create && (u = d);
          }
          if (u < 0)
            o[l] = this.createTooltipView(c, l ? o[l - 1] : null), a && (a[l] = !!c.above);
          else {
            let d = o[l] = this.tooltipViews[u];
            a && (a[l] = n[u]), d.update && d.update(e);
          }
        }
      }
      for (let l of this.tooltipViews)
        o.indexOf(l) < 0 && (this.removeTooltipView(l), (r = l.destroy) === null || r === void 0 || r.call(l));
      return n && (a.forEach((l, c) => n[c] = l), n.length = a.length), this.input = i, this.tooltips = s, this.tooltipViews = o, true;
    }
  }
  function dGe(t) {
    let e = t.dom.ownerDocument.documentElement;
    return {
      top: 0,
      left: 0,
      bottom: e.clientHeight,
      right: e.clientWidth
    };
  }
  const r$ = Ge.define({
    combine: (t) => {
      var e, n, r;
      return {
        position: Ee.ios ? "absolute" : ((e = t.find((i) => i.position)) === null || e === void 0 ? void 0 : e.position) || "fixed",
        parent: ((n = t.find((i) => i.parent)) === null || n === void 0 ? void 0 : n.parent) || null,
        tooltipSpace: ((r = t.find((i) => i.tooltipSpace)) === null || r === void 0 ? void 0 : r.tooltipSpace) || dGe
      };
    }
  }), PU = /* @__PURE__ */ new WeakMap(), Ej = ur.fromClass(class {
    constructor(t) {
      this.view = t, this.above = [], this.inView = true, this.madeAbsolute = false, this.lastTransaction = 0, this.measureTimeout = -1;
      let e = t.state.facet(r$);
      this.position = e.position, this.parent = e.parent, this.classes = t.themeClasses, this.createContainer(), this.measureReq = {
        read: this.readMeasure.bind(this),
        write: this.writeMeasure.bind(this),
        key: this
      }, this.resizeObserver = typeof ResizeObserver == "function" ? new ResizeObserver(() => this.measureSoon()) : null, this.manager = new _oe(t, Ij, (n, r) => this.createTooltip(n, r), (n) => {
        this.resizeObserver && this.resizeObserver.unobserve(n.dom), n.dom.remove();
      }), this.above = this.manager.tooltips.map((n) => !!n.above), this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver((n) => {
        Date.now() > this.lastTransaction - 50 && n.length > 0 && n[n.length - 1].intersectionRatio < 1 && this.measureSoon();
      }, {
        threshold: [
          1
        ]
      }) : null, this.observeIntersection(), t.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this)), this.maybeMeasure();
    }
    createContainer() {
      this.parent ? (this.container = document.createElement("div"), this.container.style.position = "relative", this.container.className = this.view.themeClasses, this.parent.appendChild(this.container)) : this.container = this.view.dom;
    }
    observeIntersection() {
      if (this.intersectionObserver) {
        this.intersectionObserver.disconnect();
        for (let t of this.manager.tooltipViews)
          this.intersectionObserver.observe(t.dom);
      }
    }
    measureSoon() {
      this.measureTimeout < 0 && (this.measureTimeout = setTimeout(() => {
        this.measureTimeout = -1, this.maybeMeasure();
      }, 50));
    }
    update(t) {
      t.transactions.length && (this.lastTransaction = Date.now());
      let e = this.manager.update(t, this.above);
      e && this.observeIntersection();
      let n = e || t.geometryChanged, r = t.state.facet(r$);
      if (r.position != this.position && !this.madeAbsolute) {
        this.position = r.position;
        for (let i of this.manager.tooltipViews)
          i.dom.style.position = this.position;
        n = true;
      }
      if (r.parent != this.parent) {
        this.parent && this.container.remove(), this.parent = r.parent, this.createContainer();
        for (let i of this.manager.tooltipViews)
          this.container.appendChild(i.dom);
        n = true;
      } else
        this.parent && this.view.themeClasses != this.classes && (this.classes = this.container.className = this.view.themeClasses);
      n && this.maybeMeasure();
    }
    createTooltip(t, e) {
      let n = t.create(this.view), r = e ? e.dom : null;
      if (n.dom.classList.add("cm-tooltip"), t.arrow && !n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
        let i = document.createElement("div");
        i.className = "cm-tooltip-arrow", n.dom.appendChild(i);
      }
      return n.dom.style.position = this.position, n.dom.style.top = i0, n.dom.style.left = "0px", this.container.insertBefore(n.dom, r), n.mount && n.mount(this.view), this.resizeObserver && this.resizeObserver.observe(n.dom), n;
    }
    destroy() {
      var t, e, n;
      this.view.win.removeEventListener("resize", this.measureSoon);
      for (let r of this.manager.tooltipViews)
        r.dom.remove(), (t = r.destroy) === null || t === void 0 || t.call(r);
      this.parent && this.container.remove(), (e = this.resizeObserver) === null || e === void 0 || e.disconnect(), (n = this.intersectionObserver) === null || n === void 0 || n.disconnect(), clearTimeout(this.measureTimeout);
    }
    readMeasure() {
      let t = 1, e = 1, n = false;
      if (this.position == "fixed" && this.manager.tooltipViews.length) {
        let { dom: s } = this.manager.tooltipViews[0];
        if (Ee.gecko)
          n = s.offsetParent != this.container.ownerDocument.body;
        else if (s.style.top == i0 && s.style.left == "0px") {
          let o = s.getBoundingClientRect();
          n = Math.abs(o.top + 1e4) > 1 || Math.abs(o.left) > 1;
        }
      }
      if (n || this.position == "absolute")
        if (this.parent) {
          let s = this.parent.getBoundingClientRect();
          s.width && s.height && (t = s.width / this.parent.offsetWidth, e = s.height / this.parent.offsetHeight);
        } else
          ({ scaleX: t, scaleY: e } = this.view.viewState);
      let r = this.view.scrollDOM.getBoundingClientRect(), i = Pj(this.view);
      return {
        visible: {
          left: r.left + i.left,
          top: r.top + i.top,
          right: r.right - i.right,
          bottom: r.bottom - i.bottom
        },
        parent: this.parent ? this.container.getBoundingClientRect() : this.view.dom.getBoundingClientRect(),
        pos: this.manager.tooltips.map((s, o) => {
          let a = this.manager.tooltipViews[o];
          return a.getCoords ? a.getCoords(s.pos) : this.view.coordsAtPos(s.pos);
        }),
        size: this.manager.tooltipViews.map(({ dom: s }) => s.getBoundingClientRect()),
        space: this.view.state.facet(r$).tooltipSpace(this.view),
        scaleX: t,
        scaleY: e,
        makeAbsolute: n
      };
    }
    writeMeasure(t) {
      var e;
      if (t.makeAbsolute) {
        this.madeAbsolute = true, this.position = "absolute";
        for (let a of this.manager.tooltipViews)
          a.dom.style.position = "absolute";
      }
      let { visible: n, space: r, scaleX: i, scaleY: s } = t, o = [];
      for (let a = 0; a < this.manager.tooltips.length; a++) {
        let l = this.manager.tooltips[a], c = this.manager.tooltipViews[a], { dom: u } = c, d = t.pos[a], h = t.size[a];
        if (!d || l.clip !== false && (d.bottom <= Math.max(n.top, r.top) || d.top >= Math.min(n.bottom, r.bottom) || d.right < Math.max(n.left, r.left) - 0.1 || d.left > Math.min(n.right, r.right) + 0.1)) {
          u.style.top = i0;
          continue;
        }
        let f = l.arrow ? c.dom.querySelector(".cm-tooltip-arrow") : null, y = f ? 7 : 0, g = h.right - h.left, O = (e = PU.get(c)) !== null && e !== void 0 ? e : h.bottom - h.top, S = c.offset || fGe, w = this.view.textDirection == er.LTR, x = h.width > r.right - r.left ? w ? r.left : r.right - h.width : w ? Math.max(r.left, Math.min(d.left - (f ? 14 : 0) + S.x, r.right - g)) : Math.min(Math.max(r.left, d.left - g + (f ? 14 : 0) - S.x), r.right - g), P = this.above[a];
        !l.strictSide && (P ? d.top - O - y - S.y < r.top : d.bottom + O + y + S.y > r.bottom) && P == r.bottom - d.bottom > d.top - r.top && (P = this.above[a] = !P);
        let C = (P ? d.top - r.top : r.bottom - d.bottom) - y;
        if (C < O && c.resize !== false) {
          if (C < this.view.defaultLineHeight) {
            u.style.top = i0;
            continue;
          }
          PU.set(c, O), u.style.height = (O = C) / s + "px";
        } else
          u.style.height && (u.style.height = "");
        let _ = P ? d.top - O - y - S.y : d.bottom + y + S.y, T = x + g;
        if (c.overlap !== true)
          for (let $ of o)
            $.left < T && $.right > x && $.top < _ + O && $.bottom > _ && (_ = P ? $.top - O - 2 - y : $.bottom + y + 2);
        if (this.position == "absolute" ? (u.style.top = (_ - t.parent.top) / s + "px", CU(u, (x - t.parent.left) / i)) : (u.style.top = _ / s + "px", CU(u, x / i)), f) {
          let $ = d.left + (w ? S.x : -S.x) - (x + 14 - 7);
          f.style.left = $ / i + "px";
        }
        c.overlap !== true && o.push({
          left: x,
          top: _,
          right: T,
          bottom: _ + O
        }), u.classList.toggle("cm-tooltip-above", P), u.classList.toggle("cm-tooltip-below", !P), c.positioned && c.positioned(t.space);
      }
    }
    maybeMeasure() {
      if (this.manager.tooltips.length && (this.view.inView && this.view.requestMeasure(this.measureReq), this.inView != this.view.inView && (this.inView = this.view.inView, !this.inView)))
        for (let t of this.manager.tooltipViews)
          t.dom.style.top = i0;
    }
  }, {
    eventObservers: {
      scroll() {
        this.maybeMeasure();
      }
    }
  });
  function CU(t, e) {
    let n = parseInt(t.style.left, 10);
    (isNaN(n) || Math.abs(e - n) > 1) && (t.style.left = e + "px");
  }
  const hGe = Re.baseTheme({
    ".cm-tooltip": {
      zIndex: 500,
      boxSizing: "border-box"
    },
    "&light .cm-tooltip": {
      border: "1px solid #bbb",
      backgroundColor: "#f5f5f5"
    },
    "&light .cm-tooltip-section:not(:first-child)": {
      borderTop: "1px solid #bbb"
    },
    "&dark .cm-tooltip": {
      backgroundColor: "#333338",
      color: "white"
    },
    ".cm-tooltip-arrow": {
      height: "7px",
      width: `${7 * 2}px`,
      position: "absolute",
      zIndex: -1,
      overflow: "hidden",
      "&:before, &:after": {
        content: "''",
        position: "absolute",
        width: 0,
        height: 0,
        borderLeft: "7px solid transparent",
        borderRight: "7px solid transparent"
      },
      ".cm-tooltip-above &": {
        bottom: "-7px",
        "&:before": {
          borderTop: "7px solid #bbb"
        },
        "&:after": {
          borderTop: "7px solid #f5f5f5",
          bottom: "1px"
        }
      },
      ".cm-tooltip-below &": {
        top: "-7px",
        "&:before": {
          borderBottom: "7px solid #bbb"
        },
        "&:after": {
          borderBottom: "7px solid #f5f5f5",
          top: "1px"
        }
      }
    },
    "&dark .cm-tooltip .cm-tooltip-arrow": {
      "&:before": {
        borderTopColor: "#333338",
        borderBottomColor: "#333338"
      },
      "&:after": {
        borderTopColor: "transparent",
        borderBottomColor: "transparent"
      }
    }
  }), fGe = {
    x: 0,
    y: 0
  }, Ij = Ge.define({
    enables: [
      Ej,
      hGe
    ]
  }), hP = Ge.define({
    combine: (t) => t.reduce((e, n) => e.concat(n), [])
  });
  class I2 {
    static create(e) {
      return new I2(e);
    }
    constructor(e) {
      this.view = e, this.mounted = false, this.dom = document.createElement("div"), this.dom.classList.add("cm-tooltip-hover"), this.manager = new _oe(e, hP, (n, r) => this.createHostedView(n, r), (n) => n.dom.remove());
    }
    createHostedView(e, n) {
      let r = e.create(this.view);
      return r.dom.classList.add("cm-tooltip-section"), this.dom.insertBefore(r.dom, n ? n.dom.nextSibling : this.dom.firstChild), this.mounted && r.mount && r.mount(this.view), r;
    }
    mount(e) {
      for (let n of this.manager.tooltipViews)
        n.mount && n.mount(e);
      this.mounted = true;
    }
    positioned(e) {
      for (let n of this.manager.tooltipViews)
        n.positioned && n.positioned(e);
    }
    update(e) {
      this.manager.update(e);
    }
    destroy() {
      var e;
      for (let n of this.manager.tooltipViews)
        (e = n.destroy) === null || e === void 0 || e.call(n);
    }
    passProp(e) {
      let n;
      for (let r of this.manager.tooltipViews) {
        let i = r[e];
        if (i !== void 0) {
          if (n === void 0)
            n = i;
          else if (n !== i)
            return;
        }
      }
      return n;
    }
    get offset() {
      return this.passProp("offset");
    }
    get getCoords() {
      return this.passProp("getCoords");
    }
    get overlap() {
      return this.passProp("overlap");
    }
    get resize() {
      return this.passProp("resize");
    }
  }
  const pGe = Ij.compute([
    hP
  ], (t) => {
    let e = t.facet(hP);
    return e.length === 0 ? null : {
      pos: Math.min(...e.map((n) => n.pos)),
      end: Math.max(...e.map((n) => {
        var r;
        return (r = n.end) !== null && r !== void 0 ? r : n.pos;
      })),
      create: I2.create,
      above: e[0].above,
      arrow: e.some((n) => n.arrow)
    };
  });
  class gGe {
    constructor(e, n, r, i, s) {
      this.view = e, this.source = n, this.field = r, this.setHover = i, this.hoverTime = s, this.hoverTimeout = -1, this.restartTimeout = -1, this.pending = null, this.lastMove = {
        x: 0,
        y: 0,
        target: e.dom,
        time: 0
      }, this.checkHover = this.checkHover.bind(this), e.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this)), e.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
    }
    update() {
      this.pending && (this.pending = null, clearTimeout(this.restartTimeout), this.restartTimeout = setTimeout(() => this.startHover(), 20));
    }
    get active() {
      return this.view.state.field(this.field);
    }
    checkHover() {
      if (this.hoverTimeout = -1, this.active.length)
        return;
      let e = Date.now() - this.lastMove.time;
      e < this.hoverTime ? this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - e) : this.startHover();
    }
    startHover() {
      clearTimeout(this.restartTimeout);
      let { view: e, lastMove: n } = this, r = e.docView.nearest(n.target);
      if (!r)
        return;
      let i, s = 1;
      if (r instanceof ed)
        i = r.posAtStart;
      else {
        if (i = e.posAtCoords(n), i == null)
          return;
        let a = e.coordsAtPos(i);
        if (!a || n.y < a.top || n.y > a.bottom || n.x < a.left - e.defaultCharacterWidth || n.x > a.right + e.defaultCharacterWidth)
          return;
        let l = e.bidiSpans(e.state.doc.lineAt(i)).find((u) => u.from <= i && u.to >= i), c = l && l.dir == er.RTL ? -1 : 1;
        s = n.x < a.left ? -c : c;
      }
      let o = this.source(e, i, s);
      if (o == null ? void 0 : o.then) {
        let a = this.pending = {
          pos: i
        };
        o.then((l) => {
          this.pending == a && (this.pending = null, l && !(Array.isArray(l) && !l.length) && e.dispatch({
            effects: this.setHover.of(Array.isArray(l) ? l : [
              l
            ])
          }));
        }, (l) => Vo(e.state, l, "hover tooltip"));
      } else
        o && !(Array.isArray(o) && !o.length) && e.dispatch({
          effects: this.setHover.of(Array.isArray(o) ? o : [
            o
          ])
        });
    }
    get tooltip() {
      let e = this.view.plugin(Ej), n = e ? e.manager.tooltips.findIndex((r) => r.create == I2.create) : -1;
      return n > -1 ? e.manager.tooltipViews[n] : null;
    }
    mousemove(e) {
      var n, r;
      this.lastMove = {
        x: e.clientX,
        y: e.clientY,
        target: e.target,
        time: Date.now()
      }, this.hoverTimeout < 0 && (this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime));
      let { active: i, tooltip: s } = this;
      if (i.length && s && !mGe(s.dom, e) || this.pending) {
        let { pos: o } = i[0] || this.pending, a = (r = (n = i[0]) === null || n === void 0 ? void 0 : n.end) !== null && r !== void 0 ? r : o;
        (o == a ? this.view.posAtCoords(this.lastMove) != o : !yGe(this.view, o, a, e.clientX, e.clientY)) && (this.view.dispatch({
          effects: this.setHover.of([])
        }), this.pending = null);
      }
    }
    mouseleave(e) {
      clearTimeout(this.hoverTimeout), this.hoverTimeout = -1;
      let { active: n } = this;
      if (n.length) {
        let { tooltip: r } = this;
        r && r.dom.contains(e.relatedTarget) ? this.watchTooltipLeave(r.dom) : this.view.dispatch({
          effects: this.setHover.of([])
        });
      }
    }
    watchTooltipLeave(e) {
      let n = (r) => {
        e.removeEventListener("mouseleave", n), this.active.length && !this.view.dom.contains(r.relatedTarget) && this.view.dispatch({
          effects: this.setHover.of([])
        });
      };
      e.addEventListener("mouseleave", n);
    }
    destroy() {
      clearTimeout(this.hoverTimeout), this.view.dom.removeEventListener("mouseleave", this.mouseleave), this.view.dom.removeEventListener("mousemove", this.mousemove);
    }
  }
  const ax = 4;
  function mGe(t, e) {
    let { left: n, right: r, top: i, bottom: s } = t.getBoundingClientRect(), o;
    if (o = t.querySelector(".cm-tooltip-arrow")) {
      let a = o.getBoundingClientRect();
      i = Math.min(a.top, i), s = Math.max(a.bottom, s);
    }
    return e.clientX >= n - ax && e.clientX <= r + ax && e.clientY >= i - ax && e.clientY <= s + ax;
  }
  function yGe(t, e, n, r, i, s) {
    let o = t.scrollDOM.getBoundingClientRect(), a = t.documentTop + t.documentPadding.top + t.contentHeight;
    if (o.left > r || o.right < r || o.top > i || Math.min(o.bottom, a) < i)
      return false;
    let l = t.posAtCoords({
      x: r,
      y: i
    }, false);
    return l >= e && l <= n;
  }
  function vGe(t, e = {}) {
    let n = kn.define(), r = Xd.define({
      create() {
        return [];
      },
      update(i, s) {
        if (i.length && (e.hideOnChange && (s.docChanged || s.selection) ? i = [] : e.hideOn && (i = i.filter((o) => !e.hideOn(s, o))), s.docChanged)) {
          let o = [];
          for (let a of i) {
            let l = s.changes.mapPos(a.pos, -1, yi.TrackDel);
            if (l != null) {
              let c = Object.assign(/* @__PURE__ */ Object.create(null), a);
              c.pos = l, c.end != null && (c.end = s.changes.mapPos(c.end)), o.push(c);
            }
          }
          i = o;
        }
        for (let o of s.effects)
          o.is(n) && (i = o.value), o.is(SGe) && (i = []);
        return i;
      },
      provide: (i) => hP.from(i)
    });
    return {
      active: r,
      extension: [
        r,
        ur.define((i) => new gGe(i, t, r, n, e.hoverTime || 300)),
        pGe
      ]
    };
  }
  function OGe(t, e) {
    let n = t.plugin(Ej);
    if (!n)
      return null;
    let r = n.manager.tooltips.indexOf(e);
    return r < 0 ? null : n.manager.tooltipViews[r];
  }
  const SGe = kn.define(), _U = Ge.define({
    combine(t) {
      let e, n;
      for (let r of t)
        e = e || r.topContainer, n = n || r.bottomContainer;
      return {
        topContainer: e,
        bottomContainer: n
      };
    }
  });
  function mO(t, e) {
    let n = t.plugin(Toe), r = n ? n.specs.indexOf(e) : -1;
    return r > -1 ? n.panels[r] : null;
  }
  const Toe = ur.fromClass(class {
    constructor(t) {
      this.input = t.state.facet(yO), this.specs = this.input.filter((n) => n), this.panels = this.specs.map((n) => n(t));
      let e = t.state.facet(_U);
      this.top = new lx(t, true, e.topContainer), this.bottom = new lx(t, false, e.bottomContainer), this.top.sync(this.panels.filter((n) => n.top)), this.bottom.sync(this.panels.filter((n) => !n.top));
      for (let n of this.panels)
        n.dom.classList.add("cm-panel"), n.mount && n.mount();
    }
    update(t) {
      let e = t.state.facet(_U);
      this.top.container != e.topContainer && (this.top.sync([]), this.top = new lx(t.view, true, e.topContainer)), this.bottom.container != e.bottomContainer && (this.bottom.sync([]), this.bottom = new lx(t.view, false, e.bottomContainer)), this.top.syncClasses(), this.bottom.syncClasses();
      let n = t.state.facet(yO);
      if (n != this.input) {
        let r = n.filter((l) => l), i = [], s = [], o = [], a = [];
        for (let l of r) {
          let c = this.specs.indexOf(l), u;
          c < 0 ? (u = l(t.view), a.push(u)) : (u = this.panels[c], u.update && u.update(t)), i.push(u), (u.top ? s : o).push(u);
        }
        this.specs = r, this.panels = i, this.top.sync(s), this.bottom.sync(o);
        for (let l of a)
          l.dom.classList.add("cm-panel"), l.mount && l.mount();
      } else
        for (let r of this.panels)
          r.update && r.update(t);
    }
    destroy() {
      this.top.sync([]), this.bottom.sync([]);
    }
  }, {
    provide: (t) => Re.scrollMargins.of((e) => {
      let n = e.plugin(t);
      return n && {
        top: n.top.scrollMargin(),
        bottom: n.bottom.scrollMargin()
      };
    })
  });
  class lx {
    constructor(e, n, r) {
      this.view = e, this.top = n, this.container = r, this.dom = void 0, this.classes = "", this.panels = [], this.syncClasses();
    }
    sync(e) {
      for (let n of this.panels)
        n.destroy && e.indexOf(n) < 0 && n.destroy();
      this.panels = e, this.syncDOM();
    }
    syncDOM() {
      if (this.panels.length == 0) {
        this.dom && (this.dom.remove(), this.dom = void 0);
        return;
      }
      if (!this.dom) {
        this.dom = document.createElement("div"), this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom", this.dom.style[this.top ? "top" : "bottom"] = "0";
        let n = this.container || this.view.dom;
        n.insertBefore(this.dom, this.top ? n.firstChild : null);
      }
      let e = this.dom.firstChild;
      for (let n of this.panels)
        if (n.dom.parentNode == this.dom) {
          for (; e != n.dom; )
            e = TU(e);
          e = e.nextSibling;
        } else
          this.dom.insertBefore(n.dom, e);
      for (; e; )
        e = TU(e);
    }
    scrollMargin() {
      return !this.dom || this.container ? 0 : Math.max(0, this.top ? this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) : Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
    }
    syncClasses() {
      if (!(!this.container || this.classes == this.view.themeClasses)) {
        for (let e of this.classes.split(" "))
          e && this.container.classList.remove(e);
        for (let e of (this.classes = this.view.themeClasses).split(" "))
          e && this.container.classList.add(e);
      }
    }
  }
  function TU(t) {
    let e = t.nextSibling;
    return t.remove(), e;
  }
  const yO = Ge.define({
    enables: Toe
  });
  class im extends uf {
    compare(e) {
      return this == e || this.constructor == e.constructor && this.eq(e);
    }
    eq(e) {
      return false;
    }
    destroy(e) {
    }
  }
  im.prototype.elementClass = "";
  im.prototype.toDOM = void 0;
  im.prototype.mapMode = yi.TrackBefore;
  im.prototype.startSide = im.prototype.endSide = -1;
  im.prototype.point = true;
  const Eoe = 1024;
  let wGe = 0, Xo = class {
    constructor(e, n) {
      this.from = e, this.to = n;
    }
  }, ut = class {
    constructor(e = {}) {
      this.id = wGe++, this.perNode = !!e.perNode, this.deserialize = e.deserialize || (() => {
        throw new Error("This node type doesn't define a deserialize function");
      });
    }
    add(e) {
      if (this.perNode)
        throw new RangeError("Can't add per-node props to node types");
      return typeof e != "function" && (e = Tr.match(e)), (n) => {
        let r = e(n);
        return r === void 0 ? null : [
          this,
          r
        ];
      };
    }
  };
  ut.closedBy = new ut({
    deserialize: (t) => t.split(" ")
  });
  ut.openedBy = new ut({
    deserialize: (t) => t.split(" ")
  });
  ut.group = new ut({
    deserialize: (t) => t.split(" ")
  });
  ut.isolate = new ut({
    deserialize: (t) => {
      if (t && t != "rtl" && t != "ltr" && t != "auto")
        throw new RangeError("Invalid value for isolate: " + t);
      return t || "auto";
    }
  });
  ut.contextHash = new ut({
    perNode: true
  });
  ut.lookAhead = new ut({
    perNode: true
  });
  ut.mounted = new ut({
    perNode: true
  });
  let vO = class {
    constructor(e, n, r) {
      this.tree = e, this.overlay = n, this.parser = r;
    }
    static get(e) {
      return e && e.props && e.props[ut.mounted.id];
    }
  };
  const xGe = /* @__PURE__ */ Object.create(null);
  let Tr = class Ioe {
    constructor(e, n, r, i = 0) {
      this.name = e, this.props = n, this.id = r, this.flags = i;
    }
    static define(e) {
      let n = e.props && e.props.length ? /* @__PURE__ */ Object.create(null) : xGe, r = (e.top ? 1 : 0) | (e.skipped ? 2 : 0) | (e.error ? 4 : 0) | (e.name == null ? 8 : 0), i = new Ioe(e.name || "", n, e.id, r);
      if (e.props) {
        for (let s of e.props)
          if (Array.isArray(s) || (s = s(i)), s) {
            if (s[0].perNode)
              throw new RangeError("Can't store a per-node prop on a node type");
            n[s[0].id] = s[1];
          }
      }
      return i;
    }
    prop(e) {
      return this.props[e.id];
    }
    get isTop() {
      return (this.flags & 1) > 0;
    }
    get isSkipped() {
      return (this.flags & 2) > 0;
    }
    get isError() {
      return (this.flags & 4) > 0;
    }
    get isAnonymous() {
      return (this.flags & 8) > 0;
    }
    is(e) {
      if (typeof e == "string") {
        if (this.name == e)
          return true;
        let n = this.prop(ut.group);
        return n ? n.indexOf(e) > -1 : false;
      }
      return this.id == e;
    }
    static match(e) {
      let n = /* @__PURE__ */ Object.create(null);
      for (let r in e)
        for (let i of r.split(" "))
          n[i] = e[r];
      return (r) => {
        for (let i = r.prop(ut.group), s = -1; s < (i ? i.length : 0); s++) {
          let o = n[s < 0 ? r.name : i[s]];
          if (o)
            return o;
        }
      };
    }
  };
  Tr.none = new Tr("", /* @__PURE__ */ Object.create(null), 0, 8);
  class Qm {
    constructor(e) {
      this.types = e;
      for (let n = 0; n < e.length; n++)
        if (e[n].id != n)
          throw new RangeError("Node type ids should correspond to array positions when creating a node set");
    }
    extend(...e) {
      let n = [];
      for (let r of this.types) {
        let i = null;
        for (let s of e) {
          let o = s(r);
          o && (i || (i = Object.assign({}, r.props)), i[o[0].id] = o[1]);
        }
        n.push(i ? new Tr(r.name, i, r.id, r.flags) : r);
      }
      return new Qm(n);
    }
  }
  const cx = /* @__PURE__ */ new WeakMap(), EU = /* @__PURE__ */ new WeakMap();
  (function(t) {
    t[t.ExcludeBuffers = 1] = "ExcludeBuffers", t[t.IncludeAnonymous = 2] = "IncludeAnonymous", t[t.IgnoreMounts = 4] = "IgnoreMounts", t[t.IgnoreOverlays = 8] = "IgnoreOverlays";
  })(dn || (dn = {}));
  let At = class ZM {
    constructor(e, n, r, i, s) {
      if (this.type = e, this.children = n, this.positions = r, this.length = i, this.props = null, s && s.length) {
        this.props = /* @__PURE__ */ Object.create(null);
        for (let [o, a] of s)
          this.props[typeof o == "number" ? o : o.id] = a;
      }
    }
    toString() {
      let e = vO.get(this);
      if (e && !e.overlay)
        return e.tree.toString();
      let n = "";
      for (let r of this.children) {
        let i = r.toString();
        i && (n && (n += ","), n += i);
      }
      return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (n.length ? "(" + n + ")" : "") : n;
    }
    cursor(e = 0) {
      return new fP(this.topNode, e);
    }
    cursorAt(e, n = 0, r = 0) {
      let i = cx.get(this) || this.topNode, s = new fP(i);
      return s.moveTo(e, n), cx.set(this, s._tree), s;
    }
    get topNode() {
      return new ia(this, 0, 0, null);
    }
    resolve(e, n = 0) {
      let r = OO(cx.get(this) || this.topNode, e, n, false);
      return cx.set(this, r), r;
    }
    resolveInner(e, n = 0) {
      let r = OO(EU.get(this) || this.topNode, e, n, true);
      return EU.set(this, r), r;
    }
    resolveStack(e, n = 0) {
      return CGe(this, e, n);
    }
    iterate(e) {
      let { enter: n, leave: r, from: i = 0, to: s = this.length } = e, o = e.mode || 0, a = (o & dn.IncludeAnonymous) > 0;
      for (let l = this.cursor(o | dn.IncludeAnonymous); ; ) {
        let c = false;
        if (l.from <= s && l.to >= i && (!a && l.type.isAnonymous || n(l) !== false)) {
          if (l.firstChild())
            continue;
          c = true;
        }
        for (; c && r && (a || !l.type.isAnonymous) && r(l), !l.nextSibling(); ) {
          if (!l.parent())
            return;
          c = true;
        }
      }
    }
    prop(e) {
      return e.perNode ? this.props ? this.props[e.id] : void 0 : this.type.prop(e);
    }
    get propValues() {
      let e = [];
      if (this.props)
        for (let n in this.props)
          e.push([
            +n,
            this.props[n]
          ]);
      return e;
    }
    balance(e = {}) {
      return this.children.length <= 8 ? this : Aj(Tr.none, this.children, this.positions, 0, this.children.length, 0, this.length, (n, r, i) => new ZM(this.type, n, r, i, this.propValues), e.makeTree || ((n, r, i) => new ZM(Tr.none, n, r, i)));
    }
    static build(e) {
      return _Ge(e);
    }
  };
  At.empty = new At(Tr.none, [], [], 0);
  let bGe = class $oe {
    constructor(e, n) {
      this.buffer = e, this.index = n;
    }
    get id() {
      return this.buffer[this.index - 4];
    }
    get start() {
      return this.buffer[this.index - 3];
    }
    get end() {
      return this.buffer[this.index - 2];
    }
    get size() {
      return this.buffer[this.index - 1];
    }
    get pos() {
      return this.index;
    }
    next() {
      this.index -= 4;
    }
    fork() {
      return new $oe(this.buffer, this.index);
    }
  }, sm = class Aoe {
    constructor(e, n, r) {
      this.buffer = e, this.length = n, this.set = r;
    }
    get type() {
      return Tr.none;
    }
    toString() {
      let e = [];
      for (let n = 0; n < this.buffer.length; )
        e.push(this.childString(n)), n = this.buffer[n + 3];
      return e.join(",");
    }
    childString(e) {
      let n = this.buffer[e], r = this.buffer[e + 3], i = this.set.types[n], s = i.name;
      if (/\W/.test(s) && !i.isError && (s = JSON.stringify(s)), e += 4, r == e)
        return s;
      let o = [];
      for (; e < r; )
        o.push(this.childString(e)), e = this.buffer[e + 3];
      return s + "(" + o.join(",") + ")";
    }
    findChild(e, n, r, i, s) {
      let { buffer: o } = this, a = -1;
      for (let l = e; l != n && !(Roe(s, i, o[l + 1], o[l + 2]) && (a = l, r > 0)); l = o[l + 3])
        ;
      return a;
    }
    slice(e, n, r) {
      let i = this.buffer, s = new Uint16Array(n - e), o = 0;
      for (let a = e, l = 0; a < n; ) {
        s[l++] = i[a++], s[l++] = i[a++] - r;
        let c = s[l++] = i[a++] - r;
        s[l++] = i[a++] - e, o = Math.max(o, c);
      }
      return new Aoe(s, o, this.set);
    }
  };
  function Roe(t, e, n, r) {
    switch (t) {
      case -2:
        return n < e;
      case -1:
        return r >= e && n < e;
      case 0:
        return n < e && r > e;
      case 1:
        return n <= e && r > e;
      case 2:
        return r > e;
      case 4:
        return true;
    }
  }
  function OO(t, e, n, r) {
    for (var i; t.from == t.to || (n < 1 ? t.from >= e : t.from > e) || (n > -1 ? t.to <= e : t.to < e); ) {
      let o = !r && t instanceof ia && t.index < 0 ? null : t.parent;
      if (!o)
        return t;
      t = o;
    }
    let s = r ? 0 : dn.IgnoreOverlays;
    if (r)
      for (let o = t, a = o.parent; a; o = a, a = o.parent)
        o instanceof ia && o.index < 0 && ((i = a.enter(e, n, s)) === null || i === void 0 ? void 0 : i.from) != o.from && (t = a);
    for (; ; ) {
      let o = t.enter(e, n, s);
      if (!o)
        return t;
      t = o;
    }
  }
  let Moe = class {
    cursor(e = 0) {
      return new fP(this, e);
    }
    getChild(e, n = null, r = null) {
      let i = IU(this, e, n, r);
      return i.length ? i[0] : null;
    }
    getChildren(e, n = null, r = null) {
      return IU(this, e, n, r);
    }
    resolve(e, n = 0) {
      return OO(this, e, n, false);
    }
    resolveInner(e, n = 0) {
      return OO(this, e, n, true);
    }
    matchContext(e) {
      return HM(this.parent, e);
    }
    enterUnfinishedNodesBefore(e) {
      let n = this.childBefore(e), r = this;
      for (; n; ) {
        let i = n.lastChild;
        if (!i || i.to != n.to)
          break;
        i.type.isError && i.from == i.to ? (r = n, n = i.prevSibling) : n = i;
      }
      return r;
    }
    get node() {
      return this;
    }
    get next() {
      return this.parent;
    }
  }, ia = class gb extends Moe {
    constructor(e, n, r, i) {
      super(), this._tree = e, this.from = n, this.index = r, this._parent = i;
    }
    get type() {
      return this._tree.type;
    }
    get name() {
      return this._tree.type.name;
    }
    get to() {
      return this.from + this._tree.length;
    }
    nextChild(e, n, r, i, s = 0) {
      for (let o = this; ; ) {
        for (let { children: a, positions: l } = o._tree, c = n > 0 ? a.length : -1; e != c; e += n) {
          let u = a[e], d = l[e] + o.from;
          if (Roe(i, r, d, d + u.length)) {
            if (u instanceof sm) {
              if (s & dn.ExcludeBuffers)
                continue;
              let h = u.findChild(0, u.buffer.length, n, r - d, i);
              if (h > -1)
                return new SO(new kGe(o, u, e, d), null, h);
            } else if (s & dn.IncludeAnonymous || !u.type.isAnonymous || $j(u)) {
              let h;
              if (!(s & dn.IgnoreMounts) && (h = vO.get(u)) && !h.overlay)
                return new gb(h.tree, d, e, o);
              let f = new gb(u, d, e, o);
              return s & dn.IncludeAnonymous || !f.type.isAnonymous ? f : f.nextChild(n < 0 ? u.children.length - 1 : 0, n, r, i);
            }
          }
        }
        if (s & dn.IncludeAnonymous || !o.type.isAnonymous || (o.index >= 0 ? e = o.index + n : e = n < 0 ? -1 : o._parent._tree.children.length, o = o._parent, !o))
          return null;
      }
    }
    get firstChild() {
      return this.nextChild(0, 1, 0, 4);
    }
    get lastChild() {
      return this.nextChild(this._tree.children.length - 1, -1, 0, 4);
    }
    childAfter(e) {
      return this.nextChild(0, 1, e, 2);
    }
    childBefore(e) {
      return this.nextChild(this._tree.children.length - 1, -1, e, -2);
    }
    enter(e, n, r = 0) {
      let i;
      if (!(r & dn.IgnoreOverlays) && (i = vO.get(this._tree)) && i.overlay) {
        let s = e - this.from;
        for (let { from: o, to: a } of i.overlay)
          if ((n > 0 ? o <= s : o < s) && (n < 0 ? a >= s : a > s))
            return new gb(i.tree, i.overlay[0].from + this.from, -1, this);
      }
      return this.nextChild(0, 1, e, n, r);
    }
    nextSignificantParent() {
      let e = this;
      for (; e.type.isAnonymous && e._parent; )
        e = e._parent;
      return e;
    }
    get parent() {
      return this._parent ? this._parent.nextSignificantParent() : null;
    }
    get nextSibling() {
      return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4) : null;
    }
    get prevSibling() {
      return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4) : null;
    }
    get tree() {
      return this._tree;
    }
    toTree() {
      return this._tree;
    }
    toString() {
      return this._tree.toString();
    }
  };
  function IU(t, e, n, r) {
    let i = t.cursor(), s = [];
    if (!i.firstChild())
      return s;
    if (n != null) {
      for (let o = false; !o; )
        if (o = i.type.is(n), !i.nextSibling())
          return s;
    }
    for (; ; ) {
      if (r != null && i.type.is(r))
        return s;
      if (i.type.is(e) && s.push(i.node), !i.nextSibling())
        return r == null ? s : [];
    }
  }
  function HM(t, e, n = e.length - 1) {
    for (let r = t; n >= 0; r = r.parent) {
      if (!r)
        return false;
      if (!r.type.isAnonymous) {
        if (e[n] && e[n] != r.name)
          return false;
        n--;
      }
    }
    return true;
  }
  let kGe = class {
    constructor(e, n, r, i) {
      this.parent = e, this.buffer = n, this.index = r, this.start = i;
    }
  }, SO = class E0 extends Moe {
    get name() {
      return this.type.name;
    }
    get from() {
      return this.context.start + this.context.buffer.buffer[this.index + 1];
    }
    get to() {
      return this.context.start + this.context.buffer.buffer[this.index + 2];
    }
    constructor(e, n, r) {
      super(), this.context = e, this._parent = n, this.index = r, this.type = e.buffer.set.types[e.buffer.buffer[r]];
    }
    child(e, n, r) {
      let { buffer: i } = this.context, s = i.findChild(this.index + 4, i.buffer[this.index + 3], e, n - this.context.start, r);
      return s < 0 ? null : new E0(this.context, this, s);
    }
    get firstChild() {
      return this.child(1, 0, 4);
    }
    get lastChild() {
      return this.child(-1, 0, 4);
    }
    childAfter(e) {
      return this.child(1, e, 2);
    }
    childBefore(e) {
      return this.child(-1, e, -2);
    }
    enter(e, n, r = 0) {
      if (r & dn.ExcludeBuffers)
        return null;
      let { buffer: i } = this.context, s = i.findChild(this.index + 4, i.buffer[this.index + 3], n > 0 ? 1 : -1, e - this.context.start, n);
      return s < 0 ? null : new E0(this.context, this, s);
    }
    get parent() {
      return this._parent || this.context.parent.nextSignificantParent();
    }
    externalSibling(e) {
      return this._parent ? null : this.context.parent.nextChild(this.context.index + e, e, 0, 4);
    }
    get nextSibling() {
      let { buffer: e } = this.context, n = e.buffer[this.index + 3];
      return n < (this._parent ? e.buffer[this._parent.index + 3] : e.buffer.length) ? new E0(this.context, this._parent, n) : this.externalSibling(1);
    }
    get prevSibling() {
      let { buffer: e } = this.context, n = this._parent ? this._parent.index + 4 : 0;
      return this.index == n ? this.externalSibling(-1) : new E0(this.context, this._parent, e.findChild(n, this.index, -1, 0, 4));
    }
    get tree() {
      return null;
    }
    toTree() {
      let e = [], n = [], { buffer: r } = this.context, i = this.index + 4, s = r.buffer[this.index + 3];
      if (s > i) {
        let o = r.buffer[this.index + 1];
        e.push(r.slice(i, s, o)), n.push(0);
      }
      return new At(this.type, e, n, this.to - this.from);
    }
    toString() {
      return this.context.buffer.childString(this.index);
    }
  };
  function Doe(t) {
    if (!t.length)
      return null;
    let e = 0, n = t[0];
    for (let s = 1; s < t.length; s++) {
      let o = t[s];
      (o.from > n.from || o.to < n.to) && (n = o, e = s);
    }
    let r = n instanceof ia && n.index < 0 ? null : n.parent, i = t.slice();
    return r ? i[e] = r : i.splice(e, 1), new PGe(i, n);
  }
  let PGe = class {
    constructor(e, n) {
      this.heads = e, this.node = n;
    }
    get next() {
      return Doe(this.heads);
    }
  };
  function CGe(t, e, n) {
    let r = t.resolveInner(e, n), i = null;
    for (let s = r instanceof ia ? r : r.context.parent; s; s = s.parent)
      if (s.index < 0) {
        let o = s.parent;
        (i || (i = [
          r
        ])).push(o.resolve(e, n)), s = o;
      } else {
        let o = vO.get(s.tree);
        if (o && o.overlay && o.overlay[0].from <= e && o.overlay[o.overlay.length - 1].to >= e) {
          let a = new ia(o.tree, o.overlay[0].from + s.from, -1, s);
          (i || (i = [
            r
          ])).push(OO(a, e, n, false));
        }
      }
    return i ? Doe(i) : r;
  }
  let fP = class {
    get name() {
      return this.type.name;
    }
    constructor(e, n = 0) {
      if (this.mode = n, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, e instanceof ia)
        this.yieldNode(e);
      else {
        this._tree = e.context.parent, this.buffer = e.context;
        for (let r = e._parent; r; r = r._parent)
          this.stack.unshift(r.index);
        this.bufferNode = e, this.yieldBuf(e.index);
      }
    }
    yieldNode(e) {
      return e ? (this._tree = e, this.type = e.type, this.from = e.from, this.to = e.to, true) : false;
    }
    yieldBuf(e, n) {
      this.index = e;
      let { start: r, buffer: i } = this.buffer;
      return this.type = n || i.set.types[i.buffer[e]], this.from = r + i.buffer[e + 1], this.to = r + i.buffer[e + 2], true;
    }
    yield(e) {
      return e ? e instanceof ia ? (this.buffer = null, this.yieldNode(e)) : (this.buffer = e.context, this.yieldBuf(e.index, e.type)) : false;
    }
    toString() {
      return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
    }
    enterChild(e, n, r) {
      if (!this.buffer)
        return this.yield(this._tree.nextChild(e < 0 ? this._tree._tree.children.length - 1 : 0, e, n, r, this.mode));
      let { buffer: i } = this.buffer, s = i.findChild(this.index + 4, i.buffer[this.index + 3], e, n - this.buffer.start, r);
      return s < 0 ? false : (this.stack.push(this.index), this.yieldBuf(s));
    }
    firstChild() {
      return this.enterChild(1, 0, 4);
    }
    lastChild() {
      return this.enterChild(-1, 0, 4);
    }
    childAfter(e) {
      return this.enterChild(1, e, 2);
    }
    childBefore(e) {
      return this.enterChild(-1, e, -2);
    }
    enter(e, n, r = this.mode) {
      return this.buffer ? r & dn.ExcludeBuffers ? false : this.enterChild(1, e, n) : this.yield(this._tree.enter(e, n, r));
    }
    parent() {
      if (!this.buffer)
        return this.yieldNode(this.mode & dn.IncludeAnonymous ? this._tree._parent : this._tree.parent);
      if (this.stack.length)
        return this.yieldBuf(this.stack.pop());
      let e = this.mode & dn.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
      return this.buffer = null, this.yieldNode(e);
    }
    sibling(e) {
      if (!this.buffer)
        return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + e, e, 0, 4, this.mode)) : false;
      let { buffer: n } = this.buffer, r = this.stack.length - 1;
      if (e < 0) {
        let i = r < 0 ? 0 : this.stack[r] + 4;
        if (this.index != i)
          return this.yieldBuf(n.findChild(i, this.index, -1, 0, 4));
      } else {
        let i = n.buffer[this.index + 3];
        if (i < (r < 0 ? n.buffer.length : n.buffer[this.stack[r] + 3]))
          return this.yieldBuf(i);
      }
      return r < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + e, e, 0, 4, this.mode)) : false;
    }
    nextSibling() {
      return this.sibling(1);
    }
    prevSibling() {
      return this.sibling(-1);
    }
    atLastNode(e) {
      let n, r, { buffer: i } = this;
      if (i) {
        if (e > 0) {
          if (this.index < i.buffer.buffer.length)
            return false;
        } else
          for (let s = 0; s < this.index; s++)
            if (i.buffer.buffer[s + 3] < this.index)
              return false;
        ({ index: n, parent: r } = i);
      } else
        ({ index: n, _parent: r } = this._tree);
      for (; r; { index: n, _parent: r } = r)
        if (n > -1)
          for (let s = n + e, o = e < 0 ? -1 : r._tree.children.length; s != o; s += e) {
            let a = r._tree.children[s];
            if (this.mode & dn.IncludeAnonymous || a instanceof sm || !a.type.isAnonymous || $j(a))
              return false;
          }
      return true;
    }
    move(e, n) {
      if (n && this.enterChild(e, 0, 4))
        return true;
      for (; ; ) {
        if (this.sibling(e))
          return true;
        if (this.atLastNode(e) || !this.parent())
          return false;
      }
    }
    next(e = true) {
      return this.move(1, e);
    }
    prev(e = true) {
      return this.move(-1, e);
    }
    moveTo(e, n = 0) {
      for (; (this.from == this.to || (n < 1 ? this.from >= e : this.from > e) || (n > -1 ? this.to <= e : this.to < e)) && this.parent(); )
        ;
      for (; this.enterChild(1, e, n); )
        ;
      return this;
    }
    get node() {
      if (!this.buffer)
        return this._tree;
      let e = this.bufferNode, n = null, r = 0;
      if (e && e.context == this.buffer)
        e:
          for (let i = this.index, s = this.stack.length; s >= 0; ) {
            for (let o = e; o; o = o._parent)
              if (o.index == i) {
                if (i == this.index)
                  return o;
                n = o, r = s + 1;
                break e;
              }
            i = this.stack[--s];
          }
      for (let i = r; i < this.stack.length; i++)
        n = new SO(this.buffer, n, this.stack[i]);
      return this.bufferNode = new SO(this.buffer, n, this.index);
    }
    get tree() {
      return this.buffer ? null : this._tree._tree;
    }
    iterate(e, n) {
      for (let r = 0; ; ) {
        let i = false;
        if (this.type.isAnonymous || e(this) !== false) {
          if (this.firstChild()) {
            r++;
            continue;
          }
          this.type.isAnonymous || (i = true);
        }
        for (; ; ) {
          if (i && n && n(this), i = this.type.isAnonymous, !r)
            return;
          if (this.nextSibling())
            break;
          this.parent(), r--, i = true;
        }
      }
    }
    matchContext(e) {
      if (!this.buffer)
        return HM(this.node.parent, e);
      let { buffer: n } = this.buffer, { types: r } = n.set;
      for (let i = e.length - 1, s = this.stack.length - 1; i >= 0; s--) {
        if (s < 0)
          return HM(this._tree, e, i);
        let o = r[n.buffer[this.stack[s]]];
        if (!o.isAnonymous) {
          if (e[i] && e[i] != o.name)
            return false;
          i--;
        }
      }
      return true;
    }
  };
  function $j(t) {
    return t.children.some((e) => e instanceof sm || !e.type.isAnonymous || $j(e));
  }
  function _Ge(t) {
    var e;
    let { buffer: n, nodeSet: r, maxBufferLength: i = Eoe, reused: s = [], minRepeatType: o = r.types.length } = t, a = Array.isArray(n) ? new bGe(n, n.length) : n, l = r.types, c = 0, u = 0;
    function d(C, _, T, $, N, L) {
      let { id: z, start: M, end: R, size: F } = a, Q = u, X = c;
      for (; F < 0; )
        if (a.next(), F == -1) {
          let se = s[z];
          T.push(se), $.push(M - C);
          return;
        } else if (F == -3) {
          c = z;
          return;
        } else if (F == -4) {
          u = z;
          return;
        } else
          throw new RangeError(`Unrecognized record size: ${F}`);
      let Z = l[z], U, H, te = M - C;
      if (R - M <= i && (H = O(a.pos - _, N))) {
        let se = new Uint16Array(H.size - H.skip), ae = a.pos - H.size, _e3 = se.length;
        for (; a.pos > ae; )
          _e3 = S(H.start, se, _e3);
        U = new sm(se, R - H.start, r), te = H.start - C;
      } else {
        let se = a.pos - F;
        a.next();
        let ae = [], _e3 = [], Me = z >= o ? z : -1, ke = 0, tt = R;
        for (; a.pos > se; )
          Me >= 0 && a.id == Me && a.size >= 0 ? (a.end <= tt - i && (y(ae, _e3, M, ke, a.end, tt, Me, Q, X), ke = ae.length, tt = a.end), a.next()) : L > 2500 ? h(M, se, ae, _e3) : d(M, se, ae, _e3, Me, L + 1);
        if (Me >= 0 && ke > 0 && ke < ae.length && y(ae, _e3, M, ke, M, tt, Me, Q, X), ae.reverse(), _e3.reverse(), Me > -1 && ke > 0) {
          let it = f(Z, X);
          U = Aj(Z, ae, _e3, 0, ae.length, 0, R - M, it, it);
        } else
          U = g(Z, ae, _e3, R - M, Q - R, X);
      }
      T.push(U), $.push(te);
    }
    function h(C, _, T, $) {
      let N = [], L = 0, z = -1;
      for (; a.pos > _; ) {
        let { id: M, start: R, end: F, size: Q } = a;
        if (Q > 4)
          a.next();
        else {
          if (z > -1 && R < z)
            break;
          z < 0 && (z = F - i), N.push(M, R, F), L++, a.next();
        }
      }
      if (L) {
        let M = new Uint16Array(L * 4), R = N[N.length - 2];
        for (let F = N.length - 3, Q = 0; F >= 0; F -= 3)
          M[Q++] = N[F], M[Q++] = N[F + 1] - R, M[Q++] = N[F + 2] - R, M[Q++] = Q;
        T.push(new sm(M, N[2] - R, r)), $.push(R - C);
      }
    }
    function f(C, _) {
      return (T, $, N) => {
        let L = 0, z = T.length - 1, M, R;
        if (z >= 0 && (M = T[z]) instanceof At) {
          if (!z && M.type == C && M.length == N)
            return M;
          (R = M.prop(ut.lookAhead)) && (L = $[z] + M.length + R);
        }
        return g(C, T, $, N, L, _);
      };
    }
    function y(C, _, T, $, N, L, z, M, R) {
      let F = [], Q = [];
      for (; C.length > $; )
        F.push(C.pop()), Q.push(_.pop() + T - N);
      C.push(g(r.types[z], F, Q, L - N, M - L, R)), _.push(N - T);
    }
    function g(C, _, T, $, N, L, z) {
      if (L) {
        let M = [
          ut.contextHash,
          L
        ];
        z = z ? [
          M
        ].concat(z) : [
          M
        ];
      }
      if (N > 25) {
        let M = [
          ut.lookAhead,
          N
        ];
        z = z ? [
          M
        ].concat(z) : [
          M
        ];
      }
      return new At(C, _, T, $, z);
    }
    function O(C, _) {
      let T = a.fork(), $ = 0, N = 0, L = 0, z = T.end - i, M = {
        size: 0,
        start: 0,
        skip: 0
      };
      e:
        for (let R = T.pos - C; T.pos > R; ) {
          let F = T.size;
          if (T.id == _ && F >= 0) {
            M.size = $, M.start = N, M.skip = L, L += 4, $ += 4, T.next();
            continue;
          }
          let Q = T.pos - F;
          if (F < 0 || Q < R || T.start < z)
            break;
          let X = T.id >= o ? 4 : 0, Z = T.start;
          for (T.next(); T.pos > Q; ) {
            if (T.size < 0)
              if (T.size == -3)
                X += 4;
              else
                break e;
            else
              T.id >= o && (X += 4);
            T.next();
          }
          N = Z, $ += F, L += X;
        }
      return (_ < 0 || $ == C) && (M.size = $, M.start = N, M.skip = L), M.size > 4 ? M : void 0;
    }
    function S(C, _, T) {
      let { id: $, start: N, end: L, size: z } = a;
      if (a.next(), z >= 0 && $ < o) {
        let M = T;
        if (z > 4) {
          let R = a.pos - (z - 4);
          for (; a.pos > R; )
            T = S(C, _, T);
        }
        _[--T] = M, _[--T] = L - C, _[--T] = N - C, _[--T] = $;
      } else
        z == -3 ? c = $ : z == -4 && (u = $);
      return T;
    }
    let w = [], x = [];
    for (; a.pos > 0; )
      d(t.start || 0, t.bufferStart || 0, w, x, -1, 0);
    let P = (e = t.length) !== null && e !== void 0 ? e : w.length ? x[0] + w[0].length : 0;
    return new At(l[t.topID], w.reverse(), x.reverse(), P);
  }
  const $U = /* @__PURE__ */ new WeakMap();
  function mb(t, e) {
    if (!t.isAnonymous || e instanceof sm || e.type != t)
      return 1;
    let n = $U.get(e);
    if (n == null) {
      n = 1;
      for (let r of e.children) {
        if (r.type != t || !(r instanceof At)) {
          n = 1;
          break;
        }
        n += mb(t, r);
      }
      $U.set(e, n);
    }
    return n;
  }
  function Aj(t, e, n, r, i, s, o, a, l) {
    let c = 0;
    for (let y = r; y < i; y++)
      c += mb(t, e[y]);
    let u = Math.ceil(c * 1.5 / 8), d = [], h = [];
    function f(y, g, O, S, w) {
      for (let x = O; x < S; ) {
        let P = x, C = g[x], _ = mb(t, y[x]);
        for (x++; x < S; x++) {
          let T = mb(t, y[x]);
          if (_ + T >= u)
            break;
          _ += T;
        }
        if (x == P + 1) {
          if (_ > u) {
            let T = y[P];
            f(T.children, T.positions, 0, T.children.length, g[P] + w);
            continue;
          }
          d.push(y[P]);
        } else {
          let T = g[x - 1] + y[x - 1].length - C;
          d.push(Aj(t, y, g, P, x, C, T, null, l));
        }
        h.push(C + w - s);
      }
    }
    return f(e, n, r, i, 0), (a || l)(d, h, o);
  }
  Loe = class {
    constructor() {
      this.map = /* @__PURE__ */ new WeakMap();
    }
    setBuffer(e, n, r) {
      let i = this.map.get(e);
      i || this.map.set(e, i = /* @__PURE__ */ new Map()), i.set(n, r);
    }
    getBuffer(e, n) {
      let r = this.map.get(e);
      return r && r.get(n);
    }
    set(e, n) {
      e instanceof SO ? this.setBuffer(e.context.buffer, e.index, n) : e instanceof ia && this.map.set(e.tree, n);
    }
    get(e) {
      return e instanceof SO ? this.getBuffer(e.context.buffer, e.index) : e instanceof ia ? this.map.get(e.tree) : void 0;
    }
    cursorSet(e, n) {
      e.buffer ? this.setBuffer(e.buffer.buffer, e.index, n) : this.map.set(e.tree, n);
    }
    cursorGet(e) {
      return e.buffer ? this.getBuffer(e.buffer.buffer, e.index) : this.map.get(e.tree);
    }
  };
  class Bc {
    constructor(e, n, r, i, s = false, o = false) {
      this.from = e, this.to = n, this.tree = r, this.offset = i, this.open = (s ? 1 : 0) | (o ? 2 : 0);
    }
    get openStart() {
      return (this.open & 1) > 0;
    }
    get openEnd() {
      return (this.open & 2) > 0;
    }
    static addTree(e, n = [], r = false) {
      let i = [
        new Bc(0, e.length, e, 0, false, r)
      ];
      for (let s of n)
        s.to > e.length && i.push(s);
      return i;
    }
    static applyChanges(e, n, r = 128) {
      if (!n.length)
        return e;
      let i = [], s = 1, o = e.length ? e[0] : null;
      for (let a = 0, l = 0, c = 0; ; a++) {
        let u = a < n.length ? n[a] : null, d = u ? u.fromA : 1e9;
        if (d - l >= r)
          for (; o && o.from < d; ) {
            let h = o;
            if (l >= h.from || d <= h.to || c) {
              let f = Math.max(h.from, l) - c, y = Math.min(h.to, d) - c;
              h = f >= y ? null : new Bc(f, y, h.tree, h.offset + c, a > 0, !!u);
            }
            if (h && i.push(h), o.to > d)
              break;
            o = s < e.length ? e[s++] : null;
          }
        if (!u)
          break;
        l = u.toA, c = u.toA - u.toB;
      }
      return i;
    }
  }
  class $2 {
    startParse(e, n, r) {
      return typeof e == "string" && (e = new TGe(e)), r = r ? r.length ? r.map((i) => new Xo(i.from, i.to)) : [
        new Xo(0, 0)
      ] : [
        new Xo(0, e.length)
      ], this.createParse(e, n || [], r);
    }
    parse(e, n, r) {
      let i = this.startParse(e, n, r);
      for (; ; ) {
        let s = i.advance();
        if (s)
          return s;
      }
    }
  }
  class TGe {
    constructor(e) {
      this.string = e;
    }
    get length() {
      return this.string.length;
    }
    chunk(e) {
      return this.string.slice(e);
    }
    get lineChunks() {
      return false;
    }
    read(e, n) {
      return this.string.slice(e, n);
    }
  }
  joe = function(t) {
    return (e, n, r, i) => new IGe(e, t, n, r, i);
  };
  class AU {
    constructor(e, n, r, i, s) {
      this.parser = e, this.parse = n, this.overlay = r, this.target = i, this.from = s;
    }
  }
  function RU(t) {
    if (!t.length || t.some((e) => e.from >= e.to))
      throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(t));
  }
  class EGe {
    constructor(e, n, r, i, s, o, a) {
      this.parser = e, this.predicate = n, this.mounts = r, this.index = i, this.start = s, this.target = o, this.prev = a, this.depth = 0, this.ranges = [];
    }
  }
  const YM = new ut({
    perNode: true
  });
  class IGe {
    constructor(e, n, r, i, s) {
      this.nest = n, this.input = r, this.fragments = i, this.ranges = s, this.inner = [], this.innerDone = 0, this.baseTree = null, this.stoppedAt = null, this.baseParse = e;
    }
    advance() {
      if (this.baseParse) {
        let r = this.baseParse.advance();
        if (!r)
          return null;
        if (this.baseParse = null, this.baseTree = r, this.startInner(), this.stoppedAt != null)
          for (let i of this.inner)
            i.parse.stopAt(this.stoppedAt);
      }
      if (this.innerDone == this.inner.length) {
        let r = this.baseTree;
        return this.stoppedAt != null && (r = new At(r.type, r.children, r.positions, r.length, r.propValues.concat([
          [
            YM,
            this.stoppedAt
          ]
        ]))), r;
      }
      let e = this.inner[this.innerDone], n = e.parse.advance();
      if (n) {
        this.innerDone++;
        let r = Object.assign(/* @__PURE__ */ Object.create(null), e.target.props);
        r[ut.mounted.id] = new vO(n, e.overlay, e.parser), e.target.props = r;
      }
      return null;
    }
    get parsedPos() {
      if (this.baseParse)
        return 0;
      let e = this.input.length;
      for (let n = this.innerDone; n < this.inner.length; n++)
        this.inner[n].from < e && (e = Math.min(e, this.inner[n].parse.parsedPos));
      return e;
    }
    stopAt(e) {
      if (this.stoppedAt = e, this.baseParse)
        this.baseParse.stopAt(e);
      else
        for (let n = this.innerDone; n < this.inner.length; n++)
          this.inner[n].parse.stopAt(e);
    }
    startInner() {
      let e = new RGe(this.fragments), n = null, r = null, i = new fP(new ia(this.baseTree, this.ranges[0].from, 0, null), dn.IncludeAnonymous | dn.IgnoreMounts);
      e:
        for (let s, o; ; ) {
          let a = true, l;
          if (this.stoppedAt != null && i.from >= this.stoppedAt)
            a = false;
          else if (e.hasNode(i)) {
            if (n) {
              let c = n.mounts.find((u) => u.frag.from <= i.from && u.frag.to >= i.to && u.mount.overlay);
              if (c)
                for (let u of c.mount.overlay) {
                  let d = u.from + c.pos, h = u.to + c.pos;
                  d >= i.from && h <= i.to && !n.ranges.some((f) => f.from < h && f.to > d) && n.ranges.push({
                    from: d,
                    to: h
                  });
                }
            }
            a = false;
          } else if (r && (o = $Ge(r.ranges, i.from, i.to)))
            a = o != 2;
          else if (!i.type.isAnonymous && (s = this.nest(i, this.input)) && (i.from < i.to || !s.overlay)) {
            i.tree || AGe(i);
            let c = e.findMounts(i.from, s.parser);
            if (typeof s.overlay == "function")
              n = new EGe(s.parser, s.overlay, c, this.inner.length, i.from, i.tree, n);
            else {
              let u = LU(this.ranges, s.overlay || (i.from < i.to ? [
                new Xo(i.from, i.to)
              ] : []));
              u.length && RU(u), (u.length || !s.overlay) && this.inner.push(new AU(s.parser, u.length ? s.parser.startParse(this.input, jU(c, u), u) : s.parser.startParse(""), s.overlay ? s.overlay.map((d) => new Xo(d.from - i.from, d.to - i.from)) : null, i.tree, u.length ? u[0].from : i.from)), s.overlay ? u.length && (r = {
                ranges: u,
                depth: 0,
                prev: r
              }) : a = false;
            }
          } else if (n && (l = n.predicate(i)) && (l === true && (l = new Xo(i.from, i.to)), l.from < l.to)) {
            let c = n.ranges.length - 1;
            c >= 0 && n.ranges[c].to == l.from ? n.ranges[c] = {
              from: n.ranges[c].from,
              to: l.to
            } : n.ranges.push(l);
          }
          if (a && i.firstChild())
            n && n.depth++, r && r.depth++;
          else
            for (; !i.nextSibling(); ) {
              if (!i.parent())
                break e;
              if (n && !--n.depth) {
                let c = LU(this.ranges, n.ranges);
                c.length && (RU(c), this.inner.splice(n.index, 0, new AU(n.parser, n.parser.startParse(this.input, jU(n.mounts, c), c), n.ranges.map((u) => new Xo(u.from - n.start, u.to - n.start)), n.target, c[0].from))), n = n.prev;
              }
              r && !--r.depth && (r = r.prev);
            }
        }
    }
  }
  function $Ge(t, e, n) {
    for (let r of t) {
      if (r.from >= n)
        break;
      if (r.to > e)
        return r.from <= e && r.to >= n ? 2 : 1;
    }
    return 0;
  }
  function MU(t, e, n, r, i, s) {
    if (e < n) {
      let o = t.buffer[e + 1];
      r.push(t.slice(e, n, o)), i.push(o - s);
    }
  }
  function AGe(t) {
    let { node: e } = t, n = [], r = e.context.buffer;
    do
      n.push(t.index), t.parent();
    while (!t.tree);
    let i = t.tree, s = i.children.indexOf(r), o = i.children[s], a = o.buffer, l = [
      s
    ];
    function c(u, d, h, f, y, g) {
      let O = n[g], S = [], w = [];
      MU(o, u, O, S, w, f);
      let x = a[O + 1], P = a[O + 2];
      l.push(S.length);
      let C = g ? c(O + 4, a[O + 3], o.set.types[a[O]], x, P - x, g - 1) : e.toTree();
      return S.push(C), w.push(x - f), MU(o, a[O + 3], d, S, w, f), new At(h, S, w, y);
    }
    i.children[s] = c(0, a.length, Tr.none, 0, o.length, n.length - 1);
    for (let u of l) {
      let d = t.tree.children[u], h = t.tree.positions[u];
      t.yield(new ia(d, h + t.from, u, t._tree));
    }
  }
  class DU {
    constructor(e, n) {
      this.offset = n, this.done = false, this.cursor = e.cursor(dn.IncludeAnonymous | dn.IgnoreMounts);
    }
    moveTo(e) {
      let { cursor: n } = this, r = e - this.offset;
      for (; !this.done && n.from < r; )
        n.to >= e && n.enter(r, 1, dn.IgnoreOverlays | dn.ExcludeBuffers) || n.next(false) || (this.done = true);
    }
    hasNode(e) {
      if (this.moveTo(e.from), !this.done && this.cursor.from + this.offset == e.from && this.cursor.tree)
        for (let n = this.cursor.tree; ; ) {
          if (n == e.tree)
            return true;
          if (n.children.length && n.positions[0] == 0 && n.children[0] instanceof At)
            n = n.children[0];
          else
            break;
        }
      return false;
    }
  }
  let RGe = class {
    constructor(e) {
      var n;
      if (this.fragments = e, this.curTo = 0, this.fragI = 0, e.length) {
        let r = this.curFrag = e[0];
        this.curTo = (n = r.tree.prop(YM)) !== null && n !== void 0 ? n : r.to, this.inner = new DU(r.tree, -r.offset);
      } else
        this.curFrag = this.inner = null;
    }
    hasNode(e) {
      for (; this.curFrag && e.from >= this.curTo; )
        this.nextFrag();
      return this.curFrag && this.curFrag.from <= e.from && this.curTo >= e.to && this.inner.hasNode(e);
    }
    nextFrag() {
      var e;
      if (this.fragI++, this.fragI == this.fragments.length)
        this.curFrag = this.inner = null;
      else {
        let n = this.curFrag = this.fragments[this.fragI];
        this.curTo = (e = n.tree.prop(YM)) !== null && e !== void 0 ? e : n.to, this.inner = new DU(n.tree, -n.offset);
      }
    }
    findMounts(e, n) {
      var r;
      let i = [];
      if (this.inner) {
        this.inner.cursor.moveTo(e, 1);
        for (let s = this.inner.cursor.node; s; s = s.parent) {
          let o = (r = s.tree) === null || r === void 0 ? void 0 : r.prop(ut.mounted);
          if (o && o.parser == n)
            for (let a = this.fragI; a < this.fragments.length; a++) {
              let l = this.fragments[a];
              if (l.from >= s.to)
                break;
              l.tree == this.curFrag.tree && i.push({
                frag: l,
                pos: s.from - l.offset,
                mount: o
              });
            }
        }
      }
      return i;
    }
  };
  function LU(t, e) {
    let n = null, r = e;
    for (let i = 1, s = 0; i < t.length; i++) {
      let o = t[i - 1].to, a = t[i].from;
      for (; s < r.length; s++) {
        let l = r[s];
        if (l.from >= a)
          break;
        l.to <= o || (n || (r = n = e.slice()), l.from < o ? (n[s] = new Xo(l.from, o), l.to > a && n.splice(s + 1, 0, new Xo(a, l.to))) : l.to > a ? n[s--] = new Xo(a, l.to) : n.splice(s--, 1));
      }
    }
    return r;
  }
  function MGe(t, e, n, r) {
    let i = 0, s = 0, o = false, a = false, l = -1e9, c = [];
    for (; ; ) {
      let u = i == t.length ? 1e9 : o ? t[i].to : t[i].from, d = s == e.length ? 1e9 : a ? e[s].to : e[s].from;
      if (o != a) {
        let h = Math.max(l, n), f = Math.min(u, d, r);
        h < f && c.push(new Xo(h, f));
      }
      if (l = Math.min(u, d), l == 1e9)
        break;
      u == l && (o ? (o = false, i++) : o = true), d == l && (a ? (a = false, s++) : a = true);
    }
    return c;
  }
  function jU(t, e) {
    let n = [];
    for (let { pos: r, mount: i, frag: s } of t) {
      let o = r + (i.overlay ? i.overlay[0].from : 0), a = o + i.tree.length, l = Math.max(s.from, o), c = Math.min(s.to, a);
      if (i.overlay) {
        let u = i.overlay.map((h) => new Xo(h.from + r, h.to + r)), d = MGe(e, u, l, c);
        for (let h = 0, f = l; ; h++) {
          let y = h == d.length, g = y ? c : d[h].from;
          if (g > f && n.push(new Bc(f, g, i.tree, -o, s.from >= f || s.openStart, s.to <= g || s.openEnd)), y)
            break;
          f = d[h].to;
        }
      } else
        n.push(new Bc(l, c, i.tree, -o, s.from >= o || s.openStart, s.to <= a || s.openEnd));
    }
    return n;
  }
  let DGe = 0;
  class Js {
    constructor(e, n, r, i) {
      this.name = e, this.set = n, this.base = r, this.modified = i, this.id = DGe++;
    }
    toString() {
      let { name: e } = this;
      for (let n of this.modified)
        n.name && (e = `${n.name}(${e})`);
      return e;
    }
    static define(e, n) {
      let r = typeof e == "string" ? e : "?";
      if (e instanceof Js && (n = e), n == null ? void 0 : n.base)
        throw new Error("Can not derive from a modified tag");
      let i = new Js(r, [], null, []);
      if (i.set.push(i), n)
        for (let s of n.set)
          i.set.push(s);
      return i;
    }
    static defineModifier(e) {
      let n = new pP(e);
      return (r) => r.modified.indexOf(n) > -1 ? r : pP.get(r.base || r, r.modified.concat(n).sort((i, s) => i.id - s.id));
    }
  }
  let LGe = 0;
  class pP {
    constructor(e) {
      this.name = e, this.instances = [], this.id = LGe++;
    }
    static get(e, n) {
      if (!n.length)
        return e;
      let r = n[0].instances.find((a) => a.base == e && jGe(n, a.modified));
      if (r)
        return r;
      let i = [], s = new Js(e.name, i, e, n);
      for (let a of n)
        a.instances.push(s);
      let o = NGe(n);
      for (let a of e.set)
        if (!a.modified.length)
          for (let l of o)
            i.push(pP.get(a, l));
      return s;
    }
  }
  function jGe(t, e) {
    return t.length == e.length && t.every((n, r) => n == e[r]);
  }
  function NGe(t) {
    let e = [
      []
    ];
    for (let n = 0; n < t.length; n++)
      for (let r = 0, i = e.length; r < i; r++)
        e.push(e[r].concat(t[n]));
    return e.sort((n, r) => r.length - n.length);
  }
  zm = function(t) {
    let e = /* @__PURE__ */ Object.create(null);
    for (let n in t) {
      let r = t[n];
      Array.isArray(r) || (r = [
        r
      ]);
      for (let i of n.split(" "))
        if (i) {
          let s = [], o = 2, a = i;
          for (let d = 0; ; ) {
            if (a == "..." && d > 0 && d + 3 == i.length) {
              o = 1;
              break;
            }
            let h = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);
            if (!h)
              throw new RangeError("Invalid path: " + i);
            if (s.push(h[0] == "*" ? "" : h[0][0] == '"' ? JSON.parse(h[0]) : h[0]), d += h[0].length, d == i.length)
              break;
            let f = i[d++];
            if (d == i.length && f == "!") {
              o = 0;
              break;
            }
            if (f != "/")
              throw new RangeError("Invalid path: " + i);
            a = i.slice(d);
          }
          let l = s.length - 1, c = s[l];
          if (!c)
            throw new RangeError("Invalid path: " + i);
          let u = new gP(r, o, l > 0 ? s.slice(0, l) : null);
          e[c] = u.sort(e[c]);
        }
    }
    return Noe.add(e);
  };
  const Noe = new ut();
  class gP {
    constructor(e, n, r, i) {
      this.tags = e, this.mode = n, this.context = r, this.next = i;
    }
    get opaque() {
      return this.mode == 0;
    }
    get inherit() {
      return this.mode == 1;
    }
    sort(e) {
      return !e || e.depth < this.depth ? (this.next = e, this) : (e.next = this.sort(e.next), e);
    }
    get depth() {
      return this.context ? this.context.length : 0;
    }
  }
  gP.empty = new gP([], 2, null);
  function Qoe(t, e) {
    let n = /* @__PURE__ */ Object.create(null);
    for (let s of t)
      if (!Array.isArray(s.tag))
        n[s.tag.id] = s.class;
      else
        for (let o of s.tag)
          n[o.id] = s.class;
    let { scope: r, all: i = null } = e || {};
    return {
      style: (s) => {
        let o = i;
        for (let a of s)
          for (let l of a.set) {
            let c = n[l.id];
            if (c) {
              o = o ? o + " " + c : c;
              break;
            }
          }
        return o;
      },
      scope: r
    };
  }
  function QGe(t, e) {
    let n = null;
    for (let r of t) {
      let i = r.style(e);
      i && (n = n ? n + " " + i : i);
    }
    return n;
  }
  function zGe(t, e, n, r = 0, i = t.length) {
    let s = new FGe(r, Array.isArray(e) ? e : [
      e
    ], n);
    s.highlightRange(t.cursor(), r, i, "", s.highlighters), s.flush(i);
  }
  class FGe {
    constructor(e, n, r) {
      this.at = e, this.highlighters = n, this.span = r, this.class = "";
    }
    startSpan(e, n) {
      n != this.class && (this.flush(e), e > this.at && (this.at = e), this.class = n);
    }
    flush(e) {
      e > this.at && this.class && this.span(this.at, e, this.class);
    }
    highlightRange(e, n, r, i, s) {
      let { type: o, from: a, to: l } = e;
      if (a >= r || l <= n)
        return;
      o.isTop && (s = this.highlighters.filter((f) => !f.scope || f.scope(o)));
      let c = i, u = BGe(e) || gP.empty, d = QGe(s, u.tags);
      if (d && (c && (c += " "), c += d, u.mode == 1 && (i += (i ? " " : "") + d)), this.startSpan(Math.max(n, a), c), u.opaque)
        return;
      let h = e.tree && e.tree.prop(ut.mounted);
      if (h && h.overlay) {
        let f = e.node.enter(h.overlay[0].from + a, 1), y = this.highlighters.filter((O) => !O.scope || O.scope(h.tree.type)), g = e.firstChild();
        for (let O = 0, S = a; ; O++) {
          let w = O < h.overlay.length ? h.overlay[O] : null, x = w ? w.from + a : l, P = Math.max(n, S), C = Math.min(r, x);
          if (P < C && g)
            for (; e.from < C && (this.highlightRange(e, P, C, i, s), this.startSpan(Math.min(C, e.to), c), !(e.to >= x || !e.nextSibling())); )
              ;
          if (!w || x > r)
            break;
          S = w.to + a, S > n && (this.highlightRange(f.cursor(), Math.max(n, w.from + a), Math.min(r, S), "", y), this.startSpan(Math.min(r, S), c));
        }
        g && e.parent();
      } else if (e.firstChild()) {
        h && (i = "");
        do
          if (!(e.to <= n)) {
            if (e.from >= r)
              break;
            this.highlightRange(e, n, r, i, s), this.startSpan(Math.min(r, e.to), c);
          }
        while (e.nextSibling());
        e.parent();
      }
    }
  }
  function BGe(t) {
    let e = t.type.prop(Noe);
    for (; e && e.context && !t.matchContext(e.context); )
      e = e.next;
    return e || null;
  }
  let xe, ux, ju, NU, QU, Nu, dx, i$, hl, fh, ll, cl, GM, s0, hx;
  xe = Js.define;
  ux = xe();
  ju = xe();
  NU = xe(ju);
  QU = xe(ju);
  Nu = xe();
  dx = xe(Nu);
  i$ = xe(Nu);
  hl = xe();
  fh = xe(hl);
  ll = xe();
  cl = xe();
  GM = xe();
  s0 = xe(GM);
  hx = xe();
  V = {
    comment: ux,
    lineComment: xe(ux),
    blockComment: xe(ux),
    docComment: xe(ux),
    name: ju,
    variableName: xe(ju),
    typeName: NU,
    tagName: xe(NU),
    propertyName: QU,
    attributeName: xe(QU),
    className: xe(ju),
    labelName: xe(ju),
    namespace: xe(ju),
    macroName: xe(ju),
    literal: Nu,
    string: dx,
    docString: xe(dx),
    character: xe(dx),
    attributeValue: xe(dx),
    number: i$,
    integer: xe(i$),
    float: xe(i$),
    bool: xe(Nu),
    regexp: xe(Nu),
    escape: xe(Nu),
    color: xe(Nu),
    url: xe(Nu),
    keyword: ll,
    self: xe(ll),
    null: xe(ll),
    atom: xe(ll),
    unit: xe(ll),
    modifier: xe(ll),
    operatorKeyword: xe(ll),
    controlKeyword: xe(ll),
    definitionKeyword: xe(ll),
    moduleKeyword: xe(ll),
    operator: cl,
    derefOperator: xe(cl),
    arithmeticOperator: xe(cl),
    logicOperator: xe(cl),
    bitwiseOperator: xe(cl),
    compareOperator: xe(cl),
    updateOperator: xe(cl),
    definitionOperator: xe(cl),
    typeOperator: xe(cl),
    controlOperator: xe(cl),
    punctuation: GM,
    separator: xe(GM),
    bracket: s0,
    angleBracket: xe(s0),
    squareBracket: xe(s0),
    paren: xe(s0),
    brace: xe(s0),
    content: hl,
    heading: fh,
    heading1: xe(fh),
    heading2: xe(fh),
    heading3: xe(fh),
    heading4: xe(fh),
    heading5: xe(fh),
    heading6: xe(fh),
    contentSeparator: xe(hl),
    list: xe(hl),
    quote: xe(hl),
    emphasis: xe(hl),
    strong: xe(hl),
    link: xe(hl),
    monospace: xe(hl),
    strikethrough: xe(hl),
    inserted: xe(),
    deleted: xe(),
    changed: xe(),
    invalid: xe(),
    meta: hx,
    documentMeta: xe(hx),
    annotation: xe(hx),
    processingInstruction: xe(hx),
    definition: Js.defineModifier("definition"),
    constant: Js.defineModifier("constant"),
    function: Js.defineModifier("function"),
    standard: Js.defineModifier("standard"),
    local: Js.defineModifier("local"),
    special: Js.defineModifier("special")
  };
  for (let t in V) {
    let e = V[t];
    e instanceof Js && (e.name = t);
  }
  Qoe([
    {
      tag: V.link,
      class: "tok-link"
    },
    {
      tag: V.heading,
      class: "tok-heading"
    },
    {
      tag: V.emphasis,
      class: "tok-emphasis"
    },
    {
      tag: V.strong,
      class: "tok-strong"
    },
    {
      tag: V.keyword,
      class: "tok-keyword"
    },
    {
      tag: V.atom,
      class: "tok-atom"
    },
    {
      tag: V.bool,
      class: "tok-bool"
    },
    {
      tag: V.url,
      class: "tok-url"
    },
    {
      tag: V.labelName,
      class: "tok-labelName"
    },
    {
      tag: V.inserted,
      class: "tok-inserted"
    },
    {
      tag: V.deleted,
      class: "tok-deleted"
    },
    {
      tag: V.literal,
      class: "tok-literal"
    },
    {
      tag: V.string,
      class: "tok-string"
    },
    {
      tag: V.number,
      class: "tok-number"
    },
    {
      tag: [
        V.regexp,
        V.escape,
        V.special(V.string)
      ],
      class: "tok-string2"
    },
    {
      tag: V.variableName,
      class: "tok-variableName"
    },
    {
      tag: V.local(V.variableName),
      class: "tok-variableName tok-local"
    },
    {
      tag: V.definition(V.variableName),
      class: "tok-variableName tok-definition"
    },
    {
      tag: V.special(V.variableName),
      class: "tok-variableName2"
    },
    {
      tag: V.definition(V.propertyName),
      class: "tok-propertyName tok-definition"
    },
    {
      tag: V.typeName,
      class: "tok-typeName"
    },
    {
      tag: V.namespace,
      class: "tok-namespace"
    },
    {
      tag: V.className,
      class: "tok-className"
    },
    {
      tag: V.macroName,
      class: "tok-macroName"
    },
    {
      tag: V.propertyName,
      class: "tok-propertyName"
    },
    {
      tag: V.operator,
      class: "tok-operator"
    },
    {
      tag: V.comment,
      class: "tok-comment"
    },
    {
      tag: V.meta,
      class: "tok-meta"
    },
    {
      tag: V.invalid,
      class: "tok-invalid"
    },
    {
      tag: V.punctuation,
      class: "tok-punctuation"
    }
  ]);
  var s$;
  const nd = new ut();
  function A2(t) {
    return Ge.define({
      combine: t ? (e) => e.concat(t) : void 0
    });
  }
  const Rj = new ut();
  class gs {
    constructor(e, n, r = [], i = "") {
      this.data = e, this.name = i, lr.prototype.hasOwnProperty("tree") || Object.defineProperty(lr.prototype, "tree", {
        get() {
          return Un(this);
        }
      }), this.parser = n, this.extension = [
        lm.of(this),
        lr.languageData.of((s, o, a) => {
          let l = zU(s, o, a), c = l.type.prop(nd);
          if (!c)
            return [];
          let u = s.facet(c), d = l.type.prop(Rj);
          if (d) {
            let h = l.resolve(o - l.from, a);
            for (let f of d)
              if (f.test(h, s)) {
                let y = s.facet(f.facet);
                return f.type == "replace" ? y : y.concat(u);
              }
          }
          return u;
        })
      ].concat(r);
    }
    isActiveAt(e, n, r = -1) {
      return zU(e, n, r).type.prop(nd) == this.data;
    }
    findRegions(e) {
      let n = e.facet(lm);
      if ((n == null ? void 0 : n.data) == this.data)
        return [
          {
            from: 0,
            to: e.doc.length
          }
        ];
      if (!n || !n.allowsNesting)
        return [];
      let r = [], i = (s, o) => {
        if (s.prop(nd) == this.data) {
          r.push({
            from: o,
            to: o + s.length
          });
          return;
        }
        let a = s.prop(ut.mounted);
        if (a) {
          if (a.tree.prop(nd) == this.data) {
            if (a.overlay)
              for (let l of a.overlay)
                r.push({
                  from: l.from + o,
                  to: l.to + o
                });
            else
              r.push({
                from: o,
                to: o + s.length
              });
            return;
          } else if (a.overlay) {
            let l = r.length;
            if (i(a.tree, a.overlay[0].from + o), r.length > l)
              return;
          }
        }
        for (let l = 0; l < s.children.length; l++) {
          let c = s.children[l];
          c instanceof At && i(c, s.positions[l] + o);
        }
      };
      return i(Un(e), 0), r;
    }
    get allowsNesting() {
      return true;
    }
  }
  gs.setState = kn.define();
  function zU(t, e, n) {
    let r = t.facet(lm), i = Un(t).topNode;
    if (!r || r.allowsNesting)
      for (let s = i; s; s = s.enter(e, n, dn.ExcludeBuffers))
        s.type.isTop && (i = s);
    return i;
  }
  om = class extends gs {
    constructor(e, n, r) {
      super(e, n, [], r), this.parser = n;
    }
    static define(e) {
      let n = A2(e.languageData);
      return new om(n, e.parser.configure({
        props: [
          nd.add((r) => r.isTop ? n : void 0)
        ]
      }), e.name);
    }
    configure(e, n) {
      return new om(this.data, this.parser.configure(e), n || this.name);
    }
    get allowsNesting() {
      return this.parser.hasWrappers();
    }
  };
  Un = function(t) {
    let e = t.field(gs.state, false);
    return e ? e.tree : At.empty;
  };
  function UGe(t, e, n = 50) {
    var r;
    let i = (r = t.field(gs.state, false)) === null || r === void 0 ? void 0 : r.context;
    if (!i)
      return null;
    let s = i.viewport;
    i.updateViewport({
      from: 0,
      to: e
    });
    let o = i.isDone(e) || i.work(n, e) ? i.tree : null;
    return i.updateViewport(s), o;
  }
  class VGe {
    constructor(e) {
      this.doc = e, this.cursorPos = 0, this.string = "", this.cursor = e.iter();
    }
    get length() {
      return this.doc.length;
    }
    syncTo(e) {
      return this.string = this.cursor.next(e - this.cursorPos).value, this.cursorPos = e + this.string.length, this.cursorPos - this.string.length;
    }
    chunk(e) {
      return this.syncTo(e), this.string;
    }
    get lineChunks() {
      return true;
    }
    read(e, n) {
      let r = this.cursorPos - this.string.length;
      return e < r || n >= this.cursorPos ? this.doc.sliceString(e, n) : this.string.slice(e - r, n - r);
    }
  }
  let o0 = null;
  class pf {
    constructor(e, n, r = [], i, s, o, a, l) {
      this.parser = e, this.state = n, this.fragments = r, this.tree = i, this.treeLen = s, this.viewport = o, this.skipped = a, this.scheduleOn = l, this.parse = null, this.tempSkipped = [];
    }
    static create(e, n, r) {
      return new pf(e, n, [], At.empty, 0, r, [], null);
    }
    startParse() {
      return this.parser.startParse(new VGe(this.state.doc), this.fragments);
    }
    work(e, n) {
      return n != null && n >= this.state.doc.length && (n = void 0), this.tree != At.empty && this.isDone(n ?? this.state.doc.length) ? (this.takeTree(), true) : this.withContext(() => {
        var r;
        if (typeof e == "number") {
          let i = Date.now() + e;
          e = () => Date.now() > i;
        }
        for (this.parse || (this.parse = this.startParse()), n != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > n) && n < this.state.doc.length && this.parse.stopAt(n); ; ) {
          let i = this.parse.advance();
          if (i)
            if (this.fragments = this.withoutTempSkipped(Bc.addTree(i, this.fragments, this.parse.stoppedAt != null)), this.treeLen = (r = this.parse.stoppedAt) !== null && r !== void 0 ? r : this.state.doc.length, this.tree = i, this.parse = null, this.treeLen < (n ?? this.state.doc.length))
              this.parse = this.startParse();
            else
              return true;
          if (e())
            return false;
        }
      });
    }
    takeTree() {
      let e, n;
      this.parse && (e = this.parse.parsedPos) >= this.treeLen && ((this.parse.stoppedAt == null || this.parse.stoppedAt > e) && this.parse.stopAt(e), this.withContext(() => {
        for (; !(n = this.parse.advance()); )
          ;
      }), this.treeLen = e, this.tree = n, this.fragments = this.withoutTempSkipped(Bc.addTree(this.tree, this.fragments, true)), this.parse = null);
    }
    withContext(e) {
      let n = o0;
      o0 = this;
      try {
        return e();
      } finally {
        o0 = n;
      }
    }
    withoutTempSkipped(e) {
      for (let n; n = this.tempSkipped.pop(); )
        e = FU(e, n.from, n.to);
      return e;
    }
    changes(e, n) {
      let { fragments: r, tree: i, treeLen: s, viewport: o, skipped: a } = this;
      if (this.takeTree(), !e.empty) {
        let l = [];
        if (e.iterChangedRanges((c, u, d, h) => l.push({
          fromA: c,
          toA: u,
          fromB: d,
          toB: h
        })), r = Bc.applyChanges(r, l), i = At.empty, s = 0, o = {
          from: e.mapPos(o.from, -1),
          to: e.mapPos(o.to, 1)
        }, this.skipped.length) {
          a = [];
          for (let c of this.skipped) {
            let u = e.mapPos(c.from, 1), d = e.mapPos(c.to, -1);
            u < d && a.push({
              from: u,
              to: d
            });
          }
        }
      }
      return new pf(this.parser, n, r, i, s, o, a, this.scheduleOn);
    }
    updateViewport(e) {
      if (this.viewport.from == e.from && this.viewport.to == e.to)
        return false;
      this.viewport = e;
      let n = this.skipped.length;
      for (let r = 0; r < this.skipped.length; r++) {
        let { from: i, to: s } = this.skipped[r];
        i < e.to && s > e.from && (this.fragments = FU(this.fragments, i, s), this.skipped.splice(r--, 1));
      }
      return this.skipped.length >= n ? false : (this.reset(), true);
    }
    reset() {
      this.parse && (this.takeTree(), this.parse = null);
    }
    skipUntilInView(e, n) {
      this.skipped.push({
        from: e,
        to: n
      });
    }
    static getSkippingParser(e) {
      return new class extends $2 {
        createParse(n, r, i) {
          let s = i[0].from, o = i[i.length - 1].to;
          return {
            parsedPos: s,
            advance() {
              let l = o0;
              if (l) {
                for (let c of i)
                  l.tempSkipped.push(c);
                e && (l.scheduleOn = l.scheduleOn ? Promise.all([
                  l.scheduleOn,
                  e
                ]) : e);
              }
              return this.parsedPos = o, new At(Tr.none, [], [], o - s);
            },
            stoppedAt: null,
            stopAt() {
            }
          };
        }
      }();
    }
    isDone(e) {
      e = Math.min(e, this.state.doc.length);
      let n = this.fragments;
      return this.treeLen >= e && n.length && n[0].from == 0 && n[0].to >= e;
    }
    static get() {
      return o0;
    }
  }
  function FU(t, e, n) {
    return Bc.applyChanges(t, [
      {
        fromA: e,
        toA: n,
        fromB: e,
        toB: n
      }
    ]);
  }
  class am {
    constructor(e) {
      this.context = e, this.tree = e.tree;
    }
    apply(e) {
      if (!e.docChanged && this.tree == this.context.tree)
        return this;
      let n = this.context.changes(e.changes, e.state), r = this.context.treeLen == e.startState.doc.length ? void 0 : Math.max(e.changes.mapPos(this.context.treeLen), n.viewport.to);
      return n.work(20, r) || n.takeTree(), new am(n);
    }
    static init(e) {
      let n = Math.min(3e3, e.doc.length), r = pf.create(e.facet(lm).parser, e, {
        from: 0,
        to: n
      });
      return r.work(20, n) || r.takeTree(), new am(r);
    }
  }
  gs.state = Xd.define({
    create: am.init,
    update(t, e) {
      for (let n of e.effects)
        if (n.is(gs.setState))
          return n.value;
      return e.startState.facet(lm) != e.state.facet(lm) ? am.init(e.state) : t.apply(e);
    }
  });
  let zoe = (t) => {
    let e = setTimeout(() => t(), 500);
    return () => clearTimeout(e);
  };
  typeof requestIdleCallback < "u" && (zoe = (t) => {
    let e = -1, n = setTimeout(() => {
      e = requestIdleCallback(t, {
        timeout: 500 - 100
      });
    }, 100);
    return () => e < 0 ? clearTimeout(n) : cancelIdleCallback(e);
  });
  const o$ = typeof navigator < "u" && (!((s$ = navigator.scheduling) === null || s$ === void 0) && s$.isInputPending) ? () => navigator.scheduling.isInputPending() : null, XGe = ur.fromClass(class {
    constructor(e) {
      this.view = e, this.working = null, this.workScheduled = 0, this.chunkEnd = -1, this.chunkBudget = -1, this.work = this.work.bind(this), this.scheduleWork();
    }
    update(e) {
      let n = this.view.state.field(gs.state).context;
      (n.updateViewport(e.view.viewport) || this.view.viewport.to > n.treeLen) && this.scheduleWork(), (e.docChanged || e.selectionSet) && (this.view.hasFocus && (this.chunkBudget += 50), this.scheduleWork()), this.checkAsyncSchedule(n);
    }
    scheduleWork() {
      if (this.working)
        return;
      let { state: e } = this.view, n = e.field(gs.state);
      (n.tree != n.context.tree || !n.context.isDone(e.doc.length)) && (this.working = zoe(this.work));
    }
    work(e) {
      this.working = null;
      let n = Date.now();
      if (this.chunkEnd < n && (this.chunkEnd < 0 || this.view.hasFocus) && (this.chunkEnd = n + 3e4, this.chunkBudget = 3e3), this.chunkBudget <= 0)
        return;
      let { state: r, viewport: { to: i } } = this.view, s = r.field(gs.state);
      if (s.tree == s.context.tree && s.context.isDone(i + 1e5))
        return;
      let o = Date.now() + Math.min(this.chunkBudget, 100, e && !o$ ? Math.max(25, e.timeRemaining() - 5) : 1e9), a = s.context.treeLen < i && r.doc.length > i + 1e3, l = s.context.work(() => o$ && o$() || Date.now() > o, i + (a ? 0 : 1e5));
      this.chunkBudget -= Date.now() - n, (l || this.chunkBudget <= 0) && (s.context.takeTree(), this.view.dispatch({
        effects: gs.setState.of(new am(s.context))
      })), this.chunkBudget > 0 && !(l && !a) && this.scheduleWork(), this.checkAsyncSchedule(s.context);
    }
    checkAsyncSchedule(e) {
      e.scheduleOn && (this.workScheduled++, e.scheduleOn.then(() => this.scheduleWork()).catch((n) => Vo(this.view.state, n)).then(() => this.workScheduled--), e.scheduleOn = null);
    }
    destroy() {
      this.working && this.working();
    }
    isWorking() {
      return !!(this.working || this.workScheduled > 0);
    }
  }, {
    eventHandlers: {
      focus() {
        this.scheduleWork();
      }
    }
  }), lm = Ge.define({
    combine(t) {
      return t.length ? t[0] : null;
    },
    enables: (t) => [
      gs.state,
      XGe,
      Re.contentAttributes.compute([
        t
      ], (e) => {
        let n = e.facet(t);
        return n && n.name ? {
          "data-language": n.name
        } : {};
      })
    ]
  });
  cm = class {
    constructor(e, n = []) {
      this.language = e, this.support = n, this.extension = [
        e,
        n
      ];
    }
  };
  class ie {
    constructor(e, n, r, i, s, o = void 0) {
      this.name = e, this.alias = n, this.extensions = r, this.filename = i, this.loadFunc = s, this.support = o, this.loading = null;
    }
    load() {
      return this.loading || (this.loading = this.loadFunc().then((e) => this.support = e, (e) => {
        throw this.loading = null, e;
      }));
    }
    static of(e) {
      let { load: n, support: r } = e;
      if (!n) {
        if (!r)
          throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");
        n = () => Promise.resolve(r);
      }
      return new ie(e.name, (e.alias || []).concat(e.name).map((i) => i.toLowerCase()), e.extensions || [], e.filename, n, r);
    }
    static matchFilename(e, n) {
      for (let i of e)
        if (i.filename && i.filename.test(n))
          return i;
      let r = /\.([^.]+)$/.exec(n);
      if (r) {
        for (let i of e)
          if (i.extensions.indexOf(r[1]) > -1)
            return i;
      }
      return null;
    }
    static matchLanguageName(e, n, r = true) {
      n = n.toLowerCase();
      for (let i of e)
        if (i.alias.some((s) => s == n))
          return i;
      if (r)
        for (let i of e)
          for (let s of i.alias) {
            let o = n.indexOf(s);
            if (o > -1 && (s.length > 2 || !/\w/.test(n[o - 1]) && !/\w/.test(n[o + s.length])))
              return i;
          }
      return null;
    }
  }
  const WGe = Ge.define(), Fm = Ge.define({
    combine: (t) => {
      if (!t.length)
        return "  ";
      let e = t[0];
      if (!e || /\S/.test(e) || Array.from(e).some((n) => n != e[0]))
        throw new Error("Invalid indent unit: " + JSON.stringify(t[0]));
      return e;
    }
  });
  function gf(t) {
    let e = t.facet(Fm);
    return e.charCodeAt(0) == 9 ? t.tabSize * e.length : e.length;
  }
  function mP(t, e) {
    let n = "", r = t.tabSize, i = t.facet(Fm)[0];
    if (i == "	") {
      for (; e >= r; )
        n += "	", e -= r;
      i = " ";
    }
    for (let s = 0; s < e; s++)
      n += i;
    return n;
  }
  function Foe(t, e) {
    t instanceof lr && (t = new Mj(t));
    for (let r of t.state.facet(WGe)) {
      let i = r(t, e);
      if (i !== void 0)
        return i;
    }
    let n = Un(t.state);
    return n.length >= e ? ZGe(t, n, e) : null;
  }
  class Mj {
    constructor(e, n = {}) {
      this.state = e, this.options = n, this.unit = gf(e);
    }
    lineAt(e, n = 1) {
      let r = this.state.doc.lineAt(e), { simulateBreak: i, simulateDoubleBreak: s } = this.options;
      return i != null && i >= r.from && i <= r.to ? s && i == e ? {
        text: "",
        from: e
      } : (n < 0 ? i < e : i <= e) ? {
        text: r.text.slice(i - r.from),
        from: i
      } : {
        text: r.text.slice(0, i - r.from),
        from: r.from
      } : r;
    }
    textAfterPos(e, n = 1) {
      if (this.options.simulateDoubleBreak && e == this.options.simulateBreak)
        return "";
      let { text: r, from: i } = this.lineAt(e, n);
      return r.slice(e - i, Math.min(r.length, e + 100 - i));
    }
    column(e, n = 1) {
      let { text: r, from: i } = this.lineAt(e, n), s = this.countColumn(r, e - i), o = this.options.overrideIndentation ? this.options.overrideIndentation(i) : -1;
      return o > -1 && (s += o - this.countColumn(r, r.search(/\S|$/))), s;
    }
    countColumn(e, n = e.length) {
      return em(e, this.state.tabSize, n);
    }
    lineIndent(e, n = 1) {
      let { text: r, from: i } = this.lineAt(e, n), s = this.options.overrideIndentation;
      if (s) {
        let o = s(i);
        if (o > -1)
          return o;
      }
      return this.countColumn(r, r.search(/\S|$/));
    }
    get simulatedBreak() {
      return this.options.simulateBreak || null;
    }
  }
  Bm = new ut();
  function ZGe(t, e, n) {
    let r = e.resolveStack(n), i = e.resolveInner(n, -1).resolve(n, 0).enterUnfinishedNodesBefore(n);
    if (i != r.node) {
      let s = [];
      for (let o = i; o && !(o.from < r.node.from || o.to > r.node.to || o.from == r.node.from && o.type == r.node.type); o = o.parent)
        s.push(o);
      for (let o = s.length - 1; o >= 0; o--)
        r = {
          node: s[o],
          next: r
        };
    }
    return Boe(r, t, n);
  }
  function Boe(t, e, n) {
    for (let r = t; r; r = r.next) {
      let i = YGe(r.node);
      if (i)
        return i(Dj.create(e, n, r));
    }
    return 0;
  }
  function HGe(t) {
    return t.pos == t.options.simulateBreak && t.options.simulateDoubleBreak;
  }
  function YGe(t) {
    let e = t.type.prop(Bm);
    if (e)
      return e;
    let n = t.firstChild, r;
    if (n && (r = n.type.prop(ut.closedBy))) {
      let i = t.lastChild, s = i && r.indexOf(i.name) > -1;
      return (o) => Uoe(o, true, 1, void 0, s && !HGe(o) ? i.from : void 0);
    }
    return t.parent == null ? GGe : null;
  }
  function GGe() {
    return 0;
  }
  class Dj extends Mj {
    constructor(e, n, r) {
      super(e.state, e.options), this.base = e, this.pos = n, this.context = r;
    }
    get node() {
      return this.context.node;
    }
    static create(e, n, r) {
      return new Dj(e, n, r);
    }
    get textAfter() {
      return this.textAfterPos(this.pos);
    }
    get baseIndent() {
      return this.baseIndentFor(this.node);
    }
    baseIndentFor(e) {
      let n = this.state.doc.lineAt(e.from);
      for (; ; ) {
        let r = e.resolve(n.from);
        for (; r.parent && r.parent.from == r.from; )
          r = r.parent;
        if (qGe(r, e))
          break;
        n = this.state.doc.lineAt(r.from);
      }
      return this.lineIndent(n.from);
    }
    continue() {
      return Boe(this.context.next, this.base, this.pos);
    }
  }
  function qGe(t, e) {
    for (let n = e; n; n = n.parent)
      if (t == n)
        return true;
    return false;
  }
  function KGe(t) {
    let e = t.node, n = e.childAfter(e.from), r = e.lastChild;
    if (!n)
      return null;
    let i = t.options.simulateBreak, s = t.state.doc.lineAt(n.from), o = i == null || i <= s.from ? s.to : Math.min(s.to, i);
    for (let a = n.to; ; ) {
      let l = e.childAfter(a);
      if (!l || l == r)
        return null;
      if (!l.type.isSkipped) {
        if (l.from >= o)
          return null;
        let c = /^ */.exec(s.text.slice(n.to - s.from))[0].length;
        return {
          from: n.from,
          to: n.to + c
        };
      }
      a = l.to;
    }
  }
  JGe = function({ closing: t, align: e = true, units: n = 1 }) {
    return (r) => Uoe(r, e, n, t);
  };
  function Uoe(t, e, n, r, i) {
    let s = t.textAfter, o = s.match(/^\s*/)[0].length, a = r && s.slice(o, o + r.length) == r || i == t.pos + o, l = e ? KGe(t) : null;
    return l ? a ? t.column(l.from) : t.column(l.to) : t.baseIndent + (a ? 0 : t.unit * n);
  }
  eqe = (t) => t.baseIndent;
  yb = function({ except: t, units: e = 1 } = {}) {
    return (n) => {
      let r = t && t.test(n.textAfter);
      return n.baseIndent + (r ? 0 : e * n.unit);
    };
  };
  const tqe = 200;
  function nqe() {
    return lr.transactionFilter.of((t) => {
      if (!t.docChanged || !t.isUserEvent("input.type") && !t.isUserEvent("input.complete"))
        return t;
      let e = t.startState.languageDataAt("indentOnInput", t.startState.selection.main.head);
      if (!e.length)
        return t;
      let n = t.newDoc, { head: r } = t.newSelection.main, i = n.lineAt(r);
      if (r > i.from + tqe)
        return t;
      let s = n.sliceString(i.from, r);
      if (!e.some((c) => c.test(s)))
        return t;
      let { state: o } = t, a = -1, l = [];
      for (let { head: c } of o.selection.ranges) {
        let u = o.doc.lineAt(c);
        if (u.from == a)
          continue;
        a = u.from;
        let d = Foe(o, u.from);
        if (d == null)
          continue;
        let h = /^\s*/.exec(u.text)[0], f = mP(o, d);
        h != f && l.push({
          from: u.from,
          to: u.from + h.length,
          insert: f
        });
      }
      return l.length ? [
        t,
        {
          changes: l,
          sequential: true
        }
      ] : t;
    });
  }
  let Voe;
  Voe = Ge.define();
  Um = new ut();
  Xoe = function(t) {
    let e = t.firstChild, n = t.lastChild;
    return e && e.to < n.from ? {
      from: e.to,
      to: n.type.isError ? t.to : n.from
    } : null;
  };
  function rqe(t, e, n) {
    let r = Un(t);
    if (r.length < n)
      return null;
    let i = r.resolveStack(n, 1), s = null;
    for (let o = i; o; o = o.next) {
      let a = o.node;
      if (a.to <= n || a.from > n)
        continue;
      if (s && a.from < e)
        break;
      let l = a.type.prop(Um);
      if (l && (a.to < r.length - 50 || r.length == t.doc.length || !iqe(a))) {
        let c = l(a, t);
        c && c.from <= n && c.from >= e && c.to > n && (s = c);
      }
    }
    return s;
  }
  function iqe(t) {
    let e = t.lastChild;
    return e && e.to == t.to && e.type.isError;
  }
  function Woe(t, e, n) {
    for (let r of t.facet(Voe)) {
      let i = r(t, e, n);
      if (i)
        return i;
    }
    return rqe(t, e, n);
  }
  function Zoe(t, e) {
    let n = e.mapPos(t.from, 1), r = e.mapPos(t.to, -1);
    return n >= r ? void 0 : {
      from: n,
      to: r
    };
  }
  const Lj = kn.define({
    map: Zoe
  }), R2 = kn.define({
    map: Zoe
  });
  function Hoe(t) {
    let e = [];
    for (let { head: n } of t.state.selection.ranges)
      e.some((r) => r.from <= n && r.to >= n) || e.push(t.lineBlockAt(n));
    return e;
  }
  const CS = Xd.define({
    create() {
      return Qe.none;
    },
    update(t, e) {
      e.isUserEvent("delete") && e.changes.iterChangedRanges((n, r) => t = BU(t, n, r)), t = t.map(e.changes);
      for (let n of e.effects)
        if (n.is(Lj) && !sqe(t, n.value.from, n.value.to)) {
          let { preparePlaceholder: r } = e.state.facet(jj), i = r ? Qe.replace({
            widget: new fqe(r(e.state, n.value))
          }) : UU;
          t = t.update({
            add: [
              i.range(n.value.from, n.value.to)
            ]
          });
        } else
          n.is(R2) && (t = t.update({
            filter: (r, i) => n.value.from != r || n.value.to != i,
            filterFrom: n.value.from,
            filterTo: n.value.to
          }));
      return e.selection && (t = BU(t, e.selection.main.head)), t;
    },
    provide: (t) => Re.decorations.from(t),
    toJSON(t, e) {
      let n = [];
      return t.between(0, e.doc.length, (r, i) => {
        n.push(r, i);
      }), n;
    },
    fromJSON(t) {
      if (!Array.isArray(t) || t.length % 2)
        throw new RangeError("Invalid JSON for fold state");
      let e = [];
      for (let n = 0; n < t.length; ) {
        let r = t[n++], i = t[n++];
        if (typeof r != "number" || typeof i != "number")
          throw new RangeError("Invalid JSON for fold state");
        e.push(UU.range(r, i));
      }
      return Qe.set(e, true);
    }
  });
  function BU(t, e, n = e) {
    let r = false;
    return t.between(e, n, (i, s) => {
      i < n && s > e && (r = true);
    }), r ? t.update({
      filterFrom: e,
      filterTo: n,
      filter: (i, s) => i >= n || s <= e
    }) : t;
  }
  function Yoe(t, e, n) {
    var r;
    let i = null;
    return (r = t.field(CS, false)) === null || r === void 0 || r.between(e, n, (s, o) => {
      (!i || i.from > s) && (i = {
        from: s,
        to: o
      });
    }), i;
  }
  function sqe(t, e, n) {
    let r = false;
    return t.between(e, e, (i, s) => {
      i == e && s == n && (r = true);
    }), r;
  }
  function Goe(t, e) {
    return t.field(CS, false) ? e : e.concat(kn.appendConfig.of(hqe()));
  }
  const oqe = (t) => {
    for (let e of Hoe(t)) {
      let n = Woe(t.state, e.from, e.to);
      if (n)
        return t.dispatch({
          effects: Goe(t.state, [
            Lj.of(n),
            qoe(t, n)
          ])
        }), true;
    }
    return false;
  }, aqe = (t) => {
    if (!t.state.field(CS, false))
      return false;
    let e = [];
    for (let n of Hoe(t)) {
      let r = Yoe(t.state, n.from, n.to);
      r && e.push(R2.of(r), qoe(t, r, false));
    }
    return e.length && t.dispatch({
      effects: e
    }), e.length > 0;
  };
  function qoe(t, e, n = true) {
    let r = t.state.doc.lineAt(e.from).number, i = t.state.doc.lineAt(e.to).number;
    return Re.announce.of(`${t.state.phrase(n ? "Folded lines" : "Unfolded lines")} ${r} ${t.state.phrase("to")} ${i}.`);
  }
  const lqe = (t) => {
    let { state: e } = t, n = [];
    for (let r = 0; r < e.doc.length; ) {
      let i = t.lineBlockAt(r), s = Woe(e, i.from, i.to);
      s && n.push(Lj.of(s)), r = (s ? t.lineBlockAt(s.to) : i).to + 1;
    }
    return n.length && t.dispatch({
      effects: Goe(t.state, n)
    }), !!n.length;
  }, cqe = (t) => {
    let e = t.state.field(CS, false);
    if (!e || !e.size)
      return false;
    let n = [];
    return e.between(0, t.state.doc.length, (r, i) => {
      n.push(R2.of({
        from: r,
        to: i
      }));
    }), t.dispatch({
      effects: n
    }), true;
  }, uqe = [
    {
      key: "Ctrl-Shift-[",
      mac: "Cmd-Alt-[",
      run: oqe
    },
    {
      key: "Ctrl-Shift-]",
      mac: "Cmd-Alt-]",
      run: aqe
    },
    {
      key: "Ctrl-Alt-[",
      run: lqe
    },
    {
      key: "Ctrl-Alt-]",
      run: cqe
    }
  ], dqe = {
    placeholderDOM: null,
    preparePlaceholder: null,
    placeholderText: "\u2026"
  }, jj = Ge.define({
    combine(t) {
      return kHe(t, dqe);
    }
  });
  function hqe(t) {
    let e = [
      CS,
      pqe
    ];
    return t && e.push(jj.of(t)), e;
  }
  function Koe(t, e) {
    let { state: n } = t, r = n.facet(jj), i = (o) => {
      let a = t.lineBlockAt(t.posAtDOM(o.target)), l = Yoe(t.state, a.from, a.to);
      l && t.dispatch({
        effects: R2.of(l)
      }), o.preventDefault();
    };
    if (r.placeholderDOM)
      return r.placeholderDOM(t, i, e);
    let s = document.createElement("span");
    return s.textContent = r.placeholderText, s.setAttribute("aria-label", n.phrase("folded code")), s.title = n.phrase("unfold"), s.className = "cm-foldPlaceholder", s.onclick = i, s;
  }
  const UU = Qe.replace({
    widget: new class extends Yl {
      toDOM(t) {
        return Koe(t, null);
      }
    }()
  });
  class fqe extends Yl {
    constructor(e) {
      super(), this.value = e;
    }
    eq(e) {
      return this.value == e.value;
    }
    toDOM(e) {
      return Koe(e, this.value);
    }
  }
  const pqe = Re.baseTheme({
    ".cm-foldPlaceholder": {
      backgroundColor: "#eee",
      border: "1px solid #ddd",
      color: "#888",
      borderRadius: ".2em",
      margin: "0 1px",
      padding: "0 1px",
      cursor: "pointer"
    },
    ".cm-foldGutter span": {
      padding: "0 1px",
      cursor: "pointer"
    }
  });
  class _S {
    constructor(e, n) {
      this.specs = e;
      let r;
      function i(a) {
        let l = Ed.newName();
        return (r || (r = /* @__PURE__ */ Object.create(null)))["." + l] = a, l;
      }
      const s = typeof n.all == "string" ? n.all : n.all ? i(n.all) : void 0, o = n.scope;
      this.scope = o instanceof gs ? (a) => a.prop(nd) == o.data : o ? (a) => a == o : void 0, this.style = Qoe(e.map((a) => ({
        tag: a.tag,
        class: a.class || i(Object.assign({}, a, {
          tag: null
        }))
      })), {
        all: s
      }).style, this.module = r ? new Ed(r) : null, this.themeType = n.themeType;
    }
    static define(e, n) {
      return new _S(e, n || {});
    }
  }
  const qM = Ge.define(), Joe = Ge.define({
    combine(t) {
      return t.length ? [
        t[0]
      ] : null;
    }
  });
  function a$(t) {
    let e = t.facet(qM);
    return e.length ? e : t.facet(Joe);
  }
  function gqe(t, e) {
    let n = [
      yqe
    ], r;
    return t instanceof _S && (t.module && n.push(Re.styleModule.of(t.module)), r = t.themeType), (e == null ? void 0 : e.fallback) ? n.push(Joe.of(t)) : r ? n.push(qM.computeN([
      Re.darkTheme
    ], (i) => i.facet(Re.darkTheme) == (r == "dark") ? [
      t
    ] : [])) : n.push(qM.of(t)), n;
  }
  class mqe {
    constructor(e) {
      this.markCache = /* @__PURE__ */ Object.create(null), this.tree = Un(e.state), this.decorations = this.buildDeco(e, a$(e.state)), this.decoratedTo = e.viewport.to;
    }
    update(e) {
      let n = Un(e.state), r = a$(e.state), i = r != a$(e.startState), { viewport: s } = e.view, o = e.changes.mapPos(this.decoratedTo, 1);
      n.length < s.to && !i && n.type == this.tree.type && o >= s.to ? (this.decorations = this.decorations.map(e.changes), this.decoratedTo = o) : (n != this.tree || e.viewportChanged || i) && (this.tree = n, this.decorations = this.buildDeco(e.view, r), this.decoratedTo = s.to);
    }
    buildDeco(e, n) {
      if (!n || !this.tree.length)
        return Qe.none;
      let r = new PM();
      for (let { from: i, to: s } of e.visibleRanges)
        zGe(this.tree, n, (o, a, l) => {
          r.add(o, a, this.markCache[l] || (this.markCache[l] = Qe.mark({
            class: l
          })));
        }, i, s);
      return r.finish();
    }
  }
  const yqe = xS.high(ur.fromClass(mqe, {
    decorations: (t) => t.decorations
  }));
  V.meta, V.link, V.heading, V.emphasis, V.strong, V.strikethrough, V.keyword, V.atom, V.bool, V.url, V.contentSeparator, V.labelName, V.literal, V.inserted, V.string, V.deleted, V.regexp, V.escape, V.string, V.variableName, V.variableName, V.typeName, V.namespace, V.className, V.variableName, V.macroName, V.propertyName, V.comment, V.invalid;
  vqe = new ut();
  function VU(t, e, n, r = 0, i = 0) {
    e == null && (e = t.search(/[^\s\u00a0]/), e == -1 && (e = t.length));
    let s = i;
    for (let o = r; o < e; o++)
      t.charCodeAt(o) == 9 ? s += n - s % n : s++;
    return s;
  }
  class eae {
    constructor(e, n, r, i) {
      this.string = e, this.tabSize = n, this.indentUnit = r, this.overrideIndent = i, this.pos = 0, this.start = 0, this.lastColumnPos = 0, this.lastColumnValue = 0;
    }
    eol() {
      return this.pos >= this.string.length;
    }
    sol() {
      return this.pos == 0;
    }
    peek() {
      return this.string.charAt(this.pos) || void 0;
    }
    next() {
      if (this.pos < this.string.length)
        return this.string.charAt(this.pos++);
    }
    eat(e) {
      let n = this.string.charAt(this.pos), r;
      if (typeof e == "string" ? r = n == e : r = n && (e instanceof RegExp ? e.test(n) : e(n)), r)
        return ++this.pos, n;
    }
    eatWhile(e) {
      let n = this.pos;
      for (; this.eat(e); )
        ;
      return this.pos > n;
    }
    eatSpace() {
      let e = this.pos;
      for (; /[\s\u00a0]/.test(this.string.charAt(this.pos)); )
        ++this.pos;
      return this.pos > e;
    }
    skipToEnd() {
      this.pos = this.string.length;
    }
    skipTo(e) {
      let n = this.string.indexOf(e, this.pos);
      if (n > -1)
        return this.pos = n, true;
    }
    backUp(e) {
      this.pos -= e;
    }
    column() {
      return this.lastColumnPos < this.start && (this.lastColumnValue = VU(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue), this.lastColumnPos = this.start), this.lastColumnValue;
    }
    indentation() {
      var e;
      return (e = this.overrideIndent) !== null && e !== void 0 ? e : VU(this.string, null, this.tabSize);
    }
    match(e, n, r) {
      if (typeof e == "string") {
        let i = (o) => r ? o.toLowerCase() : o, s = this.string.substr(this.pos, e.length);
        return i(s) == i(e) ? (n !== false && (this.pos += e.length), true) : null;
      } else {
        let i = this.string.slice(this.pos).match(e);
        return i && i.index > 0 ? null : (i && n !== false && (this.pos += i[0].length), i);
      }
    }
    current() {
      return this.string.slice(this.start, this.pos);
    }
  }
  function Oqe(t) {
    return {
      name: t.name || "",
      token: t.token,
      blankLine: t.blankLine || (() => {
      }),
      startState: t.startState || (() => true),
      copyState: t.copyState || Sqe,
      indent: t.indent || (() => null),
      languageData: t.languageData || {},
      tokenTable: t.tokenTable || zj,
      mergeTokens: t.mergeTokens !== false
    };
  }
  function Sqe(t) {
    if (typeof t != "object")
      return t;
    let e = {};
    for (let n in t) {
      let r = t[n];
      e[n] = r instanceof Array ? r.slice() : r;
    }
    return e;
  }
  const XU = /* @__PURE__ */ new WeakMap();
  class Nj extends gs {
    constructor(e) {
      let n = A2(e.languageData), r = Oqe(e), i, s = new class extends $2 {
        createParse(o, a, l) {
          return new xqe(i, o, a, l);
        }
      }();
      super(n, s, [], e.name), this.topNode = Pqe(n, this), i = this, this.streamParser = r, this.stateAfter = new ut({
        perNode: true
      }), this.tokenTable = e.tokenTable ? new iae(r.tokenTable) : kqe;
    }
    static define(e) {
      return new Nj(e);
    }
    getIndent(e) {
      let n, { overrideIndentation: r } = e.options;
      r && (n = XU.get(e.state), n != null && n < e.pos - 1e4 && (n = void 0));
      let i = Qj(this, e.node.tree, e.node.from, e.node.from, n ?? e.pos), s, o;
      if (i ? (o = i.state, s = i.pos + 1) : (o = this.streamParser.startState(e.unit), s = e.node.from), e.pos - s > 1e4)
        return null;
      for (; s < e.pos; ) {
        let l = e.state.doc.lineAt(s), c = Math.min(e.pos, l.to);
        if (l.length) {
          let u = r ? r(l.from) : -1, d = new eae(l.text, e.state.tabSize, e.unit, u < 0 ? void 0 : u);
          for (; d.pos < c - l.from; )
            nae(this.streamParser.token, d, o);
        } else
          this.streamParser.blankLine(o, e.unit);
        if (c == e.pos)
          break;
        s = l.to + 1;
      }
      let a = e.lineAt(e.pos);
      return r && n == null && XU.set(e.state, a.from), this.streamParser.indent(o, /^\s*(.*)/.exec(a.text)[1], e);
    }
    get allowsNesting() {
      return false;
    }
  }
  function Qj(t, e, n, r, i) {
    let s = n >= r && n + e.length <= i && e.prop(t.stateAfter);
    if (s)
      return {
        state: t.streamParser.copyState(s),
        pos: n + e.length
      };
    for (let o = e.children.length - 1; o >= 0; o--) {
      let a = e.children[o], l = n + e.positions[o], c = a instanceof At && l < i && Qj(t, a, l, r, i);
      if (c)
        return c;
    }
    return null;
  }
  function tae(t, e, n, r, i) {
    if (i && n <= 0 && r >= e.length)
      return e;
    !i && n == 0 && e.type == t.topNode && (i = true);
    for (let s = e.children.length - 1; s >= 0; s--) {
      let o = e.positions[s], a = e.children[s], l;
      if (o < r && a instanceof At) {
        if (!(l = tae(t, a, n - o, r - o, i)))
          break;
        return i ? new At(e.type, e.children.slice(0, s).concat(l), e.positions.slice(0, s + 1), o + l.length) : l;
      }
    }
    return null;
  }
  function wqe(t, e, n, r, i) {
    for (let s of e) {
      let o = s.from + (s.openStart ? 25 : 0), a = s.to - (s.openEnd ? 25 : 0), l = o <= n && a > n && Qj(t, s.tree, 0 - s.offset, n, a), c;
      if (l && l.pos <= r && (c = tae(t, s.tree, n + s.offset, l.pos + s.offset, false)))
        return {
          state: l.state,
          tree: c
        };
    }
    return {
      state: t.streamParser.startState(i ? gf(i) : 4),
      tree: At.empty
    };
  }
  let xqe = class {
    constructor(e, n, r, i) {
      this.lang = e, this.input = n, this.fragments = r, this.ranges = i, this.stoppedAt = null, this.chunks = [], this.chunkPos = [], this.chunk = [], this.chunkReused = void 0, this.rangeIndex = 0, this.to = i[i.length - 1].to;
      let s = pf.get(), o = i[0].from, { state: a, tree: l } = wqe(e, r, o, this.to, s == null ? void 0 : s.state);
      this.state = a, this.parsedPos = this.chunkStart = o + l.length;
      for (let c = 0; c < l.children.length; c++)
        this.chunks.push(l.children[c]), this.chunkPos.push(l.positions[c]);
      s && this.parsedPos < s.viewport.from - 1e5 && i.some((c) => c.from <= s.viewport.from && c.to >= s.viewport.from) && (this.state = this.lang.streamParser.startState(gf(s.state)), s.skipUntilInView(this.parsedPos, s.viewport.from), this.parsedPos = s.viewport.from), this.moveRangeIndex();
    }
    advance() {
      let e = pf.get(), n = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt), r = Math.min(n, this.chunkStart + 512);
      for (e && (r = Math.min(r, e.viewport.to)); this.parsedPos < r; )
        this.parseLine(e);
      return this.chunkStart < this.parsedPos && this.finishChunk(), this.parsedPos >= n ? this.finish() : e && this.parsedPos >= e.viewport.to ? (e.skipUntilInView(this.parsedPos, n), this.finish()) : null;
    }
    stopAt(e) {
      this.stoppedAt = e;
    }
    lineAfter(e) {
      let n = this.input.chunk(e);
      if (this.input.lineChunks)
        n == `
` && (n = "");
      else {
        let r = n.indexOf(`
`);
        r > -1 && (n = n.slice(0, r));
      }
      return e + n.length <= this.to ? n : n.slice(0, this.to - e);
    }
    nextLine() {
      let e = this.parsedPos, n = this.lineAfter(e), r = e + n.length;
      for (let i = this.rangeIndex; ; ) {
        let s = this.ranges[i].to;
        if (s >= r || (n = n.slice(0, s - (r - n.length)), i++, i == this.ranges.length))
          break;
        let o = this.ranges[i].from, a = this.lineAfter(o);
        n += a, r = o + a.length;
      }
      return {
        line: n,
        end: r
      };
    }
    skipGapsTo(e, n, r) {
      for (; ; ) {
        let i = this.ranges[this.rangeIndex].to, s = e + n;
        if (r > 0 ? i > s : i >= s)
          break;
        let o = this.ranges[++this.rangeIndex].from;
        n += o - i;
      }
      return n;
    }
    moveRangeIndex() {
      for (; this.ranges[this.rangeIndex].to < this.parsedPos; )
        this.rangeIndex++;
    }
    emitToken(e, n, r, i) {
      let s = 4;
      if (this.ranges.length > 1) {
        i = this.skipGapsTo(n, i, 1), n += i;
        let a = this.chunk.length;
        i = this.skipGapsTo(r, i, -1), r += i, s += this.chunk.length - a;
      }
      let o = this.chunk.length - 4;
      return this.lang.streamParser.mergeTokens && s == 4 && o >= 0 && this.chunk[o] == e && this.chunk[o + 2] == n ? this.chunk[o + 2] = r : this.chunk.push(e, n, r, s), i;
    }
    parseLine(e) {
      let { line: n, end: r } = this.nextLine(), i = 0, { streamParser: s } = this.lang, o = new eae(n, e ? e.state.tabSize : 4, e ? gf(e.state) : 2);
      if (o.eol())
        s.blankLine(this.state, o.indentUnit);
      else
        for (; !o.eol(); ) {
          let a = nae(s.token, o, this.state);
          if (a && (i = this.emitToken(this.lang.tokenTable.resolve(a), this.parsedPos + o.start, this.parsedPos + o.pos, i)), o.start > 1e4)
            break;
        }
      this.parsedPos = r, this.moveRangeIndex(), this.parsedPos < this.to && this.parsedPos++;
    }
    finishChunk() {
      let e = At.build({
        buffer: this.chunk,
        start: this.chunkStart,
        length: this.parsedPos - this.chunkStart,
        nodeSet: bqe,
        topID: 0,
        maxBufferLength: 512,
        reused: this.chunkReused
      });
      e = new At(e.type, e.children, e.positions, e.length, [
        [
          this.lang.stateAfter,
          this.lang.streamParser.copyState(this.state)
        ]
      ]), this.chunks.push(e), this.chunkPos.push(this.chunkStart - this.ranges[0].from), this.chunk = [], this.chunkReused = void 0, this.chunkStart = this.parsedPos;
    }
    finish() {
      return new At(this.lang.topNode, this.chunks, this.chunkPos, this.parsedPos - this.ranges[0].from).balance();
    }
  };
  function nae(t, e, n) {
    e.start = e.pos;
    for (let r = 0; r < 10; r++) {
      let i = t(e, n);
      if (e.pos > e.start)
        return i;
    }
    throw new Error("Stream parser failed to advance stream.");
  }
  const zj = /* @__PURE__ */ Object.create(null), wO = [
    Tr.none
  ], bqe = new Qm(wO), WU = [], ZU = /* @__PURE__ */ Object.create(null), rae = /* @__PURE__ */ Object.create(null);
  for (let [t, e] of [
    [
      "variable",
      "variableName"
    ],
    [
      "variable-2",
      "variableName.special"
    ],
    [
      "string-2",
      "string.special"
    ],
    [
      "def",
      "variableName.definition"
    ],
    [
      "tag",
      "tagName"
    ],
    [
      "attribute",
      "attributeName"
    ],
    [
      "type",
      "typeName"
    ],
    [
      "builtin",
      "variableName.standard"
    ],
    [
      "qualifier",
      "modifier"
    ],
    [
      "error",
      "invalid"
    ],
    [
      "header",
      "heading"
    ],
    [
      "property",
      "propertyName"
    ]
  ])
    rae[t] = sae(zj, e);
  class iae {
    constructor(e) {
      this.extra = e, this.table = Object.assign(/* @__PURE__ */ Object.create(null), rae);
    }
    resolve(e) {
      return e ? this.table[e] || (this.table[e] = sae(this.extra, e)) : 0;
    }
  }
  const kqe = new iae(zj);
  function l$(t, e) {
    WU.indexOf(t) > -1 || (WU.push(t), console.warn(e));
  }
  function sae(t, e) {
    let n = [];
    for (let a of e.split(" ")) {
      let l = [];
      for (let c of a.split(".")) {
        let u = t[c] || V[c];
        u ? typeof u == "function" ? l.length ? l = l.map(u) : l$(c, `Modifier ${c} used at start of tag`) : l.length ? l$(c, `Tag ${c} used as modifier`) : l = Array.isArray(u) ? u : [
          u
        ] : l$(c, `Unknown highlighting tag ${c}`);
      }
      for (let c of l)
        n.push(c);
    }
    if (!n.length)
      return 0;
    let r = e.replace(/ /g, "_"), i = r + " " + n.map((a) => a.id), s = ZU[i];
    if (s)
      return s.id;
    let o = ZU[i] = Tr.define({
      id: wO.length,
      name: r,
      props: [
        zm({
          [r]: n
        })
      ]
    });
    return wO.push(o), o.id;
  }
  function Pqe(t, e) {
    let n = Tr.define({
      id: wO.length,
      name: "Document",
      props: [
        nd.add(() => t),
        Bm.add(() => (r) => e.getIndent(r))
      ],
      top: true
    });
    return wO.push(n), n;
  }
  er.RTL, er.LTR;
  let Cqe = class {
    constructor(e, n, r, i) {
      this.state = e, this.pos = n, this.explicit = r, this.view = i, this.abortListeners = [], this.abortOnDocChange = false;
    }
    tokenBefore(e) {
      let n = Un(this.state).resolveInner(this.pos, -1);
      for (; n && e.indexOf(n.name) < 0; )
        n = n.parent;
      return n ? {
        from: n.from,
        to: this.pos,
        text: this.state.sliceDoc(n.from, this.pos),
        type: n.type
      } : null;
    }
    matchBefore(e) {
      let n = this.state.doc.lineAt(this.pos), r = Math.max(n.from, this.pos - 250), i = n.text.slice(r - n.from, this.pos - n.from), s = i.search(Iqe(e, false));
      return s < 0 ? null : {
        from: r + s,
        to: this.pos,
        text: i.slice(s)
      };
    }
    get aborted() {
      return this.abortListeners == null;
    }
    addEventListener(e, n, r) {
      e == "abort" && this.abortListeners && (this.abortListeners.push(n), r && r.onDocChange && (this.abortOnDocChange = true));
    }
  };
  function HU(t) {
    let e = Object.keys(t).join(""), n = /\w/.test(e);
    return n && (e = e.replace(/\w/g, "")), `[${n ? "\\w" : ""}${e.replace(/[^\w\s]/g, "\\$&")}]`;
  }
  function _qe(t) {
    let e = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ Object.create(null);
    for (let { label: i } of t) {
      e[i[0]] = true;
      for (let s = 1; s < i.length; s++)
        n[i[s]] = true;
    }
    let r = HU(e) + HU(n) + "*$";
    return [
      new RegExp("^" + r),
      new RegExp(r)
    ];
  }
  Tqe = function(t) {
    let e = t.map((i) => typeof i == "string" ? {
      label: i
    } : i), [n, r] = e.every((i) => /^\w+$/.test(i.label)) ? [
      /\w*$/,
      /\w+$/
    ] : _qe(e);
    return (i) => {
      let s = i.matchBefore(r);
      return s || i.explicit ? {
        from: s ? s.from : i.pos,
        options: e,
        validFor: n
      } : null;
    };
  };
  Eqe = function(t, e) {
    return (n) => {
      for (let r = Un(n.state).resolveInner(n.pos, -1); r; r = r.parent) {
        if (t.indexOf(r.name) > -1)
          return null;
        if (r.type.isTop)
          break;
      }
      return e(n);
    };
  };
  function Iqe(t, e) {
    var n;
    let { source: r } = t, i = e && r[0] != "^", s = r[r.length - 1] != "$";
    return !i && !s ? t : new RegExp(`${i ? "^" : ""}(?:${r})${s ? "$" : ""}`, (n = t.flags) !== null && n !== void 0 ? n : t.ignoreCase ? "i" : "");
  }
  const $qe = Wd.define(), Aqe = Re.baseTheme({
    ".cm-tooltip.cm-tooltip-autocomplete": {
      "& > ul": {
        fontFamily: "monospace",
        whiteSpace: "nowrap",
        overflow: "hidden auto",
        maxWidth_fallback: "700px",
        maxWidth: "min(700px, 95vw)",
        minWidth: "250px",
        maxHeight: "10em",
        height: "100%",
        listStyle: "none",
        margin: 0,
        padding: 0,
        "& > li, & > completion-section": {
          padding: "1px 3px",
          lineHeight: 1.2
        },
        "& > li": {
          overflowX: "hidden",
          textOverflow: "ellipsis",
          cursor: "pointer"
        },
        "& > completion-section": {
          display: "list-item",
          borderBottom: "1px solid silver",
          paddingLeft: "0.5em",
          opacity: 0.7
        }
      }
    },
    "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
      background: "#17c",
      color: "white"
    },
    "&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
      background: "#777"
    },
    "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
      background: "#347",
      color: "white"
    },
    "&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
      background: "#444"
    },
    ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
      content: '"\xB7\xB7\xB7"',
      opacity: 0.5,
      display: "block",
      textAlign: "center"
    },
    ".cm-tooltip.cm-completionInfo": {
      position: "absolute",
      padding: "3px 9px",
      width: "max-content",
      maxWidth: "400px",
      boxSizing: "border-box",
      whiteSpace: "pre-line"
    },
    ".cm-completionInfo.cm-completionInfo-left": {
      right: "100%"
    },
    ".cm-completionInfo.cm-completionInfo-right": {
      left: "100%"
    },
    ".cm-completionInfo.cm-completionInfo-left-narrow": {
      right: "30px"
    },
    ".cm-completionInfo.cm-completionInfo-right-narrow": {
      left: "30px"
    },
    "&light .cm-snippetField": {
      backgroundColor: "#00000022"
    },
    "&dark .cm-snippetField": {
      backgroundColor: "#ffffff22"
    },
    ".cm-snippetFieldPosition": {
      verticalAlign: "text-top",
      width: 0,
      height: "1.15em",
      display: "inline-block",
      margin: "0 -0.7px -.7em",
      borderLeft: "1.4px dotted #888"
    },
    ".cm-completionMatchedText": {
      textDecoration: "underline"
    },
    ".cm-completionDetail": {
      marginLeft: "0.5em",
      fontStyle: "italic"
    },
    ".cm-completionIcon": {
      fontSize: "90%",
      width: ".8em",
      display: "inline-block",
      textAlign: "center",
      paddingRight: ".6em",
      opacity: "0.6",
      boxSizing: "content-box"
    },
    ".cm-completionIcon-function, .cm-completionIcon-method": {
      "&:after": {
        content: "'\u0192'"
      }
    },
    ".cm-completionIcon-class": {
      "&:after": {
        content: "'\u25CB'"
      }
    },
    ".cm-completionIcon-interface": {
      "&:after": {
        content: "'\u25CC'"
      }
    },
    ".cm-completionIcon-variable": {
      "&:after": {
        content: "'\u{1D465}'"
      }
    },
    ".cm-completionIcon-constant": {
      "&:after": {
        content: "'\u{1D436}'"
      }
    },
    ".cm-completionIcon-type": {
      "&:after": {
        content: "'\u{1D461}'"
      }
    },
    ".cm-completionIcon-enum": {
      "&:after": {
        content: "'\u222A'"
      }
    },
    ".cm-completionIcon-property": {
      "&:after": {
        content: "'\u25A1'"
      }
    },
    ".cm-completionIcon-keyword": {
      "&:after": {
        content: "'\u{1F511}\uFE0E'"
      }
    },
    ".cm-completionIcon-namespace": {
      "&:after": {
        content: "'\u25A2'"
      }
    },
    ".cm-completionIcon-text": {
      "&:after": {
        content: "'abc'",
        fontSize: "50%",
        verticalAlign: "middle"
      }
    }
  });
  class Rqe {
    constructor(e, n, r, i) {
      this.field = e, this.line = n, this.from = r, this.to = i;
    }
  }
  class Fj {
    constructor(e, n, r) {
      this.field = e, this.from = n, this.to = r;
    }
    map(e) {
      let n = e.mapPos(this.from, -1, yi.TrackDel), r = e.mapPos(this.to, 1, yi.TrackDel);
      return n == null || r == null ? null : new Fj(this.field, n, r);
    }
  }
  class Bj {
    constructor(e, n) {
      this.lines = e, this.fieldPositions = n;
    }
    instantiate(e, n) {
      let r = [], i = [
        n
      ], s = e.doc.lineAt(n), o = /^\s*/.exec(s.text)[0];
      for (let l of this.lines) {
        if (r.length) {
          let c = o, u = /^\t*/.exec(l)[0].length;
          for (let d = 0; d < u; d++)
            c += e.facet(Fm);
          i.push(n + c.length - u), l = c + l.slice(u);
        }
        r.push(l), n += l.length + 1;
      }
      let a = this.fieldPositions.map((l) => new Fj(l.field, i[l.line] + l.from, i[l.line] + l.to));
      return {
        text: r,
        ranges: a
      };
    }
    static parse(e) {
      let n = [], r = [], i = [], s;
      for (let o of e.split(/\r\n?|\n/)) {
        for (; s = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o); ) {
          let a = s[1] ? +s[1] : null, l = s[2] || s[3] || "", c = -1, u = l.replace(/\\[{}]/g, (d) => d[1]);
          for (let d = 0; d < n.length; d++)
            (a != null ? n[d].seq == a : u && n[d].name == u) && (c = d);
          if (c < 0) {
            let d = 0;
            for (; d < n.length && (a == null || n[d].seq != null && n[d].seq < a); )
              d++;
            n.splice(d, 0, {
              seq: a,
              name: u
            }), c = d;
            for (let h of i)
              h.field >= c && h.field++;
          }
          for (let d of i)
            if (d.line == r.length && d.from > s.index) {
              let h = s[2] ? 3 + (s[1] || "").length : 2;
              d.from -= h, d.to -= h;
            }
          i.push(new Rqe(c, r.length, s.index, s.index + u.length)), o = o.slice(0, s.index) + l + o.slice(s.index + s[0].length);
        }
        o = o.replace(/\\([{}])/g, (a, l, c) => {
          for (let u of i)
            u.line == r.length && u.from > c && (u.from--, u.to--);
          return l;
        }), r.push(o);
      }
      return new Bj(r, i);
    }
  }
  let Mqe = Qe.widget({
    widget: new class extends Yl {
      toDOM() {
        let t = document.createElement("span");
        return t.className = "cm-snippetFieldPosition", t;
      }
      ignoreEvent() {
        return false;
      }
    }()
  }), Dqe = Qe.mark({
    class: "cm-snippetField"
  });
  class Vm {
    constructor(e, n) {
      this.ranges = e, this.active = n, this.deco = Qe.set(e.map((r) => (r.from == r.to ? Mqe : Dqe).range(r.from, r.to)), true);
    }
    map(e) {
      let n = [];
      for (let r of this.ranges) {
        let i = r.map(e);
        if (!i)
          return null;
        n.push(i);
      }
      return new Vm(n, this.active);
    }
    selectionInsideField(e) {
      return e.ranges.every((n) => this.ranges.some((r) => r.field == this.active && r.from <= n.from && r.to >= n.to));
    }
  }
  const TS = kn.define({
    map(t, e) {
      return t && t.map(e);
    }
  }), Lqe = kn.define(), xO = Xd.define({
    create() {
      return null;
    },
    update(t, e) {
      for (let n of e.effects) {
        if (n.is(TS))
          return n.value;
        if (n.is(Lqe) && t)
          return new Vm(t.ranges, n.value);
      }
      return t && e.docChanged && (t = t.map(e.changes)), t && e.selection && !t.selectionInsideField(e.selection) && (t = null), t;
    },
    provide: (t) => Re.decorations.from(t, (e) => e ? e.deco : Qe.none)
  });
  function Uj(t, e) {
    return Ve.create(t.filter((n) => n.field == e).map((n) => Ve.range(n.from, n.to)));
  }
  function jqe(t) {
    let e = Bj.parse(t);
    return (n, r, i, s) => {
      let { text: o, ranges: a } = e.instantiate(n.state, i), { main: l } = n.state.selection, c = {
        changes: {
          from: i,
          to: s == l.from ? l.to : s,
          insert: Qt.of(o)
        },
        scrollIntoView: true,
        annotations: r ? [
          $qe.of(r),
          Yo.userEvent.of("input.complete")
        ] : void 0
      };
      if (a.length && (c.selection = Uj(a, 0)), a.some((u) => u.field > 0)) {
        let u = new Vm(a, 0), d = c.effects = [
          TS.of(u)
        ];
        n.state.field(xO, false) === void 0 && d.push(kn.appendConfig.of([
          xO,
          Bqe,
          Uqe,
          Aqe
        ]));
      }
      n.dispatch(n.state.update(c));
    };
  }
  function oae(t) {
    return ({ state: e, dispatch: n }) => {
      let r = e.field(xO, false);
      if (!r || t < 0 && r.active == 0)
        return false;
      let i = r.active + t, s = t > 0 && !r.ranges.some((o) => o.field == i + t);
      return n(e.update({
        selection: Uj(r.ranges, i),
        effects: TS.of(s ? null : new Vm(r.ranges, i)),
        scrollIntoView: true
      })), true;
    };
  }
  const Nqe = ({ state: t, dispatch: e }) => t.field(xO, false) ? (e(t.update({
    effects: TS.of(null)
  })), true) : false, Qqe = oae(1), zqe = oae(-1), Fqe = [
    {
      key: "Tab",
      run: Qqe,
      shift: zqe
    },
    {
      key: "Escape",
      run: Nqe
    }
  ], YU = Ge.define({
    combine(t) {
      return t.length ? t[0] : Fqe;
    }
  }), Bqe = xS.highest(E2.compute([
    YU
  ], (t) => t.facet(YU)));
  is = function(t, e) {
    return {
      ...e,
      apply: jqe(t)
    };
  };
  const Uqe = Re.domEventHandlers({
    mousedown(t, e) {
      let n = e.state.field(xO, false), r;
      if (!n || (r = e.posAtCoords({
        x: t.clientX,
        y: t.clientY
      })) == null)
        return false;
      let i = n.ranges.find((s) => s.from <= r && s.to >= r);
      return !i || i.field == n.active ? false : (e.dispatch({
        selection: Uj(n.ranges, i.field),
        effects: TS.of(n.ranges.some((s) => s.field > i.field) ? new Vm(n.ranges, i.field) : null),
        scrollIntoView: true
      }), true);
    }
  }), aae = new class extends uf {
  }();
  aae.startSide = 1;
  aae.endSide = -1;
  class yP {
    static create(e, n, r, i, s) {
      let o = i + (i << 8) + e + (n << 4) | 0;
      return new yP(e, n, r, o, s, [], []);
    }
    constructor(e, n, r, i, s, o, a) {
      this.type = e, this.value = n, this.from = r, this.hash = i, this.end = s, this.children = o, this.positions = a, this.hashProp = [
        [
          ut.contextHash,
          i
        ]
      ];
    }
    addChild(e, n) {
      e.prop(ut.contextHash) != this.hash && (e = new At(e.type, e.children, e.positions, e.length, this.hashProp)), this.children.push(e), this.positions.push(n);
    }
    toTree(e, n = this.end) {
      let r = this.children.length - 1;
      return r >= 0 && (n = Math.max(n, this.positions[r] + this.children[r].length + this.from)), new At(e.types[this.type], this.children, this.positions, n - this.from).balance({
        makeTree: (i, s, o) => new At(Tr.none, i, s, o, this.hashProp)
      });
    }
  }
  var we;
  (function(t) {
    t[t.Document = 1] = "Document", t[t.CodeBlock = 2] = "CodeBlock", t[t.FencedCode = 3] = "FencedCode", t[t.Blockquote = 4] = "Blockquote", t[t.HorizontalRule = 5] = "HorizontalRule", t[t.BulletList = 6] = "BulletList", t[t.OrderedList = 7] = "OrderedList", t[t.ListItem = 8] = "ListItem", t[t.ATXHeading1 = 9] = "ATXHeading1", t[t.ATXHeading2 = 10] = "ATXHeading2", t[t.ATXHeading3 = 11] = "ATXHeading3", t[t.ATXHeading4 = 12] = "ATXHeading4", t[t.ATXHeading5 = 13] = "ATXHeading5", t[t.ATXHeading6 = 14] = "ATXHeading6", t[t.SetextHeading1 = 15] = "SetextHeading1", t[t.SetextHeading2 = 16] = "SetextHeading2", t[t.HTMLBlock = 17] = "HTMLBlock", t[t.LinkReference = 18] = "LinkReference", t[t.Paragraph = 19] = "Paragraph", t[t.CommentBlock = 20] = "CommentBlock", t[t.ProcessingInstructionBlock = 21] = "ProcessingInstructionBlock", t[t.Escape = 22] = "Escape", t[t.Entity = 23] = "Entity", t[t.HardBreak = 24] = "HardBreak", t[t.Emphasis = 25] = "Emphasis", t[t.StrongEmphasis = 26] = "StrongEmphasis", t[t.Link = 27] = "Link", t[t.Image = 28] = "Image", t[t.InlineCode = 29] = "InlineCode", t[t.HTMLTag = 30] = "HTMLTag", t[t.Comment = 31] = "Comment", t[t.ProcessingInstruction = 32] = "ProcessingInstruction", t[t.Autolink = 33] = "Autolink", t[t.HeaderMark = 34] = "HeaderMark", t[t.QuoteMark = 35] = "QuoteMark", t[t.ListMark = 36] = "ListMark", t[t.LinkMark = 37] = "LinkMark", t[t.EmphasisMark = 38] = "EmphasisMark", t[t.CodeMark = 39] = "CodeMark", t[t.CodeText = 40] = "CodeText", t[t.CodeInfo = 41] = "CodeInfo", t[t.LinkTitle = 42] = "LinkTitle", t[t.LinkLabel = 43] = "LinkLabel", t[t.URL = 44] = "URL";
  })(we || (we = {}));
  class Vqe {
    constructor(e, n) {
      this.start = e, this.content = n, this.marks = [], this.parsers = [];
    }
  }
  let Xqe = class {
    constructor() {
      this.text = "", this.baseIndent = 0, this.basePos = 0, this.depth = 0, this.markers = [], this.pos = 0, this.indent = 0, this.next = -1;
    }
    forward() {
      this.basePos > this.pos && this.forwardInner();
    }
    forwardInner() {
      let e = this.skipSpace(this.basePos);
      this.indent = this.countIndent(e, this.pos, this.indent), this.pos = e, this.next = e == this.text.length ? -1 : this.text.charCodeAt(e);
    }
    skipSpace(e) {
      return uv(this.text, e);
    }
    reset(e) {
      for (this.text = e, this.baseIndent = this.basePos = this.pos = this.indent = 0, this.forwardInner(), this.depth = 1; this.markers.length; )
        this.markers.pop();
    }
    moveBase(e) {
      this.basePos = e, this.baseIndent = this.countIndent(e, this.pos, this.indent);
    }
    moveBaseColumn(e) {
      this.baseIndent = e, this.basePos = this.findColumn(e);
    }
    addMarker(e) {
      this.markers.push(e);
    }
    countIndent(e, n = 0, r = 0) {
      for (let i = n; i < e; i++)
        r += this.text.charCodeAt(i) == 9 ? 4 - r % 4 : 1;
      return r;
    }
    findColumn(e) {
      let n = 0;
      for (let r = 0; n < this.text.length && r < e; n++)
        r += this.text.charCodeAt(n) == 9 ? 4 - r % 4 : 1;
      return n;
    }
    scrub() {
      if (!this.baseIndent)
        return this.text;
      let e = "";
      for (let n = 0; n < this.basePos; n++)
        e += " ";
      return e + this.text.slice(this.basePos);
    }
  };
  function GU(t, e, n) {
    if (n.pos == n.text.length || t != e.block && n.indent >= e.stack[n.depth + 1].value + n.baseIndent)
      return true;
    if (n.indent >= n.baseIndent + 4)
      return false;
    let r = (t.type == we.OrderedList ? Wj : Xj)(n, e, false);
    return r > 0 && (t.type != we.BulletList || Vj(n, e, false) < 0) && n.text.charCodeAt(n.pos + r - 1) == t.value;
  }
  const lae = {
    [we.Blockquote](t, e, n) {
      return n.next != 62 ? false : (n.markers.push(Et(we.QuoteMark, e.lineStart + n.pos, e.lineStart + n.pos + 1)), n.moveBase(n.pos + (aa(n.text.charCodeAt(n.pos + 1)) ? 2 : 1)), t.end = e.lineStart + n.text.length, true);
    },
    [we.ListItem](t, e, n) {
      return n.indent < n.baseIndent + t.value && n.next > -1 ? false : (n.moveBaseColumn(n.baseIndent + t.value), true);
    },
    [we.OrderedList]: GU,
    [we.BulletList]: GU,
    [we.Document]() {
      return true;
    }
  };
  function aa(t) {
    return t == 32 || t == 9 || t == 10 || t == 13;
  }
  function uv(t, e = 0) {
    for (; e < t.length && aa(t.charCodeAt(e)); )
      e++;
    return e;
  }
  function qU(t, e, n) {
    for (; e > n && aa(t.charCodeAt(e - 1)); )
      e--;
    return e;
  }
  function cae(t) {
    if (t.next != 96 && t.next != 126)
      return -1;
    let e = t.pos + 1;
    for (; e < t.text.length && t.text.charCodeAt(e) == t.next; )
      e++;
    if (e < t.pos + 3)
      return -1;
    if (t.next == 96) {
      for (let n = e; n < t.text.length; n++)
        if (t.text.charCodeAt(n) == 96)
          return -1;
    }
    return e;
  }
  function uae(t) {
    return t.next != 62 ? -1 : t.text.charCodeAt(t.pos + 1) == 32 ? 2 : 1;
  }
  function Vj(t, e, n) {
    if (t.next != 42 && t.next != 45 && t.next != 95)
      return -1;
    let r = 1;
    for (let i = t.pos + 1; i < t.text.length; i++) {
      let s = t.text.charCodeAt(i);
      if (s == t.next)
        r++;
      else if (!aa(s))
        return -1;
    }
    return n && t.next == 45 && fae(t) > -1 && t.depth == e.stack.length && e.parser.leafBlockParsers.indexOf(yae.SetextHeading) > -1 || r < 3 ? -1 : 1;
  }
  function dae(t, e) {
    for (let n = t.stack.length - 1; n >= 0; n--)
      if (t.stack[n].type == e)
        return true;
    return false;
  }
  function Xj(t, e, n) {
    return (t.next == 45 || t.next == 43 || t.next == 42) && (t.pos == t.text.length - 1 || aa(t.text.charCodeAt(t.pos + 1))) && (!n || dae(e, we.BulletList) || t.skipSpace(t.pos + 2) < t.text.length) ? 1 : -1;
  }
  function Wj(t, e, n) {
    let r = t.pos, i = t.next;
    for (; i >= 48 && i <= 57; ) {
      r++;
      if (r == t.text.length)
        return -1;
      i = t.text.charCodeAt(r);
    }
    return r == t.pos || r > t.pos + 9 || i != 46 && i != 41 || r < t.text.length - 1 && !aa(t.text.charCodeAt(r + 1)) || n && !dae(e, we.OrderedList) && (t.skipSpace(r + 1) == t.text.length || r > t.pos + 1 || t.next != 49) ? -1 : r + 1 - t.pos;
  }
  function hae(t) {
    if (t.next != 35)
      return -1;
    let e = t.pos + 1;
    for (; e < t.text.length && t.text.charCodeAt(e) == 35; )
      e++;
    if (e < t.text.length && t.text.charCodeAt(e) != 32)
      return -1;
    let n = e - t.pos;
    return n > 6 ? -1 : n;
  }
  function fae(t) {
    if (t.next != 45 && t.next != 61 || t.indent >= t.baseIndent + 4)
      return -1;
    let e = t.pos + 1;
    for (; e < t.text.length && t.text.charCodeAt(e) == t.next; )
      e++;
    let n = e;
    for (; e < t.text.length && aa(t.text.charCodeAt(e)); )
      e++;
    return e == t.text.length ? n : -1;
  }
  const KM = /^[ \t]*$/, pae = /-->/, gae = /\?>/, JM = [
    [
      /^<(?:script|pre|style)(?:\s|>|$)/i,
      /<\/(?:script|pre|style)>/i
    ],
    [
      /^\s*<!--/,
      pae
    ],
    [
      /^\s*<\?/,
      gae
    ],
    [
      /^\s*<![A-Z]/,
      />/
    ],
    [
      /^\s*<!\[CDATA\[/,
      /\]\]>/
    ],
    [
      /^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,
      KM
    ],
    [
      /^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,
      KM
    ]
  ];
  function mae(t, e, n) {
    if (t.next != 60)
      return -1;
    let r = t.text.slice(t.pos);
    for (let i = 0, s = JM.length - (n ? 1 : 0); i < s; i++)
      if (JM[i][0].test(r))
        return i;
    return -1;
  }
  function KU(t, e) {
    let n = t.countIndent(e, t.pos, t.indent), r = t.countIndent(t.skipSpace(e), e, n);
    return r >= n + 5 ? n + 1 : r;
  }
  function ph(t, e, n) {
    let r = t.length - 1;
    r >= 0 && t[r].to == e && t[r].type == we.CodeText ? t[r].to = n : t.push(Et(we.CodeText, e, n));
  }
  const fx = {
    LinkReference: void 0,
    IndentedCode(t, e) {
      let n = e.baseIndent + 4;
      if (e.indent < n)
        return false;
      let r = e.findColumn(n), i = t.lineStart + r, s = t.lineStart + e.text.length, o = [], a = [];
      for (ph(o, i, s); t.nextLine() && e.depth >= t.stack.length; )
        if (e.pos == e.text.length) {
          ph(a, t.lineStart - 1, t.lineStart);
          for (let l of e.markers)
            a.push(l);
        } else {
          if (e.indent < n)
            break;
          {
            if (a.length) {
              for (let c of a)
                c.type == we.CodeText ? ph(o, c.from, c.to) : o.push(c);
              a = [];
            }
            ph(o, t.lineStart - 1, t.lineStart);
            for (let c of e.markers)
              o.push(c);
            s = t.lineStart + e.text.length;
            let l = t.lineStart + e.findColumn(e.baseIndent + 4);
            l < s && ph(o, l, s);
          }
        }
      return a.length && (a = a.filter((l) => l.type != we.CodeText), a.length && (e.markers = a.concat(e.markers))), t.addNode(t.buffer.writeElements(o, -i).finish(we.CodeBlock, s - i), i), true;
    },
    FencedCode(t, e) {
      let n = cae(e);
      if (n < 0)
        return false;
      let r = t.lineStart + e.pos, i = e.next, s = n - e.pos, o = e.skipSpace(n), a = qU(e.text, e.text.length, o), l = [
        Et(we.CodeMark, r, r + s)
      ];
      o < a && l.push(Et(we.CodeInfo, t.lineStart + o, t.lineStart + a));
      for (let c = true; t.nextLine() && e.depth >= t.stack.length; c = false) {
        let u = e.pos;
        if (e.indent - e.baseIndent < 4)
          for (; u < e.text.length && e.text.charCodeAt(u) == i; )
            u++;
        if (u - e.pos >= s && e.skipSpace(u) == e.text.length) {
          for (let d of e.markers)
            l.push(d);
          l.push(Et(we.CodeMark, t.lineStart + e.pos, t.lineStart + u)), t.nextLine();
          break;
        } else {
          c || ph(l, t.lineStart - 1, t.lineStart);
          for (let f of e.markers)
            l.push(f);
          let d = t.lineStart + e.basePos, h = t.lineStart + e.text.length;
          d < h && ph(l, d, h);
        }
      }
      return t.addNode(t.buffer.writeElements(l, -r).finish(we.FencedCode, t.prevLineEnd() - r), r), true;
    },
    Blockquote(t, e) {
      let n = uae(e);
      return n < 0 ? false : (t.startContext(we.Blockquote, e.pos), t.addNode(we.QuoteMark, t.lineStart + e.pos, t.lineStart + e.pos + 1), e.moveBase(e.pos + n), null);
    },
    HorizontalRule(t, e) {
      if (Vj(e, t, false) < 0)
        return false;
      let n = t.lineStart + e.pos;
      return t.nextLine(), t.addNode(we.HorizontalRule, n), true;
    },
    BulletList(t, e) {
      let n = Xj(e, t, false);
      if (n < 0)
        return false;
      t.block.type != we.BulletList && t.startContext(we.BulletList, e.basePos, e.next);
      let r = KU(e, e.pos + 1);
      return t.startContext(we.ListItem, e.basePos, r - e.baseIndent), t.addNode(we.ListMark, t.lineStart + e.pos, t.lineStart + e.pos + n), e.moveBaseColumn(r), null;
    },
    OrderedList(t, e) {
      let n = Wj(e, t, false);
      if (n < 0)
        return false;
      t.block.type != we.OrderedList && t.startContext(we.OrderedList, e.basePos, e.text.charCodeAt(e.pos + n - 1));
      let r = KU(e, e.pos + n);
      return t.startContext(we.ListItem, e.basePos, r - e.baseIndent), t.addNode(we.ListMark, t.lineStart + e.pos, t.lineStart + e.pos + n), e.moveBaseColumn(r), null;
    },
    ATXHeading(t, e) {
      let n = hae(e);
      if (n < 0)
        return false;
      let r = e.pos, i = t.lineStart + r, s = qU(e.text, e.text.length, r), o = s;
      for (; o > r && e.text.charCodeAt(o - 1) == e.next; )
        o--;
      (o == s || o == r || !aa(e.text.charCodeAt(o - 1))) && (o = e.text.length);
      let a = t.buffer.write(we.HeaderMark, 0, n).writeElements(t.parser.parseInline(e.text.slice(r + n + 1, o), i + n + 1), -i);
      o < e.text.length && a.write(we.HeaderMark, o - r, s - r);
      let l = a.finish(we.ATXHeading1 - 1 + n, e.text.length - r);
      return t.nextLine(), t.addNode(l, i), true;
    },
    HTMLBlock(t, e) {
      let n = mae(e, t, false);
      if (n < 0)
        return false;
      let r = t.lineStart + e.pos, i = JM[n][1], s = [], o = i != KM;
      for (; !i.test(e.text) && t.nextLine(); ) {
        if (e.depth < t.stack.length) {
          o = false;
          break;
        }
        for (let c of e.markers)
          s.push(c);
      }
      o && t.nextLine();
      let a = i == pae ? we.CommentBlock : i == gae ? we.ProcessingInstructionBlock : we.HTMLBlock, l = t.prevLineEnd();
      return t.addNode(t.buffer.writeElements(s, -r).finish(a, l - r), r), true;
    },
    SetextHeading: void 0
  };
  class Wqe {
    constructor(e) {
      this.stage = 0, this.elts = [], this.pos = 0, this.start = e.start, this.advance(e.content);
    }
    nextLine(e, n, r) {
      if (this.stage == -1)
        return false;
      let i = r.content + `
` + n.scrub(), s = this.advance(i);
      return s > -1 && s < i.length ? this.complete(e, r, s) : false;
    }
    finish(e, n) {
      return (this.stage == 2 || this.stage == 3) && uv(n.content, this.pos) == n.content.length ? this.complete(e, n, n.content.length) : false;
    }
    complete(e, n, r) {
      return e.addLeafElement(n, Et(we.LinkReference, this.start, this.start + r, this.elts)), true;
    }
    nextStage(e) {
      return e ? (this.pos = e.to - this.start, this.elts.push(e), this.stage++, true) : (e === false && (this.stage = -1), false);
    }
    advance(e) {
      for (; ; ) {
        if (this.stage == -1)
          return -1;
        if (this.stage == 0) {
          if (!this.nextStage(Cae(e, this.pos, this.start, true)))
            return -1;
          if (e.charCodeAt(this.pos) != 58)
            return this.stage = -1;
          this.elts.push(Et(we.LinkMark, this.pos + this.start, this.pos + this.start + 1)), this.pos++;
        } else if (this.stage == 1) {
          if (!this.nextStage(kae(e, uv(e, this.pos), this.start)))
            return -1;
        } else if (this.stage == 2) {
          let n = uv(e, this.pos), r = 0;
          if (n > this.pos) {
            let i = Pae(e, n, this.start);
            if (i) {
              let s = c$(e, i.to - this.start);
              s > 0 && (this.nextStage(i), r = s);
            }
          }
          return r || (r = c$(e, this.pos)), r > 0 && r < e.length ? r : -1;
        } else
          return c$(e, this.pos);
      }
    }
  }
  function c$(t, e) {
    for (; e < t.length; e++) {
      let n = t.charCodeAt(e);
      if (n == 10)
        break;
      if (!aa(n))
        return -1;
    }
    return e;
  }
  class Zqe {
    nextLine(e, n, r) {
      let i = n.depth < e.stack.length ? -1 : fae(n), s = n.next;
      if (i < 0)
        return false;
      let o = Et(we.HeaderMark, e.lineStart + n.pos, e.lineStart + i);
      return e.nextLine(), e.addLeafElement(r, Et(s == 61 ? we.SetextHeading1 : we.SetextHeading2, r.start, e.prevLineEnd(), [
        ...e.parser.parseInline(r.content, r.start),
        o
      ])), true;
    }
    finish() {
      return false;
    }
  }
  const yae = {
    LinkReference(t, e) {
      return e.content.charCodeAt(0) == 91 ? new Wqe(e) : null;
    },
    SetextHeading() {
      return new Zqe();
    }
  }, Hqe = [
    (t, e) => hae(e) >= 0,
    (t, e) => cae(e) >= 0,
    (t, e) => uae(e) >= 0,
    (t, e) => Xj(e, t, true) >= 0,
    (t, e) => Wj(e, t, true) >= 0,
    (t, e) => Vj(e, t, true) >= 0,
    (t, e) => mae(e, t, true) >= 0
  ], Yqe = {
    text: "",
    end: 0
  };
  class Gqe {
    constructor(e, n, r, i) {
      this.parser = e, this.input = n, this.ranges = i, this.line = new Xqe(), this.atEnd = false, this.reusePlaceholders = /* @__PURE__ */ new Map(), this.stoppedAt = null, this.rangeI = 0, this.to = i[i.length - 1].to, this.lineStart = this.absoluteLineStart = this.absoluteLineEnd = i[0].from, this.block = yP.create(we.Document, 0, this.lineStart, 0, 0), this.stack = [
        this.block
      ], this.fragments = r.length ? new eKe(r, n) : null, this.readLine();
    }
    get parsedPos() {
      return this.absoluteLineStart;
    }
    advance() {
      if (this.stoppedAt != null && this.absoluteLineStart > this.stoppedAt)
        return this.finish();
      let { line: e } = this;
      for (; ; ) {
        for (let r = 0; ; ) {
          let i = e.depth < this.stack.length ? this.stack[this.stack.length - 1] : null;
          for (; r < e.markers.length && (!i || e.markers[r].from < i.end); ) {
            let s = e.markers[r++];
            this.addNode(s.type, s.from, s.to);
          }
          if (!i)
            break;
          this.finishContext();
        }
        if (e.pos < e.text.length)
          break;
        if (!this.nextLine())
          return this.finish();
      }
      if (this.fragments && this.reuseFragment(e.basePos))
        return null;
      e:
        for (; ; ) {
          for (let r of this.parser.blockParsers)
            if (r) {
              let i = r(this, e);
              if (i != false) {
                if (i == true)
                  return null;
                e.forward();
                continue e;
              }
            }
          break;
        }
      let n = new Vqe(this.lineStart + e.pos, e.text.slice(e.pos));
      for (let r of this.parser.leafBlockParsers)
        if (r) {
          let i = r(this, n);
          i && n.parsers.push(i);
        }
      e:
        for (; this.nextLine() && e.pos != e.text.length; ) {
          if (e.indent < e.baseIndent + 4) {
            for (let r of this.parser.endLeafBlock)
              if (r(this, e, n))
                break e;
          }
          for (let r of n.parsers)
            if (r.nextLine(this, e, n))
              return null;
          n.content += `
` + e.scrub();
          for (let r of e.markers)
            n.marks.push(r);
        }
      return this.finishLeaf(n), null;
    }
    stopAt(e) {
      if (this.stoppedAt != null && this.stoppedAt < e)
        throw new RangeError("Can't move stoppedAt forward");
      this.stoppedAt = e;
    }
    reuseFragment(e) {
      if (!this.fragments.moveTo(this.absoluteLineStart + e, this.absoluteLineStart) || !this.fragments.matches(this.block.hash))
        return false;
      let n = this.fragments.takeNodes(this);
      return n ? (this.absoluteLineStart += n, this.lineStart = _ae(this.absoluteLineStart, this.ranges), this.moveRangeI(), this.absoluteLineStart < this.to ? (this.lineStart++, this.absoluteLineStart++, this.readLine()) : (this.atEnd = true, this.readLine()), true) : false;
    }
    get depth() {
      return this.stack.length;
    }
    parentType(e = this.depth - 1) {
      return this.parser.nodeSet.types[this.stack[e].type];
    }
    nextLine() {
      return this.lineStart += this.line.text.length, this.absoluteLineEnd >= this.to ? (this.absoluteLineStart = this.absoluteLineEnd, this.atEnd = true, this.readLine(), false) : (this.lineStart++, this.absoluteLineStart = this.absoluteLineEnd + 1, this.moveRangeI(), this.readLine(), true);
    }
    peekLine() {
      return this.scanLine(this.absoluteLineEnd + 1).text;
    }
    moveRangeI() {
      for (; this.rangeI < this.ranges.length - 1 && this.absoluteLineStart >= this.ranges[this.rangeI].to; )
        this.rangeI++, this.absoluteLineStart = Math.max(this.absoluteLineStart, this.ranges[this.rangeI].from);
    }
    scanLine(e) {
      let n = Yqe;
      if (n.end = e, e >= this.to)
        n.text = "";
      else if (n.text = this.lineChunkAt(e), n.end += n.text.length, this.ranges.length > 1) {
        let r = this.absoluteLineStart, i = this.rangeI;
        for (; this.ranges[i].to < n.end; ) {
          i++;
          let s = this.ranges[i].from, o = this.lineChunkAt(s);
          n.end = s + o.length, n.text = n.text.slice(0, this.ranges[i - 1].to - r) + o, r = n.end - n.text.length;
        }
      }
      return n;
    }
    readLine() {
      let { line: e } = this, { text: n, end: r } = this.scanLine(this.absoluteLineStart);
      for (this.absoluteLineEnd = r, e.reset(n); e.depth < this.stack.length; e.depth++) {
        let i = this.stack[e.depth], s = this.parser.skipContextMarkup[i.type];
        if (!s)
          throw new Error("Unhandled block context " + we[i.type]);
        if (!s(i, this, e))
          break;
        e.forward();
      }
    }
    lineChunkAt(e) {
      let n = this.input.chunk(e), r;
      if (this.input.lineChunks)
        r = n == `
` ? "" : n;
      else {
        let i = n.indexOf(`
`);
        r = i < 0 ? n : n.slice(0, i);
      }
      return e + r.length > this.to ? r.slice(0, this.to - e) : r;
    }
    prevLineEnd() {
      return this.atEnd ? this.lineStart : this.lineStart - 1;
    }
    startContext(e, n, r = 0) {
      this.block = yP.create(e, r, this.lineStart + n, this.block.hash, this.lineStart + this.line.text.length), this.stack.push(this.block);
    }
    startComposite(e, n, r = 0) {
      this.startContext(this.parser.getNodeType(e), n, r);
    }
    addNode(e, n, r) {
      typeof e == "number" && (e = new At(this.parser.nodeSet.types[e], um, um, (r ?? this.prevLineEnd()) - n)), this.block.addChild(e, n - this.block.from);
    }
    addElement(e) {
      this.block.addChild(e.toTree(this.parser.nodeSet), e.from - this.block.from);
    }
    addLeafElement(e, n) {
      this.addNode(this.buffer.writeElements(nD(n.children, e.marks), -n.from).finish(n.type, n.to - n.from), n.from);
    }
    finishContext() {
      let e = this.stack.pop(), n = this.stack[this.stack.length - 1];
      n.addChild(e.toTree(this.parser.nodeSet), e.from - n.from), this.block = n;
    }
    finish() {
      for (; this.stack.length > 1; )
        this.finishContext();
      return this.addGaps(this.block.toTree(this.parser.nodeSet, this.lineStart));
    }
    addGaps(e) {
      return this.ranges.length > 1 ? vae(this.ranges, 0, e.topNode, this.ranges[0].from, this.reusePlaceholders) : e;
    }
    finishLeaf(e) {
      for (let r of e.parsers)
        if (r.finish(this, e))
          return;
      let n = nD(this.parser.parseInline(e.content, e.start), e.marks);
      this.addNode(this.buffer.writeElements(n, -e.start).finish(we.Paragraph, e.content.length), e.start);
    }
    elt(e, n, r, i) {
      return typeof e == "string" ? Et(this.parser.getNodeType(e), n, r, i) : new wae(e, n);
    }
    get buffer() {
      return new Sae(this.parser.nodeSet);
    }
  }
  function vae(t, e, n, r, i) {
    let s = t[e].to, o = [], a = [], l = n.from + r;
    function c(u, d) {
      for (; d ? u >= s : u > s; ) {
        let h = t[e + 1].from - s;
        r += h, u += h, e++, s = t[e].to;
      }
    }
    for (let u = n.firstChild; u; u = u.nextSibling) {
      c(u.from + r, true);
      let d = u.from + r, h, f = i.get(u.tree);
      f ? h = f : u.to + r > s ? (h = vae(t, e, u, r, i), c(u.to + r, false)) : h = u.toTree(), o.push(h), a.push(d - l);
    }
    return c(n.to + r, false), new At(n.type, o, a, n.to + r - l, n.tree ? n.tree.propValues : void 0);
  }
  class M2 extends $2 {
    constructor(e, n, r, i, s, o, a, l, c) {
      super(), this.nodeSet = e, this.blockParsers = n, this.leafBlockParsers = r, this.blockNames = i, this.endLeafBlock = s, this.skipContextMarkup = o, this.inlineParsers = a, this.inlineNames = l, this.wrappers = c, this.nodeTypes = /* @__PURE__ */ Object.create(null);
      for (let u of e.types)
        this.nodeTypes[u.name] = u.id;
    }
    createParse(e, n, r) {
      let i = new Gqe(this, e, n, r);
      for (let s of this.wrappers)
        i = s(i, e, n, r);
      return i;
    }
    configure(e) {
      let n = eD(e);
      if (!n)
        return this;
      let { nodeSet: r, skipContextMarkup: i } = this, s = this.blockParsers.slice(), o = this.leafBlockParsers.slice(), a = this.blockNames.slice(), l = this.inlineParsers.slice(), c = this.inlineNames.slice(), u = this.endLeafBlock.slice(), d = this.wrappers;
      if (a0(n.defineNodes)) {
        i = Object.assign({}, i);
        let h = r.types.slice(), f;
        for (let y of n.defineNodes) {
          let { name: g, block: O, composite: S, style: w } = typeof y == "string" ? {
            name: y
          } : y;
          if (h.some((C) => C.name == g))
            continue;
          S && (i[h.length] = (C, _, T) => S(_, T, C.value));
          let x = h.length, P = S ? [
            "Block",
            "BlockContext"
          ] : O ? x >= we.ATXHeading1 && x <= we.SetextHeading2 ? [
            "Block",
            "LeafBlock",
            "Heading"
          ] : [
            "Block",
            "LeafBlock"
          ] : void 0;
          h.push(Tr.define({
            id: x,
            name: g,
            props: P && [
              [
                ut.group,
                P
              ]
            ]
          })), w && (f || (f = {}), Array.isArray(w) || w instanceof Js ? f[g] = w : Object.assign(f, w));
        }
        r = new Qm(h), f && (r = r.extend(zm(f)));
      }
      if (a0(n.props) && (r = r.extend(...n.props)), a0(n.remove))
        for (let h of n.remove) {
          let f = this.blockNames.indexOf(h), y = this.inlineNames.indexOf(h);
          f > -1 && (s[f] = o[f] = void 0), y > -1 && (l[y] = void 0);
        }
      if (a0(n.parseBlock))
        for (let h of n.parseBlock) {
          let f = a.indexOf(h.name);
          if (f > -1)
            s[f] = h.parse, o[f] = h.leaf;
          else {
            let y = h.before ? px(a, h.before) : h.after ? px(a, h.after) + 1 : a.length - 1;
            s.splice(y, 0, h.parse), o.splice(y, 0, h.leaf), a.splice(y, 0, h.name);
          }
          h.endLeaf && u.push(h.endLeaf);
        }
      if (a0(n.parseInline))
        for (let h of n.parseInline) {
          let f = c.indexOf(h.name);
          if (f > -1)
            l[f] = h.parse;
          else {
            let y = h.before ? px(c, h.before) : h.after ? px(c, h.after) + 1 : c.length - 1;
            l.splice(y, 0, h.parse), c.splice(y, 0, h.name);
          }
        }
      return n.wrap && (d = d.concat(n.wrap)), new M2(r, s, o, a, u, i, l, c, d);
    }
    getNodeType(e) {
      let n = this.nodeTypes[e];
      if (n == null)
        throw new RangeError(`Unknown node type '${e}'`);
      return n;
    }
    parseInline(e, n) {
      let r = new Kqe(this, e, n);
      e:
        for (let i = n; i < r.end; ) {
          let s = r.char(i);
          for (let o of this.inlineParsers)
            if (o) {
              let a = o(r, s, i);
              if (a >= 0) {
                i = a;
                continue e;
              }
            }
          i++;
        }
      return r.resolveMarkers(0);
    }
  }
  function a0(t) {
    return t != null && t.length > 0;
  }
  function eD(t) {
    if (!Array.isArray(t))
      return t;
    if (t.length == 0)
      return null;
    let e = eD(t[0]);
    if (t.length == 1)
      return e;
    let n = eD(t.slice(1));
    if (!n || !e)
      return e || n;
    let r = (o, a) => (o || um).concat(a || um), i = e.wrap, s = n.wrap;
    return {
      props: r(e.props, n.props),
      defineNodes: r(e.defineNodes, n.defineNodes),
      parseBlock: r(e.parseBlock, n.parseBlock),
      parseInline: r(e.parseInline, n.parseInline),
      remove: r(e.remove, n.remove),
      wrap: i ? s ? (o, a, l, c) => i(s(o, a, l, c), a, l, c) : i : s
    };
  }
  function px(t, e) {
    let n = t.indexOf(e);
    if (n < 0)
      throw new RangeError(`Position specified relative to unknown parser ${e}`);
    return n;
  }
  let Oae = [
    Tr.none
  ];
  for (let t = 1, e; e = we[t]; t++)
    Oae[t] = Tr.define({
      id: t,
      name: e,
      props: t >= we.Escape ? [] : [
        [
          ut.group,
          t in lae ? [
            "Block",
            "BlockContext"
          ] : [
            "Block",
            "LeafBlock"
          ]
        ]
      ],
      top: e == "Document"
    });
  const um = [];
  let Sae = class {
    constructor(e) {
      this.nodeSet = e, this.content = [], this.nodes = [];
    }
    write(e, n, r, i = 0) {
      return this.content.push(e, n, r, 4 + i * 4), this;
    }
    writeElements(e, n = 0) {
      for (let r of e)
        r.writeTo(this, n);
      return this;
    }
    finish(e, n) {
      return At.build({
        buffer: this.content,
        nodeSet: this.nodeSet,
        reused: this.nodes,
        topID: e,
        length: n
      });
    }
  }, bO = class {
    constructor(e, n, r, i = um) {
      this.type = e, this.from = n, this.to = r, this.children = i;
    }
    writeTo(e, n) {
      let r = e.content.length;
      e.writeElements(this.children, n), e.content.push(this.type, this.from + n, this.to + n, e.content.length + 4 - r);
    }
    toTree(e) {
      return new Sae(e).writeElements(this.children, -this.from).finish(this.type, this.to - this.from);
    }
  };
  class wae {
    constructor(e, n) {
      this.tree = e, this.from = n;
    }
    get to() {
      return this.from + this.tree.length;
    }
    get type() {
      return this.tree.type.id;
    }
    get children() {
      return um;
    }
    writeTo(e, n) {
      e.nodes.push(this.tree), e.content.push(e.nodes.length - 1, this.from + n, this.to + n, -1);
    }
    toTree() {
      return this.tree;
    }
  }
  function Et(t, e, n, r) {
    return new bO(t, e, n, r);
  }
  const xae = {
    resolve: "Emphasis",
    mark: "EmphasisMark"
  }, bae = {
    resolve: "Emphasis",
    mark: "EmphasisMark"
  }, Mp = {}, tD = {};
  class Mo {
    constructor(e, n, r, i) {
      this.type = e, this.from = n, this.to = r, this.side = i;
    }
  }
  const JU = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
  let kO = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;
  try {
    kO = new RegExp("[\\p{S}|\\p{P}]", "u");
  } catch {
  }
  const u$ = {
    Escape(t, e, n) {
      if (e != 92 || n == t.end - 1)
        return -1;
      let r = t.char(n + 1);
      for (let i = 0; i < JU.length; i++)
        if (JU.charCodeAt(i) == r)
          return t.append(Et(we.Escape, n, n + 2));
      return -1;
    },
    Entity(t, e, n) {
      if (e != 38)
        return -1;
      let r = /^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(t.slice(n + 1, n + 31));
      return r ? t.append(Et(we.Entity, n, n + 1 + r[0].length)) : -1;
    },
    InlineCode(t, e, n) {
      if (e != 96 || n && t.char(n - 1) == 96)
        return -1;
      let r = n + 1;
      for (; r < t.end && t.char(r) == 96; )
        r++;
      let i = r - n, s = 0;
      for (; r < t.end; r++)
        if (t.char(r) == 96) {
          if (s++, s == i && t.char(r + 1) != 96)
            return t.append(Et(we.InlineCode, n, r + 1, [
              Et(we.CodeMark, n, n + i),
              Et(we.CodeMark, r + 1 - i, r + 1)
            ]));
        } else
          s = 0;
      return -1;
    },
    HTMLTag(t, e, n) {
      if (e != 60 || n == t.end - 1)
        return -1;
      let r = t.slice(n + 1, t.end), i = /^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(r);
      if (i)
        return t.append(Et(we.Autolink, n, n + 1 + i[0].length, [
          Et(we.LinkMark, n, n + 1),
          Et(we.URL, n + 1, n + i[0].length),
          Et(we.LinkMark, n + i[0].length, n + 1 + i[0].length)
        ]));
      let s = /^!--[^>](?:-[^-]|[^-])*?-->/i.exec(r);
      if (s)
        return t.append(Et(we.Comment, n, n + 1 + s[0].length));
      let o = /^\?[^]*?\?>/.exec(r);
      if (o)
        return t.append(Et(we.ProcessingInstruction, n, n + 1 + o[0].length));
      let a = /^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(r);
      return a ? t.append(Et(we.HTMLTag, n, n + 1 + a[0].length)) : -1;
    },
    Emphasis(t, e, n) {
      if (e != 95 && e != 42)
        return -1;
      let r = n + 1;
      for (; t.char(r) == e; )
        r++;
      let i = t.slice(n - 1, n), s = t.slice(r, r + 1), o = kO.test(i), a = kO.test(s), l = /\s|^$/.test(i), c = /\s|^$/.test(s), u = !c && (!a || l || o), d = !l && (!o || c || a), h = u && (e == 42 || !d || o), f = d && (e == 42 || !u || a);
      return t.append(new Mo(e == 95 ? xae : bae, n, r, (h ? 1 : 0) | (f ? 2 : 0)));
    },
    HardBreak(t, e, n) {
      if (e == 92 && t.char(n + 1) == 10)
        return t.append(Et(we.HardBreak, n, n + 2));
      if (e == 32) {
        let r = n + 1;
        for (; t.char(r) == 32; )
          r++;
        if (t.char(r) == 10 && r >= n + 2)
          return t.append(Et(we.HardBreak, n, r + 1));
      }
      return -1;
    },
    Link(t, e, n) {
      return e == 91 ? t.append(new Mo(Mp, n, n + 1, 1)) : -1;
    },
    Image(t, e, n) {
      return e == 33 && t.char(n + 1) == 91 ? t.append(new Mo(tD, n, n + 2, 1)) : -1;
    },
    LinkEnd(t, e, n) {
      if (e != 93)
        return -1;
      for (let r = t.parts.length - 1; r >= 0; r--) {
        let i = t.parts[r];
        if (i instanceof Mo && (i.type == Mp || i.type == tD)) {
          if (!i.side || t.skipSpace(i.to) == n && !/[(\[]/.test(t.slice(n + 1, n + 2)))
            return t.parts[r] = null, -1;
          let s = t.takeContent(r), o = t.parts[r] = qqe(t, s, i.type == Mp ? we.Link : we.Image, i.from, n + 1);
          if (i.type == Mp)
            for (let a = 0; a < r; a++) {
              let l = t.parts[a];
              l instanceof Mo && l.type == Mp && (l.side = 0);
            }
          return o.to;
        }
      }
      return -1;
    }
  };
  function qqe(t, e, n, r, i) {
    let { text: s } = t, o = t.char(i), a = i;
    if (e.unshift(Et(we.LinkMark, r, r + (n == we.Image ? 2 : 1))), e.push(Et(we.LinkMark, i - 1, i)), o == 40) {
      let l = t.skipSpace(i + 1), c = kae(s, l - t.offset, t.offset), u;
      c && (l = t.skipSpace(c.to), l != c.to && (u = Pae(s, l - t.offset, t.offset), u && (l = t.skipSpace(u.to)))), t.char(l) == 41 && (e.push(Et(we.LinkMark, i, i + 1)), a = l + 1, c && e.push(c), u && e.push(u), e.push(Et(we.LinkMark, l, a)));
    } else if (o == 91) {
      let l = Cae(s, i - t.offset, t.offset, false);
      l && (e.push(l), a = l.to);
    }
    return Et(n, r, a, e);
  }
  function kae(t, e, n) {
    if (t.charCodeAt(e) == 60) {
      for (let i = e + 1; i < t.length; i++) {
        let s = t.charCodeAt(i);
        if (s == 62)
          return Et(we.URL, e + n, i + 1 + n);
        if (s == 60 || s == 10)
          return false;
      }
      return null;
    } else {
      let i = 0, s = e;
      for (let o = false; s < t.length; s++) {
        let a = t.charCodeAt(s);
        if (aa(a))
          break;
        if (o)
          o = false;
        else if (a == 40)
          i++;
        else if (a == 41) {
          if (!i)
            break;
          i--;
        } else
          a == 92 && (o = true);
      }
      return s > e ? Et(we.URL, e + n, s + n) : s == t.length ? null : false;
    }
  }
  function Pae(t, e, n) {
    let r = t.charCodeAt(e);
    if (r != 39 && r != 34 && r != 40)
      return false;
    let i = r == 40 ? 41 : r;
    for (let s = e + 1, o = false; s < t.length; s++) {
      let a = t.charCodeAt(s);
      if (o)
        o = false;
      else {
        if (a == i)
          return Et(we.LinkTitle, e + n, s + 1 + n);
        a == 92 && (o = true);
      }
    }
    return null;
  }
  function Cae(t, e, n, r) {
    for (let i = false, s = e + 1, o = Math.min(t.length, s + 999); s < o; s++) {
      let a = t.charCodeAt(s);
      if (i)
        i = false;
      else {
        if (a == 93)
          return r ? false : Et(we.LinkLabel, e + n, s + 1 + n);
        if (r && !aa(a) && (r = false), a == 91)
          return false;
        a == 92 && (i = true);
      }
    }
    return null;
  }
  class Kqe {
    constructor(e, n, r) {
      this.parser = e, this.text = n, this.offset = r, this.parts = [];
    }
    char(e) {
      return e >= this.end ? -1 : this.text.charCodeAt(e - this.offset);
    }
    get end() {
      return this.offset + this.text.length;
    }
    slice(e, n) {
      return this.text.slice(e - this.offset, n - this.offset);
    }
    append(e) {
      return this.parts.push(e), e.to;
    }
    addDelimiter(e, n, r, i, s) {
      return this.append(new Mo(e, n, r, (i ? 1 : 0) | (s ? 2 : 0)));
    }
    get hasOpenLink() {
      for (let e = this.parts.length - 1; e >= 0; e--) {
        let n = this.parts[e];
        if (n instanceof Mo && (n.type == Mp || n.type == tD))
          return true;
      }
      return false;
    }
    addElement(e) {
      return this.append(e);
    }
    resolveMarkers(e) {
      for (let r = e; r < this.parts.length; r++) {
        let i = this.parts[r];
        if (!(i instanceof Mo && i.type.resolve && i.side & 2))
          continue;
        let s = i.type == xae || i.type == bae, o = i.to - i.from, a, l = r - 1;
        for (; l >= e; l--) {
          let g = this.parts[l];
          if (g instanceof Mo && g.side & 1 && g.type == i.type && !(s && (i.side & 1 || g.side & 2) && (g.to - g.from + o) % 3 == 0 && ((g.to - g.from) % 3 || o % 3))) {
            a = g;
            break;
          }
        }
        if (!a)
          continue;
        let c = i.type.resolve, u = [], d = a.from, h = i.to;
        if (s) {
          let g = Math.min(2, a.to - a.from, o);
          d = a.to - g, h = i.from + g, c = g == 1 ? "Emphasis" : "StrongEmphasis";
        }
        a.type.mark && u.push(this.elt(a.type.mark, d, a.to));
        for (let g = l + 1; g < r; g++)
          this.parts[g] instanceof bO && u.push(this.parts[g]), this.parts[g] = null;
        i.type.mark && u.push(this.elt(i.type.mark, i.from, h));
        let f = this.elt(c, d, h, u);
        this.parts[l] = s && a.from != d ? new Mo(a.type, a.from, d, a.side) : null, (this.parts[r] = s && i.to != h ? new Mo(i.type, h, i.to, i.side) : null) ? this.parts.splice(r, 0, f) : this.parts[r] = f;
      }
      let n = [];
      for (let r = e; r < this.parts.length; r++) {
        let i = this.parts[r];
        i instanceof bO && n.push(i);
      }
      return n;
    }
    findOpeningDelimiter(e) {
      for (let n = this.parts.length - 1; n >= 0; n--) {
        let r = this.parts[n];
        if (r instanceof Mo && r.type == e)
          return n;
      }
      return null;
    }
    takeContent(e) {
      let n = this.resolveMarkers(e);
      return this.parts.length = e, n;
    }
    skipSpace(e) {
      return uv(this.text, e - this.offset) + this.offset;
    }
    elt(e, n, r, i) {
      return typeof e == "string" ? Et(this.parser.getNodeType(e), n, r, i) : new wae(e, n);
    }
  }
  function nD(t, e) {
    if (!e.length)
      return t;
    if (!t.length)
      return e;
    let n = t.slice(), r = 0;
    for (let i of e) {
      for (; r < n.length && n[r].to < i.to; )
        r++;
      if (r < n.length && n[r].from < i.from) {
        let s = n[r];
        s instanceof bO && (n[r] = new bO(s.type, s.from, s.to, nD(s.children, [
          i
        ])));
      } else
        n.splice(r++, 0, i);
    }
    return n;
  }
  const Jqe = [
    we.CodeBlock,
    we.ListItem,
    we.OrderedList,
    we.BulletList
  ];
  let eKe = class {
    constructor(e, n) {
      this.fragments = e, this.input = n, this.i = 0, this.fragment = null, this.fragmentEnd = -1, this.cursor = null, e.length && (this.fragment = e[this.i++]);
    }
    nextFragment() {
      this.fragment = this.i < this.fragments.length ? this.fragments[this.i++] : null, this.cursor = null, this.fragmentEnd = -1;
    }
    moveTo(e, n) {
      for (; this.fragment && this.fragment.to <= e; )
        this.nextFragment();
      if (!this.fragment || this.fragment.from > (e ? e - 1 : 0))
        return false;
      if (this.fragmentEnd < 0) {
        let s = this.fragment.to;
        for (; s > 0 && this.input.read(s - 1, s) != `
`; )
          s--;
        this.fragmentEnd = s ? s - 1 : 0;
      }
      let r = this.cursor;
      r || (r = this.cursor = this.fragment.tree.cursor(), r.firstChild());
      let i = e + this.fragment.offset;
      for (; r.to <= i; )
        if (!r.parent())
          return false;
      for (; ; ) {
        if (r.from >= i)
          return this.fragment.from <= n;
        if (!r.childAfter(i))
          return false;
      }
    }
    matches(e) {
      let n = this.cursor.tree;
      return n && n.prop(ut.contextHash) == e;
    }
    takeNodes(e) {
      let n = this.cursor, r = this.fragment.offset, i = this.fragmentEnd - (this.fragment.openEnd ? 1 : 0), s = e.absoluteLineStart, o = s, a = e.block.children.length, l = o, c = a;
      for (; ; ) {
        if (n.to - r > i) {
          if (n.type.isAnonymous && n.firstChild())
            continue;
          break;
        }
        let u = _ae(n.from - r, e.ranges);
        if (n.to - r <= e.ranges[e.rangeI].to)
          e.addNode(n.tree, u);
        else {
          let d = new At(e.parser.nodeSet.types[we.Paragraph], [], [], 0, e.block.hashProp);
          e.reusePlaceholders.set(d, n.tree), e.addNode(d, u);
        }
        if (n.type.is("Block") && (Jqe.indexOf(n.type.id) < 0 ? (o = n.to - r, a = e.block.children.length) : (o = l, a = c, l = n.to - r, c = e.block.children.length)), !n.nextSibling())
          break;
      }
      for (; e.block.children.length > a; )
        e.block.children.pop(), e.block.positions.pop();
      return o - s;
    }
  };
  function _ae(t, e) {
    let n = t;
    for (let r = 1; r < e.length; r++) {
      let i = e[r - 1].to, s = e[r].from;
      i < t && (n -= s - i);
    }
    return n;
  }
  const tKe = zm({
    "Blockquote/...": V.quote,
    HorizontalRule: V.contentSeparator,
    "ATXHeading1/... SetextHeading1/...": V.heading1,
    "ATXHeading2/... SetextHeading2/...": V.heading2,
    "ATXHeading3/...": V.heading3,
    "ATXHeading4/...": V.heading4,
    "ATXHeading5/...": V.heading5,
    "ATXHeading6/...": V.heading6,
    "Comment CommentBlock": V.comment,
    Escape: V.escape,
    Entity: V.character,
    "Emphasis/...": V.emphasis,
    "StrongEmphasis/...": V.strong,
    "Link/... Image/...": V.link,
    "OrderedList/... BulletList/...": V.list,
    "BlockQuote/...": V.quote,
    "InlineCode CodeText": V.monospace,
    "URL Autolink": V.url,
    "HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark": V.processingInstruction,
    "CodeInfo LinkLabel": V.labelName,
    LinkTitle: V.string,
    Paragraph: V.content
  }), nKe = new M2(new Qm(Oae).extend(tKe), Object.keys(fx).map((t) => fx[t]), Object.keys(fx).map((t) => yae[t]), Object.keys(fx), Hqe, lae, Object.keys(u$).map((t) => u$[t]), Object.keys(u$), []);
  function rKe(t, e, n) {
    let r = [];
    for (let i = t.firstChild, s = e; ; i = i.nextSibling) {
      let o = i ? i.from : n;
      if (o > s && r.push({
        from: s,
        to: o
      }), !i)
        break;
      s = i.to;
    }
    return r;
  }
  function iKe(t) {
    let { codeParser: e, htmlParser: n } = t;
    return {
      wrap: joe((i, s) => {
        let o = i.type.id;
        if (e && (o == we.CodeBlock || o == we.FencedCode)) {
          let a = "";
          if (o == we.FencedCode) {
            let c = i.node.getChild(we.CodeInfo);
            c && (a = s.read(c.from, c.to));
          }
          let l = e(a);
          if (l)
            return {
              parser: l,
              overlay: (c) => c.type.id == we.CodeText
            };
        } else if (n && (o == we.HTMLBlock || o == we.HTMLTag || o == we.CommentBlock))
          return {
            parser: n,
            overlay: rKe(i.node, i.from, i.to)
          };
        return null;
      })
    };
  }
  const sKe = {
    resolve: "Strikethrough",
    mark: "StrikethroughMark"
  }, oKe = {
    defineNodes: [
      {
        name: "Strikethrough",
        style: {
          "Strikethrough/...": V.strikethrough
        }
      },
      {
        name: "StrikethroughMark",
        style: V.processingInstruction
      }
    ],
    parseInline: [
      {
        name: "Strikethrough",
        parse(t, e, n) {
          if (e != 126 || t.char(n + 1) != 126 || t.char(n + 2) == 126)
            return -1;
          let r = t.slice(n - 1, n), i = t.slice(n + 2, n + 3), s = /\s|^$/.test(r), o = /\s|^$/.test(i), a = kO.test(r), l = kO.test(i);
          return t.addDelimiter(sKe, n, n + 2, !o && (!l || s || a), !s && (!a || o || l));
        },
        after: "Emphasis"
      }
    ]
  };
  function dv(t, e, n = 0, r, i = 0) {
    let s = 0, o = true, a = -1, l = -1, c = false, u = () => {
      r.push(t.elt("TableCell", i + a, i + l, t.parser.parseInline(e.slice(a, l), i + a)));
    };
    for (let d = n; d < e.length; d++) {
      let h = e.charCodeAt(d);
      h == 124 && !c ? ((!o || a > -1) && s++, o = false, r && (a > -1 && u(), r.push(t.elt("TableDelimiter", d + i, d + i + 1))), a = l = -1) : (c || h != 32 && h != 9) && (a < 0 && (a = d), l = d + 1), c = !c && h == 92;
    }
    return a > -1 && (s++, r && u()), s;
  }
  function eV(t, e) {
    for (let n = e; n < t.length; n++) {
      let r = t.charCodeAt(n);
      if (r == 124)
        return true;
      r == 92 && n++;
    }
    return false;
  }
  const Tae = /^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;
  class tV {
    constructor() {
      this.rows = null;
    }
    nextLine(e, n, r) {
      if (this.rows == null) {
        this.rows = false;
        let i;
        if ((n.next == 45 || n.next == 58 || n.next == 124) && Tae.test(i = n.text.slice(n.pos))) {
          let s = [];
          dv(e, r.content, 0, s, r.start) == dv(e, i, n.pos) && (this.rows = [
            e.elt("TableHeader", r.start, r.start + r.content.length, s),
            e.elt("TableDelimiter", e.lineStart + n.pos, e.lineStart + n.text.length)
          ]);
        }
      } else if (this.rows) {
        let i = [];
        dv(e, n.text, n.pos, i, e.lineStart), this.rows.push(e.elt("TableRow", e.lineStart + n.pos, e.lineStart + n.text.length, i));
      }
      return false;
    }
    finish(e, n) {
      return this.rows ? (e.addLeafElement(n, e.elt("Table", n.start, n.start + n.content.length, this.rows)), true) : false;
    }
  }
  const aKe = {
    defineNodes: [
      {
        name: "Table",
        block: true
      },
      {
        name: "TableHeader",
        style: {
          "TableHeader/...": V.heading
        }
      },
      "TableRow",
      {
        name: "TableCell",
        style: V.content
      },
      {
        name: "TableDelimiter",
        style: V.processingInstruction
      }
    ],
    parseBlock: [
      {
        name: "Table",
        leaf(t, e) {
          return eV(e.content, 0) ? new tV() : null;
        },
        endLeaf(t, e, n) {
          if (n.parsers.some((i) => i instanceof tV) || !eV(e.text, e.basePos))
            return false;
          let r = t.peekLine();
          return Tae.test(r) && dv(t, e.text, e.basePos) == dv(t, r, e.basePos);
        },
        before: "SetextHeading"
      }
    ]
  };
  class lKe {
    nextLine() {
      return false;
    }
    finish(e, n) {
      return e.addLeafElement(n, e.elt("Task", n.start, n.start + n.content.length, [
        e.elt("TaskMarker", n.start, n.start + 3),
        ...e.parser.parseInline(n.content.slice(3), n.start + 3)
      ])), true;
    }
  }
  const cKe = {
    defineNodes: [
      {
        name: "Task",
        block: true,
        style: V.list
      },
      {
        name: "TaskMarker",
        style: V.atom
      }
    ],
    parseBlock: [
      {
        name: "TaskList",
        leaf(t, e) {
          return /^\[[ xX]\][ \t]/.test(e.content) && t.parentType().name == "ListItem" ? new lKe() : null;
        },
        after: "SetextHeading"
      }
    ]
  }, nV = /(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy, rV = /[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy, uKe = /[\w-]+\.[\w-]+($|\/)/, iV = /[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy, sV = /\/[a-zA-Z\d@.]+/gy;
  function oV(t, e, n, r) {
    let i = 0;
    for (let s = e; s < n; s++)
      t[s] == r && i++;
    return i;
  }
  function dKe(t, e) {
    rV.lastIndex = e;
    let n = rV.exec(t);
    if (!n || uKe.exec(n[0])[0].indexOf("_") > -1)
      return -1;
    let r = e + n[0].length;
    for (; ; ) {
      let i = t[r - 1], s;
      if (/[?!.,:*_~]/.test(i) || i == ")" && oV(t, e, r, ")") > oV(t, e, r, "("))
        r--;
      else if (i == ";" && (s = /&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(t.slice(e, r))))
        r = e + s.index;
      else
        break;
    }
    return r;
  }
  function aV(t, e) {
    iV.lastIndex = e;
    let n = iV.exec(t);
    if (!n)
      return -1;
    let r = n[0][n[0].length - 1];
    return r == "_" || r == "-" ? -1 : e + n[0].length - (r == "." ? 1 : 0);
  }
  const hKe = {
    parseInline: [
      {
        name: "Autolink",
        parse(t, e, n) {
          let r = n - t.offset;
          if (r && /\w/.test(t.text[r - 1]))
            return -1;
          nV.lastIndex = r;
          let i = nV.exec(t.text), s = -1;
          if (!i)
            return -1;
          if (i[1] || i[2]) {
            if (s = dKe(t.text, r + i[0].length), s > -1 && t.hasOpenLink) {
              let o = /([^\[\]]|\[[^\]]*\])*/.exec(t.text.slice(r, s));
              s = r + o[0].length;
            }
          } else
            i[3] ? s = aV(t.text, r) : (s = aV(t.text, r + i[0].length), s > -1 && i[0] == "xmpp:" && (sV.lastIndex = s, i = sV.exec(t.text), i && (s = i.index + i[0].length)));
          return s < 0 ? -1 : (t.addElement(t.elt("URL", n, s + t.offset)), s + t.offset);
        }
      }
    ]
  }, fKe = [
    aKe,
    cKe,
    oKe,
    hKe
  ];
  function Eae(t, e, n) {
    return (r, i, s) => {
      if (i != t || r.char(s + 1) == t)
        return -1;
      let o = [
        r.elt(n, s, s + 1)
      ];
      for (let a = s + 1; a < r.end; a++) {
        let l = r.char(a);
        if (l == t)
          return r.addElement(r.elt(e, s, a + 1, o.concat(r.elt(n, a, a + 1))));
        if (l == 92 && o.push(r.elt("Escape", a, a++ + 2)), aa(l))
          break;
      }
      return -1;
    };
  }
  const pKe = {
    defineNodes: [
      {
        name: "Superscript",
        style: V.special(V.content)
      },
      {
        name: "SuperscriptMark",
        style: V.processingInstruction
      }
    ],
    parseInline: [
      {
        name: "Superscript",
        parse: Eae(94, "Superscript", "SuperscriptMark")
      }
    ]
  }, gKe = {
    defineNodes: [
      {
        name: "Subscript",
        style: V.special(V.content)
      },
      {
        name: "SubscriptMark",
        style: V.processingInstruction
      }
    ],
    parseInline: [
      {
        name: "Subscript",
        parse: Eae(126, "Subscript", "SubscriptMark")
      }
    ]
  }, mKe = {
    defineNodes: [
      {
        name: "Emoji",
        style: V.character
      }
    ],
    parseInline: [
      {
        name: "Emoji",
        parse(t, e, n) {
          let r;
          return e != 58 || !(r = /^[a-zA-Z_0-9]+:/.exec(t.slice(n + 1, t.end))) ? -1 : t.addElement(t.elt("Emoji", n, n + 1 + r[0].length));
        }
      }
    ]
  };
  class vP {
    constructor(e, n, r, i, s, o, a, l, c, u = 0, d) {
      this.p = e, this.stack = n, this.state = r, this.reducePos = i, this.pos = s, this.score = o, this.buffer = a, this.bufferBase = l, this.curContext = c, this.lookAhead = u, this.parent = d;
    }
    toString() {
      return `[${this.stack.filter((e, n) => n % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
    }
    static start(e, n, r = 0) {
      let i = e.parser.context;
      return new vP(e, [], n, r, r, 0, [], 0, i ? new lV(i, i.start) : null, 0, null);
    }
    get context() {
      return this.curContext ? this.curContext.context : null;
    }
    pushState(e, n) {
      this.stack.push(this.state, n, this.bufferBase + this.buffer.length), this.state = e;
    }
    reduce(e) {
      var n;
      let r = e >> 19, i = e & 65535, { parser: s } = this.p, o = this.reducePos < this.pos - 25;
      o && this.setLookAhead(this.pos);
      let a = s.dynamicPrecedence(i);
      if (a && (this.score += a), r == 0) {
        this.pushState(s.getGoto(this.state, i, true), this.reducePos), i < s.minRepeatTerm && this.storeNode(i, this.reducePos, this.reducePos, o ? 8 : 4, true), this.reduceContext(i, this.reducePos);
        return;
      }
      let l = this.stack.length - (r - 1) * 3 - (e & 262144 ? 6 : 0), c = l ? this.stack[l - 2] : this.p.ranges[0].from, u = this.reducePos - c;
      u >= 2e3 && !(!((n = this.p.parser.nodeSet.types[i]) === null || n === void 0) && n.isAnonymous) && (c == this.p.lastBigReductionStart ? (this.p.bigReductionCount++, this.p.lastBigReductionSize = u) : this.p.lastBigReductionSize < u && (this.p.bigReductionCount = 1, this.p.lastBigReductionStart = c, this.p.lastBigReductionSize = u));
      let d = l ? this.stack[l - 1] : 0, h = this.bufferBase + this.buffer.length - d;
      if (i < s.minRepeatTerm || e & 131072) {
        let f = s.stateFlag(this.state, 1) ? this.pos : this.reducePos;
        this.storeNode(i, c, f, h + 4, true);
      }
      if (e & 262144)
        this.state = this.stack[l];
      else {
        let f = this.stack[l - 3];
        this.state = s.getGoto(f, i, true);
      }
      for (; this.stack.length > l; )
        this.stack.pop();
      this.reduceContext(i, c);
    }
    storeNode(e, n, r, i = 4, s = false) {
      if (e == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
        let o = this, a = this.buffer.length;
        if (a == 0 && o.parent && (a = o.bufferBase - o.parent.bufferBase, o = o.parent), a > 0 && o.buffer[a - 4] == 0 && o.buffer[a - 1] > -1) {
          if (n == r)
            return;
          if (o.buffer[a - 2] >= n) {
            o.buffer[a - 2] = r;
            return;
          }
        }
      }
      if (!s || this.pos == r)
        this.buffer.push(e, n, r, i);
      else {
        let o = this.buffer.length;
        if (o > 0 && this.buffer[o - 4] != 0) {
          let a = false;
          for (let l = o; l > 0 && this.buffer[l - 2] > r; l -= 4)
            if (this.buffer[l - 1] >= 0) {
              a = true;
              break;
            }
          if (a)
            for (; o > 0 && this.buffer[o - 2] > r; )
              this.buffer[o] = this.buffer[o - 4], this.buffer[o + 1] = this.buffer[o - 3], this.buffer[o + 2] = this.buffer[o - 2], this.buffer[o + 3] = this.buffer[o - 1], o -= 4, i > 4 && (i -= 4);
        }
        this.buffer[o] = e, this.buffer[o + 1] = n, this.buffer[o + 2] = r, this.buffer[o + 3] = i;
      }
    }
    shift(e, n, r, i) {
      if (e & 131072)
        this.pushState(e & 65535, this.pos);
      else if (e & 262144)
        this.pos = i, this.shiftContext(n, r), n <= this.p.parser.maxNode && this.buffer.push(n, r, i, 4);
      else {
        let s = e, { parser: o } = this.p;
        (i > this.pos || n <= o.maxNode) && (this.pos = i, o.stateFlag(s, 1) || (this.reducePos = i)), this.pushState(s, r), this.shiftContext(n, r), n <= o.maxNode && this.buffer.push(n, r, i, 4);
      }
    }
    apply(e, n, r, i) {
      e & 65536 ? this.reduce(e) : this.shift(e, n, r, i);
    }
    useNode(e, n) {
      let r = this.p.reused.length - 1;
      (r < 0 || this.p.reused[r] != e) && (this.p.reused.push(e), r++);
      let i = this.pos;
      this.reducePos = this.pos = i + e.length, this.pushState(n, i), this.buffer.push(r, i, this.reducePos, -1), this.curContext && this.updateContext(this.curContext.tracker.reuse(this.curContext.context, e, this, this.p.stream.reset(this.pos - e.length)));
    }
    split() {
      let e = this, n = e.buffer.length;
      for (; n > 0 && e.buffer[n - 2] > e.reducePos; )
        n -= 4;
      let r = e.buffer.slice(n), i = e.bufferBase + n;
      for (; e && i == e.bufferBase; )
        e = e.parent;
      return new vP(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, r, i, this.curContext, this.lookAhead, e);
    }
    recoverByDelete(e, n) {
      let r = e <= this.p.parser.maxNode;
      r && this.storeNode(e, this.pos, n, 4), this.storeNode(0, this.pos, n, r ? 8 : 4), this.pos = this.reducePos = n, this.score -= 190;
    }
    canShift(e) {
      for (let n = new yKe(this); ; ) {
        let r = this.p.parser.stateSlot(n.state, 4) || this.p.parser.hasAction(n.state, e);
        if (r == 0)
          return false;
        if (!(r & 65536))
          return true;
        n.reduce(r);
      }
    }
    recoverByInsert(e) {
      if (this.stack.length >= 300)
        return [];
      let n = this.p.parser.nextStates(this.state);
      if (n.length > 8 || this.stack.length >= 120) {
        let i = [];
        for (let s = 0, o; s < n.length; s += 2)
          (o = n[s + 1]) != this.state && this.p.parser.hasAction(o, e) && i.push(n[s], o);
        if (this.stack.length < 120)
          for (let s = 0; i.length < 8 && s < n.length; s += 2) {
            let o = n[s + 1];
            i.some((a, l) => l & 1 && a == o) || i.push(n[s], o);
          }
        n = i;
      }
      let r = [];
      for (let i = 0; i < n.length && r.length < 4; i += 2) {
        let s = n[i + 1];
        if (s == this.state)
          continue;
        let o = this.split();
        o.pushState(s, this.pos), o.storeNode(0, o.pos, o.pos, 4, true), o.shiftContext(n[i], this.pos), o.reducePos = this.pos, o.score -= 200, r.push(o);
      }
      return r;
    }
    forceReduce() {
      let { parser: e } = this.p, n = e.stateSlot(this.state, 5);
      if (!(n & 65536))
        return false;
      if (!e.validAction(this.state, n)) {
        let r = n >> 19, i = n & 65535, s = this.stack.length - r * 3;
        if (s < 0 || e.getGoto(this.stack[s], i, false) < 0) {
          let o = this.findForcedReduction();
          if (o == null)
            return false;
          n = o;
        }
        this.storeNode(0, this.pos, this.pos, 4, true), this.score -= 100;
      }
      return this.reducePos = this.pos, this.reduce(n), true;
    }
    findForcedReduction() {
      let { parser: e } = this.p, n = [], r = (i, s) => {
        if (!n.includes(i))
          return n.push(i), e.allActions(i, (o) => {
            if (!(o & 393216))
              if (o & 65536) {
                let a = (o >> 19) - s;
                if (a > 1) {
                  let l = o & 65535, c = this.stack.length - a * 3;
                  if (c >= 0 && e.getGoto(this.stack[c], l, false) >= 0)
                    return a << 19 | 65536 | l;
                }
              } else {
                let a = r(o, s + 1);
                if (a != null)
                  return a;
              }
          });
      };
      return r(this.state, 0);
    }
    forceAll() {
      for (; !this.p.parser.stateFlag(this.state, 2); )
        if (!this.forceReduce()) {
          this.storeNode(0, this.pos, this.pos, 4, true);
          break;
        }
      return this;
    }
    get deadEnd() {
      if (this.stack.length != 3)
        return false;
      let { parser: e } = this.p;
      return e.data[e.stateSlot(this.state, 1)] == 65535 && !e.stateSlot(this.state, 4);
    }
    restart() {
      this.storeNode(0, this.pos, this.pos, 4, true), this.state = this.stack[0], this.stack.length = 0;
    }
    sameState(e) {
      if (this.state != e.state || this.stack.length != e.stack.length)
        return false;
      for (let n = 0; n < this.stack.length; n += 3)
        if (this.stack[n] != e.stack[n])
          return false;
      return true;
    }
    get parser() {
      return this.p.parser;
    }
    dialectEnabled(e) {
      return this.p.parser.dialect.flags[e];
    }
    shiftContext(e, n) {
      this.curContext && this.updateContext(this.curContext.tracker.shift(this.curContext.context, e, this, this.p.stream.reset(n)));
    }
    reduceContext(e, n) {
      this.curContext && this.updateContext(this.curContext.tracker.reduce(this.curContext.context, e, this, this.p.stream.reset(n)));
    }
    emitContext() {
      let e = this.buffer.length - 1;
      (e < 0 || this.buffer[e] != -3) && this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
    }
    emitLookAhead() {
      let e = this.buffer.length - 1;
      (e < 0 || this.buffer[e] != -4) && this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
    }
    updateContext(e) {
      if (e != this.curContext.context) {
        let n = new lV(this.curContext.tracker, e);
        n.hash != this.curContext.hash && this.emitContext(), this.curContext = n;
      }
    }
    setLookAhead(e) {
      e > this.lookAhead && (this.emitLookAhead(), this.lookAhead = e);
    }
    close() {
      this.curContext && this.curContext.tracker.strict && this.emitContext(), this.lookAhead > 0 && this.emitLookAhead();
    }
  }
  class lV {
    constructor(e, n) {
      this.tracker = e, this.context = n, this.hash = e.strict ? e.hash(n) : 0;
    }
  }
  class yKe {
    constructor(e) {
      this.start = e, this.state = e.state, this.stack = e.stack, this.base = this.stack.length;
    }
    reduce(e) {
      let n = e & 65535, r = e >> 19;
      r == 0 ? (this.stack == this.start.stack && (this.stack = this.stack.slice()), this.stack.push(this.state, 0, 0), this.base += 3) : this.base -= (r - 1) * 3;
      let i = this.start.p.parser.getGoto(this.stack[this.base - 3], n, true);
      this.state = i;
    }
  }
  class OP {
    constructor(e, n, r) {
      this.stack = e, this.pos = n, this.index = r, this.buffer = e.buffer, this.index == 0 && this.maybeNext();
    }
    static create(e, n = e.bufferBase + e.buffer.length) {
      return new OP(e, n, n - e.bufferBase);
    }
    maybeNext() {
      let e = this.stack.parent;
      e != null && (this.index = this.stack.bufferBase - e.bufferBase, this.stack = e, this.buffer = e.buffer);
    }
    get id() {
      return this.buffer[this.index - 4];
    }
    get start() {
      return this.buffer[this.index - 3];
    }
    get end() {
      return this.buffer[this.index - 2];
    }
    get size() {
      return this.buffer[this.index - 1];
    }
    next() {
      this.index -= 4, this.pos -= 4, this.index == 0 && this.maybeNext();
    }
    fork() {
      return new OP(this.stack, this.pos, this.index);
    }
  }
  function I0(t, e = Uint16Array) {
    if (typeof t != "string")
      return t;
    let n = null;
    for (let r = 0, i = 0; r < t.length; ) {
      let s = 0;
      for (; ; ) {
        let o = t.charCodeAt(r++), a = false;
        if (o == 126) {
          s = 65535;
          break;
        }
        o >= 92 && o--, o >= 34 && o--;
        let l = o - 32;
        if (l >= 46 && (l -= 46, a = true), s += l, a)
          break;
        s *= 46;
      }
      n ? n[i++] = s : n = new e(s);
    }
    return n;
  }
  class vb {
    constructor() {
      this.start = -1, this.value = -1, this.end = -1, this.extended = -1, this.lookAhead = 0, this.mask = 0, this.context = 0;
    }
  }
  const cV = new vb();
  class vKe {
    constructor(e, n) {
      this.input = e, this.ranges = n, this.chunk = "", this.chunkOff = 0, this.chunk2 = "", this.chunk2Pos = 0, this.next = -1, this.token = cV, this.rangeIndex = 0, this.pos = this.chunkPos = n[0].from, this.range = n[0], this.end = n[n.length - 1].to, this.readNext();
    }
    resolveOffset(e, n) {
      let r = this.range, i = this.rangeIndex, s = this.pos + e;
      for (; s < r.from; ) {
        if (!i)
          return null;
        let o = this.ranges[--i];
        s -= r.from - o.to, r = o;
      }
      for (; n < 0 ? s > r.to : s >= r.to; ) {
        if (i == this.ranges.length - 1)
          return null;
        let o = this.ranges[++i];
        s += o.from - r.to, r = o;
      }
      return s;
    }
    clipPos(e) {
      if (e >= this.range.from && e < this.range.to)
        return e;
      for (let n of this.ranges)
        if (n.to > e)
          return Math.max(e, n.from);
      return this.end;
    }
    peek(e) {
      let n = this.chunkOff + e, r, i;
      if (n >= 0 && n < this.chunk.length)
        r = this.pos + e, i = this.chunk.charCodeAt(n);
      else {
        let s = this.resolveOffset(e, 1);
        if (s == null)
          return -1;
        if (r = s, r >= this.chunk2Pos && r < this.chunk2Pos + this.chunk2.length)
          i = this.chunk2.charCodeAt(r - this.chunk2Pos);
        else {
          let o = this.rangeIndex, a = this.range;
          for (; a.to <= r; )
            a = this.ranges[++o];
          this.chunk2 = this.input.chunk(this.chunk2Pos = r), r + this.chunk2.length > a.to && (this.chunk2 = this.chunk2.slice(0, a.to - r)), i = this.chunk2.charCodeAt(0);
        }
      }
      return r >= this.token.lookAhead && (this.token.lookAhead = r + 1), i;
    }
    acceptToken(e, n = 0) {
      let r = n ? this.resolveOffset(n, -1) : this.pos;
      if (r == null || r < this.token.start)
        throw new RangeError("Token end out of bounds");
      this.token.value = e, this.token.end = r;
    }
    acceptTokenTo(e, n) {
      this.token.value = e, this.token.end = n;
    }
    getChunk() {
      if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
        let { chunk: e, chunkPos: n } = this;
        this.chunk = this.chunk2, this.chunkPos = this.chunk2Pos, this.chunk2 = e, this.chunk2Pos = n, this.chunkOff = this.pos - this.chunkPos;
      } else {
        this.chunk2 = this.chunk, this.chunk2Pos = this.chunkPos;
        let e = this.input.chunk(this.pos), n = this.pos + e.length;
        this.chunk = n > this.range.to ? e.slice(0, this.range.to - this.pos) : e, this.chunkPos = this.pos, this.chunkOff = 0;
      }
    }
    readNext() {
      return this.chunkOff >= this.chunk.length && (this.getChunk(), this.chunkOff == this.chunk.length) ? this.next = -1 : this.next = this.chunk.charCodeAt(this.chunkOff);
    }
    advance(e = 1) {
      for (this.chunkOff += e; this.pos + e >= this.range.to; ) {
        if (this.rangeIndex == this.ranges.length - 1)
          return this.setDone();
        e -= this.range.to - this.pos, this.range = this.ranges[++this.rangeIndex], this.pos = this.range.from;
      }
      return this.pos += e, this.pos >= this.token.lookAhead && (this.token.lookAhead = this.pos + 1), this.readNext();
    }
    setDone() {
      return this.pos = this.chunkPos = this.end, this.range = this.ranges[this.rangeIndex = this.ranges.length - 1], this.chunk = "", this.next = -1;
    }
    reset(e, n) {
      if (n ? (this.token = n, n.start = e, n.lookAhead = e + 1, n.value = n.extended = -1) : this.token = cV, this.pos != e) {
        if (this.pos = e, e == this.end)
          return this.setDone(), this;
        for (; e < this.range.from; )
          this.range = this.ranges[--this.rangeIndex];
        for (; e >= this.range.to; )
          this.range = this.ranges[++this.rangeIndex];
        e >= this.chunkPos && e < this.chunkPos + this.chunk.length ? this.chunkOff = e - this.chunkPos : (this.chunk = "", this.chunkOff = 0), this.readNext();
      }
      return this;
    }
    read(e, n) {
      if (e >= this.chunkPos && n <= this.chunkPos + this.chunk.length)
        return this.chunk.slice(e - this.chunkPos, n - this.chunkPos);
      if (e >= this.chunk2Pos && n <= this.chunk2Pos + this.chunk2.length)
        return this.chunk2.slice(e - this.chunk2Pos, n - this.chunk2Pos);
      if (e >= this.range.from && n <= this.range.to)
        return this.input.read(e, n);
      let r = "";
      for (let i of this.ranges) {
        if (i.from >= n)
          break;
        i.to > e && (r += this.input.read(Math.max(i.from, e), Math.min(i.to, n)));
      }
      return r;
    }
  }
  class xg {
    constructor(e, n) {
      this.data = e, this.id = n;
    }
    token(e, n) {
      let { parser: r } = n.p;
      Iae(this.data, e, n, this.id, r.data, r.tokenPrecTable);
    }
  }
  xg.prototype.contextual = xg.prototype.fallback = xg.prototype.extend = false;
  SP = class {
    constructor(e, n, r) {
      this.precTable = n, this.elseToken = r, this.data = typeof e == "string" ? I0(e) : e;
    }
    token(e, n) {
      let r = e.pos, i = 0;
      for (; ; ) {
        let s = e.next < 0, o = e.resolveOffset(1, 1);
        if (Iae(this.data, e, n, 0, this.data, this.precTable), e.token.value > -1)
          break;
        if (this.elseToken == null)
          return;
        if (s || i++, o == null)
          break;
        e.reset(o, e.token);
      }
      i && (e.reset(r, e.token), e.acceptToken(this.elseToken, i));
    }
  };
  SP.prototype.contextual = xg.prototype.fallback = xg.prototype.extend = false;
  po = class {
    constructor(e, n = {}) {
      this.token = e, this.contextual = !!n.contextual, this.fallback = !!n.fallback, this.extend = !!n.extend;
    }
  };
  function Iae(t, e, n, r, i, s) {
    let o = 0, a = 1 << r, { dialect: l } = n.p.parser;
    e:
      for (; a & t[o]; ) {
        let c = t[o + 1];
        for (let f = o + 3; f < c; f += 2)
          if ((t[f + 1] & a) > 0) {
            let y = t[f];
            if (l.allows(y) && (e.token.value == -1 || e.token.value == y || OKe(y, e.token.value, i, s))) {
              e.acceptToken(y);
              break;
            }
          }
        let u = e.next, d = 0, h = t[o + 2];
        if (e.next < 0 && h > d && t[c + h * 3 - 3] == 65535) {
          o = t[c + h * 3 - 1];
          continue e;
        }
        for (; d < h; ) {
          let f = d + h >> 1, y = c + f + (f << 1), g = t[y], O = t[y + 1] || 65536;
          if (u < g)
            h = f;
          else if (u >= O)
            d = f + 1;
          else {
            o = t[y + 2], e.advance();
            continue e;
          }
        }
        break;
      }
  }
  function uV(t, e, n) {
    for (let r = e, i; (i = t[r]) != 65535; r++)
      if (i == n)
        return r - e;
    return -1;
  }
  function OKe(t, e, n, r) {
    let i = uV(n, r, e);
    return i < 0 || uV(n, r, t) < i;
  }
  const Ds = typeof process < "u" && process.env && /\bparse\b/.test({}.LOG);
  let d$ = null;
  function dV(t, e, n) {
    let r = t.cursor(dn.IncludeAnonymous);
    for (r.moveTo(e); ; )
      if (!(n < 0 ? r.childBefore(e) : r.childAfter(e)))
        for (; ; ) {
          if ((n < 0 ? r.to < e : r.from > e) && !r.type.isError)
            return n < 0 ? Math.max(0, Math.min(r.to - 1, e - 25)) : Math.min(t.length, Math.max(r.from + 1, e + 25));
          if (n < 0 ? r.prevSibling() : r.nextSibling())
            break;
          if (!r.parent())
            return n < 0 ? 0 : t.length;
        }
  }
  class SKe {
    constructor(e, n) {
      this.fragments = e, this.nodeSet = n, this.i = 0, this.fragment = null, this.safeFrom = -1, this.safeTo = -1, this.trees = [], this.start = [], this.index = [], this.nextFragment();
    }
    nextFragment() {
      let e = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
      if (e) {
        for (this.safeFrom = e.openStart ? dV(e.tree, e.from + e.offset, 1) - e.offset : e.from, this.safeTo = e.openEnd ? dV(e.tree, e.to + e.offset, -1) - e.offset : e.to; this.trees.length; )
          this.trees.pop(), this.start.pop(), this.index.pop();
        this.trees.push(e.tree), this.start.push(-e.offset), this.index.push(0), this.nextStart = this.safeFrom;
      } else
        this.nextStart = 1e9;
    }
    nodeAt(e) {
      if (e < this.nextStart)
        return null;
      for (; this.fragment && this.safeTo <= e; )
        this.nextFragment();
      if (!this.fragment)
        return null;
      for (; ; ) {
        let n = this.trees.length - 1;
        if (n < 0)
          return this.nextFragment(), null;
        let r = this.trees[n], i = this.index[n];
        if (i == r.children.length) {
          this.trees.pop(), this.start.pop(), this.index.pop();
          continue;
        }
        let s = r.children[i], o = this.start[n] + r.positions[i];
        if (o > e)
          return this.nextStart = o, null;
        if (s instanceof At) {
          if (o == e) {
            if (o < this.safeFrom)
              return null;
            let a = o + s.length;
            if (a <= this.safeTo) {
              let l = s.prop(ut.lookAhead);
              if (!l || a + l < this.fragment.to)
                return s;
            }
          }
          this.index[n]++, o + s.length >= Math.max(this.safeFrom, e) && (this.trees.push(s), this.start.push(o), this.index.push(0));
        } else
          this.index[n]++, this.nextStart = o + s.length;
      }
    }
  }
  class wKe {
    constructor(e, n) {
      this.stream = n, this.tokens = [], this.mainToken = null, this.actions = [], this.tokens = e.tokenizers.map((r) => new vb());
    }
    getActions(e) {
      let n = 0, r = null, { parser: i } = e.p, { tokenizers: s } = i, o = i.stateSlot(e.state, 3), a = e.curContext ? e.curContext.hash : 0, l = 0;
      for (let c = 0; c < s.length; c++) {
        if (!(1 << c & o))
          continue;
        let u = s[c], d = this.tokens[c];
        if (!(r && !u.fallback) && ((u.contextual || d.start != e.pos || d.mask != o || d.context != a) && (this.updateCachedToken(d, u, e), d.mask = o, d.context = a), d.lookAhead > d.end + 25 && (l = Math.max(d.lookAhead, l)), d.value != 0)) {
          let h = n;
          if (d.extended > -1 && (n = this.addActions(e, d.extended, d.end, n)), n = this.addActions(e, d.value, d.end, n), !u.extend && (r = d, n > h))
            break;
        }
      }
      for (; this.actions.length > n; )
        this.actions.pop();
      return l && e.setLookAhead(l), !r && e.pos == this.stream.end && (r = new vb(), r.value = e.p.parser.eofTerm, r.start = r.end = e.pos, n = this.addActions(e, r.value, r.end, n)), this.mainToken = r, this.actions;
    }
    getMainToken(e) {
      if (this.mainToken)
        return this.mainToken;
      let n = new vb(), { pos: r, p: i } = e;
      return n.start = r, n.end = Math.min(r + 1, i.stream.end), n.value = r == i.stream.end ? i.parser.eofTerm : 0, n;
    }
    updateCachedToken(e, n, r) {
      let i = this.stream.clipPos(r.pos);
      if (n.token(this.stream.reset(i, e), r), e.value > -1) {
        let { parser: s } = r.p;
        for (let o = 0; o < s.specialized.length; o++)
          if (s.specialized[o] == e.value) {
            let a = s.specializers[o](this.stream.read(e.start, e.end), r);
            if (a >= 0 && r.p.parser.dialect.allows(a >> 1)) {
              a & 1 ? e.extended = a >> 1 : e.value = a >> 1;
              break;
            }
          }
      } else
        e.value = 0, e.end = this.stream.clipPos(i + 1);
    }
    putAction(e, n, r, i) {
      for (let s = 0; s < i; s += 3)
        if (this.actions[s] == e)
          return i;
      return this.actions[i++] = e, this.actions[i++] = n, this.actions[i++] = r, i;
    }
    addActions(e, n, r, i) {
      let { state: s } = e, { parser: o } = e.p, { data: a } = o;
      for (let l = 0; l < 2; l++)
        for (let c = o.stateSlot(s, l ? 2 : 1); ; c += 3) {
          if (a[c] == 65535)
            if (a[c + 1] == 1)
              c = kc(a, c + 2);
            else {
              i == 0 && a[c + 1] == 2 && (i = this.putAction(kc(a, c + 2), n, r, i));
              break;
            }
          a[c] == n && (i = this.putAction(kc(a, c + 1), n, r, i));
        }
      return i;
    }
  }
  class xKe {
    constructor(e, n, r, i) {
      this.parser = e, this.input = n, this.ranges = i, this.recovering = 0, this.nextStackID = 9812, this.minStackPos = 0, this.reused = [], this.stoppedAt = null, this.lastBigReductionStart = -1, this.lastBigReductionSize = 0, this.bigReductionCount = 0, this.stream = new vKe(n, i), this.tokens = new wKe(e, this.stream), this.topTerm = e.top[1];
      let { from: s } = i[0];
      this.stacks = [
        vP.start(this, e.top[0], s)
      ], this.fragments = r.length && this.stream.end - s > e.bufferLength * 4 ? new SKe(r, e.nodeSet) : null;
    }
    get parsedPos() {
      return this.minStackPos;
    }
    advance() {
      let e = this.stacks, n = this.minStackPos, r = this.stacks = [], i, s;
      if (this.bigReductionCount > 300 && e.length == 1) {
        let [o] = e;
        for (; o.forceReduce() && o.stack.length && o.stack[o.stack.length - 2] >= this.lastBigReductionStart; )
          ;
        this.bigReductionCount = this.lastBigReductionSize = 0;
      }
      for (let o = 0; o < e.length; o++) {
        let a = e[o];
        for (; ; ) {
          if (this.tokens.mainToken = null, a.pos > n)
            r.push(a);
          else {
            if (this.advanceStack(a, r, e))
              continue;
            {
              i || (i = [], s = []), i.push(a);
              let l = this.tokens.getMainToken(a);
              s.push(l.value, l.end);
            }
          }
          break;
        }
      }
      if (!r.length) {
        let o = i && kKe(i);
        if (o)
          return Ds && console.log("Finish with " + this.stackID(o)), this.stackToTree(o);
        if (this.parser.strict)
          throw Ds && i && console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none")), new SyntaxError("No parse at " + n);
        this.recovering || (this.recovering = 5);
      }
      if (this.recovering && i) {
        let o = this.stoppedAt != null && i[0].pos > this.stoppedAt ? i[0] : this.runRecovery(i, s, r);
        if (o)
          return Ds && console.log("Force-finish " + this.stackID(o)), this.stackToTree(o.forceAll());
      }
      if (this.recovering) {
        let o = this.recovering == 1 ? 1 : this.recovering * 3;
        if (r.length > o)
          for (r.sort((a, l) => l.score - a.score); r.length > o; )
            r.pop();
        r.some((a) => a.reducePos > n) && this.recovering--;
      } else if (r.length > 1) {
        e:
          for (let o = 0; o < r.length - 1; o++) {
            let a = r[o];
            for (let l = o + 1; l < r.length; l++) {
              let c = r[l];
              if (a.sameState(c) || a.buffer.length > 500 && c.buffer.length > 500)
                if ((a.score - c.score || a.buffer.length - c.buffer.length) > 0)
                  r.splice(l--, 1);
                else {
                  r.splice(o--, 1);
                  continue e;
                }
            }
          }
        r.length > 12 && r.splice(12, r.length - 12);
      }
      this.minStackPos = r[0].pos;
      for (let o = 1; o < r.length; o++)
        r[o].pos < this.minStackPos && (this.minStackPos = r[o].pos);
      return null;
    }
    stopAt(e) {
      if (this.stoppedAt != null && this.stoppedAt < e)
        throw new RangeError("Can't move stoppedAt forward");
      this.stoppedAt = e;
    }
    advanceStack(e, n, r) {
      let i = e.pos, { parser: s } = this, o = Ds ? this.stackID(e) + " -> " : "";
      if (this.stoppedAt != null && i > this.stoppedAt)
        return e.forceReduce() ? e : null;
      if (this.fragments) {
        let c = e.curContext && e.curContext.tracker.strict, u = c ? e.curContext.hash : 0;
        for (let d = this.fragments.nodeAt(i); d; ) {
          let h = this.parser.nodeSet.types[d.type.id] == d.type ? s.getGoto(e.state, d.type.id) : -1;
          if (h > -1 && d.length && (!c || (d.prop(ut.contextHash) || 0) == u))
            return e.useNode(d, h), Ds && console.log(o + this.stackID(e) + ` (via reuse of ${s.getName(d.type.id)})`), true;
          if (!(d instanceof At) || d.children.length == 0 || d.positions[0] > 0)
            break;
          let f = d.children[0];
          if (f instanceof At && d.positions[0] == 0)
            d = f;
          else
            break;
        }
      }
      let a = s.stateSlot(e.state, 4);
      if (a > 0)
        return e.reduce(a), Ds && console.log(o + this.stackID(e) + ` (via always-reduce ${s.getName(a & 65535)})`), true;
      if (e.stack.length >= 8400)
        for (; e.stack.length > 6e3 && e.forceReduce(); )
          ;
      let l = this.tokens.getActions(e);
      for (let c = 0; c < l.length; ) {
        let u = l[c++], d = l[c++], h = l[c++], f = c == l.length || !r, y = f ? e : e.split(), g = this.tokens.mainToken;
        if (y.apply(u, d, g ? g.start : y.pos, h), Ds && console.log(o + this.stackID(y) + ` (via ${u & 65536 ? `reduce of ${s.getName(u & 65535)}` : "shift"} for ${s.getName(d)} @ ${i}${y == e ? "" : ", split"})`), f)
          return true;
        y.pos > i ? n.push(y) : r.push(y);
      }
      return false;
    }
    advanceFully(e, n) {
      let r = e.pos;
      for (; ; ) {
        if (!this.advanceStack(e, null, null))
          return false;
        if (e.pos > r)
          return hV(e, n), true;
      }
    }
    runRecovery(e, n, r) {
      let i = null, s = false;
      for (let o = 0; o < e.length; o++) {
        let a = e[o], l = n[o << 1], c = n[(o << 1) + 1], u = Ds ? this.stackID(a) + " -> " : "";
        if (a.deadEnd && (s || (s = true, a.restart(), Ds && console.log(u + this.stackID(a) + " (restarted)"), this.advanceFully(a, r))))
          continue;
        let d = a.split(), h = u;
        for (let f = 0; d.forceReduce() && f < 10 && (Ds && console.log(h + this.stackID(d) + " (via force-reduce)"), !this.advanceFully(d, r)); f++)
          Ds && (h = this.stackID(d) + " -> ");
        for (let f of a.recoverByInsert(l))
          Ds && console.log(u + this.stackID(f) + " (via recover-insert)"), this.advanceFully(f, r);
        this.stream.end > a.pos ? (c == a.pos && (c++, l = 0), a.recoverByDelete(l, c), Ds && console.log(u + this.stackID(a) + ` (via recover-delete ${this.parser.getName(l)})`), hV(a, r)) : (!i || i.score < a.score) && (i = a);
      }
      return i;
    }
    stackToTree(e) {
      return e.close(), At.build({
        buffer: OP.create(e),
        nodeSet: this.parser.nodeSet,
        topID: this.topTerm,
        maxBufferLength: this.parser.bufferLength,
        reused: this.reused,
        start: this.ranges[0].from,
        length: e.pos - this.ranges[0].from,
        minRepeatType: this.parser.minRepeatTerm
      });
    }
    stackID(e) {
      let n = (d$ || (d$ = /* @__PURE__ */ new WeakMap())).get(e);
      return n || d$.set(e, n = String.fromCodePoint(this.nextStackID++)), n + e;
    }
  }
  function hV(t, e) {
    for (let n = 0; n < e.length; n++) {
      let r = e[n];
      if (r.pos == t.pos && r.sameState(t)) {
        e[n].score < t.score && (e[n] = t);
        return;
      }
    }
    e.push(t);
  }
  class bKe {
    constructor(e, n, r) {
      this.source = e, this.flags = n, this.disabled = r;
    }
    allows(e) {
      return !this.disabled || this.disabled[e] == 0;
    }
  }
  const h$ = (t) => t;
  $ae = class {
    constructor(e) {
      this.start = e.start, this.shift = e.shift || h$, this.reduce = e.reduce || h$, this.reuse = e.reuse || h$, this.hash = e.hash || (() => 0), this.strict = e.strict !== false;
    }
  };
  dm = class extends $2 {
    constructor(e) {
      if (super(), this.wrappers = [], e.version != 14)
        throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);
      let n = e.nodeNames.split(" ");
      this.minRepeatTerm = n.length;
      for (let a = 0; a < e.repeatNodeCount; a++)
        n.push("");
      let r = Object.keys(e.topRules).map((a) => e.topRules[a][1]), i = [];
      for (let a = 0; a < n.length; a++)
        i.push([]);
      function s(a, l, c) {
        i[a].push([
          l,
          l.deserialize(String(c))
        ]);
      }
      if (e.nodeProps)
        for (let a of e.nodeProps) {
          let l = a[0];
          typeof l == "string" && (l = ut[l]);
          for (let c = 1; c < a.length; ) {
            let u = a[c++];
            if (u >= 0)
              s(u, l, a[c++]);
            else {
              let d = a[c + -u];
              for (let h = -u; h > 0; h--)
                s(a[c++], l, d);
              c++;
            }
          }
        }
      this.nodeSet = new Qm(n.map((a, l) => Tr.define({
        name: l >= this.minRepeatTerm ? void 0 : a,
        id: l,
        props: i[l],
        top: r.indexOf(l) > -1,
        error: l == 0,
        skipped: e.skippedNodes && e.skippedNodes.indexOf(l) > -1
      }))), e.propSources && (this.nodeSet = this.nodeSet.extend(...e.propSources)), this.strict = false, this.bufferLength = Eoe;
      let o = I0(e.tokenData);
      this.context = e.context, this.specializerSpecs = e.specialized || [], this.specialized = new Uint16Array(this.specializerSpecs.length);
      for (let a = 0; a < this.specializerSpecs.length; a++)
        this.specialized[a] = this.specializerSpecs[a].term;
      this.specializers = this.specializerSpecs.map(fV), this.states = I0(e.states, Uint32Array), this.data = I0(e.stateData), this.goto = I0(e.goto), this.maxTerm = e.maxTerm, this.tokenizers = e.tokenizers.map((a) => typeof a == "number" ? new xg(o, a) : a), this.topRules = e.topRules, this.dialects = e.dialects || {}, this.dynamicPrecedences = e.dynamicPrecedences || null, this.tokenPrecTable = e.tokenPrec, this.termNames = e.termNames || null, this.maxNode = this.nodeSet.types.length - 1, this.dialect = this.parseDialect(), this.top = this.topRules[Object.keys(this.topRules)[0]];
    }
    createParse(e, n, r) {
      let i = new xKe(this, e, n, r);
      for (let s of this.wrappers)
        i = s(i, e, n, r);
      return i;
    }
    getGoto(e, n, r = false) {
      let i = this.goto;
      if (n >= i[0])
        return -1;
      for (let s = i[n + 1]; ; ) {
        let o = i[s++], a = o & 1, l = i[s++];
        if (a && r)
          return l;
        for (let c = s + (o >> 1); s < c; s++)
          if (i[s] == e)
            return l;
        if (a)
          return -1;
      }
    }
    hasAction(e, n) {
      let r = this.data;
      for (let i = 0; i < 2; i++)
        for (let s = this.stateSlot(e, i ? 2 : 1), o; ; s += 3) {
          if ((o = r[s]) == 65535)
            if (r[s + 1] == 1)
              o = r[s = kc(r, s + 2)];
            else {
              if (r[s + 1] == 2)
                return kc(r, s + 2);
              break;
            }
          if (o == n || o == 0)
            return kc(r, s + 1);
        }
      return 0;
    }
    stateSlot(e, n) {
      return this.states[e * 6 + n];
    }
    stateFlag(e, n) {
      return (this.stateSlot(e, 0) & n) > 0;
    }
    validAction(e, n) {
      return !!this.allActions(e, (r) => r == n ? true : null);
    }
    allActions(e, n) {
      let r = this.stateSlot(e, 4), i = r ? n(r) : void 0;
      for (let s = this.stateSlot(e, 1); i == null; s += 3) {
        if (this.data[s] == 65535)
          if (this.data[s + 1] == 1)
            s = kc(this.data, s + 2);
          else
            break;
        i = n(kc(this.data, s + 1));
      }
      return i;
    }
    nextStates(e) {
      let n = [];
      for (let r = this.stateSlot(e, 1); ; r += 3) {
        if (this.data[r] == 65535)
          if (this.data[r + 1] == 1)
            r = kc(this.data, r + 2);
          else
            break;
        if (!(this.data[r + 2] & 1)) {
          let i = this.data[r + 1];
          n.some((s, o) => o & 1 && s == i) || n.push(this.data[r], i);
        }
      }
      return n;
    }
    configure(e) {
      let n = Object.assign(Object.create(dm.prototype), this);
      if (e.props && (n.nodeSet = this.nodeSet.extend(...e.props)), e.top) {
        let r = this.topRules[e.top];
        if (!r)
          throw new RangeError(`Invalid top rule name ${e.top}`);
        n.top = r;
      }
      return e.tokenizers && (n.tokenizers = this.tokenizers.map((r) => {
        let i = e.tokenizers.find((s) => s.from == r);
        return i ? i.to : r;
      })), e.specializers && (n.specializers = this.specializers.slice(), n.specializerSpecs = this.specializerSpecs.map((r, i) => {
        let s = e.specializers.find((a) => a.from == r.external);
        if (!s)
          return r;
        let o = Object.assign(Object.assign({}, r), {
          external: s.to
        });
        return n.specializers[i] = fV(o), o;
      })), e.contextTracker && (n.context = e.contextTracker), e.dialect && (n.dialect = this.parseDialect(e.dialect)), e.strict != null && (n.strict = e.strict), e.wrap && (n.wrappers = n.wrappers.concat(e.wrap)), e.bufferLength != null && (n.bufferLength = e.bufferLength), n;
    }
    hasWrappers() {
      return this.wrappers.length > 0;
    }
    getName(e) {
      return this.termNames ? this.termNames[e] : String(e <= this.maxNode && this.nodeSet.types[e].name || e);
    }
    get eofTerm() {
      return this.maxNode + 1;
    }
    get topNode() {
      return this.nodeSet.types[this.top[1]];
    }
    dynamicPrecedence(e) {
      let n = this.dynamicPrecedences;
      return n == null ? 0 : n[e] || 0;
    }
    parseDialect(e) {
      let n = Object.keys(this.dialects), r = n.map(() => false);
      if (e)
        for (let s of e.split(" ")) {
          let o = n.indexOf(s);
          o >= 0 && (r[o] = true);
        }
      let i = null;
      for (let s = 0; s < n.length; s++)
        if (!r[s])
          for (let o = this.dialects[n[s]], a; (a = this.data[o++]) != 65535; )
            (i || (i = new Uint8Array(this.maxTerm + 1)))[a] = 1;
      return new bKe(e, r, i);
    }
    static deserialize(e) {
      return new dm(e);
    }
  };
  function kc(t, e) {
    return t[e] | t[e + 1] << 16;
  }
  function kKe(t) {
    let e = null;
    for (let n of t) {
      let r = n.p.stoppedAt;
      (n.pos == n.p.stream.end || r != null && n.pos > r) && n.p.parser.stateFlag(n.state, 2) && (!e || e.score < n.score) && (e = n);
    }
    return e;
  }
  function fV(t) {
    if (t.external) {
      let e = t.extend ? 1 : 0;
      return (n, r) => t.external(n, r) << 1 | e;
    }
    return t.get;
  }
  const PKe = 55, CKe = 1, _Ke = 56, TKe = 2, EKe = 57, IKe = 3, pV = 4, $Ke = 5, Zj = 6, Aae = 7, Rae = 8, Mae = 9, Dae = 10, AKe = 11, RKe = 12, MKe = 13, f$ = 58, DKe = 14, LKe = 15, gV = 59, Lae = 21, jKe = 23, jae = 24, NKe = 25, rD = 27, Nae = 28, QKe = 29, zKe = 32, FKe = 35, BKe = 37, UKe = 38, VKe = 0, XKe = 1, WKe = {
    area: true,
    base: true,
    br: true,
    col: true,
    command: true,
    embed: true,
    frame: true,
    hr: true,
    img: true,
    input: true,
    keygen: true,
    link: true,
    meta: true,
    param: true,
    source: true,
    track: true,
    wbr: true,
    menuitem: true
  }, ZKe = {
    dd: true,
    li: true,
    optgroup: true,
    option: true,
    p: true,
    rp: true,
    rt: true,
    tbody: true,
    td: true,
    tfoot: true,
    th: true,
    tr: true
  }, mV = {
    dd: {
      dd: true,
      dt: true
    },
    dt: {
      dd: true,
      dt: true
    },
    li: {
      li: true
    },
    option: {
      option: true,
      optgroup: true
    },
    optgroup: {
      optgroup: true
    },
    p: {
      address: true,
      article: true,
      aside: true,
      blockquote: true,
      dir: true,
      div: true,
      dl: true,
      fieldset: true,
      footer: true,
      form: true,
      h1: true,
      h2: true,
      h3: true,
      h4: true,
      h5: true,
      h6: true,
      header: true,
      hgroup: true,
      hr: true,
      menu: true,
      nav: true,
      ol: true,
      p: true,
      pre: true,
      section: true,
      table: true,
      ul: true
    },
    rp: {
      rp: true,
      rt: true
    },
    rt: {
      rp: true,
      rt: true
    },
    tbody: {
      tbody: true,
      tfoot: true
    },
    td: {
      td: true,
      th: true
    },
    tfoot: {
      tbody: true
    },
    th: {
      td: true,
      th: true
    },
    thead: {
      tbody: true,
      tfoot: true
    },
    tr: {
      tr: true
    }
  };
  function HKe(t) {
    return t == 45 || t == 46 || t == 58 || t >= 65 && t <= 90 || t == 95 || t >= 97 && t <= 122 || t >= 161;
  }
  let yV = null, vV = null, OV = 0;
  function iD(t, e) {
    let n = t.pos + e;
    if (OV == n && vV == t)
      return yV;
    let r = t.peek(e), i = "";
    for (; HKe(r); )
      i += String.fromCharCode(r), r = t.peek(++e);
    return vV = t, OV = n, yV = i ? i.toLowerCase() : r == YKe || r == GKe ? void 0 : null;
  }
  const Qae = 60, wP = 62, Hj = 47, YKe = 63, GKe = 33, qKe = 45;
  function SV(t, e) {
    this.name = t, this.parent = e;
  }
  const KKe = [
    Zj,
    Dae,
    Aae,
    Rae,
    Mae
  ], JKe = new $ae({
    start: null,
    shift(t, e, n, r) {
      return KKe.indexOf(e) > -1 ? new SV(iD(r, 1) || "", t) : t;
    },
    reduce(t, e) {
      return e == Lae && t ? t.parent : t;
    },
    reuse(t, e, n, r) {
      let i = e.type.id;
      return i == Zj || i == BKe ? new SV(iD(r, 1) || "", t) : t;
    },
    strict: false
  }), eJe = new po((t, e) => {
    if (t.next != Qae) {
      t.next < 0 && e.context && t.acceptToken(f$);
      return;
    }
    t.advance();
    let n = t.next == Hj;
    n && t.advance();
    let r = iD(t, 0);
    if (r === void 0)
      return;
    if (!r)
      return t.acceptToken(n ? LKe : DKe);
    let i = e.context ? e.context.name : null;
    if (n) {
      if (r == i)
        return t.acceptToken(AKe);
      if (i && ZKe[i])
        return t.acceptToken(f$, -2);
      if (e.dialectEnabled(VKe))
        return t.acceptToken(RKe);
      for (let s = e.context; s; s = s.parent)
        if (s.name == r)
          return;
      t.acceptToken(MKe);
    } else {
      if (r == "script")
        return t.acceptToken(Aae);
      if (r == "style")
        return t.acceptToken(Rae);
      if (r == "textarea")
        return t.acceptToken(Mae);
      if (WKe.hasOwnProperty(r))
        return t.acceptToken(Dae);
      i && mV[i] && mV[i][r] ? t.acceptToken(f$, -1) : t.acceptToken(Zj);
    }
  }, {
    contextual: true
  }), tJe = new po((t) => {
    for (let e = 0, n = 0; ; n++) {
      if (t.next < 0) {
        n && t.acceptToken(gV);
        break;
      }
      if (t.next == qKe)
        e++;
      else if (t.next == wP && e >= 2) {
        n >= 3 && t.acceptToken(gV, -2);
        break;
      } else
        e = 0;
      t.advance();
    }
  });
  function nJe(t) {
    for (; t; t = t.parent)
      if (t.name == "svg" || t.name == "math")
        return true;
    return false;
  }
  const rJe = new po((t, e) => {
    if (t.next == Hj && t.peek(1) == wP) {
      let n = e.dialectEnabled(XKe) || nJe(e.context);
      t.acceptToken(n ? $Ke : pV, 2);
    } else
      t.next == wP && t.acceptToken(pV, 1);
  });
  function Yj(t, e, n) {
    let r = 2 + t.length;
    return new po((i) => {
      for (let s = 0, o = 0, a = 0; ; a++) {
        if (i.next < 0) {
          a && i.acceptToken(e);
          break;
        }
        if (s == 0 && i.next == Qae || s == 1 && i.next == Hj || s >= 2 && s < r && i.next == t.charCodeAt(s - 2))
          s++, o++;
        else if (s == r && i.next == wP) {
          a > o ? i.acceptToken(e, -o) : i.acceptToken(n, -(o - 2));
          break;
        } else if ((i.next == 10 || i.next == 13) && a) {
          i.acceptToken(e, 1);
          break;
        } else
          s = o = 0;
        i.advance();
      }
    });
  }
  const iJe = Yj("script", PKe, CKe), sJe = Yj("style", _Ke, TKe), oJe = Yj("textarea", EKe, IKe), aJe = zm({
    "Text RawText IncompleteTag IncompleteCloseTag": V.content,
    "StartTag StartCloseTag SelfClosingEndTag EndTag": V.angleBracket,
    TagName: V.tagName,
    "MismatchedCloseTag/TagName": [
      V.tagName,
      V.invalid
    ],
    AttributeName: V.attributeName,
    "AttributeValue UnquotedAttributeValue": V.attributeValue,
    Is: V.definitionOperator,
    "EntityReference CharacterReference": V.character,
    Comment: V.blockComment,
    ProcessingInst: V.processingInstruction,
    DoctypeDecl: V.documentMeta
  }), lJe = dm.deserialize({
    version: 14,
    states: ",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59p,59pO(OQ#|O,59rO(TQ#|O,59sOOO`-E7X-E7XO(YQ&rO'#CtOOQW'#D['#D[O(hQ&rO1G.xOOOa1G.x1G.xOOO`1G/Z1G/ZO(sQ&rO1G/ROOOb1G/R1G/RO)OQ&rO1G/UOOOd1G/U1G/UO)ZQ&rO1G/XOOO`1G/X1G/XO)fQ&rO1G/ZOOOa-E7]-E7]O)qQ#tO'#CzOOO`1G.w1G.wOOOb-E7^-E7^O)vQ#tO'#C}OOOd-E7_-E7_O){Q#tO'#DQOOO`-E7`-E7`O*QQ#|O,59nOOOp-E7a-E7aOOO`1G/[1G/[OOO`1G/^1G/^OOO`1G/_1G/_O*VQ,UO,59`OOQW-E7Y-E7YOOOa7+$d7+$dOOO`7+$u7+$uOOOb7+$m7+$mOOOd7+$p7+$pOOO`7+$s7+$sO*bQ#|O,59fO*gQ#|O,59iO*lQ#|O,59lOOO`1G/Y1G/YO*qO7[O'#CwO+SOMhO'#CwOOQW1G.z1G.zOOO`1G/Q1G/QOOO`1G/T1G/TOOO`1G/W1G/WOOOO'#D]'#D]O+eO7[O,59cOOQW,59c,59cOOOO'#D^'#D^O+vOMhO,59cOOOO-E7Z-E7ZOOQW1G.}1G.}OOOO-E7[-E7[",
    stateData: ",c~O!_OS~OUSOVPOWQOXROYTO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O|_O!eZO~OgaO~OgbO~OgcO~OgdO~OgeO~O!XfOPmP![mP~O!YiOQpP![pP~O!ZlORsP![sP~OUSOVPOWQOXROYTOZqO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O!eZO~O![rO~P#gO!]sO!fuO~OgvO~OgwO~OS|OT}OiyO~OS!POT}OiyO~OS!ROT}OiyO~OS!TOT}OiyO~OS}OT}OiyO~O!XfOPmX![mX~OP!WO![!XO~O!YiOQpX![pX~OQ!ZO![!XO~O!ZlORsX![sX~OR!]O![!XO~O![!XO~P#gOg!_O~O!]sO!f!aO~OS!bO~OS!cO~Oj!dOShXThXihX~OS!fOT!gOiyO~OS!hOT!gOiyO~OS!iOT!gOiyO~OS!jOT!gOiyO~OS!gOT!gOiyO~Og!kO~Og!lO~Og!mO~OS!nO~Ol!qO!a!oO!c!pO~OS!rO~OS!sO~OS!tO~Ob!uOc!uOd!uO!a!wO!b!uO~Ob!xOc!xOd!xO!c!wO!d!xO~Ob!uOc!uOd!uO!a!{O!b!uO~Ob!xOc!xOd!xO!c!{O!d!xO~OT~cbd!ey|!e~",
    goto: "%q!aPPPPPPPPPPPPPPPPPPPPP!b!hP!nPP!zP!}#Q#T#Z#^#a#g#j#m#s#y!bP!b!bP$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",
    nodeNames: "\u26A0 StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",
    maxTerm: 68,
    context: JKe,
    nodeProps: [
      [
        "closedBy",
        -10,
        1,
        2,
        3,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        "EndTag",
        6,
        "EndTag SelfClosingEndTag",
        -4,
        22,
        31,
        34,
        37,
        "CloseTag"
      ],
      [
        "openedBy",
        4,
        "StartTag StartCloseTag",
        5,
        "StartTag",
        -4,
        30,
        33,
        36,
        38,
        "OpenTag"
      ],
      [
        "group",
        -10,
        14,
        15,
        18,
        19,
        20,
        21,
        40,
        41,
        42,
        43,
        "Entity",
        17,
        "Entity TextContent",
        -3,
        29,
        32,
        35,
        "TextContent Entity"
      ],
      [
        "isolate",
        -11,
        22,
        30,
        31,
        33,
        34,
        36,
        37,
        38,
        39,
        42,
        43,
        "ltr",
        -3,
        27,
        28,
        40,
        ""
      ]
    ],
    propSources: [
      aJe
    ],
    skippedNodes: [
      0
    ],
    repeatNodeCount: 9,
    tokenData: "!<p!aR!YOX$qXY,QYZ,QZ[$q[]&X]^,Q^p$qpq,Qqr-_rs3_sv-_vw3}wxHYx}-_}!OH{!O!P-_!P!Q$q!Q![-_![!]Mz!]!^-_!^!_!$S!_!`!;x!`!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4U-_4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!Z$|caPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr$qrs&}sv$qvw+Pwx(tx!^$q!^!_*V!_!a&X!a#S$q#S#T&X#T;'S$q;'S;=`+z<%lO$q!R&bXaP!b`!dpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&Xq'UVaP!dpOv&}wx'kx!^&}!^!_(V!_;'S&};'S;=`(n<%lO&}P'pTaPOv'kw!^'k!_;'S'k;'S;=`(P<%lO'kP(SP;=`<%l'kp([S!dpOv(Vx;'S(V;'S;=`(h<%lO(Vp(kP;=`<%l(Vq(qP;=`<%l&}a({WaP!b`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t`)jT!b`Or)esv)ew;'S)e;'S;=`)y<%lO)e`)|P;=`<%l)ea*SP;=`<%l(t!Q*^V!b`!dpOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!Q*vP;=`<%l*V!R*|P;=`<%l&XW+UYlWOX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+PW+wP;=`<%l+P!Z+}P;=`<%l$q!a,]`aP!b`!dp!_^OX&XXY,QYZ,QZ]&X]^,Q^p&Xpq,Qqr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!_-ljiSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_*V!_!a&X!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q[/ebiSlWOX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+PS0rXiSqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0mS1bP;=`<%l0m[1hP;=`<%l/^!V1vciSaP!b`!dpOq&Xqr1krs&}sv1kvw0mwx(tx!P1k!P!Q&X!Q!^1k!^!_*V!_!a&X!a#s1k#s$f&X$f;'S1k;'S;=`3R<%l?Ah1k?Ah?BY&X?BY?Mn1k?MnO&X!V3UP;=`<%l1k!_3[P;=`<%l-_!Z3hV!ahaP!dpOv&}wx'kx!^&}!^!_(V!_;'S&};'S;=`(n<%lO&}!_4WiiSlWd!ROX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst>]tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^/^!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!Z5zblWOX5uXZ7SZ[5u[^7S^p5uqr5urs7Sst+Ptw5uwx7Sx!]5u!]!^7w!^!a7S!a#S5u#S#T7S#T;'S5u;'S;=`8n<%lO5u!R7VVOp7Sqs7St!]7S!]!^7l!^;'S7S;'S;=`7q<%lO7S!R7qOb!R!R7tP;=`<%l7S!Z8OYlWb!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z8qP;=`<%l5u!_8{iiSlWOX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst/^tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^:j!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!_:sbiSlWb!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!V<QciSOp7Sqr;{rs7Sst0mtw;{wx7Sx!P;{!P!Q7S!Q!];{!]!^=]!^!a7S!a#s;{#s$f7S$f;'S;{;'S;=`>P<%l?Ah;{?Ah?BY7S?BY?Mn;{?MnO7S!V=dXiSb!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!V>SP;=`<%l;{!_>YP;=`<%l8t!_>dhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^/^!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!Z@TalWOX@OXZAYZ[@O[^AY^p@Oqr@OrsAYsw@OwxAYx!]@O!]!^Az!^!aAY!a#S@O#S#TAY#T;'S@O;'S;=`Bq<%lO@O!RA]UOpAYq!]AY!]!^Ao!^;'SAY;'S;=`At<%lOAY!RAtOc!R!RAwP;=`<%lAY!ZBRYlWc!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!ZBtP;=`<%l@O!_COhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^Dj!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!_DsbiSlWc!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VFQbiSOpAYqrE{rsAYswE{wxAYx!PE{!P!QAY!Q!]E{!]!^GY!^!aAY!a#sE{#s$fAY$f;'SE{;'S;=`G|<%l?AhE{?Ah?BYAY?BY?MnE{?MnOAY!VGaXiSc!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!VHPP;=`<%lE{!_HVP;=`<%lBw!ZHcW!cxaP!b`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t!aIYliSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OKQ!O!P-_!P!Q$q!Q!^-_!^!_*V!_!a&X!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!aK_kiSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_*V!_!`&X!`!aMS!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!TM_XaP!b`!dp!fQOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!aNZ!ZiSgQaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OMz!O!PMz!P!Q$q!Q![Mz![!]Mz!]!^-_!^!_*V!_!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f$}-_$}%OMz%O%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4UMz4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Je-_$Je$JgMz$Jg$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!a!$PP;=`<%lMz!R!$ZY!b`!dpOq*Vqr!$yrs(Vsv*Vwx)ex!a*V!a!b!4t!b;'S*V;'S;=`*s<%lO*V!R!%Q]!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!%y!O!f*V!f!g!']!g#W*V#W#X!0`#X;'S*V;'S;=`*s<%lO*V!R!&QX!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!&m!O;'S*V;'S;=`*s<%lO*V!R!&vV!b`!dp!ePOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!'dX!b`!dpOr*Vrs(Vsv*Vwx)ex!q*V!q!r!(P!r;'S*V;'S;=`*s<%lO*V!R!(WX!b`!dpOr*Vrs(Vsv*Vwx)ex!e*V!e!f!(s!f;'S*V;'S;=`*s<%lO*V!R!(zX!b`!dpOr*Vrs(Vsv*Vwx)ex!v*V!v!w!)g!w;'S*V;'S;=`*s<%lO*V!R!)nX!b`!dpOr*Vrs(Vsv*Vwx)ex!{*V!{!|!*Z!|;'S*V;'S;=`*s<%lO*V!R!*bX!b`!dpOr*Vrs(Vsv*Vwx)ex!r*V!r!s!*}!s;'S*V;'S;=`*s<%lO*V!R!+UX!b`!dpOr*Vrs(Vsv*Vwx)ex!g*V!g!h!+q!h;'S*V;'S;=`*s<%lO*V!R!+xY!b`!dpOr!+qrs!,hsv!+qvw!-Swx!.[x!`!+q!`!a!/j!a;'S!+q;'S;=`!0Y<%lO!+qq!,mV!dpOv!,hvx!-Sx!`!,h!`!a!-q!a;'S!,h;'S;=`!.U<%lO!,hP!-VTO!`!-S!`!a!-f!a;'S!-S;'S;=`!-k<%lO!-SP!-kO|PP!-nP;=`<%l!-Sq!-xS!dp|POv(Vx;'S(V;'S;=`(h<%lO(Vq!.XP;=`<%l!,ha!.aX!b`Or!.[rs!-Ssv!.[vw!-Sw!`!.[!`!a!.|!a;'S!.[;'S;=`!/d<%lO!.[a!/TT!b`|POr)esv)ew;'S)e;'S;=`)y<%lO)ea!/gP;=`<%l!.[!R!/sV!b`!dp|POr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!0]P;=`<%l!+q!R!0gX!b`!dpOr*Vrs(Vsv*Vwx)ex#c*V#c#d!1S#d;'S*V;'S;=`*s<%lO*V!R!1ZX!b`!dpOr*Vrs(Vsv*Vwx)ex#V*V#V#W!1v#W;'S*V;'S;=`*s<%lO*V!R!1}X!b`!dpOr*Vrs(Vsv*Vwx)ex#h*V#h#i!2j#i;'S*V;'S;=`*s<%lO*V!R!2qX!b`!dpOr*Vrs(Vsv*Vwx)ex#m*V#m#n!3^#n;'S*V;'S;=`*s<%lO*V!R!3eX!b`!dpOr*Vrs(Vsv*Vwx)ex#d*V#d#e!4Q#e;'S*V;'S;=`*s<%lO*V!R!4XX!b`!dpOr*Vrs(Vsv*Vwx)ex#X*V#X#Y!+q#Y;'S*V;'S;=`*s<%lO*V!R!4{Y!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!a!4t!a!b!:]!b;'S!4t;'S;=`!;r<%lO!4tq!5pV!dpOv!5kvx!6Vx!a!5k!a!b!7W!b;'S!5k;'S;=`!8V<%lO!5kP!6YTO!a!6V!a!b!6i!b;'S!6V;'S;=`!7Q<%lO!6VP!6lTO!`!6V!`!a!6{!a;'S!6V;'S;=`!7Q<%lO!6VP!7QOyPP!7TP;=`<%l!6Vq!7]V!dpOv!5kvx!6Vx!`!5k!`!a!7r!a;'S!5k;'S;=`!8V<%lO!5kq!7yS!dpyPOv(Vx;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!b`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!b`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!b`yPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!b`!dpyPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!<TXjSaP!b`!dpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X",
    tokenizers: [
      iJe,
      sJe,
      oJe,
      rJe,
      eJe,
      tJe,
      0,
      1,
      2,
      3,
      4,
      5
    ],
    topRules: {
      Document: [
        0,
        16
      ]
    },
    dialects: {
      noMatch: 0,
      selfClosing: 515
    },
    tokenPrec: 517
  });
  function zae(t, e) {
    let n = /* @__PURE__ */ Object.create(null);
    for (let r of t.getChildren(jae)) {
      let i = r.getChild(NKe), s = r.getChild(rD) || r.getChild(Nae);
      i && (n[e.read(i.from, i.to)] = s ? s.type.id == rD ? e.read(s.from + 1, s.to - 1) : e.read(s.from, s.to) : "");
    }
    return n;
  }
  function wV(t, e) {
    let n = t.getChild(jKe);
    return n ? e.read(n.from, n.to) : " ";
  }
  function p$(t, e, n) {
    let r;
    for (let i of n)
      if (!i.attrs || i.attrs(r || (r = zae(t.node.parent.firstChild, e))))
        return {
          parser: i.parser
        };
    return null;
  }
  function Fae(t = [], e = []) {
    let n = [], r = [], i = [], s = [];
    for (let a of t)
      (a.tag == "script" ? n : a.tag == "style" ? r : a.tag == "textarea" ? i : s).push(a);
    let o = e.length ? /* @__PURE__ */ Object.create(null) : null;
    for (let a of e)
      (o[a.name] || (o[a.name] = [])).push(a);
    return joe((a, l) => {
      let c = a.type.id;
      if (c == QKe)
        return p$(a, l, n);
      if (c == zKe)
        return p$(a, l, r);
      if (c == FKe)
        return p$(a, l, i);
      if (c == Lae && s.length) {
        let u = a.node, d = u.firstChild, h = d && wV(d, l), f;
        if (h) {
          for (let y of s)
            if (y.tag == h && (!y.attrs || y.attrs(f || (f = zae(d, l))))) {
              let g = u.lastChild, O = g.type.id == UKe ? g.from : u.to;
              if (O > d.to)
                return {
                  parser: y.parser,
                  overlay: [
                    {
                      from: d.to,
                      to: O
                    }
                  ]
                };
            }
        }
      }
      if (o && c == jae) {
        let u = a.node, d;
        if (d = u.firstChild) {
          let h = o[l.read(d.from, d.to)];
          if (h)
            for (let f of h) {
              if (f.tagName && f.tagName != wV(u.parent, l))
                continue;
              let y = u.lastChild;
              if (y.type.id == rD) {
                let g = y.from + 1, O = y.lastChild, S = y.to - (O && O.isError ? 0 : 1);
                if (S > g)
                  return {
                    parser: f.parser,
                    overlay: [
                      {
                        from: g,
                        to: S
                      }
                    ]
                  };
              } else if (y.type.id == Nae)
                return {
                  parser: f.parser,
                  overlay: [
                    {
                      from: y.from,
                      to: y.to
                    }
                  ]
                };
            }
        }
      }
      return null;
    });
  }
  const cJe = 122, xV = 1, uJe = 123, dJe = 124, Bae = 2, hJe = 125, fJe = 3, pJe = 4, Uae = [
    9,
    10,
    11,
    12,
    13,
    32,
    133,
    160,
    5760,
    8192,
    8193,
    8194,
    8195,
    8196,
    8197,
    8198,
    8199,
    8200,
    8201,
    8202,
    8232,
    8233,
    8239,
    8287,
    12288
  ], gJe = 58, mJe = 40, Vae = 95, yJe = 91, Ob = 45, vJe = 46, OJe = 35, SJe = 37, wJe = 38, xJe = 92, bJe = 10, kJe = 42;
  function PO(t) {
    return t >= 65 && t <= 90 || t >= 97 && t <= 122 || t >= 161;
  }
  function Gj(t) {
    return t >= 48 && t <= 57;
  }
  function bV(t) {
    return Gj(t) || t >= 97 && t <= 102 || t >= 65 && t <= 70;
  }
  const Xae = (t, e, n) => (r, i) => {
    for (let s = false, o = 0, a = 0; ; a++) {
      let { next: l } = r;
      if (PO(l) || l == Ob || l == Vae || s && Gj(l))
        !s && (l != Ob || a > 0) && (s = true), o === a && l == Ob && o++, r.advance();
      else if (l == xJe && r.peek(1) != bJe) {
        if (r.advance(), bV(r.next)) {
          do
            r.advance();
          while (bV(r.next));
          r.next == 32 && r.advance();
        } else
          r.next > -1 && r.advance();
        s = true;
      } else {
        s && r.acceptToken(o == 2 && i.canShift(Bae) ? e : l == mJe ? n : t);
        break;
      }
    }
  }, PJe = new po(Xae(uJe, Bae, dJe)), CJe = new po(Xae(hJe, fJe, pJe)), _Je = new po((t) => {
    if (Uae.includes(t.peek(-1))) {
      let { next: e } = t;
      (PO(e) || e == Vae || e == OJe || e == vJe || e == kJe || e == yJe || e == gJe && PO(t.peek(1)) || e == Ob || e == wJe) && t.acceptToken(cJe);
    }
  }), TJe = new po((t) => {
    if (!Uae.includes(t.peek(-1))) {
      let { next: e } = t;
      if (e == SJe && (t.advance(), t.acceptToken(xV)), PO(e)) {
        do
          t.advance();
        while (PO(t.next) || Gj(t.next));
        t.acceptToken(xV);
      }
    }
  }), EJe = zm({
    "AtKeyword import charset namespace keyframes media supports": V.definitionKeyword,
    "from to selector": V.keyword,
    NamespaceName: V.namespace,
    KeyframeName: V.labelName,
    KeyframeRangeName: V.operatorKeyword,
    TagName: V.tagName,
    ClassName: V.className,
    PseudoClassName: V.constant(V.className),
    IdName: V.labelName,
    "FeatureName PropertyName": V.propertyName,
    AttributeName: V.attributeName,
    NumberLiteral: V.number,
    KeywordQuery: V.keyword,
    UnaryQueryOp: V.operatorKeyword,
    "CallTag ValueName": V.atom,
    VariableName: V.variableName,
    Callee: V.operatorKeyword,
    Unit: V.unit,
    "UniversalSelector NestingSelector": V.definitionOperator,
    "MatchOp CompareOp": V.compareOperator,
    "ChildOp SiblingOp, LogicOp": V.logicOperator,
    BinOp: V.arithmeticOperator,
    Important: V.modifier,
    Comment: V.blockComment,
    ColorLiteral: V.color,
    "ParenthesizedContent StringLiteral": V.string,
    ":": V.punctuation,
    "PseudoOp #": V.derefOperator,
    "; ,": V.separator,
    "( )": V.paren,
    "[ ]": V.squareBracket,
    "{ }": V.brace
  }), IJe = {
    __proto__: null,
    lang: 38,
    "nth-child": 38,
    "nth-last-child": 38,
    "nth-of-type": 38,
    "nth-last-of-type": 38,
    dir: 38,
    "host-context": 38,
    if: 84,
    url: 124,
    "url-prefix": 124,
    domain: 124,
    regexp: 124
  }, $Je = {
    __proto__: null,
    or: 98,
    and: 98,
    not: 106,
    only: 106,
    layer: 170
  }, AJe = {
    __proto__: null,
    selector: 112,
    layer: 166
  }, RJe = {
    __proto__: null,
    "@import": 162,
    "@media": 174,
    "@charset": 178,
    "@namespace": 182,
    "@keyframes": 188,
    "@supports": 200,
    "@scope": 204
  }, MJe = {
    __proto__: null,
    to: 207
  }, DJe = dm.deserialize({
    version: 14,
    states: "EbQYQdOOO#qQdOOP#xO`OOOOQP'#Cf'#CfOOQP'#Ce'#CeO#}QdO'#ChO$nQaO'#CcO$xQdO'#CkO%TQdO'#DpO%YQdO'#DrO%_QdO'#DuO%_QdO'#DxOOQP'#FV'#FVO&eQhO'#EhOOQS'#FU'#FUOOQS'#Ek'#EkQYQdOOO&lQdO'#EOO&PQhO'#EUO&lQdO'#EWO'aQdO'#EYO'lQdO'#E]O'tQhO'#EcO(VQdO'#EeO(bQaO'#CfO)VQ`O'#D{O)[Q`O'#F`O)gQdO'#F`QOQ`OOP)qO&jO'#CaPOOO)C@t)C@tOOQP'#Cj'#CjOOQP,59S,59SO#}QdO,59SO)|QdO,59VO%TQdO,5:[O%YQdO,5:^O%_QdO,5:aO%_QdO,5:cO%_QdO,5:dO%_QdO'#ErO*XQ`O,58}O*aQdO'#DzOOQS,58},58}OOQP'#Cn'#CnOOQO'#Dn'#DnOOQP,59V,59VO*hQ`O,59VO*mQ`O,59VOOQP'#Dq'#DqOOQP,5:[,5:[OOQO'#Ds'#DsO*rQpO,5:^O+]QaO,5:aO+sQaO,5:dOOQW'#DZ'#DZO,ZQhO'#DdO,xQhO'#FaO'tQhO'#DbO-WQ`O'#DhOOQW'#F['#F[O-]Q`O,5;SO-eQ`O'#DeOOQS-E8i-E8iOOQ['#Cs'#CsO-jQdO'#CtO.QQdO'#CzO.hQdO'#C}O/OQ!pO'#DPO1RQ!jO,5:jOOQO'#DU'#DUO*mQ`O'#DTO1cQ!nO'#FXO3`Q`O'#DVO3eQ`O'#DkOOQ['#FX'#FXO-`Q`O,5:pO3jQ!bO,5:rOOQS'#E['#E[O3rQ`O,5:tO3wQdO,5:tOOQO'#E_'#E_O4PQ`O,5:wO4UQhO,5:}O%_QdO'#DgOOQS,5;P,5;PO-eQ`O,5;PO4^QdO,5;PO4fQdO,5:gO4vQdO'#EtO5TQ`O,5;zO5TQ`O,5;zPOOO'#Ej'#EjP5`O&jO,58{POOO,58{,58{OOQP1G.n1G.nOOQP1G.q1G.qO*hQ`O1G.qO*mQ`O1G.qOOQP1G/v1G/vO5kQpO1G/xO5sQaO1G/{O6ZQaO1G/}O6qQaO1G0OO7XQaO,5;^OOQO-E8p-E8pOOQS1G.i1G.iO7cQ`O,5:fO7hQdO'#DoO7oQdO'#CrOOQP1G/x1G/xO&lQdO1G/xO7vQ!jO'#DZO8UQ!bO,59vO8^QhO,5:OOOQO'#F]'#F]O8XQ!bO,59zO'tQhO,59xO8fQhO'#EvO8sQ`O,5;{O9OQhO,59|O9uQhO'#DiOOQW,5:S,5:SOOQS1G0n1G0nOOQW,5:P,5:PO9|Q!fO'#FYOOQS'#FY'#FYOOQS'#Em'#EmO;^QdO,59`OOQ[,59`,59`O;tQdO,59fOOQ[,59f,59fO<[QdO,59iOOQ[,59i,59iOOQ[,59k,59kO&lQdO,59mO<rQhO'#EQOOQW'#EQ'#EQO=WQ`O1G0UO1[QhO1G0UOOQ[,59o,59oO'tQhO'#DXOOQ[,59q,59qO=]Q#tO,5:VOOQS1G0[1G0[OOQS1G0^1G0^OOQS1G0`1G0`O=hQ`O1G0`O=mQdO'#E`OOQS1G0c1G0cOOQS1G0i1G0iO=xQaO,5:RO-`Q`O1G0kOOQS1G0k1G0kO-eQ`O1G0kO>PQ!fO1G0ROOQO1G0R1G0ROOQO,5;`,5;`O>gQdO,5;`OOQO-E8r-E8rO>tQ`O1G1fPOOO-E8h-E8hPOOO1G.g1G.gOOQP7+$]7+$]OOQP7+%d7+%dO&lQdO7+%dOOQS1G0Q1G0QO?PQaO'#F_O?ZQ`O,5:ZO?`Q!fO'#ElO@^QdO'#FWO@hQ`O,59^O@mQ!bO7+%dO&lQdO1G/bO@uQhO1G/fOOQW1G/j1G/jOOQW1G/d1G/dOAWQhO,5;bOOQO-E8t-E8tOAfQhO'#DZOAtQhO'#F^OBPQ`O'#F^OBUQ`O,5:TOOQS-E8k-E8kOOQ[1G.z1G.zOOQ[1G/Q1G/QOOQ[1G/T1G/TOOQ[1G/X1G/XOBZQdO,5:lOOQS7+%p7+%pOB`Q`O7+%pOBeQhO'#DYOBmQ`O,59sO'tQhO,59sOOQ[1G/q1G/qOBuQ`O1G/qOOQS7+%z7+%zOBzQbO'#DPOOQO'#Eb'#EbOCYQ`O'#EaOOQO'#Ea'#EaOCeQ`O'#EwOCmQdO,5:zOOQS,5:z,5:zOOQ[1G/m1G/mOOQS7+&V7+&VO-`Q`O7+&VOCxQ!fO'#EsO&lQdO'#EsOEPQdO7+%mOOQO7+%m7+%mOOQO1G0z1G0zOEdQ!bO<<IOOElQdO'#EqOEvQ`O,5;yOOQP1G/u1G/uOOQS-E8j-E8jOFOQdO'#EpOFYQ`O,5;rOOQ]1G.x1G.xOOQP<<IO<<IOOFbQdO7+$|OOQO'#D]'#D]OFiQ!bO7+%QOFqQhO'#EoOF{Q`O,5;xO&lQdO,5;xOOQW1G/o1G/oOOQO'#ES'#ESOGTQ`O1G0WOOQS<<I[<<I[O&lQdO,59tOGnQhO1G/_OOQ[1G/_1G/_OGuQ`O1G/_OOQW-E8l-E8lOOQ[7+%]7+%]OOQO,5:{,5:{O=pQdO'#ExOCeQ`O,5;cOOQS,5;c,5;cOOQS-E8u-E8uOOQS1G0f1G0fOOQS<<Iq<<IqOG}Q!fO,5;_OOQS-E8q-E8qOOQO<<IX<<IXOOQPAN>jAN>jOIUQaO,5;]OOQO-E8o-E8oOI`QdO,5;[OOQO-E8n-E8nOOQW<<Hh<<HhOOQW<<Hl<<HlOIjQhO<<HlOI{QhO,5;ZOJWQ`O,5;ZOOQO-E8m-E8mOJ]QdO1G1dOBZQdO'#EuOJgQ`O7+%rOOQW7+%r7+%rOJoQ!bO1G/`OOQ[7+$y7+$yOJzQhO7+$yPKRQ`O'#EnOOQO,5;d,5;dOOQO-E8v-E8vOOQS1G0}1G0}OKWQ`OAN>WO&lQdO1G0uOK]Q`O7+'OOOQO,5;a,5;aOOQO-E8s-E8sOOQW<<I^<<I^OOQ[<<He<<HePOQW,5;Y,5;YOOQWG23rG23rOKeQdO7+&a",
    stateData: "Kx~O#sOS#tQQ~OW[OZ[O]TO`VOaVOi]OjWOmXO!jYO!mZO!saO!ybO!{cO!}dO#QeO#WfO#YgO#oRO~OQiOW[OZ[O]TO`VOaVOi]OjWOmXO!jYO!mZO!saO!ybO!{cO!}dO#QeO#WfO#YgO#ohO~O#m$SP~P!dO#tmO~O#ooO~O]qO`rOarOjsOmtO!juO!mwO#nvO~OpzO!^xO~P$SOc!QO#o|O#p}O~O#o!RO~O#o!TO~OW[OZ[O]TO`VOaVOjWOmXO!jYO!mZO#oRO~OS!]Oe!YO!V![O!Y!`O#q!XOp$TP~Ok$TP~P&POQ!jOe!cOm!dOp!eOr!mOt!mOz!kO!`!lO#o!bO#p!hO#}!fO~Ot!qO!`!lO#o!pO~Ot!sO#o!sO~OS!]Oe!YO!V![O!Y!`O#q!XO~Oe!vOpzO#Z!xO~O]YX`YX`!pXaYXjYXmYXpYX!^YX!jYX!mYX#nYX~O`!zO~Ok!{O#m$SXo$SX~O#m$SXo$SX~P!dO#u#OO#v#OO#w#QO~Oc#UO#o|O#p}O~OpzO!^xO~Oo$SP~P!dOe#`O~Oe#aO~Ol#bO!h#cO~O]qO`rOarOjsOmtO~Op!ia!^!ia!j!ia!m!ia#n!iad!ia~P*zOp!la!^!la!j!la!m!la#n!lad!la~P*zOR#gOS!]Oe!YOr#gOt#gO!V![O!Y!`O#q#dO#}!fO~O!R#iO!^#jOk$TXp$TX~Oe#mO~Ok#oOpzO~Oe!vO~O]#rO`#rOd#uOi#rOj#rOk#rO~P&lO]#rO`#rOi#rOj#rOk#rOl#wO~P&lO]#rO`#rOi#rOj#rOk#rOo#yO~P&lOP#zOSsXesXksXvsX!VsX!YsX!usX!wsX#qsX!TsXQsX]sX`sXdsXisXjsXmsXpsXrsXtsXzsX!`sX#osX#psX#}sXlsXosX!^sX!qsX#msX~Ov#{O!u#|O!w#}Ok$TP~P'tOe#aOS#{Xk#{Xv#{X!V#{X!Y#{X!u#{X!w#{X#q#{XQ#{X]#{X`#{Xd#{Xi#{Xj#{Xm#{Xp#{Xr#{Xt#{Xz#{X!`#{X#o#{X#p#{X#}#{Xl#{Xo#{X!^#{X!q#{X#m#{X~Oe$RO~Oe$TO~Ok$VOv#{O~Ok$WO~Ot$XO!`!lO~Op$YO~OpzO!R#iO~OpzO#Z$`O~O!q$bOk!oa#m!oao!oa~P&lOk#hX#m#hXo#hX~P!dOk!{O#m$Sao$Sa~O#u#OO#v#OO#w$hO~Ol$jO!h$kO~Op!ii!^!ii!j!ii!m!ii#n!iid!ii~P*zOp!ki!^!ki!j!ki!m!ki#n!kid!ki~P*zOp!li!^!li!j!li!m!li#n!lid!li~P*zOp#fa!^#fa~P$SOo$lO~Od$RP~P%_Od#zP~P&lO`!PXd}X!R}X!T!PX~O`$sO!T$tO~Od$uO!R#iO~Ok#jXp#jX!^#jX~P'tO!^#jOk$Tap$Ta~O!R#iOk!Uap!Ua!^!Uad!Ua`!Ua~OS!]Oe!YO!V![O!Y!`O#q$yO~Od$QP~P9dOv#{OQ#|X]#|X`#|Xd#|Xe#|Xi#|Xj#|Xk#|Xm#|Xp#|Xr#|Xt#|Xz#|X!`#|X#o#|X#p#|X#}#|Xl#|Xo#|X~O]#rO`#rOd%OOi#rOj#rOk#rO~P&lO]#rO`#rOi#rOj#rOk#rOl%PO~P&lO]#rO`#rOi#rOj#rOk#rOo%QO~P&lOe%SOS!tXk!tX!V!tX!Y!tX#q!tX~Ok%TO~Od%YOt%ZO!a%ZO~Ok%[O~Oo%cO#o%^O#}%]O~Od%dO~P$SOv#{O!^%hO!q%jOk!oi#m!oio!oi~P&lOk#ha#m#hao#ha~P!dOk!{O#m$Sio$Si~O!^%mOd$RX~P$SOd%oO~Ov#{OQ#`Xd#`Xe#`Xm#`Xp#`Xr#`Xt#`Xz#`X!^#`X!`#`X#o#`X#p#`X#}#`X~O!^%qOd#zX~P&lOd%sO~Ol%tOv#{O~OR#gOr#gOt#gO#q%vO#}!fO~O!R#iOk#jap#ja!^#ja~O`!PXd}X!R}X!^}X~O!R#iO!^%xOd$QX~O`%zO~Od%{O~O#o%|O~Ok&OO~O`&PO!R#iO~Od&ROk&QO~Od&UO~OP#zOpsX!^sXdsX~O#}%]Op#TX!^#TX~OpzO!^&WO~Oo&[O#o%^O#}%]O~Ov#{OQ#gXe#gXk#gXm#gXp#gXr#gXt#gXz#gX!^#gX!`#gX!q#gX#m#gX#o#gX#p#gX#}#gXo#gX~O!^%hO!q&`Ok!oq#m!oqo!oq~P&lOl&aOv#{O~Od#eX!^#eX~P%_O!^%mOd$Ra~Od#dX!^#dX~P&lO!^%qOd#za~Od&fO~P&lOd&gO!T&hO~Od#cX!^#cX~P9dO!^%xOd$Qa~O]&mOd&oO~OS#bae#ba!V#ba!Y#ba#q#ba~Od&qO~PG]Od&qOk&rO~Ov#{OQ#gae#gak#gam#gap#gar#gat#gaz#ga!^#ga!`#ga!q#ga#m#ga#o#ga#p#ga#}#gao#ga~Od#ea!^#ea~P$SOd#da!^#da~P&lOR#gOr#gOt#gO#q%vO#}%]O~O!R#iOd#ca!^#ca~O`&xO~O!^%xOd$Qi~P&lO]&mOd&|O~Ov#{Od|ik|i~Od&}O~PG]Ok'OO~Od'PO~O!^%xOd$Qq~Od#cq!^#cq~P&lO#s!a#t#}]#}v!m~",
    goto: "2h$UPPPPP$VP$YP$c$uP$cP%X$cPP%_PPP%e%o%oPPPPP%oPP%oP&]P%oP%o'W%oP't'w'}'}(^'}P'}P'}P'}'}P(m'}(yP(|PP)p)v$c)|$c*SP$cP$c$cP*Y*{+YP$YP+aP+dP$YP$YP$YP+j$YP+m+p+s+z$YP$YPP$YP,P,V,f,|-[-b-l-r-x.O.U.`.f.l.rPPPPPPPPPPP.x/R/w/z0|P1U1u2O2R2U2[RnQ_^OP`kz!{$dq[OPYZ`kuvwxz!v!{#`$d%mqSOPYZ`kuvwxz!v!{#`$d%mQpTR#RqQ!OVR#SrQ#S!QS$Q!i!jR$i#U!V!mac!c!d!e!z#a#c#t#v#x#{$a$k$p$s%h%i%q%u%z&P&d&l&x'Q!U!mac!c!d!e!z#a#c#t#v#x#{$a$k$p$s%h%i%q%u%z&P&d&l&x'QU#g!Y$t&hU%`$Y%b&WR&V%_!V!iac!c!d!e!z#a#c#t#v#x#{$a$k$p$s%h%i%q%u%z&P&d&l&x'QR$S!kQ%W$RR&S%Xk!^]bf!Y![!g#i#j#m$P$R%X%xQ#e!YQ${#mQ%w$tQ&j%xR&w&hQ!ygQ#p!`Q$^!xR%f$`R#n!]!U!mac!c!d!e!z#a#c#t#v#x#{$a$k$p$s%h%i%q%u%z&P&d&l&x'QQ!qdR$X!rQ!PVR#TrQ#S!PR$i#TQ!SWR#VsQ!UXR#WtQ{UQ!wgQ#^yQ#o!_Q$U!nQ$[!uQ$_!yQ%e$^Q&Y%aQ&]%fR&v&XSjPzQ!}kQ$c!{R%k$dZiPkz!{$dR$P!gQ%}%SR&z&mR!rdR!teR$Z!tS%a$Y%bR&t&WV%_$Y%b&WQ#PmR$g#PQ`OSkPzU!a`k$dR$d!{Q$p#aY%p$p%u&d&l'QQ%u$sQ&d%qQ&l%zR'Q&xQ#t!cQ#v!dQ#x!eV$}#t#v#xQ%X$RR&T%XQ%y$zS&k%y&yR&y&lQ%r$pR&e%rQ%n$mR&c%nQyUR#]yQ%i$aR&_%iQ!|jS$e!|$fR$f!}Q&n%}R&{&nQ#k!ZR$x#kQ%b$YR&Z%bQ&X%aR&u&X__OP`kz!{$d^UOP`kz!{$dQ!VYQ!WZQ#XuQ#YvQ#ZwQ#[xQ$]!vQ$m#`R&b%mR$q#aQ!gaQ!oc[#q!c!d!e#t#v#xQ$a!zd$o#a$p$s%q%u%z&d&l&x'QQ$r#cQ%R#{S%g$a%iQ%l$kQ&^%hR&p&P]#s!c!d!e#t#v#xW!Z]b!g$PQ!ufQ#f!YQ#l![Q$v#iQ$w#jQ$z#mS%V$R%XR&i%xQ#h!YQ%w$tR&w&hR$|#mR$n#`QlPR#_zQ!_]Q!nbQ$O!gR%U$P",
    nodeNames: "\u26A0 Unit VariableName VariableName QueryCallee Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NestingSelector ClassSelector . ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue AtKeyword # ; ] [ BracketedValue } { BracedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee IfExpression if ArgList IfBranch KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp ComparisonQuery CompareOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector ParenthesizedSelector CallQuery ArgList , CallLiteral CallTag ParenthesizedContent PseudoClassName ArgList IdSelector IdName AttributeSelector AttributeName MatchOp ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp Block Declaration PropertyName Important ImportStatement import Layer layer LayerName layer MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports ScopeStatement scope to AtRule Styles",
    maxTerm: 143,
    nodeProps: [
      [
        "isolate",
        -2,
        5,
        36,
        ""
      ],
      [
        "openedBy",
        20,
        "(",
        28,
        "[",
        31,
        "{"
      ],
      [
        "closedBy",
        21,
        ")",
        29,
        "]",
        32,
        "}"
      ]
    ],
    propSources: [
      EJe
    ],
    skippedNodes: [
      0,
      5,
      106
    ],
    repeatNodeCount: 15,
    tokenData: "JQ~R!YOX$qX^%i^p$qpq%iqr({rs-ust/itu6Wuv$qvw7Qwx7cxy9Qyz9cz{9h{|:R|}>t}!O?V!O!P?t!P!Q@]!Q![AU![!]BP!]!^B{!^!_C^!_!`DY!`!aDm!a!b$q!b!cEn!c!}$q!}#OG{#O#P$q#P#QH^#Q#R6W#R#o$q#o#pHo#p#q6W#q#rIQ#r#sIc#s#y$q#y#z%i#z$f$q$f$g%i$g#BY$q#BY#BZ%i#BZ$IS$q$IS$I_%i$I_$I|$q$I|$JO%i$JO$JT$q$JT$JU%i$JU$KV$q$KV$KW%i$KW&FU$q&FU&FV%i&FV;'S$q;'S;=`Iz<%lO$q`$tSOy%Qz;'S%Q;'S;=`%c<%lO%Q`%VS!a`Oy%Qz;'S%Q;'S;=`%c<%lO%Q`%fP;=`<%l%Q~%nh#s~OX%QX^'Y^p%Qpq'Yqy%Qz#y%Q#y#z'Y#z$f%Q$f$g'Y$g#BY%Q#BY#BZ'Y#BZ$IS%Q$IS$I_'Y$I_$I|%Q$I|$JO'Y$JO$JT%Q$JT$JU'Y$JU$KV%Q$KV$KW'Y$KW&FU%Q&FU&FV'Y&FV;'S%Q;'S;=`%c<%lO%Q~'ah#s~!a`OX%QX^'Y^p%Qpq'Yqy%Qz#y%Q#y#z'Y#z$f%Q$f$g'Y$g#BY%Q#BY#BZ'Y#BZ$IS%Q$IS$I_'Y$I_$I|%Q$I|$JO'Y$JO$JT%Q$JT$JU'Y$JU$KV%Q$KV$KW'Y$KW&FU%Q&FU&FV'Y&FV;'S%Q;'S;=`%c<%lO%Qj)OUOy%Qz#]%Q#]#^)b#^;'S%Q;'S;=`%c<%lO%Qj)gU!a`Oy%Qz#a%Q#a#b)y#b;'S%Q;'S;=`%c<%lO%Qj*OU!a`Oy%Qz#d%Q#d#e*b#e;'S%Q;'S;=`%c<%lO%Qj*gU!a`Oy%Qz#c%Q#c#d*y#d;'S%Q;'S;=`%c<%lO%Qj+OU!a`Oy%Qz#f%Q#f#g+b#g;'S%Q;'S;=`%c<%lO%Qj+gU!a`Oy%Qz#h%Q#h#i+y#i;'S%Q;'S;=`%c<%lO%Qj,OU!a`Oy%Qz#T%Q#T#U,b#U;'S%Q;'S;=`%c<%lO%Qj,gU!a`Oy%Qz#b%Q#b#c,y#c;'S%Q;'S;=`%c<%lO%Qj-OU!a`Oy%Qz#h%Q#h#i-b#i;'S%Q;'S;=`%c<%lO%Qj-iS!qY!a`Oy%Qz;'S%Q;'S;=`%c<%lO%Q~-xWOY-uZr-urs.bs#O-u#O#P.g#P;'S-u;'S;=`/c<%lO-u~.gOt~~.jRO;'S-u;'S;=`.s;=`O-u~.vXOY-uZr-urs.bs#O-u#O#P.g#P;'S-u;'S;=`/c;=`<%l-u<%lO-u~/fP;=`<%l-uj/nYjYOy%Qz!Q%Q!Q![0^![!c%Q!c!i0^!i#T%Q#T#Z0^#Z;'S%Q;'S;=`%c<%lO%Qj0cY!a`Oy%Qz!Q%Q!Q![1R![!c%Q!c!i1R!i#T%Q#T#Z1R#Z;'S%Q;'S;=`%c<%lO%Qj1WY!a`Oy%Qz!Q%Q!Q![1v![!c%Q!c!i1v!i#T%Q#T#Z1v#Z;'S%Q;'S;=`%c<%lO%Qj1}YrY!a`Oy%Qz!Q%Q!Q![2m![!c%Q!c!i2m!i#T%Q#T#Z2m#Z;'S%Q;'S;=`%c<%lO%Qj2tYrY!a`Oy%Qz!Q%Q!Q![3d![!c%Q!c!i3d!i#T%Q#T#Z3d#Z;'S%Q;'S;=`%c<%lO%Qj3iY!a`Oy%Qz!Q%Q!Q![4X![!c%Q!c!i4X!i#T%Q#T#Z4X#Z;'S%Q;'S;=`%c<%lO%Qj4`YrY!a`Oy%Qz!Q%Q!Q![5O![!c%Q!c!i5O!i#T%Q#T#Z5O#Z;'S%Q;'S;=`%c<%lO%Qj5TY!a`Oy%Qz!Q%Q!Q![5s![!c%Q!c!i5s!i#T%Q#T#Z5s#Z;'S%Q;'S;=`%c<%lO%Qj5zSrY!a`Oy%Qz;'S%Q;'S;=`%c<%lO%Qd6ZUOy%Qz!_%Q!_!`6m!`;'S%Q;'S;=`%c<%lO%Qd6tS!hS!a`Oy%Qz;'S%Q;'S;=`%c<%lO%Qb7VSZQOy%Qz;'S%Q;'S;=`%c<%lO%Q~7fWOY7cZw7cwx.bx#O7c#O#P8O#P;'S7c;'S;=`8z<%lO7c~8RRO;'S7c;'S;=`8[;=`O7c~8_XOY7cZw7cwx.bx#O7c#O#P8O#P;'S7c;'S;=`8z;=`<%l7c<%lO7c~8}P;=`<%l7cj9VSeYOy%Qz;'S%Q;'S;=`%c<%lO%Q~9hOd~n9oUWQvWOy%Qz!_%Q!_!`6m!`;'S%Q;'S;=`%c<%lO%Qj:YWvW!mQOy%Qz!O%Q!O!P:r!P!Q%Q!Q![=w![;'S%Q;'S;=`%c<%lO%Qj:wU!a`Oy%Qz!Q%Q!Q![;Z![;'S%Q;'S;=`%c<%lO%Qj;bY!a`#}YOy%Qz!Q%Q!Q![;Z![!g%Q!g!h<Q!h#X%Q#X#Y<Q#Y;'S%Q;'S;=`%c<%lO%Qj<VY!a`Oy%Qz{%Q{|<u|}%Q}!O<u!O!Q%Q!Q![=^![;'S%Q;'S;=`%c<%lO%Qj<zU!a`Oy%Qz!Q%Q!Q![=^![;'S%Q;'S;=`%c<%lO%Qj=eU!a`#}YOy%Qz!Q%Q!Q![=^![;'S%Q;'S;=`%c<%lO%Qj>O[!a`#}YOy%Qz!O%Q!O!P;Z!P!Q%Q!Q![=w![!g%Q!g!h<Q!h#X%Q#X#Y<Q#Y;'S%Q;'S;=`%c<%lO%Qj>yS!^YOy%Qz;'S%Q;'S;=`%c<%lO%Qj?[WvWOy%Qz!O%Q!O!P:r!P!Q%Q!Q![=w![;'S%Q;'S;=`%c<%lO%Qj?yU]YOy%Qz!Q%Q!Q![;Z![;'S%Q;'S;=`%c<%lO%Q~@bTvWOy%Qz{@q{;'S%Q;'S;=`%c<%lO%Q~@xS!a`#t~Oy%Qz;'S%Q;'S;=`%c<%lO%QjAZ[#}YOy%Qz!O%Q!O!P;Z!P!Q%Q!Q![=w![!g%Q!g!h<Q!h#X%Q#X#Y<Q#Y;'S%Q;'S;=`%c<%lO%QjBUU`YOy%Qz![%Q![!]Bh!];'S%Q;'S;=`%c<%lO%QbBoSaQ!a`Oy%Qz;'S%Q;'S;=`%c<%lO%QjCQSkYOy%Qz;'S%Q;'S;=`%c<%lO%QhCcU!TWOy%Qz!_%Q!_!`Cu!`;'S%Q;'S;=`%c<%lO%QhC|S!TW!a`Oy%Qz;'S%Q;'S;=`%c<%lO%QlDaS!TW!hSOy%Qz;'S%Q;'S;=`%c<%lO%QjDtV!jQ!TWOy%Qz!_%Q!_!`Cu!`!aEZ!a;'S%Q;'S;=`%c<%lO%QbEbS!jQ!a`Oy%Qz;'S%Q;'S;=`%c<%lO%QjEqYOy%Qz}%Q}!OFa!O!c%Q!c!}GO!}#T%Q#T#oGO#o;'S%Q;'S;=`%c<%lO%QjFfW!a`Oy%Qz!c%Q!c!}GO!}#T%Q#T#oGO#o;'S%Q;'S;=`%c<%lO%QjGV[iY!a`Oy%Qz}%Q}!OGO!O!Q%Q!Q![GO![!c%Q!c!}GO!}#T%Q#T#oGO#o;'S%Q;'S;=`%c<%lO%QjHQSmYOy%Qz;'S%Q;'S;=`%c<%lO%QnHcSl^Oy%Qz;'S%Q;'S;=`%c<%lO%QjHtSpYOy%Qz;'S%Q;'S;=`%c<%lO%QjIVSoYOy%Qz;'S%Q;'S;=`%c<%lO%QfIhU!mQOy%Qz!_%Q!_!`6m!`;'S%Q;'S;=`%c<%lO%Q`I}P;=`<%l$q",
    tokenizers: [
      _Je,
      TJe,
      PJe,
      CJe,
      1,
      2,
      3,
      4,
      new SP("m~RRYZ[z{a~~g~aO#v~~dP!P!Qg~lO#w~~", 28, 129)
    ],
    topRules: {
      StyleSheet: [
        0,
        6
      ],
      Styles: [
        1,
        105
      ]
    },
    specialized: [
      {
        term: 124,
        get: (t) => IJe[t] || -1
      },
      {
        term: 125,
        get: (t) => $Je[t] || -1
      },
      {
        term: 4,
        get: (t) => AJe[t] || -1
      },
      {
        term: 25,
        get: (t) => RJe[t] || -1
      },
      {
        term: 123,
        get: (t) => MJe[t] || -1
      }
    ],
    tokenPrec: 1963
  });
  let g$ = null;
  function m$() {
    if (!g$ && typeof document == "object" && document.body) {
      let { style: t } = document.body, e = [], n = /* @__PURE__ */ new Set();
      for (let r in t)
        r != "cssText" && r != "cssFloat" && typeof t[r] == "string" && (/[A-Z]/.test(r) && (r = r.replace(/[A-Z]/g, (i) => "-" + i.toLowerCase())), n.has(r) || (e.push(r), n.add(r)));
      g$ = e.sort().map((r) => ({
        type: "property",
        label: r,
        apply: r + ": "
      }));
    }
    return g$ || [];
  }
  const kV = [
    "active",
    "after",
    "any-link",
    "autofill",
    "backdrop",
    "before",
    "checked",
    "cue",
    "default",
    "defined",
    "disabled",
    "empty",
    "enabled",
    "file-selector-button",
    "first",
    "first-child",
    "first-letter",
    "first-line",
    "first-of-type",
    "focus",
    "focus-visible",
    "focus-within",
    "fullscreen",
    "has",
    "host",
    "host-context",
    "hover",
    "in-range",
    "indeterminate",
    "invalid",
    "is",
    "lang",
    "last-child",
    "last-of-type",
    "left",
    "link",
    "marker",
    "modal",
    "not",
    "nth-child",
    "nth-last-child",
    "nth-last-of-type",
    "nth-of-type",
    "only-child",
    "only-of-type",
    "optional",
    "out-of-range",
    "part",
    "placeholder",
    "placeholder-shown",
    "read-only",
    "read-write",
    "required",
    "right",
    "root",
    "scope",
    "selection",
    "slotted",
    "target",
    "target-text",
    "valid",
    "visited",
    "where"
  ].map((t) => ({
    type: "class",
    label: t
  })), PV = [
    "above",
    "absolute",
    "activeborder",
    "additive",
    "activecaption",
    "after-white-space",
    "ahead",
    "alias",
    "all",
    "all-scroll",
    "alphabetic",
    "alternate",
    "always",
    "antialiased",
    "appworkspace",
    "asterisks",
    "attr",
    "auto",
    "auto-flow",
    "avoid",
    "avoid-column",
    "avoid-page",
    "avoid-region",
    "axis-pan",
    "background",
    "backwards",
    "baseline",
    "below",
    "bidi-override",
    "blink",
    "block",
    "block-axis",
    "bold",
    "bolder",
    "border",
    "border-box",
    "both",
    "bottom",
    "break",
    "break-all",
    "break-word",
    "bullets",
    "button",
    "button-bevel",
    "buttonface",
    "buttonhighlight",
    "buttonshadow",
    "buttontext",
    "calc",
    "capitalize",
    "caps-lock-indicator",
    "caption",
    "captiontext",
    "caret",
    "cell",
    "center",
    "checkbox",
    "circle",
    "cjk-decimal",
    "clear",
    "clip",
    "close-quote",
    "col-resize",
    "collapse",
    "color",
    "color-burn",
    "color-dodge",
    "column",
    "column-reverse",
    "compact",
    "condensed",
    "contain",
    "content",
    "contents",
    "content-box",
    "context-menu",
    "continuous",
    "copy",
    "counter",
    "counters",
    "cover",
    "crop",
    "cross",
    "crosshair",
    "currentcolor",
    "cursive",
    "cyclic",
    "darken",
    "dashed",
    "decimal",
    "decimal-leading-zero",
    "default",
    "default-button",
    "dense",
    "destination-atop",
    "destination-in",
    "destination-out",
    "destination-over",
    "difference",
    "disc",
    "discard",
    "disclosure-closed",
    "disclosure-open",
    "document",
    "dot-dash",
    "dot-dot-dash",
    "dotted",
    "double",
    "down",
    "e-resize",
    "ease",
    "ease-in",
    "ease-in-out",
    "ease-out",
    "element",
    "ellipse",
    "ellipsis",
    "embed",
    "end",
    "ethiopic-abegede-gez",
    "ethiopic-halehame-aa-er",
    "ethiopic-halehame-gez",
    "ew-resize",
    "exclusion",
    "expanded",
    "extends",
    "extra-condensed",
    "extra-expanded",
    "fantasy",
    "fast",
    "fill",
    "fill-box",
    "fixed",
    "flat",
    "flex",
    "flex-end",
    "flex-start",
    "footnotes",
    "forwards",
    "from",
    "geometricPrecision",
    "graytext",
    "grid",
    "groove",
    "hand",
    "hard-light",
    "help",
    "hidden",
    "hide",
    "higher",
    "highlight",
    "highlighttext",
    "horizontal",
    "hsl",
    "hsla",
    "hue",
    "icon",
    "ignore",
    "inactiveborder",
    "inactivecaption",
    "inactivecaptiontext",
    "infinite",
    "infobackground",
    "infotext",
    "inherit",
    "initial",
    "inline",
    "inline-axis",
    "inline-block",
    "inline-flex",
    "inline-grid",
    "inline-table",
    "inset",
    "inside",
    "intrinsic",
    "invert",
    "italic",
    "justify",
    "keep-all",
    "landscape",
    "large",
    "larger",
    "left",
    "level",
    "lighter",
    "lighten",
    "line-through",
    "linear",
    "linear-gradient",
    "lines",
    "list-item",
    "listbox",
    "listitem",
    "local",
    "logical",
    "loud",
    "lower",
    "lower-hexadecimal",
    "lower-latin",
    "lower-norwegian",
    "lowercase",
    "ltr",
    "luminosity",
    "manipulation",
    "match",
    "matrix",
    "matrix3d",
    "medium",
    "menu",
    "menutext",
    "message-box",
    "middle",
    "min-intrinsic",
    "mix",
    "monospace",
    "move",
    "multiple",
    "multiple_mask_images",
    "multiply",
    "n-resize",
    "narrower",
    "ne-resize",
    "nesw-resize",
    "no-close-quote",
    "no-drop",
    "no-open-quote",
    "no-repeat",
    "none",
    "normal",
    "not-allowed",
    "nowrap",
    "ns-resize",
    "numbers",
    "numeric",
    "nw-resize",
    "nwse-resize",
    "oblique",
    "opacity",
    "open-quote",
    "optimizeLegibility",
    "optimizeSpeed",
    "outset",
    "outside",
    "outside-shape",
    "overlay",
    "overline",
    "padding",
    "padding-box",
    "painted",
    "page",
    "paused",
    "perspective",
    "pinch-zoom",
    "plus-darker",
    "plus-lighter",
    "pointer",
    "polygon",
    "portrait",
    "pre",
    "pre-line",
    "pre-wrap",
    "preserve-3d",
    "progress",
    "push-button",
    "radial-gradient",
    "radio",
    "read-only",
    "read-write",
    "read-write-plaintext-only",
    "rectangle",
    "region",
    "relative",
    "repeat",
    "repeating-linear-gradient",
    "repeating-radial-gradient",
    "repeat-x",
    "repeat-y",
    "reset",
    "reverse",
    "rgb",
    "rgba",
    "ridge",
    "right",
    "rotate",
    "rotate3d",
    "rotateX",
    "rotateY",
    "rotateZ",
    "round",
    "row",
    "row-resize",
    "row-reverse",
    "rtl",
    "run-in",
    "running",
    "s-resize",
    "sans-serif",
    "saturation",
    "scale",
    "scale3d",
    "scaleX",
    "scaleY",
    "scaleZ",
    "screen",
    "scroll",
    "scrollbar",
    "scroll-position",
    "se-resize",
    "self-start",
    "self-end",
    "semi-condensed",
    "semi-expanded",
    "separate",
    "serif",
    "show",
    "single",
    "skew",
    "skewX",
    "skewY",
    "skip-white-space",
    "slide",
    "slider-horizontal",
    "slider-vertical",
    "sliderthumb-horizontal",
    "sliderthumb-vertical",
    "slow",
    "small",
    "small-caps",
    "small-caption",
    "smaller",
    "soft-light",
    "solid",
    "source-atop",
    "source-in",
    "source-out",
    "source-over",
    "space",
    "space-around",
    "space-between",
    "space-evenly",
    "spell-out",
    "square",
    "start",
    "static",
    "status-bar",
    "stretch",
    "stroke",
    "stroke-box",
    "sub",
    "subpixel-antialiased",
    "svg_masks",
    "super",
    "sw-resize",
    "symbolic",
    "symbols",
    "system-ui",
    "table",
    "table-caption",
    "table-cell",
    "table-column",
    "table-column-group",
    "table-footer-group",
    "table-header-group",
    "table-row",
    "table-row-group",
    "text",
    "text-bottom",
    "text-top",
    "textarea",
    "textfield",
    "thick",
    "thin",
    "threeddarkshadow",
    "threedface",
    "threedhighlight",
    "threedlightshadow",
    "threedshadow",
    "to",
    "top",
    "transform",
    "translate",
    "translate3d",
    "translateX",
    "translateY",
    "translateZ",
    "transparent",
    "ultra-condensed",
    "ultra-expanded",
    "underline",
    "unidirectional-pan",
    "unset",
    "up",
    "upper-latin",
    "uppercase",
    "url",
    "var",
    "vertical",
    "vertical-text",
    "view-box",
    "visible",
    "visibleFill",
    "visiblePainted",
    "visibleStroke",
    "visual",
    "w-resize",
    "wait",
    "wave",
    "wider",
    "window",
    "windowframe",
    "windowtext",
    "words",
    "wrap",
    "wrap-reverse",
    "x-large",
    "x-small",
    "xor",
    "xx-large",
    "xx-small"
  ].map((t) => ({
    type: "keyword",
    label: t
  })).concat([
    "aliceblue",
    "antiquewhite",
    "aqua",
    "aquamarine",
    "azure",
    "beige",
    "bisque",
    "black",
    "blanchedalmond",
    "blue",
    "blueviolet",
    "brown",
    "burlywood",
    "cadetblue",
    "chartreuse",
    "chocolate",
    "coral",
    "cornflowerblue",
    "cornsilk",
    "crimson",
    "cyan",
    "darkblue",
    "darkcyan",
    "darkgoldenrod",
    "darkgray",
    "darkgreen",
    "darkkhaki",
    "darkmagenta",
    "darkolivegreen",
    "darkorange",
    "darkorchid",
    "darkred",
    "darksalmon",
    "darkseagreen",
    "darkslateblue",
    "darkslategray",
    "darkturquoise",
    "darkviolet",
    "deeppink",
    "deepskyblue",
    "dimgray",
    "dodgerblue",
    "firebrick",
    "floralwhite",
    "forestgreen",
    "fuchsia",
    "gainsboro",
    "ghostwhite",
    "gold",
    "goldenrod",
    "gray",
    "grey",
    "green",
    "greenyellow",
    "honeydew",
    "hotpink",
    "indianred",
    "indigo",
    "ivory",
    "khaki",
    "lavender",
    "lavenderblush",
    "lawngreen",
    "lemonchiffon",
    "lightblue",
    "lightcoral",
    "lightcyan",
    "lightgoldenrodyellow",
    "lightgray",
    "lightgreen",
    "lightpink",
    "lightsalmon",
    "lightseagreen",
    "lightskyblue",
    "lightslategray",
    "lightsteelblue",
    "lightyellow",
    "lime",
    "limegreen",
    "linen",
    "magenta",
    "maroon",
    "mediumaquamarine",
    "mediumblue",
    "mediumorchid",
    "mediumpurple",
    "mediumseagreen",
    "mediumslateblue",
    "mediumspringgreen",
    "mediumturquoise",
    "mediumvioletred",
    "midnightblue",
    "mintcream",
    "mistyrose",
    "moccasin",
    "navajowhite",
    "navy",
    "oldlace",
    "olive",
    "olivedrab",
    "orange",
    "orangered",
    "orchid",
    "palegoldenrod",
    "palegreen",
    "paleturquoise",
    "palevioletred",
    "papayawhip",
    "peachpuff",
    "peru",
    "pink",
    "plum",
    "powderblue",
    "purple",
    "rebeccapurple",
    "red",
    "rosybrown",
    "royalblue",
    "saddlebrown",
    "salmon",
    "sandybrown",
    "seagreen",
    "seashell",
    "sienna",
    "silver",
    "skyblue",
    "slateblue",
    "slategray",
    "snow",
    "springgreen",
    "steelblue",
    "tan",
    "teal",
    "thistle",
    "tomato",
    "turquoise",
    "violet",
    "wheat",
    "white",
    "whitesmoke",
    "yellow",
    "yellowgreen"
  ].map((t) => ({
    type: "constant",
    label: t
  }))), LJe = [
    "a",
    "abbr",
    "address",
    "article",
    "aside",
    "b",
    "bdi",
    "bdo",
    "blockquote",
    "body",
    "br",
    "button",
    "canvas",
    "caption",
    "cite",
    "code",
    "col",
    "colgroup",
    "dd",
    "del",
    "details",
    "dfn",
    "dialog",
    "div",
    "dl",
    "dt",
    "em",
    "figcaption",
    "figure",
    "footer",
    "form",
    "header",
    "hgroup",
    "h1",
    "h2",
    "h3",
    "h4",
    "h5",
    "h6",
    "hr",
    "html",
    "i",
    "iframe",
    "img",
    "input",
    "ins",
    "kbd",
    "label",
    "legend",
    "li",
    "main",
    "meter",
    "nav",
    "ol",
    "output",
    "p",
    "pre",
    "ruby",
    "section",
    "select",
    "small",
    "source",
    "span",
    "strong",
    "sub",
    "summary",
    "sup",
    "table",
    "tbody",
    "td",
    "template",
    "textarea",
    "tfoot",
    "th",
    "thead",
    "tr",
    "u",
    "ul"
  ].map((t) => ({
    type: "type",
    label: t
  })), jJe = [
    "@charset",
    "@color-profile",
    "@container",
    "@counter-style",
    "@font-face",
    "@font-feature-values",
    "@font-palette-values",
    "@import",
    "@keyframes",
    "@layer",
    "@media",
    "@namespace",
    "@page",
    "@position-try",
    "@property",
    "@scope",
    "@starting-style",
    "@supports",
    "@view-transition"
  ].map((t) => ({
    type: "keyword",
    label: t
  })), fc = /^(\w[\w-]*|-\w[\w-]*|)$/, NJe = /^-(-[\w-]*)?$/;
  function QJe(t, e) {
    var n;
    if ((t.name == "(" || t.type.isError) && (t = t.parent || t), t.name != "ArgList")
      return false;
    let r = (n = t.parent) === null || n === void 0 ? void 0 : n.firstChild;
    return (r == null ? void 0 : r.name) != "Callee" ? false : e.sliceString(r.from, r.to) == "var";
  }
  const CV = new Loe(), zJe = [
    "Declaration"
  ];
  function FJe(t) {
    for (let e = t; ; ) {
      if (e.type.isTop)
        return e;
      if (!(e = e.parent))
        return t;
    }
  }
  function Wae(t, e, n) {
    if (e.to - e.from > 4096) {
      let r = CV.get(e);
      if (r)
        return r;
      let i = [], s = /* @__PURE__ */ new Set(), o = e.cursor(dn.IncludeAnonymous);
      if (o.firstChild())
        do
          for (let a of Wae(t, o.node, n))
            s.has(a.label) || (s.add(a.label), i.push(a));
        while (o.nextSibling());
      return CV.set(e, i), i;
    } else {
      let r = [], i = /* @__PURE__ */ new Set();
      return e.cursor().iterate((s) => {
        var o;
        if (n(s) && s.matchContext(zJe) && ((o = s.node.nextSibling) === null || o === void 0 ? void 0 : o.name) == ":") {
          let a = t.sliceString(s.from, s.to);
          i.has(a) || (i.add(a), r.push({
            label: a,
            type: "variable"
          }));
        }
      }), r;
    }
  }
  let Hae, CO;
  Zae = (t) => (e) => {
    let { state: n, pos: r } = e, i = Un(n).resolveInner(r, -1), s = i.type.isError && i.from == i.to - 1 && n.doc.sliceString(i.from, i.to) == "-";
    if (i.name == "PropertyName" || (s || i.name == "TagName") && /^(Block|Styles)$/.test(i.resolve(i.to).name))
      return {
        from: i.from,
        options: m$(),
        validFor: fc
      };
    if (i.name == "ValueName")
      return {
        from: i.from,
        options: PV,
        validFor: fc
      };
    if (i.name == "PseudoClassName")
      return {
        from: i.from,
        options: kV,
        validFor: fc
      };
    if (t(i) || (e.explicit || s) && QJe(i, n.doc))
      return {
        from: t(i) || s ? i.from : r,
        options: Wae(n.doc, FJe(i), t),
        validFor: NJe
      };
    if (i.name == "TagName") {
      for (let { parent: l } = i; l; l = l.parent)
        if (l.name == "Block")
          return {
            from: i.from,
            options: m$(),
            validFor: fc
          };
      return {
        from: i.from,
        options: LJe,
        validFor: fc
      };
    }
    if (i.name == "AtKeyword")
      return {
        from: i.from,
        options: jJe,
        validFor: fc
      };
    if (!e.explicit)
      return null;
    let o = i.resolve(r), a = o.childBefore(r);
    return a && a.name == ":" && o.name == "PseudoClassSelector" ? {
      from: r,
      options: kV,
      validFor: fc
    } : a && a.name == ":" && o.name == "Declaration" || o.name == "ArgList" ? {
      from: r,
      options: PV,
      validFor: fc
    } : o.name == "Block" || o.name == "Styles" ? {
      from: r,
      options: m$(),
      validFor: fc
    } : null;
  };
  Hae = Zae((t) => t.name == "VariableName");
  CO = om.define({
    name: "css",
    parser: DJe.configure({
      props: [
        Bm.add({
          Declaration: yb()
        }),
        Um.add({
          "Block KeyframeList": Xoe
        })
      ]
    }),
    languageData: {
      commentTokens: {
        block: {
          open: "/*",
          close: "*/"
        }
      },
      indentOnInput: /^\s*\}$/,
      wordChars: "-"
    }
  });
  function Yae() {
    return new cm(CO, CO.data.of({
      autocomplete: Hae
    }));
  }
  const BJe = Object.freeze(Object.defineProperty({
    __proto__: null,
    css: Yae,
    cssCompletionSource: Hae,
    cssLanguage: CO,
    defineCSSCompletionSource: Zae
  }, Symbol.toStringTag, {
    value: "Module"
  })), UJe = 316, VJe = 317, _V = 1, XJe = 2, WJe = 3, ZJe = 4, HJe = 318, YJe = 320, GJe = 321, qJe = 5, KJe = 6, JJe = 0, sD = [
    9,
    10,
    11,
    12,
    13,
    32,
    133,
    160,
    5760,
    8192,
    8193,
    8194,
    8195,
    8196,
    8197,
    8198,
    8199,
    8200,
    8201,
    8202,
    8232,
    8233,
    8239,
    8287,
    12288
  ], Gae = 125, eet = 59, oD = 47, tet = 42, net = 43, ret = 45, iet = 60, set = 44, oet = 63, aet = 46, cet = 91, uet = new $ae({
    start: false,
    shift(t, e) {
      return e == qJe || e == KJe || e == YJe ? t : e == GJe;
    },
    strict: false
  }), det = new po((t, e) => {
    let { next: n } = t;
    (n == Gae || n == -1 || e.context) && t.acceptToken(HJe);
  }, {
    contextual: true,
    fallback: true
  }), het = new po((t, e) => {
    let { next: n } = t, r;
    sD.indexOf(n) > -1 || n == oD && ((r = t.peek(1)) == oD || r == tet) || n != Gae && n != eet && n != -1 && !e.context && t.acceptToken(UJe);
  }, {
    contextual: true
  }), fet = new po((t, e) => {
    t.next == cet && !e.context && t.acceptToken(VJe);
  }, {
    contextual: true
  }), pet = new po((t, e) => {
    let { next: n } = t;
    if (n == net || n == ret) {
      if (t.advance(), n == t.next) {
        t.advance();
        let r = !e.context && e.canShift(_V);
        t.acceptToken(r ? _V : XJe);
      }
    } else
      n == oet && t.peek(1) == aet && (t.advance(), t.advance(), (t.next < 48 || t.next > 57) && t.acceptToken(WJe));
  }, {
    contextual: true
  });
  function y$(t, e) {
    return t >= 65 && t <= 90 || t >= 97 && t <= 122 || t == 95 || t >= 192 || !e && t >= 48 && t <= 57;
  }
  const get = new po((t, e) => {
    if (t.next != iet || !e.dialectEnabled(JJe) || (t.advance(), t.next == oD))
      return;
    let n = 0;
    for (; sD.indexOf(t.next) > -1; )
      t.advance(), n++;
    if (y$(t.next, true)) {
      for (t.advance(), n++; y$(t.next, false); )
        t.advance(), n++;
      for (; sD.indexOf(t.next) > -1; )
        t.advance(), n++;
      if (t.next == set)
        return;
      for (let r = 0; ; r++) {
        if (r == 7) {
          if (!y$(t.next, true))
            return;
          break;
        }
        if (t.next != "extends".charCodeAt(r))
          break;
        t.advance(), n++;
      }
    }
    t.acceptToken(ZJe, -n);
  }), met = zm({
    "get set async static": V.modifier,
    "for while do if else switch try catch finally return throw break continue default case defer": V.controlKeyword,
    "in of await yield void typeof delete instanceof as satisfies": V.operatorKeyword,
    "let var const using function class extends": V.definitionKeyword,
    "import export from": V.moduleKeyword,
    "with debugger new": V.keyword,
    TemplateString: V.special(V.string),
    super: V.atom,
    BooleanLiteral: V.bool,
    this: V.self,
    null: V.null,
    Star: V.modifier,
    VariableName: V.variableName,
    "CallExpression/VariableName TaggedTemplateExpression/VariableName": V.function(V.variableName),
    VariableDefinition: V.definition(V.variableName),
    Label: V.labelName,
    PropertyName: V.propertyName,
    PrivatePropertyName: V.special(V.propertyName),
    "CallExpression/MemberExpression/PropertyName": V.function(V.propertyName),
    "FunctionDeclaration/VariableDefinition": V.function(V.definition(V.variableName)),
    "ClassDeclaration/VariableDefinition": V.definition(V.className),
    "NewExpression/VariableName": V.className,
    PropertyDefinition: V.definition(V.propertyName),
    PrivatePropertyDefinition: V.definition(V.special(V.propertyName)),
    UpdateOp: V.updateOperator,
    "LineComment Hashbang": V.lineComment,
    BlockComment: V.blockComment,
    Number: V.number,
    String: V.string,
    Escape: V.escape,
    ArithOp: V.arithmeticOperator,
    LogicOp: V.logicOperator,
    BitOp: V.bitwiseOperator,
    CompareOp: V.compareOperator,
    RegExp: V.regexp,
    Equals: V.definitionOperator,
    Arrow: V.function(V.punctuation),
    ": Spread": V.punctuation,
    "( )": V.paren,
    "[ ]": V.squareBracket,
    "{ }": V.brace,
    "InterpolationStart InterpolationEnd": V.special(V.brace),
    ".": V.derefOperator,
    ", ;": V.separator,
    "@": V.meta,
    TypeName: V.typeName,
    TypeDefinition: V.definition(V.typeName),
    "type enum interface implements namespace module declare": V.definitionKeyword,
    "abstract global Privacy readonly override": V.modifier,
    "is keyof unique infer asserts": V.operatorKeyword,
    JSXAttributeValue: V.attributeValue,
    JSXText: V.content,
    "JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": V.angleBracket,
    "JSXIdentifier JSXNameSpacedName": V.tagName,
    "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": V.attributeName,
    "JSXBuiltin/JSXIdentifier": V.standard(V.tagName)
  }), yet = {
    __proto__: null,
    export: 20,
    as: 25,
    from: 33,
    default: 36,
    async: 41,
    function: 42,
    in: 52,
    out: 55,
    const: 56,
    extends: 60,
    this: 64,
    true: 72,
    false: 72,
    null: 84,
    void: 88,
    typeof: 92,
    super: 108,
    new: 142,
    delete: 154,
    yield: 163,
    await: 167,
    class: 172,
    public: 235,
    private: 235,
    protected: 235,
    readonly: 237,
    instanceof: 256,
    satisfies: 259,
    import: 292,
    keyof: 349,
    unique: 353,
    infer: 359,
    asserts: 395,
    is: 397,
    abstract: 417,
    implements: 419,
    type: 421,
    let: 424,
    var: 426,
    using: 429,
    interface: 435,
    enum: 439,
    namespace: 445,
    module: 447,
    declare: 451,
    global: 455,
    defer: 471,
    for: 476,
    of: 485,
    while: 488,
    with: 492,
    do: 496,
    if: 500,
    else: 502,
    switch: 506,
    case: 512,
    try: 518,
    catch: 522,
    finally: 526,
    return: 530,
    throw: 534,
    break: 538,
    continue: 542,
    debugger: 546
  }, vet = {
    __proto__: null,
    async: 129,
    get: 131,
    set: 133,
    declare: 195,
    public: 197,
    private: 197,
    protected: 197,
    static: 199,
    abstract: 201,
    override: 203,
    readonly: 209,
    accessor: 211,
    new: 401
  }, Oet = {
    __proto__: null,
    "<": 193
  }, wet = dm.deserialize({
    version: 14,
    states: "$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-E<j-E<jO9kQ`O,5=_O!$rQ`O,5=_O!$wQlO,5;ZO!&zQMhO'#EkO!(eQ`O,5;ZO!(jQlO'#DyO!(tQpO,5;dO!(|QpO,5;dO%[QlO,5;dOOQ['#FT'#FTOOQ['#FV'#FVO%[QlO,5;eO%[QlO,5;eO%[QlO,5;eO%[QlO,5;eO%[QlO,5;eO%[QlO,5;eO%[QlO,5;eO%[QlO,5;eO%[QlO,5;eO%[QlO,5;eOOQ['#FZ'#FZO!)[QlO,5;tOOQ!0Lf,5;y,5;yOOQ!0Lf,5;z,5;zOOQ!0Lf,5;|,5;|O%[QlO'#IpO!+_Q!0LrO,5<iO%[QlO,5;eO!&zQMhO,5;eO!+|QMhO,5;eO!-nQMhO'#E^O%[QlO,5;wOOQ!0Lf,5;{,5;{O!-uQ,UO'#FjO!.rQ,UO'#KXO!.^Q,UO'#KXO!.yQ,UO'#KXOOQO'#KX'#KXO!/_Q,UO,5<SOOOW,5<`,5<`O!/pQlO'#FvOOOW'#Io'#IoO7VO7dO,5<QO!/wQ,UO'#FxOOQ!0Lf,5<Q,5<QO!0hQ$IUO'#CyOOQ!0Lh'#C}'#C}O!0{O#@ItO'#DRO!1iQMjO,5<eO!1pQ`O,5<hO!3YQ(CWO'#GXO!3jQ`O'#GYO!3oQ`O'#GYO!5_Q(CWO'#G^O!6dQpO'#GbOOQO'#Gn'#GnO!,TQMhO'#GmOOQO'#Gp'#GpO!,TQMhO'#GoO!7VQ$IUO'#JlOOQ!0Lh'#Jl'#JlO!7aQ`O'#JkO!7oQ`O'#JjO!7wQ`O'#CuOOQ!0Lh'#C{'#C{O!8YQ`O'#C}OOQ!0Lh'#DV'#DVOOQ!0Lh'#DX'#DXO!8_Q`O,5<eO1SQ`O'#DZO!,TQMhO'#GPO!,TQMhO'#GRO!8gQ`O'#GTO!8lQ`O'#GUO!3oQ`O'#G[O!,TQMhO'#GaO<]Q`O'#JkO!8qQ`O'#EqO!9`Q`O,5<gOOQ!0Lb'#Cr'#CrO!9hQ`O'#ErO!:bQpO'#EsOOQ!0Lb'#KR'#KRO!:iQ!0LrO'#KaO9uQ!0LrO,5=cO`QlO,5>tOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!<hQ!0MxO,5:bO!:]QpO,5:`O!?RQ!0MxO,5:jO%[QlO,5:jO!AiQ!0MxO,5:lOOQO,5@z,5@zO!BYQMhO,5=_O!BhQ!0LrO'#JiO9`Q`O'#JiO!ByQ!0LrO,59ZO!CUQpO,59ZO!C^QMhO,59ZO:dQMhO,59ZO!CiQ`O,5;ZO!CqQ`O'#HbO!DVQ`O'#KdO%[QlO,5;}O!:]QpO,5<PO!D_Q`O,5=zO!DdQ`O,5=zO!DiQ`O,5=zO!DwQ`O,5=zO9uQ!0LrO,5=zO<]Q`O,5=jOOQO'#Cy'#CyO!EOQpO,5=gO!EWQMhO,5=hO!EcQ`O,5=jO!EhQ!bO,5=mO!EpQ`O'#K`O?YQ`O'#HWO9kQ`O'#HYO!EuQ`O'#HYO:dQMhO'#H[O!EzQ`O'#H[OOQ[,5=p,5=pO!FPQ`O'#H]O!FbQ`O'#CoO!FgQ`O,59PO!FqQ`O,59PO!HvQlO,59POOQ[,59P,59PO!IWQ!0LrO,59PO%[QlO,59PO!KcQlO'#HeOOQ['#Hf'#HfOOQ['#Hg'#HgO`QlO,5=}O!KyQ`O,5=}O`QlO,5>TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-E<f-E<fO#)kQ!0MSO,5;RODWQpO,5:rO#)uQpO,5:rODWQpO,5;RO!ByQ!0LrO,5:rOOQ!0Lb'#Ej'#EjOOQO,5;R,5;RO%[QlO,5;RO#*SQ!0LrO,5;RO#*_Q!0LrO,5;RO!CUQpO,5:rOOQO,5;X,5;XO#*mQ!0LrO,5;RPOOO'#I^'#I^P#+RO&2DjO,58|POOO,58|,58|OOOO-E<^-E<^OOQ!0Lh1G.p1G.pOOOO-E<_-E<_OOOO,59},59}O#+^Q!bO,59}OOOO-E<a-E<aOOQ!0Lf1G/g1G/gO#+cQ!fO,5?OO+}QlO,5?OOOQO,5?U,5?UO#+mQlO'#IdOOQO-E<b-E<bO#+zQ`O,5@`O#,SQ!fO,5@`O#,ZQ`O,5@nOOQ!0Lf1G/m1G/mO%[QlO,5@oO#,cQ`O'#IjOOQO-E<h-E<hO#,ZQ`O,5@nOOQ!0Lb1G0x1G0xOOQ!0Ln1G/x1G/xOOQ!0Ln1G0Y1G0YO%[QlO,5@lO#,wQ!0LrO,5@lO#-YQ!0LrO,5@lO#-aQ`O,5@kO9eQ`O,5@kO#-iQ`O,5@kO#-wQ`O'#ImO#-aQ`O,5@kOOQ!0Lb1G0w1G0wO!(tQpO,5:uO!)PQpO,5:uOOQS,5:w,5:wO#.iQdO,5:wO#.qQMhO1G2yO9kQ`O1G2yOOQ!0Lf1G0u1G0uO#/PQ!0MxO1G0uO#0UQ!0MvO,5;VOOQ!0Lh'#GW'#GWO#0rQ!0MzO'#JlO!$wQlO1G0uO#2}Q!fO'#JwO%[QlO'#JwO#3XQ`O,5:eOOQ!0Lh'#D_'#D_OOQ!0Lf1G1O1G1OO%[QlO1G1OOOQ!0Lf1G1f1G1fO#3^Q`O1G1OO#5rQ!0MxO1G1PO#5yQ!0MxO1G1PO#8aQ!0MxO1G1PO#8hQ!0MxO1G1PO#;OQ!0MxO1G1PO#=fQ!0MxO1G1PO#=mQ!0MxO1G1PO#=tQ!0MxO1G1PO#@[Q!0MxO1G1PO#@cQ!0MxO1G1PO#BpQ?MtO'#CiO#DkQ?MtO1G1`O#DrQ?MtO'#JsO#EVQ!0MxO,5?[OOQ!0Lb-E<n-E<nO#GdQ!0MxO1G1PO#HaQ!0MzO1G1POOQ!0Lf1G1P1G1PO#IdQMjO'#J|O#InQ`O,5:xO#IsQ!0MxO1G1cO#JgQ,UO,5<WO#JoQ,UO,5<XO#JwQ,UO'#FoO#K`Q`O'#FnOOQO'#KY'#KYOOQO'#In'#InO#KeQ,UO1G1nOOQ!0Lf1G1n1G1nOOOW1G1y1G1yO#KvQ?MtO'#JrO#LQQ`O,5<bO!)[QlO,5<bOOOW-E<m-E<mOOQ!0Lf1G1l1G1lO#LVQpO'#KXOOQ!0Lf,5<d,5<dO#L_QpO,5<dO#LdQMhO'#DTOOOO'#Ib'#IbO#LkO#@ItO,59mOOQ!0Lh,59m,59mO%[QlO1G2PO!8lQ`O'#IrO#LvQ`O,5<zOOQ!0Lh,5<w,5<wO!,TQMhO'#IuO#MdQMjO,5=XO!,TQMhO'#IwO#NVQMjO,5=ZO!&zQMhO,5=]OOQO1G2S1G2SO#NaQ!dO'#CrO#NtQ(CWO'#ErO$ |QpO'#GbO$!dQ!dO,5<sO$!kQ`O'#K[O9eQ`O'#K[O$!yQ`O,5<uO$#aQ!dO'#C{O!,TQMhO,5<tO$#kQ`O'#GZO$$PQ`O,5<tO$$UQ!dO'#GWO$$cQ!dO'#K]O$$mQ`O'#K]O!&zQMhO'#K]O$$rQ`O,5<xO$$wQlO'#JvO$%RQpO'#GcO#$`QpO'#GcO$%dQ`O'#GgO!3oQ`O'#GkO$%iQ!0LrO'#ItO$%tQpO,5<|OOQ!0Lp,5<|,5<|O$%{QpO'#GcO$&YQpO'#GdO$&kQpO'#GdO$&pQMjO,5=XO$'QQMjO,5=ZOOQ!0Lh,5=^,5=^O!,TQMhO,5@VO!,TQMhO,5@VO$'bQ`O'#IyO$'vQ`O,5@UO$(OQ`O,59aOOQ!0Lh,59i,59iO$(TQ`O,5@VO$)TQ$IYO,59uOOQ!0Lh'#Jp'#JpO$)vQMjO,5<kO$*iQMjO,5<mO@zQ`O,5<oOOQ!0Lh,5<p,5<pO$*sQ`O,5<vO$*xQMjO,5<{O$+YQ`O'#KPO!$wQlO1G2RO$+_Q`O1G2RO9eQ`O'#KSO9eQ`O'#EtO%[QlO'#EtO9eQ`O'#I{O$+dQ!0LrO,5@{OOQ[1G2}1G2}OOQ[1G4`1G4`OOQ!0Lf1G/|1G/|OOQ!0Lf1G/z1G/zO$-fQ!0MxO1G0UOOQ[1G2y1G2yO!&zQMhO1G2yO%[QlO1G2yO#.tQ`O1G2yO$/jQMhO'#EkOOQ!0Lb,5@T,5@TO$/wQ!0LrO,5@TOOQ[1G.u1G.uO!ByQ!0LrO1G.uO!CUQpO1G.uO!C^QMhO1G.uO$0YQ`O1G0uO$0_Q`O'#CiO$0jQ`O'#KeO$0rQ`O,5=|O$0wQ`O'#KeO$0|Q`O'#KeO$1[Q`O'#JRO$1jQ`O,5AOO$1rQ!fO1G1iOOQ!0Lf1G1k1G1kO9kQ`O1G3fO@zQ`O1G3fO$1yQ`O1G3fO$2OQ`O1G3fO!DiQ`O1G3fO9uQ!0LrO1G3fOOQ[1G3f1G3fO!EcQ`O1G3UO!&zQMhO1G3RO$2TQ`O1G3ROOQ[1G3S1G3SO!&zQMhO1G3SO$2YQ`O1G3SO$2bQpO'#HQOOQ[1G3U1G3UO!6_QpO'#I}O!EhQ!bO1G3XOOQ[1G3X1G3XOOQ[,5=r,5=rO$2jQMhO,5=tO9kQ`O,5=tO$%dQ`O,5=vO9`Q`O,5=vO!CUQpO,5=vO!C^QMhO,5=vO:dQMhO,5=vO$2xQ`O'#KcO$3TQ`O,5=wOOQ[1G.k1G.kO$3YQ!0LrO1G.kO@zQ`O1G.kO$3eQ`O1G.kO9uQ!0LrO1G.kO$5mQ!fO,5AQO$5zQ`O,5AQO9eQ`O,5AQO$6VQlO,5>PO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5<iO$BOQ!fO1G4jOOQO1G4p1G4pO%[QlO,5?OO$BYQ`O1G5zO$BbQ`O1G6YO$BjQ!fO1G6ZO9eQ`O,5?UO$BtQ!0MxO1G6WO%[QlO1G6WO$CUQ!0LrO1G6WO$CgQ`O1G6VO$CgQ`O1G6VO9eQ`O1G6VO$CoQ`O,5?XO9eQ`O,5?XOOQO,5?X,5?XO$DTQ`O,5?XO$+YQ`O,5?XOOQO-E<k-E<kOOQS1G0a1G0aOOQS1G0c1G0cO#.lQ`O1G0cOOQ[7+(e7+(eO!&zQMhO7+(eO%[QlO7+(eO$DcQ`O7+(eO$DnQMhO7+(eO$D|Q!0MzO,5=XO$GXQ!0MzO,5=ZO$IdQ!0MzO,5=XO$KuQ!0MzO,5=ZO$NWQ!0MzO,59uO%!]Q!0MzO,5<kO%$hQ!0MzO,5<mO%&sQ!0MzO,5<{OOQ!0Lf7+&a7+&aO%)UQ!0MxO7+&aO%)xQlO'#IfO%*VQ`O,5@cO%*_Q!fO,5@cOOQ!0Lf1G0P1G0PO%*iQ`O7+&jOOQ!0Lf7+&j7+&jO%*nQ?MtO,5:fO%[QlO7+&zO%*xQ?MtO,5:bO%+VQ?MtO,5:jO%+aQ?MtO,5:lO%+kQMhO'#IiO%+uQ`O,5@hOOQ!0Lh1G0d1G0dOOQO1G1r1G1rOOQO1G1s1G1sO%+}Q!jO,5<ZO!)[QlO,5<YOOQO-E<l-E<lOOQ!0Lf7+'Y7+'YOOOW7+'e7+'eOOOW1G1|1G1|O%,YQ`O1G1|OOQ!0Lf1G2O1G2OOOOO,59o,59oO%,_Q!dO,59oOOOO-E<`-E<`OOQ!0Lh1G/X1G/XO%,fQ!0MxO7+'kOOQ!0Lh,5?^,5?^O%-YQMhO1G2fP%-aQ`O'#IrPOQ!0Lh-E<p-E<pO%-}QMjO,5?aOOQ!0Lh-E<s-E<sO%.pQMjO,5?cOOQ!0Lh-E<u-E<uO%.zQ!dO1G2wO%/RQ!dO'#CrO%/iQMhO'#KSO$$wQlO'#JvOOQ!0Lh1G2_1G2_O%/sQ`O'#IqO%0[Q`O,5@vO%0[Q`O,5@vO%0dQ`O,5@vO%0oQ`O,5@vOOQO1G2a1G2aO%0}QMjO1G2`O$+YQ`O'#K[O!,TQMhO1G2`O%1_Q(CWO'#IsO%1lQ`O,5@wO!&zQMhO,5@wO%1tQ!dO,5@wOOQ!0Lh1G2d1G2dO%4UQ!fO'#CiO%4`Q`O,5=POOQ!0Lb,5<},5<}O%4hQpO,5<}OOQ!0Lb,5=O,5=OOCwQ`O,5<}O%4sQpO,5<}OOQ!0Lb,5=R,5=RO$+YQ`O,5=VOOQO,5?`,5?`OOQO-E<r-E<rOOQ!0Lp1G2h1G2hO#$`QpO,5<}O$$wQlO,5=PO%5RQ`O,5=OO%5^QpO,5=OO!,TQMhO'#IuO%6WQMjO1G2sO!,TQMhO'#IwO%6yQMjO1G2uO%7TQMjO1G5qO%7_QMjO1G5qOOQO,5?e,5?eOOQO-E<w-E<wOOQO1G.{1G.{O!,TQMhO1G5qO!,TQMhO1G5qO!:]QpO,59wO%[QlO,59wOOQ!0Lh,5<j,5<jO%7lQ`O1G2ZO!,TQMhO1G2bO%7qQ!0MxO7+'mOOQ!0Lf7+'m7+'mO!$wQlO7+'mO%8eQ`O,5;`OOQ!0Lb,5?g,5?gOOQ!0Lb-E<y-E<yO%8jQ!dO'#K^O#(ZQ`O7+(eO4UQ!fO7+(eO$DfQ`O7+(eO%8tQ!0MvO'#CiO%9XQ!0MvO,5=SO%9lQ`O,5=SO%9tQ`O,5=SOOQ!0Lb1G5o1G5oOOQ[7+$a7+$aO!ByQ!0LrO7+$aO!CUQpO7+$aO!$wQlO7+&aO%9yQ`O'#JQO%:bQ`O,5APOOQO1G3h1G3hO9kQ`O,5APO%:bQ`O,5APO%:jQ`O,5APOOQO,5?m,5?mOOQO-E=P-E=POOQ!0Lf7+'T7+'TO%:oQ`O7+)QO9uQ!0LrO7+)QO9kQ`O7+)QO@zQ`O7+)QO%:tQ`O7+)QOOQ[7+)Q7+)QOOQ[7+(p7+(pO%:yQ!0MvO7+(mO!&zQMhO7+(mO!E^Q`O7+(nOOQ[7+(n7+(nO!&zQMhO7+(nO%;TQ`O'#KbO%;`Q`O,5=lOOQO,5?i,5?iOOQO-E<{-E<{OOQ[7+(s7+(sO%<rQpO'#HZOOQ[1G3`1G3`O!&zQMhO1G3`O%[QlO1G3`O%<yQ`O1G3`O%=UQMhO1G3`O9uQ!0LrO1G3bO$%dQ`O1G3bO9`Q`O1G3bO!CUQpO1G3bO!C^QMhO1G3bO%=dQ`O'#JPO%=xQ`O,5@}O%>QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-E<c-E<cOOQO,5?V,5?VOOQO-E<i-E<iO!CUQpO1G/sOOQO-E<e-E<eOOQ!0Ln1G0]1G0]OOQ!0Lf7+%u7+%uO#(ZQ`O7+%uOOQ!0Lf7+&`7+&`O?YQ`O7+&`O!CUQpO7+&`OOQO7+%x7+%xO$AlQ!0MxO7+&XOOQO7+&X7+&XO%[QlO7+&XO%@nQ!0LrO7+&XO!ByQ!0LrO7+%xO!CUQpO7+%xO%@yQ!0LrO7+&XO%AXQ!0MxO7++rO%[QlO7++rO%AiQ`O7++qO%AiQ`O7++qOOQO1G4s1G4sO9eQ`O1G4sO%AqQ`O1G4sOOQS7+%}7+%}O#(ZQ`O<<LPO4UQ!fO<<LPO%BPQ`O<<LPOOQ[<<LP<<LPO!&zQMhO<<LPO%[QlO<<LPO%BXQ`O<<LPO%BdQ!0MzO,5?aO%DoQ!0MzO,5?cO%FzQ!0MzO1G2`O%I]Q!0MzO1G2sO%KhQ!0MzO1G2uO%MsQ!fO,5?QO%[QlO,5?QOOQO-E<d-E<dO%M}Q`O1G5}OOQ!0Lf<<JU<<JUO%NVQ?MtO1G0uO&!^Q?MtO1G1PO&!eQ?MtO1G1PO&$fQ?MtO1G1PO&$mQ?MtO1G1PO&&nQ?MtO1G1PO&(oQ?MtO1G1PO&(vQ?MtO1G1PO&(}Q?MtO1G1PO&+OQ?MtO1G1PO&+VQ?MtO1G1PO&+^Q!0MxO<<JfO&-UQ?MtO1G1PO&.RQ?MvO1G1PO&/UQ?MvO'#JlO&1[Q?MtO1G1cO&1iQ?MtO1G0UO&1sQMjO,5?TOOQO-E<g-E<gO!)[QlO'#FqOOQO'#KZ'#KZOOQO1G1u1G1uO&1}Q`O1G1tO&2SQ?MtO,5?[OOOW7+'h7+'hOOOO1G/Z1G/ZO&2^Q!dO1G4xOOQ!0Lh7+(Q7+(QP!&zQMhO,5?^O!,TQMhO7+(cO&2eQ`O,5?]O9eQ`O,5?]O$+YQ`O,5?]OOQO-E<o-E<oO&2sQ`O1G6bO&2sQ`O1G6bO&2{Q`O1G6bO&3WQMjO7+'zO&3hQ!dO,5?_O&3rQ`O,5?_O!&zQMhO,5?_OOQO-E<q-E<qO&3wQ!dO1G6cO&4RQ`O1G6cO&4ZQ`O1G2kO!&zQMhO1G2kOOQ!0Lb1G2i1G2iOOQ!0Lb1G2j1G2jO%4hQpO1G2iO!CUQpO1G2iOCwQ`O1G2iOOQ!0Lb1G2q1G2qO&4`QpO1G2iO&4nQ`O1G2kO$+YQ`O1G2jOCwQ`O1G2jO$$wQlO1G2kO&4vQ`O1G2jO&5jQMjO,5?aOOQ!0Lh-E<t-E<tO&6]QMjO,5?cOOQ!0Lh-E<v-E<vO!,TQMhO7++]O&6gQMjO7++]O&6qQMjO7++]OOQ!0Lh1G/c1G/cO&7OQ`O1G/cOOQ!0Lh7+'u7+'uO&7TQMjO7+'|O&7eQ!0MxO<<KXOOQ!0Lf<<KX<<KXO&8XQ`O1G0zO!&zQMhO'#IzO&8^Q`O,5@xO&:`Q!fO<<LPO!&zQMhO1G2nO&:gQ!0LrO1G2nOOQ[<<G{<<G{O!ByQ!0LrO<<G{O&:xQ!0MxO<<I{OOQ!0Lf<<I{<<I{OOQO,5?l,5?lO&;lQ`O,5?lO&;qQ`O,5?lOOQO-E=O-E=OO&<PQ`O1G6kO&<PQ`O1G6kO9kQ`O1G6kO@zQ`O<<LlOOQ[<<Ll<<LlO&<XQ`O<<LlO9uQ!0LrO<<LlO9kQ`O<<LlOOQ[<<LX<<LXO%:yQ!0MvO<<LXOOQ[<<LY<<LYO!E^Q`O<<LYO&<^QpO'#I|O&<iQ`O,5@|O!)[QlO,5@|OOQ[1G3W1G3WOOQO'#JO'#JOO9uQ!0LrO'#JOO&<qQpO,5=uOOQ[,5=u,5=uO&<xQpO'#EgO&=PQpO'#GeO&=UQ`O7+(zO&=ZQ`O7+(zOOQ[7+(z7+(zO!&zQMhO7+(zO%[QlO7+(zO&=cQ`O7+(zOOQ[7+(|7+(|O9uQ!0LrO7+(|O$%dQ`O7+(|O9`Q`O7+(|O!CUQpO7+(|O&=nQ`O,5?kOOQO-E<}-E<}OOQO'#H^'#H^O&=yQ`O1G6iO9uQ!0LrO<<GqOOQ[<<Gq<<GqO@zQ`O<<GqO&>RQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<<Ly<<LyOOQ[<<L{<<L{OOQ[-E=Q-E=QOOQ[1G3z1G3zO&>nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<<Ia<<IaOOQ!0Lf<<Iz<<IzO?YQ`O<<IzOOQO<<Is<<IsO$AlQ!0MxO<<IsO%[QlO<<IsOOQO<<Id<<IdO!ByQ!0LrO<<IdO&?SQ!0LrO<<IsO&?_Q!0MxO<= ^O&?oQ`O<= ]OOQO7+*_7+*_O9eQ`O7+*_OOQ[ANAkANAkO&?wQ!fOANAkO!&zQMhOANAkO#(ZQ`OANAkO4UQ!fOANAkO&@OQ`OANAkO%[QlOANAkO&@WQ!0MzO7+'zO&BiQ!0MzO,5?aO&DtQ!0MzO,5?cO&GPQ!0MzO7+'|O&IbQ!fO1G4lO&IlQ?MtO7+&aO&KpQ?MvO,5=XO&MwQ?MvO,5=ZO&NXQ?MvO,5=XO&NiQ?MvO,5=ZO&NyQ?MvO,59uO'#PQ?MvO,5<kO'%SQ?MvO,5<mO''hQ?MvO,5<{O')^Q?MtO7+'kO')kQ?MtO7+'mO')xQ`O,5<]OOQO7+'`7+'`OOQ!0Lh7+*d7+*dO')}QMjO<<K}OOQO1G4w1G4wO'*UQ`O1G4wO'*aQ`O1G4wO'*oQ`O7++|O'*oQ`O7++|O!&zQMhO1G4yO'*wQ!dO1G4yO'+RQ`O7++}O'+ZQ`O7+(VO'+fQ!dO7+(VOOQ!0Lb7+(T7+(TOOQ!0Lb7+(U7+(UO!CUQpO7+(TOCwQ`O7+(TO'+pQ`O7+(VO!&zQMhO7+(VO$+YQ`O7+(UO'+uQ`O7+(VOCwQ`O7+(UO'+}QMjO<<NwO!,TQMhO<<NwOOQ!0Lh7+$}7+$}O',XQ!dO,5?fOOQO-E<x-E<xO',cQ!0MvO7+(YO!&zQMhO7+(YOOQ[AN=gAN=gO9kQ`O1G5WOOQO1G5W1G5WO',sQ`O1G5WO',xQ`O7+,VO',xQ`O7+,VO9uQ!0LrOANBWO@zQ`OANBWOOQ[ANBWANBWO'-QQ`OANBWOOQ[ANAsANAsOOQ[ANAtANAtO'-VQ`O,5?hOOQO-E<z-E<zO'-bQ?MtO1G6hOOQO,5?j,5?jOOQO-E<|-E<|OOQ[1G3a1G3aO'-lQ`O,5=POOQ[<<Lf<<LfO!&zQMhO<<LfO&=UQ`O<<LfO'-qQ`O<<LfO%[QlO<<LfOOQ[<<Lh<<LhO9uQ!0LrO<<LhO$%dQ`O<<LhO9`Q`O<<LhO'-yQpO1G5VO'.UQ`O7+,TOOQ[AN=]AN=]O9uQ!0LrOAN=]OOQ[<= r<= rOOQ[<= s<= sO'.^Q`O<= rO'.cQ`O<= sOOQ[<<Lq<<LqO'.hQ`O<<LqO'.mQlO<<LqOOQ[1G3{1G3{O?YQ`O7+)lO'.tQ`O<<JQO'/PQ?MtO<<JQOOQO<<Hy<<HyOOQ!0LfAN?fAN?fOOQOAN?_AN?_O$AlQ!0MxOAN?_OOQOAN?OAN?OO%[QlOAN?_OOQO<<My<<MyOOQ[G27VG27VO!&zQMhOG27VO#(ZQ`OG27VO'/ZQ!fOG27VO4UQ!fOG27VO'/bQ`OG27VO'/jQ?MtO<<JfO'/wQ?MvO1G2`O'1mQ?MvO,5?aO'3pQ?MvO,5?cO'5sQ?MvO1G2sO'7vQ?MvO1G2uO'9yQ?MtO<<KXO':WQ?MtO<<I{OOQO1G1w1G1wO!,TQMhOANAiOOQO7+*c7+*cO':eQ`O7+*cO':pQ`O<= hO':xQ!dO7+*eOOQ!0Lb<<Kq<<KqO$+YQ`O<<KqOCwQ`O<<KqO';SQ`O<<KqO!&zQMhO<<KqOOQ!0Lb<<Ko<<KoO!CUQpO<<KoO';_Q!dO<<KqOOQ!0Lb<<Kp<<KpO';iQ`O<<KqO!&zQMhO<<KqO$+YQ`O<<KpO';nQMjOANDcO';xQ!0MvO<<KtOOQO7+*r7+*rO9kQ`O7+*rO'<YQ`O<= qOOQ[G27rG27rO9uQ!0LrOG27rO@zQ`OG27rO!)[QlO1G5SO'<bQ`O7+,SO'<jQ`O1G2kO&=UQ`OANBQOOQ[ANBQANBQO!&zQMhOANBQO'<oQ`OANBQOOQ[ANBSANBSO9uQ!0LrOANBSO$%dQ`OANBSOOQO'#H_'#H_OOQO7+*q7+*qOOQ[G22wG22wOOQ[ANE^ANE^OOQ[ANE_ANE_OOQ[ANB]ANB]O'<wQ`OANB]OOQ[<<MW<<MWO!)[QlOAN?lOOQOG24yG24yO$AlQ!0MxOG24yO#(ZQ`OLD,qOOQ[LD,qLD,qO!&zQMhOLD,qO'<|Q!fOLD,qO'=TQ?MvO7+'zO'>yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<<M}<<M}OOQ!0LbANA]ANA]O$+YQ`OANA]OCwQ`OANA]O'EVQ!dOANA]OOQ!0LbANAZANAZO'E^Q`OANA]O!&zQMhOANA]O'EiQ!dOANA]OOQ!0LbANA[ANA[OOQO<<N^<<N^OOQ[LD-^LD-^O9uQ!0LrOLD-^O'EsQ?MtO7+*nOOQO'#Gf'#GfOOQ[G27lG27lO&=UQ`OG27lO!&zQMhOG27lOOQ[G27nG27nO9uQ!0LrOG27nOOQ[G27wG27wO'E}Q?MtOG25WOOQOLD*eLD*eOOQ[!$(!]!$(!]O#(ZQ`O!$(!]O!&zQMhO!$(!]O'FXQ!0MzOG27TOOQ!0LbG26wG26wO$+YQ`OG26wO'HjQ`OG26wOCwQ`OG26wO'HuQ!dOG26wO!&zQMhOG26wOOQ[!$(!x!$(!xOOQ[LD-WLD-WO&=UQ`OLD-WOOQ[LD-YLD-YOOQ[!)9Ew!)9EwO#(ZQ`O!)9EwOOQ!0LbLD,cLD,cO$+YQ`OLD,cOCwQ`OLD,cO'H|Q`OLD,cO'IXQ!dOLD,cOOQ[!$(!r!$(!rOOQ[!.K;c!.K;cO'I`Q?MvOG27TOOQ!0Lb!$( }!$( }O$+YQ`O!$( }OCwQ`O!$( }O'KUQ`O!$( }OOQ!0Lb!)9Ei!)9EiO$+YQ`O!)9EiOCwQ`O!)9EiOOQ!0Lb!.K;T!.K;TO$+YQ`O!.K;TOOQ!0Lb!4/0o!4/0oO!)[QlO'#DzO1PQ`O'#EXO'KaQ!fO'#JrO'KhQ!L^O'#DvO'KoQlO'#EOO'KvQ!fO'#CiO'N^Q!fO'#CiO!)[QlO'#EQO'NnQlO,5;ZO!)[QlO,5;eO!)[QlO,5;eO!)[QlO,5;eO!)[QlO,5;eO!)[QlO,5;eO!)[QlO,5;eO!)[QlO,5;eO!)[QlO,5;eO!)[QlO,5;eO!)[QlO,5;eO!)[QlO'#IpO(!qQ`O,5<iO!)[QlO,5;eO(!yQMhO,5;eO($dQMhO,5;eO!)[QlO,5;wO!&zQMhO'#GmO(!yQMhO'#GmO!&zQMhO'#GoO(!yQMhO'#GoO1SQ`O'#DZO1SQ`O'#DZO!&zQMhO'#GPO(!yQMhO'#GPO!&zQMhO'#GRO(!yQMhO'#GRO!&zQMhO'#GaO(!yQMhO'#GaO!)[QlO,5:jO($kQpO'#D_O($uQpO'#JvO!)[QlO,5@oO'NnQlO1G0uO(%PQ?MtO'#CiO!)[QlO1G2PO!&zQMhO'#IuO(!yQMhO'#IuO!&zQMhO'#IwO(!yQMhO'#IwO(%ZQ!dO'#CrO!&zQMhO,5<tO(!yQMhO,5<tO'NnQlO1G2RO!)[QlO7+&zO!&zQMhO1G2`O(!yQMhO1G2`O!&zQMhO'#IuO(!yQMhO'#IuO!&zQMhO'#IwO(!yQMhO'#IwO!&zQMhO1G2bO(!yQMhO1G2bO'NnQlO7+'mO'NnQlO7+&aO!&zQMhOANAiO(!yQMhOANAiO(%nQ`O'#EoO(%sQ`O'#EoO(%{Q`O'#F]O(&QQ`O'#EyO(&VQ`O'#KTO(&bQ`O'#KRO(&mQ`O,5;ZO(&rQMjO,5<eO(&yQ`O'#GYO('OQ`O'#GYO('TQ`O,5<eO(']Q`O,5<gO('eQ`O,5;ZO('mQ?MtO1G1`O('tQ`O,5<tO('yQ`O,5<tO((OQ`O,5<vO((TQ`O,5<vO((YQ`O1G2RO((_Q`O1G0uO((dQMjO<<K}O((kQMjO<<K}O((rQMhO'#F|O9`Q`O'#F{OAuQ`O'#EnO!)[QlO,5;tO!3oQ`O'#GYO!3oQ`O'#GYO!3oQ`O'#G[O!3oQ`O'#G[O!,TQMhO7+(cO!,TQMhO7+(cO%.zQ!dO1G2wO%.zQ!dO1G2wO!&zQMhO,5=]O!&zQMhO,5=]",
    stateData: "()x~O'|OS'}OSTOS(ORQ~OPYOQYOSfOY!VOaqOdzOeyOl!POpkOrYOskOtkOzkO|YO!OYO!SWO!WkO!XkO!_XO!iuO!lZO!oYO!pYO!qYO!svO!uwO!xxO!|]O$W|O$niO%h}O%j!QO%l!OO%m!OO%n!OO%q!RO%s!SO%v!TO%w!TO%y!UO&W!WO&^!XO&`!YO&b!ZO&d![O&g!]O&m!^O&s!_O&u!`O&w!aO&y!bO&{!cO(TSO(VTO(YUO(aVO(o[O~OWtO~P`OPYOQYOSfOd!jOe!iOpkOrYOskOtkOzkO|YO!OYO!SWO!WkO!XkO!_!eO!iuO!lZO!oYO!pYO!qYO!svO!u!gO!x!hO$W!kO$niO(T!dO(VTO(YUO(aVO(o[O~Oa!wOs!nO!S!oO!b!yO!c!vO!d!vO!|<VO#T!pO#U!pO#V!xO#W!pO#X!pO#[!zO#]!zO(U!lO(VTO(YUO(e!mO(o!sO~O(O!{O~OP]XR]X[]Xa]Xj]Xr]X!Q]X!S]X!]]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X'z]X(a]X(r]X(y]X(z]X~O!g%RX~P(qO_!}O(V#PO(W!}O(X#PO~O_#QO(X#PO(Y#PO(Z#QO~Ox#SO!U#TO(b#TO(c#VO~OPYOQYOSfOd!jOe!iOpkOrYOskOtkOzkO|YO!OYO!SWO!WkO!XkO!_!eO!iuO!lZO!oYO!pYO!qYO!svO!u!gO!x!hO$W!kO$niO(T<ZO(VTO(YUO(aVO(o[O~O![#ZO!]#WO!Y(hP!Y(vP~P+}O!^#cO~P`OPYOQYOSfOd!jOe!iOrYOskOtkOzkO|YO!OYO!SWO!WkO!XkO!_!eO!iuO!lZO!oYO!pYO!qYO!svO!u!gO!x!hO$W!kO$niO(VTO(YUO(aVO(o[O~Op#mO![#iO!|]O#i#lO#j#iO(T<[O!k(sP~P.iO!l#oO(T#nO~O!x#sO!|]O%h#tO~O#k#uO~O!g#vO#k#uO~OP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!]$_O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO#z$WO#{$XO(aVO(r$YO(y#|O(z#}O~Oa(fX'z(fX'w(fX!k(fX!Y(fX!_(fX%i(fX!g(fX~P1qO#S$dO#`$eO$Q$eOP(gXR(gX[(gXj(gXr(gX!Q(gX!S(gX!](gX!l(gX!p(gX#R(gX#n(gX#o(gX#p(gX#q(gX#r(gX#s(gX#t(gX#u(gX#v(gX#x(gX#z(gX#{(gX(a(gX(r(gX(y(gX(z(gX!_(gX%i(gX~Oa(gX'z(gX'w(gX!Y(gX!k(gXv(gX!g(gX~P4UO#`$eO~O$]$hO$_$gO$f$mO~OSfO!_$nO$i$oO$k$qO~Oh%VOj%dOk%dOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T$sO(VTO(YUO(a$uO(y$}O(z%POg(^P~Ol%[O~P7eO!l%eO~O!S%hO!_%iO(T%gO~O!g%mO~Oa%nO'z%nO~O!Q%rO~P%[O(U!lO~P%[O%n%vO~P%[Oh%VO!l%eO(T%gO(U!lO~Oe%}O!l%eO(T%gO~Oj$RO~O!_&PO(T%gO(U!lO(VTO(YUO`)WP~O!Q&SO!l&RO%j&VO&T&WO~P;SO!x#sO~O%s&YO!S)SX!_)SX(T)SX~O(T&ZO~Ol!PO!u&`O%j!QO%l!OO%m!OO%n!OO%q!RO%s!SO%v!TO%w!TO~Od&eOe&dO!x&bO%h&cO%{&aO~P<bOd&hOeyOl!PO!_&gO!u&`O!xxO!|]O%h}O%l!OO%m!OO%n!OO%q!RO%s!SO%v!TO%w!TO%y!UO~Ob&kO#`&nO%j&iO(U!lO~P=gO!l&oO!u&sO~O!l#oO~O!_XO~Oa%nO'x&{O'z%nO~Oa%nO'x'OO'z%nO~Oa%nO'x'QO'z%nO~O'w]X!Y]Xv]X!k]X&[]X!_]X%i]X!g]X~P(qO!b'_O!c'WO!d'WO(U!lO(VTO(YUO~Os'UO!S'TO!['XO(e'SO!^(iP!^(xP~P@nOn'bO!_'`O(T%gO~Oe'gO!l%eO(T%gO~O!Q&SO!l&RO~Os!nO!S!oO!|<VO#T!pO#U!pO#W!pO#X!pO(U!lO(VTO(YUO(e!mO(o!sO~O!b'mO!c'lO!d'lO#V!pO#['nO#]'nO~PBYOa%nOh%VO!g#vO!l%eO'z%nO(r'pO~O!p'tO#`'rO~PChOs!nO!S!oO(VTO(YUO(e!mO(o!sO~O!_XOs(mX!S(mX!b(mX!c(mX!d(mX!|(mX#T(mX#U(mX#V(mX#W(mX#X(mX#[(mX#](mX(U(mX(V(mX(Y(mX(e(mX(o(mX~O!c'lO!d'lO(U!lO~PDWO(P'xO(Q'xO(R'zO~O_!}O(V'|O(W!}O(X'|O~O_#QO(X'|O(Y'|O(Z#QO~Ov(OO~P%[Ox#SO!U#TO(b#TO(c(RO~O![(TO!Y'WX!Y'^X!]'WX!]'^X~P+}O!](VO!Y(hX~OP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!](VO!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO#z$WO#{$XO(aVO(r$YO(y#|O(z#}O~O!Y(hX~PHRO!Y([O~O!Y(uX!](uX!g(uX!k(uX(r(uX~O#`(uX#k#dX!^(uX~PJUO#`(]O!Y(wX!](wX~O!](^O!Y(vX~O!Y(aO~O#`$eO~PJUO!^(bO~P`OR#zO!Q#yO!S#{O!l#xO(aVOP!na[!naj!nar!na!]!na!p!na#R!na#n!na#o!na#p!na#q!na#r!na#s!na#t!na#u!na#v!na#x!na#z!na#{!na(r!na(y!na(z!na~Oa!na'z!na'w!na!Y!na!k!nav!na!_!na%i!na!g!na~PKlO!k(cO~O!g#vO#`(dO(r'pO!](tXa(tX'z(tX~O!k(tX~PNXO!S%hO!_%iO!|]O#i(iO#j(hO(T%gO~O!](jO!k(sX~O!k(lO~O!S%hO!_%iO#j(hO(T%gO~OP(gXR(gX[(gXj(gXr(gX!Q(gX!S(gX!](gX!l(gX!p(gX#R(gX#n(gX#o(gX#p(gX#q(gX#r(gX#s(gX#t(gX#u(gX#v(gX#x(gX#z(gX#{(gX(a(gX(r(gX(y(gX(z(gX~O!g#vO!k(gX~P! uOR(nO!Q(mO!l#xO#S$dO!|!{a!S!{a~O!x!{a%h!{a!_!{a#i!{a#j!{a(T!{a~P!#vO!x(rO~OPYOQYOSfOd!jOe!iOpkOrYOskOtkOzkO|YO!OYO!SWO!WkO!XkO!_XO!iuO!lZO!oYO!pYO!qYO!svO!u!gO!x!hO$W!kO$niO(T!dO(VTO(YUO(aVO(o[O~Oh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O<sO!S${O!_$|O!i>VO!l$xO#j<yO$W%`O$t<uO$v<wO$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~O#k(xO~O![(zO!k(kP~P%[O(e(|O(o[O~O!S)OO!l#xO(e(|O(o[O~OP<UOQ<UOSfOd>ROe!iOpkOr<UOskOtkOzkO|<UO!O<UO!SWO!WkO!XkO!_!eO!i<XO!lZO!o<UO!p<UO!q<UO!s<YO!u<]O!x!hO$W!kO$n>PO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!O<sO!S*YO!_*ZO!i>VO!l$xO#j<yO$W%`O$t<uO$v<wO$y%aO(VTO(YUO(a$uO(y$}O(z%PO~Op*`O![*^O(T*XO!k)OP~P!1uO#k*aO~O!l*bO~Oh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O<sO!S${O!_$|O!i>VO!l$xO#j<yO$W%`O$t<uO$v<wO$y%aO(T*dO(VTO(YUO(a$uO(y$}O(z%PO~O![*gO!Y)PP~P!3tOr*sOs!nO!S*iO!b*qO!c*kO!d*kO!l*bO#[*rO%`*mO(U!lO(VTO(YUO(e!mO~O!^*pO~P!5iO#S$dOn(`X!Q(`X'y(`X(y(`X(z(`X!](`X#`(`X~Og(`X$O(`X~P!6kOn*xO#`*wOg(_X!](_X~O!]*yOg(^X~Oj%dOk%dOl%dO(T&ZOg(^P~Os*|O~Og)}O(T&ZO~O!l+SO~O(T(vO~Op+WO!S%hO![#iO!_%iO!|]O#i#lO#j#iO(T%gO!k(sP~O!g#vO#k+XO~O!S%hO![+ZO!](^O!_%iO(T%gO!Y(vP~Os'[O!S+]O![+[O(VTO(YUO(e(|O~O!^(xP~P!9|O!]+^Oa)TX'z)TX~OP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO#z$WO#{$XO(aVO(r$YO(y#|O(z#}O~Oa!ja!]!ja'z!ja'w!ja!Y!ja!k!jav!ja!_!ja%i!ja!g!ja~P!:tOR#zO!Q#yO!S#{O!l#xO(aVOP!ra[!raj!rar!ra!]!ra!p!ra#R!ra#n!ra#o!ra#p!ra#q!ra#r!ra#s!ra#t!ra#u!ra#v!ra#x!ra#z!ra#{!ra(r!ra(y!ra(z!ra~Oa!ra'z!ra'w!ra!Y!ra!k!rav!ra!_!ra%i!ra!g!ra~P!=[OR#zO!Q#yO!S#{O!l#xO(aVOP!ta[!taj!tar!ta!]!ta!p!ta#R!ta#n!ta#o!ta#p!ta#q!ta#r!ta#s!ta#t!ta#u!ta#v!ta#x!ta#z!ta#{!ta(r!ta(y!ta(z!ta~Oa!ta'z!ta'w!ta!Y!ta!k!tav!ta!_!ta%i!ta!g!ta~P!?rOh%VOn+gO!_'`O%i+fO~O!g+iOa(]X!_(]X'z(]X!](]X~Oa%nO!_XO'z%nO~Oh%VO!l%eO~Oh%VO!l%eO(T%gO~O!g#vO#k(xO~Ob+tO%j+uO(T+qO(VTO(YUO!^)XP~O!]+vO`)WX~O[+zO~O`+{O~O!_&PO(T%gO(U!lO`)WP~O%j,OO~P;SOh%VO#`,SO~Oh%VOn,VO!_$|O~O!_,XO~O!Q,ZO!_XO~O%n%vO~O!x,`O~Oe,eO~Ob,fO(T#nO(VTO(YUO!^)VP~Oe%}O~O%j!QO(T&ZO~P=gO[,kO`,jO~OPYOQYOSfOdzOeyOpkOrYOskOtkOzkO|YO!OYO!SWO!WkO!XkO!iuO!lZO!oYO!pYO!qYO!svO!xxO!|]O$niO%h}O(VTO(YUO(aVO(o[O~O!_!eO!u!gO$W!kO(T!dO~P!FyO`,jOa%nO'z%nO~OPYOQYOSfOd!jOe!iOpkOrYOskOtkOzkO|YO!OYO!SWO!WkO!XkO!_!eO!iuO!lZO!oYO!pYO!qYO!svO!x!hO$W!kO$niO(T!dO(VTO(YUO(aVO(o[O~Oa,pOl!OO!uwO%l!OO%m!OO%n!OO~P!IcO!l&oO~O&^,vO~O!_,xO~O&o,zO&q,{OP&laQ&laS&laY&laa&lad&lae&lal&lap&lar&las&lat&laz&la|&la!O&la!S&la!W&la!X&la!_&la!i&la!l&la!o&la!p&la!q&la!s&la!u&la!x&la!|&la$W&la$n&la%h&la%j&la%l&la%m&la%n&la%q&la%s&la%v&la%w&la%y&la&W&la&^&la&`&la&b&la&d&la&g&la&m&la&s&la&u&la&w&la&y&la&{&la'w&la(T&la(V&la(Y&la(a&la(o&la!^&la&e&lab&la&j&la~O(T-QO~Oh!eX!]!RX!^!RX!g!RX!g!eX!l!eX#`!RX~O!]!eX!^!eX~P#!iO!g-VO#`-UOh(jX!]#hX!^#hX!g(jX!l(jX~O!](jX!^(jX~P##[Oh%VO!g-XO!l%eO!]!aX!^!aX~Os!nO!S!oO(VTO(YUO(e!mO~OP<UOQ<UOSfOd>ROe!iOpkOr<UOskOtkOzkO|<UO!O<UO!SWO!WkO!XkO!_!eO!i<XO!lZO!o<UO!p<UO!q<UO!s<YO!u<]O!x!hO$W!kO$n>PO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[<mOj<bOr<kO!Q#yO!S#{O!l#xO!p$[O#R<bO#n<_O#o<`O#p<`O#q<`O#r<aO#s<bO#t<bO#u<lO#v<cO#x<eO#z<gO#{<hO(aVO(r$YO(y#|O(z#}O~O$O.{O~P#BwO#S$dO#`<nO$Q<nO$O(gX!^(gX~P! uOa'da!]'da'z'da'w'da!k'da!Y'dav'da!_'da%i'da!g'da~P!:tO[#mia#mij#mir#mi!]#mi#R#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO(y#mi(z#mi~P#EyOn>]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]<iO!^(fX~P#BwO!^/ZO~O!g)hO$f({X~O$f/]O~Ov/^O~P!&zOx)yO(b)zO(c/aO~O!S/dO~O(y$}On%aa!Q%aa'y%aa(z%aa!]%aa#`%aa~Og%aa$O%aa~P#L{O(z%POn%ca!Q%ca'y%ca(y%ca!]%ca#`%ca~Og%ca$O%ca~P#MnO!]fX!gfX!kfX!k$zX(rfX~P!0SOp%WO![/mO!](^O(T/lO!Y(vP!Y)PP~P!1uOr*sO!b*qO!c*kO!d*kO!l*bO#[*rO%`*mO(U!lO(VTO(YUO~Os<}O!S/nO![+[O!^*pO(e<|O!^(xP~P$ [O!k/oO~P#/sO!]/pO!g#vO(r'pO!k)OX~O!k/uO~OnoX!QoX'yoX(yoX(zoX~O!g#vO!koX~P$#OOp/wO!S%hO![*^O!_%iO(T%gO!k)OP~O#k/xO~O!Y$zX!]$zX!g%RX~P!0SO!]/yO!Y)PX~P#/sO!g/{O~O!Y/}O~OpkO(T0OO~P.iOh%VOr0TO!g#vO!l%eO(r'pO~O!g+iO~Oa%nO!]0XO'z%nO~O!^0ZO~P!5iO!c0[O!d0[O(U!lO~P#$`Os!nO!S0]O(VTO(YUO(e!mO~O#[0_O~Og%aa!]%aa#`%aa$O%aa~P!1WOg%ca!]%ca#`%ca$O%ca~P!1WOj%dOk%dOl%dO(T&ZOg'mX!]'mX~O!]*yOg(^a~Og0hO~On0jO#`0iOg(_a!](_a~OR0kO!Q0kO!S0lO#S$dOn}a'y}a(y}a(z}a!]}a#`}a~Og}a$O}a~P$(cO!Q*OO'y*POn$sa(y$sa(z$sa!]$sa#`$sa~Og$sa$O$sa~P$)_O!Q*OO'y*POn$ua(y$ua(z$ua!]$ua#`$ua~Og$ua$O$ua~P$*QO#k0oO~Og%Ta!]%Ta#`%Ta$O%Ta~P!1WO!g#vO~O#k0rO~O!]+^Oa)Ta'z)Ta~OR#zO!Q#yO!S#{O!l#xO(aVOP!ri[!rij!rir!ri!]!ri!p!ri#R!ri#n!ri#o!ri#p!ri#q!ri#r!ri#s!ri#t!ri#u!ri#v!ri#x!ri#z!ri#{!ri(r!ri(y!ri(z!ri~Oa!ri'z!ri'w!ri!Y!ri!k!riv!ri!_!ri%i!ri!g!ri~P$+oOh%VOr%XOs$tOt$tOz%YO|%ZO!O<sO!S${O!_$|O!i>VO!l$xO#j<yO$W%`O$t<uO$v<wO$y%aO(VTO(YUO(a$uO(y$}O(z%PO~Op0{O%]0|O(T0zO~P$.VO!g+iOa(]a!_(]a'z(]a!](]a~O#k1SO~O[]X!]fX!^fX~O!]1TO!^)XX~O!^1VO~O[1WO~Ob1YO(T+qO(VTO(YUO~O!_&PO(T%gO`'uX!]'uX~O!]+vO`)Wa~O!k1]O~P!:tO[1`O~O`1aO~O#`1fO~On1iO!_$|O~O(e(|O!^)UP~Oh%VOn1rO!_1oO%i1qO~O[1|O!]1zO!^)VX~O!^1}O~O`2POa%nO'z%nO~O(T#nO(VTO(YUO~O#S$dO#`$eO$Q$eOP(gXR(gX[(gXr(gX!Q(gX!S(gX!](gX!l(gX!p(gX#R(gX#n(gX#o(gX#p(gX#q(gX#r(gX#s(gX#t(gX#u(gX#v(gX#x(gX#z(gX#{(gX(a(gX(r(gX(y(gX(z(gX~Oj2SO&[2TOa(gX~P$3pOj2SO#`$eO&[2TO~Oa2VO~P%[Oa2XO~O&e2[OP&ciQ&ciS&ciY&cia&cid&cie&cil&cip&cir&cis&cit&ciz&ci|&ci!O&ci!S&ci!W&ci!X&ci!_&ci!i&ci!l&ci!o&ci!p&ci!q&ci!s&ci!u&ci!x&ci!|&ci$W&ci$n&ci%h&ci%j&ci%l&ci%m&ci%n&ci%q&ci%s&ci%v&ci%w&ci%y&ci&W&ci&^&ci&`&ci&b&ci&d&ci&g&ci&m&ci&s&ci&u&ci&w&ci&y&ci&{&ci'w&ci(T&ci(V&ci(Y&ci(a&ci(o&ci!^&cib&ci&j&ci~Ob2bO!^2`O&j2aO~P`O!_XO!l2dO~O&q,{OP&liQ&liS&liY&lia&lid&lie&lil&lip&lir&lis&lit&liz&li|&li!O&li!S&li!W&li!X&li!_&li!i&li!l&li!o&li!p&li!q&li!s&li!u&li!x&li!|&li$W&li$n&li%h&li%j&li%l&li%m&li%n&li%q&li%s&li%v&li%w&li%y&li&W&li&^&li&`&li&b&li&d&li&g&li&m&li&s&li&u&li&w&li&y&li&{&li'w&li(T&li(V&li(Y&li(a&li(o&li!^&li&e&lib&li&j&li~O!Y2jO~O!]!aa!^!aa~P#BwOs!nO!S!oO![2pO(e!mO!]'XX!^'XX~P@nO!]-]O!^(ia~O!]'_X!^'_X~P!9|O!]-`O!^(xa~O!^2wO~P'_Oa%nO#`3QO'z%nO~Oa%nO!g#vO#`3QO'z%nO~Oa%nO!g#vO!p3UO#`3QO'z%nO(r'pO~Oa%nO'z%nO~P!:tO!]$_Ov$qa~O!Y'Wi!]'Wi~P!:tO!](VO!Y(hi~O!](^O!Y(vi~O!Y(wi!](wi~P!:tO!](ti!k(tia(ti'z(ti~P!:tO#`3WO!](ti!k(tia(ti'z(ti~O!](jO!k(si~O!S%hO!_%iO!|]O#i3]O#j3[O(T%gO~O!S%hO!_%iO#j3[O(T%gO~On3dO!_'`O%i3cO~Oh%VOn3dO!_'`O%i3cO~O#k%aaP%aaR%aa[%aaa%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa'z%aa(a%aa(r%aa!k%aa!Y%aa'w%aav%aa!_%aa%i%aa!g%aa~P#L{O#k%caP%caR%ca[%caa%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca'z%ca(a%ca(r%ca!k%ca!Y%ca'w%cav%ca!_%ca%i%ca!g%ca~P#MnO#k%aaP%aaR%aa[%aaa%aaj%aar%aa!S%aa!]%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa'z%aa(a%aa(r%aa!k%aa!Y%aa'w%aa#`%aav%aa!_%aa%i%aa!g%aa~P#/sO#k%caP%caR%ca[%caa%caj%car%ca!S%ca!]%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca'z%ca(a%ca(r%ca!k%ca!Y%ca'w%ca#`%cav%ca!_%ca%i%ca!g%ca~P#/sO#k}aP}a[}aa}aj}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a'z}a(a}a(r}a!k}a!Y}a'w}av}a!_}a%i}a!g}a~P$(cO#k$saP$saR$sa[$saa$saj$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa'z$sa(a$sa(r$sa!k$sa!Y$sa'w$sav$sa!_$sa%i$sa!g$sa~P$)_O#k$uaP$uaR$ua[$uaa$uaj$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua'z$ua(a$ua(r$ua!k$ua!Y$ua'w$uav$ua!_$ua%i$ua!g$ua~P$*QO#k%TaP%TaR%Ta[%Taa%Taj%Tar%Ta!S%Ta!]%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta'z%Ta(a%Ta(r%Ta!k%Ta!Y%Ta'w%Ta#`%Tav%Ta!_%Ta%i%Ta!g%Ta~P#/sOa#cq!]#cq'z#cq'w#cq!Y#cq!k#cqv#cq!_#cq%i#cq!g#cq~P!:tO![3lO!]'YX!k'YX~P%[O!].tO!k(ka~O!].tO!k(ka~P!:tO!Y3oO~O$O!na!^!na~PKlO$O!ja!]!ja!^!ja~P#BwO$O!ra!^!ra~P!=[O$O!ta!^!ta~P!?rOg']X!]']X~P!,TO!]/POg(pa~OSfO!_4TO$d4UO~O!^4YO~Ov4ZO~P#/sOa$mq!]$mq'z$mq'w$mq!Y$mq!k$mqv$mq!_$mq%i$mq!g$mq~P!:tO!Y4]O~P!&zO!S4^O~O!Q*OO'y*PO(z%POn'ia(y'ia!]'ia#`'ia~Og'ia$O'ia~P%-fO!Q*OO'y*POn'ka(y'ka(z'ka!]'ka#`'ka~Og'ka$O'ka~P%.XO(r$YO~P#/sO!YfX!Y$zX!]fX!]$zX!g%RX#`fX~P!0SOp%WO(T=WO~P!1uOp4bO!S%hO![4aO!_%iO(T%gO!]'eX!k'eX~O!]/pO!k)Oa~O!]/pO!g#vO!k)Oa~O!]/pO!g#vO(r'pO!k)Oa~Og$|i!]$|i#`$|i$O$|i~P!1WO![4jO!Y'gX!]'gX~P!3tO!]/yO!Y)Pa~O!]/yO!Y)Pa~P#/sOP]XR]X[]Xj]Xr]X!Q]X!S]X!Y]X!]]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X~Oj%YX!g%YX~P%2OOj4oO!g#vO~Oh%VO!g#vO!l%eO~Oh%VOr4tO!l%eO(r'pO~Or4yO!g#vO(r'pO~Os!nO!S4zO(VTO(YUO(e!mO~O(y$}On%ai!Q%ai'y%ai(z%ai!]%ai#`%ai~Og%ai$O%ai~P%5oO(z%POn%ci!Q%ci'y%ci(y%ci!]%ci#`%ci~Og%ci$O%ci~P%6bOg(_i!](_i~P!1WO#`5QOg(_i!](_i~P!1WO!k5VO~Oa$oq!]$oq'z$oq'w$oq!Y$oq!k$oqv$oq!_$oq%i$oq!g$oq~P!:tO!Y5ZO~O!]5[O!_)QX~P#/sOa$zX!_$zX%^]X'z$zX!]$zX~P!0SO%^5_OaoX!_oX'zoX!]oX~P$#OOp5`O(T#nO~O%^5_O~Ob5fO%j5gO(T+qO(VTO(YUO!]'tX!^'tX~O!]1TO!^)Xa~O[5kO~O`5lO~O[5pO~Oa%nO'z%nO~P#/sO!]5uO#`5wO!^)UX~O!^5xO~Or6OOs!nO!S*iO!b!yO!c!vO!d!vO!|<VO#T!pO#U!pO#V!pO#W!pO#X!pO#[5}O#]!zO(U!lO(VTO(YUO(e!mO(o!sO~O!^5|O~P%;eOn6TO!_1oO%i6SO~Oh%VOn6TO!_1oO%i6SO~Ob6[O(T#nO(VTO(YUO!]'sX!^'sX~O!]1zO!^)Va~O(VTO(YUO(e6^O~O`6bO~Oj6eO&[6fO~PNXO!k6gO~P%[Oa6iO~Oa6iO~P%[Ob2bO!^6nO&j2aO~P`O!g6pO~O!g6rOh(ji!](ji!^(ji!g(ji!l(jir(ji(r(ji~O!]#hi!^#hi~P#BwO#`6sO!]#hi!^#hi~O!]!ai!^!ai~P#BwOa%nO#`6|O'z%nO~Oa%nO!g#vO#`6|O'z%nO~O!](tq!k(tqa(tq'z(tq~P!:tO!](jO!k(sq~O!S%hO!_%iO#j7TO(T%gO~O!_'`O%i7WO~On7[O!_'`O%i7WO~O#k'iaP'iaR'ia['iaa'iaj'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia'z'ia(a'ia(r'ia!k'ia!Y'ia'w'iav'ia!_'ia%i'ia!g'ia~P%-fO#k'kaP'kaR'ka['kaa'kaj'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka'z'ka(a'ka(r'ka!k'ka!Y'ka'w'kav'ka!_'ka%i'ka!g'ka~P%.XO#k$|iP$|iR$|i[$|ia$|ij$|ir$|i!S$|i!]$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i'z$|i(a$|i(r$|i!k$|i!Y$|i'w$|i#`$|iv$|i!_$|i%i$|i!g$|i~P#/sO#k%aiP%aiR%ai[%aia%aij%air%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai'z%ai(a%ai(r%ai!k%ai!Y%ai'w%aiv%ai!_%ai%i%ai!g%ai~P%5oO#k%ciP%ciR%ci[%cia%cij%cir%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci'z%ci(a%ci(r%ci!k%ci!Y%ci'w%civ%ci!_%ci%i%ci!g%ci~P%6bO!]'Ya!k'Ya~P!:tO!].tO!k(ki~O$O#ci!]#ci!^#ci~P#BwOP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mij#mir#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi$O#mi(r#mi(y#mi(z#mi!]#mi!^#mi~O#n#mi~P%NdO#n<_O~P%NdOP$[OR#zOr<kO!Q#yO!S#{O!l#xO!p$[O#n<_O#o<`O#p<`O#q<`O(aVO[#mij#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi$O#mi(r#mi(y#mi(z#mi!]#mi!^#mi~O#r#mi~P&!lO#r<aO~P&!lOP$[OR#zO[<mOj<bOr<kO!Q#yO!S#{O!l#xO!p$[O#R<bO#n<_O#o<`O#p<`O#q<`O#r<aO#s<bO#t<bO#u<lO(aVO#x#mi#z#mi#{#mi$O#mi(r#mi(y#mi(z#mi!]#mi!^#mi~O#v#mi~P&$tOP$[OR#zO[<mOj<bOr<kO!Q#yO!S#{O!l#xO!p$[O#R<bO#n<_O#o<`O#p<`O#q<`O#r<aO#s<bO#t<bO#u<lO#v<cO(aVO(z#}O#z#mi#{#mi$O#mi(r#mi(y#mi!]#mi!^#mi~O#x<eO~P&&uO#x#mi~P&&uO#v<cO~P&$tOP$[OR#zO[<mOj<bOr<kO!Q#yO!S#{O!l#xO!p$[O#R<bO#n<_O#o<`O#p<`O#q<`O#r<aO#s<bO#t<bO#u<lO#v<cO#x<eO(aVO(y#|O(z#}O#{#mi$O#mi(r#mi!]#mi!^#mi~O#z#mi~P&)UO#z<gO~P&)UOa#|y!]#|y'z#|y'w#|y!Y#|y!k#|yv#|y!_#|y%i#|y!g#|y~P!:tO[#mij#mir#mi#R#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi$O#mi(r#mi!]#mi!^#mi~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O#n<_O#o<`O#p<`O#q<`O(aVO(y#mi(z#mi~P&,QOn>^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOr<QO!g#vO(r'pO~Ov(fX~P1qO!Q%rO~P!)[O(U!lO~P!)[O!YfX!]fX#`fX~P%2OOP]XR]X[]Xj]Xr]X!Q]X!S]X!]]X!]fX!l]X!p]X#R]X#S]X#`]X#`fX#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X~O!gfX!k]X!kfX(rfX~P'LTOP<UOQ<UOSfOd>ROe!iOpkOr<UOskOtkOzkO|<UO!O<UO!SWO!WkO!XkO!_XO!i<XO!lZO!o<UO!p<UO!q<UO!s<YO!u<]O!x!hO$W!kO$n>PO(T)]O(VTO(YUO(aVO(o[O~O!]<iO!^$qa~Oh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O<tO!S${O!_$|O!i>WO!l$xO#j<zO$W%`O$t<vO$v<xO$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Ol)dO~P(!yOr!eX(r!eX~P#!iOr(jX(r(jX~P##[O!^]X!^fX~P'LTO!YfX!Y$zX!]fX!]$zX#`fX~P!0SO#k<^O~O!g#vO#k<^O~O#`<nO~Oj<bO~O#`=OO!](wX!^(wX~O#`<nO!](uX!^(uX~O#k=PO~Og=RO~P!1WO#k=XO~O#k=YO~Og=RO(T&ZO~O!g#vO#k=ZO~O!g#vO#k=PO~O$O=[O~P#BwO#k=]O~O#k=^O~O#k=cO~O#k=dO~O#k=eO~O#k=fO~O$O=gO~P!1WO$O=hO~P!1WOl=sO~P7eOk#S#T#U#W#X#[#i#j#u$n$t$v$y%]%^%h%i%j%q%s%v%w%y%{~(OT#o!X'|(U#ps#n#qr!Q'}$]'}(T$_(e~",
    goto: "$9Y)]PPPPPP)^PP)aP)rP+W/]PPPP6mPP7TPP=QPPP@tPA^PA^PPPA^PCfPA^PA^PA^PCjPCoPD^PIWPPPI[PPPPI[L_PPPLeMVPI[PI[PP! eI[PPPI[PI[P!#lI[P!'S!(X!(bP!)U!)Y!)U!,gPPPPPPP!-W!(XPP!-h!/YP!2iI[I[!2n!5z!:h!:h!>gPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#<e#<k#<n)aP#<q)aP#<z#<z#<zP)aP)aP)aP)aPP)aP#=Q#=TP#=T)aP#=XP#=[P)aP)aP)aP)aP)aP)a)aPP#=b#=h#=s#=y#>P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{<Y%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_S#q]<V!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SU+P%]<s<tQ+t&PQ,f&gQ,m&oQ0x+gQ0}+iQ1Y+uQ2R,kQ3`.gQ5`0|Q5f1TQ6[1zQ7Y3dQ8`5gR9e7['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;k<l<m<o<p<q<r<u<v<w<x<y<z=S=T=U=V=X=Y=]=^=_=`=a=b=c=d=g=h>P>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>R>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k<o<q<u<w<y=S=U=X=]=_=a=c=g>]>^o>U<l<m<p<r<v<x<z=T=V=Y=^=`=b=d=hW%Ti%V*y>PS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;k<l<m<o<p<q<r<u<v<w<x<y<z=S=T=U=V=X=Y=]=^=_=`=a=b=c=d=g=h>P>X>Y>]>^T)z$u){V+P%]<s<tW'[!e%i*Z-`S(}#y#zQ+c%rQ+y&SS.b(m(nQ1j,XQ5T0kR8i5u'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`<W=vT#TV#U'RkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`<W=vS(o#p'iQ)P#zS+b%q.|S.c(n(pR3^.d'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SS#q]<VQ&t!XQ&u!YQ&w![Q&x!]R2Z,vQ'a!hQ+e%wQ-h'cS.e(q+hQ2x-gW3b.h.i0w0yQ6w2yW7U3_3a3e5^U9a7V7X7ZU:q9c9d9fS;b:p:sQ;p;cR;x;qU!wQ'`-eT5y1o5{!Q_OXZ`st!V!Z#d#h%e%m&i&k&r&t&u&w(j,s,x.[2[2_]!pQ!r'`-e1o5{T#q]<V%^{OPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_S(}#y#zS.b(m(n!s=l$Z$n'X)s-U-X/V2p4T5w6s:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uS<P;|;}R<S<QQ#wbQ's!uS(e#g2US(g#m+WQ+Y%fQ+j%xQ+p&OU-r'k't'wQ.W(fU/r*]*`/wQ0S*jQ0V*lQ1O+kQ1u,aS3R-s-vQ3Z.`S4e/s/tQ4n0PS4q0R0^Q4u0WQ6W1vQ7P3US7q4`4bQ7u4fU7|4r4x4{Q8P4wQ8v6XS9q7r7sQ9u7yQ9}8RQ:O8SQ:c8wQ:y9rS:z9v9xQ;S:QQ;^:dS;f:{;PS;r;g;hS;z;s;uS<O;{;}Q<R<PQ<T<SQ=o=jQ={=tR=|=uV!wQ'`-e%^aOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_S#wz!j!r=i$Z$n'X)s-U-X/V2p4T5w6s:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:o<W!P<d)^)q-Z.|2k2n3p3y3z4P4X6u7b7k7l8k9X9g9m9n;W;`=v!f$Vc#Y%q(S(Y(t(y)W)X)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:o<W!T<f)^)q-Z.|2k2n3p3v3w3y3z4P4X6u7b7k7l8k9X9g9m9n;W;`=v!^$Zc#Y%q(S(Y(t(y)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:o<WQ4_/kz>S)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>SS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>ST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>ST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:m<U<X<Y<]<^<_<`<a<b<c<d<e<f<g<h<i<k<n<{=O=P=R=Z=[=e=f>S#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k<o<q<u<w<y=S=U=X=]=_=a=c=g>]>^Q+T%aQ/c*Oo4O<l<m<p<r<v<x<z=T=V=Y=^=`=b=d=h!U$yi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k<o<q<u<w<y=S=U=X=]=_=a=c=g>]>^n=r<l<m<p<r<v<x<z=T=V=Y=^=`=b=d=hQ=w>TQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k<o<q<u<w<y=S=U=X=]=_=a=c=g>]>^o4O<l<m<p<r<v<x<z=T=V=Y=^=`=b=d=hnoOXst!Z#d%m&r&t&u&w,s,x2[2_S*f${*YQ-R'OQ-S'QR4i/y%[%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;k<l<m<o<p<q<r<u<v<w<x<y<z=S=T=U=V=X=Y=]=^=_=`=a=b=c=d=g=h>P>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f<o#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k<o<q<u<w<y=S=U=X=]=_=a=c=g>]>^n<p<l<m<p<r<v<x<z=T=V=Y=^=`=b=d=h!d=S(u)c*[*e.j.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f<q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k<o<q<u<w<y=S=U=X=]=_=a=c=g>]>^n<r<l<m<p<r<v<x<z=T=V=Y=^=`=b=d=h!h=U(u)c*[*e.k.l.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|<jQ-|<WR<j)qQ/q*]W4c/q4d7t9sU4d/r/s/tS7t4e4fR9s7u$e*Q$v(u)c)e*[*e*t*u+Q+R+V.l.m.o.p.q/_/g/i/k/v/|0d0e0v1e3f3g3h3}4R4[4g4h4l4|5O5R5S5W5r7]7^7_7`7e7f7h7i7j7p7w7z8U8X8Z9h9i9j9t9|:R:S:t:u:v:w:x:};R;e;j;v;y=p=}>O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.l<oQ.m<qQ.o<uQ.p<wQ.q<yQ/_)yQ/g*RQ/i*TQ/k*VQ/v*aS/|*g/mQ0d*wQ0e*xl0v+f,V.f1i1q3c6S7W8q9b:`:r;[;dQ1e,SQ3f=SQ3g=UQ3h=XS3}<l<mQ4R/PS4[/d4^Q4g/xQ4h/yQ4l/{Q4|0`Q5O0bQ5R0iQ5S0jQ5W0oQ5r1fQ7]=]Q7^=_Q7_=aQ7`=cQ7e<pQ7f<rQ7h<vQ7i<xQ7j<zQ7p4_Q7w4jQ7z4oQ8U5QQ8X5[Q8Z5_Q9h=YQ9i=TQ9j=VQ9t7vQ9|8QQ:R8VQ:S8[Q:t=^Q:u=`Q:v=bQ:w=dQ:x9pQ:}9yQ;R:PQ;e=gQ;j;QQ;v;kQ;y=hQ=p>PQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.n<sR7g<tnpOXst!Z#d%m&r&t&u&w,s,x2[2_Q!fPS#fZ#oQ&|!`W'h!o*i0]4zQ(P#SQ)Q#{Q)r$nS,l&k&nQ,q&oQ-O&{S-T'T/nQ-g'bQ.x)OQ/[)sQ0s+]Q0y+gQ2W,pQ2y-iQ3a.gQ4W/VQ5U0lQ6Q1rQ6c2SQ6d2TQ6h2VQ6j2XQ6o2aQ7Z3dQ7m4TQ8s6TQ9P6eQ9Q6fQ9S6iQ9f7[Q:a8tR:k9T#[cOPXZst!Z!`!o#d#o#{%m&k&n&o&r&t&u&w&{'T'b)O*i+]+g,p,s,x-i.g/n0]0l1r2S2T2V2X2[2_2a3d4z6T6e6f6i7[8t9TQ#YWQ#eYQ%quQ%svS%uw!gS(S#W(VQ(Y#ZQ(t#uQ(y#xQ)R$OQ)S$PQ)T$QQ)U$RQ)V$SQ)W$TQ)X$UQ)Y$VQ)Z$WQ)[$XQ)^$ZQ)`$_Q)b$aQ)g$eW)q$n)s/V4TQ+d%tQ+x&RS-Z'X2pQ-x'rS-}(T.PQ.S(]Q.U(dQ.s(xQ.v(zQ.z<UQ.|<XQ.}<YQ/O<]Q/b)}Q0p+XQ2k-UQ2n-XQ3O-qQ3V.VQ3k.tQ3p<^Q3q<_Q3r<`Q3s<aQ3t<bQ3u<cQ3v<dQ3w<eQ3x<fQ3y<gQ3z<hQ3{.{Q3|<kQ4P<nQ4Q<{Q4X<iQ5X0rQ5c1SQ6u=OQ6{3QQ7Q3WQ7a3lQ7b=PQ7k=RQ7l=ZQ8k5wQ9X6sQ9]6|Q9g=[Q9m=eQ9n=fQ:o9_Q;W:ZQ;`:mQ<W#SR=v>SR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i<VR)f$dY!uQ'`-e1o5{Q'k!rS'u!v!yS'w!z5}S-t'l'mQ-v'nR3T-uT#kZ%eS#jZ%eS%km,oU(g#h#i#lS.Y(h(iQ.^(jQ0t+^Q3Y.ZU3Z.[.]._S7S3[3]R9`7Td#^W#W#Z%h(T(^*Y+Z.T/mr#gZm#h#i#l%e(h(i(j+^.Z.[.]._3[3]7TS*]$x*bQ/t*^Q2U,oQ2l-VQ4`/pQ6q2dQ7s4aQ9W6rT=m'X+[V#aW%h*YU#`W%h*YS(U#W(^U(Z#Z+Z/mS-['X+[T.O(T.TV'^!e%i*ZQ$lfR)x$qT)m$l)nR4V/UT*_$x*bT*h${*YQ0w+fQ1g,VQ3_.fQ5t1iQ6P1qQ7X3cQ8r6SQ9c7WQ:^8qQ:p9bQ;Z:`Q;c:rQ;n;[R;q;dnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&l!VR,h&itmOXst!U!V!Z#d%m&i&r&t&u&w,s,x2[2_R,o&oT%lm,oR1k,XR,g&gQ&U|S+}&V&WR1^,OR+s&PT&p!W&sT&q!W&sT2^,x2_",
    nodeNames: "\u26A0 ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",
    maxTerm: 380,
    context: uet,
    nodeProps: [
      [
        "isolate",
        -8,
        5,
        6,
        14,
        37,
        39,
        51,
        53,
        55,
        ""
      ],
      [
        "group",
        -26,
        9,
        17,
        19,
        68,
        207,
        211,
        215,
        216,
        218,
        221,
        224,
        234,
        237,
        243,
        245,
        247,
        249,
        252,
        258,
        264,
        266,
        268,
        270,
        272,
        274,
        275,
        "Statement",
        -34,
        13,
        14,
        32,
        35,
        36,
        42,
        51,
        54,
        55,
        57,
        62,
        70,
        72,
        76,
        80,
        82,
        84,
        85,
        110,
        111,
        120,
        121,
        136,
        139,
        141,
        142,
        143,
        144,
        145,
        147,
        148,
        167,
        169,
        171,
        "Expression",
        -23,
        31,
        33,
        37,
        41,
        43,
        45,
        173,
        175,
        177,
        178,
        180,
        181,
        182,
        184,
        185,
        186,
        188,
        189,
        190,
        201,
        203,
        205,
        206,
        "Type",
        -3,
        88,
        103,
        109,
        "ClassItem"
      ],
      [
        "openedBy",
        23,
        "<",
        38,
        "InterpolationStart",
        56,
        "[",
        60,
        "{",
        73,
        "(",
        160,
        "JSXStartCloseTag"
      ],
      [
        "closedBy",
        -2,
        24,
        168,
        ">",
        40,
        "InterpolationEnd",
        50,
        "]",
        61,
        "}",
        74,
        ")",
        165,
        "JSXEndTag"
      ]
    ],
    propSources: [
      met
    ],
    skippedNodes: [
      0,
      5,
      6,
      278
    ],
    repeatNodeCount: 37,
    tokenData: "$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$<r#p#q$=h#q#r$>x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr<Srs&}st%ZtuCruw%Zwx(rx!^%Z!^!_*g!_!c%Z!c!}Cr!}#O%Z#O#P&c#P#R%Z#R#SCr#S#T%Z#T#oCr#o#p*g#p$g%Z$g;'SCr;'S;=`El<%lOCr(r<__WS$i&j(Wp(Z!bOY<SYZ&cZr<Srs=^sw<Swx@nx!^<S!^!_Bm!_#O<S#O#P>`#P#o<S#o#pBm#p;'S<S;'S;=`Cl<%lO<S(Q=g]WS$i&j(Z!bOY=^YZ&cZw=^wx>`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l<S%9[C}i$i&j(o%1l(Wp(Z!bOY%ZYZ&cZr%Zrs&}st%ZtuCruw%Zwx(rx!Q%Z!Q![Cr![!^%Z!^!_*g!_!c%Z!c!}Cr!}#O%Z#O#P&c#P#R%Z#R#SCr#S#T%Z#T#oCr#o#p*g#p$g%Z$g;'SCr;'S;=`El<%lOCr%9[EoP;=`<%lCr07[FRk$i&j(Wp(Z!b$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr+dHRk$i&j(Wp(Z!b$]#tOY%ZYZ&cZr%Zrs&}st%ZtuGvuw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Gv![!^%Z!^!_*g!_!c%Z!c!}Gv!}#O%Z#O#P&c#P#R%Z#R#SGv#S#T%Z#T#oGv#o#p*g#p$g%Z$g;'SGv;'S;=`Iv<%lOGv+dIyP;=`<%lGv07[JPP;=`<%lEr(KWJ_`$i&j(Wp(Z!b#p(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KWKl_$i&j$Q(Ch(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z,#xLva(z+JY$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sv%ZvwM{wx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KWNW`$i&j#z(Ch(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At! c_(Y';W$i&j(WpOY!!bYZ!#hZr!!brs!#hsw!!bwx!$xx!^!!b!^!_!%z!_#O!!b#O#P!#h#P#o!!b#o#p!%z#p;'S!!b;'S;=`!'c<%lO!!b'l!!i_$i&j(WpOY!!bYZ!#hZr!!brs!#hsw!!bwx!$xx!^!!b!^!_!%z!_#O!!b#O#P!#h#P#o!!b#o#p!%z#p;'S!!b;'S;=`!'c<%lO!!b&z!#mX$i&jOw!#hwx6cx!^!#h!^!_!$Y!_#o!#h#o#p!$Y#p;'S!#h;'S;=`!$r<%lO!#h`!$]TOw!$Ywx7]x;'S!$Y;'S;=`!$l<%lO!$Y`!$oP;=`<%l!$Y&z!$uP;=`<%l!#h'l!%R]$d`$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(r!Q!&PZ(WpOY!%zYZ!$YZr!%zrs!$Ysw!%zwx!&rx#O!%z#O#P!$Y#P;'S!%z;'S;=`!']<%lO!%z!Q!&yU$d`(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)r!Q!'`P;=`<%l!%z'l!'fP;=`<%l!!b/5|!'t_!l/.^$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#&U!)O_!k!Lf$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z-!n!*[b$i&j(Wp(Z!b(U%&f#q(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rxz%Zz{!+d{!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW!+o`$i&j(Wp(Z!b#n(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z+;x!,|`$i&j(Wp(Z!br+4YOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z,$U!.Z_!]+Jf$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[!/ec$i&j(Wp(Z!b!Q.2^OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!0p!P!Q%Z!Q![!3Y![!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#%|!0ya$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!2O!P!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#%|!2Z_![!L^$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!3eg$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!3Y![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S!3Y#S#X%Z#X#Y!4|#Y#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!5Vg$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx{%Z{|!6n|}%Z}!O!6n!O!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!6wc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!8_c$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[!9uf$i&j(Wp(Z!b#o(ChOY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcxz!;Zz{#-}{!P!;Z!P!Q#/d!Q!^!;Z!^!_#(i!_!`#7S!`!a#8i!a!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z?O!;fb$i&j(Wp(Z!b!X7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z>^!<w`$i&j(Z!b!X7`OY!<nYZ&cZw!<nwx!=yx!P!<n!P!Q!Eq!Q!^!<n!^!_!Gr!_!}!<n!}#O!KS#O#P!Dy#P#o!<n#o#p!Gr#p;'S!<n;'S;=`!L]<%lO!<n<z!>Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y<z!?Td$i&j!X7`O!^&c!_#W&c#W#X!>|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c<z!C][$i&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#O!CW#O#P!DR#P#Q!=y#Q#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW<z!DWX$i&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW<z!DvP;=`<%l!CW<z!EOX$i&jOY!=yYZ&cZ!^!=y!^!_!@c!_#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y<z!EnP;=`<%l!=y>^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!<n#Q#o!KS#o#p!JU#p;'S!KS;'S;=`!LV<%lO!KS>^!LYP;=`<%l!KS>^!L`P;=`<%l!<n=l!Ll`$i&j(Wp!X7`OY!LcYZ&cZr!Lcrs!=ys!P!Lc!P!Q!Mn!Q!^!Lc!^!_# o!_!}!Lc!}#O#%P#O#P!Dy#P#o!Lc#o#p# o#p;'S!Lc;'S;=`#&Y<%lO!Lc=l!Mwl$i&j(Wp!X7`OY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#W(r#W#X!Mn#X#Z(r#Z#[!Mn#[#](r#]#^!Mn#^#a(r#a#b!Mn#b#g(r#g#h!Mn#h#i(r#i#j!Mn#j#k!Mn#k#m(r#m#n!Mn#n#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(r8Q# vZ(Wp!X7`OY# oZr# ors!@cs!P# o!P!Q#!i!Q!}# o!}#O#$R#O#P!Bq#P;'S# o;'S;=`#$y<%lO# o8Q#!pe(Wp!X7`OY)rZr)rs#O)r#P#W)r#W#X#!i#X#Z)r#Z#[#!i#[#])r#]#^#!i#^#a)r#a#b#!i#b#g)r#g#h#!i#h#i)r#i#j#!i#j#k#!i#k#m)r#m#n#!i#n;'S)r;'S;=`*Z<%lO)r8Q#$WX(WpOY#$RZr#$Rrs!Ars#O#$R#O#P!B[#P#Q# o#Q;'S#$R;'S;=`#$s<%lO#$R8Q#$vP;=`<%l#$R8Q#$|P;=`<%l# o=l#%W^$i&j(WpOY#%PYZ&cZr#%Prs!CWs!^#%P!^!_#$R!_#O#%P#O#P!DR#P#Q!Lc#Q#o#%P#o#p#$R#p;'S#%P;'S;=`#&S<%lO#%P=l#&VP;=`<%l#%P=l#&]P;=`<%l!Lc?O#&kn$i&j(Wp(Z!b!X7`OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#W%Z#W#X#&`#X#Z%Z#Z#[#&`#[#]%Z#]#^#&`#^#a%Z#a#b#&`#b#g%Z#g#h#&`#h#i%Z#i#j#&`#j#k#&`#k#m%Z#m#n#&`#n#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z9d#(r](Wp(Z!b!X7`OY#(iZr#(irs!Grsw#(iwx# ox!P#(i!P!Q#)k!Q!}#(i!}#O#+`#O#P!Bq#P;'S#(i;'S;=`#,`<%lO#(i9d#)th(Wp(Z!b!X7`OY*gZr*grs'}sw*gwx)rx#O*g#P#W*g#W#X#)k#X#Z*g#Z#[#)k#[#]*g#]#^#)k#^#a*g#a#b#)k#b#g*g#g#h#)k#h#i*g#i#j#)k#j#k#)k#k#m*g#m#n#)k#n;'S*g;'S;=`+Z<%lO*g9d#+gZ(Wp(Z!bOY#+`Zr#+`rs!JUsw#+`wx#$Rx#O#+`#O#P!B[#P#Q#(i#Q;'S#+`;'S;=`#,Y<%lO#+`9d#,]P;=`<%l#+`9d#,cP;=`<%l#(i?O#,o`$i&j(Wp(Z!bOY#,fYZ&cZr#,frs!KSsw#,fwx#%Px!^#,f!^!_#+`!_#O#,f#O#P!DR#P#Q!;Z#Q#o#,f#o#p#+`#p;'S#,f;'S;=`#-q<%lO#,f?O#-tP;=`<%l#,f?O#-zP;=`<%l!;Z07[#.[b$i&j(Wp(Z!b(O0/l!X7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z07[#/o_$i&j(Wp(Z!bT0/lOY#/dYZ&cZr#/drs#0nsw#/dwx#4Ox!^#/d!^!_#5}!_#O#/d#O#P#1p#P#o#/d#o#p#5}#p;'S#/d;'S;=`#6|<%lO#/d06j#0w]$i&j(Z!bT0/lOY#0nYZ&cZw#0nwx#1px!^#0n!^!_#3R!_#O#0n#O#P#1p#P#o#0n#o#p#3R#p;'S#0n;'S;=`#3x<%lO#0n05W#1wX$i&jT0/lOY#1pYZ&cZ!^#1p!^!_#2d!_#o#1p#o#p#2d#p;'S#1p;'S;=`#2{<%lO#1p0/l#2iST0/lOY#2dZ;'S#2d;'S;=`#2u<%lO#2d0/l#2xP;=`<%l#2d05W#3OP;=`<%l#1p01O#3YW(Z!bT0/lOY#3RZw#3Rwx#2dx#O#3R#O#P#2d#P;'S#3R;'S;=`#3r<%lO#3R01O#3uP;=`<%l#3R06j#3{P;=`<%l#0n05x#4X]$i&j(WpT0/lOY#4OYZ&cZr#4Ors#1ps!^#4O!^!_#5Q!_#O#4O#O#P#1p#P#o#4O#o#p#5Q#p;'S#4O;'S;=`#5w<%lO#4O00^#5XW(WpT0/lOY#5QZr#5Qrs#2ds#O#5Q#O#P#2d#P;'S#5Q;'S;=`#5q<%lO#5Q00^#5tP;=`<%l#5Q05x#5zP;=`<%l#4O01p#6WY(Wp(Z!bT0/lOY#5}Zr#5}rs#3Rsw#5}wx#5Qx#O#5}#O#P#2d#P;'S#5};'S;=`#6v<%lO#5}01p#6yP;=`<%l#5}07[#7PP;=`<%l#/d)3h#7ab$i&j$Q(Ch(Wp(Z!b!X7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;ZAt#8vb$Z#t$i&j(Wp(Z!b!X7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z'Ad#:Zp$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!3Y!P!Q%Z!Q![#<_![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S#<_#S#U%Z#U#V#?i#V#X%Z#X#Y!4|#Y#b%Z#b#c#>_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#<jk$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!3Y!P!Q%Z!Q![#<_![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S#<_#S#X%Z#X#Y!4|#Y#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-<U(Wp(Z!b$n7`OY*gZr*grs'}sw*gwx)rx!P*g!P!Q#MO!Q!^*g!^!_#Mt!_!`$ f!`#O*g#P;'S*g;'S;=`+Z<%lO*g(n#MXX$k&j(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g(El#M}Z#r(Ch(Wp(Z!bOY*gZr*grs'}sw*gwx)rx!_*g!_!`#Np!`#O*g#P;'S*g;'S;=`+Z<%lO*g(El#NyX$Q(Ch(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g(El$ oX#s(Ch(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g*)x$!ga#`*!Y$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`!a$#l!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(K[$#w_#k(Cl$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x$%Vag!*r#s(Ch$f#|$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`$&[!`!a$'f!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$&g_#s(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$'qa#r(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`!a$(v!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$)R`#r(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(Kd$*`a(r(Ct$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!a%Z!a!b$+e!b#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$+p`$i&j#{(Ch(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z%#`$,}_!|$Ip$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f$.X_!S0,v$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(n$/]Z$i&jO!^$0O!^!_$0f!_#i$0O#i#j$0k#j#l$0O#l#m$2^#m#o$0O#o#p$0f#p;'S$0O;'S;=`$4i<%lO$0O(n$0VT_#S$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c#S$0kO_#S(n$0p[$i&jO!Q&c!Q![$1f![!^&c!_!c&c!c!i$1f!i#T&c#T#Z$1f#Z#o&c#o#p$3|#p;'S&c;'S;=`&w<%lO&c(n$1kZ$i&jO!Q&c!Q![$2^![!^&c!_!c&c!c!i$2^!i#T&c#T#Z$2^#Z#o&c#p;'S&c;'S;=`&w<%lO&c(n$2cZ$i&jO!Q&c!Q![$3U![!^&c!_!c&c!c!i$3U!i#T&c#T#Z$3U#Z#o&c#p;'S&c;'S;=`&w<%lO&c(n$3ZZ$i&jO!Q&c!Q![$0O![!^&c!_!c&c!c!i$0O!i#T&c#T#Z$0O#Z#o&c#p;'S&c;'S;=`&w<%lO&c#S$4PR!Q![$4Y!c!i$4Y#T#Z$4Y#S$4]S!Q![$4Y!c!i$4Y#T#Z$4Y#q#r$0f(n$4lP;=`<%l$0O#1[$4z_!Y#)l$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$6U`#x(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z+;p$7c_$i&j(Wp(Z!b(a+4QOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$8qk$i&j(Wp(Z!b(T,2j$_#t(e$I[OY%ZYZ&cZr%Zrs&}st%Ztu$8buw%Zwx(rx}%Z}!O$:f!O!Q%Z!Q![$8b![!^%Z!^!_*g!_!c%Z!c!}$8b!}#O%Z#O#P&c#P#R%Z#R#S$8b#S#T%Z#T#o$8b#o#p*g#p$g%Z$g;'S$8b;'S;=`$<l<%lO$8b+d$:qk$i&j(Wp(Z!b$_#tOY%ZYZ&cZr%Zrs&}st%Ztu$:fuw%Zwx(rx}%Z}!O$:f!O!Q%Z!Q![$:f![!^%Z!^!_*g!_!c%Z!c!}$:f!}#O%Z#O#P&c#P#R%Z#R#S$:f#S#T%Z#T#o$:f#o#p*g#p$g%Z$g;'S$:f;'S;=`$<f<%lO$:f+d$<iP;=`<%l$:f07[$<oP;=`<%l$8b#Jf$<{X!_#Hb(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g,#x$=sa(y+JY$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p#q$+e#q;'S%Z;'S;=`+a<%lO%Z)>v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",
    tokenizers: [
      het,
      fet,
      pet,
      get,
      2,
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      10,
      11,
      12,
      13,
      14,
      det,
      new SP("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~", 141, 340),
      new SP("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~", 25, 323)
    ],
    topRules: {
      Script: [
        0,
        7
      ],
      SingleExpression: [
        1,
        276
      ],
      SingleClassItem: [
        2,
        277
      ]
    },
    dialects: {
      jsx: 0,
      ts: 15175
    },
    dynamicPrecedences: {
      80: 1,
      82: 1,
      94: 1,
      169: 1,
      199: 1
    },
    specialized: [
      {
        term: 327,
        get: (t) => yet[t] || -1
      },
      {
        term: 343,
        get: (t) => vet[t] || -1
      },
      {
        term: 95,
        get: (t) => Oet[t] || -1
      }
    ],
    tokenPrec: 15201
  }), qj = [
    is("function ${name}(${params}) {\n	${}\n}", {
      label: "function",
      detail: "definition",
      type: "keyword"
    }),
    is("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n	${}\n}", {
      label: "for",
      detail: "loop",
      type: "keyword"
    }),
    is("for (let ${name} of ${collection}) {\n	${}\n}", {
      label: "for",
      detail: "of loop",
      type: "keyword"
    }),
    is("do {\n	${}\n} while (${})", {
      label: "do",
      detail: "loop",
      type: "keyword"
    }),
    is("while (${}) {\n	${}\n}", {
      label: "while",
      detail: "loop",
      type: "keyword"
    }),
    is(`try {
	\${}
} catch (\${error}) {
	\${}
}`, {
      label: "try",
      detail: "/ catch block",
      type: "keyword"
    }),
    is("if (${}) {\n	${}\n}", {
      label: "if",
      detail: "block",
      type: "keyword"
    }),
    is(`if (\${}) {
	\${}
} else {
	\${}
}`, {
      label: "if",
      detail: "/ else block",
      type: "keyword"
    }),
    is(`class \${name} {
	constructor(\${params}) {
		\${}
	}
}`, {
      label: "class",
      detail: "definition",
      type: "keyword"
    }),
    is('import {${names}} from "${module}"\n${}', {
      label: "import",
      detail: "named",
      type: "keyword"
    }),
    is('import ${name} from "${module}"\n${}', {
      label: "import",
      detail: "default",
      type: "keyword"
    })
  ], qae = qj.concat([
    is("interface ${name} {\n	${}\n}", {
      label: "interface",
      detail: "definition",
      type: "keyword"
    }),
    is("type ${name} = ${type}", {
      label: "type",
      detail: "definition",
      type: "keyword"
    }),
    is("enum ${name} {\n	${}\n}", {
      label: "enum",
      detail: "definition",
      type: "keyword"
    })
  ]), TV = new Loe(), Kae = /* @__PURE__ */ new Set([
    "Script",
    "Block",
    "FunctionExpression",
    "FunctionDeclaration",
    "ArrowFunction",
    "MethodDeclaration",
    "ForStatement"
  ]);
  function l0(t) {
    return (e, n) => {
      let r = e.node.getChild("VariableDefinition");
      return r && n(r, t), true;
    };
  }
  const xet = [
    "FunctionDeclaration"
  ], bet = {
    FunctionDeclaration: l0("function"),
    ClassDeclaration: l0("class"),
    ClassExpression: () => true,
    EnumDeclaration: l0("constant"),
    TypeAliasDeclaration: l0("type"),
    NamespaceDeclaration: l0("namespace"),
    VariableDefinition(t, e) {
      t.matchContext(xet) || e(t, "variable");
    },
    TypeDefinition(t, e) {
      e(t, "type");
    },
    __proto__: null
  };
  function Jae(t, e) {
    let n = TV.get(e);
    if (n)
      return n;
    let r = [], i = true;
    function s(o, a) {
      let l = t.sliceString(o.from, o.to);
      r.push({
        label: l,
        type: a
      });
    }
    return e.cursor(dn.IncludeAnonymous).iterate((o) => {
      if (i)
        i = false;
      else if (o.name) {
        let a = bet[o.name];
        if (a && a(o, s) || Kae.has(o.name))
          return false;
      } else if (o.to - o.from > 8192) {
        for (let a of Jae(t, o.node))
          r.push(a);
        return false;
      }
    }), TV.set(e, r), r;
  }
  const xP = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/, Kj = [
    "TemplateString",
    "String",
    "RegExp",
    "LineComment",
    "BlockComment",
    "VariableDefinition",
    "TypeDefinition",
    "Label",
    "PropertyDefinition",
    "PropertyName",
    "PrivatePropertyDefinition",
    "PrivatePropertyName",
    "JSXText",
    "JSXAttributeValue",
    "JSXOpenTag",
    "JSXCloseTag",
    "JSXSelfClosingTag",
    ".",
    "?."
  ];
  function ele(t) {
    let e = Un(t.state).resolveInner(t.pos, -1);
    if (Kj.indexOf(e.name) > -1)
      return null;
    let n = e.name == "VariableName" || e.to - e.from < 20 && xP.test(t.state.sliceDoc(e.from, e.to));
    if (!n && !t.explicit)
      return null;
    let r = [];
    for (let i = e; i; i = i.parent)
      Kae.has(i.name) && (r = r.concat(Jae(t.state.doc, i)));
    return {
      options: r,
      from: n ? e.from : t.pos,
      validFor: xP
    };
  }
  function v$(t, e, n) {
    var r;
    let i = [];
    for (; ; ) {
      let s = e.firstChild, o;
      if ((s == null ? void 0 : s.name) == "VariableName")
        return i.push(t(s)), {
          path: i.reverse(),
          name: n
        };
      if ((s == null ? void 0 : s.name) == "MemberExpression" && ((r = o = s.lastChild) === null || r === void 0 ? void 0 : r.name) == "PropertyName")
        i.push(t(o)), e = s;
      else
        return null;
    }
  }
  function tle(t) {
    let e = (r) => t.state.doc.sliceString(r.from, r.to), n = Un(t.state).resolveInner(t.pos, -1);
    return n.name == "PropertyName" ? v$(e, n.parent, e(n)) : (n.name == "." || n.name == "?.") && n.parent.name == "MemberExpression" ? v$(e, n.parent, "") : Kj.indexOf(n.name) > -1 ? null : n.name == "VariableName" || n.to - n.from < 20 && xP.test(e(n)) ? {
      path: [],
      name: e(n)
    } : n.name == "MemberExpression" ? v$(e, n, "") : t.explicit ? {
      path: [],
      name: ""
    } : null;
  }
  function ket(t, e) {
    let n = [], r = /* @__PURE__ */ new Set();
    for (let i = 0; ; i++) {
      for (let o of (Object.getOwnPropertyNames || Object.keys)(t)) {
        if (!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(o) || r.has(o))
          continue;
        r.add(o);
        let a;
        try {
          a = t[o];
        } catch {
          continue;
        }
        n.push({
          label: o,
          type: typeof a == "function" ? /^[A-Z]/.test(o) ? "class" : e ? "function" : "method" : e ? "variable" : "property",
          boost: -i
        });
      }
      let s = Object.getPrototypeOf(t);
      if (!s)
        return n;
      t = s;
    }
  }
  function Pet(t) {
    let e = /* @__PURE__ */ new Map();
    return (n) => {
      let r = tle(n);
      if (!r)
        return null;
      let i = t;
      for (let o of r.path)
        if (i = i[o], !i)
          return null;
      let s = e.get(i);
      return s || e.set(i, s = ket(i, !r.path.length)), {
        from: n.pos - r.name.length,
        options: s,
        validFor: xP
      };
    };
  }
  let nle, Jj, eN, tN;
  qo = om.define({
    name: "javascript",
    parser: wet.configure({
      props: [
        Bm.add({
          IfStatement: yb({
            except: /^\s*({|else\b)/
          }),
          TryStatement: yb({
            except: /^\s*({|catch\b|finally\b)/
          }),
          LabeledStatement: eqe,
          SwitchBody: (t) => {
            let e = t.textAfter, n = /^\s*\}/.test(e), r = /^\s*(case|default)\b/.test(e);
            return t.baseIndent + (n ? 0 : r ? 1 : 2) * t.unit;
          },
          Block: JGe({
            closing: "}"
          }),
          ArrowFunction: (t) => t.baseIndent + t.unit,
          "TemplateString BlockComment": () => null,
          "Statement Property": yb({
            except: /^\s*{/
          }),
          JSXElement(t) {
            let e = /^\s*<\//.test(t.textAfter);
            return t.lineIndent(t.node.from) + (e ? 0 : t.unit);
          },
          JSXEscape(t) {
            let e = /\s*\}/.test(t.textAfter);
            return t.lineIndent(t.node.from) + (e ? 0 : t.unit);
          },
          "JSXOpenTag JSXSelfClosingTag"(t) {
            return t.column(t.node.from) + t.unit;
          }
        }),
        Um.add({
          "Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": Xoe,
          BlockComment(t) {
            return {
              from: t.from + 2,
              to: t.to - 2
            };
          }
        })
      ]
    }),
    languageData: {
      closeBrackets: {
        brackets: [
          "(",
          "[",
          "{",
          "'",
          '"',
          "`"
        ]
      },
      commentTokens: {
        line: "//",
        block: {
          open: "/*",
          close: "*/"
        }
      },
      indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
      wordChars: "$"
    }
  });
  nle = {
    test: (t) => /^JSX/.test(t.name),
    facet: A2({
      commentTokens: {
        block: {
          open: "{/*",
          close: "*/}"
        }
      }
    })
  };
  Jj = qo.configure({
    dialect: "ts"
  }, "typescript");
  eN = qo.configure({
    dialect: "jsx",
    props: [
      Rj.add((t) => t.isTop ? [
        nle
      ] : void 0)
    ]
  });
  tN = qo.configure({
    dialect: "jsx ts",
    props: [
      Rj.add((t) => t.isTop ? [
        nle
      ] : void 0)
    ]
  }, "typescript");
  let rle = (t) => ({
    label: t,
    type: "keyword"
  });
  const ile = "break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(rle), Cet = ile.concat([
    "declare",
    "implements",
    "private",
    "protected",
    "public"
  ].map(rle));
  function sle(t = {}) {
    let e = t.jsx ? t.typescript ? tN : eN : t.typescript ? Jj : qo, n = t.typescript ? qae.concat(Cet) : qj.concat(ile);
    return new cm(e, [
      qo.data.of({
        autocomplete: Eqe(Kj, Tqe(n))
      }),
      qo.data.of({
        autocomplete: ele
      }),
      t.jsx ? ole : []
    ]);
  }
  function _et(t) {
    for (; ; ) {
      if (t.name == "JSXOpenTag" || t.name == "JSXSelfClosingTag" || t.name == "JSXFragmentTag")
        return t;
      if (t.name == "JSXEscape" || !t.parent)
        return null;
      t = t.parent;
    }
  }
  function EV(t, e, n = t.length) {
    for (let r = e == null ? void 0 : e.firstChild; r; r = r.nextSibling)
      if (r.name == "JSXIdentifier" || r.name == "JSXBuiltin" || r.name == "JSXNamespacedName" || r.name == "JSXMemberExpression")
        return t.sliceString(r.from, Math.min(r.to, n));
    return "";
  }
  const Tet = typeof navigator == "object" && /Android\b/.test(navigator.userAgent), ole = Re.inputHandler.of((t, e, n, r, i) => {
    if ((Tet ? t.composing : t.compositionStarted) || t.state.readOnly || e != n || r != ">" && r != "/" || !qo.isActiveAt(t.state, e, -1))
      return false;
    let s = i(), { state: o } = s, a = o.changeByRange((l) => {
      var c;
      let { head: u } = l, d = Un(o).resolveInner(u - 1, -1), h;
      if (d.name == "JSXStartTag" && (d = d.parent), !(o.doc.sliceString(u - 1, u) != r || d.name == "JSXAttributeValue" && d.to > u)) {
        if (r == ">" && d.name == "JSXFragmentTag")
          return {
            range: l,
            changes: {
              from: u,
              insert: "</>"
            }
          };
        if (r == "/" && d.name == "JSXStartCloseTag") {
          let f = d.parent, y = f.parent;
          if (y && f.from == u - 2 && ((h = EV(o.doc, y.firstChild, u)) || ((c = y.firstChild) === null || c === void 0 ? void 0 : c.name) == "JSXFragmentTag")) {
            let g = `${h}>`;
            return {
              range: Ve.cursor(u + g.length, -1),
              changes: {
                from: u,
                insert: g
              }
            };
          }
        } else if (r == ">") {
          let f = _et(d);
          if (f && f.name == "JSXOpenTag" && !/^\/?>|^<\//.test(o.doc.sliceString(u, u + 2)) && (h = EV(o.doc, f, u)))
            return {
              range: l,
              changes: {
                from: u,
                insert: `</${h}>`
              }
            };
        }
      }
      return {
        range: l
      };
    });
    return a.changes.empty ? false : (t.dispatch([
      s,
      o.update(a, {
        userEvent: "input.complete",
        scrollIntoView: true
      })
    ]), true);
  });
  function Eet(t, e) {
    return e || (e = {
      parserOptions: {
        ecmaVersion: 2019,
        sourceType: "module"
      },
      env: {
        browser: true,
        node: true,
        es6: true,
        es2015: true,
        es2017: true,
        es2020: true
      },
      rules: {}
    }, t.getRules().forEach((n, r) => {
      var i;
      !((i = n.meta.docs) === null || i === void 0) && i.recommended && (e.rules[r] = 2);
    })), (n) => {
      let { state: r } = n, i = [];
      for (let { from: s, to: o } of qo.findRegions(r)) {
        let a = r.doc.lineAt(s), l = {
          line: a.number - 1,
          col: s - a.from,
          pos: s
        };
        for (let c of t.verify(r.sliceDoc(s, o), e))
          i.push(Iet(c, r.doc, l));
      }
      return i;
    };
  }
  function IV(t, e, n, r) {
    return n.line(t + r.line).from + e + (t == 1 ? r.col - 1 : -1);
  }
  function Iet(t, e, n) {
    let r = IV(t.line, t.column, e, n), i = {
      from: r,
      to: t.endLine != null && t.endColumn != 1 ? IV(t.endLine, t.endColumn, e, n) : r,
      message: t.message,
      source: t.ruleId ? "eslint:" + t.ruleId : "eslint",
      severity: t.severity == 1 ? "warning" : "error"
    };
    if (t.fix) {
      let { range: s, text: o } = t.fix, a = s[0] + n.pos - r, l = s[1] + n.pos - r;
      i.actions = [
        {
          name: "fix",
          apply(c, u) {
            c.dispatch({
              changes: {
                from: u + a,
                to: u + l,
                insert: o
              },
              scrollIntoView: true
            });
          }
        }
      ];
    }
    return i;
  }
  const gx = Object.freeze(Object.defineProperty({
    __proto__: null,
    autoCloseTags: ole,
    completionPath: tle,
    esLint: Eet,
    javascript: sle,
    javascriptLanguage: qo,
    jsxLanguage: eN,
    localCompletionSource: ele,
    scopeCompletionSource: Pet,
    snippets: qj,
    tsxLanguage: tN,
    typescriptLanguage: Jj,
    typescriptSnippets: qae
  }, Symbol.toStringTag, {
    value: "Module"
  })), c0 = [
    "_blank",
    "_self",
    "_top",
    "_parent"
  ], O$ = [
    "ascii",
    "utf-8",
    "utf-16",
    "latin1",
    "latin1"
  ], S$ = [
    "get",
    "post",
    "put",
    "delete"
  ], w$ = [
    "application/x-www-form-urlencoded",
    "multipart/form-data",
    "text/plain"
  ], Ls = [
    "true",
    "false"
  ], Fe = {}, $et = {
    a: {
      attrs: {
        href: null,
        ping: null,
        type: null,
        media: null,
        target: c0,
        hreflang: null
      }
    },
    abbr: Fe,
    address: Fe,
    area: {
      attrs: {
        alt: null,
        coords: null,
        href: null,
        target: null,
        ping: null,
        media: null,
        hreflang: null,
        type: null,
        shape: [
          "default",
          "rect",
          "circle",
          "poly"
        ]
      }
    },
    article: Fe,
    aside: Fe,
    audio: {
      attrs: {
        src: null,
        mediagroup: null,
        crossorigin: [
          "anonymous",
          "use-credentials"
        ],
        preload: [
          "none",
          "metadata",
          "auto"
        ],
        autoplay: [
          "autoplay"
        ],
        loop: [
          "loop"
        ],
        controls: [
          "controls"
        ]
      }
    },
    b: Fe,
    base: {
      attrs: {
        href: null,
        target: c0
      }
    },
    bdi: Fe,
    bdo: Fe,
    blockquote: {
      attrs: {
        cite: null
      }
    },
    body: Fe,
    br: Fe,
    button: {
      attrs: {
        form: null,
        formaction: null,
        name: null,
        value: null,
        autofocus: [
          "autofocus"
        ],
        disabled: [
          "autofocus"
        ],
        formenctype: w$,
        formmethod: S$,
        formnovalidate: [
          "novalidate"
        ],
        formtarget: c0,
        type: [
          "submit",
          "reset",
          "button"
        ]
      }
    },
    canvas: {
      attrs: {
        width: null,
        height: null
      }
    },
    caption: Fe,
    center: Fe,
    cite: Fe,
    code: Fe,
    col: {
      attrs: {
        span: null
      }
    },
    colgroup: {
      attrs: {
        span: null
      }
    },
    command: {
      attrs: {
        type: [
          "command",
          "checkbox",
          "radio"
        ],
        label: null,
        icon: null,
        radiogroup: null,
        command: null,
        title: null,
        disabled: [
          "disabled"
        ],
        checked: [
          "checked"
        ]
      }
    },
    data: {
      attrs: {
        value: null
      }
    },
    datagrid: {
      attrs: {
        disabled: [
          "disabled"
        ],
        multiple: [
          "multiple"
        ]
      }
    },
    datalist: {
      attrs: {
        data: null
      }
    },
    dd: Fe,
    del: {
      attrs: {
        cite: null,
        datetime: null
      }
    },
    details: {
      attrs: {
        open: [
          "open"
        ]
      }
    },
    dfn: Fe,
    div: Fe,
    dl: Fe,
    dt: Fe,
    em: Fe,
    embed: {
      attrs: {
        src: null,
        type: null,
        width: null,
        height: null
      }
    },
    eventsource: {
      attrs: {
        src: null
      }
    },
    fieldset: {
      attrs: {
        disabled: [
          "disabled"
        ],
        form: null,
        name: null
      }
    },
    figcaption: Fe,
    figure: Fe,
    footer: Fe,
    form: {
      attrs: {
        action: null,
        name: null,
        "accept-charset": O$,
        autocomplete: [
          "on",
          "off"
        ],
        enctype: w$,
        method: S$,
        novalidate: [
          "novalidate"
        ],
        target: c0
      }
    },
    h1: Fe,
    h2: Fe,
    h3: Fe,
    h4: Fe,
    h5: Fe,
    h6: Fe,
    head: {
      children: [
        "title",
        "base",
        "link",
        "style",
        "meta",
        "script",
        "noscript",
        "command"
      ]
    },
    header: Fe,
    hgroup: Fe,
    hr: Fe,
    html: {
      attrs: {
        manifest: null
      }
    },
    i: Fe,
    iframe: {
      attrs: {
        src: null,
        srcdoc: null,
        name: null,
        width: null,
        height: null,
        sandbox: [
          "allow-top-navigation",
          "allow-same-origin",
          "allow-forms",
          "allow-scripts"
        ],
        seamless: [
          "seamless"
        ]
      }
    },
    img: {
      attrs: {
        alt: null,
        src: null,
        ismap: null,
        usemap: null,
        width: null,
        height: null,
        crossorigin: [
          "anonymous",
          "use-credentials"
        ]
      }
    },
    input: {
      attrs: {
        alt: null,
        dirname: null,
        form: null,
        formaction: null,
        height: null,
        list: null,
        max: null,
        maxlength: null,
        min: null,
        name: null,
        pattern: null,
        placeholder: null,
        size: null,
        src: null,
        step: null,
        value: null,
        width: null,
        accept: [
          "audio/*",
          "video/*",
          "image/*"
        ],
        autocomplete: [
          "on",
          "off"
        ],
        autofocus: [
          "autofocus"
        ],
        checked: [
          "checked"
        ],
        disabled: [
          "disabled"
        ],
        formenctype: w$,
        formmethod: S$,
        formnovalidate: [
          "novalidate"
        ],
        formtarget: c0,
        multiple: [
          "multiple"
        ],
        readonly: [
          "readonly"
        ],
        required: [
          "required"
        ],
        type: [
          "hidden",
          "text",
          "search",
          "tel",
          "url",
          "email",
          "password",
          "datetime",
          "date",
          "month",
          "week",
          "time",
          "datetime-local",
          "number",
          "range",
          "color",
          "checkbox",
          "radio",
          "file",
          "submit",
          "image",
          "reset",
          "button"
        ]
      }
    },
    ins: {
      attrs: {
        cite: null,
        datetime: null
      }
    },
    kbd: Fe,
    keygen: {
      attrs: {
        challenge: null,
        form: null,
        name: null,
        autofocus: [
          "autofocus"
        ],
        disabled: [
          "disabled"
        ],
        keytype: [
          "RSA"
        ]
      }
    },
    label: {
      attrs: {
        for: null,
        form: null
      }
    },
    legend: Fe,
    li: {
      attrs: {
        value: null
      }
    },
    link: {
      attrs: {
        href: null,
        type: null,
        hreflang: null,
        media: null,
        sizes: [
          "all",
          "16x16",
          "16x16 32x32",
          "16x16 32x32 64x64"
        ]
      }
    },
    map: {
      attrs: {
        name: null
      }
    },
    mark: Fe,
    menu: {
      attrs: {
        label: null,
        type: [
          "list",
          "context",
          "toolbar"
        ]
      }
    },
    meta: {
      attrs: {
        content: null,
        charset: O$,
        name: [
          "viewport",
          "application-name",
          "author",
          "description",
          "generator",
          "keywords"
        ],
        "http-equiv": [
          "content-language",
          "content-type",
          "default-style",
          "refresh"
        ]
      }
    },
    meter: {
      attrs: {
        value: null,
        min: null,
        low: null,
        high: null,
        max: null,
        optimum: null
      }
    },
    nav: Fe,
    noscript: Fe,
    object: {
      attrs: {
        data: null,
        type: null,
        name: null,
        usemap: null,
        form: null,
        width: null,
        height: null,
        typemustmatch: [
          "typemustmatch"
        ]
      }
    },
    ol: {
      attrs: {
        reversed: [
          "reversed"
        ],
        start: null,
        type: [
          "1",
          "a",
          "A",
          "i",
          "I"
        ]
      },
      children: [
        "li",
        "script",
        "template",
        "ul",
        "ol"
      ]
    },
    optgroup: {
      attrs: {
        disabled: [
          "disabled"
        ],
        label: null
      }
    },
    option: {
      attrs: {
        disabled: [
          "disabled"
        ],
        label: null,
        selected: [
          "selected"
        ],
        value: null
      }
    },
    output: {
      attrs: {
        for: null,
        form: null,
        name: null
      }
    },
    p: Fe,
    param: {
      attrs: {
        name: null,
        value: null
      }
    },
    pre: Fe,
    progress: {
      attrs: {
        value: null,
        max: null
      }
    },
    q: {
      attrs: {
        cite: null
      }
    },
    rp: Fe,
    rt: Fe,
    ruby: Fe,
    samp: Fe,
    script: {
      attrs: {
        type: [
          "text/javascript"
        ],
        src: null,
        async: [
          "async"
        ],
        defer: [
          "defer"
        ],
        charset: O$
      }
    },
    section: Fe,
    select: {
      attrs: {
        form: null,
        name: null,
        size: null,
        autofocus: [
          "autofocus"
        ],
        disabled: [
          "disabled"
        ],
        multiple: [
          "multiple"
        ]
      }
    },
    slot: {
      attrs: {
        name: null
      }
    },
    small: Fe,
    source: {
      attrs: {
        src: null,
        type: null,
        media: null
      }
    },
    span: Fe,
    strong: Fe,
    style: {
      attrs: {
        type: [
          "text/css"
        ],
        media: null,
        scoped: null
      }
    },
    sub: Fe,
    summary: Fe,
    sup: Fe,
    table: Fe,
    tbody: Fe,
    td: {
      attrs: {
        colspan: null,
        rowspan: null,
        headers: null
      }
    },
    template: Fe,
    textarea: {
      attrs: {
        dirname: null,
        form: null,
        maxlength: null,
        name: null,
        placeholder: null,
        rows: null,
        cols: null,
        autofocus: [
          "autofocus"
        ],
        disabled: [
          "disabled"
        ],
        readonly: [
          "readonly"
        ],
        required: [
          "required"
        ],
        wrap: [
          "soft",
          "hard"
        ]
      }
    },
    tfoot: Fe,
    th: {
      attrs: {
        colspan: null,
        rowspan: null,
        headers: null,
        scope: [
          "row",
          "col",
          "rowgroup",
          "colgroup"
        ]
      }
    },
    thead: Fe,
    time: {
      attrs: {
        datetime: null
      }
    },
    title: Fe,
    tr: Fe,
    track: {
      attrs: {
        src: null,
        label: null,
        default: null,
        kind: [
          "subtitles",
          "captions",
          "descriptions",
          "chapters",
          "metadata"
        ],
        srclang: null
      }
    },
    ul: {
      children: [
        "li",
        "script",
        "template",
        "ul",
        "ol"
      ]
    },
    var: Fe,
    video: {
      attrs: {
        src: null,
        poster: null,
        width: null,
        height: null,
        crossorigin: [
          "anonymous",
          "use-credentials"
        ],
        preload: [
          "auto",
          "metadata",
          "none"
        ],
        autoplay: [
          "autoplay"
        ],
        mediagroup: [
          "movie"
        ],
        muted: [
          "muted"
        ],
        controls: [
          "controls"
        ]
      }
    },
    wbr: Fe
  }, ale = {
    accesskey: null,
    class: null,
    contenteditable: Ls,
    contextmenu: null,
    dir: [
      "ltr",
      "rtl",
      "auto"
    ],
    draggable: [
      "true",
      "false",
      "auto"
    ],
    dropzone: [
      "copy",
      "move",
      "link",
      "string:",
      "file:"
    ],
    hidden: [
      "hidden"
    ],
    id: null,
    inert: [
      "inert"
    ],
    itemid: null,
    itemprop: null,
    itemref: null,
    itemscope: [
      "itemscope"
    ],
    itemtype: null,
    lang: [
      "ar",
      "bn",
      "de",
      "en-GB",
      "en-US",
      "es",
      "fr",
      "hi",
      "id",
      "ja",
      "pa",
      "pt",
      "ru",
      "tr",
      "zh"
    ],
    spellcheck: Ls,
    autocorrect: Ls,
    autocapitalize: Ls,
    style: null,
    tabindex: null,
    title: null,
    translate: [
      "yes",
      "no"
    ],
    rel: [
      "stylesheet",
      "alternate",
      "author",
      "bookmark",
      "help",
      "license",
      "next",
      "nofollow",
      "noreferrer",
      "prefetch",
      "prev",
      "search",
      "tag"
    ],
    role: "alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),
    "aria-activedescendant": null,
    "aria-atomic": Ls,
    "aria-autocomplete": [
      "inline",
      "list",
      "both",
      "none"
    ],
    "aria-busy": Ls,
    "aria-checked": [
      "true",
      "false",
      "mixed",
      "undefined"
    ],
    "aria-controls": null,
    "aria-describedby": null,
    "aria-disabled": Ls,
    "aria-dropeffect": null,
    "aria-expanded": [
      "true",
      "false",
      "undefined"
    ],
    "aria-flowto": null,
    "aria-grabbed": [
      "true",
      "false",
      "undefined"
    ],
    "aria-haspopup": Ls,
    "aria-hidden": Ls,
    "aria-invalid": [
      "true",
      "false",
      "grammar",
      "spelling"
    ],
    "aria-label": null,
    "aria-labelledby": null,
    "aria-level": null,
    "aria-live": [
      "off",
      "polite",
      "assertive"
    ],
    "aria-multiline": Ls,
    "aria-multiselectable": Ls,
    "aria-owns": null,
    "aria-posinset": null,
    "aria-pressed": [
      "true",
      "false",
      "mixed",
      "undefined"
    ],
    "aria-readonly": Ls,
    "aria-relevant": null,
    "aria-required": Ls,
    "aria-selected": [
      "true",
      "false",
      "undefined"
    ],
    "aria-setsize": null,
    "aria-sort": [
      "ascending",
      "descending",
      "none",
      "other"
    ],
    "aria-valuemax": null,
    "aria-valuemin": null,
    "aria-valuenow": null,
    "aria-valuetext": null
  }, lle = "beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map((t) => "on" + t);
  for (let t of lle)
    ale[t] = null;
  class _O {
    constructor(e, n) {
      this.tags = {
        ...$et,
        ...e
      }, this.globalAttrs = {
        ...ale,
        ...n
      }, this.allTags = Object.keys(this.tags), this.globalAttrNames = Object.keys(this.globalAttrs);
    }
  }
  _O.default = new _O();
  function hm(t, e, n = t.length) {
    if (!e)
      return "";
    let r = e.firstChild, i = r && r.getChild("TagName");
    return i ? t.sliceString(i.from, Math.min(i.to, n)) : "";
  }
  function fm(t, e = false) {
    for (; t; t = t.parent)
      if (t.name == "Element")
        if (e)
          e = false;
        else
          return t;
    return null;
  }
  function cle(t, e, n) {
    let r = n.tags[hm(t, fm(e))];
    return (r == null ? void 0 : r.children) || n.allTags;
  }
  function nN(t, e) {
    let n = [];
    for (let r = fm(e); r && !r.type.isTop; r = fm(r.parent)) {
      let i = hm(t, r);
      if (i && r.lastChild.name == "CloseTag")
        break;
      i && n.indexOf(i) < 0 && (e.name == "EndTag" || e.from >= r.firstChild.to) && n.push(i);
    }
    return n;
  }
  const ule = /^[:\-\.\w\u00b7-\uffff]*$/;
  function $V(t, e, n, r, i) {
    let s = /\s*>/.test(t.sliceDoc(i, i + 5)) ? "" : ">", o = fm(n, n.name == "StartTag" || n.name == "TagName");
    return {
      from: r,
      to: i,
      options: cle(t.doc, o, e).map((a) => ({
        label: a,
        type: "type"
      })).concat(nN(t.doc, n).map((a, l) => ({
        label: "/" + a,
        apply: "/" + a + s,
        type: "type",
        boost: 99 - l
      }))),
      validFor: /^\/?[:\-\.\w\u00b7-\uffff]*$/
    };
  }
  function AV(t, e, n, r) {
    let i = /\s*>/.test(t.sliceDoc(r, r + 5)) ? "" : ">";
    return {
      from: n,
      to: r,
      options: nN(t.doc, e).map((s, o) => ({
        label: s,
        apply: s + i,
        type: "type",
        boost: 99 - o
      })),
      validFor: ule
    };
  }
  function Aet(t, e, n, r) {
    let i = [], s = 0;
    for (let o of cle(t.doc, n, e))
      i.push({
        label: "<" + o,
        type: "type"
      });
    for (let o of nN(t.doc, n))
      i.push({
        label: "</" + o + ">",
        type: "type",
        boost: 99 - s++
      });
    return {
      from: r,
      to: r,
      options: i,
      validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/
    };
  }
  function Ret(t, e, n, r, i) {
    let s = fm(n), o = s ? e.tags[hm(t.doc, s)] : null, a = o && o.attrs ? Object.keys(o.attrs) : [], l = o && o.globalAttrs === false ? a : a.length ? a.concat(e.globalAttrNames) : e.globalAttrNames;
    return {
      from: r,
      to: i,
      options: l.map((c) => ({
        label: c,
        type: "property"
      })),
      validFor: ule
    };
  }
  function Met(t, e, n, r, i) {
    var s;
    let o = (s = n.parent) === null || s === void 0 ? void 0 : s.getChild("AttributeName"), a = [], l;
    if (o) {
      let c = t.sliceDoc(o.from, o.to), u = e.globalAttrs[c];
      if (!u) {
        let d = fm(n), h = d ? e.tags[hm(t.doc, d)] : null;
        u = (h == null ? void 0 : h.attrs) && h.attrs[c];
      }
      if (u) {
        let d = t.sliceDoc(r, i).toLowerCase(), h = '"', f = '"';
        /^['"]/.test(d) ? (l = d[0] == '"' ? /^[^"]*$/ : /^[^']*$/, h = "", f = t.sliceDoc(i, i + 1) == d[0] ? "" : d[0], d = d.slice(1), r++) : l = /^[^\s<>='"]*$/;
        for (let y of u)
          a.push({
            label: y,
            apply: h + y + f,
            type: "constant"
          });
      }
    }
    return {
      from: r,
      to: i,
      options: a,
      validFor: l
    };
  }
  function dle(t, e) {
    let { state: n, pos: r } = e, i = Un(n).resolveInner(r, -1), s = i.resolve(r);
    for (let o = r, a; s == i && (a = i.childBefore(o)); ) {
      let l = a.lastChild;
      if (!l || !l.type.isError || l.from < l.to)
        break;
      s = i = a, o = l.from;
    }
    return i.name == "TagName" ? i.parent && /CloseTag$/.test(i.parent.name) ? AV(n, i, i.from, r) : $V(n, t, i, i.from, r) : i.name == "StartTag" || i.name == "IncompleteTag" ? $V(n, t, i, r, r) : i.name == "StartCloseTag" || i.name == "IncompleteCloseTag" ? AV(n, i, r, r) : i.name == "OpenTag" || i.name == "SelfClosingTag" || i.name == "AttributeName" ? Ret(n, t, i, i.name == "AttributeName" ? i.from : r, r) : i.name == "Is" || i.name == "AttributeValue" || i.name == "UnquotedAttributeValue" ? Met(n, t, i, i.name == "Is" ? r : i.from, r) : e.explicit && (s.name == "Element" || s.name == "Text" || s.name == "Document") ? Aet(n, t, i, r) : null;
  }
  function hle(t) {
    return dle(_O.default, t);
  }
  function fle(t) {
    let { extraTags: e, extraGlobalAttributes: n } = t, r = n || e ? new _O(e, n) : _O.default;
    return (i) => dle(r, i);
  }
  const Det = qo.parser.configure({
    top: "SingleExpression"
  }), ple = [
    {
      tag: "script",
      attrs: (t) => t.type == "text/typescript" || t.lang == "ts",
      parser: Jj.parser
    },
    {
      tag: "script",
      attrs: (t) => t.type == "text/babel" || t.type == "text/jsx",
      parser: eN.parser
    },
    {
      tag: "script",
      attrs: (t) => t.type == "text/typescript-jsx",
      parser: tN.parser
    },
    {
      tag: "script",
      attrs(t) {
        return /^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(t.type);
      },
      parser: Det
    },
    {
      tag: "script",
      attrs(t) {
        return !t.type || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(t.type);
      },
      parser: qo.parser
    },
    {
      tag: "style",
      attrs(t) {
        return (!t.lang || t.lang == "css") && (!t.type || /^(text\/)?(x-)?(stylesheet|css)$/i.test(t.type));
      },
      parser: CO.parser
    }
  ], gle = [
    {
      name: "style",
      parser: CO.parser.configure({
        top: "Styles"
      })
    }
  ].concat(lle.map((t) => ({
    name: t,
    parser: qo.parser
  }))), mle = om.define({
    name: "html",
    parser: lJe.configure({
      props: [
        Bm.add({
          Element(t) {
            let e = /^(\s*)(<\/)?/.exec(t.textAfter);
            return t.node.to <= t.pos + e[0].length ? t.continue() : t.lineIndent(t.node.from) + (e[2] ? 0 : t.unit);
          },
          "OpenTag CloseTag SelfClosingTag"(t) {
            return t.column(t.node.from) + t.unit;
          },
          Document(t) {
            if (t.pos + /\s*/.exec(t.textAfter)[0].length < t.node.to)
              return t.continue();
            let e = null, n;
            for (let r = t.node; ; ) {
              let i = r.lastChild;
              if (!i || i.name != "Element" || i.to != r.to)
                break;
              e = r = i;
            }
            return e && !((n = e.lastChild) && (n.name == "CloseTag" || n.name == "SelfClosingTag")) ? t.lineIndent(e.from) + t.unit : null;
          }
        }),
        Um.add({
          Element(t) {
            let e = t.firstChild, n = t.lastChild;
            return !e || e.name != "OpenTag" ? null : {
              from: e.to,
              to: n.name == "CloseTag" ? n.from : t.to
            };
          }
        }),
        vqe.add({
          "OpenTag CloseTag": (t) => t.getChild("TagName")
        })
      ]
    }),
    languageData: {
      commentTokens: {
        block: {
          open: "<!--",
          close: "-->"
        }
      },
      indentOnInput: /^\s*<\/\w+\W$/,
      wordChars: "-_"
    }
  }), hv = mle.configure({
    wrap: Fae(ple, gle)
  });
  yle = function(t = {}) {
    let e = "", n;
    t.matchClosingTags === false && (e = "noMatch"), t.selfClosingTags === true && (e = (e ? e + " " : "") + "selfClosing"), (t.nestedLanguages && t.nestedLanguages.length || t.nestedAttributes && t.nestedAttributes.length) && (n = Fae((t.nestedLanguages || []).concat(ple), (t.nestedAttributes || []).concat(gle)));
    let r = n ? mle.configure({
      wrap: n,
      dialect: e
    }) : e ? hv.configure({
      dialect: e
    }) : hv;
    return new cm(r, [
      hv.data.of({
        autocomplete: fle(t)
      }),
      t.autoCloseTags !== false ? vle : [],
      sle().support,
      Yae().support
    ]);
  };
  const RV = new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")), vle = Re.inputHandler.of((t, e, n, r, i) => {
    if (t.composing || t.state.readOnly || e != n || r != ">" && r != "/" || !hv.isActiveAt(t.state, e, -1))
      return false;
    let s = i(), { state: o } = s, a = o.changeByRange((l) => {
      var c, u, d;
      let h = o.doc.sliceString(l.from - 1, l.to) == r, { head: f } = l, y = Un(o).resolveInner(f, -1), g;
      if (h && r == ">" && y.name == "EndTag") {
        let O = y.parent;
        if (((u = (c = O.parent) === null || c === void 0 ? void 0 : c.lastChild) === null || u === void 0 ? void 0 : u.name) != "CloseTag" && (g = hm(o.doc, O.parent, f)) && !RV.has(g)) {
          let S = f + (o.doc.sliceString(f, f + 1) === ">" ? 1 : 0), w = `</${g}>`;
          return {
            range: l,
            changes: {
              from: f,
              to: S,
              insert: w
            }
          };
        }
      } else if (h && r == "/" && y.name == "IncompleteCloseTag") {
        let O = y.parent;
        if (y.from == f - 2 && ((d = O.lastChild) === null || d === void 0 ? void 0 : d.name) != "CloseTag" && (g = hm(o.doc, O, f)) && !RV.has(g)) {
          let S = f + (o.doc.sliceString(f, f + 1) === ">" ? 1 : 0), w = `${g}>`;
          return {
            range: Ve.cursor(f + w.length, -1),
            changes: {
              from: f,
              to: S,
              insert: w
            }
          };
        }
      }
      return {
        range: l
      };
    });
    return a.changes.empty ? false : (t.dispatch([
      s,
      o.update(a, {
        userEvent: "input.complete",
        scrollIntoView: true
      })
    ]), true);
  }), Let = Object.freeze(Object.defineProperty({
    __proto__: null,
    autoCloseTags: vle,
    html: yle,
    htmlCompletionSource: hle,
    htmlCompletionSourceWith: fle,
    htmlLanguage: hv
  }, Symbol.toStringTag, {
    value: "Module"
  })), Ole = A2({
    commentTokens: {
      block: {
        open: "<!--",
        close: "-->"
      }
    }
  }), Sle = new ut(), wle = nKe.configure({
    props: [
      Um.add((t) => !t.is("Block") || t.is("Document") || aD(t) != null || jet(t) ? void 0 : (e, n) => ({
        from: n.doc.lineAt(e.from).to,
        to: e.to
      })),
      Sle.add(aD),
      Bm.add({
        Document: () => null
      }),
      nd.add({
        Document: Ole
      })
    ]
  });
  function aD(t) {
    let e = /^(?:ATX|Setext)Heading(\d)$/.exec(t.name);
    return e ? +e[1] : void 0;
  }
  function jet(t) {
    return t.name == "OrderedList" || t.name == "BulletList";
  }
  function Net(t, e) {
    let n = t;
    for (; ; ) {
      let r = n.nextSibling, i;
      if (!r || (i = aD(r.type)) != null && i <= e)
        break;
      n = r;
    }
    return n.to;
  }
  const Qet = Voe.of((t, e, n) => {
    for (let r = Un(t).resolveInner(n, -1); r && !(r.from < e); r = r.parent) {
      let i = r.type.prop(Sle);
      if (i == null)
        continue;
      let s = Net(r, i);
      if (s > n)
        return {
          from: n,
          to: s
        };
    }
    return null;
  });
  function rN(t) {
    return new gs(Ole, t, [], "markdown");
  }
  const xle = rN(wle), zet = wle.configure([
    fKe,
    gKe,
    pKe,
    mKe,
    {
      props: [
        Um.add({
          Table: (t, e) => ({
            from: e.doc.lineAt(t.from).to,
            to: t.to
          })
        })
      ]
    }
  ]), TO = rN(zet);
  function Fet(t, e) {
    return (n) => {
      if (n && t) {
        let r = null;
        if (n = /\S*/.exec(n)[0], typeof t == "function" ? r = t(n) : r = ie.matchLanguageName(t, n, true), r instanceof ie)
          return r.support ? r.support.language.parser : pf.getSkippingParser(r.load());
        if (r)
          return r.parser;
      }
      return e ? e.parser : null;
    };
  }
  class x$ {
    constructor(e, n, r, i, s, o, a) {
      this.node = e, this.from = n, this.to = r, this.spaceBefore = i, this.spaceAfter = s, this.type = o, this.item = a;
    }
    blank(e, n = true) {
      let r = this.spaceBefore + (this.node.name == "Blockquote" ? ">" : "");
      if (e != null) {
        for (; r.length < e; )
          r += " ";
        return r;
      } else {
        for (let i = this.to - this.from - r.length - this.spaceAfter.length; i > 0; i--)
          r += " ";
        return r + (n ? this.spaceAfter : "");
      }
    }
    marker(e, n) {
      let r = this.node.name == "OrderedList" ? String(+kle(this.item, e)[2] + n) : "";
      return this.spaceBefore + r + this.type + this.spaceAfter;
    }
  }
  function ble(t, e) {
    let n = [], r = [];
    for (let i = t; i; i = i.parent) {
      if (i.name == "FencedCode")
        return r;
      (i.name == "ListItem" || i.name == "Blockquote") && n.push(i);
    }
    for (let i = n.length - 1; i >= 0; i--) {
      let s = n[i], o, a = e.lineAt(s.from), l = s.from - a.from;
      if (s.name == "Blockquote" && (o = /^ *>( ?)/.exec(a.text.slice(l))))
        r.push(new x$(s, l, l + o[0].length, "", o[1], ">", null));
      else if (s.name == "ListItem" && s.parent.name == "OrderedList" && (o = /^( *)\d+([.)])( *)/.exec(a.text.slice(l)))) {
        let c = o[3], u = o[0].length;
        c.length >= 4 && (c = c.slice(0, c.length - 4), u -= 4), r.push(new x$(s.parent, l, l + u, o[1], c, o[2], s));
      } else if (s.name == "ListItem" && s.parent.name == "BulletList" && (o = /^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(a.text.slice(l)))) {
        let c = o[4], u = o[0].length;
        c.length > 4 && (c = c.slice(0, c.length - 4), u -= 4);
        let d = o[2];
        o[3] && (d += o[3].replace(/[xX]/, " ")), r.push(new x$(s.parent, l, l + u, o[1], c, d, s));
      }
    }
    return r;
  }
  function kle(t, e) {
    return /^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(t.from, t.from + 10));
  }
  function b$(t, e, n, r = 0) {
    for (let i = -1, s = t; ; ) {
      if (s.name == "ListItem") {
        let a = kle(s, e), l = +a[2];
        if (i >= 0) {
          if (l != i + 1)
            return;
          n.push({
            from: s.from + a[1].length,
            to: s.from + a[0].length,
            insert: String(i + 2 + r)
          });
        }
        i = l;
      }
      let o = s.nextSibling;
      if (!o)
        break;
      s = o;
    }
  }
  function iN(t, e) {
    let n = /^[ \t]*/.exec(t)[0].length;
    if (!n || e.facet(Fm) != "	")
      return t;
    let r = em(t, 4, n), i = "";
    for (let s = r; s > 0; )
      s >= 4 ? (i += "	", s -= 4) : (i += " ", s--);
    return i + t.slice(n);
  }
  const Ple = ({ state: t, dispatch: e }) => {
    let n = Un(t), { doc: r } = t, i = null, s = t.changeByRange((o) => {
      if (!o.empty || !TO.isActiveAt(t, o.from, -1) && !TO.isActiveAt(t, o.from, 1))
        return i = {
          range: o
        };
      let a = o.from, l = r.lineAt(a), c = ble(n.resolveInner(a, -1), r);
      for (; c.length && c[c.length - 1].from > a - l.from; )
        c.pop();
      if (!c.length)
        return i = {
          range: o
        };
      let u = c[c.length - 1];
      if (u.to - u.spaceAfter.length > a - l.from)
        return i = {
          range: o
        };
      let d = a >= u.to - u.spaceAfter.length && !/\S/.test(l.text.slice(u.to));
      if (u.item && d) {
        let O = u.node.firstChild, S = u.node.getChild("ListItem", "ListItem");
        if (O.to >= a || S && S.to < a || l.from > 0 && !/[^\s>]/.test(r.lineAt(l.from - 1).text)) {
          let w = c.length > 1 ? c[c.length - 2] : null, x, P = "";
          w && w.item ? (x = l.from + w.from, P = w.marker(r, 1)) : x = l.from + (w ? w.to : 0);
          let C = [
            {
              from: x,
              to: a,
              insert: P
            }
          ];
          return u.node.name == "OrderedList" && b$(u.item, r, C, -2), w && w.node.name == "OrderedList" && b$(w.item, r, C), {
            range: Ve.cursor(x + P.length),
            changes: C
          };
        } else {
          let w = DV(c, t, l);
          return {
            range: Ve.cursor(a + w.length + 1),
            changes: {
              from: l.from,
              insert: w + t.lineBreak
            }
          };
        }
      }
      if (u.node.name == "Blockquote" && d && l.from) {
        let O = r.lineAt(l.from - 1), S = />\s*$/.exec(O.text);
        if (S && S.index == u.from) {
          let w = t.changes([
            {
              from: O.from + S.index,
              to: O.to
            },
            {
              from: l.from + u.from,
              to: l.to
            }
          ]);
          return {
            range: o.map(w),
            changes: w
          };
        }
      }
      let h = [];
      u.node.name == "OrderedList" && b$(u.item, r, h);
      let f = u.item && u.item.from < l.from, y = "";
      if (!f || /^[\s\d.)\-+*>]*/.exec(l.text)[0].length >= u.to)
        for (let O = 0, S = c.length - 1; O <= S; O++)
          y += O == S && !f ? c[O].marker(r, 1) : c[O].blank(O < S ? em(l.text, 4, c[O + 1].from) - y.length : null);
      let g = a;
      for (; g > l.from && /\s/.test(l.text.charAt(g - l.from - 1)); )
        g--;
      return y = iN(y, t), Bet(u.node, t.doc) && (y = DV(c, t, l) + t.lineBreak + y), h.push({
        from: g,
        to: a,
        insert: t.lineBreak + y
      }), {
        range: Ve.cursor(g + y.length + 1),
        changes: h
      };
    });
    return i ? false : (e(t.update(s, {
      scrollIntoView: true,
      userEvent: "input"
    })), true);
  };
  function MV(t) {
    return t.name == "QuoteMark" || t.name == "ListMark";
  }
  function Bet(t, e) {
    if (t.name != "OrderedList" && t.name != "BulletList")
      return false;
    let n = t.firstChild, r = t.getChild("ListItem", "ListItem");
    if (!r)
      return false;
    let i = e.lineAt(n.to), s = e.lineAt(r.from), o = /^[\s>]*$/.test(i.text);
    return i.number + (o ? 0 : 1) < s.number;
  }
  function DV(t, e, n) {
    let r = "";
    for (let i = 0, s = t.length - 2; i <= s; i++)
      r += t[i].blank(i < s ? em(n.text, 4, t[i + 1].from) - r.length : null, i < s);
    return iN(r, e);
  }
  function Uet(t, e) {
    let n = t.resolveInner(e, -1), r = e;
    MV(n) && (r = n.from, n = n.parent);
    for (let i; i = n.childBefore(r); )
      if (MV(i))
        r = i.from;
      else if (i.name == "OrderedList" || i.name == "BulletList")
        n = i.lastChild, r = n.to;
      else
        break;
    return n;
  }
  const Cle = ({ state: t, dispatch: e }) => {
    let n = Un(t), r = null, i = t.changeByRange((s) => {
      let o = s.from, { doc: a } = t;
      if (s.empty && TO.isActiveAt(t, s.from)) {
        let l = a.lineAt(o), c = ble(Uet(n, o), a);
        if (c.length) {
          let u = c[c.length - 1], d = u.to - u.spaceAfter.length + (u.spaceAfter ? 1 : 0);
          if (o - l.from > d && !/\S/.test(l.text.slice(d, o - l.from)))
            return {
              range: Ve.cursor(l.from + d),
              changes: {
                from: l.from + d,
                to: o
              }
            };
          if (o - l.from == d && (!u.item || l.from <= u.item.from || !/\S/.test(l.text.slice(0, u.to)))) {
            let h = l.from + u.from;
            if (u.item && u.node.from < u.item.from && /\S/.test(l.text.slice(u.from, u.to))) {
              let f = u.blank(em(l.text, 4, u.to) - em(l.text, 4, u.from));
              return h == l.from && (f = iN(f, t)), {
                range: Ve.cursor(h + f.length),
                changes: {
                  from: h,
                  to: l.from + u.to,
                  insert: f
                }
              };
            }
            if (h < o)
              return {
                range: Ve.cursor(h),
                changes: {
                  from: h,
                  to: o
                }
              };
          }
        }
      }
      return r = {
        range: s
      };
    });
    return r ? false : (e(t.update(i, {
      scrollIntoView: true,
      userEvent: "delete"
    })), true);
  }, _le = [
    {
      key: "Enter",
      run: Ple
    },
    {
      key: "Backspace",
      run: Cle
    }
  ], Tle = yle({
    matchClosingTags: false
  });
  function Ele(t = {}) {
    let { codeLanguages: e, defaultCodeLanguage: n, addKeymap: r = true, base: { parser: i } = xle, completeHTMLTags: s = true, pasteURLAsLink: o = true, htmlTagLanguage: a = Tle } = t;
    if (!(i instanceof M2))
      throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");
    let l = t.extensions ? [
      t.extensions
    ] : [], c = [
      a.support,
      Qet
    ], u;
    o && c.push(Ile), n instanceof cm ? (c.push(n.support), u = n.language) : n && (u = n);
    let d = e || u ? Fet(e, u) : void 0;
    l.push(iKe({
      codeParser: d,
      htmlParser: a.language.parser
    })), r && c.push(xS.high(E2.of(_le)));
    let h = rN(i.configure(l));
    return s && c.push(h.data.of({
      autocomplete: Vet
    })), new cm(h, c);
  }
  function Vet(t) {
    let { state: e, pos: n } = t, r = /<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(n - 25, n));
    if (!r)
      return null;
    let i = Un(e).resolveInner(n, -1);
    for (; i && !i.type.isTop; ) {
      if (i.name == "CodeBlock" || i.name == "FencedCode" || i.name == "ProcessingInstructionBlock" || i.name == "CommentBlock" || i.name == "Link" || i.name == "Image")
        return null;
      i = i.parent;
    }
    return {
      from: n - r[0].length,
      to: n,
      options: Xet(),
      validFor: /^<[:\-\.\w\u00b7-\uffff]*$/
    };
  }
  let k$ = null;
  function Xet() {
    if (k$)
      return k$;
    let t = hle(new Cqe(lr.create({
      extensions: Tle
    }), 0, true));
    return k$ = t ? t.options : [];
  }
  const Wet = /code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i, Ile = Re.domEventHandlers({
    paste: (t, e) => {
      var n;
      let { main: r } = e.state.selection;
      if (r.empty)
        return false;
      let i = (n = t.clipboardData) === null || n === void 0 ? void 0 : n.getData("text/plain");
      if (!i || !/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(i) || (/^www\./.test(i) && (i = "https://" + i), !TO.isActiveAt(e.state, r.from, 1)))
        return false;
      let s = Un(e.state), o = false;
      return s.iterate({
        from: r.from,
        to: r.to,
        enter: (a) => {
          (a.from > r.from || Wet.test(a.name)) && (o = true);
        },
        leave: (a) => {
          a.to < r.to && (o = true);
        }
      }), o ? false : (e.dispatch({
        changes: [
          {
            from: r.from,
            insert: "["
          },
          {
            from: r.to,
            insert: `](${i})`
          }
        ],
        userEvent: "input.paste",
        scrollIntoView: true
      }), true);
    }
  }), Zet = Object.freeze(Object.defineProperty({
    __proto__: null,
    commonmarkLanguage: xle,
    deleteMarkupBackward: Cle,
    insertNewlineContinueMarkup: Ple,
    markdown: Ele,
    markdownKeymap: _le,
    markdownLanguage: TO,
    pasteURLAsLink: Ile
  }, Symbol.toStringTag, {
    value: "Module"
  })), Het = "modulepreload", Yet = function(t, e) {
    return new URL(t, e).href;
  }, LV = {}, le = function(e, n, r) {
    if (!n || n.length === 0)
      return e();
    const i = document.getElementsByTagName("link");
    return Promise.all(n.map((s) => {
      if (s = Yet(s, r), s in LV)
        return;
      LV[s] = true;
      const o = s.endsWith(".css"), a = o ? '[rel="stylesheet"]' : "";
      if (!!r)
        for (let u = i.length - 1; u >= 0; u--) {
          const d = i[u];
          if (d.href === s && (!o || d.rel === "stylesheet"))
            return;
        }
      else if (document.querySelector(`link[href="${s}"]${a}`))
        return;
      const c = document.createElement("link");
      if (c.rel = o ? "stylesheet" : Het, o || (c.as = "script", c.crossOrigin = ""), c.href = s, document.head.appendChild(c), o)
        return new Promise((u, d) => {
          c.addEventListener("load", u), c.addEventListener("error", () => d(new Error(`Unable to preload CSS for ${s}`)));
        });
    })).then(() => e()).catch((s) => {
      const o = new Event("vite:preloadError", {
        cancelable: true
      });
      if (o.payload = s, window.dispatchEvent(o), !o.defaultPrevented)
        throw s;
    });
  };
  function pe(t) {
    return new cm(Nj.define(t));
  }
  function Tu(t) {
    return le(() => import("./index-9bb08011.js").then(async (m4) => {
      await m4.__tla;
      return m4;
    }), ["./index-9bb08011.js","./index-c30f3063.js"], import.meta.url).then((e) => e.sql({
      dialect: e[t]
    }));
  }
  const Get = [
    ie.of({
      name: "C",
      extensions: [
        "c",
        "h",
        "ino"
      ],
      load() {
        return le(() => import("./index-fd58da1f.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-fd58da1f.js","./index-c30f3063.js"], import.meta.url).then((t) => t.cpp());
      }
    }),
    ie.of({
      name: "C++",
      alias: [
        "cpp"
      ],
      extensions: [
        "cpp",
        "c++",
        "cc",
        "cxx",
        "hpp",
        "h++",
        "hh",
        "hxx"
      ],
      load() {
        return le(() => import("./index-fd58da1f.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-fd58da1f.js","./index-c30f3063.js"], import.meta.url).then((t) => t.cpp());
      }
    }),
    ie.of({
      name: "CQL",
      alias: [
        "cassandra"
      ],
      extensions: [
        "cql"
      ],
      load() {
        return Tu("Cassandra");
      }
    }),
    ie.of({
      name: "CSS",
      extensions: [
        "css"
      ],
      load() {
        return le(() => Promise.resolve().then(() => BJe), void 0, import.meta.url).then((t) => t.css());
      }
    }),
    ie.of({
      name: "Go",
      extensions: [
        "go"
      ],
      load() {
        return le(() => import("./index-4591519f.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-4591519f.js","./index-c30f3063.js"], import.meta.url).then((t) => t.go());
      }
    }),
    ie.of({
      name: "HTML",
      alias: [
        "xhtml"
      ],
      extensions: [
        "html",
        "htm",
        "handlebars",
        "hbs"
      ],
      load() {
        return le(() => Promise.resolve().then(() => Let), void 0, import.meta.url).then((t) => t.html());
      }
    }),
    ie.of({
      name: "Java",
      extensions: [
        "java"
      ],
      load() {
        return le(() => import("./index-56a8696a.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-56a8696a.js","./index-c30f3063.js"], import.meta.url).then((t) => t.java());
      }
    }),
    ie.of({
      name: "JavaScript",
      alias: [
        "ecmascript",
        "js",
        "node"
      ],
      extensions: [
        "js",
        "mjs",
        "cjs"
      ],
      load() {
        return le(() => Promise.resolve().then(() => gx), void 0, import.meta.url).then((t) => t.javascript());
      }
    }),
    ie.of({
      name: "JSON",
      alias: [
        "json5"
      ],
      extensions: [
        "json",
        "map"
      ],
      load() {
        return le(() => import("./index-385b2f2b.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-385b2f2b.js","./index-c30f3063.js"], import.meta.url).then((t) => t.json());
      }
    }),
    ie.of({
      name: "JSX",
      extensions: [
        "jsx"
      ],
      load() {
        return le(() => Promise.resolve().then(() => gx), void 0, import.meta.url).then((t) => t.javascript({
          jsx: true
        }));
      }
    }),
    ie.of({
      name: "LESS",
      extensions: [
        "less"
      ],
      load() {
        return le(() => import("./index-32a1bc79.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-32a1bc79.js","./index-c30f3063.js"], import.meta.url).then((t) => t.less());
      }
    }),
    ie.of({
      name: "Liquid",
      extensions: [
        "liquid"
      ],
      load() {
        return le(() => import("./index-f64796b8.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-f64796b8.js","./index-c30f3063.js"], import.meta.url).then((t) => t.liquid());
      }
    }),
    ie.of({
      name: "MariaDB SQL",
      load() {
        return Tu("MariaSQL");
      }
    }),
    ie.of({
      name: "Markdown",
      extensions: [
        "md",
        "markdown",
        "mkd"
      ],
      load() {
        return le(() => Promise.resolve().then(() => Zet), void 0, import.meta.url).then((t) => t.markdown());
      }
    }),
    ie.of({
      name: "MS SQL",
      load() {
        return Tu("MSSQL");
      }
    }),
    ie.of({
      name: "MySQL",
      load() {
        return Tu("MySQL");
      }
    }),
    ie.of({
      name: "PHP",
      extensions: [
        "php",
        "php3",
        "php4",
        "php5",
        "php7",
        "phtml"
      ],
      load() {
        return le(() => import("./index-9e3439b3.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-9e3439b3.js","./index-c30f3063.js"], import.meta.url).then((t) => t.php());
      }
    }),
    ie.of({
      name: "PLSQL",
      extensions: [
        "pls"
      ],
      load() {
        return Tu("PLSQL");
      }
    }),
    ie.of({
      name: "PostgreSQL",
      load() {
        return Tu("PostgreSQL");
      }
    }),
    ie.of({
      name: "Python",
      extensions: [
        "BUILD",
        "bzl",
        "py",
        "pyw"
      ],
      filename: /^(BUCK|BUILD)$/,
      load() {
        return le(() => import("./index-5f8db899.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-5f8db899.js","./index-c30f3063.js"], import.meta.url).then((t) => t.python());
      }
    }),
    ie.of({
      name: "Rust",
      extensions: [
        "rs"
      ],
      load() {
        return le(() => import("./index-366f825d.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-366f825d.js","./index-c30f3063.js"], import.meta.url).then((t) => t.rust());
      }
    }),
    ie.of({
      name: "Sass",
      extensions: [
        "sass"
      ],
      load() {
        return le(() => import("./index-0ac283ff.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-0ac283ff.js","./index-c30f3063.js"], import.meta.url).then((t) => t.sass({
          indented: true
        }));
      }
    }),
    ie.of({
      name: "SCSS",
      extensions: [
        "scss"
      ],
      load() {
        return le(() => import("./index-0ac283ff.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-0ac283ff.js","./index-c30f3063.js"], import.meta.url).then((t) => t.sass());
      }
    }),
    ie.of({
      name: "SQL",
      extensions: [
        "sql"
      ],
      load() {
        return Tu("StandardSQL");
      }
    }),
    ie.of({
      name: "SQLite",
      load() {
        return Tu("SQLite");
      }
    }),
    ie.of({
      name: "TSX",
      extensions: [
        "tsx"
      ],
      load() {
        return le(() => Promise.resolve().then(() => gx), void 0, import.meta.url).then((t) => t.javascript({
          jsx: true,
          typescript: true
        }));
      }
    }),
    ie.of({
      name: "TypeScript",
      alias: [
        "ts"
      ],
      extensions: [
        "ts",
        "mts",
        "cts"
      ],
      load() {
        return le(() => Promise.resolve().then(() => gx), void 0, import.meta.url).then((t) => t.javascript({
          typescript: true
        }));
      }
    }),
    ie.of({
      name: "WebAssembly",
      extensions: [
        "wat",
        "wast"
      ],
      load() {
        return le(() => import("./index-0bdf2322.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-0bdf2322.js","./index-c30f3063.js"], import.meta.url).then((t) => t.wast());
      }
    }),
    ie.of({
      name: "XML",
      alias: [
        "rss",
        "wsdl",
        "xsd"
      ],
      extensions: [
        "xml",
        "xsl",
        "xsd",
        "svg"
      ],
      load() {
        return le(() => import("./index-dfab0ff7.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-dfab0ff7.js","./index-c30f3063.js"], import.meta.url).then((t) => t.xml());
      }
    }),
    ie.of({
      name: "YAML",
      alias: [
        "yml"
      ],
      extensions: [
        "yaml",
        "yml"
      ],
      load() {
        return le(() => import("./index-afb45b29.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-afb45b29.js","./index-c30f3063.js"], import.meta.url).then((t) => t.yaml());
      }
    }),
    ie.of({
      name: "APL",
      extensions: [
        "dyalog",
        "apl"
      ],
      load() {
        return le(() => import("./apl-f73da2d7.js"), [], import.meta.url).then((t) => pe(t.apl));
      }
    }),
    ie.of({
      name: "PGP",
      alias: [
        "asciiarmor"
      ],
      extensions: [
        "asc",
        "pgp",
        "sig"
      ],
      load() {
        return le(() => import("./asciiarmor-e7973ceb.js"), [], import.meta.url).then((t) => pe(t.asciiArmor));
      }
    }),
    ie.of({
      name: "ASN.1",
      extensions: [
        "asn",
        "asn1"
      ],
      load() {
        return le(() => import("./asn1-f9c290f0.js"), [], import.meta.url).then((t) => pe(t.asn1({})));
      }
    }),
    ie.of({
      name: "Asterisk",
      filename: /^extensions\.conf$/i,
      load() {
        return le(() => import("./asterisk-9c249b4c.js"), [], import.meta.url).then((t) => pe(t.asterisk));
      }
    }),
    ie.of({
      name: "Brainfuck",
      extensions: [
        "b",
        "bf"
      ],
      load() {
        return le(() => import("./brainfuck-637b9bf0.js"), [], import.meta.url).then((t) => pe(t.brainfuck));
      }
    }),
    ie.of({
      name: "Cobol",
      extensions: [
        "cob",
        "cpy"
      ],
      load() {
        return le(() => import("./cobol-3c0e8dcf.js"), [], import.meta.url).then((t) => pe(t.cobol));
      }
    }),
    ie.of({
      name: "C#",
      alias: [
        "csharp",
        "cs"
      ],
      extensions: [
        "cs"
      ],
      load() {
        return le(() => import("./clike-be721a9d.js"), [], import.meta.url).then((t) => pe(t.csharp));
      }
    }),
    ie.of({
      name: "Clojure",
      extensions: [
        "clj",
        "cljc",
        "cljx"
      ],
      load() {
        return le(() => import("./clojure-46c215dd.js"), [], import.meta.url).then((t) => pe(t.clojure));
      }
    }),
    ie.of({
      name: "ClojureScript",
      extensions: [
        "cljs"
      ],
      load() {
        return le(() => import("./clojure-46c215dd.js"), [], import.meta.url).then((t) => pe(t.clojure));
      }
    }),
    ie.of({
      name: "Closure Stylesheets (GSS)",
      extensions: [
        "gss"
      ],
      load() {
        return le(() => import("./css-ae0ae1d0.js"), [], import.meta.url).then((t) => pe(t.gss));
      }
    }),
    ie.of({
      name: "CMake",
      extensions: [
        "cmake",
        "cmake.in"
      ],
      filename: /^CMakeLists\.txt$/,
      load() {
        return le(() => import("./cmake-f314e514.js"), [], import.meta.url).then((t) => pe(t.cmake));
      }
    }),
    ie.of({
      name: "CoffeeScript",
      alias: [
        "coffee",
        "coffee-script"
      ],
      extensions: [
        "coffee"
      ],
      load() {
        return le(() => import("./coffeescript-cf6fb77c.js"), [], import.meta.url).then((t) => pe(t.coffeeScript));
      }
    }),
    ie.of({
      name: "Common Lisp",
      alias: [
        "lisp"
      ],
      extensions: [
        "cl",
        "lisp",
        "el"
      ],
      load() {
        return le(() => import("./commonlisp-4f2152ad.js"), [], import.meta.url).then((t) => pe(t.commonLisp));
      }
    }),
    ie.of({
      name: "Cypher",
      extensions: [
        "cyp",
        "cypher"
      ],
      load() {
        return le(() => import("./cypher-236a65ad.js"), [], import.meta.url).then((t) => pe(t.cypher));
      }
    }),
    ie.of({
      name: "Cython",
      extensions: [
        "pyx",
        "pxd",
        "pxi"
      ],
      load() {
        return le(() => import("./python-fa45e8d1.js"), [], import.meta.url).then((t) => pe(t.cython));
      }
    }),
    ie.of({
      name: "Crystal",
      extensions: [
        "cr"
      ],
      load() {
        return le(() => import("./crystal-02658b69.js"), [], import.meta.url).then((t) => pe(t.crystal));
      }
    }),
    ie.of({
      name: "D",
      extensions: [
        "d"
      ],
      load() {
        return le(() => import("./d-76ab4361.js"), [], import.meta.url).then((t) => pe(t.d));
      }
    }),
    ie.of({
      name: "Dart",
      extensions: [
        "dart"
      ],
      load() {
        return le(() => import("./clike-be721a9d.js"), [], import.meta.url).then((t) => pe(t.dart));
      }
    }),
    ie.of({
      name: "diff",
      extensions: [
        "diff",
        "patch"
      ],
      load() {
        return le(() => import("./diff-1bf42f34.js"), [], import.meta.url).then((t) => pe(t.diff));
      }
    }),
    ie.of({
      name: "Dockerfile",
      filename: /^Dockerfile$/,
      load() {
        return le(() => import("./dockerfile-8937608e.js"), ["./dockerfile-8937608e.js","./simple-mode-6643bd24.js"], import.meta.url).then((t) => pe(t.dockerFile));
      }
    }),
    ie.of({
      name: "DTD",
      extensions: [
        "dtd"
      ],
      load() {
        return le(() => import("./dtd-8d673f3f.js"), [], import.meta.url).then((t) => pe(t.dtd));
      }
    }),
    ie.of({
      name: "Dylan",
      extensions: [
        "dylan",
        "dyl",
        "intr"
      ],
      load() {
        return le(() => import("./dylan-94e68d48.js"), [], import.meta.url).then((t) => pe(t.dylan));
      }
    }),
    ie.of({
      name: "EBNF",
      load() {
        return le(() => import("./ebnf-9a58f677.js"), [], import.meta.url).then((t) => pe(t.ebnf));
      }
    }),
    ie.of({
      name: "ECL",
      extensions: [
        "ecl"
      ],
      load() {
        return le(() => import("./ecl-8c848bde.js"), [], import.meta.url).then((t) => pe(t.ecl));
      }
    }),
    ie.of({
      name: "edn",
      extensions: [
        "edn"
      ],
      load() {
        return le(() => import("./clojure-46c215dd.js"), [], import.meta.url).then((t) => pe(t.clojure));
      }
    }),
    ie.of({
      name: "Eiffel",
      extensions: [
        "e"
      ],
      load() {
        return le(() => import("./eiffel-c812667a.js"), [], import.meta.url).then((t) => pe(t.eiffel));
      }
    }),
    ie.of({
      name: "Elm",
      extensions: [
        "elm"
      ],
      load() {
        return le(() => import("./elm-389625db.js"), [], import.meta.url).then((t) => pe(t.elm));
      }
    }),
    ie.of({
      name: "Erlang",
      extensions: [
        "erl"
      ],
      load() {
        return le(() => import("./erlang-72724d5c.js"), [], import.meta.url).then((t) => pe(t.erlang));
      }
    }),
    ie.of({
      name: "Esper",
      load() {
        return le(() => import("./sql-62feda9f.js"), [], import.meta.url).then((t) => pe(t.esper));
      }
    }),
    ie.of({
      name: "Factor",
      extensions: [
        "factor"
      ],
      load() {
        return le(() => import("./factor-c8b4156e.js"), ["./factor-c8b4156e.js","./simple-mode-6643bd24.js"], import.meta.url).then((t) => pe(t.factor));
      }
    }),
    ie.of({
      name: "FCL",
      load() {
        return le(() => import("./fcl-d5e95185.js"), [], import.meta.url).then((t) => pe(t.fcl));
      }
    }),
    ie.of({
      name: "Forth",
      extensions: [
        "forth",
        "fth",
        "4th"
      ],
      load() {
        return le(() => import("./forth-a6c07be1.js"), [], import.meta.url).then((t) => pe(t.forth));
      }
    }),
    ie.of({
      name: "Fortran",
      extensions: [
        "f",
        "for",
        "f77",
        "f90",
        "f95"
      ],
      load() {
        return le(() => import("./fortran-b746f455.js"), [], import.meta.url).then((t) => pe(t.fortran));
      }
    }),
    ie.of({
      name: "F#",
      alias: [
        "fsharp"
      ],
      extensions: [
        "fs"
      ],
      load() {
        return le(() => import("./mllike-1f866598.js"), [], import.meta.url).then((t) => pe(t.fSharp));
      }
    }),
    ie.of({
      name: "Gas",
      extensions: [
        "s"
      ],
      load() {
        return le(() => import("./gas-a519128b.js"), [], import.meta.url).then((t) => pe(t.gas));
      }
    }),
    ie.of({
      name: "Gherkin",
      extensions: [
        "feature"
      ],
      load() {
        return le(() => import("./gherkin-0efe02ac.js"), [], import.meta.url).then((t) => pe(t.gherkin));
      }
    }),
    ie.of({
      name: "Groovy",
      extensions: [
        "groovy",
        "gradle"
      ],
      filename: /^Jenkinsfile$/,
      load() {
        return le(() => import("./groovy-0f5f2f64.js"), [], import.meta.url).then((t) => pe(t.groovy));
      }
    }),
    ie.of({
      name: "Haskell",
      extensions: [
        "hs"
      ],
      load() {
        return le(() => import("./haskell-b620645c.js"), [], import.meta.url).then((t) => pe(t.haskell));
      }
    }),
    ie.of({
      name: "Haxe",
      extensions: [
        "hx"
      ],
      load() {
        return le(() => import("./haxe-7215664e.js"), [], import.meta.url).then((t) => pe(t.haxe));
      }
    }),
    ie.of({
      name: "HXML",
      extensions: [
        "hxml"
      ],
      load() {
        return le(() => import("./haxe-7215664e.js"), [], import.meta.url).then((t) => pe(t.hxml));
      }
    }),
    ie.of({
      name: "HTTP",
      load() {
        return le(() => import("./http-e091c18d.js"), [], import.meta.url).then((t) => pe(t.http));
      }
    }),
    ie.of({
      name: "IDL",
      extensions: [
        "pro"
      ],
      load() {
        return le(() => import("./idl-91cb7788.js"), [], import.meta.url).then((t) => pe(t.idl));
      }
    }),
    ie.of({
      name: "JSON-LD",
      alias: [
        "jsonld"
      ],
      extensions: [
        "jsonld"
      ],
      load() {
        return le(() => import("./javascript-da64953c.js"), [], import.meta.url).then((t) => pe(t.jsonld));
      }
    }),
    ie.of({
      name: "Jinja2",
      extensions: [
        "j2",
        "jinja",
        "jinja2"
      ],
      load() {
        return le(() => import("./jinja2-580c43a7.js"), [], import.meta.url).then((t) => pe(t.jinja2));
      }
    }),
    ie.of({
      name: "Julia",
      extensions: [
        "jl"
      ],
      load() {
        return le(() => import("./julia-2f39a740.js"), [], import.meta.url).then((t) => pe(t.julia));
      }
    }),
    ie.of({
      name: "Kotlin",
      extensions: [
        "kt",
        "kts"
      ],
      load() {
        return le(() => import("./clike-be721a9d.js"), [], import.meta.url).then((t) => pe(t.kotlin));
      }
    }),
    ie.of({
      name: "LiveScript",
      alias: [
        "ls"
      ],
      extensions: [
        "ls"
      ],
      load() {
        return le(() => import("./livescript-a3318e59.js"), [], import.meta.url).then((t) => pe(t.liveScript));
      }
    }),
    ie.of({
      name: "Lua",
      extensions: [
        "lua"
      ],
      load() {
        return le(() => import("./lua-ee237842.js"), [], import.meta.url).then((t) => pe(t.lua));
      }
    }),
    ie.of({
      name: "mIRC",
      extensions: [
        "mrc"
      ],
      load() {
        return le(() => import("./mirc-c043bc0a.js"), [], import.meta.url).then((t) => pe(t.mirc));
      }
    }),
    ie.of({
      name: "Mathematica",
      extensions: [
        "m",
        "nb",
        "wl",
        "wls"
      ],
      load() {
        return le(() => import("./mathematica-4db1ec63.js"), [], import.meta.url).then((t) => pe(t.mathematica));
      }
    }),
    ie.of({
      name: "Modelica",
      extensions: [
        "mo"
      ],
      load() {
        return le(() => import("./modelica-c19c47b8.js"), [], import.meta.url).then((t) => pe(t.modelica));
      }
    }),
    ie.of({
      name: "MUMPS",
      extensions: [
        "mps"
      ],
      load() {
        return le(() => import("./mumps-82310ef4.js"), [], import.meta.url).then((t) => pe(t.mumps));
      }
    }),
    ie.of({
      name: "Mbox",
      extensions: [
        "mbox"
      ],
      load() {
        return le(() => import("./mbox-b40e52ca.js"), [], import.meta.url).then((t) => pe(t.mbox));
      }
    }),
    ie.of({
      name: "Nginx",
      filename: /nginx.*\.conf$/i,
      load() {
        return le(() => import("./nginx-0992a7c8.js"), [], import.meta.url).then((t) => pe(t.nginx));
      }
    }),
    ie.of({
      name: "NSIS",
      extensions: [
        "nsh",
        "nsi"
      ],
      load() {
        return le(() => import("./nsis-57810a88.js"), ["./nsis-57810a88.js","./simple-mode-6643bd24.js"], import.meta.url).then((t) => pe(t.nsis));
      }
    }),
    ie.of({
      name: "NTriples",
      extensions: [
        "nt",
        "nq"
      ],
      load() {
        return le(() => import("./ntriples-8490b09b.js"), [], import.meta.url).then((t) => pe(t.ntriples));
      }
    }),
    ie.of({
      name: "Objective-C",
      alias: [
        "objective-c",
        "objc"
      ],
      extensions: [
        "m"
      ],
      load() {
        return le(() => import("./clike-be721a9d.js"), [], import.meta.url).then((t) => pe(t.objectiveC));
      }
    }),
    ie.of({
      name: "Objective-C++",
      alias: [
        "objective-c++",
        "objc++"
      ],
      extensions: [
        "mm"
      ],
      load() {
        return le(() => import("./clike-be721a9d.js"), [], import.meta.url).then((t) => pe(t.objectiveCpp));
      }
    }),
    ie.of({
      name: "OCaml",
      extensions: [
        "ml",
        "mli",
        "mll",
        "mly"
      ],
      load() {
        return le(() => import("./mllike-1f866598.js"), [], import.meta.url).then((t) => pe(t.oCaml));
      }
    }),
    ie.of({
      name: "Octave",
      extensions: [
        "m"
      ],
      load() {
        return le(() => import("./octave-3f516c2f.js"), [], import.meta.url).then((t) => pe(t.octave));
      }
    }),
    ie.of({
      name: "Oz",
      extensions: [
        "oz"
      ],
      load() {
        return le(() => import("./oz-a640e05c.js"), [], import.meta.url).then((t) => pe(t.oz));
      }
    }),
    ie.of({
      name: "Pascal",
      extensions: [
        "p",
        "pas"
      ],
      load() {
        return le(() => import("./pascal-ed0353c0.js"), [], import.meta.url).then((t) => pe(t.pascal));
      }
    }),
    ie.of({
      name: "Perl",
      extensions: [
        "pl",
        "pm"
      ],
      load() {
        return le(() => import("./perl-a9455719.js"), [], import.meta.url).then((t) => pe(t.perl));
      }
    }),
    ie.of({
      name: "Pig",
      extensions: [
        "pig"
      ],
      load() {
        return le(() => import("./pig-3510ca5f.js"), [], import.meta.url).then((t) => pe(t.pig));
      }
    }),
    ie.of({
      name: "PowerShell",
      extensions: [
        "ps1",
        "psd1",
        "psm1"
      ],
      load() {
        return le(() => import("./powershell-c2c54630.js"), [], import.meta.url).then((t) => pe(t.powerShell));
      }
    }),
    ie.of({
      name: "Properties files",
      alias: [
        "ini",
        "properties"
      ],
      extensions: [
        "properties",
        "ini",
        "in"
      ],
      load() {
        return le(() => import("./properties-aba123c1.js"), [], import.meta.url).then((t) => pe(t.properties));
      }
    }),
    ie.of({
      name: "ProtoBuf",
      extensions: [
        "proto"
      ],
      load() {
        return le(() => import("./protobuf-1713bf80.js"), [], import.meta.url).then((t) => pe(t.protobuf));
      }
    }),
    ie.of({
      name: "Pug",
      alias: [
        "jade"
      ],
      extensions: [
        "pug",
        "jade"
      ],
      load() {
        return le(() => import("./pug-c3549eac.js"), ["./pug-c3549eac.js","./javascript-da64953c.js"], import.meta.url).then((t) => pe(t.pug));
      }
    }),
    ie.of({
      name: "Puppet",
      extensions: [
        "pp"
      ],
      load() {
        return le(() => import("./puppet-3229bfe4.js"), [], import.meta.url).then((t) => pe(t.puppet));
      }
    }),
    ie.of({
      name: "Q",
      extensions: [
        "q"
      ],
      load() {
        return le(() => import("./q-ddde97d0.js"), [], import.meta.url).then((t) => pe(t.q));
      }
    }),
    ie.of({
      name: "R",
      alias: [
        "rscript"
      ],
      extensions: [
        "r",
        "R"
      ],
      load() {
        return le(() => import("./r-3ca97919.js"), [], import.meta.url).then((t) => pe(t.r));
      }
    }),
    ie.of({
      name: "RPM Changes",
      load() {
        return le(() => import("./rpm-aa81b362.js"), [], import.meta.url).then((t) => pe(t.rpmChanges));
      }
    }),
    ie.of({
      name: "RPM Spec",
      extensions: [
        "spec"
      ],
      load() {
        return le(() => import("./rpm-aa81b362.js"), [], import.meta.url).then((t) => pe(t.rpmSpec));
      }
    }),
    ie.of({
      name: "Ruby",
      alias: [
        "jruby",
        "macruby",
        "rake",
        "rb",
        "rbx"
      ],
      extensions: [
        "rb"
      ],
      filename: /^(Gemfile|Rakefile)$/,
      load() {
        return le(() => import("./ruby-e88f1f8d.js"), [], import.meta.url).then((t) => pe(t.ruby));
      }
    }),
    ie.of({
      name: "SAS",
      extensions: [
        "sas"
      ],
      load() {
        return le(() => import("./sas-4096b960.js"), [], import.meta.url).then((t) => pe(t.sas));
      }
    }),
    ie.of({
      name: "Scala",
      extensions: [
        "scala"
      ],
      load() {
        return le(() => import("./clike-be721a9d.js"), [], import.meta.url).then((t) => pe(t.scala));
      }
    }),
    ie.of({
      name: "Scheme",
      extensions: [
        "scm",
        "ss"
      ],
      load() {
        return le(() => import("./scheme-ca3e6863.js"), [], import.meta.url).then((t) => pe(t.scheme));
      }
    }),
    ie.of({
      name: "Shell",
      alias: [
        "bash",
        "sh",
        "zsh"
      ],
      extensions: [
        "sh",
        "ksh",
        "bash"
      ],
      filename: /^PKGBUILD$/,
      load() {
        return le(() => import("./shell-61e14131.js"), [], import.meta.url).then((t) => pe(t.shell));
      }
    }),
    ie.of({
      name: "Sieve",
      extensions: [
        "siv",
        "sieve"
      ],
      load() {
        return le(() => import("./sieve-4b1eb6fb.js"), [], import.meta.url).then((t) => pe(t.sieve));
      }
    }),
    ie.of({
      name: "Smalltalk",
      extensions: [
        "st"
      ],
      load() {
        return le(() => import("./smalltalk-b41561ee.js"), [], import.meta.url).then((t) => pe(t.smalltalk));
      }
    }),
    ie.of({
      name: "Solr",
      load() {
        return le(() => import("./solr-eac40f87.js"), [], import.meta.url).then((t) => pe(t.solr));
      }
    }),
    ie.of({
      name: "SML",
      extensions: [
        "sml",
        "sig",
        "fun",
        "smackspec"
      ],
      load() {
        return le(() => import("./mllike-1f866598.js"), [], import.meta.url).then((t) => pe(t.sml));
      }
    }),
    ie.of({
      name: "SPARQL",
      alias: [
        "sparul"
      ],
      extensions: [
        "rq",
        "sparql"
      ],
      load() {
        return le(() => import("./sparql-a1ae2f33.js"), [], import.meta.url).then((t) => pe(t.sparql));
      }
    }),
    ie.of({
      name: "Spreadsheet",
      alias: [
        "excel",
        "formula"
      ],
      load() {
        return le(() => import("./spreadsheet-9f4dc4c6.js"), [], import.meta.url).then((t) => pe(t.spreadsheet));
      }
    }),
    ie.of({
      name: "Squirrel",
      extensions: [
        "nut"
      ],
      load() {
        return le(() => import("./clike-be721a9d.js"), [], import.meta.url).then((t) => pe(t.squirrel));
      }
    }),
    ie.of({
      name: "Stylus",
      extensions: [
        "styl"
      ],
      load() {
        return le(() => import("./stylus-db1355f1.js"), [], import.meta.url).then((t) => pe(t.stylus));
      }
    }),
    ie.of({
      name: "Swift",
      extensions: [
        "swift"
      ],
      load() {
        return le(() => import("./swift-b6dd686e.js"), [], import.meta.url).then((t) => pe(t.swift));
      }
    }),
    ie.of({
      name: "sTeX",
      load() {
        return le(() => import("./stex-611747c4.js"), [], import.meta.url).then((t) => pe(t.stex));
      }
    }),
    ie.of({
      name: "LaTeX",
      alias: [
        "tex"
      ],
      extensions: [
        "text",
        "ltx",
        "tex"
      ],
      load() {
        return le(() => import("./stex-611747c4.js"), [], import.meta.url).then((t) => pe(t.stex));
      }
    }),
    ie.of({
      name: "SystemVerilog",
      extensions: [
        "v",
        "sv",
        "svh"
      ],
      load() {
        return le(() => import("./verilog-701759f4.js"), [], import.meta.url).then((t) => pe(t.verilog));
      }
    }),
    ie.of({
      name: "Tcl",
      extensions: [
        "tcl"
      ],
      load() {
        return le(() => import("./tcl-9a9d281f.js"), [], import.meta.url).then((t) => pe(t.tcl));
      }
    }),
    ie.of({
      name: "Textile",
      extensions: [
        "textile"
      ],
      load() {
        return le(() => import("./textile-27197230.js"), [], import.meta.url).then((t) => pe(t.textile));
      }
    }),
    ie.of({
      name: "TiddlyWiki",
      load() {
        return le(() => import("./tiddlywiki-053c4b39.js"), [], import.meta.url).then((t) => pe(t.tiddlyWiki));
      }
    }),
    ie.of({
      name: "Tiki wiki",
      load() {
        return le(() => import("./tiki-f8970e14.js"), [], import.meta.url).then((t) => pe(t.tiki));
      }
    }),
    ie.of({
      name: "TOML",
      extensions: [
        "toml"
      ],
      load() {
        return le(() => import("./toml-024602c7.js"), [], import.meta.url).then((t) => pe(t.toml));
      }
    }),
    ie.of({
      name: "Troff",
      extensions: [
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9"
      ],
      load() {
        return le(() => import("./troff-1c50c70f.js"), [], import.meta.url).then((t) => pe(t.troff));
      }
    }),
    ie.of({
      name: "TTCN",
      extensions: [
        "ttcn",
        "ttcn3",
        "ttcnpp"
      ],
      load() {
        return le(() => import("./ttcn-a4846d83.js"), [], import.meta.url).then((t) => pe(t.ttcn));
      }
    }),
    ie.of({
      name: "TTCN_CFG",
      extensions: [
        "cfg"
      ],
      load() {
        return le(() => import("./ttcn-cfg-0c96bcc1.js"), [], import.meta.url).then((t) => pe(t.ttcnCfg));
      }
    }),
    ie.of({
      name: "Turtle",
      extensions: [
        "ttl"
      ],
      load() {
        return le(() => import("./turtle-b550492d.js"), [], import.meta.url).then((t) => pe(t.turtle));
      }
    }),
    ie.of({
      name: "Web IDL",
      extensions: [
        "webidl"
      ],
      load() {
        return le(() => import("./webidl-beade871.js"), [], import.meta.url).then((t) => pe(t.webIDL));
      }
    }),
    ie.of({
      name: "VB.NET",
      extensions: [
        "vb"
      ],
      load() {
        return le(() => import("./vb-e9655ff4.js"), [], import.meta.url).then((t) => pe(t.vb));
      }
    }),
    ie.of({
      name: "VBScript",
      extensions: [
        "vbs"
      ],
      load() {
        return le(() => import("./vbscript-e62417ba.js"), [], import.meta.url).then((t) => pe(t.vbScript));
      }
    }),
    ie.of({
      name: "Velocity",
      extensions: [
        "vtl"
      ],
      load() {
        return le(() => import("./velocity-5bdd1b6a.js"), [], import.meta.url).then((t) => pe(t.velocity));
      }
    }),
    ie.of({
      name: "Verilog",
      extensions: [
        "v"
      ],
      load() {
        return le(() => import("./verilog-701759f4.js"), [], import.meta.url).then((t) => pe(t.verilog));
      }
    }),
    ie.of({
      name: "VHDL",
      extensions: [
        "vhd",
        "vhdl"
      ],
      load() {
        return le(() => import("./vhdl-288f0dde.js"), [], import.meta.url).then((t) => pe(t.vhdl));
      }
    }),
    ie.of({
      name: "XQuery",
      extensions: [
        "xy",
        "xquery"
      ],
      load() {
        return le(() => import("./xquery-b8525bba.js"), [], import.meta.url).then((t) => pe(t.xQuery));
      }
    }),
    ie.of({
      name: "Yacas",
      extensions: [
        "ys"
      ],
      load() {
        return le(() => import("./yacas-d031e2ab.js"), [], import.meta.url).then((t) => pe(t.yacas));
      }
    }),
    ie.of({
      name: "Z80",
      extensions: [
        "z80"
      ],
      load() {
        return le(() => import("./z80-bb7f2654.js"), [], import.meta.url).then((t) => pe(t.z80));
      }
    }),
    ie.of({
      name: "MscGen",
      extensions: [
        "mscgen",
        "mscin",
        "msc"
      ],
      load() {
        return le(() => import("./mscgen-96577242.js"), [], import.meta.url).then((t) => pe(t.mscgen));
      }
    }),
    ie.of({
      name: "X\xF9",
      extensions: [
        "xu"
      ],
      load() {
        return le(() => import("./mscgen-96577242.js"), [], import.meta.url).then((t) => pe(t.xu));
      }
    }),
    ie.of({
      name: "MsGenny",
      extensions: [
        "msgenny"
      ],
      load() {
        return le(() => import("./mscgen-96577242.js"), [], import.meta.url).then((t) => pe(t.msgenny));
      }
    }),
    ie.of({
      name: "Vue",
      extensions: [
        "vue"
      ],
      load() {
        return le(() => import("./index-464a8b13.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-464a8b13.js","./index-c30f3063.js"], import.meta.url).then((t) => t.vue());
      }
    }),
    ie.of({
      name: "Angular Template",
      load() {
        return le(() => import("./index-350cc85a.js").then(async (m4) => {
          await m4.__tla;
          return m4;
        }), ["./index-350cc85a.js","./index-c30f3063.js"], import.meta.url).then((t) => t.angular());
      }
    })
  ], qet = (t, e, n) => {
    const r = n.filter((i) => !itt(i) && !i.changes.empty);
    if (r.length !== 0)
      return t.change((i) => {
        r.forEach((s) => {
          s.changes.iterChanges((o, a, l, c, u) => {
            dW(i, e.slice(), l, a - o, u.toString());
          });
        });
      }), _g(t.docSync());
  }, Ket = (t, e, n) => {
    let r = t.state.selection;
    for (const i of n) {
      const s = Jet(i, e, t.state);
      if (s != null) {
        const o = Za.of(s, t.state.doc.length, `
`);
        r = r.map(o, 1), t.dispatch({
          changes: o,
          annotations: lD.of({})
        });
      }
    }
    t.dispatch({
      selection: r,
      annotations: lD.of({})
    });
  };
  function Jet(t, e, n) {
    return t.action === "insert" ? ett(e, t) : t.action === "splice" ? ttt(e, t) : t.action === "del" ? ntt(e, t) : t.action === "put" ? rtt(e, t, n) : null;
  }
  function ett(t, e) {
    const n = D2(t, e.path);
    if (n == null)
      return [];
    const r = e.values.map((i) => i ? i.toString() : "").join("");
    return [
      {
        from: n,
        to: n,
        insert: r
      }
    ];
  }
  function ttt(t, e) {
    const n = D2(t, e.path);
    return n == null ? [] : [
      {
        from: n,
        insert: e.value
      }
    ];
  }
  function ntt(t, e) {
    const n = D2(t, e.path);
    if (n == null)
      return [];
    const r = e.length || 1;
    return [
      {
        from: n,
        to: n + r
      }
    ];
  }
  function rtt(t, e, n) {
    if (D2(t, [
      ...e.path,
      0
    ]) == null)
      return [];
    const i = n.doc.length;
    return typeof e.value != "string" ? [] : [
      {
        from: 0,
        to: i,
        insert: e.value
      }
    ];
  }
  function D2(t, e) {
    if (e.length !== t.length + 1)
      return null;
    for (let r = 0; r < t.length; r++)
      if (t[r] !== e[r])
        return null;
    const n = e[e.length - 1];
    return typeof n == "number" ? n : null;
  }
  const lD = Wd.define(), itt = (t) => !!t.annotation(lD), stt = ({ handle: t, path: e }) => {
    if (!t.isReady)
      throw new Error("ensure the handle is ready before initializing the automergeSyncPlugin");
    return ur.fromClass(class {
      constructor(n) {
        __publicField(this, "view");
        __publicField(this, "reconciledHeads", _g(t.docSync()));
        __publicField(this, "isProcessingCmTransaction", false);
        __publicField(this, "onChange", () => {
          if (this.isProcessingCmTransaction)
            return;
          const n = _g(t.docSync());
          if (hW(n, this.reconciledHeads))
            return;
          const r = Dye(t.docSync(), this.reconciledHeads, n);
          Ket(this.view, e, r), this.reconciledHeads = n;
        });
        this.view = n, this.onChange = this.onChange.bind(this), t.on("change", this.onChange);
      }
      update(n) {
        this.isProcessingCmTransaction = true;
        const r = qet(t, e, n.transactions);
        r && (this.reconciledHeads = r), this.isProcessingCmTransaction = false;
      }
      destroy() {
        t.off("change", this.onChange);
      }
    });
  };
  class Kn {
    lineAt(e) {
      if (e < 0 || e > this.length)
        throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);
      return this.lineInner(e, false, 1, 0);
    }
    line(e) {
      if (e < 1 || e > this.lines)
        throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);
      return this.lineInner(e, true, 1, 0);
    }
    replace(e, n, r) {
      [e, n] = pm(this, e, n);
      let i = [];
      return this.decompose(0, e, i, 2), r.length && r.decompose(0, r.length, i, 3), this.decompose(n, this.length, i, 1), Pl.from(i, this.length - (n - e) + r.length);
    }
    append(e) {
      return this.replace(this.length, this.length, e);
    }
    slice(e, n = this.length) {
      [e, n] = pm(this, e, n);
      let r = [];
      return this.decompose(e, n, r, 0), Pl.from(r, n - e);
    }
    eq(e) {
      if (e == this)
        return true;
      if (e.length != this.length || e.lines != this.lines)
        return false;
      let n = this.scanIdentical(e, 1), r = this.length - this.scanIdentical(e, -1), i = new fv(this), s = new fv(e);
      for (let o = n, a = n; ; ) {
        if (i.next(o), s.next(o), o = 0, i.lineBreak != s.lineBreak || i.done != s.done || i.value != s.value)
          return false;
        if (a += i.value.length, i.done || a >= r)
          return true;
      }
    }
    iter(e = 1) {
      return new fv(this, e);
    }
    iterRange(e, n = this.length) {
      return new $le(this, e, n);
    }
    iterLines(e, n) {
      let r;
      if (e == null)
        r = this.iter();
      else {
        n == null && (n = this.lines + 1);
        let i = this.line(e).from;
        r = this.iterRange(i, Math.max(i, n == this.lines + 1 ? this.length : n <= 1 ? 0 : this.line(n - 1).to));
      }
      return new Ale(r);
    }
    toString() {
      return this.sliceString(0);
    }
    toJSON() {
      let e = [];
      return this.flatten(e), e;
    }
    constructor() {
    }
    static of(e) {
      if (e.length == 0)
        throw new RangeError("A document must have at least one line");
      return e.length == 1 && !e[0] ? Kn.empty : e.length <= 32 ? new Yn(e) : Pl.from(Yn.split(e, []));
    }
  }
  class Yn extends Kn {
    constructor(e, n = ott(e)) {
      super(), this.text = e, this.length = n;
    }
    get lines() {
      return this.text.length;
    }
    get children() {
      return null;
    }
    lineInner(e, n, r, i) {
      for (let s = 0; ; s++) {
        let o = this.text[s], a = i + o.length;
        if ((n ? r : a) >= e)
          return new att(i, a, r, o);
        i = a + 1, r++;
      }
    }
    decompose(e, n, r, i) {
      let s = e <= 0 && n >= this.length ? this : new Yn(jV(this.text, e, n), Math.min(n, this.length) - Math.max(0, e));
      if (i & 1) {
        let o = r.pop(), a = Sb(s.text, o.text.slice(), 0, s.length);
        if (a.length <= 32)
          r.push(new Yn(a, o.length + s.length));
        else {
          let l = a.length >> 1;
          r.push(new Yn(a.slice(0, l)), new Yn(a.slice(l)));
        }
      } else
        r.push(s);
    }
    replace(e, n, r) {
      if (!(r instanceof Yn))
        return super.replace(e, n, r);
      [e, n] = pm(this, e, n);
      let i = Sb(this.text, Sb(r.text, jV(this.text, 0, e)), n), s = this.length + r.length - (n - e);
      return i.length <= 32 ? new Yn(i, s) : Pl.from(Yn.split(i, []), s);
    }
    sliceString(e, n = this.length, r = `
`) {
      [e, n] = pm(this, e, n);
      let i = "";
      for (let s = 0, o = 0; s <= n && o < this.text.length; o++) {
        let a = this.text[o], l = s + a.length;
        s > e && o && (i += r), e < l && n > s && (i += a.slice(Math.max(0, e - s), n - s)), s = l + 1;
      }
      return i;
    }
    flatten(e) {
      for (let n of this.text)
        e.push(n);
    }
    scanIdentical() {
      return 0;
    }
    static split(e, n) {
      let r = [], i = -1;
      for (let s of e)
        r.push(s), i += s.length + 1, r.length == 32 && (n.push(new Yn(r, i)), r = [], i = -1);
      return i > -1 && n.push(new Yn(r, i)), n;
    }
  }
  class Pl extends Kn {
    constructor(e, n) {
      super(), this.children = e, this.length = n, this.lines = 0;
      for (let r of e)
        this.lines += r.lines;
    }
    lineInner(e, n, r, i) {
      for (let s = 0; ; s++) {
        let o = this.children[s], a = i + o.length, l = r + o.lines - 1;
        if ((n ? l : a) >= e)
          return o.lineInner(e, n, r, i);
        i = a + 1, r = l + 1;
      }
    }
    decompose(e, n, r, i) {
      for (let s = 0, o = 0; o <= n && s < this.children.length; s++) {
        let a = this.children[s], l = o + a.length;
        if (e <= l && n >= o) {
          let c = i & ((o <= e ? 1 : 0) | (l >= n ? 2 : 0));
          o >= e && l <= n && !c ? r.push(a) : a.decompose(e - o, n - o, r, c);
        }
        o = l + 1;
      }
    }
    replace(e, n, r) {
      if ([e, n] = pm(this, e, n), r.lines < this.lines)
        for (let i = 0, s = 0; i < this.children.length; i++) {
          let o = this.children[i], a = s + o.length;
          if (e >= s && n <= a) {
            let l = o.replace(e - s, n - s, r), c = this.lines - o.lines + l.lines;
            if (l.lines < c >> 5 - 1 && l.lines > c >> 5 + 1) {
              let u = this.children.slice();
              return u[i] = l, new Pl(u, this.length - (n - e) + r.length);
            }
            return super.replace(s, a, l);
          }
          s = a + 1;
        }
      return super.replace(e, n, r);
    }
    sliceString(e, n = this.length, r = `
`) {
      [e, n] = pm(this, e, n);
      let i = "";
      for (let s = 0, o = 0; s < this.children.length && o <= n; s++) {
        let a = this.children[s], l = o + a.length;
        o > e && s && (i += r), e < l && n > o && (i += a.sliceString(e - o, n - o, r)), o = l + 1;
      }
      return i;
    }
    flatten(e) {
      for (let n of this.children)
        n.flatten(e);
    }
    scanIdentical(e, n) {
      if (!(e instanceof Pl))
        return 0;
      let r = 0, [i, s, o, a] = n > 0 ? [
        0,
        0,
        this.children.length,
        e.children.length
      ] : [
        this.children.length - 1,
        e.children.length - 1,
        -1,
        -1
      ];
      for (; ; i += n, s += n) {
        if (i == o || s == a)
          return r;
        let l = this.children[i], c = e.children[s];
        if (l != c)
          return r + l.scanIdentical(c, n);
        r += l.length + 1;
      }
    }
    static from(e, n = e.reduce((r, i) => r + i.length + 1, -1)) {
      let r = 0;
      for (let f of e)
        r += f.lines;
      if (r < 32) {
        let f = [];
        for (let y of e)
          y.flatten(f);
        return new Yn(f, n);
      }
      let i = Math.max(32, r >> 5), s = i << 1, o = i >> 1, a = [], l = 0, c = -1, u = [];
      function d(f) {
        let y;
        if (f.lines > s && f instanceof Pl)
          for (let g of f.children)
            d(g);
        else
          f.lines > o && (l > o || !l) ? (h(), a.push(f)) : f instanceof Yn && l && (y = u[u.length - 1]) instanceof Yn && f.lines + y.lines <= 32 ? (l += f.lines, c += f.length + 1, u[u.length - 1] = new Yn(y.text.concat(f.text), y.length + 1 + f.length)) : (l + f.lines > i && h(), l += f.lines, c += f.length + 1, u.push(f));
      }
      function h() {
        l != 0 && (a.push(u.length == 1 ? u[0] : Pl.from(u, c)), c = -1, l = u.length = 0);
      }
      for (let f of e)
        d(f);
      return h(), a.length == 1 ? a[0] : new Pl(a, n);
    }
  }
  Kn.empty = new Yn([
    ""
  ], 0);
  function ott(t) {
    let e = -1;
    for (let n of t)
      e += n.length + 1;
    return e;
  }
  function Sb(t, e, n = 0, r = 1e9) {
    for (let i = 0, s = 0, o = true; s < t.length && i <= r; s++) {
      let a = t[s], l = i + a.length;
      l >= n && (l > r && (a = a.slice(0, r - i)), i < n && (a = a.slice(n - i)), o ? (e[e.length - 1] += a, o = false) : e.push(a)), i = l + 1;
    }
    return e;
  }
  function jV(t, e, n) {
    return Sb(t, [
      ""
    ], e, n);
  }
  class fv {
    constructor(e, n = 1) {
      this.dir = n, this.done = false, this.lineBreak = false, this.value = "", this.nodes = [
        e
      ], this.offsets = [
        n > 0 ? 1 : (e instanceof Yn ? e.text.length : e.children.length) << 1
      ];
    }
    nextInner(e, n) {
      for (this.done = this.lineBreak = false; ; ) {
        let r = this.nodes.length - 1, i = this.nodes[r], s = this.offsets[r], o = s >> 1, a = i instanceof Yn ? i.text.length : i.children.length;
        if (o == (n > 0 ? a : 0)) {
          if (r == 0)
            return this.done = true, this.value = "", this;
          n > 0 && this.offsets[r - 1]++, this.nodes.pop(), this.offsets.pop();
        } else if ((s & 1) == (n > 0 ? 0 : 1)) {
          if (this.offsets[r] += n, e == 0)
            return this.lineBreak = true, this.value = `
`, this;
          e--;
        } else if (i instanceof Yn) {
          let l = i.text[o + (n < 0 ? -1 : 0)];
          if (this.offsets[r] += n, l.length > Math.max(0, e))
            return this.value = e == 0 ? l : n > 0 ? l.slice(e) : l.slice(0, l.length - e), this;
          e -= l.length;
        } else {
          let l = i.children[o + (n < 0 ? -1 : 0)];
          e > l.length ? (e -= l.length, this.offsets[r] += n) : (n < 0 && this.offsets[r]--, this.nodes.push(l), this.offsets.push(n > 0 ? 1 : (l instanceof Yn ? l.text.length : l.children.length) << 1));
        }
      }
    }
    next(e = 0) {
      return e < 0 && (this.nextInner(-e, -this.dir), e = this.value.length), this.nextInner(e, this.dir);
    }
  }
  class $le {
    constructor(e, n, r) {
      this.value = "", this.done = false, this.cursor = new fv(e, n > r ? -1 : 1), this.pos = n > r ? e.length : 0, this.from = Math.min(n, r), this.to = Math.max(n, r);
    }
    nextInner(e, n) {
      if (n < 0 ? this.pos <= this.from : this.pos >= this.to)
        return this.value = "", this.done = true, this;
      e += Math.max(0, n < 0 ? this.pos - this.to : this.from - this.pos);
      let r = n < 0 ? this.pos - this.from : this.to - this.pos;
      e > r && (e = r), r -= e;
      let { value: i } = this.cursor.next(e);
      return this.pos += (i.length + e) * n, this.value = i.length <= r ? i : n < 0 ? i.slice(i.length - r) : i.slice(0, r), this.done = !this.value, this;
    }
    next(e = 0) {
      return e < 0 ? e = Math.max(e, this.from - this.pos) : e > 0 && (e = Math.min(e, this.to - this.pos)), this.nextInner(e, this.cursor.dir);
    }
    get lineBreak() {
      return this.cursor.lineBreak && this.value != "";
    }
  }
  class Ale {
    constructor(e) {
      this.inner = e, this.afterBreak = true, this.value = "", this.done = false;
    }
    next(e = 0) {
      let { done: n, lineBreak: r, value: i } = this.inner.next(e);
      return n && this.afterBreak ? (this.value = "", this.afterBreak = false) : n ? (this.done = true, this.value = "") : r ? this.afterBreak ? this.value = "" : (this.afterBreak = true, this.next()) : (this.value = i, this.afterBreak = false), this;
    }
    get lineBreak() {
      return false;
    }
  }
  typeof Symbol < "u" && (Kn.prototype[Symbol.iterator] = function() {
    return this.iter();
  }, fv.prototype[Symbol.iterator] = $le.prototype[Symbol.iterator] = Ale.prototype[Symbol.iterator] = function() {
    return this;
  });
  class att {
    constructor(e, n, r, i) {
      this.from = e, this.to = n, this.number = r, this.text = i;
    }
    get length() {
      return this.to - this.from;
    }
  }
  function pm(t, e, n) {
    return e = Math.max(0, Math.min(t.length, e)), [
      e,
      Math.max(e, Math.min(t.length, n))
    ];
  }
  let bg = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t) => t ? parseInt(t, 36) : 1);
  for (let t = 1; t < bg.length; t++)
    bg[t] += bg[t - 1];
  function ltt(t) {
    for (let e = 1; e < bg.length; e += 2)
      if (bg[e] > t)
        return bg[e - 1] <= t;
    return false;
  }
  function NV(t) {
    return t >= 127462 && t <= 127487;
  }
  const QV = 8205;
  function Vl(t, e, n = true, r = true) {
    return (n ? Rle : ctt)(t, e, r);
  }
  function Rle(t, e, n) {
    if (e == t.length)
      return e;
    e && Mle(t.charCodeAt(e)) && Dle(t.charCodeAt(e - 1)) && e--;
    let r = Sl(t, e);
    for (e += Vu(r); e < t.length; ) {
      let i = Sl(t, e);
      if (r == QV || i == QV || n && ltt(i))
        e += Vu(i), r = i;
      else if (NV(i)) {
        let s = 0, o = e - 2;
        for (; o >= 0 && NV(Sl(t, o)); )
          s++, o -= 2;
        if (s % 2 == 0)
          break;
        e += 2;
      } else
        break;
    }
    return e;
  }
  function ctt(t, e, n) {
    for (; e > 0; ) {
      let r = Rle(t, e - 2, n);
      if (r < e)
        return r;
      e--;
    }
    return 0;
  }
  function Mle(t) {
    return t >= 56320 && t < 57344;
  }
  function Dle(t) {
    return t >= 55296 && t < 56320;
  }
  function Sl(t, e) {
    let n = t.charCodeAt(e);
    if (!Dle(n) || e + 1 == t.length)
      return n;
    let r = t.charCodeAt(e + 1);
    return Mle(r) ? (n - 55296 << 10) + (r - 56320) + 65536 : n;
  }
  function Lle(t) {
    return t <= 65535 ? String.fromCharCode(t) : (t -= 65536, String.fromCharCode((t >> 10) + 55296, (t & 1023) + 56320));
  }
  function Vu(t) {
    return t < 65536 ? 1 : 2;
  }
  const cD = /\r\n?|\n/;
  var Xu = function(t) {
    return t[t.Simple = 0] = "Simple", t[t.TrackDel = 1] = "TrackDel", t[t.TrackBefore = 2] = "TrackBefore", t[t.TrackAfter = 3] = "TrackAfter", t;
  }(Xu || (Xu = {}));
  class Dl {
    constructor(e) {
      this.sections = e;
    }
    get length() {
      let e = 0;
      for (let n = 0; n < this.sections.length; n += 2)
        e += this.sections[n];
      return e;
    }
    get newLength() {
      let e = 0;
      for (let n = 0; n < this.sections.length; n += 2) {
        let r = this.sections[n + 1];
        e += r < 0 ? this.sections[n] : r;
      }
      return e;
    }
    get empty() {
      return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0;
    }
    iterGaps(e) {
      for (let n = 0, r = 0, i = 0; n < this.sections.length; ) {
        let s = this.sections[n++], o = this.sections[n++];
        o < 0 ? (e(r, i, s), i += s) : i += o, r += s;
      }
    }
    iterChangedRanges(e, n = false) {
      uD(this, e, n);
    }
    get invertedDesc() {
      let e = [];
      for (let n = 0; n < this.sections.length; ) {
        let r = this.sections[n++], i = this.sections[n++];
        i < 0 ? e.push(r, i) : e.push(i, r);
      }
      return new Dl(e);
    }
    composeDesc(e) {
      return this.empty ? e : e.empty ? this : jle(this, e);
    }
    mapDesc(e, n = false) {
      return e.empty ? this : dD(this, e, n);
    }
    mapPos(e, n = -1, r = Xu.Simple) {
      let i = 0, s = 0;
      for (let o = 0; o < this.sections.length; ) {
        let a = this.sections[o++], l = this.sections[o++], c = i + a;
        if (l < 0) {
          if (c > e)
            return s + (e - i);
          s += a;
        } else {
          if (r != Xu.Simple && c >= e && (r == Xu.TrackDel && i < e && c > e || r == Xu.TrackBefore && i < e || r == Xu.TrackAfter && c > e))
            return null;
          if (c > e || c == e && n < 0 && !a)
            return e == i || n < 0 ? s : s + l;
          s += l;
        }
        i = c;
      }
      if (e > i)
        throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);
      return s;
    }
    touchesRange(e, n = e) {
      for (let r = 0, i = 0; r < this.sections.length && i <= n; ) {
        let s = this.sections[r++], o = this.sections[r++], a = i + s;
        if (o >= 0 && i <= n && a >= e)
          return i < e && a > n ? "cover" : true;
        i = a;
      }
      return false;
    }
    toString() {
      let e = "";
      for (let n = 0; n < this.sections.length; ) {
        let r = this.sections[n++], i = this.sections[n++];
        e += (e ? " " : "") + r + (i >= 0 ? ":" + i : "");
      }
      return e;
    }
    toJSON() {
      return this.sections;
    }
    static fromJSON(e) {
      if (!Array.isArray(e) || e.length % 2 || e.some((n) => typeof n != "number"))
        throw new RangeError("Invalid JSON representation of ChangeDesc");
      return new Dl(e);
    }
    static create(e) {
      return new Dl(e);
    }
  }
  class Fr extends Dl {
    constructor(e, n) {
      super(e), this.inserted = n;
    }
    apply(e) {
      if (this.length != e.length)
        throw new RangeError("Applying change set to a document with the wrong length");
      return uD(this, (n, r, i, s, o) => e = e.replace(i, i + (r - n), o), false), e;
    }
    mapDesc(e, n = false) {
      return dD(this, e, n, true);
    }
    invert(e) {
      let n = this.sections.slice(), r = [];
      for (let i = 0, s = 0; i < n.length; i += 2) {
        let o = n[i], a = n[i + 1];
        if (a >= 0) {
          n[i] = a, n[i + 1] = o;
          let l = i >> 1;
          for (; r.length < l; )
            r.push(Kn.empty);
          r.push(o ? e.slice(s, s + o) : Kn.empty);
        }
        s += o;
      }
      return new Fr(n, r);
    }
    compose(e) {
      return this.empty ? e : e.empty ? this : jle(this, e, true);
    }
    map(e, n = false) {
      return e.empty ? this : dD(this, e, n, true);
    }
    iterChanges(e, n = false) {
      uD(this, e, n);
    }
    get desc() {
      return Dl.create(this.sections);
    }
    filter(e) {
      let n = [], r = [], i = [], s = new EO(this);
      e:
        for (let o = 0, a = 0; ; ) {
          let l = o == e.length ? 1e9 : e[o++];
          for (; a < l || a == l && s.len == 0; ) {
            if (s.done)
              break e;
            let u = Math.min(s.len, l - a);
            ui(i, u, -1);
            let d = s.ins == -1 ? -1 : s.off == 0 ? s.ins : 0;
            ui(n, u, d), d > 0 && rd(r, n, s.text), s.forward(u), a += u;
          }
          let c = e[o++];
          for (; a < c; ) {
            if (s.done)
              break e;
            let u = Math.min(s.len, c - a);
            ui(n, u, -1), ui(i, u, s.ins == -1 ? -1 : s.off == 0 ? s.ins : 0), s.forward(u), a += u;
          }
        }
      return {
        changes: new Fr(n, r),
        filtered: Dl.create(i)
      };
    }
    toJSON() {
      let e = [];
      for (let n = 0; n < this.sections.length; n += 2) {
        let r = this.sections[n], i = this.sections[n + 1];
        i < 0 ? e.push(r) : i == 0 ? e.push([
          r
        ]) : e.push([
          r
        ].concat(this.inserted[n >> 1].toJSON()));
      }
      return e;
    }
    static of(e, n, r) {
      let i = [], s = [], o = 0, a = null;
      function l(u = false) {
        if (!u && !i.length)
          return;
        o < n && ui(i, n - o, -1);
        let d = new Fr(i, s);
        a = a ? a.compose(d.map(a)) : d, i = [], s = [], o = 0;
      }
      function c(u) {
        if (Array.isArray(u))
          for (let d of u)
            c(d);
        else if (u instanceof Fr) {
          if (u.length != n)
            throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);
          l(), a = a ? a.compose(u.map(a)) : u;
        } else {
          let { from: d, to: h = d, insert: f } = u;
          if (d > h || d < 0 || h > n)
            throw new RangeError(`Invalid change range ${d} to ${h} (in doc of length ${n})`);
          let y = f ? typeof f == "string" ? Kn.of(f.split(r || cD)) : f : Kn.empty, g = y.length;
          if (d == h && g == 0)
            return;
          d < o && l(), d > o && ui(i, d - o, -1), ui(i, h - d, g), rd(s, i, y), o = h;
        }
      }
      return c(e), l(!a), a;
    }
    static empty(e) {
      return new Fr(e ? [
        e,
        -1
      ] : [], []);
    }
    static fromJSON(e) {
      if (!Array.isArray(e))
        throw new RangeError("Invalid JSON representation of ChangeSet");
      let n = [], r = [];
      for (let i = 0; i < e.length; i++) {
        let s = e[i];
        if (typeof s == "number")
          n.push(s, -1);
        else {
          if (!Array.isArray(s) || typeof s[0] != "number" || s.some((o, a) => a && typeof o != "string"))
            throw new RangeError("Invalid JSON representation of ChangeSet");
          if (s.length == 1)
            n.push(s[0], 0);
          else {
            for (; r.length < i; )
              r.push(Kn.empty);
            r[i] = Kn.of(s.slice(1)), n.push(s[0], r[i].length);
          }
        }
      }
      return new Fr(n, r);
    }
    static createSet(e, n) {
      return new Fr(e, n);
    }
  }
  function ui(t, e, n, r = false) {
    if (e == 0 && n <= 0)
      return;
    let i = t.length - 2;
    i >= 0 && n <= 0 && n == t[i + 1] ? t[i] += e : e == 0 && t[i] == 0 ? t[i + 1] += n : r ? (t[i] += e, t[i + 1] += n) : t.push(e, n);
  }
  function rd(t, e, n) {
    if (n.length == 0)
      return;
    let r = e.length - 2 >> 1;
    if (r < t.length)
      t[t.length - 1] = t[t.length - 1].append(n);
    else {
      for (; t.length < r; )
        t.push(Kn.empty);
      t.push(n);
    }
  }
  function uD(t, e, n) {
    let r = t.inserted;
    for (let i = 0, s = 0, o = 0; o < t.sections.length; ) {
      let a = t.sections[o++], l = t.sections[o++];
      if (l < 0)
        i += a, s += a;
      else {
        let c = i, u = s, d = Kn.empty;
        for (; c += a, u += l, l && r && (d = d.append(r[o - 2 >> 1])), !(n || o == t.sections.length || t.sections[o + 1] < 0); )
          a = t.sections[o++], l = t.sections[o++];
        e(i, c, s, u, d), i = c, s = u;
      }
    }
  }
  function dD(t, e, n, r = false) {
    let i = [], s = r ? [] : null, o = new EO(t), a = new EO(e);
    for (let l = -1; ; )
      if (o.ins == -1 && a.ins == -1) {
        let c = Math.min(o.len, a.len);
        ui(i, c, -1), o.forward(c), a.forward(c);
      } else if (a.ins >= 0 && (o.ins < 0 || l == o.i || o.off == 0 && (a.len < o.len || a.len == o.len && !n))) {
        let c = a.len;
        for (ui(i, a.ins, -1); c; ) {
          let u = Math.min(o.len, c);
          o.ins >= 0 && l < o.i && o.len <= u && (ui(i, 0, o.ins), s && rd(s, i, o.text), l = o.i), o.forward(u), c -= u;
        }
        a.next();
      } else if (o.ins >= 0) {
        let c = 0, u = o.len;
        for (; u; )
          if (a.ins == -1) {
            let d = Math.min(u, a.len);
            c += d, u -= d, a.forward(d);
          } else if (a.ins == 0 && a.len < u)
            u -= a.len, a.next();
          else
            break;
        ui(i, c, l < o.i ? o.ins : 0), s && l < o.i && rd(s, i, o.text), l = o.i, o.forward(o.len - u);
      } else {
        if (o.done && a.done)
          return s ? Fr.createSet(i, s) : Dl.create(i);
        throw new Error("Mismatched change set lengths");
      }
  }
  function jle(t, e, n = false) {
    let r = [], i = n ? [] : null, s = new EO(t), o = new EO(e);
    for (let a = false; ; ) {
      if (s.done && o.done)
        return i ? Fr.createSet(r, i) : Dl.create(r);
      if (s.ins == 0)
        ui(r, s.len, 0, a), s.next();
      else if (o.len == 0 && !o.done)
        ui(r, 0, o.ins, a), i && rd(i, r, o.text), o.next();
      else {
        if (s.done || o.done)
          throw new Error("Mismatched change set lengths");
        {
          let l = Math.min(s.len2, o.len), c = r.length;
          if (s.ins == -1) {
            let u = o.ins == -1 ? -1 : o.off ? 0 : o.ins;
            ui(r, l, u, a), i && u && rd(i, r, o.text);
          } else
            o.ins == -1 ? (ui(r, s.off ? 0 : s.len, l, a), i && rd(i, r, s.textBit(l))) : (ui(r, s.off ? 0 : s.len, o.off ? 0 : o.ins, a), i && !o.off && rd(i, r, o.text));
          a = (s.ins > l || o.ins >= 0 && o.len > l) && (a || r.length > c), s.forward2(l), o.forward(l);
        }
      }
    }
  }
  class EO {
    constructor(e) {
      this.set = e, this.i = 0, this.next();
    }
    next() {
      let { sections: e } = this.set;
      this.i < e.length ? (this.len = e[this.i++], this.ins = e[this.i++]) : (this.len = 0, this.ins = -2), this.off = 0;
    }
    get done() {
      return this.ins == -2;
    }
    get len2() {
      return this.ins < 0 ? this.len : this.ins;
    }
    get text() {
      let { inserted: e } = this.set, n = this.i - 2 >> 1;
      return n >= e.length ? Kn.empty : e[n];
    }
    textBit(e) {
      let { inserted: n } = this.set, r = this.i - 2 >> 1;
      return r >= n.length && !e ? Kn.empty : n[r].slice(this.off, e == null ? void 0 : this.off + e);
    }
    forward(e) {
      e == this.len ? this.next() : (this.len -= e, this.off += e);
    }
    forward2(e) {
      this.ins == -1 ? this.forward(e) : e == this.ins ? this.next() : (this.ins -= e, this.off += e);
    }
  }
  class jh {
    constructor(e, n, r) {
      this.from = e, this.to = n, this.flags = r;
    }
    get anchor() {
      return this.flags & 32 ? this.to : this.from;
    }
    get head() {
      return this.flags & 32 ? this.from : this.to;
    }
    get empty() {
      return this.from == this.to;
    }
    get assoc() {
      return this.flags & 8 ? -1 : this.flags & 16 ? 1 : 0;
    }
    get bidiLevel() {
      let e = this.flags & 7;
      return e == 7 ? null : e;
    }
    get goalColumn() {
      let e = this.flags >> 6;
      return e == 16777215 ? void 0 : e;
    }
    map(e, n = -1) {
      let r, i;
      return this.empty ? r = i = e.mapPos(this.from, n) : (r = e.mapPos(this.from, 1), i = e.mapPos(this.to, -1)), r == this.from && i == this.to ? this : new jh(r, i, this.flags);
    }
    extend(e, n = e) {
      if (e <= this.anchor && n >= this.anchor)
        return He.range(e, n);
      let r = Math.abs(e - this.anchor) > Math.abs(n - this.anchor) ? e : n;
      return He.range(this.anchor, r);
    }
    eq(e, n = false) {
      return this.anchor == e.anchor && this.head == e.head && (!n || !this.empty || this.assoc == e.assoc);
    }
    toJSON() {
      return {
        anchor: this.anchor,
        head: this.head
      };
    }
    static fromJSON(e) {
      if (!e || typeof e.anchor != "number" || typeof e.head != "number")
        throw new RangeError("Invalid JSON representation for SelectionRange");
      return He.range(e.anchor, e.head);
    }
    static create(e, n, r) {
      return new jh(e, n, r);
    }
  }
  class He {
    constructor(e, n) {
      this.ranges = e, this.mainIndex = n;
    }
    map(e, n = -1) {
      return e.empty ? this : He.create(this.ranges.map((r) => r.map(e, n)), this.mainIndex);
    }
    eq(e, n = false) {
      if (this.ranges.length != e.ranges.length || this.mainIndex != e.mainIndex)
        return false;
      for (let r = 0; r < this.ranges.length; r++)
        if (!this.ranges[r].eq(e.ranges[r], n))
          return false;
      return true;
    }
    get main() {
      return this.ranges[this.mainIndex];
    }
    asSingle() {
      return this.ranges.length == 1 ? this : new He([
        this.main
      ], 0);
    }
    addRange(e, n = true) {
      return He.create([
        e
      ].concat(this.ranges), n ? 0 : this.mainIndex + 1);
    }
    replaceRange(e, n = this.mainIndex) {
      let r = this.ranges.slice();
      return r[n] = e, He.create(r, this.mainIndex);
    }
    toJSON() {
      return {
        ranges: this.ranges.map((e) => e.toJSON()),
        main: this.mainIndex
      };
    }
    static fromJSON(e) {
      if (!e || !Array.isArray(e.ranges) || typeof e.main != "number" || e.main >= e.ranges.length)
        throw new RangeError("Invalid JSON representation for EditorSelection");
      return new He(e.ranges.map((n) => jh.fromJSON(n)), e.main);
    }
    static single(e, n = e) {
      return new He([
        He.range(e, n)
      ], 0);
    }
    static create(e, n = 0) {
      if (e.length == 0)
        throw new RangeError("A selection needs at least one range");
      for (let r = 0, i = 0; i < e.length; i++) {
        let s = e[i];
        if (s.empty ? s.from <= r : s.from < r)
          return He.normalized(e.slice(), n);
        r = s.to;
      }
      return new He(e, n);
    }
    static cursor(e, n = 0, r, i) {
      return jh.create(e, e, (n == 0 ? 0 : n < 0 ? 8 : 16) | (r == null ? 7 : Math.min(6, r)) | (i ?? 16777215) << 6);
    }
    static range(e, n, r, i) {
      let s = (r ?? 16777215) << 6 | (i == null ? 7 : Math.min(6, i));
      return n < e ? jh.create(n, e, 48 | s) : jh.create(e, n, (n > e ? 8 : 0) | s);
    }
    static normalized(e, n = 0) {
      let r = e[n];
      e.sort((i, s) => i.from - s.from), n = e.indexOf(r);
      for (let i = 1; i < e.length; i++) {
        let s = e[i], o = e[i - 1];
        if (s.empty ? s.from <= o.to : s.from < o.to) {
          let a = o.from, l = Math.max(s.to, o.to);
          i <= n && n--, e.splice(--i, 2, s.anchor > s.head ? He.range(l, a) : He.range(a, l));
        }
      }
      return new He(e, n);
    }
  }
  function Nle(t, e) {
    for (let n of t.ranges)
      if (n.to > e)
        throw new RangeError("Selection points outside of document");
  }
  let sN = 0;
  class $r {
    constructor(e, n, r, i, s) {
      this.combine = e, this.compareInput = n, this.compare = r, this.isStatic = i, this.id = sN++, this.default = e([]), this.extensions = typeof s == "function" ? s(this) : s;
    }
    get reader() {
      return this;
    }
    static define(e = {}) {
      return new $r(e.combine || ((n) => n), e.compareInput || ((n, r) => n === r), e.compare || (e.combine ? (n, r) => n === r : oN), !!e.static, e.enables);
    }
    of(e) {
      return new wb([], this, 0, e);
    }
    compute(e, n) {
      if (this.isStatic)
        throw new Error("Can't compute a static facet");
      return new wb(e, this, 1, n);
    }
    computeN(e, n) {
      if (this.isStatic)
        throw new Error("Can't compute a static facet");
      return new wb(e, this, 2, n);
    }
    from(e, n) {
      return n || (n = (r) => r), this.compute([
        e
      ], (r) => n(r.field(e)));
    }
  }
  function oN(t, e) {
    return t == e || t.length == e.length && t.every((n, r) => n === e[r]);
  }
  class wb {
    constructor(e, n, r, i) {
      this.dependencies = e, this.facet = n, this.type = r, this.value = i, this.id = sN++;
    }
    dynamicSlot(e) {
      var n;
      let r = this.value, i = this.facet.compareInput, s = this.id, o = e[s] >> 1, a = this.type == 2, l = false, c = false, u = [];
      for (let d of this.dependencies)
        d == "doc" ? l = true : d == "selection" ? c = true : ((n = e[d.id]) !== null && n !== void 0 ? n : 1) & 1 || u.push(e[d.id]);
      return {
        create(d) {
          return d.values[o] = r(d), 1;
        },
        update(d, h) {
          if (l && h.docChanged || c && (h.docChanged || h.selection) || hD(d, u)) {
            let f = r(d);
            if (a ? !zV(f, d.values[o], i) : !i(f, d.values[o]))
              return d.values[o] = f, 1;
          }
          return 0;
        },
        reconfigure: (d, h) => {
          let f, y = h.config.address[s];
          if (y != null) {
            let g = kP(h, y);
            if (this.dependencies.every((O) => O instanceof $r ? h.facet(O) === d.facet(O) : O instanceof Hi ? h.field(O, false) == d.field(O, false) : true) || (a ? zV(f = r(d), g, i) : i(f = r(d), g)))
              return d.values[o] = g, 0;
          } else
            f = r(d);
          return d.values[o] = f, 1;
        }
      };
    }
  }
  function zV(t, e, n) {
    if (t.length != e.length)
      return false;
    for (let r = 0; r < t.length; r++)
      if (!n(t[r], e[r]))
        return false;
    return true;
  }
  function hD(t, e) {
    let n = false;
    for (let r of e)
      pv(t, r) & 1 && (n = true);
    return n;
  }
  function utt(t, e, n) {
    let r = n.map((l) => t[l.id]), i = n.map((l) => l.type), s = r.filter((l) => !(l & 1)), o = t[e.id] >> 1;
    function a(l) {
      let c = [];
      for (let u = 0; u < r.length; u++) {
        let d = kP(l, r[u]);
        if (i[u] == 2)
          for (let h of d)
            c.push(h);
        else
          c.push(d);
      }
      return e.combine(c);
    }
    return {
      create(l) {
        for (let c of r)
          pv(l, c);
        return l.values[o] = a(l), 1;
      },
      update(l, c) {
        if (!hD(l, s))
          return 0;
        let u = a(l);
        return e.compare(u, l.values[o]) ? 0 : (l.values[o] = u, 1);
      },
      reconfigure(l, c) {
        let u = hD(l, r), d = c.config.facets[e.id], h = c.facet(e);
        if (d && !u && oN(n, d))
          return l.values[o] = h, 0;
        let f = a(l);
        return e.compare(f, h) ? (l.values[o] = h, 0) : (l.values[o] = f, 1);
      }
    };
  }
  const FV = $r.define({
    static: true
  });
  class Hi {
    constructor(e, n, r, i, s) {
      this.id = e, this.createF = n, this.updateF = r, this.compareF = i, this.spec = s, this.provides = void 0;
    }
    static define(e) {
      let n = new Hi(sN++, e.create, e.update, e.compare || ((r, i) => r === i), e);
      return e.provide && (n.provides = e.provide(n)), n;
    }
    create(e) {
      let n = e.facet(FV).find((r) => r.field == this);
      return ((n == null ? void 0 : n.create) || this.createF)(e);
    }
    slot(e) {
      let n = e[this.id] >> 1;
      return {
        create: (r) => (r.values[n] = this.create(r), 1),
        update: (r, i) => {
          let s = r.values[n], o = this.updateF(s, i);
          return this.compareF(s, o) ? 0 : (r.values[n] = o, 1);
        },
        reconfigure: (r, i) => i.config.address[this.id] != null ? (r.values[n] = i.field(this), 0) : (r.values[n] = this.create(r), 1)
      };
    }
    init(e) {
      return [
        this,
        FV.of({
          field: this,
          create: e
        })
      ];
    }
    get extension() {
      return this;
    }
  }
  const kh = {
    lowest: 4,
    low: 3,
    default: 2,
    high: 1,
    highest: 0
  };
  function u0(t) {
    return (e) => new Qle(e, t);
  }
  const dtt = {
    highest: u0(kh.highest),
    high: u0(kh.high),
    default: u0(kh.default),
    low: u0(kh.low),
    lowest: u0(kh.lowest)
  };
  class Qle {
    constructor(e, n) {
      this.inner = e, this.prec = n;
    }
  }
  class L2 {
    of(e) {
      return new fD(this, e);
    }
    reconfigure(e) {
      return L2.reconfigure.of({
        compartment: this,
        extension: e
      });
    }
    get(e) {
      return e.config.compartments.get(this);
    }
  }
  class fD {
    constructor(e, n) {
      this.compartment = e, this.inner = n;
    }
  }
  class bP {
    constructor(e, n, r, i, s, o) {
      for (this.base = e, this.compartments = n, this.dynamicSlots = r, this.address = i, this.staticValues = s, this.facets = o, this.statusTemplate = []; this.statusTemplate.length < r.length; )
        this.statusTemplate.push(0);
    }
    staticFacet(e) {
      let n = this.address[e.id];
      return n == null ? e.default : this.staticValues[n >> 1];
    }
    static resolve(e, n, r) {
      let i = [], s = /* @__PURE__ */ Object.create(null), o = /* @__PURE__ */ new Map();
      for (let h of htt(e, n, o))
        h instanceof Hi ? i.push(h) : (s[h.facet.id] || (s[h.facet.id] = [])).push(h);
      let a = /* @__PURE__ */ Object.create(null), l = [], c = [];
      for (let h of i)
        a[h.id] = c.length << 1, c.push((f) => h.slot(f));
      let u = r == null ? void 0 : r.config.facets;
      for (let h in s) {
        let f = s[h], y = f[0].facet, g = u && u[h] || [];
        if (f.every((O) => O.type == 0))
          if (a[y.id] = l.length << 1 | 1, oN(g, f))
            l.push(r.facet(y));
          else {
            let O = y.combine(f.map((S) => S.value));
            l.push(r && y.compare(O, r.facet(y)) ? r.facet(y) : O);
          }
        else {
          for (let O of f)
            O.type == 0 ? (a[O.id] = l.length << 1 | 1, l.push(O.value)) : (a[O.id] = c.length << 1, c.push((S) => O.dynamicSlot(S)));
          a[y.id] = c.length << 1, c.push((O) => utt(O, y, f));
        }
      }
      let d = c.map((h) => h(a));
      return new bP(e, o, d, a, l, s);
    }
  }
  function htt(t, e, n) {
    let r = [
      [],
      [],
      [],
      [],
      []
    ], i = /* @__PURE__ */ new Map();
    function s(o, a) {
      let l = i.get(o);
      if (l != null) {
        if (l <= a)
          return;
        let c = r[l].indexOf(o);
        c > -1 && r[l].splice(c, 1), o instanceof fD && n.delete(o.compartment);
      }
      if (i.set(o, a), Array.isArray(o))
        for (let c of o)
          s(c, a);
      else if (o instanceof fD) {
        if (n.has(o.compartment))
          throw new RangeError("Duplicate use of compartment in extensions");
        let c = e.get(o.compartment) || o.inner;
        n.set(o.compartment, c), s(c, a);
      } else if (o instanceof Qle)
        s(o.inner, o.prec);
      else if (o instanceof Hi)
        r[a].push(o), o.provides && s(o.provides, a);
      else if (o instanceof wb)
        r[a].push(o), o.facet.extensions && s(o.facet.extensions, kh.default);
      else {
        let c = o.extension;
        if (!c)
          throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
        s(c, a);
      }
    }
    return s(t, kh.default), r.reduce((o, a) => o.concat(a));
  }
  function pv(t, e) {
    if (e & 1)
      return 2;
    let n = e >> 1, r = t.status[n];
    if (r == 4)
      throw new Error("Cyclic dependency between fields and/or facets");
    if (r & 2)
      return r;
    t.status[n] = 4;
    let i = t.computeSlot(t, t.config.dynamicSlots[n]);
    return t.status[n] = 2 | i;
  }
  function kP(t, e) {
    return e & 1 ? t.config.staticValues[e >> 1] : t.values[e >> 1];
  }
  const zle = $r.define(), pD = $r.define({
    combine: (t) => t.some((e) => e),
    static: true
  }), Fle = $r.define({
    combine: (t) => t.length ? t[0] : void 0,
    static: true
  }), Ble = $r.define(), Ule = $r.define(), Vle = $r.define(), Xle = $r.define({
    combine: (t) => t.length ? t[0] : false
  });
  class Zd {
    constructor(e, n) {
      this.type = e, this.value = n;
    }
    static define() {
      return new ftt();
    }
  }
  class ftt {
    of(e) {
      return new Zd(this, e);
    }
  }
  class ptt {
    constructor(e) {
      this.map = e;
    }
    of(e) {
      return new Dt(this, e);
    }
  }
  class Dt {
    constructor(e, n) {
      this.type = e, this.value = n;
    }
    map(e) {
      let n = this.type.map(this.value, e);
      return n === void 0 ? void 0 : n == this.value ? this : new Dt(this.type, n);
    }
    is(e) {
      return this.type == e;
    }
    static define(e = {}) {
      return new ptt(e.map || ((n) => n));
    }
    static mapEffects(e, n) {
      if (!e.length)
        return e;
      let r = [];
      for (let i of e) {
        let s = i.map(n);
        s && r.push(s);
      }
      return r;
    }
  }
  Dt.reconfigure = Dt.define();
  Dt.appendConfig = Dt.define();
  class Pr {
    constructor(e, n, r, i, s, o) {
      this.startState = e, this.changes = n, this.selection = r, this.effects = i, this.annotations = s, this.scrollIntoView = o, this._doc = null, this._state = null, r && Nle(r, n.newLength), s.some((a) => a.type == Pr.time) || (this.annotations = s.concat(Pr.time.of(Date.now())));
    }
    static create(e, n, r, i, s, o) {
      return new Pr(e, n, r, i, s, o);
    }
    get newDoc() {
      return this._doc || (this._doc = this.changes.apply(this.startState.doc));
    }
    get newSelection() {
      return this.selection || this.startState.selection.map(this.changes);
    }
    get state() {
      return this._state || this.startState.applyTransaction(this), this._state;
    }
    annotation(e) {
      for (let n of this.annotations)
        if (n.type == e)
          return n.value;
    }
    get docChanged() {
      return !this.changes.empty;
    }
    get reconfigured() {
      return this.startState.config != this.state.config;
    }
    isUserEvent(e) {
      let n = this.annotation(Pr.userEvent);
      return !!(n && (n == e || n.length > e.length && n.slice(0, e.length) == e && n[e.length] == "."));
    }
  }
  Pr.time = Zd.define();
  Pr.userEvent = Zd.define();
  Pr.addToHistory = Zd.define();
  Pr.remote = Zd.define();
  function gtt(t, e) {
    let n = [];
    for (let r = 0, i = 0; ; ) {
      let s, o;
      if (r < t.length && (i == e.length || e[i] >= t[r]))
        s = t[r++], o = t[r++];
      else if (i < e.length)
        s = e[i++], o = e[i++];
      else
        return n;
      !n.length || n[n.length - 1] < s ? n.push(s, o) : n[n.length - 1] < o && (n[n.length - 1] = o);
    }
  }
  function Wle(t, e, n) {
    var r;
    let i, s, o;
    return n ? (i = e.changes, s = Fr.empty(e.changes.length), o = t.changes.compose(e.changes)) : (i = e.changes.map(t.changes), s = t.changes.mapDesc(e.changes, true), o = t.changes.compose(i)), {
      changes: o,
      selection: e.selection ? e.selection.map(s) : (r = t.selection) === null || r === void 0 ? void 0 : r.map(i),
      effects: Dt.mapEffects(t.effects, i).concat(Dt.mapEffects(e.effects, s)),
      annotations: t.annotations.length ? t.annotations.concat(e.annotations) : e.annotations,
      scrollIntoView: t.scrollIntoView || e.scrollIntoView
    };
  }
  function gD(t, e, n) {
    let r = e.selection, i = kg(e.annotations);
    return e.userEvent && (i = i.concat(Pr.userEvent.of(e.userEvent))), {
      changes: e.changes instanceof Fr ? e.changes : Fr.of(e.changes || [], n, t.facet(Fle)),
      selection: r && (r instanceof He ? r : He.single(r.anchor, r.head)),
      effects: kg(e.effects),
      annotations: i,
      scrollIntoView: !!e.scrollIntoView
    };
  }
  function Zle(t, e, n) {
    let r = gD(t, e.length ? e[0] : {}, t.doc.length);
    e.length && e[0].filter === false && (n = false);
    for (let s = 1; s < e.length; s++) {
      e[s].filter === false && (n = false);
      let o = !!e[s].sequential;
      r = Wle(r, gD(t, e[s], o ? r.changes.newLength : t.doc.length), o);
    }
    let i = Pr.create(t, r.changes, r.selection, r.effects, r.annotations, r.scrollIntoView);
    return ytt(n ? mtt(i) : i);
  }
  function mtt(t) {
    let e = t.startState, n = true;
    for (let i of e.facet(Ble)) {
      let s = i(t);
      if (s === false) {
        n = false;
        break;
      }
      Array.isArray(s) && (n = n === true ? s : gtt(n, s));
    }
    if (n !== true) {
      let i, s;
      if (n === false)
        s = t.changes.invertedDesc, i = Fr.empty(e.doc.length);
      else {
        let o = t.changes.filter(n);
        i = o.changes, s = o.filtered.mapDesc(o.changes).invertedDesc;
      }
      t = Pr.create(e, i, t.selection && t.selection.map(s), Dt.mapEffects(t.effects, s), t.annotations, t.scrollIntoView);
    }
    let r = e.facet(Ule);
    for (let i = r.length - 1; i >= 0; i--) {
      let s = r[i](t);
      s instanceof Pr ? t = s : Array.isArray(s) && s.length == 1 && s[0] instanceof Pr ? t = s[0] : t = Zle(e, kg(s), false);
    }
    return t;
  }
  function ytt(t) {
    let e = t.startState, n = e.facet(Vle), r = t;
    for (let i = n.length - 1; i >= 0; i--) {
      let s = n[i](t);
      s && Object.keys(s).length && (r = Wle(r, gD(e, s, t.changes.newLength), true));
    }
    return r == t ? t : Pr.create(e, t.changes, t.selection, r.effects, r.annotations, r.scrollIntoView);
  }
  const vtt = [];
  function kg(t) {
    return t == null ? vtt : Array.isArray(t) ? t : [
      t
    ];
  }
  var Si = function(t) {
    return t[t.Word = 0] = "Word", t[t.Space = 1] = "Space", t[t.Other = 2] = "Other", t;
  }(Si || (Si = {}));
  const Ott = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  let mD;
  try {
    mD = new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
  } catch {
  }
  function Stt(t) {
    if (mD)
      return mD.test(t);
    for (let e = 0; e < t.length; e++) {
      let n = t[e];
      if (/\w/.test(n) || n > "\x80" && (n.toUpperCase() != n.toLowerCase() || Ott.test(n)))
        return true;
    }
    return false;
  }
  function wtt(t) {
    return (e) => {
      if (!/\S/.test(e))
        return Si.Space;
      if (Stt(e))
        return Si.Word;
      for (let n = 0; n < t.length; n++)
        if (e.indexOf(t[n]) > -1)
          return Si.Word;
      return Si.Other;
    };
  }
  class Hn {
    constructor(e, n, r, i, s, o) {
      this.config = e, this.doc = n, this.selection = r, this.values = i, this.status = e.statusTemplate.slice(), this.computeSlot = s, o && (o._state = this);
      for (let a = 0; a < this.config.dynamicSlots.length; a++)
        pv(this, a << 1);
      this.computeSlot = null;
    }
    field(e, n = true) {
      let r = this.config.address[e.id];
      if (r == null) {
        if (n)
          throw new RangeError("Field is not present in this state");
        return;
      }
      return pv(this, r), kP(this, r);
    }
    update(...e) {
      return Zle(this, e, true);
    }
    applyTransaction(e) {
      let n = this.config, { base: r, compartments: i } = n;
      for (let a of e.effects)
        a.is(L2.reconfigure) ? (n && (i = /* @__PURE__ */ new Map(), n.compartments.forEach((l, c) => i.set(c, l)), n = null), i.set(a.value.compartment, a.value.extension)) : a.is(Dt.reconfigure) ? (n = null, r = a.value) : a.is(Dt.appendConfig) && (n = null, r = kg(r).concat(a.value));
      let s;
      n ? s = e.startState.values.slice() : (n = bP.resolve(r, i, this), s = new Hn(n, this.doc, this.selection, n.dynamicSlots.map(() => null), (l, c) => c.reconfigure(l, this), null).values);
      let o = e.startState.facet(pD) ? e.newSelection : e.newSelection.asSingle();
      new Hn(n, e.newDoc, o, s, (a, l) => l.update(a, e), e);
    }
    replaceSelection(e) {
      return typeof e == "string" && (e = this.toText(e)), this.changeByRange((n) => ({
        changes: {
          from: n.from,
          to: n.to,
          insert: e
        },
        range: He.cursor(n.from + e.length)
      }));
    }
    changeByRange(e) {
      let n = this.selection, r = e(n.ranges[0]), i = this.changes(r.changes), s = [
        r.range
      ], o = kg(r.effects);
      for (let a = 1; a < n.ranges.length; a++) {
        let l = e(n.ranges[a]), c = this.changes(l.changes), u = c.map(i);
        for (let h = 0; h < a; h++)
          s[h] = s[h].map(u);
        let d = i.mapDesc(c, true);
        s.push(l.range.map(d)), i = i.compose(u), o = Dt.mapEffects(o, u).concat(Dt.mapEffects(kg(l.effects), d));
      }
      return {
        changes: i,
        selection: He.create(s, n.mainIndex),
        effects: o
      };
    }
    changes(e = []) {
      return e instanceof Fr ? e : Fr.of(e, this.doc.length, this.facet(Hn.lineSeparator));
    }
    toText(e) {
      return Kn.of(e.split(this.facet(Hn.lineSeparator) || cD));
    }
    sliceDoc(e = 0, n = this.doc.length) {
      return this.doc.sliceString(e, n, this.lineBreak);
    }
    facet(e) {
      let n = this.config.address[e.id];
      return n == null ? e.default : (pv(this, n), kP(this, n));
    }
    toJSON(e) {
      let n = {
        doc: this.sliceDoc(),
        selection: this.selection.toJSON()
      };
      if (e)
        for (let r in e) {
          let i = e[r];
          i instanceof Hi && this.config.address[i.id] != null && (n[r] = i.spec.toJSON(this.field(e[r]), this));
        }
      return n;
    }
    static fromJSON(e, n = {}, r) {
      if (!e || typeof e.doc != "string")
        throw new RangeError("Invalid JSON representation for EditorState");
      let i = [];
      if (r) {
        for (let s in r)
          if (Object.prototype.hasOwnProperty.call(e, s)) {
            let o = r[s], a = e[s];
            i.push(o.init((l) => o.spec.fromJSON(a, l)));
          }
      }
      return Hn.create({
        doc: e.doc,
        selection: He.fromJSON(e.selection),
        extensions: n.extensions ? i.concat([
          n.extensions
        ]) : i
      });
    }
    static create(e = {}) {
      let n = bP.resolve(e.extensions || [], /* @__PURE__ */ new Map()), r = e.doc instanceof Kn ? e.doc : Kn.of((e.doc || "").split(n.staticFacet(Hn.lineSeparator) || cD)), i = e.selection ? e.selection instanceof He ? e.selection : He.single(e.selection.anchor, e.selection.head) : He.single(0);
      return Nle(i, r.length), n.staticFacet(pD) || (i = i.asSingle()), new Hn(n, r, i, n.dynamicSlots.map(() => null), (s, o) => o.create(s), null);
    }
    get tabSize() {
      return this.facet(Hn.tabSize);
    }
    get lineBreak() {
      return this.facet(Hn.lineSeparator) || `
`;
    }
    get readOnly() {
      return this.facet(Xle);
    }
    phrase(e, ...n) {
      for (let r of this.facet(Hn.phrases))
        if (Object.prototype.hasOwnProperty.call(r, e)) {
          e = r[e];
          break;
        }
      return n.length && (e = e.replace(/\$(\$|\d*)/g, (r, i) => {
        if (i == "$")
          return "$";
        let s = +(i || 1);
        return !s || s > n.length ? r : n[s - 1];
      })), e;
    }
    languageDataAt(e, n, r = -1) {
      let i = [];
      for (let s of this.facet(zle))
        for (let o of s(this, n, r))
          Object.prototype.hasOwnProperty.call(o, e) && i.push(o[e]);
      return i;
    }
    charCategorizer(e) {
      return wtt(this.languageDataAt("wordChars", e).join(""));
    }
    wordAt(e) {
      let { text: n, from: r, length: i } = this.doc.lineAt(e), s = this.charCategorizer(e), o = e - r, a = e - r;
      for (; o > 0; ) {
        let l = Vl(n, o, false);
        if (s(n.slice(l, o)) != Si.Word)
          break;
        o = l;
      }
      for (; a < i; ) {
        let l = Vl(n, a);
        if (s(n.slice(a, l)) != Si.Word)
          break;
        a = l;
      }
      return o == a ? null : He.range(o + r, a + r);
    }
  }
  Hn.allowMultipleSelections = pD;
  Hn.tabSize = $r.define({
    combine: (t) => t.length ? t[0] : 4
  });
  Hn.lineSeparator = Fle;
  Hn.readOnly = Xle;
  Hn.phrases = $r.define({
    compare(t, e) {
      let n = Object.keys(t), r = Object.keys(e);
      return n.length == r.length && n.every((i) => t[i] == e[i]);
    }
  });
  Hn.languageData = zle;
  Hn.changeFilter = Ble;
  Hn.transactionFilter = Ule;
  Hn.transactionExtender = Vle;
  L2.reconfigure = Dt.define();
  function j2(t, e, n = {}) {
    let r = {};
    for (let i of t)
      for (let s of Object.keys(i)) {
        let o = i[s], a = r[s];
        if (a === void 0)
          r[s] = o;
        else if (!(a === o || o === void 0))
          if (Object.hasOwnProperty.call(n, s))
            r[s] = n[s](a, o);
          else
            throw new Error("Config merge conflict for field " + s);
      }
    for (let i in e)
      r[i] === void 0 && (r[i] = e[i]);
    return r;
  }
  class IO {
    eq(e) {
      return this == e;
    }
    range(e, n = e) {
      return yD.create(e, n, this);
    }
  }
  IO.prototype.startSide = IO.prototype.endSide = 0;
  IO.prototype.point = false;
  IO.prototype.mapMode = Xu.TrackDel;
  let yD = class Hle {
    constructor(e, n, r) {
      this.from = e, this.to = n, this.value = r;
    }
    static create(e, n, r) {
      return new Hle(e, n, r);
    }
  };
  function vD(t, e) {
    return t.from - e.from || t.value.startSide - e.value.startSide;
  }
  class aN {
    constructor(e, n, r, i) {
      this.from = e, this.to = n, this.value = r, this.maxPoint = i;
    }
    get length() {
      return this.to[this.to.length - 1];
    }
    findIndex(e, n, r, i = 0) {
      let s = r ? this.to : this.from;
      for (let o = i, a = s.length; ; ) {
        if (o == a)
          return o;
        let l = o + a >> 1, c = s[l] - e || (r ? this.value[l].endSide : this.value[l].startSide) - n;
        if (l == o)
          return c >= 0 ? o : a;
        c >= 0 ? a = l : o = l + 1;
      }
    }
    between(e, n, r, i) {
      for (let s = this.findIndex(n, -1e9, true), o = this.findIndex(r, 1e9, false, s); s < o; s++)
        if (i(this.from[s] + e, this.to[s] + e, this.value[s]) === false)
          return false;
    }
    map(e, n) {
      let r = [], i = [], s = [], o = -1, a = -1;
      for (let l = 0; l < this.value.length; l++) {
        let c = this.value[l], u = this.from[l] + e, d = this.to[l] + e, h, f;
        if (u == d) {
          let y = n.mapPos(u, c.startSide, c.mapMode);
          if (y == null || (h = f = y, c.startSide != c.endSide && (f = n.mapPos(u, c.endSide), f < h)))
            continue;
        } else if (h = n.mapPos(u, c.startSide), f = n.mapPos(d, c.endSide), h > f || h == f && c.startSide > 0 && c.endSide <= 0)
          continue;
        (f - h || c.endSide - c.startSide) < 0 || (o < 0 && (o = h), c.point && (a = Math.max(a, f - h)), r.push(c), i.push(h - o), s.push(f - o));
      }
      return {
        mapped: r.length ? new aN(i, s, r, a) : null,
        pos: o
      };
    }
  }
  class zi {
    constructor(e, n, r, i) {
      this.chunkPos = e, this.chunk = n, this.nextLayer = r, this.maxPoint = i;
    }
    static create(e, n, r, i) {
      return new zi(e, n, r, i);
    }
    get length() {
      let e = this.chunk.length - 1;
      return e < 0 ? 0 : Math.max(this.chunkEnd(e), this.nextLayer.length);
    }
    get size() {
      if (this.isEmpty)
        return 0;
      let e = this.nextLayer.size;
      for (let n of this.chunk)
        e += n.value.length;
      return e;
    }
    chunkEnd(e) {
      return this.chunkPos[e] + this.chunk[e].length;
    }
    update(e) {
      let { add: n = [], sort: r = false, filterFrom: i = 0, filterTo: s = this.length } = e, o = e.filter;
      if (n.length == 0 && !o)
        return this;
      if (r && (n = n.slice().sort(vD)), this.isEmpty)
        return n.length ? zi.of(n) : this;
      let a = new Yle(this, null, -1).goto(0), l = 0, c = [], u = new $O();
      for (; a.value || l < n.length; )
        if (l < n.length && (a.from - n[l].from || a.startSide - n[l].value.startSide) >= 0) {
          let d = n[l++];
          u.addInner(d.from, d.to, d.value) || c.push(d);
        } else
          a.rangeIndex == 1 && a.chunkIndex < this.chunk.length && (l == n.length || this.chunkEnd(a.chunkIndex) < n[l].from) && (!o || i > this.chunkEnd(a.chunkIndex) || s < this.chunkPos[a.chunkIndex]) && u.addChunk(this.chunkPos[a.chunkIndex], this.chunk[a.chunkIndex]) ? a.nextChunk() : ((!o || i > a.to || s < a.from || o(a.from, a.to, a.value)) && (u.addInner(a.from, a.to, a.value) || c.push(yD.create(a.from, a.to, a.value))), a.next());
      return u.finishInner(this.nextLayer.isEmpty && !c.length ? zi.empty : this.nextLayer.update({
        add: c,
        filter: o,
        filterFrom: i,
        filterTo: s
      }));
    }
    map(e) {
      if (e.empty || this.isEmpty)
        return this;
      let n = [], r = [], i = -1;
      for (let o = 0; o < this.chunk.length; o++) {
        let a = this.chunkPos[o], l = this.chunk[o], c = e.touchesRange(a, a + l.length);
        if (c === false)
          i = Math.max(i, l.maxPoint), n.push(l), r.push(e.mapPos(a));
        else if (c === true) {
          let { mapped: u, pos: d } = l.map(a, e);
          u && (i = Math.max(i, u.maxPoint), n.push(u), r.push(d));
        }
      }
      let s = this.nextLayer.map(e);
      return n.length == 0 ? s : new zi(r, n, s || zi.empty, i);
    }
    between(e, n, r) {
      if (!this.isEmpty) {
        for (let i = 0; i < this.chunk.length; i++) {
          let s = this.chunkPos[i], o = this.chunk[i];
          if (n >= s && e <= s + o.length && o.between(s, e - s, n - s, r) === false)
            return;
        }
        this.nextLayer.between(e, n, r);
      }
    }
    iter(e = 0) {
      return AO.from([
        this
      ]).goto(e);
    }
    get isEmpty() {
      return this.nextLayer == this;
    }
    static iter(e, n = 0) {
      return AO.from(e).goto(n);
    }
    static compare(e, n, r, i, s = -1) {
      let o = e.filter((d) => d.maxPoint > 0 || !d.isEmpty && d.maxPoint >= s), a = n.filter((d) => d.maxPoint > 0 || !d.isEmpty && d.maxPoint >= s), l = BV(o, a, r), c = new d0(o, l, s), u = new d0(a, l, s);
      r.iterGaps((d, h, f) => UV(c, d, u, h, f, i)), r.empty && r.length == 0 && UV(c, 0, u, 0, 0, i);
    }
    static eq(e, n, r = 0, i) {
      i == null && (i = 1e9 - 1);
      let s = e.filter((u) => !u.isEmpty && n.indexOf(u) < 0), o = n.filter((u) => !u.isEmpty && e.indexOf(u) < 0);
      if (s.length != o.length)
        return false;
      if (!s.length)
        return true;
      let a = BV(s, o), l = new d0(s, a, 0).goto(r), c = new d0(o, a, 0).goto(r);
      for (; ; ) {
        if (l.to != c.to || !OD(l.active, c.active) || l.point && (!c.point || !l.point.eq(c.point)))
          return false;
        if (l.to > i)
          return true;
        l.next(), c.next();
      }
    }
    static spans(e, n, r, i, s = -1) {
      let o = new d0(e, null, s).goto(n), a = n, l = o.openStart;
      for (; ; ) {
        let c = Math.min(o.to, r);
        if (o.point) {
          let u = o.activeForPoint(o.to), d = o.pointFrom < n ? u.length + 1 : o.point.startSide < 0 ? u.length : Math.min(u.length, l);
          i.point(a, c, o.point, u, d, o.pointRank), l = Math.min(o.openEnd(c), u.length);
        } else
          c > a && (i.span(a, c, o.active, l), l = o.openEnd(c));
        if (o.to > r)
          return l + (o.point && o.to > r ? 1 : 0);
        a = o.to, o.next();
      }
    }
    static of(e, n = false) {
      let r = new $O();
      for (let i of e instanceof yD ? [
        e
      ] : n ? xtt(e) : e)
        r.add(i.from, i.to, i.value);
      return r.finish();
    }
    static join(e) {
      if (!e.length)
        return zi.empty;
      let n = e[e.length - 1];
      for (let r = e.length - 2; r >= 0; r--)
        for (let i = e[r]; i != zi.empty; i = i.nextLayer)
          n = new zi(i.chunkPos, i.chunk, n, Math.max(i.maxPoint, n.maxPoint));
      return n;
    }
  }
  zi.empty = new zi([], [], null, -1);
  function xtt(t) {
    if (t.length > 1)
      for (let e = t[0], n = 1; n < t.length; n++) {
        let r = t[n];
        if (vD(e, r) > 0)
          return t.slice().sort(vD);
        e = r;
      }
    return t;
  }
  zi.empty.nextLayer = zi.empty;
  class $O {
    finishChunk(e) {
      this.chunks.push(new aN(this.from, this.to, this.value, this.maxPoint)), this.chunkPos.push(this.chunkStart), this.chunkStart = -1, this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint), this.maxPoint = -1, e && (this.from = [], this.to = [], this.value = []);
    }
    constructor() {
      this.chunks = [], this.chunkPos = [], this.chunkStart = -1, this.last = null, this.lastFrom = -1e9, this.lastTo = -1e9, this.from = [], this.to = [], this.value = [], this.maxPoint = -1, this.setMaxPoint = -1, this.nextLayer = null;
    }
    add(e, n, r) {
      this.addInner(e, n, r) || (this.nextLayer || (this.nextLayer = new $O())).add(e, n, r);
    }
    addInner(e, n, r) {
      let i = e - this.lastTo || r.startSide - this.last.endSide;
      if (i <= 0 && (e - this.lastFrom || r.startSide - this.last.startSide) < 0)
        throw new Error("Ranges must be added sorted by `from` position and `startSide`");
      return i < 0 ? false : (this.from.length == 250 && this.finishChunk(true), this.chunkStart < 0 && (this.chunkStart = e), this.from.push(e - this.chunkStart), this.to.push(n - this.chunkStart), this.last = r, this.lastFrom = e, this.lastTo = n, this.value.push(r), r.point && (this.maxPoint = Math.max(this.maxPoint, n - e)), true);
    }
    addChunk(e, n) {
      if ((e - this.lastTo || n.value[0].startSide - this.last.endSide) < 0)
        return false;
      this.from.length && this.finishChunk(true), this.setMaxPoint = Math.max(this.setMaxPoint, n.maxPoint), this.chunks.push(n), this.chunkPos.push(e);
      let r = n.value.length - 1;
      return this.last = n.value[r], this.lastFrom = n.from[r] + e, this.lastTo = n.to[r] + e, true;
    }
    finish() {
      return this.finishInner(zi.empty);
    }
    finishInner(e) {
      if (this.from.length && this.finishChunk(false), this.chunks.length == 0)
        return e;
      let n = zi.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(e) : e, this.setMaxPoint);
      return this.from = null, n;
    }
  }
  function BV(t, e, n) {
    let r = /* @__PURE__ */ new Map();
    for (let s of t)
      for (let o = 0; o < s.chunk.length; o++)
        s.chunk[o].maxPoint <= 0 && r.set(s.chunk[o], s.chunkPos[o]);
    let i = /* @__PURE__ */ new Set();
    for (let s of e)
      for (let o = 0; o < s.chunk.length; o++) {
        let a = r.get(s.chunk[o]);
        a != null && (n ? n.mapPos(a) : a) == s.chunkPos[o] && !(n == null ? void 0 : n.touchesRange(a, a + s.chunk[o].length)) && i.add(s.chunk[o]);
      }
    return i;
  }
  class Yle {
    constructor(e, n, r, i = 0) {
      this.layer = e, this.skip = n, this.minPoint = r, this.rank = i;
    }
    get startSide() {
      return this.value ? this.value.startSide : 0;
    }
    get endSide() {
      return this.value ? this.value.endSide : 0;
    }
    goto(e, n = -1e9) {
      return this.chunkIndex = this.rangeIndex = 0, this.gotoInner(e, n, false), this;
    }
    gotoInner(e, n, r) {
      for (; this.chunkIndex < this.layer.chunk.length; ) {
        let i = this.layer.chunk[this.chunkIndex];
        if (!(this.skip && this.skip.has(i) || this.layer.chunkEnd(this.chunkIndex) < e || i.maxPoint < this.minPoint))
          break;
        this.chunkIndex++, r = false;
      }
      if (this.chunkIndex < this.layer.chunk.length) {
        let i = this.layer.chunk[this.chunkIndex].findIndex(e - this.layer.chunkPos[this.chunkIndex], n, true);
        (!r || this.rangeIndex < i) && this.setRangeIndex(i);
      }
      this.next();
    }
    forward(e, n) {
      (this.to - e || this.endSide - n) < 0 && this.gotoInner(e, n, true);
    }
    next() {
      for (; ; )
        if (this.chunkIndex == this.layer.chunk.length) {
          this.from = this.to = 1e9, this.value = null;
          break;
        } else {
          let e = this.layer.chunkPos[this.chunkIndex], n = this.layer.chunk[this.chunkIndex], r = e + n.from[this.rangeIndex];
          if (this.from = r, this.to = e + n.to[this.rangeIndex], this.value = n.value[this.rangeIndex], this.setRangeIndex(this.rangeIndex + 1), this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
            break;
        }
    }
    setRangeIndex(e) {
      if (e == this.layer.chunk[this.chunkIndex].value.length) {
        if (this.chunkIndex++, this.skip)
          for (; this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]); )
            this.chunkIndex++;
        this.rangeIndex = 0;
      } else
        this.rangeIndex = e;
    }
    nextChunk() {
      this.chunkIndex++, this.rangeIndex = 0, this.next();
    }
    compare(e) {
      return this.from - e.from || this.startSide - e.startSide || this.rank - e.rank || this.to - e.to || this.endSide - e.endSide;
    }
  }
  class AO {
    constructor(e) {
      this.heap = e;
    }
    static from(e, n = null, r = -1) {
      let i = [];
      for (let s = 0; s < e.length; s++)
        for (let o = e[s]; !o.isEmpty; o = o.nextLayer)
          o.maxPoint >= r && i.push(new Yle(o, n, r, s));
      return i.length == 1 ? i[0] : new AO(i);
    }
    get startSide() {
      return this.value ? this.value.startSide : 0;
    }
    goto(e, n = -1e9) {
      for (let r of this.heap)
        r.goto(e, n);
      for (let r = this.heap.length >> 1; r >= 0; r--)
        P$(this.heap, r);
      return this.next(), this;
    }
    forward(e, n) {
      for (let r of this.heap)
        r.forward(e, n);
      for (let r = this.heap.length >> 1; r >= 0; r--)
        P$(this.heap, r);
      (this.to - e || this.value.endSide - n) < 0 && this.next();
    }
    next() {
      if (this.heap.length == 0)
        this.from = this.to = 1e9, this.value = null, this.rank = -1;
      else {
        let e = this.heap[0];
        this.from = e.from, this.to = e.to, this.value = e.value, this.rank = e.rank, e.value && e.next(), P$(this.heap, 0);
      }
    }
  }
  function P$(t, e) {
    for (let n = t[e]; ; ) {
      let r = (e << 1) + 1;
      if (r >= t.length)
        break;
      let i = t[r];
      if (r + 1 < t.length && i.compare(t[r + 1]) >= 0 && (i = t[r + 1], r++), n.compare(i) < 0)
        break;
      t[r] = n, t[e] = i, e = r;
    }
  }
  class d0 {
    constructor(e, n, r) {
      this.minPoint = r, this.active = [], this.activeTo = [], this.activeRank = [], this.minActive = -1, this.point = null, this.pointFrom = 0, this.pointRank = 0, this.to = -1e9, this.endSide = 0, this.openStart = -1, this.cursor = AO.from(e, n, r);
    }
    goto(e, n = -1e9) {
      return this.cursor.goto(e, n), this.active.length = this.activeTo.length = this.activeRank.length = 0, this.minActive = -1, this.to = e, this.endSide = n, this.openStart = -1, this.next(), this;
    }
    forward(e, n) {
      for (; this.minActive > -1 && (this.activeTo[this.minActive] - e || this.active[this.minActive].endSide - n) < 0; )
        this.removeActive(this.minActive);
      this.cursor.forward(e, n);
    }
    removeActive(e) {
      mx(this.active, e), mx(this.activeTo, e), mx(this.activeRank, e), this.minActive = VV(this.active, this.activeTo);
    }
    addActive(e) {
      let n = 0, { value: r, to: i, rank: s } = this.cursor;
      for (; n < this.activeRank.length && (s - this.activeRank[n] || i - this.activeTo[n]) > 0; )
        n++;
      yx(this.active, n, r), yx(this.activeTo, n, i), yx(this.activeRank, n, s), e && yx(e, n, this.cursor.from), this.minActive = VV(this.active, this.activeTo);
    }
    next() {
      let e = this.to, n = this.point;
      this.point = null;
      let r = this.openStart < 0 ? [] : null;
      for (; ; ) {
        let i = this.minActive;
        if (i > -1 && (this.activeTo[i] - this.cursor.from || this.active[i].endSide - this.cursor.startSide) < 0) {
          if (this.activeTo[i] > e) {
            this.to = this.activeTo[i], this.endSide = this.active[i].endSide;
            break;
          }
          this.removeActive(i), r && mx(r, i);
        } else if (this.cursor.value)
          if (this.cursor.from > e) {
            this.to = this.cursor.from, this.endSide = this.cursor.startSide;
            break;
          } else {
            let s = this.cursor.value;
            if (!s.point)
              this.addActive(r), this.cursor.next();
            else if (n && this.cursor.to == this.to && this.cursor.from < this.cursor.to)
              this.cursor.next();
            else {
              this.point = s, this.pointFrom = this.cursor.from, this.pointRank = this.cursor.rank, this.to = this.cursor.to, this.endSide = s.endSide, this.cursor.next(), this.forward(this.to, this.endSide);
              break;
            }
          }
        else {
          this.to = this.endSide = 1e9;
          break;
        }
      }
      if (r) {
        this.openStart = 0;
        for (let i = r.length - 1; i >= 0 && r[i] < e; i--)
          this.openStart++;
      }
    }
    activeForPoint(e) {
      if (!this.active.length)
        return this.active;
      let n = [];
      for (let r = this.active.length - 1; r >= 0 && !(this.activeRank[r] < this.pointRank); r--)
        (this.activeTo[r] > e || this.activeTo[r] == e && this.active[r].endSide >= this.point.endSide) && n.push(this.active[r]);
      return n.reverse();
    }
    openEnd(e) {
      let n = 0;
      for (let r = this.activeTo.length - 1; r >= 0 && this.activeTo[r] > e; r--)
        n++;
      return n;
    }
  }
  function UV(t, e, n, r, i, s) {
    t.goto(e), n.goto(r);
    let o = r + i, a = r, l = r - e;
    for (; ; ) {
      let c = t.to + l - n.to || t.endSide - n.endSide, u = c < 0 ? t.to + l : n.to, d = Math.min(u, o);
      if (t.point || n.point ? t.point && n.point && (t.point == n.point || t.point.eq(n.point)) && OD(t.activeForPoint(t.to), n.activeForPoint(n.to)) || s.comparePoint(a, d, t.point, n.point) : d > a && !OD(t.active, n.active) && s.compareRange(a, d, t.active, n.active), u > o)
        break;
      a = u, c <= 0 && t.next(), c >= 0 && n.next();
    }
  }
  function OD(t, e) {
    if (t.length != e.length)
      return false;
    for (let n = 0; n < t.length; n++)
      if (t[n] != e[n] && !t[n].eq(e[n]))
        return false;
    return true;
  }
  function mx(t, e) {
    for (let n = e, r = t.length - 1; n < r; n++)
      t[n] = t[n + 1];
    t.pop();
  }
  function yx(t, e, n) {
    for (let r = t.length - 1; r >= e; r--)
      t[r + 1] = t[r];
    t[e] = n;
  }
  function VV(t, e) {
    let n = -1, r = 1e9;
    for (let i = 0; i < e.length; i++)
      (e[i] - r || t[i].endSide - t[n].endSide) < 0 && (n = i, r = e[i]);
    return n;
  }
  function lN(t, e, n = t.length) {
    let r = 0;
    for (let i = 0; i < n; )
      t.charCodeAt(i) == 9 ? (r += e - r % e, i++) : (r++, i = Vl(t, i));
    return r;
  }
  const btt = 1024;
  let ktt = 0;
  class Bn {
    constructor(e = {}) {
      this.id = ktt++, this.perNode = !!e.perNode, this.deserialize = e.deserialize || (() => {
        throw new Error("This node type doesn't define a deserialize function");
      });
    }
    add(e) {
      if (this.perNode)
        throw new RangeError("Can't add per-node props to node types");
      return typeof e != "function" && (e = qc.match(e)), (n) => {
        let r = e(n);
        return r === void 0 ? null : [
          this,
          r
        ];
      };
    }
  }
  Bn.closedBy = new Bn({
    deserialize: (t) => t.split(" ")
  });
  Bn.openedBy = new Bn({
    deserialize: (t) => t.split(" ")
  });
  Bn.group = new Bn({
    deserialize: (t) => t.split(" ")
  });
  Bn.isolate = new Bn({
    deserialize: (t) => {
      if (t && t != "rtl" && t != "ltr" && t != "auto")
        throw new RangeError("Invalid value for isolate: " + t);
      return t || "auto";
    }
  });
  Bn.contextHash = new Bn({
    perNode: true
  });
  Bn.lookAhead = new Bn({
    perNode: true
  });
  Bn.mounted = new Bn({
    perNode: true
  });
  class PP {
    constructor(e, n, r) {
      this.tree = e, this.overlay = n, this.parser = r;
    }
    static get(e) {
      return e && e.props && e.props[Bn.mounted.id];
    }
  }
  const Ptt = /* @__PURE__ */ Object.create(null);
  class qc {
    constructor(e, n, r, i = 0) {
      this.name = e, this.props = n, this.id = r, this.flags = i;
    }
    static define(e) {
      let n = e.props && e.props.length ? /* @__PURE__ */ Object.create(null) : Ptt, r = (e.top ? 1 : 0) | (e.skipped ? 2 : 0) | (e.error ? 4 : 0) | (e.name == null ? 8 : 0), i = new qc(e.name || "", n, e.id, r);
      if (e.props) {
        for (let s of e.props)
          if (Array.isArray(s) || (s = s(i)), s) {
            if (s[0].perNode)
              throw new RangeError("Can't store a per-node prop on a node type");
            n[s[0].id] = s[1];
          }
      }
      return i;
    }
    prop(e) {
      return this.props[e.id];
    }
    get isTop() {
      return (this.flags & 1) > 0;
    }
    get isSkipped() {
      return (this.flags & 2) > 0;
    }
    get isError() {
      return (this.flags & 4) > 0;
    }
    get isAnonymous() {
      return (this.flags & 8) > 0;
    }
    is(e) {
      if (typeof e == "string") {
        if (this.name == e)
          return true;
        let n = this.prop(Bn.group);
        return n ? n.indexOf(e) > -1 : false;
      }
      return this.id == e;
    }
    static match(e) {
      let n = /* @__PURE__ */ Object.create(null);
      for (let r in e)
        for (let i of r.split(" "))
          n[i] = e[r];
      return (r) => {
        for (let i = r.prop(Bn.group), s = -1; s < (i ? i.length : 0); s++) {
          let o = n[s < 0 ? r.name : i[s]];
          if (o)
            return o;
        }
      };
    }
  }
  qc.none = new qc("", /* @__PURE__ */ Object.create(null), 0, 8);
  const vx = /* @__PURE__ */ new WeakMap(), XV = /* @__PURE__ */ new WeakMap();
  var fi;
  (function(t) {
    t[t.ExcludeBuffers = 1] = "ExcludeBuffers", t[t.IncludeAnonymous = 2] = "IncludeAnonymous", t[t.IgnoreMounts = 4] = "IgnoreMounts", t[t.IgnoreOverlays = 8] = "IgnoreOverlays";
  })(fi || (fi = {}));
  class Fa {
    constructor(e, n, r, i, s) {
      if (this.type = e, this.children = n, this.positions = r, this.length = i, this.props = null, s && s.length) {
        this.props = /* @__PURE__ */ Object.create(null);
        for (let [o, a] of s)
          this.props[typeof o == "number" ? o : o.id] = a;
      }
    }
    toString() {
      let e = PP.get(this);
      if (e && !e.overlay)
        return e.tree.toString();
      let n = "";
      for (let r of this.children) {
        let i = r.toString();
        i && (n && (n += ","), n += i);
      }
      return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (n.length ? "(" + n + ")" : "") : n;
    }
    cursor(e = 0) {
      return new wD(this.topNode, e);
    }
    cursorAt(e, n = 0, r = 0) {
      let i = vx.get(this) || this.topNode, s = new wD(i);
      return s.moveTo(e, n), vx.set(this, s._tree), s;
    }
    get topNode() {
      return new Ko(this, 0, 0, null);
    }
    resolve(e, n = 0) {
      let r = RO(vx.get(this) || this.topNode, e, n, false);
      return vx.set(this, r), r;
    }
    resolveInner(e, n = 0) {
      let r = RO(XV.get(this) || this.topNode, e, n, true);
      return XV.set(this, r), r;
    }
    resolveStack(e, n = 0) {
      return Ttt(this, e, n);
    }
    iterate(e) {
      let { enter: n, leave: r, from: i = 0, to: s = this.length } = e, o = e.mode || 0, a = (o & fi.IncludeAnonymous) > 0;
      for (let l = this.cursor(o | fi.IncludeAnonymous); ; ) {
        let c = false;
        if (l.from <= s && l.to >= i && (!a && l.type.isAnonymous || n(l) !== false)) {
          if (l.firstChild())
            continue;
          c = true;
        }
        for (; c && r && (a || !l.type.isAnonymous) && r(l), !l.nextSibling(); ) {
          if (!l.parent())
            return;
          c = true;
        }
      }
    }
    prop(e) {
      return e.perNode ? this.props ? this.props[e.id] : void 0 : this.type.prop(e);
    }
    get propValues() {
      let e = [];
      if (this.props)
        for (let n in this.props)
          e.push([
            +n,
            this.props[n]
          ]);
      return e;
    }
    balance(e = {}) {
      return this.children.length <= 8 ? this : dN(qc.none, this.children, this.positions, 0, this.children.length, 0, this.length, (n, r, i) => new Fa(this.type, n, r, i, this.propValues), e.makeTree || ((n, r, i) => new Fa(qc.none, n, r, i)));
    }
    static build(e) {
      return Ett(e);
    }
  }
  Fa.empty = new Fa(qc.none, [], [], 0);
  class cN {
    constructor(e, n) {
      this.buffer = e, this.index = n;
    }
    get id() {
      return this.buffer[this.index - 4];
    }
    get start() {
      return this.buffer[this.index - 3];
    }
    get end() {
      return this.buffer[this.index - 2];
    }
    get size() {
      return this.buffer[this.index - 1];
    }
    get pos() {
      return this.index;
    }
    next() {
      this.index -= 4;
    }
    fork() {
      return new cN(this.buffer, this.index);
    }
  }
  class Ad {
    constructor(e, n, r) {
      this.buffer = e, this.length = n, this.set = r;
    }
    get type() {
      return qc.none;
    }
    toString() {
      let e = [];
      for (let n = 0; n < this.buffer.length; )
        e.push(this.childString(n)), n = this.buffer[n + 3];
      return e.join(",");
    }
    childString(e) {
      let n = this.buffer[e], r = this.buffer[e + 3], i = this.set.types[n], s = i.name;
      if (/\W/.test(s) && !i.isError && (s = JSON.stringify(s)), e += 4, r == e)
        return s;
      let o = [];
      for (; e < r; )
        o.push(this.childString(e)), e = this.buffer[e + 3];
      return s + "(" + o.join(",") + ")";
    }
    findChild(e, n, r, i, s) {
      let { buffer: o } = this, a = -1;
      for (let l = e; l != n && !(Gle(s, i, o[l + 1], o[l + 2]) && (a = l, r > 0)); l = o[l + 3])
        ;
      return a;
    }
    slice(e, n, r) {
      let i = this.buffer, s = new Uint16Array(n - e), o = 0;
      for (let a = e, l = 0; a < n; ) {
        s[l++] = i[a++], s[l++] = i[a++] - r;
        let c = s[l++] = i[a++] - r;
        s[l++] = i[a++] - e, o = Math.max(o, c);
      }
      return new Ad(s, o, this.set);
    }
  }
  function Gle(t, e, n, r) {
    switch (t) {
      case -2:
        return n < e;
      case -1:
        return r >= e && n < e;
      case 0:
        return n < e && r > e;
      case 1:
        return n <= e && r > e;
      case 2:
        return r > e;
      case 4:
        return true;
    }
  }
  function RO(t, e, n, r) {
    for (var i; t.from == t.to || (n < 1 ? t.from >= e : t.from > e) || (n > -1 ? t.to <= e : t.to < e); ) {
      let o = !r && t instanceof Ko && t.index < 0 ? null : t.parent;
      if (!o)
        return t;
      t = o;
    }
    let s = r ? 0 : fi.IgnoreOverlays;
    if (r)
      for (let o = t, a = o.parent; a; o = a, a = o.parent)
        o instanceof Ko && o.index < 0 && ((i = a.enter(e, n, s)) === null || i === void 0 ? void 0 : i.from) != o.from && (t = a);
    for (; ; ) {
      let o = t.enter(e, n, s);
      if (!o)
        return t;
      t = o;
    }
  }
  class qle {
    cursor(e = 0) {
      return new wD(this, e);
    }
    getChild(e, n = null, r = null) {
      let i = WV(this, e, n, r);
      return i.length ? i[0] : null;
    }
    getChildren(e, n = null, r = null) {
      return WV(this, e, n, r);
    }
    resolve(e, n = 0) {
      return RO(this, e, n, false);
    }
    resolveInner(e, n = 0) {
      return RO(this, e, n, true);
    }
    matchContext(e) {
      return SD(this, e);
    }
    enterUnfinishedNodesBefore(e) {
      let n = this.childBefore(e), r = this;
      for (; n; ) {
        let i = n.lastChild;
        if (!i || i.to != n.to)
          break;
        i.type.isError && i.from == i.to ? (r = n, n = i.prevSibling) : n = i;
      }
      return r;
    }
    get node() {
      return this;
    }
    get next() {
      return this.parent;
    }
  }
  class Ko extends qle {
    constructor(e, n, r, i) {
      super(), this._tree = e, this.from = n, this.index = r, this._parent = i;
    }
    get type() {
      return this._tree.type;
    }
    get name() {
      return this._tree.type.name;
    }
    get to() {
      return this.from + this._tree.length;
    }
    nextChild(e, n, r, i, s = 0) {
      for (let o = this; ; ) {
        for (let { children: a, positions: l } = o._tree, c = n > 0 ? a.length : -1; e != c; e += n) {
          let u = a[e], d = l[e] + o.from;
          if (Gle(i, r, d, d + u.length)) {
            if (u instanceof Ad) {
              if (s & fi.ExcludeBuffers)
                continue;
              let h = u.findChild(0, u.buffer.length, n, r - d, i);
              if (h > -1)
                return new id(new Ctt(o, u, e, d), null, h);
            } else if (s & fi.IncludeAnonymous || !u.type.isAnonymous || uN(u)) {
              let h;
              if (!(s & fi.IgnoreMounts) && (h = PP.get(u)) && !h.overlay)
                return new Ko(h.tree, d, e, o);
              let f = new Ko(u, d, e, o);
              return s & fi.IncludeAnonymous || !f.type.isAnonymous ? f : f.nextChild(n < 0 ? u.children.length - 1 : 0, n, r, i);
            }
          }
        }
        if (s & fi.IncludeAnonymous || !o.type.isAnonymous || (o.index >= 0 ? e = o.index + n : e = n < 0 ? -1 : o._parent._tree.children.length, o = o._parent, !o))
          return null;
      }
    }
    get firstChild() {
      return this.nextChild(0, 1, 0, 4);
    }
    get lastChild() {
      return this.nextChild(this._tree.children.length - 1, -1, 0, 4);
    }
    childAfter(e) {
      return this.nextChild(0, 1, e, 2);
    }
    childBefore(e) {
      return this.nextChild(this._tree.children.length - 1, -1, e, -2);
    }
    enter(e, n, r = 0) {
      let i;
      if (!(r & fi.IgnoreOverlays) && (i = PP.get(this._tree)) && i.overlay) {
        let s = e - this.from;
        for (let { from: o, to: a } of i.overlay)
          if ((n > 0 ? o <= s : o < s) && (n < 0 ? a >= s : a > s))
            return new Ko(i.tree, i.overlay[0].from + this.from, -1, this);
      }
      return this.nextChild(0, 1, e, n, r);
    }
    nextSignificantParent() {
      let e = this;
      for (; e.type.isAnonymous && e._parent; )
        e = e._parent;
      return e;
    }
    get parent() {
      return this._parent ? this._parent.nextSignificantParent() : null;
    }
    get nextSibling() {
      return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4) : null;
    }
    get prevSibling() {
      return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4) : null;
    }
    get tree() {
      return this._tree;
    }
    toTree() {
      return this._tree;
    }
    toString() {
      return this._tree.toString();
    }
  }
  function WV(t, e, n, r) {
    let i = t.cursor(), s = [];
    if (!i.firstChild())
      return s;
    if (n != null) {
      for (let o = false; !o; )
        if (o = i.type.is(n), !i.nextSibling())
          return s;
    }
    for (; ; ) {
      if (r != null && i.type.is(r))
        return s;
      if (i.type.is(e) && s.push(i.node), !i.nextSibling())
        return r == null ? s : [];
    }
  }
  function SD(t, e, n = e.length - 1) {
    for (let r = t.parent; n >= 0; r = r.parent) {
      if (!r)
        return false;
      if (!r.type.isAnonymous) {
        if (e[n] && e[n] != r.name)
          return false;
        n--;
      }
    }
    return true;
  }
  class Ctt {
    constructor(e, n, r, i) {
      this.parent = e, this.buffer = n, this.index = r, this.start = i;
    }
  }
  class id extends qle {
    get name() {
      return this.type.name;
    }
    get from() {
      return this.context.start + this.context.buffer.buffer[this.index + 1];
    }
    get to() {
      return this.context.start + this.context.buffer.buffer[this.index + 2];
    }
    constructor(e, n, r) {
      super(), this.context = e, this._parent = n, this.index = r, this.type = e.buffer.set.types[e.buffer.buffer[r]];
    }
    child(e, n, r) {
      let { buffer: i } = this.context, s = i.findChild(this.index + 4, i.buffer[this.index + 3], e, n - this.context.start, r);
      return s < 0 ? null : new id(this.context, this, s);
    }
    get firstChild() {
      return this.child(1, 0, 4);
    }
    get lastChild() {
      return this.child(-1, 0, 4);
    }
    childAfter(e) {
      return this.child(1, e, 2);
    }
    childBefore(e) {
      return this.child(-1, e, -2);
    }
    enter(e, n, r = 0) {
      if (r & fi.ExcludeBuffers)
        return null;
      let { buffer: i } = this.context, s = i.findChild(this.index + 4, i.buffer[this.index + 3], n > 0 ? 1 : -1, e - this.context.start, n);
      return s < 0 ? null : new id(this.context, this, s);
    }
    get parent() {
      return this._parent || this.context.parent.nextSignificantParent();
    }
    externalSibling(e) {
      return this._parent ? null : this.context.parent.nextChild(this.context.index + e, e, 0, 4);
    }
    get nextSibling() {
      let { buffer: e } = this.context, n = e.buffer[this.index + 3];
      return n < (this._parent ? e.buffer[this._parent.index + 3] : e.buffer.length) ? new id(this.context, this._parent, n) : this.externalSibling(1);
    }
    get prevSibling() {
      let { buffer: e } = this.context, n = this._parent ? this._parent.index + 4 : 0;
      return this.index == n ? this.externalSibling(-1) : new id(this.context, this._parent, e.findChild(n, this.index, -1, 0, 4));
    }
    get tree() {
      return null;
    }
    toTree() {
      let e = [], n = [], { buffer: r } = this.context, i = this.index + 4, s = r.buffer[this.index + 3];
      if (s > i) {
        let o = r.buffer[this.index + 1];
        e.push(r.slice(i, s, o)), n.push(0);
      }
      return new Fa(this.type, e, n, this.to - this.from);
    }
    toString() {
      return this.context.buffer.childString(this.index);
    }
  }
  function Kle(t) {
    if (!t.length)
      return null;
    let e = 0, n = t[0];
    for (let s = 1; s < t.length; s++) {
      let o = t[s];
      (o.from > n.from || o.to < n.to) && (n = o, e = s);
    }
    let r = n instanceof Ko && n.index < 0 ? null : n.parent, i = t.slice();
    return r ? i[e] = r : i.splice(e, 1), new _tt(i, n);
  }
  class _tt {
    constructor(e, n) {
      this.heads = e, this.node = n;
    }
    get next() {
      return Kle(this.heads);
    }
  }
  function Ttt(t, e, n) {
    let r = t.resolveInner(e, n), i = null;
    for (let s = r instanceof Ko ? r : r.context.parent; s; s = s.parent)
      if (s.index < 0) {
        let o = s.parent;
        (i || (i = [
          r
        ])).push(o.resolve(e, n)), s = o;
      } else {
        let o = PP.get(s.tree);
        if (o && o.overlay && o.overlay[0].from <= e && o.overlay[o.overlay.length - 1].to >= e) {
          let a = new Ko(o.tree, o.overlay[0].from + s.from, -1, s);
          (i || (i = [
            r
          ])).push(RO(a, e, n, false));
        }
      }
    return i ? Kle(i) : r;
  }
  class wD {
    get name() {
      return this.type.name;
    }
    constructor(e, n = 0) {
      if (this.mode = n, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, e instanceof Ko)
        this.yieldNode(e);
      else {
        this._tree = e.context.parent, this.buffer = e.context;
        for (let r = e._parent; r; r = r._parent)
          this.stack.unshift(r.index);
        this.bufferNode = e, this.yieldBuf(e.index);
      }
    }
    yieldNode(e) {
      return e ? (this._tree = e, this.type = e.type, this.from = e.from, this.to = e.to, true) : false;
    }
    yieldBuf(e, n) {
      this.index = e;
      let { start: r, buffer: i } = this.buffer;
      return this.type = n || i.set.types[i.buffer[e]], this.from = r + i.buffer[e + 1], this.to = r + i.buffer[e + 2], true;
    }
    yield(e) {
      return e ? e instanceof Ko ? (this.buffer = null, this.yieldNode(e)) : (this.buffer = e.context, this.yieldBuf(e.index, e.type)) : false;
    }
    toString() {
      return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
    }
    enterChild(e, n, r) {
      if (!this.buffer)
        return this.yield(this._tree.nextChild(e < 0 ? this._tree._tree.children.length - 1 : 0, e, n, r, this.mode));
      let { buffer: i } = this.buffer, s = i.findChild(this.index + 4, i.buffer[this.index + 3], e, n - this.buffer.start, r);
      return s < 0 ? false : (this.stack.push(this.index), this.yieldBuf(s));
    }
    firstChild() {
      return this.enterChild(1, 0, 4);
    }
    lastChild() {
      return this.enterChild(-1, 0, 4);
    }
    childAfter(e) {
      return this.enterChild(1, e, 2);
    }
    childBefore(e) {
      return this.enterChild(-1, e, -2);
    }
    enter(e, n, r = this.mode) {
      return this.buffer ? r & fi.ExcludeBuffers ? false : this.enterChild(1, e, n) : this.yield(this._tree.enter(e, n, r));
    }
    parent() {
      if (!this.buffer)
        return this.yieldNode(this.mode & fi.IncludeAnonymous ? this._tree._parent : this._tree.parent);
      if (this.stack.length)
        return this.yieldBuf(this.stack.pop());
      let e = this.mode & fi.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
      return this.buffer = null, this.yieldNode(e);
    }
    sibling(e) {
      if (!this.buffer)
        return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + e, e, 0, 4, this.mode)) : false;
      let { buffer: n } = this.buffer, r = this.stack.length - 1;
      if (e < 0) {
        let i = r < 0 ? 0 : this.stack[r] + 4;
        if (this.index != i)
          return this.yieldBuf(n.findChild(i, this.index, -1, 0, 4));
      } else {
        let i = n.buffer[this.index + 3];
        if (i < (r < 0 ? n.buffer.length : n.buffer[this.stack[r] + 3]))
          return this.yieldBuf(i);
      }
      return r < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + e, e, 0, 4, this.mode)) : false;
    }
    nextSibling() {
      return this.sibling(1);
    }
    prevSibling() {
      return this.sibling(-1);
    }
    atLastNode(e) {
      let n, r, { buffer: i } = this;
      if (i) {
        if (e > 0) {
          if (this.index < i.buffer.buffer.length)
            return false;
        } else
          for (let s = 0; s < this.index; s++)
            if (i.buffer.buffer[s + 3] < this.index)
              return false;
        ({ index: n, parent: r } = i);
      } else
        ({ index: n, _parent: r } = this._tree);
      for (; r; { index: n, _parent: r } = r)
        if (n > -1)
          for (let s = n + e, o = e < 0 ? -1 : r._tree.children.length; s != o; s += e) {
            let a = r._tree.children[s];
            if (this.mode & fi.IncludeAnonymous || a instanceof Ad || !a.type.isAnonymous || uN(a))
              return false;
          }
      return true;
    }
    move(e, n) {
      if (n && this.enterChild(e, 0, 4))
        return true;
      for (; ; ) {
        if (this.sibling(e))
          return true;
        if (this.atLastNode(e) || !this.parent())
          return false;
      }
    }
    next(e = true) {
      return this.move(1, e);
    }
    prev(e = true) {
      return this.move(-1, e);
    }
    moveTo(e, n = 0) {
      for (; (this.from == this.to || (n < 1 ? this.from >= e : this.from > e) || (n > -1 ? this.to <= e : this.to < e)) && this.parent(); )
        ;
      for (; this.enterChild(1, e, n); )
        ;
      return this;
    }
    get node() {
      if (!this.buffer)
        return this._tree;
      let e = this.bufferNode, n = null, r = 0;
      if (e && e.context == this.buffer)
        e:
          for (let i = this.index, s = this.stack.length; s >= 0; ) {
            for (let o = e; o; o = o._parent)
              if (o.index == i) {
                if (i == this.index)
                  return o;
                n = o, r = s + 1;
                break e;
              }
            i = this.stack[--s];
          }
      for (let i = r; i < this.stack.length; i++)
        n = new id(this.buffer, n, this.stack[i]);
      return this.bufferNode = new id(this.buffer, n, this.index);
    }
    get tree() {
      return this.buffer ? null : this._tree._tree;
    }
    iterate(e, n) {
      for (let r = 0; ; ) {
        let i = false;
        if (this.type.isAnonymous || e(this) !== false) {
          if (this.firstChild()) {
            r++;
            continue;
          }
          this.type.isAnonymous || (i = true);
        }
        for (; i && n && n(this), i = this.type.isAnonymous, !this.nextSibling(); ) {
          if (!r)
            return;
          this.parent(), r--, i = true;
        }
      }
    }
    matchContext(e) {
      if (!this.buffer)
        return SD(this.node, e);
      let { buffer: n } = this.buffer, { types: r } = n.set;
      for (let i = e.length - 1, s = this.stack.length - 1; i >= 0; s--) {
        if (s < 0)
          return SD(this.node, e, i);
        let o = r[n.buffer[this.stack[s]]];
        if (!o.isAnonymous) {
          if (e[i] && e[i] != o.name)
            return false;
          i--;
        }
      }
      return true;
    }
  }
  function uN(t) {
    return t.children.some((e) => e instanceof Ad || !e.type.isAnonymous || uN(e));
  }
  function Ett(t) {
    var e;
    let { buffer: n, nodeSet: r, maxBufferLength: i = btt, reused: s = [], minRepeatType: o = r.types.length } = t, a = Array.isArray(n) ? new cN(n, n.length) : n, l = r.types, c = 0, u = 0;
    function d(C, _, T, $, N, L) {
      let { id: z, start: M, end: R, size: F } = a, Q = u;
      for (; F < 0; )
        if (a.next(), F == -1) {
          let te = s[z];
          T.push(te), $.push(M - C);
          return;
        } else if (F == -3) {
          c = z;
          return;
        } else if (F == -4) {
          u = z;
          return;
        } else
          throw new RangeError(`Unrecognized record size: ${F}`);
      let X = l[z], Z, U, H = M - C;
      if (R - M <= i && (U = O(a.pos - _, N))) {
        let te = new Uint16Array(U.size - U.skip), se = a.pos - U.size, ae = te.length;
        for (; a.pos > se; )
          ae = S(U.start, te, ae);
        Z = new Ad(te, R - U.start, r), H = U.start - C;
      } else {
        let te = a.pos - F;
        a.next();
        let se = [], ae = [], _e3 = z >= o ? z : -1, Me = 0, ke = R;
        for (; a.pos > te; )
          _e3 >= 0 && a.id == _e3 && a.size >= 0 ? (a.end <= ke - i && (y(se, ae, M, Me, a.end, ke, _e3, Q), Me = se.length, ke = a.end), a.next()) : L > 2500 ? h(M, te, se, ae) : d(M, te, se, ae, _e3, L + 1);
        if (_e3 >= 0 && Me > 0 && Me < se.length && y(se, ae, M, Me, M, ke, _e3, Q), se.reverse(), ae.reverse(), _e3 > -1 && Me > 0) {
          let tt = f(X);
          Z = dN(X, se, ae, 0, se.length, 0, R - M, tt, tt);
        } else
          Z = g(X, se, ae, R - M, Q - R);
      }
      T.push(Z), $.push(H);
    }
    function h(C, _, T, $) {
      let N = [], L = 0, z = -1;
      for (; a.pos > _; ) {
        let { id: M, start: R, end: F, size: Q } = a;
        if (Q > 4)
          a.next();
        else {
          if (z > -1 && R < z)
            break;
          z < 0 && (z = F - i), N.push(M, R, F), L++, a.next();
        }
      }
      if (L) {
        let M = new Uint16Array(L * 4), R = N[N.length - 2];
        for (let F = N.length - 3, Q = 0; F >= 0; F -= 3)
          M[Q++] = N[F], M[Q++] = N[F + 1] - R, M[Q++] = N[F + 2] - R, M[Q++] = Q;
        T.push(new Ad(M, N[2] - R, r)), $.push(R - C);
      }
    }
    function f(C) {
      return (_, T, $) => {
        let N = 0, L = _.length - 1, z, M;
        if (L >= 0 && (z = _[L]) instanceof Fa) {
          if (!L && z.type == C && z.length == $)
            return z;
          (M = z.prop(Bn.lookAhead)) && (N = T[L] + z.length + M);
        }
        return g(C, _, T, $, N);
      };
    }
    function y(C, _, T, $, N, L, z, M) {
      let R = [], F = [];
      for (; C.length > $; )
        R.push(C.pop()), F.push(_.pop() + T - N);
      C.push(g(r.types[z], R, F, L - N, M - L)), _.push(N - T);
    }
    function g(C, _, T, $, N = 0, L) {
      if (c) {
        let z = [
          Bn.contextHash,
          c
        ];
        L = L ? [
          z
        ].concat(L) : [
          z
        ];
      }
      if (N > 25) {
        let z = [
          Bn.lookAhead,
          N
        ];
        L = L ? [
          z
        ].concat(L) : [
          z
        ];
      }
      return new Fa(C, _, T, $, L);
    }
    function O(C, _) {
      let T = a.fork(), $ = 0, N = 0, L = 0, z = T.end - i, M = {
        size: 0,
        start: 0,
        skip: 0
      };
      e:
        for (let R = T.pos - C; T.pos > R; ) {
          let F = T.size;
          if (T.id == _ && F >= 0) {
            M.size = $, M.start = N, M.skip = L, L += 4, $ += 4, T.next();
            continue;
          }
          let Q = T.pos - F;
          if (F < 0 || Q < R || T.start < z)
            break;
          let X = T.id >= o ? 4 : 0, Z = T.start;
          for (T.next(); T.pos > Q; ) {
            if (T.size < 0)
              if (T.size == -3)
                X += 4;
              else
                break e;
            else
              T.id >= o && (X += 4);
            T.next();
          }
          N = Z, $ += F, L += X;
        }
      return (_ < 0 || $ == C) && (M.size = $, M.start = N, M.skip = L), M.size > 4 ? M : void 0;
    }
    function S(C, _, T) {
      let { id: $, start: N, end: L, size: z } = a;
      if (a.next(), z >= 0 && $ < o) {
        let M = T;
        if (z > 4) {
          let R = a.pos - (z - 4);
          for (; a.pos > R; )
            T = S(C, _, T);
        }
        _[--T] = M, _[--T] = L - C, _[--T] = N - C, _[--T] = $;
      } else
        z == -3 ? c = $ : z == -4 && (u = $);
      return T;
    }
    let w = [], x = [];
    for (; a.pos > 0; )
      d(t.start || 0, t.bufferStart || 0, w, x, -1, 0);
    let P = (e = t.length) !== null && e !== void 0 ? e : w.length ? x[0] + w[0].length : 0;
    return new Fa(l[t.topID], w.reverse(), x.reverse(), P);
  }
  const ZV = /* @__PURE__ */ new WeakMap();
  function xb(t, e) {
    if (!t.isAnonymous || e instanceof Ad || e.type != t)
      return 1;
    let n = ZV.get(e);
    if (n == null) {
      n = 1;
      for (let r of e.children) {
        if (r.type != t || !(r instanceof Fa)) {
          n = 1;
          break;
        }
        n += xb(t, r);
      }
      ZV.set(e, n);
    }
    return n;
  }
  function dN(t, e, n, r, i, s, o, a, l) {
    let c = 0;
    for (let y = r; y < i; y++)
      c += xb(t, e[y]);
    let u = Math.ceil(c * 1.5 / 8), d = [], h = [];
    function f(y, g, O, S, w) {
      for (let x = O; x < S; ) {
        let P = x, C = g[x], _ = xb(t, y[x]);
        for (x++; x < S; x++) {
          let T = xb(t, y[x]);
          if (_ + T >= u)
            break;
          _ += T;
        }
        if (x == P + 1) {
          if (_ > u) {
            let T = y[P];
            f(T.children, T.positions, 0, T.children.length, g[P] + w);
            continue;
          }
          d.push(y[P]);
        } else {
          let T = g[x - 1] + y[x - 1].length - C;
          d.push(dN(t, y, g, P, x, C, T, null, l));
        }
        h.push(C + w - s);
      }
    }
    return f(e, n, r, i, 0), (a || l)(d, h, o);
  }
  new Bn({
    perNode: true
  });
  const xD = Zd.define(), Itt = Zd.define(), $tt = $r.define(), Jle = $r.define({
    combine(t) {
      return j2(t, {
        minDepth: 100,
        newGroupDelay: 500,
        joinToEvent: (e, n) => n
      }, {
        minDepth: Math.max,
        newGroupDelay: Math.min,
        joinToEvent: (e, n) => (r, i) => e(r, i) || n(r, i)
      });
    }
  }), ece = Hi.define({
    create() {
      return El.empty;
    },
    update(t, e) {
      let n = e.state.facet(Jle), r = e.annotation(xD);
      if (r) {
        let l = ms.fromTransaction(e, r.selection), c = r.side, u = c == 0 ? t.undone : t.done;
        return l ? u = CP(u, u.length, n.minDepth, l) : u = rce(u, e.startState.selection), new El(c == 0 ? r.rest : u, c == 0 ? u : r.rest);
      }
      let i = e.annotation(Itt);
      if ((i == "full" || i == "before") && (t = t.isolate()), e.annotation(Pr.addToHistory) === false)
        return e.changes.empty ? t : t.addMapping(e.changes.desc);
      let s = ms.fromTransaction(e), o = e.annotation(Pr.time), a = e.annotation(Pr.userEvent);
      return s ? t = t.addChanges(s, o, a, n, e) : e.selection && (t = t.addSelection(e.startState.selection, o, a, n.newGroupDelay)), (i == "full" || i == "after") && (t = t.isolate()), t;
    },
    toJSON(t) {
      return {
        done: t.done.map((e) => e.toJSON()),
        undone: t.undone.map((e) => e.toJSON())
      };
    },
    fromJSON(t) {
      return new El(t.done.map(ms.fromJSON), t.undone.map(ms.fromJSON));
    }
  });
  function Att(t = {}) {
    return [
      ece,
      Jle.of(t),
      Re.domEventHandlers({
        beforeinput(e, n) {
          let r = e.inputType == "historyUndo" ? tce : e.inputType == "historyRedo" ? bD : null;
          return r ? (e.preventDefault(), r(n)) : false;
        }
      })
    ];
  }
  function N2(t, e) {
    return function({ state: n, dispatch: r }) {
      if (!e && n.readOnly)
        return false;
      let i = n.field(ece, false);
      if (!i)
        return false;
      let s = i.pop(t, n, e);
      return s ? (r(s), true) : false;
    };
  }
  const tce = N2(0, false), bD = N2(1, false), Rtt = N2(0, true), Mtt = N2(1, true);
  class ms {
    constructor(e, n, r, i, s) {
      this.changes = e, this.effects = n, this.mapped = r, this.startSelection = i, this.selectionsAfter = s;
    }
    setSelAfter(e) {
      return new ms(this.changes, this.effects, this.mapped, this.startSelection, e);
    }
    toJSON() {
      var e, n, r;
      return {
        changes: (e = this.changes) === null || e === void 0 ? void 0 : e.toJSON(),
        mapped: (n = this.mapped) === null || n === void 0 ? void 0 : n.toJSON(),
        startSelection: (r = this.startSelection) === null || r === void 0 ? void 0 : r.toJSON(),
        selectionsAfter: this.selectionsAfter.map((i) => i.toJSON())
      };
    }
    static fromJSON(e) {
      return new ms(e.changes && Fr.fromJSON(e.changes), [], e.mapped && Dl.fromJSON(e.mapped), e.startSelection && He.fromJSON(e.startSelection), e.selectionsAfter.map(He.fromJSON));
    }
    static fromTransaction(e, n) {
      let r = Wo;
      for (let i of e.startState.facet($tt)) {
        let s = i(e);
        s.length && (r = r.concat(s));
      }
      return !r.length && e.changes.empty ? null : new ms(e.changes.invert(e.startState.doc), r, void 0, n || e.startState.selection, Wo);
    }
    static selection(e) {
      return new ms(void 0, Wo, void 0, void 0, e);
    }
  }
  function CP(t, e, n, r) {
    let i = e + 1 > n + 20 ? e - n - 1 : 0, s = t.slice(i, e);
    return s.push(r), s;
  }
  function Dtt(t, e) {
    let n = [], r = false;
    return t.iterChangedRanges((i, s) => n.push(i, s)), e.iterChangedRanges((i, s, o, a) => {
      for (let l = 0; l < n.length; ) {
        let c = n[l++], u = n[l++];
        a >= c && o <= u && (r = true);
      }
    }), r;
  }
  function Ltt(t, e) {
    return t.ranges.length == e.ranges.length && t.ranges.filter((n, r) => n.empty != e.ranges[r].empty).length === 0;
  }
  function nce(t, e) {
    return t.length ? e.length ? t.concat(e) : t : e;
  }
  const Wo = [], jtt = 200;
  function rce(t, e) {
    if (t.length) {
      let n = t[t.length - 1], r = n.selectionsAfter.slice(Math.max(0, n.selectionsAfter.length - jtt));
      return r.length && r[r.length - 1].eq(e) ? t : (r.push(e), CP(t, t.length - 1, 1e9, n.setSelAfter(r)));
    } else
      return [
        ms.selection([
          e
        ])
      ];
  }
  function Ntt(t) {
    let e = t[t.length - 1], n = t.slice();
    return n[t.length - 1] = e.setSelAfter(e.selectionsAfter.slice(0, e.selectionsAfter.length - 1)), n;
  }
  function C$(t, e) {
    if (!t.length)
      return t;
    let n = t.length, r = Wo;
    for (; n; ) {
      let i = Qtt(t[n - 1], e, r);
      if (i.changes && !i.changes.empty || i.effects.length) {
        let s = t.slice(0, n);
        return s[n - 1] = i, s;
      } else
        e = i.mapped, n--, r = i.selectionsAfter;
    }
    return r.length ? [
      ms.selection(r)
    ] : Wo;
  }
  function Qtt(t, e, n) {
    let r = nce(t.selectionsAfter.length ? t.selectionsAfter.map((a) => a.map(e)) : Wo, n);
    if (!t.changes)
      return ms.selection(r);
    let i = t.changes.map(e), s = e.mapDesc(t.changes, true), o = t.mapped ? t.mapped.composeDesc(s) : s;
    return new ms(i, Dt.mapEffects(t.effects, e), o, t.startSelection.map(s), r);
  }
  const ztt = /^(input\.type|delete)($|\.)/;
  class El {
    constructor(e, n, r = 0, i = void 0) {
      this.done = e, this.undone = n, this.prevTime = r, this.prevUserEvent = i;
    }
    isolate() {
      return this.prevTime ? new El(this.done, this.undone) : this;
    }
    addChanges(e, n, r, i, s) {
      let o = this.done, a = o[o.length - 1];
      return a && a.changes && !a.changes.empty && e.changes && (!r || ztt.test(r)) && (!a.selectionsAfter.length && n - this.prevTime < i.newGroupDelay && i.joinToEvent(s, Dtt(a.changes, e.changes)) || r == "input.type.compose") ? o = CP(o, o.length - 1, i.minDepth, new ms(e.changes.compose(a.changes), nce(e.effects, a.effects), a.mapped, a.startSelection, Wo)) : o = CP(o, o.length, i.minDepth, e), new El(o, Wo, n, r);
    }
    addSelection(e, n, r, i) {
      let s = this.done.length ? this.done[this.done.length - 1].selectionsAfter : Wo;
      return s.length > 0 && n - this.prevTime < i && r == this.prevUserEvent && r && /^select($|\.)/.test(r) && Ltt(s[s.length - 1], e) ? this : new El(rce(this.done, e), this.undone, n, r);
    }
    addMapping(e) {
      return new El(C$(this.done, e), C$(this.undone, e), this.prevTime, this.prevUserEvent);
    }
    pop(e, n, r) {
      let i = e == 0 ? this.done : this.undone;
      if (i.length == 0)
        return null;
      let s = i[i.length - 1], o = s.selectionsAfter[0] || n.selection;
      if (r && s.selectionsAfter.length)
        return n.update({
          selection: s.selectionsAfter[s.selectionsAfter.length - 1],
          annotations: xD.of({
            side: e,
            rest: Ntt(i),
            selection: o
          }),
          userEvent: e == 0 ? "select.undo" : "select.redo",
          scrollIntoView: true
        });
      if (s.changes) {
        let a = i.length == 1 ? Wo : i.slice(0, i.length - 1);
        return s.mapped && (a = C$(a, s.mapped)), n.update({
          changes: s.changes,
          selection: s.startSelection,
          effects: s.effects,
          annotations: xD.of({
            side: e,
            rest: a,
            selection: o
          }),
          filter: false,
          userEvent: e == 0 ? "undo" : "redo",
          scrollIntoView: true
        });
      } else
        return null;
    }
  }
  El.empty = new El(Wo, Wo);
  const Ftt = [
    {
      key: "Mod-z",
      run: tce,
      preventDefault: true
    },
    {
      key: "Mod-y",
      mac: "Mod-Shift-z",
      run: bD,
      preventDefault: true
    },
    {
      linux: "Ctrl-Shift-z",
      run: bD,
      preventDefault: true
    },
    {
      key: "Mod-u",
      run: Rtt,
      preventDefault: true
    },
    {
      key: "Alt-u",
      mac: "Mod-Shift-u",
      run: Mtt,
      preventDefault: true
    }
  ];
  function hN(t, e) {
    return He.create(t.ranges.map(e), t.mainIndex);
  }
  function If(t, e) {
    return t.update({
      selection: e,
      scrollIntoView: true,
      userEvent: "select"
    });
  }
  function lu({ state: t, dispatch: e }, n) {
    let r = hN(t.selection, n);
    return r.eq(t.selection, true) ? false : (e(If(t, r)), true);
  }
  function Q2(t, e) {
    return He.cursor(e ? t.to : t.from);
  }
  function ice(t, e) {
    return lu(t, (n) => n.empty ? t.moveByChar(n, e) : Q2(n, e));
  }
  function la(t) {
    return t.textDirectionAt(t.state.selection.main.head) == er.LTR;
  }
  const sce = (t) => ice(t, !la(t)), oce = (t) => ice(t, la(t));
  function ace(t, e) {
    return lu(t, (n) => n.empty ? t.moveByGroup(n, e) : Q2(n, e));
  }
  const Btt = (t) => ace(t, !la(t)), Utt = (t) => ace(t, la(t));
  function lce(t, e) {
    return lu(t, (n) => {
      if (!n.empty)
        return Q2(n, e);
      let r = t.moveVertically(n, e);
      return r.head != n.head ? r : t.moveToLineBoundary(n, e);
    });
  }
  const cce = (t) => lce(t, false), uce = (t) => lce(t, true);
  function dce(t) {
    let e = t.scrollDOM.clientHeight < t.scrollDOM.scrollHeight - 2, n = 0, r = 0, i;
    if (e) {
      for (let s of t.state.facet(Re.scrollMargins)) {
        let o = s(t);
        (o == null ? void 0 : o.top) && (n = Math.max(o == null ? void 0 : o.top, n)), (o == null ? void 0 : o.bottom) && (r = Math.max(o == null ? void 0 : o.bottom, r));
      }
      i = t.scrollDOM.clientHeight - n - r;
    } else
      i = (t.dom.ownerDocument.defaultView || window).innerHeight;
    return {
      marginTop: n,
      marginBottom: r,
      selfScroll: e,
      height: Math.max(t.defaultLineHeight, i - 5)
    };
  }
  function hce(t, e) {
    let n = dce(t), { state: r } = t, i = hN(r.selection, (o) => o.empty ? t.moveVertically(o, e, n.height) : Q2(o, e));
    if (i.eq(r.selection))
      return false;
    let s;
    if (n.selfScroll) {
      let o = t.coordsAtPos(r.selection.main.head), a = t.scrollDOM.getBoundingClientRect(), l = a.top + n.marginTop, c = a.bottom - n.marginBottom;
      o && o.top > l && o.bottom < c && (s = Re.scrollIntoView(i.main.head, {
        y: "start",
        yMargin: o.top - l
      }));
    }
    return t.dispatch(If(r, i), {
      effects: s
    }), true;
  }
  const HV = (t) => hce(t, false), kD = (t) => hce(t, true);
  function Hd(t, e, n) {
    let r = t.lineBlockAt(e.head), i = t.moveToLineBoundary(e, n);
    if (i.head == e.head && i.head != (n ? r.to : r.from) && (i = t.moveToLineBoundary(e, n, false)), !n && i.head == r.from && r.length) {
      let s = /^\s*/.exec(t.state.sliceDoc(r.from, Math.min(r.from + 100, r.to)))[0].length;
      s && e.head != r.from + s && (i = He.cursor(r.from + s));
    }
    return i;
  }
  const Vtt = (t) => lu(t, (e) => Hd(t, e, true)), Xtt = (t) => lu(t, (e) => Hd(t, e, false)), Wtt = (t) => lu(t, (e) => Hd(t, e, !la(t))), Ztt = (t) => lu(t, (e) => Hd(t, e, la(t))), Htt = (t) => lu(t, (e) => He.cursor(t.lineBlockAt(e.head).from, 1)), Ytt = (t) => lu(t, (e) => He.cursor(t.lineBlockAt(e.head).to, -1));
  function Gl(t, e) {
    let n = hN(t.state.selection, (r) => {
      let i = e(r);
      return He.range(r.anchor, i.head, i.goalColumn, i.bidiLevel || void 0);
    });
    return n.eq(t.state.selection) ? false : (t.dispatch(If(t.state, n)), true);
  }
  function fce(t, e) {
    return Gl(t, (n) => t.moveByChar(n, e));
  }
  const pce = (t) => fce(t, !la(t)), gce = (t) => fce(t, la(t));
  function mce(t, e) {
    return Gl(t, (n) => t.moveByGroup(n, e));
  }
  const Gtt = (t) => mce(t, !la(t)), qtt = (t) => mce(t, la(t));
  function yce(t, e) {
    return Gl(t, (n) => t.moveVertically(n, e));
  }
  const vce = (t) => yce(t, false), Oce = (t) => yce(t, true);
  function Sce(t, e) {
    return Gl(t, (n) => t.moveVertically(n, e, dce(t).height));
  }
  const YV = (t) => Sce(t, false), GV = (t) => Sce(t, true), Ktt = (t) => Gl(t, (e) => Hd(t, e, true)), Jtt = (t) => Gl(t, (e) => Hd(t, e, false)), ent = (t) => Gl(t, (e) => Hd(t, e, !la(t))), tnt = (t) => Gl(t, (e) => Hd(t, e, la(t))), nnt = (t) => Gl(t, (e) => He.cursor(t.lineBlockAt(e.head).from)), rnt = (t) => Gl(t, (e) => He.cursor(t.lineBlockAt(e.head).to)), qV = ({ state: t, dispatch: e }) => (e(If(t, {
    anchor: 0
  })), true), KV = ({ state: t, dispatch: e }) => (e(If(t, {
    anchor: t.doc.length
  })), true), JV = ({ state: t, dispatch: e }) => (e(If(t, {
    anchor: t.selection.main.anchor,
    head: 0
  })), true), eX = ({ state: t, dispatch: e }) => (e(If(t, {
    anchor: t.selection.main.anchor,
    head: t.doc.length
  })), true), int = ({ state: t, dispatch: e }) => (e(t.update({
    selection: {
      anchor: 0,
      head: t.doc.length
    },
    userEvent: "select"
  })), true);
  function ES(t, e) {
    if (t.state.readOnly)
      return false;
    let n = "delete.selection", { state: r } = t, i = r.changeByRange((s) => {
      let { from: o, to: a } = s;
      if (o == a) {
        let l = e(s);
        l < o ? (n = "delete.backward", l = Ox(t, l, false)) : l > o && (n = "delete.forward", l = Ox(t, l, true)), o = Math.min(o, l), a = Math.max(a, l);
      } else
        o = Ox(t, o, false), a = Ox(t, a, true);
      return o == a ? {
        range: s
      } : {
        changes: {
          from: o,
          to: a
        },
        range: He.cursor(o, o < s.head ? -1 : 1)
      };
    });
    return i.changes.empty ? false : (t.dispatch(r.update(i, {
      scrollIntoView: true,
      userEvent: n,
      effects: n == "delete.selection" ? Re.announce.of(r.phrase("Selection deleted")) : void 0
    })), true);
  }
  function Ox(t, e, n) {
    if (t instanceof Re)
      for (let r of t.state.facet(Re.atomicRanges).map((i) => i(t)))
        r.between(e, e, (i, s) => {
          i < e && s > e && (e = n ? s : i);
        });
    return e;
  }
  const wce = (t, e, n) => ES(t, (r) => {
    let i = r.from, { state: s } = t, o = s.doc.lineAt(i), a, l;
    if (n && !e && i > o.from && i < o.from + 200 && !/[^ \t]/.test(a = o.text.slice(0, i - o.from))) {
      if (a[a.length - 1] == "	")
        return i - 1;
      let c = lN(a, s.tabSize), u = c % gf(s) || gf(s);
      for (let d = 0; d < u && a[a.length - 1 - d] == " "; d++)
        i--;
      l = i;
    } else
      l = Vl(o.text, i - o.from, e, e) + o.from, l == i && o.number != (e ? s.doc.lines : 1) ? l += e ? 1 : -1 : !e && /[\ufe00-\ufe0f]/.test(o.text.slice(l - o.from, i - o.from)) && (l = Vl(o.text, l - o.from, false, false) + o.from);
    return l;
  }), PD = (t) => wce(t, false, true), xce = (t) => wce(t, true, false), bce = (t, e) => ES(t, (n) => {
    let r = n.head, { state: i } = t, s = i.doc.lineAt(r), o = i.charCategorizer(r);
    for (let a = null; ; ) {
      if (r == (e ? s.to : s.from)) {
        r == n.head && s.number != (e ? i.doc.lines : 1) && (r += e ? 1 : -1);
        break;
      }
      let l = Vl(s.text, r - s.from, e) + s.from, c = s.text.slice(Math.min(r, l) - s.from, Math.max(r, l) - s.from), u = o(c);
      if (a != null && u != a)
        break;
      (c != " " || r != n.head) && (a = u), r = l;
    }
    return r;
  }), kce = (t) => bce(t, false), snt = (t) => bce(t, true), ont = (t) => ES(t, (e) => {
    let n = t.lineBlockAt(e.head).to;
    return e.head < n ? n : Math.min(t.state.doc.length, e.head + 1);
  }), ant = (t) => ES(t, (e) => {
    let n = t.moveToLineBoundary(e, false).head;
    return e.head > n ? n : Math.max(0, e.head - 1);
  }), lnt = (t) => ES(t, (e) => {
    let n = t.moveToLineBoundary(e, true).head;
    return e.head < n ? n : Math.min(t.state.doc.length, e.head + 1);
  }), cnt = ({ state: t, dispatch: e }) => {
    if (t.readOnly)
      return false;
    let n = t.changeByRange((r) => ({
      changes: {
        from: r.from,
        to: r.to,
        insert: Kn.of([
          "",
          ""
        ])
      },
      range: He.cursor(r.from)
    }));
    return e(t.update(n, {
      scrollIntoView: true,
      userEvent: "input"
    })), true;
  }, unt = ({ state: t, dispatch: e }) => {
    if (t.readOnly)
      return false;
    let n = t.changeByRange((r) => {
      if (!r.empty || r.from == 0 || r.from == t.doc.length)
        return {
          range: r
        };
      let i = r.from, s = t.doc.lineAt(i), o = i == s.from ? i - 1 : Vl(s.text, i - s.from, false) + s.from, a = i == s.to ? i + 1 : Vl(s.text, i - s.from, true) + s.from;
      return {
        changes: {
          from: o,
          to: a,
          insert: t.doc.slice(i, a).append(t.doc.slice(o, i))
        },
        range: He.cursor(a)
      };
    });
    return n.changes.empty ? false : (e(t.update(n, {
      scrollIntoView: true,
      userEvent: "move.character"
    })), true);
  };
  function dnt(t, e) {
    if (/\(\)|\[\]|\{\}/.test(t.sliceDoc(e - 1, e + 1)))
      return {
        from: e,
        to: e
      };
    let n = Un(t).resolveInner(e), r = n.childBefore(e), i = n.childAfter(e), s;
    return r && i && r.to <= e && i.from >= e && (s = r.type.prop(Bn.closedBy)) && s.indexOf(i.name) > -1 && t.doc.lineAt(r.to).from == t.doc.lineAt(i.from).from && !/\S/.test(t.sliceDoc(r.to, i.from)) ? {
      from: r.to,
      to: i.from
    } : null;
  }
  const hnt = fnt(false);
  function fnt(t) {
    return ({ state: e, dispatch: n }) => {
      if (e.readOnly)
        return false;
      let r = e.changeByRange((i) => {
        let { from: s, to: o } = i, a = e.doc.lineAt(s), l = !t && s == o && dnt(e, s);
        t && (s = o = (o <= a.to ? a : e.doc.lineAt(o)).to);
        let c = new Mj(e, {
          simulateBreak: s,
          simulateDoubleBreak: !!l
        }), u = Foe(c, s);
        for (u == null && (u = lN(/^\s*/.exec(e.doc.lineAt(s).text)[0], e.tabSize)); o < a.to && /\s/.test(a.text[o - a.from]); )
          o++;
        l ? { from: s, to: o } = l : s > a.from && s < a.from + 100 && !/\S/.test(a.text.slice(0, s)) && (s = a.from);
        let d = [
          "",
          mP(e, u)
        ];
        return l && d.push(mP(e, c.lineIndent(a.from, -1))), {
          changes: {
            from: s,
            to: o,
            insert: Kn.of(d)
          },
          range: He.cursor(s + 1 + d[1].length)
        };
      });
      return n(e.update(r, {
        scrollIntoView: true,
        userEvent: "input"
      })), true;
    };
  }
  function Pce(t, e) {
    let n = -1;
    return t.changeByRange((r) => {
      let i = [];
      for (let o = r.from; o <= r.to; ) {
        let a = t.doc.lineAt(o);
        a.number > n && (r.empty || r.to > a.from) && (e(a, i, r), n = a.number), o = a.to + 1;
      }
      let s = t.changes(i);
      return {
        changes: i,
        range: He.range(s.mapPos(r.anchor, 1), s.mapPos(r.head, 1))
      };
    });
  }
  const pnt = ({ state: t, dispatch: e }) => t.readOnly ? false : (e(t.update(Pce(t, (n, r) => {
    r.push({
      from: n.from,
      insert: t.facet(Fm)
    });
  }), {
    userEvent: "input.indent"
  })), true), gnt = ({ state: t, dispatch: e }) => t.readOnly ? false : (e(t.update(Pce(t, (n, r) => {
    let i = /^\s*/.exec(n.text)[0];
    if (!i)
      return;
    let s = lN(i, t.tabSize), o = 0, a = mP(t, Math.max(0, s - gf(t)));
    for (; o < i.length && o < a.length && i.charCodeAt(o) == a.charCodeAt(o); )
      o++;
    r.push({
      from: n.from + o,
      to: n.from + i.length,
      insert: a.slice(o)
    });
  }), {
    userEvent: "delete.dedent"
  })), true), mnt = [
    {
      key: "Ctrl-b",
      run: sce,
      shift: pce,
      preventDefault: true
    },
    {
      key: "Ctrl-f",
      run: oce,
      shift: gce
    },
    {
      key: "Ctrl-p",
      run: cce,
      shift: vce
    },
    {
      key: "Ctrl-n",
      run: uce,
      shift: Oce
    },
    {
      key: "Ctrl-a",
      run: Htt,
      shift: nnt
    },
    {
      key: "Ctrl-e",
      run: Ytt,
      shift: rnt
    },
    {
      key: "Ctrl-d",
      run: xce
    },
    {
      key: "Ctrl-h",
      run: PD
    },
    {
      key: "Ctrl-k",
      run: ont
    },
    {
      key: "Ctrl-Alt-h",
      run: kce
    },
    {
      key: "Ctrl-o",
      run: cnt
    },
    {
      key: "Ctrl-t",
      run: unt
    },
    {
      key: "Ctrl-v",
      run: kD
    }
  ], ynt = [
    {
      key: "ArrowLeft",
      run: sce,
      shift: pce,
      preventDefault: true
    },
    {
      key: "Mod-ArrowLeft",
      mac: "Alt-ArrowLeft",
      run: Btt,
      shift: Gtt,
      preventDefault: true
    },
    {
      mac: "Cmd-ArrowLeft",
      run: Wtt,
      shift: ent,
      preventDefault: true
    },
    {
      key: "ArrowRight",
      run: oce,
      shift: gce,
      preventDefault: true
    },
    {
      key: "Mod-ArrowRight",
      mac: "Alt-ArrowRight",
      run: Utt,
      shift: qtt,
      preventDefault: true
    },
    {
      mac: "Cmd-ArrowRight",
      run: Ztt,
      shift: tnt,
      preventDefault: true
    },
    {
      key: "ArrowUp",
      run: cce,
      shift: vce,
      preventDefault: true
    },
    {
      mac: "Cmd-ArrowUp",
      run: qV,
      shift: JV
    },
    {
      mac: "Ctrl-ArrowUp",
      run: HV,
      shift: YV
    },
    {
      key: "ArrowDown",
      run: uce,
      shift: Oce,
      preventDefault: true
    },
    {
      mac: "Cmd-ArrowDown",
      run: KV,
      shift: eX
    },
    {
      mac: "Ctrl-ArrowDown",
      run: kD,
      shift: GV
    },
    {
      key: "PageUp",
      run: HV,
      shift: YV
    },
    {
      key: "PageDown",
      run: kD,
      shift: GV
    },
    {
      key: "Home",
      run: Xtt,
      shift: Jtt,
      preventDefault: true
    },
    {
      key: "Mod-Home",
      run: qV,
      shift: JV
    },
    {
      key: "End",
      run: Vtt,
      shift: Ktt,
      preventDefault: true
    },
    {
      key: "Mod-End",
      run: KV,
      shift: eX
    },
    {
      key: "Enter",
      run: hnt
    },
    {
      key: "Mod-a",
      run: int
    },
    {
      key: "Backspace",
      run: PD,
      shift: PD
    },
    {
      key: "Delete",
      run: xce
    },
    {
      key: "Mod-Backspace",
      mac: "Alt-Backspace",
      run: kce
    },
    {
      key: "Mod-Delete",
      mac: "Alt-Delete",
      run: snt
    },
    {
      mac: "Mod-Backspace",
      run: ant
    },
    {
      mac: "Mod-Delete",
      run: lnt
    }
  ].concat(mnt.map((t) => ({
    mac: t.key,
    run: t.run,
    shift: t.shift
  }))), vnt = {
    key: "Tab",
    run: pnt,
    shift: gnt
  };
  function an() {
    var t = arguments[0];
    typeof t == "string" && (t = document.createElement(t));
    var e = 1, n = arguments[1];
    if (n && typeof n == "object" && n.nodeType == null && !Array.isArray(n)) {
      for (var r in n)
        if (Object.prototype.hasOwnProperty.call(n, r)) {
          var i = n[r];
          typeof i == "string" ? t.setAttribute(r, i) : i != null && (t[r] = i);
        }
      e++;
    }
    for (; e < arguments.length; e++)
      Cce(t, arguments[e]);
    return t;
  }
  function Cce(t, e) {
    if (typeof e == "string")
      t.appendChild(document.createTextNode(e));
    else if (e != null)
      if (e.nodeType != null)
        t.appendChild(e);
      else if (Array.isArray(e))
        for (var n = 0; n < e.length; n++)
          Cce(t, e[n]);
      else
        throw new RangeError("Unsupported child node: " + e);
  }
  const tX = typeof String.prototype.normalize == "function" ? (t) => t.normalize("NFKD") : (t) => t;
  class MO {
    constructor(e, n, r = 0, i = e.length, s, o) {
      this.test = o, this.value = {
        from: 0,
        to: 0
      }, this.done = false, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(r, i), this.bufferStart = r, this.normalize = s ? (a) => s(tX(a)) : tX, this.query = this.normalize(n);
    }
    peek() {
      if (this.bufferPos == this.buffer.length) {
        if (this.bufferStart += this.buffer.length, this.iter.next(), this.iter.done)
          return -1;
        this.bufferPos = 0, this.buffer = this.iter.value;
      }
      return Sl(this.buffer, this.bufferPos);
    }
    next() {
      for (; this.matches.length; )
        this.matches.pop();
      return this.nextOverlapping();
    }
    nextOverlapping() {
      for (; ; ) {
        let e = this.peek();
        if (e < 0)
          return this.done = true, this;
        let n = Lle(e), r = this.bufferStart + this.bufferPos;
        this.bufferPos += Vu(e);
        let i = this.normalize(n);
        for (let s = 0, o = r; ; s++) {
          let a = i.charCodeAt(s), l = this.match(a, o, this.bufferPos + this.bufferStart);
          if (s == i.length - 1) {
            if (l)
              return this.value = l, this;
            break;
          }
          o == r && s < n.length && n.charCodeAt(s) == a && o++;
        }
      }
    }
    match(e, n, r) {
      let i = null;
      for (let s = 0; s < this.matches.length; s += 2) {
        let o = this.matches[s], a = false;
        this.query.charCodeAt(o) == e && (o == this.query.length - 1 ? i = {
          from: this.matches[s + 1],
          to: r
        } : (this.matches[s]++, a = true)), a || (this.matches.splice(s, 2), s -= 2);
      }
      return this.query.charCodeAt(0) == e && (this.query.length == 1 ? i = {
        from: n,
        to: r
      } : this.matches.push(1, n)), i && this.test && !this.test(i.from, i.to, this.buffer, this.bufferStart) && (i = null), i;
    }
  }
  typeof Symbol < "u" && (MO.prototype[Symbol.iterator] = function() {
    return this;
  });
  const _ce = {
    from: -1,
    to: -1,
    match: /.*/.exec("")
  }, fN = "gm" + (/x/.unicode == null ? "" : "u");
  class Tce {
    constructor(e, n, r, i = 0, s = e.length) {
      if (this.text = e, this.to = s, this.curLine = "", this.done = false, this.value = _ce, /\\[sWDnr]|\n|\r|\[\^/.test(n))
        return new Ece(e, n, r, i, s);
      this.re = new RegExp(n, fN + ((r == null ? void 0 : r.ignoreCase) ? "i" : "")), this.test = r == null ? void 0 : r.test, this.iter = e.iter();
      let o = e.lineAt(i);
      this.curLineStart = o.from, this.matchPos = _P(e, i), this.getLine(this.curLineStart);
    }
    getLine(e) {
      this.iter.next(e), this.iter.lineBreak ? this.curLine = "" : (this.curLine = this.iter.value, this.curLineStart + this.curLine.length > this.to && (this.curLine = this.curLine.slice(0, this.to - this.curLineStart)), this.iter.next());
    }
    nextLine() {
      this.curLineStart = this.curLineStart + this.curLine.length + 1, this.curLineStart > this.to ? this.curLine = "" : this.getLine(0);
    }
    next() {
      for (let e = this.matchPos - this.curLineStart; ; ) {
        this.re.lastIndex = e;
        let n = this.matchPos <= this.to && this.re.exec(this.curLine);
        if (n) {
          let r = this.curLineStart + n.index, i = r + n[0].length;
          if (this.matchPos = _P(this.text, i + (r == i ? 1 : 0)), r == this.curLineStart + this.curLine.length && this.nextLine(), (r < i || r > this.value.to) && (!this.test || this.test(r, i, n)))
            return this.value = {
              from: r,
              to: i,
              match: n
            }, this;
          e = this.matchPos - this.curLineStart;
        } else if (this.curLineStart + this.curLine.length < this.to)
          this.nextLine(), e = 0;
        else
          return this.done = true, this;
      }
    }
  }
  const _$ = /* @__PURE__ */ new WeakMap();
  class Pg {
    constructor(e, n) {
      this.from = e, this.text = n;
    }
    get to() {
      return this.from + this.text.length;
    }
    static get(e, n, r) {
      let i = _$.get(e);
      if (!i || i.from >= r || i.to <= n) {
        let a = new Pg(n, e.sliceString(n, r));
        return _$.set(e, a), a;
      }
      if (i.from == n && i.to == r)
        return i;
      let { text: s, from: o } = i;
      return o > n && (s = e.sliceString(n, o) + s, o = n), i.to < r && (s += e.sliceString(i.to, r)), _$.set(e, new Pg(o, s)), new Pg(n, s.slice(n - o, r - o));
    }
  }
  class Ece {
    constructor(e, n, r, i, s) {
      this.text = e, this.to = s, this.done = false, this.value = _ce, this.matchPos = _P(e, i), this.re = new RegExp(n, fN + ((r == null ? void 0 : r.ignoreCase) ? "i" : "")), this.test = r == null ? void 0 : r.test, this.flat = Pg.get(e, i, this.chunkEnd(i + 5e3));
    }
    chunkEnd(e) {
      return e >= this.to ? this.to : this.text.lineAt(e).to;
    }
    next() {
      for (; ; ) {
        let e = this.re.lastIndex = this.matchPos - this.flat.from, n = this.re.exec(this.flat.text);
        if (n && !n[0] && n.index == e && (this.re.lastIndex = e + 1, n = this.re.exec(this.flat.text)), n) {
          let r = this.flat.from + n.index, i = r + n[0].length;
          if ((this.flat.to >= this.to || n.index + n[0].length <= this.flat.text.length - 10) && (!this.test || this.test(r, i, n)))
            return this.value = {
              from: r,
              to: i,
              match: n
            }, this.matchPos = _P(this.text, i + (r == i ? 1 : 0)), this;
        }
        if (this.flat.to == this.to)
          return this.done = true, this;
        this.flat = Pg.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
      }
    }
  }
  typeof Symbol < "u" && (Tce.prototype[Symbol.iterator] = Ece.prototype[Symbol.iterator] = function() {
    return this;
  });
  function Ont(t) {
    try {
      return new RegExp(t, fN), true;
    } catch {
      return false;
    }
  }
  function _P(t, e) {
    if (e >= t.length)
      return e;
    let n = t.lineAt(e), r;
    for (; e < n.to && (r = n.text.charCodeAt(e - n.from)) >= 56320 && r < 57344; )
      e++;
    return e;
  }
  function CD(t) {
    let e = String(t.state.doc.lineAt(t.state.selection.main.head).number), n = an("input", {
      class: "cm-textfield",
      name: "line",
      value: e
    }), r = an("form", {
      class: "cm-gotoLine",
      onkeydown: (s) => {
        s.keyCode == 27 ? (s.preventDefault(), t.dispatch({
          effects: TP.of(false)
        }), t.focus()) : s.keyCode == 13 && (s.preventDefault(), i());
      },
      onsubmit: (s) => {
        s.preventDefault(), i();
      }
    }, an("label", t.state.phrase("Go to line"), ": ", n), " ", an("button", {
      class: "cm-button",
      type: "submit"
    }, t.state.phrase("go")));
    function i() {
      let s = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);
      if (!s)
        return;
      let { state: o } = t, a = o.doc.lineAt(o.selection.main.head), [, l, c, u, d] = s, h = u ? +u.slice(1) : 0, f = c ? +c : a.number;
      if (c && d) {
        let O = f / 100;
        l && (O = O * (l == "-" ? -1 : 1) + a.number / o.doc.lines), f = Math.round(o.doc.lines * O);
      } else
        c && l && (f = f * (l == "-" ? -1 : 1) + a.number);
      let y = o.doc.line(Math.max(1, Math.min(o.doc.lines, f))), g = He.cursor(y.from + Math.max(0, Math.min(h, y.length)));
      t.dispatch({
        effects: [
          TP.of(false),
          Re.scrollIntoView(g.from, {
            y: "center"
          })
        ],
        selection: g
      }), t.focus();
    }
    return {
      dom: r
    };
  }
  const TP = Dt.define(), nX = Hi.define({
    create() {
      return true;
    },
    update(t, e) {
      for (let n of e.effects)
        n.is(TP) && (t = n.value);
      return t;
    },
    provide: (t) => yO.from(t, (e) => e ? CD : null)
  }), Snt = (t) => {
    let e = mO(t, CD);
    if (!e) {
      let n = [
        TP.of(true)
      ];
      t.state.field(nX, false) == null && n.push(Dt.appendConfig.of([
        nX,
        wnt
      ])), t.dispatch({
        effects: n
      }), e = mO(t, CD);
    }
    return e && e.dom.querySelector("input").select(), true;
  }, wnt = Re.baseTheme({
    ".cm-panel.cm-gotoLine": {
      padding: "2px 6px 4px",
      "& label": {
        fontSize: "80%"
      }
    }
  }), xnt = ({ state: t, dispatch: e }) => {
    let { selection: n } = t, r = He.create(n.ranges.map((i) => t.wordAt(i.head) || He.cursor(i.head)), n.mainIndex);
    return r.eq(n) ? false : (e(t.update({
      selection: r
    })), true);
  };
  function bnt(t, e) {
    let { main: n, ranges: r } = t.selection, i = t.wordAt(n.head), s = i && i.from == n.from && i.to == n.to;
    for (let o = false, a = new MO(t.doc, e, r[r.length - 1].to); ; )
      if (a.next(), a.done) {
        if (o)
          return null;
        a = new MO(t.doc, e, 0, Math.max(0, r[r.length - 1].from - 1)), o = true;
      } else {
        if (o && r.some((l) => l.from == a.value.from))
          continue;
        if (s) {
          let l = t.wordAt(a.value.from);
          if (!l || l.from != a.value.from || l.to != a.value.to)
            continue;
        }
        return a.value;
      }
  }
  const knt = ({ state: t, dispatch: e }) => {
    let { ranges: n } = t.selection;
    if (n.some((s) => s.from === s.to))
      return xnt({
        state: t,
        dispatch: e
      });
    let r = t.sliceDoc(n[0].from, n[0].to);
    if (t.selection.ranges.some((s) => t.sliceDoc(s.from, s.to) != r))
      return false;
    let i = bnt(t, r);
    return i ? (e(t.update({
      selection: t.selection.addRange(He.range(i.from, i.to), false),
      effects: Re.scrollIntoView(i.to)
    })), true) : false;
  }, Xm = $r.define({
    combine(t) {
      return j2(t, {
        top: false,
        caseSensitive: false,
        literal: false,
        regexp: false,
        wholeWord: false,
        createPanel: (e) => new Lnt(e),
        scrollToMatch: (e) => Re.scrollIntoView(e)
      });
    }
  });
  class Ice {
    constructor(e) {
      this.search = e.search, this.caseSensitive = !!e.caseSensitive, this.literal = !!e.literal, this.regexp = !!e.regexp, this.replace = e.replace || "", this.valid = !!this.search && (!this.regexp || Ont(this.search)), this.unquoted = this.unquote(this.search), this.wholeWord = !!e.wholeWord;
    }
    unquote(e) {
      return this.literal ? e : e.replace(/\\([nrt\\])/g, (n, r) => r == "n" ? `
` : r == "r" ? "\r" : r == "t" ? "	" : "\\");
    }
    eq(e) {
      return this.search == e.search && this.replace == e.replace && this.caseSensitive == e.caseSensitive && this.regexp == e.regexp && this.wholeWord == e.wholeWord;
    }
    create() {
      return this.regexp ? new Tnt(this) : new Cnt(this);
    }
    getCursor(e, n = 0, r) {
      let i = e.doc ? e : Hn.create({
        doc: e
      });
      return r == null && (r = i.doc.length), this.regexp ? Lp(this, i, n, r) : Dp(this, i, n, r);
    }
  }
  class $ce {
    constructor(e) {
      this.spec = e;
    }
  }
  function Dp(t, e, n, r) {
    return new MO(e.doc, t.unquoted, n, r, t.caseSensitive ? void 0 : (i) => i.toLowerCase(), t.wholeWord ? Pnt(e.doc, e.charCategorizer(e.selection.main.head)) : void 0);
  }
  function Pnt(t, e) {
    return (n, r, i, s) => ((s > n || s + i.length < r) && (s = Math.max(0, n - 2), i = t.sliceString(s, Math.min(t.length, r + 2))), (e(EP(i, n - s)) != Si.Word || e(IP(i, n - s)) != Si.Word) && (e(IP(i, r - s)) != Si.Word || e(EP(i, r - s)) != Si.Word));
  }
  class Cnt extends $ce {
    constructor(e) {
      super(e);
    }
    nextMatch(e, n, r) {
      let i = Dp(this.spec, e, r, e.doc.length).nextOverlapping();
      return i.done && (i = Dp(this.spec, e, 0, n).nextOverlapping()), i.done ? null : i.value;
    }
    prevMatchInRange(e, n, r) {
      for (let i = r; ; ) {
        let s = Math.max(n, i - 1e4 - this.spec.unquoted.length), o = Dp(this.spec, e, s, i), a = null;
        for (; !o.nextOverlapping().done; )
          a = o.value;
        if (a)
          return a;
        if (s == n)
          return null;
        i -= 1e4;
      }
    }
    prevMatch(e, n, r) {
      return this.prevMatchInRange(e, 0, n) || this.prevMatchInRange(e, r, e.doc.length);
    }
    getReplacement(e) {
      return this.spec.unquote(this.spec.replace);
    }
    matchAll(e, n) {
      let r = Dp(this.spec, e, 0, e.doc.length), i = [];
      for (; !r.next().done; ) {
        if (i.length >= n)
          return null;
        i.push(r.value);
      }
      return i;
    }
    highlight(e, n, r, i) {
      let s = Dp(this.spec, e, Math.max(0, n - this.spec.unquoted.length), Math.min(r + this.spec.unquoted.length, e.doc.length));
      for (; !s.next().done; )
        i(s.value.from, s.value.to);
    }
  }
  function Lp(t, e, n, r) {
    return new Tce(e.doc, t.search, {
      ignoreCase: !t.caseSensitive,
      test: t.wholeWord ? _nt(e.charCategorizer(e.selection.main.head)) : void 0
    }, n, r);
  }
  function EP(t, e) {
    return t.slice(Vl(t, e, false), e);
  }
  function IP(t, e) {
    return t.slice(e, Vl(t, e));
  }
  function _nt(t) {
    return (e, n, r) => !r[0].length || (t(EP(r.input, r.index)) != Si.Word || t(IP(r.input, r.index)) != Si.Word) && (t(IP(r.input, r.index + r[0].length)) != Si.Word || t(EP(r.input, r.index + r[0].length)) != Si.Word);
  }
  class Tnt extends $ce {
    nextMatch(e, n, r) {
      let i = Lp(this.spec, e, r, e.doc.length).next();
      return i.done && (i = Lp(this.spec, e, 0, n).next()), i.done ? null : i.value;
    }
    prevMatchInRange(e, n, r) {
      for (let i = 1; ; i++) {
        let s = Math.max(n, r - i * 1e4), o = Lp(this.spec, e, s, r), a = null;
        for (; !o.next().done; )
          a = o.value;
        if (a && (s == n || a.from > s + 10))
          return a;
        if (s == n)
          return null;
      }
    }
    prevMatch(e, n, r) {
      return this.prevMatchInRange(e, 0, n) || this.prevMatchInRange(e, r, e.doc.length);
    }
    getReplacement(e) {
      return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g, (n, r) => r == "$" ? "$" : r == "&" ? e.match[0] : r != "0" && +r < e.match.length ? e.match[r] : n);
    }
    matchAll(e, n) {
      let r = Lp(this.spec, e, 0, e.doc.length), i = [];
      for (; !r.next().done; ) {
        if (i.length >= n)
          return null;
        i.push(r.value);
      }
      return i;
    }
    highlight(e, n, r, i) {
      let s = Lp(this.spec, e, Math.max(0, n - 250), Math.min(r + 250, e.doc.length));
      for (; !s.next().done; )
        i(s.value.from, s.value.to);
    }
  }
  const DO = Dt.define(), pN = Dt.define(), vd = Hi.define({
    create(t) {
      return new T$(_D(t).create(), null);
    },
    update(t, e) {
      for (let n of e.effects)
        n.is(DO) ? t = new T$(n.value.create(), t.panel) : n.is(pN) && (t = new T$(t.query, n.value ? gN : null));
      return t;
    },
    provide: (t) => yO.from(t, (e) => e.panel)
  });
  class T$ {
    constructor(e, n) {
      this.query = e, this.panel = n;
    }
  }
  const Ent = Qe.mark({
    class: "cm-searchMatch"
  }), Int = Qe.mark({
    class: "cm-searchMatch cm-searchMatch-selected"
  }), $nt = ur.fromClass(class {
    constructor(t) {
      this.view = t, this.decorations = this.highlight(t.state.field(vd));
    }
    update(t) {
      let e = t.state.field(vd);
      (e != t.startState.field(vd) || t.docChanged || t.selectionSet || t.viewportChanged) && (this.decorations = this.highlight(e));
    }
    highlight({ query: t, panel: e }) {
      if (!e || !t.spec.valid)
        return Qe.none;
      let { view: n } = this, r = new $O();
      for (let i = 0, s = n.visibleRanges, o = s.length; i < o; i++) {
        let { from: a, to: l } = s[i];
        for (; i < o - 1 && l > s[i + 1].from - 2 * 250; )
          l = s[++i].to;
        t.highlight(n.state, a, l, (c, u) => {
          let d = n.state.selection.ranges.some((h) => h.from == c && h.to == u);
          r.add(c, u, d ? Int : Ent);
        });
      }
      return r.finish();
    }
  }, {
    decorations: (t) => t.decorations
  });
  function IS(t) {
    return (e) => {
      let n = e.state.field(vd, false);
      return n && n.query.spec.valid ? t(e, n) : Mce(e);
    };
  }
  const $P = IS((t, { query: e }) => {
    let { to: n } = t.state.selection.main, r = e.nextMatch(t.state, n, n);
    if (!r)
      return false;
    let i = He.single(r.from, r.to), s = t.state.facet(Xm);
    return t.dispatch({
      selection: i,
      effects: [
        mN(t, r),
        s.scrollToMatch(i.main, t)
      ],
      userEvent: "select.search"
    }), Rce(t), true;
  }), AP = IS((t, { query: e }) => {
    let { state: n } = t, { from: r } = n.selection.main, i = e.prevMatch(n, r, r);
    if (!i)
      return false;
    let s = He.single(i.from, i.to), o = t.state.facet(Xm);
    return t.dispatch({
      selection: s,
      effects: [
        mN(t, i),
        o.scrollToMatch(s.main, t)
      ],
      userEvent: "select.search"
    }), Rce(t), true;
  }), Ant = IS((t, { query: e }) => {
    let n = e.matchAll(t.state, 1e3);
    return !n || !n.length ? false : (t.dispatch({
      selection: He.create(n.map((r) => He.range(r.from, r.to))),
      userEvent: "select.search.matches"
    }), true);
  }), Rnt = ({ state: t, dispatch: e }) => {
    let n = t.selection;
    if (n.ranges.length > 1 || n.main.empty)
      return false;
    let { from: r, to: i } = n.main, s = [], o = 0;
    for (let a = new MO(t.doc, t.sliceDoc(r, i)); !a.next().done; ) {
      if (s.length > 1e3)
        return false;
      a.value.from == r && (o = s.length), s.push(He.range(a.value.from, a.value.to));
    }
    return e(t.update({
      selection: He.create(s, o),
      userEvent: "select.search.matches"
    })), true;
  }, rX = IS((t, { query: e }) => {
    let { state: n } = t, { from: r, to: i } = n.selection.main;
    if (n.readOnly)
      return false;
    let s = e.nextMatch(n, r, r);
    if (!s)
      return false;
    let o = [], a, l, c = [];
    if (s.from == r && s.to == i && (l = n.toText(e.getReplacement(s)), o.push({
      from: s.from,
      to: s.to,
      insert: l
    }), s = e.nextMatch(n, s.from, s.to), c.push(Re.announce.of(n.phrase("replaced match on line $", n.doc.lineAt(r).number) + "."))), s) {
      let u = o.length == 0 || o[0].from >= s.to ? 0 : s.to - s.from - l.length;
      a = He.single(s.from - u, s.to - u), c.push(mN(t, s)), c.push(n.facet(Xm).scrollToMatch(a.main, t));
    }
    return t.dispatch({
      changes: o,
      selection: a,
      effects: c,
      userEvent: "input.replace"
    }), true;
  }), Mnt = IS((t, { query: e }) => {
    if (t.state.readOnly)
      return false;
    let n = e.matchAll(t.state, 1e9).map((i) => {
      let { from: s, to: o } = i;
      return {
        from: s,
        to: o,
        insert: e.getReplacement(i)
      };
    });
    if (!n.length)
      return false;
    let r = t.state.phrase("replaced $ matches", n.length) + ".";
    return t.dispatch({
      changes: n,
      effects: Re.announce.of(r),
      userEvent: "input.replace.all"
    }), true;
  });
  function gN(t) {
    return t.state.facet(Xm).createPanel(t);
  }
  function _D(t, e) {
    var n, r, i, s, o;
    let a = t.selection.main, l = a.empty || a.to > a.from + 100 ? "" : t.sliceDoc(a.from, a.to);
    if (e && !l)
      return e;
    let c = t.facet(Xm);
    return new Ice({
      search: ((n = e == null ? void 0 : e.literal) !== null && n !== void 0 ? n : c.literal) ? l : l.replace(/\n/g, "\\n"),
      caseSensitive: (r = e == null ? void 0 : e.caseSensitive) !== null && r !== void 0 ? r : c.caseSensitive,
      literal: (i = e == null ? void 0 : e.literal) !== null && i !== void 0 ? i : c.literal,
      regexp: (s = e == null ? void 0 : e.regexp) !== null && s !== void 0 ? s : c.regexp,
      wholeWord: (o = e == null ? void 0 : e.wholeWord) !== null && o !== void 0 ? o : c.wholeWord
    });
  }
  function Ace(t) {
    let e = mO(t, gN);
    return e && e.dom.querySelector("[main-field]");
  }
  function Rce(t) {
    let e = Ace(t);
    e && e == t.root.activeElement && e.select();
  }
  const Mce = (t) => {
    let e = t.state.field(vd, false);
    if (e && e.panel) {
      let n = Ace(t);
      if (n && n != t.root.activeElement) {
        let r = _D(t.state, e.query.spec);
        r.valid && t.dispatch({
          effects: DO.of(r)
        }), n.focus(), n.select();
      }
    } else
      t.dispatch({
        effects: [
          pN.of(true),
          e ? DO.of(_D(t.state, e.query.spec)) : Dt.appendConfig.of(Nnt)
        ]
      });
    return true;
  }, Dce = (t) => {
    let e = t.state.field(vd, false);
    if (!e || !e.panel)
      return false;
    let n = mO(t, gN);
    return n && n.dom.contains(t.root.activeElement) && t.focus(), t.dispatch({
      effects: pN.of(false)
    }), true;
  }, Dnt = [
    {
      key: "Mod-f",
      run: Mce,
      scope: "editor search-panel"
    },
    {
      key: "F3",
      run: $P,
      shift: AP,
      scope: "editor search-panel",
      preventDefault: true
    },
    {
      key: "Mod-g",
      run: $P,
      shift: AP,
      scope: "editor search-panel",
      preventDefault: true
    },
    {
      key: "Escape",
      run: Dce,
      scope: "editor search-panel"
    },
    {
      key: "Mod-Shift-l",
      run: Rnt
    },
    {
      key: "Mod-Alt-g",
      run: Snt
    },
    {
      key: "Mod-d",
      run: knt,
      preventDefault: true
    }
  ];
  class Lnt {
    constructor(e) {
      this.view = e;
      let n = this.query = e.state.field(vd).query.spec;
      this.commit = this.commit.bind(this), this.searchField = an("input", {
        value: n.search,
        placeholder: js(e, "Find"),
        "aria-label": js(e, "Find"),
        class: "cm-textfield",
        name: "search",
        form: "",
        "main-field": "true",
        onchange: this.commit,
        onkeyup: this.commit
      }), this.replaceField = an("input", {
        value: n.replace,
        placeholder: js(e, "Replace"),
        "aria-label": js(e, "Replace"),
        class: "cm-textfield",
        name: "replace",
        form: "",
        onchange: this.commit,
        onkeyup: this.commit
      }), this.caseField = an("input", {
        type: "checkbox",
        name: "case",
        form: "",
        checked: n.caseSensitive,
        onchange: this.commit
      }), this.reField = an("input", {
        type: "checkbox",
        name: "re",
        form: "",
        checked: n.regexp,
        onchange: this.commit
      }), this.wordField = an("input", {
        type: "checkbox",
        name: "word",
        form: "",
        checked: n.wholeWord,
        onchange: this.commit
      });
      function r(i, s, o) {
        return an("button", {
          class: "cm-button",
          name: i,
          onclick: s,
          type: "button"
        }, o);
      }
      this.dom = an("div", {
        onkeydown: (i) => this.keydown(i),
        class: "cm-search"
      }, [
        this.searchField,
        r("next", () => $P(e), [
          js(e, "next")
        ]),
        r("prev", () => AP(e), [
          js(e, "previous")
        ]),
        r("select", () => Ant(e), [
          js(e, "all")
        ]),
        an("label", null, [
          this.caseField,
          js(e, "match case")
        ]),
        an("label", null, [
          this.reField,
          js(e, "regexp")
        ]),
        an("label", null, [
          this.wordField,
          js(e, "by word")
        ]),
        ...e.state.readOnly ? [] : [
          an("br"),
          this.replaceField,
          r("replace", () => rX(e), [
            js(e, "replace")
          ]),
          r("replaceAll", () => Mnt(e), [
            js(e, "replace all")
          ])
        ],
        an("button", {
          name: "close",
          onclick: () => Dce(e),
          "aria-label": js(e, "close"),
          type: "button"
        }, [
          "\xD7"
        ])
      ]);
    }
    commit() {
      let e = new Ice({
        search: this.searchField.value,
        caseSensitive: this.caseField.checked,
        regexp: this.reField.checked,
        wholeWord: this.wordField.checked,
        replace: this.replaceField.value
      });
      e.eq(this.query) || (this.query = e, this.view.dispatch({
        effects: DO.of(e)
      }));
    }
    keydown(e) {
      lGe(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? AP : $P)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), rX(this.view));
    }
    update(e) {
      for (let n of e.transactions)
        for (let r of n.effects)
          r.is(DO) && !r.value.eq(this.query) && this.setQuery(r.value);
    }
    setQuery(e) {
      this.query = e, this.searchField.value = e.search, this.replaceField.value = e.replace, this.caseField.checked = e.caseSensitive, this.reField.checked = e.regexp, this.wordField.checked = e.wholeWord;
    }
    mount() {
      this.searchField.select();
    }
    get pos() {
      return 80;
    }
    get top() {
      return this.view.state.facet(Xm).top;
    }
  }
  function js(t, e) {
    return t.state.phrase(e);
  }
  const Sx = 30, wx = /[\s\.,:;?!]/;
  function mN(t, { from: e, to: n }) {
    let r = t.state.doc.lineAt(e), i = t.state.doc.lineAt(n).to, s = Math.max(r.from, e - Sx), o = Math.min(i, n + Sx), a = t.state.sliceDoc(s, o);
    if (s != r.from) {
      for (let l = 0; l < Sx; l++)
        if (!wx.test(a[l + 1]) && wx.test(a[l])) {
          a = a.slice(l);
          break;
        }
    }
    if (o != i) {
      for (let l = a.length - 1; l > a.length - Sx; l--)
        if (!wx.test(a[l - 1]) && wx.test(a[l])) {
          a = a.slice(0, l);
          break;
        }
    }
    return Re.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${r.number}.`);
  }
  const jnt = Re.baseTheme({
    ".cm-panel.cm-search": {
      padding: "2px 6px 4px",
      position: "relative",
      "& [name=close]": {
        position: "absolute",
        top: "0",
        right: "4px",
        backgroundColor: "inherit",
        border: "none",
        font: "inherit",
        padding: 0,
        margin: 0
      },
      "& input, & button, & label": {
        margin: ".2em .6em .2em 0"
      },
      "& input[type=checkbox]": {
        marginRight: ".2em"
      },
      "& label": {
        fontSize: "80%",
        whiteSpace: "pre"
      }
    },
    "&light .cm-searchMatch": {
      backgroundColor: "#ffff0054"
    },
    "&dark .cm-searchMatch": {
      backgroundColor: "#00ffff8a"
    },
    "&light .cm-searchMatch-selected": {
      backgroundColor: "#ff6a0054"
    },
    "&dark .cm-searchMatch-selected": {
      backgroundColor: "#ff00ff8a"
    }
  }), Nnt = [
    vd,
    dtt.low($nt),
    jnt
  ];
  class Qnt {
    constructor(e, n, r) {
      this.state = e, this.pos = n, this.explicit = r, this.abortListeners = [];
    }
    tokenBefore(e) {
      let n = Un(this.state).resolveInner(this.pos, -1);
      for (; n && e.indexOf(n.name) < 0; )
        n = n.parent;
      return n ? {
        from: n.from,
        to: this.pos,
        text: this.state.sliceDoc(n.from, this.pos),
        type: n.type
      } : null;
    }
    matchBefore(e) {
      let n = this.state.doc.lineAt(this.pos), r = Math.max(n.from, this.pos - 250), i = n.text.slice(r - n.from, this.pos - n.from), s = i.search(Lce(e, false));
      return s < 0 ? null : {
        from: r + s,
        to: this.pos,
        text: i.slice(s)
      };
    }
    get aborted() {
      return this.abortListeners == null;
    }
    addEventListener(e, n) {
      e == "abort" && this.abortListeners && this.abortListeners.push(n);
    }
  }
  function iX(t) {
    let e = Object.keys(t).join(""), n = /\w/.test(e);
    return n && (e = e.replace(/\w/g, "")), `[${n ? "\\w" : ""}${e.replace(/[^\w\s]/g, "\\$&")}]`;
  }
  function znt(t) {
    let e = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ Object.create(null);
    for (let { label: i } of t) {
      e[i[0]] = true;
      for (let s = 1; s < i.length; s++)
        n[i[s]] = true;
    }
    let r = iX(e) + iX(n) + "*$";
    return [
      new RegExp("^" + r),
      new RegExp(r)
    ];
  }
  function Fnt(t) {
    let e = t.map((i) => typeof i == "string" ? {
      label: i
    } : i), [n, r] = e.every((i) => /^\w+$/.test(i.label)) ? [
      /\w*$/,
      /\w+$/
    ] : znt(e);
    return (i) => {
      let s = i.matchBefore(r);
      return s || i.explicit ? {
        from: s ? s.from : i.pos,
        options: e,
        validFor: n
      } : null;
    };
  }
  class sX {
    constructor(e, n, r, i) {
      this.completion = e, this.source = n, this.match = r, this.score = i;
    }
  }
  function Cg(t) {
    return t.selection.main.from;
  }
  function Lce(t, e) {
    var n;
    let { source: r } = t, i = e && r[0] != "^", s = r[r.length - 1] != "$";
    return !i && !s ? t : new RegExp(`${i ? "^" : ""}(?:${r})${s ? "$" : ""}`, (n = t.flags) !== null && n !== void 0 ? n : t.ignoreCase ? "i" : "");
  }
  const jce = Zd.define();
  function Bnt(t, e, n, r) {
    let { main: i } = t.selection, s = n - i.from, o = r - i.from;
    return Object.assign(Object.assign({}, t.changeByRange((a) => a != i && n != r && t.sliceDoc(a.from + s, a.from + o) != t.sliceDoc(n, r) ? {
      range: a
    } : {
      changes: {
        from: a.from + s,
        to: r == i.from ? a.to : a.from + o,
        insert: e
      },
      range: He.cursor(a.from + s + e.length)
    })), {
      scrollIntoView: true,
      userEvent: "input.complete"
    });
  }
  const oX = /* @__PURE__ */ new WeakMap();
  function Unt(t) {
    if (!Array.isArray(t))
      return t;
    let e = oX.get(t);
    return e || oX.set(t, e = Fnt(t)), e;
  }
  const Nce = Dt.define(), yN = Dt.define();
  class Vnt {
    constructor(e) {
      this.pattern = e, this.chars = [], this.folded = [], this.any = [], this.precise = [], this.byWord = [], this.score = 0, this.matched = [];
      for (let n = 0; n < e.length; ) {
        let r = Sl(e, n), i = Vu(r);
        this.chars.push(r);
        let s = e.slice(n, n + i), o = s.toUpperCase();
        this.folded.push(Sl(o == s ? s.toLowerCase() : o, 0)), n += i;
      }
      this.astral = e.length != this.chars.length;
    }
    ret(e, n) {
      return this.score = e, this.matched = n, this;
    }
    match(e) {
      if (this.pattern.length == 0)
        return this.ret(-100, []);
      if (e.length < this.pattern.length)
        return null;
      let { chars: n, folded: r, any: i, precise: s, byWord: o } = this;
      if (n.length == 1) {
        let w = Sl(e, 0), x = Vu(w), P = x == e.length ? 0 : -100;
        if (w != n[0])
          if (w == r[0])
            P += -200;
          else
            return null;
        return this.ret(P, [
          0,
          x
        ]);
      }
      let a = e.indexOf(this.pattern);
      if (a == 0)
        return this.ret(e.length == this.pattern.length ? 0 : -100, [
          0,
          this.pattern.length
        ]);
      let l = n.length, c = 0;
      if (a < 0) {
        for (let w = 0, x = Math.min(e.length, 200); w < x && c < l; ) {
          let P = Sl(e, w);
          (P == n[c] || P == r[c]) && (i[c++] = w), w += Vu(P);
        }
        if (c < l)
          return null;
      }
      let u = 0, d = 0, h = false, f = 0, y = -1, g = -1, O = /[a-z]/.test(e), S = true;
      for (let w = 0, x = Math.min(e.length, 200), P = 0; w < x && d < l; ) {
        let C = Sl(e, w);
        a < 0 && (u < l && C == n[u] && (s[u++] = w), f < l && (C == n[f] || C == r[f] ? (f == 0 && (y = w), g = w + 1, f++) : f = 0));
        let _, T = C < 255 ? C >= 48 && C <= 57 || C >= 97 && C <= 122 ? 2 : C >= 65 && C <= 90 ? 1 : 0 : (_ = Lle(C)) != _.toLowerCase() ? 1 : _ != _.toUpperCase() ? 2 : 0;
        (!w || T == 1 && O || P == 0 && T != 0) && (n[d] == C || r[d] == C && (h = true) ? o[d++] = w : o.length && (S = false)), P = T, w += Vu(C);
      }
      return d == l && o[0] == 0 && S ? this.result(-100 + (h ? -200 : 0), o, e) : f == l && y == 0 ? this.ret(-200 - e.length + (g == e.length ? 0 : -100), [
        0,
        g
      ]) : a > -1 ? this.ret(-700 - e.length, [
        a,
        a + this.pattern.length
      ]) : f == l ? this.ret(-200 + -700 - e.length, [
        y,
        g
      ]) : d == l ? this.result(-100 + (h ? -200 : 0) + -700 + (S ? 0 : -1100), o, e) : n.length == 2 ? null : this.result((i[0] ? -700 : 0) + -200 + -1100, i, e);
    }
    result(e, n, r) {
      let i = [], s = 0;
      for (let o of n) {
        let a = o + (this.astral ? Vu(Sl(r, o)) : 1);
        s && i[s - 1] == o ? i[s - 1] = a : (i[s++] = o, i[s++] = a);
      }
      return this.ret(e - r.length, i);
    }
  }
  class Xnt {
    constructor(e) {
      this.pattern = e, this.matched = [], this.score = 0, this.folded = e.toLowerCase();
    }
    match(e) {
      if (e.length < this.pattern.length)
        return null;
      let n = e.slice(0, this.pattern.length), r = n == this.pattern ? 0 : n.toLowerCase() == this.folded ? -200 : null;
      return r == null ? null : (this.matched = [
        0,
        n.length
      ], this.score = r + (e.length == this.pattern.length ? 0 : -100), this);
    }
  }
  const Cl = $r.define({
    combine(t) {
      return j2(t, {
        activateOnTyping: true,
        activateOnCompletion: () => false,
        activateOnTypingDelay: 100,
        selectOnOpen: true,
        override: null,
        closeOnBlur: true,
        maxRenderedOptions: 100,
        defaultKeymap: true,
        tooltipClass: () => "",
        optionClass: () => "",
        aboveCursor: false,
        icons: true,
        addToOptions: [],
        positionInfo: Wnt,
        filterStrict: false,
        compareCompletions: (e, n) => e.label.localeCompare(n.label),
        interactionDelay: 75,
        updateSyncTime: 100
      }, {
        defaultKeymap: (e, n) => e && n,
        closeOnBlur: (e, n) => e && n,
        icons: (e, n) => e && n,
        tooltipClass: (e, n) => (r) => aX(e(r), n(r)),
        optionClass: (e, n) => (r) => aX(e(r), n(r)),
        addToOptions: (e, n) => e.concat(n),
        filterStrict: (e, n) => e || n
      });
    }
  });
  function aX(t, e) {
    return t ? e ? t + " " + e : t : e;
  }
  function Wnt(t, e, n, r, i, s) {
    let o = t.textDirection == er.RTL, a = o, l = false, c = "top", u, d, h = e.left - i.left, f = i.right - e.right, y = r.right - r.left, g = r.bottom - r.top;
    if (a && h < Math.min(y, f) ? a = false : !a && f < Math.min(y, h) && (a = true), y <= (a ? h : f))
      u = Math.max(i.top, Math.min(n.top, i.bottom - g)) - e.top, d = Math.min(400, a ? h : f);
    else {
      l = true, d = Math.min(400, (o ? e.right : i.right - e.left) - 30);
      let w = i.bottom - e.bottom;
      w >= g || w > e.top ? u = n.bottom - e.top : (c = "bottom", u = e.bottom - n.top);
    }
    let O = (e.bottom - e.top) / s.offsetHeight, S = (e.right - e.left) / s.offsetWidth;
    return {
      style: `${c}: ${u / O}px; max-width: ${d / S}px`,
      class: "cm-completionInfo-" + (l ? o ? "left-narrow" : "right-narrow" : a ? "left" : "right")
    };
  }
  function Znt(t) {
    let e = t.addToOptions.slice();
    return t.icons && e.push({
      render(n) {
        let r = document.createElement("div");
        return r.classList.add("cm-completionIcon"), n.type && r.classList.add(...n.type.split(/\s+/g).map((i) => "cm-completionIcon-" + i)), r.setAttribute("aria-hidden", "true"), r;
      },
      position: 20
    }), e.push({
      render(n, r, i, s) {
        let o = document.createElement("span");
        o.className = "cm-completionLabel";
        let a = n.displayLabel || n.label, l = 0;
        for (let c = 0; c < s.length; ) {
          let u = s[c++], d = s[c++];
          u > l && o.appendChild(document.createTextNode(a.slice(l, u)));
          let h = o.appendChild(document.createElement("span"));
          h.appendChild(document.createTextNode(a.slice(u, d))), h.className = "cm-completionMatchedText", l = d;
        }
        return l < a.length && o.appendChild(document.createTextNode(a.slice(l))), o;
      },
      position: 50
    }, {
      render(n) {
        if (!n.detail)
          return null;
        let r = document.createElement("span");
        return r.className = "cm-completionDetail", r.textContent = n.detail, r;
      },
      position: 80
    }), e.sort((n, r) => n.position - r.position).map((n) => n.render);
  }
  function E$(t, e, n) {
    if (t <= n)
      return {
        from: 0,
        to: t
      };
    if (e < 0 && (e = 0), e <= t >> 1) {
      let i = Math.floor(e / n);
      return {
        from: i * n,
        to: (i + 1) * n
      };
    }
    let r = Math.floor((t - e) / n);
    return {
      from: t - (r + 1) * n,
      to: t - r * n
    };
  }
  class Hnt {
    constructor(e, n, r) {
      this.view = e, this.stateField = n, this.applyCompletion = r, this.info = null, this.infoDestroy = null, this.placeInfoReq = {
        read: () => this.measureInfo(),
        write: (l) => this.placeInfo(l),
        key: this
      }, this.space = null, this.currentClass = "";
      let i = e.state.field(n), { options: s, selected: o } = i.open, a = e.state.facet(Cl);
      this.optionContent = Znt(a), this.optionClass = a.optionClass, this.tooltipClass = a.tooltipClass, this.range = E$(s.length, o, a.maxRenderedOptions), this.dom = document.createElement("div"), this.dom.className = "cm-tooltip-autocomplete", this.updateTooltipClass(e.state), this.dom.addEventListener("mousedown", (l) => {
        let { options: c } = e.state.field(n).open;
        for (let u = l.target, d; u && u != this.dom; u = u.parentNode)
          if (u.nodeName == "LI" && (d = /-(\d+)$/.exec(u.id)) && +d[1] < c.length) {
            this.applyCompletion(e, c[+d[1]]), l.preventDefault();
            return;
          }
      }), this.dom.addEventListener("focusout", (l) => {
        let c = e.state.field(this.stateField, false);
        c && c.tooltip && e.state.facet(Cl).closeOnBlur && l.relatedTarget != e.contentDOM && e.dispatch({
          effects: yN.of(null)
        });
      }), this.showOptions(s, i.id);
    }
    mount() {
      this.updateSel();
    }
    showOptions(e, n) {
      this.list && this.list.remove(), this.list = this.dom.appendChild(this.createListBox(e, n, this.range)), this.list.addEventListener("scroll", () => {
        this.info && this.view.requestMeasure(this.placeInfoReq);
      });
    }
    update(e) {
      var n;
      let r = e.state.field(this.stateField), i = e.startState.field(this.stateField);
      if (this.updateTooltipClass(e.state), r != i) {
        let { options: s, selected: o, disabled: a } = r.open;
        (!i.open || i.open.options != s) && (this.range = E$(s.length, o, e.state.facet(Cl).maxRenderedOptions), this.showOptions(s, r.id)), this.updateSel(), a != ((n = i.open) === null || n === void 0 ? void 0 : n.disabled) && this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!a);
      }
    }
    updateTooltipClass(e) {
      let n = this.tooltipClass(e);
      if (n != this.currentClass) {
        for (let r of this.currentClass.split(" "))
          r && this.dom.classList.remove(r);
        for (let r of n.split(" "))
          r && this.dom.classList.add(r);
        this.currentClass = n;
      }
    }
    positioned(e) {
      this.space = e, this.info && this.view.requestMeasure(this.placeInfoReq);
    }
    updateSel() {
      let e = this.view.state.field(this.stateField), n = e.open;
      if ((n.selected > -1 && n.selected < this.range.from || n.selected >= this.range.to) && (this.range = E$(n.options.length, n.selected, this.view.state.facet(Cl).maxRenderedOptions), this.showOptions(n.options, e.id)), this.updateSelectedOption(n.selected)) {
        this.destroyInfo();
        let { completion: r } = n.options[n.selected], { info: i } = r;
        if (!i)
          return;
        let s = typeof i == "string" ? document.createTextNode(i) : i(r);
        if (!s)
          return;
        "then" in s ? s.then((o) => {
          o && this.view.state.field(this.stateField, false) == e && this.addInfoPane(o, r);
        }).catch((o) => Vo(this.view.state, o, "completion info")) : this.addInfoPane(s, r);
      }
    }
    addInfoPane(e, n) {
      this.destroyInfo();
      let r = this.info = document.createElement("div");
      if (r.className = "cm-tooltip cm-completionInfo", e.nodeType != null)
        r.appendChild(e), this.infoDestroy = null;
      else {
        let { dom: i, destroy: s } = e;
        r.appendChild(i), this.infoDestroy = s || null;
      }
      this.dom.appendChild(r), this.view.requestMeasure(this.placeInfoReq);
    }
    updateSelectedOption(e) {
      let n = null;
      for (let r = this.list.firstChild, i = this.range.from; r; r = r.nextSibling, i++)
        r.nodeName != "LI" || !r.id ? i-- : i == e ? r.hasAttribute("aria-selected") || (r.setAttribute("aria-selected", "true"), n = r) : r.hasAttribute("aria-selected") && r.removeAttribute("aria-selected");
      return n && Gnt(this.list, n), n;
    }
    measureInfo() {
      let e = this.dom.querySelector("[aria-selected]");
      if (!e || !this.info)
        return null;
      let n = this.dom.getBoundingClientRect(), r = this.info.getBoundingClientRect(), i = e.getBoundingClientRect(), s = this.space;
      if (!s) {
        let o = this.dom.ownerDocument.defaultView || window;
        s = {
          left: 0,
          top: 0,
          right: o.innerWidth,
          bottom: o.innerHeight
        };
      }
      return i.top > Math.min(s.bottom, n.bottom) - 10 || i.bottom < Math.max(s.top, n.top) + 10 ? null : this.view.state.facet(Cl).positionInfo(this.view, n, i, r, s, this.dom);
    }
    placeInfo(e) {
      this.info && (e ? (e.style && (this.info.style.cssText = e.style), this.info.className = "cm-tooltip cm-completionInfo " + (e.class || "")) : this.info.style.cssText = "top: -1e6px");
    }
    createListBox(e, n, r) {
      const i = document.createElement("ul");
      i.id = n, i.setAttribute("role", "listbox"), i.setAttribute("aria-expanded", "true"), i.setAttribute("aria-label", this.view.state.phrase("Completions"));
      let s = null;
      for (let o = r.from; o < r.to; o++) {
        let { completion: a, match: l } = e[o], { section: c } = a;
        if (c) {
          let h = typeof c == "string" ? c : c.name;
          if (h != s && (o > r.from || r.from == 0))
            if (s = h, typeof c != "string" && c.header)
              i.appendChild(c.header(c));
            else {
              let f = i.appendChild(document.createElement("completion-section"));
              f.textContent = h;
            }
        }
        const u = i.appendChild(document.createElement("li"));
        u.id = n + "-" + o, u.setAttribute("role", "option");
        let d = this.optionClass(a);
        d && (u.className = d);
        for (let h of this.optionContent) {
          let f = h(a, this.view.state, this.view, l);
          f && u.appendChild(f);
        }
      }
      return r.from && i.classList.add("cm-completionListIncompleteTop"), r.to < e.length && i.classList.add("cm-completionListIncompleteBottom"), i;
    }
    destroyInfo() {
      this.info && (this.infoDestroy && this.infoDestroy(), this.info.remove(), this.info = null);
    }
    destroy() {
      this.destroyInfo();
    }
  }
  function Ynt(t, e) {
    return (n) => new Hnt(n, t, e);
  }
  function Gnt(t, e) {
    let n = t.getBoundingClientRect(), r = e.getBoundingClientRect(), i = n.height / t.offsetHeight;
    r.top < n.top ? t.scrollTop -= (n.top - r.top) / i : r.bottom > n.bottom && (t.scrollTop += (r.bottom - n.bottom) / i);
  }
  function lX(t) {
    return (t.boost || 0) * 100 + (t.apply ? 10 : 0) + (t.info ? 5 : 0) + (t.type ? 1 : 0);
  }
  function qnt(t, e) {
    let n = [], r = null, i = (c) => {
      n.push(c);
      let { section: u } = c.completion;
      if (u) {
        r || (r = []);
        let d = typeof u == "string" ? u : u.name;
        r.some((h) => h.name == d) || r.push(typeof u == "string" ? {
          name: d
        } : u);
      }
    }, s = e.facet(Cl);
    for (let c of t)
      if (c.hasResult()) {
        let u = c.result.getMatch;
        if (c.result.filter === false)
          for (let d of c.result.options)
            i(new sX(d, c.source, u ? u(d) : [], 1e9 - n.length));
        else {
          let d = e.sliceDoc(c.from, c.to), h, f = s.filterStrict ? new Xnt(d) : new Vnt(d);
          for (let y of c.result.options)
            if (h = f.match(y.label)) {
              let g = y.displayLabel ? u ? u(y, h.matched) : [] : h.matched;
              i(new sX(y, c.source, g, h.score + (y.boost || 0)));
            }
        }
      }
    if (r) {
      let c = /* @__PURE__ */ Object.create(null), u = 0, d = (h, f) => {
        var y, g;
        return ((y = h.rank) !== null && y !== void 0 ? y : 1e9) - ((g = f.rank) !== null && g !== void 0 ? g : 1e9) || (h.name < f.name ? -1 : 1);
      };
      for (let h of r.sort(d))
        u -= 1e5, c[h.name] = u;
      for (let h of n) {
        let { section: f } = h.completion;
        f && (h.score += c[typeof f == "string" ? f : f.name]);
      }
    }
    let o = [], a = null, l = s.compareCompletions;
    for (let c of n.sort((u, d) => d.score - u.score || l(u.completion, d.completion))) {
      let u = c.completion;
      !a || a.label != u.label || a.detail != u.detail || a.type != null && u.type != null && a.type != u.type || a.apply != u.apply || a.boost != u.boost ? o.push(c) : lX(c.completion) > lX(a) && (o[o.length - 1] = c), a = c.completion;
    }
    return o;
  }
  class og {
    constructor(e, n, r, i, s, o) {
      this.options = e, this.attrs = n, this.tooltip = r, this.timestamp = i, this.selected = s, this.disabled = o;
    }
    setSelected(e, n) {
      return e == this.selected || e >= this.options.length ? this : new og(this.options, cX(n, e), this.tooltip, this.timestamp, e, this.disabled);
    }
    static build(e, n, r, i, s) {
      let o = qnt(e, n);
      if (!o.length)
        return i && e.some((l) => l.state == 1) ? new og(i.options, i.attrs, i.tooltip, i.timestamp, i.selected, true) : null;
      let a = n.facet(Cl).selectOnOpen ? 0 : -1;
      if (i && i.selected != a && i.selected != -1) {
        let l = i.options[i.selected].completion;
        for (let c = 0; c < o.length; c++)
          if (o[c].completion == l) {
            a = c;
            break;
          }
      }
      return new og(o, cX(r, a), {
        pos: e.reduce((l, c) => c.hasResult() ? Math.min(l, c.from) : l, 1e8),
        create: irt,
        above: s.aboveCursor
      }, i ? i.timestamp : Date.now(), a, false);
    }
    map(e) {
      return new og(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), {
        pos: e.mapPos(this.tooltip.pos)
      }), this.timestamp, this.selected, this.disabled);
    }
  }
  class RP {
    constructor(e, n, r) {
      this.active = e, this.id = n, this.open = r;
    }
    static start() {
      return new RP(ert, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
    }
    update(e) {
      let { state: n } = e, r = n.facet(Cl), s = (r.override || n.languageDataAt("autocomplete", Cg(n)).map(Unt)).map((a) => (this.active.find((c) => c.source == a) || new us(a, this.active.some((c) => c.state != 0) ? 1 : 0)).update(e, r));
      s.length == this.active.length && s.every((a, l) => a == this.active[l]) && (s = this.active);
      let o = this.open;
      o && e.docChanged && (o = o.map(e.changes)), e.selection || s.some((a) => a.hasResult() && e.changes.touchesRange(a.from, a.to)) || !Knt(s, this.active) ? o = og.build(s, n, this.id, o, r) : o && o.disabled && !s.some((a) => a.state == 1) && (o = null), !o && s.every((a) => a.state != 1) && s.some((a) => a.hasResult()) && (s = s.map((a) => a.hasResult() ? new us(a.source, 0) : a));
      for (let a of e.effects)
        a.is(Qce) && (o = o && o.setSelected(a.value, this.id));
      return s == this.active && o == this.open ? this : new RP(s, this.id, o);
    }
    get tooltip() {
      return this.open ? this.open.tooltip : null;
    }
    get attrs() {
      return this.open ? this.open.attrs : Jnt;
    }
  }
  function Knt(t, e) {
    if (t == e)
      return true;
    for (let n = 0, r = 0; ; ) {
      for (; n < t.length && !t[n].hasResult; )
        n++;
      for (; r < e.length && !e[r].hasResult; )
        r++;
      let i = n == t.length, s = r == e.length;
      if (i || s)
        return i == s;
      if (t[n++].result != e[r++].result)
        return false;
    }
  }
  const Jnt = {
    "aria-autocomplete": "list"
  };
  function cX(t, e) {
    let n = {
      "aria-autocomplete": "list",
      "aria-haspopup": "listbox",
      "aria-controls": t
    };
    return e > -1 && (n["aria-activedescendant"] = t + "-" + e), n;
  }
  const ert = [];
  function trt(t, e) {
    if (t.isUserEvent("input.complete")) {
      let n = t.annotation(jce);
      if (n && e.activateOnCompletion(n))
        return "input";
    }
    return t.isUserEvent("input.type") ? "input" : t.isUserEvent("delete.backward") ? "delete" : null;
  }
  class us {
    constructor(e, n, r = -1) {
      this.source = e, this.state = n, this.explicitPos = r;
    }
    hasResult() {
      return false;
    }
    update(e, n) {
      let r = trt(e, n), i = this;
      r ? i = i.handleUserEvent(e, r, n) : e.docChanged ? i = i.handleChange(e) : e.selection && i.state != 0 && (i = new us(i.source, 0));
      for (let s of e.effects)
        if (s.is(Nce))
          i = new us(i.source, 1, s.value ? Cg(e.state) : -1);
        else if (s.is(yN))
          i = new us(i.source, 0);
        else if (s.is(rrt))
          for (let o of s.value)
            o.source == i.source && (i = o);
      return i;
    }
    handleUserEvent(e, n, r) {
      return n == "delete" || !r.activateOnTyping ? this.map(e.changes) : new us(this.source, 1);
    }
    handleChange(e) {
      return e.changes.touchesRange(Cg(e.startState)) ? new us(this.source, 0) : this.map(e.changes);
    }
    map(e) {
      return e.empty || this.explicitPos < 0 ? this : new us(this.source, this.state, e.mapPos(this.explicitPos));
    }
  }
  class gv extends us {
    constructor(e, n, r, i, s) {
      super(e, 2, n), this.result = r, this.from = i, this.to = s;
    }
    hasResult() {
      return true;
    }
    handleUserEvent(e, n, r) {
      var i;
      let s = this.result;
      s.map && !e.changes.empty && (s = s.map(s, e.changes));
      let o = e.changes.mapPos(this.from), a = e.changes.mapPos(this.to, 1), l = Cg(e.state);
      if ((this.explicitPos < 0 ? l <= o : l < this.from) || l > a || !s || n == "delete" && Cg(e.startState) == this.from)
        return new us(this.source, n == "input" && r.activateOnTyping ? 1 : 0);
      let c = this.explicitPos < 0 ? -1 : e.changes.mapPos(this.explicitPos);
      return nrt(s.validFor, e.state, o, a) ? new gv(this.source, c, s, o, a) : s.update && (s = s.update(s, o, a, new Qnt(e.state, l, c >= 0))) ? new gv(this.source, c, s, s.from, (i = s.to) !== null && i !== void 0 ? i : Cg(e.state)) : new us(this.source, 1, c);
    }
    handleChange(e) {
      return e.changes.touchesRange(this.from, this.to) ? new us(this.source, 0) : this.map(e.changes);
    }
    map(e) {
      return e.empty ? this : (this.result.map ? this.result.map(this.result, e) : this.result) ? new gv(this.source, this.explicitPos < 0 ? -1 : e.mapPos(this.explicitPos), this.result, e.mapPos(this.from), e.mapPos(this.to, 1)) : new us(this.source, 0);
    }
  }
  function nrt(t, e, n, r) {
    if (!t)
      return false;
    let i = e.sliceDoc(n, r);
    return typeof t == "function" ? t(i, n, r, e) : Lce(t, true).test(i);
  }
  const rrt = Dt.define({
    map(t, e) {
      return t.map((n) => n.map(e));
    }
  }), Qce = Dt.define(), Wm = Hi.define({
    create() {
      return RP.start();
    },
    update(t, e) {
      return t.update(e);
    },
    provide: (t) => [
      Ij.from(t, (e) => e.tooltip),
      Re.contentAttributes.from(t, (e) => e.attrs)
    ]
  });
  function zce(t, e) {
    const n = e.completion.apply || e.completion.label;
    let r = t.state.field(Wm).active.find((i) => i.source == e.source);
    return r instanceof gv ? (typeof n == "string" ? t.dispatch(Object.assign(Object.assign({}, Bnt(t.state, n, r.from, r.to)), {
      annotations: jce.of(e.completion)
    })) : n(t, e.completion, r.from, r.to), true) : false;
  }
  const irt = Ynt(Wm, zce);
  function xx(t, e = "option") {
    return (n) => {
      let r = n.state.field(Wm, false);
      if (!r || !r.open || r.open.disabled || Date.now() - r.open.timestamp < n.state.facet(Cl).interactionDelay)
        return false;
      let i = 1, s;
      e == "page" && (s = OGe(n, r.open.tooltip)) && (i = Math.max(2, Math.floor(s.dom.offsetHeight / s.dom.querySelector("li").offsetHeight) - 1));
      let { length: o } = r.open.options, a = r.open.selected > -1 ? r.open.selected + i * (t ? 1 : -1) : t ? 0 : o - 1;
      return a < 0 ? a = e == "page" ? 0 : o - 1 : a >= o && (a = e == "page" ? o - 1 : 0), n.dispatch({
        effects: Qce.of(a)
      }), true;
    };
  }
  const srt = (t) => {
    let e = t.state.field(Wm, false);
    return t.state.readOnly || !e || !e.open || e.open.selected < 0 || e.open.disabled || Date.now() - e.open.timestamp < t.state.facet(Cl).interactionDelay ? false : zce(t, e.open.options[e.open.selected]);
  }, ort = (t) => t.state.field(Wm, false) ? (t.dispatch({
    effects: Nce.of(true)
  }), true) : false, art = (t) => {
    let e = t.state.field(Wm, false);
    return !e || !e.active.some((n) => n.state != 0) ? false : (t.dispatch({
      effects: yN.of(null)
    }), true);
  }, Fce = new class extends IO {
  }();
  Fce.startSide = 1;
  Fce.endSide = -1;
  const lrt = [
    {
      key: "Ctrl-Space",
      run: ort
    },
    {
      key: "Escape",
      run: art
    },
    {
      key: "ArrowDown",
      run: xx(true)
    },
    {
      key: "ArrowUp",
      run: xx(false)
    },
    {
      key: "PageDown",
      run: xx(true, "page")
    },
    {
      key: "PageUp",
      run: xx(false, "page")
    },
    {
      key: "Enter",
      run: srt
    }
  ];
  class crt {
    constructor(e, n, r) {
      this.from = e, this.to = n, this.diagnostic = r;
    }
  }
  class Ph {
    constructor(e, n, r) {
      this.diagnostics = e, this.panel = n, this.selected = r;
    }
    static init(e, n, r) {
      let i = e, s = r.facet(Vce).markerFilter;
      s && (i = s(i, r));
      let o = Qe.set(i.map((a) => a.from == a.to || a.from == a.to - 1 && r.doc.lineAt(a.from).to == a.from ? Qe.widget({
        widget: new vrt(a),
        diagnostic: a
      }).range(a.from) : Qe.mark({
        attributes: {
          class: "cm-lintRange cm-lintRange-" + a.severity + (a.markClass ? " " + a.markClass : "")
        },
        diagnostic: a,
        inclusive: true
      }).range(a.from, a.to)), true);
      return new Ph(o, n, gm(o));
    }
  }
  function gm(t, e = null, n = 0) {
    let r = null;
    return t.between(n, 1e9, (i, s, { spec: o }) => {
      if (!(e && o.diagnostic != e))
        return r = new crt(i, s, o.diagnostic), false;
    }), r;
  }
  function urt(t, e) {
    let n = t.startState.doc.lineAt(e.pos);
    return !!(t.effects.some((r) => r.is(Bce)) || t.changes.touchesRange(n.from, n.to));
  }
  function drt(t, e) {
    return t.field(no, false) ? e : e.concat(Dt.appendConfig.of(wrt));
  }
  const Bce = Dt.define(), vN = Dt.define(), Uce = Dt.define(), no = Hi.define({
    create() {
      return new Ph(Qe.none, null, null);
    },
    update(t, e) {
      if (e.docChanged) {
        let n = t.diagnostics.map(e.changes), r = null;
        if (t.selected) {
          let i = e.changes.mapPos(t.selected.from, 1);
          r = gm(n, t.selected.diagnostic, i) || gm(n, null, i);
        }
        t = new Ph(n, t.panel, r);
      }
      for (let n of e.effects)
        n.is(Bce) ? t = Ph.init(n.value, t.panel, e.state) : n.is(vN) ? t = new Ph(t.diagnostics, n.value ? z2.open : null, t.selected) : n.is(Uce) && (t = new Ph(t.diagnostics, t.panel, n.value));
      return t;
    },
    provide: (t) => [
      yO.from(t, (e) => e.panel),
      Re.decorations.from(t, (e) => e.diagnostics)
    ]
  }), hrt = Qe.mark({
    class: "cm-lintRange cm-lintRange-active",
    inclusive: true
  });
  function frt(t, e, n) {
    let { diagnostics: r } = t.state.field(no), i = [], s = 2e8, o = 0;
    r.between(e - (n < 0 ? 1 : 0), e + (n > 0 ? 1 : 0), (l, c, { spec: u }) => {
      e >= l && e <= c && (l == c || (e > l || n > 0) && (e < c || n < 0)) && (i.push(u.diagnostic), s = Math.min(l, s), o = Math.max(c, o));
    });
    let a = t.state.facet(Vce).tooltipFilter;
    return a && (i = a(i, t.state)), i.length ? {
      pos: s,
      end: o,
      above: t.state.doc.lineAt(s).to < o,
      create() {
        return {
          dom: prt(t, i)
        };
      }
    } : null;
  }
  function prt(t, e) {
    return an("ul", {
      class: "cm-tooltip-lint"
    }, e.map((n) => Wce(t, n, false)));
  }
  const grt = (t) => {
    let e = t.state.field(no, false);
    (!e || !e.panel) && t.dispatch({
      effects: drt(t.state, [
        vN.of(true)
      ])
    });
    let n = mO(t, z2.open);
    return n && n.dom.querySelector(".cm-panel-lint ul").focus(), true;
  }, uX = (t) => {
    let e = t.state.field(no, false);
    return !e || !e.panel ? false : (t.dispatch({
      effects: vN.of(false)
    }), true);
  }, mrt = (t) => {
    let e = t.state.field(no, false);
    if (!e)
      return false;
    let n = t.state.selection.main, r = e.diagnostics.iter(n.to + 1);
    return !r.value && (r = e.diagnostics.iter(0), !r.value || r.from == n.from && r.to == n.to) ? false : (t.dispatch({
      selection: {
        anchor: r.from,
        head: r.to
      },
      scrollIntoView: true
    }), true);
  }, yrt = [
    {
      key: "Mod-Shift-m",
      run: grt,
      preventDefault: true
    },
    {
      key: "F8",
      run: mrt
    }
  ], Vce = $r.define({
    combine(t) {
      return Object.assign({
        sources: t.map((e) => e.source).filter((e) => e != null)
      }, j2(t.map((e) => e.config), {
        delay: 750,
        markerFilter: null,
        tooltipFilter: null,
        needsRefresh: null
      }, {
        needsRefresh: (e, n) => e ? n ? (r) => e(r) || n(r) : e : n
      }));
    }
  });
  function Xce(t) {
    let e = [];
    if (t)
      e:
        for (let { name: n } of t) {
          for (let r = 0; r < n.length; r++) {
            let i = n[r];
            if (/[a-zA-Z]/.test(i) && !e.some((s) => s.toLowerCase() == i.toLowerCase())) {
              e.push(i);
              continue e;
            }
          }
          e.push("");
        }
    return e;
  }
  function Wce(t, e, n) {
    var r;
    let i = n ? Xce(e.actions) : [];
    return an("li", {
      class: "cm-diagnostic cm-diagnostic-" + e.severity
    }, an("span", {
      class: "cm-diagnosticText"
    }, e.renderMessage ? e.renderMessage() : e.message), (r = e.actions) === null || r === void 0 ? void 0 : r.map((s, o) => {
      let a = false, l = (h) => {
        if (h.preventDefault(), a)
          return;
        a = true;
        let f = gm(t.state.field(no).diagnostics, e);
        f && s.apply(t, f.from, f.to);
      }, { name: c } = s, u = i[o] ? c.indexOf(i[o]) : -1, d = u < 0 ? c : [
        c.slice(0, u),
        an("u", c.slice(u, u + 1)),
        c.slice(u + 1)
      ];
      return an("button", {
        type: "button",
        class: "cm-diagnosticAction",
        onclick: l,
        onmousedown: l,
        "aria-label": ` Action: ${c}${u < 0 ? "" : ` (access key "${i[o]})"`}.`
      }, d);
    }), e.source && an("div", {
      class: "cm-diagnosticSource"
    }, e.source));
  }
  class vrt extends Yl {
    constructor(e) {
      super(), this.diagnostic = e;
    }
    eq(e) {
      return e.diagnostic == this.diagnostic;
    }
    toDOM() {
      return an("span", {
        class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity
      });
    }
  }
  class dX {
    constructor(e, n) {
      this.diagnostic = n, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = Wce(e, n, true), this.dom.id = this.id, this.dom.setAttribute("role", "option");
    }
  }
  class z2 {
    constructor(e) {
      this.view = e, this.items = [];
      let n = (i) => {
        if (i.keyCode == 27)
          uX(this.view), this.view.focus();
        else if (i.keyCode == 38 || i.keyCode == 33)
          this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
        else if (i.keyCode == 40 || i.keyCode == 34)
          this.moveSelection((this.selectedIndex + 1) % this.items.length);
        else if (i.keyCode == 36)
          this.moveSelection(0);
        else if (i.keyCode == 35)
          this.moveSelection(this.items.length - 1);
        else if (i.keyCode == 13)
          this.view.focus();
        else if (i.keyCode >= 65 && i.keyCode <= 90 && this.selectedIndex >= 0) {
          let { diagnostic: s } = this.items[this.selectedIndex], o = Xce(s.actions);
          for (let a = 0; a < o.length; a++)
            if (o[a].toUpperCase().charCodeAt(0) == i.keyCode) {
              let l = gm(this.view.state.field(no).diagnostics, s);
              l && s.actions[a].apply(e, l.from, l.to);
            }
        } else
          return;
        i.preventDefault();
      }, r = (i) => {
        for (let s = 0; s < this.items.length; s++)
          this.items[s].dom.contains(i.target) && this.moveSelection(s);
      };
      this.list = an("ul", {
        tabIndex: 0,
        role: "listbox",
        "aria-label": this.view.state.phrase("Diagnostics"),
        onkeydown: n,
        onclick: r
      }), this.dom = an("div", {
        class: "cm-panel-lint"
      }, this.list, an("button", {
        type: "button",
        name: "close",
        "aria-label": this.view.state.phrase("close"),
        onclick: () => uX(this.view)
      }, "\xD7")), this.update();
    }
    get selectedIndex() {
      let e = this.view.state.field(no).selected;
      if (!e)
        return -1;
      for (let n = 0; n < this.items.length; n++)
        if (this.items[n].diagnostic == e.diagnostic)
          return n;
      return -1;
    }
    update() {
      let { diagnostics: e, selected: n } = this.view.state.field(no), r = 0, i = false, s = null;
      for (e.between(0, this.view.state.doc.length, (o, a, { spec: l }) => {
        let c = -1, u;
        for (let d = r; d < this.items.length; d++)
          if (this.items[d].diagnostic == l.diagnostic) {
            c = d;
            break;
          }
        c < 0 ? (u = new dX(this.view, l.diagnostic), this.items.splice(r, 0, u), i = true) : (u = this.items[c], c > r && (this.items.splice(r, c - r), i = true)), n && u.diagnostic == n.diagnostic ? u.dom.hasAttribute("aria-selected") || (u.dom.setAttribute("aria-selected", "true"), s = u) : u.dom.hasAttribute("aria-selected") && u.dom.removeAttribute("aria-selected"), r++;
      }); r < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); )
        i = true, this.items.pop();
      this.items.length == 0 && (this.items.push(new dX(this.view, {
        from: -1,
        to: -1,
        severity: "info",
        message: this.view.state.phrase("No diagnostics")
      })), i = true), s ? (this.list.setAttribute("aria-activedescendant", s.id), this.view.requestMeasure({
        key: this,
        read: () => ({
          sel: s.dom.getBoundingClientRect(),
          panel: this.list.getBoundingClientRect()
        }),
        write: ({ sel: o, panel: a }) => {
          let l = a.height / this.list.offsetHeight;
          o.top < a.top ? this.list.scrollTop -= (a.top - o.top) / l : o.bottom > a.bottom && (this.list.scrollTop += (o.bottom - a.bottom) / l);
        }
      })) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), i && this.sync();
    }
    sync() {
      let e = this.list.firstChild;
      function n() {
        let r = e;
        e = r.nextSibling, r.remove();
      }
      for (let r of this.items)
        if (r.dom.parentNode == this.list) {
          for (; e != r.dom; )
            n();
          e = r.dom.nextSibling;
        } else
          this.list.insertBefore(r.dom, e);
      for (; e; )
        n();
    }
    moveSelection(e) {
      if (this.selectedIndex < 0)
        return;
      let n = this.view.state.field(no), r = gm(n.diagnostics, this.items[e].diagnostic);
      r && this.view.dispatch({
        selection: {
          anchor: r.from,
          head: r.to
        },
        scrollIntoView: true,
        effects: Uce.of(r)
      });
    }
    static open(e) {
      return new z2(e);
    }
  }
  function Ort(t, e = 'viewBox="0 0 40 40"') {
    return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`;
  }
  function bx(t) {
    return Ort(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
  }
  const Srt = Re.baseTheme({
    ".cm-diagnostic": {
      padding: "3px 6px 3px 8px",
      marginLeft: "-1px",
      display: "block",
      whiteSpace: "pre-wrap"
    },
    ".cm-diagnostic-error": {
      borderLeft: "5px solid #d11"
    },
    ".cm-diagnostic-warning": {
      borderLeft: "5px solid orange"
    },
    ".cm-diagnostic-info": {
      borderLeft: "5px solid #999"
    },
    ".cm-diagnostic-hint": {
      borderLeft: "5px solid #66d"
    },
    ".cm-diagnosticAction": {
      font: "inherit",
      border: "none",
      padding: "2px 4px",
      backgroundColor: "#444",
      color: "white",
      borderRadius: "3px",
      marginLeft: "8px",
      cursor: "pointer"
    },
    ".cm-diagnosticSource": {
      fontSize: "70%",
      opacity: 0.7
    },
    ".cm-lintRange": {
      backgroundPosition: "left bottom",
      backgroundRepeat: "repeat-x",
      paddingBottom: "0.7px"
    },
    ".cm-lintRange-error": {
      backgroundImage: bx("#d11")
    },
    ".cm-lintRange-warning": {
      backgroundImage: bx("orange")
    },
    ".cm-lintRange-info": {
      backgroundImage: bx("#999")
    },
    ".cm-lintRange-hint": {
      backgroundImage: bx("#66d")
    },
    ".cm-lintRange-active": {
      backgroundColor: "#ffdd9980"
    },
    ".cm-tooltip-lint": {
      padding: 0,
      margin: 0
    },
    ".cm-lintPoint": {
      position: "relative",
      "&:after": {
        content: '""',
        position: "absolute",
        bottom: 0,
        left: "-2px",
        borderLeft: "3px solid transparent",
        borderRight: "3px solid transparent",
        borderBottom: "4px solid #d11"
      }
    },
    ".cm-lintPoint-warning": {
      "&:after": {
        borderBottomColor: "orange"
      }
    },
    ".cm-lintPoint-info": {
      "&:after": {
        borderBottomColor: "#999"
      }
    },
    ".cm-lintPoint-hint": {
      "&:after": {
        borderBottomColor: "#66d"
      }
    },
    ".cm-panel.cm-panel-lint": {
      position: "relative",
      "& ul": {
        maxHeight: "100px",
        overflowY: "auto",
        "& [aria-selected]": {
          backgroundColor: "#ddd",
          "& u": {
            textDecoration: "underline"
          }
        },
        "&:focus [aria-selected]": {
          background_fallback: "#bdf",
          backgroundColor: "Highlight",
          color_fallback: "white",
          color: "HighlightText"
        },
        "& u": {
          textDecoration: "none"
        },
        padding: 0,
        margin: 0
      },
      "& [name=close]": {
        position: "absolute",
        top: "0",
        right: "2px",
        background: "inherit",
        border: "none",
        font: "inherit",
        padding: 0,
        margin: 0
      }
    }
  }), wrt = [
    no,
    Re.decorations.compute([
      no
    ], (t) => {
      let { selected: e, panel: n } = t.field(no);
      return !e || !n || e.from == e.to ? Qe.none : Qe.set([
        hrt.range(e.from, e.to)
      ]);
    }),
    vGe(frt, {
      hideOn: urt
    }),
    Srt
  ], Zce = "https://www.inkandswitch.com/essay-embark";
  class Hce extends Yl {
    constructor(e, n) {
      super(), this.url = e, this.caption = n;
    }
    toDOM(e) {
    }
    eq(e) {
      return e.url === this.url && e.caption === this.caption;
    }
    ignoreEvent() {
      return true;
    }
  }
  class xrt extends Hce {
    toDOM() {
      const e = document.createElement("div"), n = document.createElement("img");
      n.crossOrigin = "anonymous", n.src = `${Zce}/${this.url}`, e.append(n), e.className = "border border-gray-200 mb-4";
      const r = document.createElement("div");
      return r.append(document.createTextNode(this.caption)), r.className = "p-4 bg-gray-100 text-sm font-sans", e.append(r), e;
    }
  }
  class brt extends Hce {
    toDOM() {
      const e = document.createElement("div"), n = document.createElement("video");
      n.className = "w-full", n.crossOrigin = "anonymous", n.width = 320, n.height = 240, n.controls = true;
      const r = document.createElement("source");
      r.src = `${Zce}/${this.url}`, r.type = "video/mp4";
      const i = document.createElement("div");
      return i.append(document.createTextNode(this.caption)), i.className = "p-4 bg-gray-100 text-sm font-sans", n.appendChild(r), e.appendChild(n), e.append(i), e.className = "border border-gray-200 mb-4", e;
    }
  }
  const krt = /src="(?<value>.*?)" caption="(?<caption>.*?)"/, Prt = /(\{\{< rawhtml >}}(?<source>.*?){{< \/rawhtml >}})/gs, Crt = /({{(?<source>.*?)}})/gs;
  function hX(t) {
    var _a3, _b3, _c3;
    const e = [], n = new DOMParser();
    for (const { from: r, to: i } of t.visibleRanges) {
      const s = t.state.sliceDoc(r, i);
      let o;
      for (; o = Crt.exec(s); ) {
        const a = o.index + r, l = o.groups.source.match(krt);
        if (l) {
          const c = l.groups.value, u = l.groups.caption, d = Qe.widget({
            widget: new xrt(c, u),
            side: 1
          }).range(a);
          e.push(d), e.push(Qe.mark({
            class: "text-gray-400 font-mono text-left text-sm leading-snug inline-block opacity-60"
          }).range(a, a + o[0].length));
        }
      }
      for (; o = Prt.exec(s); ) {
        const a = o.index + r, l = n.parseFromString(o.groups.source, "text/html"), c = (_a3 = l.body.getElementsByTagName("video")[0]) == null ? void 0 : _a3.src, u = ((_c3 = (_b3 = l.body.getElementsByTagName("figcaption")[0]) == null ? void 0 : _b3.innerText) == null ? void 0 : _c3.trim()) ?? "";
        if (c) {
          const d = new URL(c).pathname.slice(1), h = Qe.widget({
            widget: new brt(d, u),
            side: 1
          }).range(a);
          e.push(h), e.push(Qe.mark({
            class: "text-gray-400 font-mono text-left text-sm leading-snug inline-block opacity-60"
          }).range(a, a + o[0].length));
        }
      }
    }
    return Qe.set(e.sort((r, i) => r.from - i.from));
  }
  const _rt = ur.fromClass(class {
    constructor(t) {
      __publicField(this, "decorations");
      this.decorations = hX(t);
    }
    update(t) {
      (t.docChanged || t.viewportChanged) && (this.decorations = hX(t.view));
    }
  }, {
    decorations: (t) => t.decorations
  });
  var $f = {}, Zm = {};
  var Yce = b;
  function ct(t) {
    for (var e = "https://reactjs.org/docs/error-decoder.html?invariant=" + t, n = 1; n < arguments.length; n++)
      e += "&args[]=" + encodeURIComponent(arguments[n]);
    return "Minified React error #" + t + "; visit " + e + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  var ss = Object.prototype.hasOwnProperty, Trt = /^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/, fX = {}, pX = {};
  function Gce(t) {
    return ss.call(pX, t) ? true : ss.call(fX, t) ? false : Trt.test(t) ? pX[t] = true : (fX[t] = true, false);
  }
  function Yi(t, e, n, r, i, s, o) {
    this.acceptsBooleans = e === 2 || e === 3 || e === 4, this.attributeName = r, this.attributeNamespace = i, this.mustUseProperty = n, this.propertyName = t, this.type = e, this.sanitizeURL = s, this.removeEmptyString = o;
  }
  var Gr = {};
  "children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t) {
    Gr[t] = new Yi(t, 0, false, t, null, false, false);
  });
  [
    [
      "acceptCharset",
      "accept-charset"
    ],
    [
      "className",
      "class"
    ],
    [
      "htmlFor",
      "for"
    ],
    [
      "httpEquiv",
      "http-equiv"
    ]
  ].forEach(function(t) {
    var e = t[0];
    Gr[e] = new Yi(e, 1, false, t[1], null, false, false);
  });
  [
    "contentEditable",
    "draggable",
    "spellCheck",
    "value"
  ].forEach(function(t) {
    Gr[t] = new Yi(t, 2, false, t.toLowerCase(), null, false, false);
  });
  [
    "autoReverse",
    "externalResourcesRequired",
    "focusable",
    "preserveAlpha"
  ].forEach(function(t) {
    Gr[t] = new Yi(t, 2, false, t, null, false, false);
  });
  "allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t) {
    Gr[t] = new Yi(t, 3, false, t.toLowerCase(), null, false, false);
  });
  [
    "checked",
    "multiple",
    "muted",
    "selected"
  ].forEach(function(t) {
    Gr[t] = new Yi(t, 3, true, t, null, false, false);
  });
  [
    "capture",
    "download"
  ].forEach(function(t) {
    Gr[t] = new Yi(t, 4, false, t, null, false, false);
  });
  [
    "cols",
    "rows",
    "size",
    "span"
  ].forEach(function(t) {
    Gr[t] = new Yi(t, 6, false, t, null, false, false);
  });
  [
    "rowSpan",
    "start"
  ].forEach(function(t) {
    Gr[t] = new Yi(t, 5, false, t.toLowerCase(), null, false, false);
  });
  var ON = /[\-:]([a-z])/g;
  function SN(t) {
    return t[1].toUpperCase();
  }
  "accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t) {
    var e = t.replace(ON, SN);
    Gr[e] = new Yi(e, 1, false, t, null, false, false);
  });
  "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t) {
    var e = t.replace(ON, SN);
    Gr[e] = new Yi(e, 1, false, t, "http://www.w3.org/1999/xlink", false, false);
  });
  [
    "xml:base",
    "xml:lang",
    "xml:space"
  ].forEach(function(t) {
    var e = t.replace(ON, SN);
    Gr[e] = new Yi(e, 1, false, t, "http://www.w3.org/XML/1998/namespace", false, false);
  });
  [
    "tabIndex",
    "crossOrigin"
  ].forEach(function(t) {
    Gr[t] = new Yi(t, 1, false, t.toLowerCase(), null, false, false);
  });
  Gr.xlinkHref = new Yi("xlinkHref", 1, false, "xlink:href", "http://www.w3.org/1999/xlink", true, false);
  [
    "src",
    "href",
    "action",
    "formAction"
  ].forEach(function(t) {
    Gr[t] = new Yi(t, 1, false, t.toLowerCase(), null, true, true);
  });
  var bb = {
    animationIterationCount: true,
    aspectRatio: true,
    borderImageOutset: true,
    borderImageSlice: true,
    borderImageWidth: true,
    boxFlex: true,
    boxFlexGroup: true,
    boxOrdinalGroup: true,
    columnCount: true,
    columns: true,
    flex: true,
    flexGrow: true,
    flexPositive: true,
    flexShrink: true,
    flexNegative: true,
    flexOrder: true,
    gridArea: true,
    gridRow: true,
    gridRowEnd: true,
    gridRowSpan: true,
    gridRowStart: true,
    gridColumn: true,
    gridColumnEnd: true,
    gridColumnSpan: true,
    gridColumnStart: true,
    fontWeight: true,
    lineClamp: true,
    lineHeight: true,
    opacity: true,
    order: true,
    orphans: true,
    tabSize: true,
    widows: true,
    zIndex: true,
    zoom: true,
    fillOpacity: true,
    floodOpacity: true,
    stopOpacity: true,
    strokeDasharray: true,
    strokeDashoffset: true,
    strokeMiterlimit: true,
    strokeOpacity: true,
    strokeWidth: true
  }, Ert = [
    "Webkit",
    "ms",
    "Moz",
    "O"
  ];
  Object.keys(bb).forEach(function(t) {
    Ert.forEach(function(e) {
      e = e + t.charAt(0).toUpperCase() + t.substring(1), bb[e] = bb[t];
    });
  });
  var Irt = /["'&<>]/;
  function Fi(t) {
    if (typeof t == "boolean" || typeof t == "number")
      return "" + t;
    t = "" + t;
    var e = Irt.exec(t);
    if (e) {
      var n = "", r, i = 0;
      for (r = e.index; r < t.length; r++) {
        switch (t.charCodeAt(r)) {
          case 34:
            e = "&quot;";
            break;
          case 38:
            e = "&amp;";
            break;
          case 39:
            e = "&#x27;";
            break;
          case 60:
            e = "&lt;";
            break;
          case 62:
            e = "&gt;";
            break;
          default:
            continue;
        }
        i !== r && (n += t.substring(i, r)), i = r + 1, n += e;
      }
      t = i !== r ? n + t.substring(i, r) : n;
    }
    return t;
  }
  var $rt = /([A-Z])/g, Art = /^ms-/, TD = Array.isArray;
  function pc(t, e) {
    return {
      insertionMode: t,
      selectedValue: e
    };
  }
  function Rrt(t, e, n) {
    switch (e) {
      case "select":
        return pc(1, n.value != null ? n.value : n.defaultValue);
      case "svg":
        return pc(2, null);
      case "math":
        return pc(3, null);
      case "foreignObject":
        return pc(1, null);
      case "table":
        return pc(4, null);
      case "thead":
      case "tbody":
      case "tfoot":
        return pc(5, null);
      case "colgroup":
        return pc(7, null);
      case "tr":
        return pc(6, null);
    }
    return 4 <= t.insertionMode || t.insertionMode === 0 ? pc(1, null) : t;
  }
  var gX = /* @__PURE__ */ new Map();
  function qce(t, e, n) {
    if (typeof n != "object")
      throw Error(ct(62));
    e = true;
    for (var r in n)
      if (ss.call(n, r)) {
        var i = n[r];
        if (i != null && typeof i != "boolean" && i !== "") {
          if (r.indexOf("--") === 0) {
            var s = Fi(r);
            i = Fi(("" + i).trim());
          } else {
            s = r;
            var o = gX.get(s);
            o !== void 0 || (o = Fi(s.replace($rt, "-$1").toLowerCase().replace(Art, "-ms-")), gX.set(s, o)), s = o, i = typeof i == "number" ? i === 0 || ss.call(bb, r) ? "" + i : i + "px" : Fi(("" + i).trim());
          }
          e ? (e = false, t.push(' style="', s, ":", i)) : t.push(";", s, ":", i);
        }
      }
    e || t.push('"');
  }
  function zs(t, e, n, r) {
    switch (n) {
      case "style":
        qce(t, e, r);
        return;
      case "defaultValue":
      case "defaultChecked":
      case "innerHTML":
      case "suppressContentEditableWarning":
      case "suppressHydrationWarning":
        return;
    }
    if (!(2 < n.length) || n[0] !== "o" && n[0] !== "O" || n[1] !== "n" && n[1] !== "N") {
      if (e = Gr.hasOwnProperty(n) ? Gr[n] : null, e !== null) {
        switch (typeof r) {
          case "function":
          case "symbol":
            return;
          case "boolean":
            if (!e.acceptsBooleans)
              return;
        }
        switch (n = e.attributeName, e.type) {
          case 3:
            r && t.push(" ", n, '=""');
            break;
          case 4:
            r === true ? t.push(" ", n, '=""') : r !== false && t.push(" ", n, '="', Fi(r), '"');
            break;
          case 5:
            isNaN(r) || t.push(" ", n, '="', Fi(r), '"');
            break;
          case 6:
            !isNaN(r) && 1 <= r && t.push(" ", n, '="', Fi(r), '"');
            break;
          default:
            e.sanitizeURL && (r = "" + r), t.push(" ", n, '="', Fi(r), '"');
        }
      } else if (Gce(n)) {
        switch (typeof r) {
          case "function":
          case "symbol":
            return;
          case "boolean":
            if (e = n.toLowerCase().slice(0, 5), e !== "data-" && e !== "aria-")
              return;
        }
        t.push(" ", n, '="', Fi(r), '"');
      }
    }
  }
  function kb(t, e, n) {
    if (e != null) {
      if (n != null)
        throw Error(ct(60));
      if (typeof e != "object" || !("__html" in e))
        throw Error(ct(61));
      e = e.__html, e != null && t.push("" + e);
    }
  }
  function Mrt(t) {
    var e = "";
    return Yce.Children.forEach(t, function(n) {
      n != null && (e += n);
    }), e;
  }
  function I$(t, e, n, r) {
    t.push(fl(n));
    var i = n = null, s;
    for (s in e)
      if (ss.call(e, s)) {
        var o = e[s];
        if (o != null)
          switch (s) {
            case "children":
              n = o;
              break;
            case "dangerouslySetInnerHTML":
              i = o;
              break;
            default:
              zs(t, r, s, o);
          }
      }
    return t.push(">"), kb(t, i, n), typeof n == "string" ? (t.push(Fi(n)), null) : n;
  }
  var Drt = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/, mX = /* @__PURE__ */ new Map();
  function fl(t) {
    var e = mX.get(t);
    if (e === void 0) {
      if (!Drt.test(t))
        throw Error(ct(65, t));
      e = "<" + t, mX.set(t, e);
    }
    return e;
  }
  function Lrt(t, e, n, r, i) {
    switch (e) {
      case "select":
        t.push(fl("select"));
        var s = null, o = null;
        for (u in n)
          if (ss.call(n, u)) {
            var a = n[u];
            if (a != null)
              switch (u) {
                case "children":
                  s = a;
                  break;
                case "dangerouslySetInnerHTML":
                  o = a;
                  break;
                case "defaultValue":
                case "value":
                  break;
                default:
                  zs(t, r, u, a);
              }
          }
        return t.push(">"), kb(t, o, s), s;
      case "option":
        o = i.selectedValue, t.push(fl("option"));
        var l = a = null, c = null, u = null;
        for (s in n)
          if (ss.call(n, s)) {
            var d = n[s];
            if (d != null)
              switch (s) {
                case "children":
                  a = d;
                  break;
                case "selected":
                  c = d;
                  break;
                case "dangerouslySetInnerHTML":
                  u = d;
                  break;
                case "value":
                  l = d;
                default:
                  zs(t, r, s, d);
              }
          }
        if (o != null)
          if (n = l !== null ? "" + l : Mrt(a), TD(o)) {
            for (r = 0; r < o.length; r++)
              if ("" + o[r] === n) {
                t.push(' selected=""');
                break;
              }
          } else
            "" + o === n && t.push(' selected=""');
        else
          c && t.push(' selected=""');
        return t.push(">"), kb(t, u, a), a;
      case "textarea":
        t.push(fl("textarea")), u = o = s = null;
        for (a in n)
          if (ss.call(n, a) && (l = n[a], l != null))
            switch (a) {
              case "children":
                u = l;
                break;
              case "value":
                s = l;
                break;
              case "defaultValue":
                o = l;
                break;
              case "dangerouslySetInnerHTML":
                throw Error(ct(91));
              default:
                zs(t, r, a, l);
            }
        if (s === null && o !== null && (s = o), t.push(">"), u != null) {
          if (s != null)
            throw Error(ct(92));
          if (TD(u) && 1 < u.length)
            throw Error(ct(93));
          s = "" + u;
        }
        return typeof s == "string" && s[0] === `
` && t.push(`
`), s !== null && t.push(Fi("" + s)), null;
      case "input":
        t.push(fl("input")), l = u = a = s = null;
        for (o in n)
          if (ss.call(n, o) && (c = n[o], c != null))
            switch (o) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(ct(399, "input"));
              case "defaultChecked":
                l = c;
                break;
              case "defaultValue":
                a = c;
                break;
              case "checked":
                u = c;
                break;
              case "value":
                s = c;
                break;
              default:
                zs(t, r, o, c);
            }
        return u !== null ? zs(t, r, "checked", u) : l !== null && zs(t, r, "checked", l), s !== null ? zs(t, r, "value", s) : a !== null && zs(t, r, "value", a), t.push("/>"), null;
      case "menuitem":
        t.push(fl("menuitem"));
        for (var h in n)
          if (ss.call(n, h) && (s = n[h], s != null))
            switch (h) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(ct(400));
              default:
                zs(t, r, h, s);
            }
        return t.push(">"), null;
      case "title":
        t.push(fl("title")), s = null;
        for (d in n)
          if (ss.call(n, d) && (o = n[d], o != null))
            switch (d) {
              case "children":
                s = o;
                break;
              case "dangerouslySetInnerHTML":
                throw Error(ct(434));
              default:
                zs(t, r, d, o);
            }
        return t.push(">"), s;
      case "listing":
      case "pre":
        t.push(fl(e)), o = s = null;
        for (l in n)
          if (ss.call(n, l) && (a = n[l], a != null))
            switch (l) {
              case "children":
                s = a;
                break;
              case "dangerouslySetInnerHTML":
                o = a;
                break;
              default:
                zs(t, r, l, a);
            }
        if (t.push(">"), o != null) {
          if (s != null)
            throw Error(ct(60));
          if (typeof o != "object" || !("__html" in o))
            throw Error(ct(61));
          n = o.__html, n != null && (typeof n == "string" && 0 < n.length && n[0] === `
` ? t.push(`
`, n) : t.push("" + n));
        }
        return typeof s == "string" && s[0] === `
` && t.push(`
`), s;
      case "area":
      case "base":
      case "br":
      case "col":
      case "embed":
      case "hr":
      case "img":
      case "keygen":
      case "link":
      case "meta":
      case "param":
      case "source":
      case "track":
      case "wbr":
        t.push(fl(e));
        for (var f in n)
          if (ss.call(n, f) && (s = n[f], s != null))
            switch (f) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(ct(399, e));
              default:
                zs(t, r, f, s);
            }
        return t.push("/>"), null;
      case "annotation-xml":
      case "color-profile":
      case "font-face":
      case "font-face-src":
      case "font-face-uri":
      case "font-face-format":
      case "font-face-name":
      case "missing-glyph":
        return I$(t, n, e, r);
      case "html":
        return i.insertionMode === 0 && t.push("<!DOCTYPE html>"), I$(t, n, e, r);
      default:
        if (e.indexOf("-") === -1 && typeof n.is != "string")
          return I$(t, n, e, r);
        t.push(fl(e)), o = s = null;
        for (c in n)
          if (ss.call(n, c) && (a = n[c], a != null))
            switch (c) {
              case "children":
                s = a;
                break;
              case "dangerouslySetInnerHTML":
                o = a;
                break;
              case "style":
                qce(t, r, a);
                break;
              case "suppressContentEditableWarning":
              case "suppressHydrationWarning":
                break;
              default:
                Gce(c) && typeof a != "function" && typeof a != "symbol" && t.push(" ", c, '="', Fi(a), '"');
            }
        return t.push(">"), kb(t, o, s), s;
    }
  }
  function yX(t, e, n) {
    if (t.push('<!--$?--><template id="'), n === null)
      throw Error(ct(395));
    return t.push(n), t.push('"></template>');
  }
  function jrt(t, e, n, r) {
    switch (n.insertionMode) {
      case 0:
      case 1:
        return t.push('<div hidden id="'), t.push(e.segmentPrefix), e = r.toString(16), t.push(e), t.push('">');
      case 2:
        return t.push('<svg aria-hidden="true" style="display:none" id="'), t.push(e.segmentPrefix), e = r.toString(16), t.push(e), t.push('">');
      case 3:
        return t.push('<math aria-hidden="true" style="display:none" id="'), t.push(e.segmentPrefix), e = r.toString(16), t.push(e), t.push('">');
      case 4:
        return t.push('<table hidden id="'), t.push(e.segmentPrefix), e = r.toString(16), t.push(e), t.push('">');
      case 5:
        return t.push('<table hidden><tbody id="'), t.push(e.segmentPrefix), e = r.toString(16), t.push(e), t.push('">');
      case 6:
        return t.push('<table hidden><tr id="'), t.push(e.segmentPrefix), e = r.toString(16), t.push(e), t.push('">');
      case 7:
        return t.push('<table hidden><colgroup id="'), t.push(e.segmentPrefix), e = r.toString(16), t.push(e), t.push('">');
      default:
        throw Error(ct(397));
    }
  }
  function Nrt(t, e) {
    switch (e.insertionMode) {
      case 0:
      case 1:
        return t.push("</div>");
      case 2:
        return t.push("</svg>");
      case 3:
        return t.push("</math>");
      case 4:
        return t.push("</table>");
      case 5:
        return t.push("</tbody></table>");
      case 6:
        return t.push("</tr></table>");
      case 7:
        return t.push("</colgroup></table>");
      default:
        throw Error(ct(397));
    }
  }
  var Qrt = /[<\u2028\u2029]/g;
  function $$(t) {
    return JSON.stringify(t).replace(Qrt, function(e) {
      switch (e) {
        case "<":
          return "\\u003c";
        case "\u2028":
          return "\\u2028";
        case "\u2029":
          return "\\u2029";
        default:
          throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React");
      }
    });
  }
  function zrt(t, e) {
    return e = e === void 0 ? "" : e, {
      bootstrapChunks: [],
      startInlineScript: "<script>",
      placeholderPrefix: e + "P:",
      segmentPrefix: e + "S:",
      boundaryPrefix: e + "B:",
      idPrefix: e,
      nextSuspenseID: 0,
      sentCompleteSegmentFunction: false,
      sentCompleteBoundaryFunction: false,
      sentClientRenderFunction: false,
      generateStaticMarkup: t
    };
  }
  function vX(t, e, n, r) {
    return n.generateStaticMarkup ? (t.push(Fi(e)), false) : (e === "" ? t = r : (r && t.push("<!-- -->"), t.push(Fi(e)), t = true), t);
  }
  var mv = Object.assign, Frt = Symbol.for("react.element"), Kce = Symbol.for("react.portal"), Jce = Symbol.for("react.fragment"), eue = Symbol.for("react.strict_mode"), tue = Symbol.for("react.profiler"), nue = Symbol.for("react.provider"), rue = Symbol.for("react.context"), iue = Symbol.for("react.forward_ref"), sue = Symbol.for("react.suspense"), oue = Symbol.for("react.suspense_list"), aue = Symbol.for("react.memo"), wN = Symbol.for("react.lazy"), Brt = Symbol.for("react.scope"), Urt = Symbol.for("react.debug_trace_mode"), Vrt = Symbol.for("react.legacy_hidden"), Xrt = Symbol.for("react.default_value"), OX = Symbol.iterator;
  function ED(t) {
    if (t == null)
      return null;
    if (typeof t == "function")
      return t.displayName || t.name || null;
    if (typeof t == "string")
      return t;
    switch (t) {
      case Jce:
        return "Fragment";
      case Kce:
        return "Portal";
      case tue:
        return "Profiler";
      case eue:
        return "StrictMode";
      case sue:
        return "Suspense";
      case oue:
        return "SuspenseList";
    }
    if (typeof t == "object")
      switch (t.$$typeof) {
        case rue:
          return (t.displayName || "Context") + ".Consumer";
        case nue:
          return (t._context.displayName || "Context") + ".Provider";
        case iue:
          var e = t.render;
          return t = t.displayName, t || (t = e.displayName || e.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
        case aue:
          return e = t.displayName || null, e !== null ? e : ED(t.type) || "Memo";
        case wN:
          e = t._payload, t = t._init;
          try {
            return ED(t(e));
          } catch {
          }
      }
    return null;
  }
  var lue = {};
  function SX(t, e) {
    if (t = t.contextTypes, !t)
      return lue;
    var n = {}, r;
    for (r in t)
      n[r] = e[r];
    return n;
  }
  var Nh = null;
  function F2(t, e) {
    if (t !== e) {
      t.context._currentValue2 = t.parentValue, t = t.parent;
      var n = e.parent;
      if (t === null) {
        if (n !== null)
          throw Error(ct(401));
      } else {
        if (n === null)
          throw Error(ct(401));
        F2(t, n);
      }
      e.context._currentValue2 = e.value;
    }
  }
  function cue(t) {
    t.context._currentValue2 = t.parentValue, t = t.parent, t !== null && cue(t);
  }
  function uue(t) {
    var e = t.parent;
    e !== null && uue(e), t.context._currentValue2 = t.value;
  }
  function due(t, e) {
    if (t.context._currentValue2 = t.parentValue, t = t.parent, t === null)
      throw Error(ct(402));
    t.depth === e.depth ? F2(t, e) : due(t, e);
  }
  function hue(t, e) {
    var n = e.parent;
    if (n === null)
      throw Error(ct(402));
    t.depth === n.depth ? F2(t, n) : hue(t, n), e.context._currentValue2 = e.value;
  }
  function MP(t) {
    var e = Nh;
    e !== t && (e === null ? uue(t) : t === null ? cue(e) : e.depth === t.depth ? F2(e, t) : e.depth > t.depth ? due(e, t) : hue(e, t), Nh = t);
  }
  var wX = {
    isMounted: function() {
      return false;
    },
    enqueueSetState: function(t, e) {
      t = t._reactInternals, t.queue !== null && t.queue.push(e);
    },
    enqueueReplaceState: function(t, e) {
      t = t._reactInternals, t.replace = true, t.queue = [
        e
      ];
    },
    enqueueForceUpdate: function() {
    }
  };
  function xX(t, e, n, r) {
    var i = t.state !== void 0 ? t.state : null;
    t.updater = wX, t.props = n, t.state = i;
    var s = {
      queue: [],
      replace: false
    };
    t._reactInternals = s;
    var o = e.contextType;
    if (t.context = typeof o == "object" && o !== null ? o._currentValue2 : r, o = e.getDerivedStateFromProps, typeof o == "function" && (o = o(n, i), i = o == null ? i : mv({}, i, o), t.state = i), typeof e.getDerivedStateFromProps != "function" && typeof t.getSnapshotBeforeUpdate != "function" && (typeof t.UNSAFE_componentWillMount == "function" || typeof t.componentWillMount == "function"))
      if (e = t.state, typeof t.componentWillMount == "function" && t.componentWillMount(), typeof t.UNSAFE_componentWillMount == "function" && t.UNSAFE_componentWillMount(), e !== t.state && wX.enqueueReplaceState(t, t.state, null), s.queue !== null && 0 < s.queue.length)
        if (e = s.queue, o = s.replace, s.queue = null, s.replace = false, o && e.length === 1)
          t.state = e[0];
        else {
          for (s = o ? e[0] : t.state, i = true, o = o ? 1 : 0; o < e.length; o++) {
            var a = e[o];
            a = typeof a == "function" ? a.call(t, s, n, r) : a, a != null && (i ? (i = false, s = mv({}, s, a)) : mv(s, a));
          }
          t.state = s;
        }
      else
        s.queue = null;
  }
  var Wrt = {
    id: 1,
    overflow: ""
  };
  function ID(t, e, n) {
    var r = t.id;
    t = t.overflow;
    var i = 32 - Pb(r) - 1;
    r &= ~(1 << i), n += 1;
    var s = 32 - Pb(e) + i;
    if (30 < s) {
      var o = i - i % 5;
      return s = (r & (1 << o) - 1).toString(32), r >>= o, i -= o, {
        id: 1 << 32 - Pb(e) + i | n << i | r,
        overflow: s + t
      };
    }
    return {
      id: 1 << s | n << i | r,
      overflow: t
    };
  }
  var Pb = Math.clz32 ? Math.clz32 : Yrt, Zrt = Math.log, Hrt = Math.LN2;
  function Yrt(t) {
    return t >>>= 0, t === 0 ? 32 : 31 - (Zrt(t) / Hrt | 0) | 0;
  }
  function Grt(t, e) {
    return t === e && (t !== 0 || 1 / t === 1 / e) || t !== t && e !== e;
  }
  var qrt = typeof Object.is == "function" ? Object.is : Grt, Kc = null, xN = null, Cb = null, ln = null, $0 = false, DP = false, LO = 0, sd = null, B2 = 0;
  function Ch() {
    if (Kc === null)
      throw Error(ct(321));
    return Kc;
  }
  function bX() {
    if (0 < B2)
      throw Error(ct(312));
    return {
      memoizedState: null,
      queue: null,
      next: null
    };
  }
  function bN() {
    return ln === null ? Cb === null ? ($0 = false, Cb = ln = bX()) : ($0 = true, ln = Cb) : ln.next === null ? ($0 = false, ln = ln.next = bX()) : ($0 = true, ln = ln.next), ln;
  }
  function kN() {
    xN = Kc = null, DP = false, Cb = null, B2 = 0, ln = sd = null;
  }
  function fue(t, e) {
    return typeof e == "function" ? e(t) : e;
  }
  function kX(t, e, n) {
    if (Kc = Ch(), ln = bN(), $0) {
      var r = ln.queue;
      if (e = r.dispatch, sd !== null && (n = sd.get(r), n !== void 0)) {
        sd.delete(r), r = ln.memoizedState;
        do
          r = t(r, n.action), n = n.next;
        while (n !== null);
        return ln.memoizedState = r, [
          r,
          e
        ];
      }
      return [
        ln.memoizedState,
        e
      ];
    }
    return t = t === fue ? typeof e == "function" ? e() : e : n !== void 0 ? n(e) : e, ln.memoizedState = t, t = ln.queue = {
      last: null,
      dispatch: null
    }, t = t.dispatch = Krt.bind(null, Kc, t), [
      ln.memoizedState,
      t
    ];
  }
  function PX(t, e) {
    if (Kc = Ch(), ln = bN(), e = e === void 0 ? null : e, ln !== null) {
      var n = ln.memoizedState;
      if (n !== null && e !== null) {
        var r = n[1];
        e:
          if (r === null)
            r = false;
          else {
            for (var i = 0; i < r.length && i < e.length; i++)
              if (!qrt(e[i], r[i])) {
                r = false;
                break e;
              }
            r = true;
          }
        if (r)
          return n[0];
      }
    }
    return t = t(), ln.memoizedState = [
      t,
      e
    ], t;
  }
  function Krt(t, e, n) {
    if (25 <= B2)
      throw Error(ct(301));
    if (t === Kc)
      if (DP = true, t = {
        action: n,
        next: null
      }, sd === null && (sd = /* @__PURE__ */ new Map()), n = sd.get(e), n === void 0)
        sd.set(e, t);
      else {
        for (e = n; e.next !== null; )
          e = e.next;
        e.next = t;
      }
  }
  function Jrt() {
    throw Error(ct(394));
  }
  function kx() {
  }
  var CX = {
    readContext: function(t) {
      return t._currentValue2;
    },
    useContext: function(t) {
      return Ch(), t._currentValue2;
    },
    useMemo: PX,
    useReducer: kX,
    useRef: function(t) {
      Kc = Ch(), ln = bN();
      var e = ln.memoizedState;
      return e === null ? (t = {
        current: t
      }, ln.memoizedState = t) : e;
    },
    useState: function(t) {
      return kX(fue, t);
    },
    useInsertionEffect: kx,
    useLayoutEffect: function() {
    },
    useCallback: function(t, e) {
      return PX(function() {
        return t;
      }, e);
    },
    useImperativeHandle: kx,
    useEffect: kx,
    useDebugValue: kx,
    useDeferredValue: function(t) {
      return Ch(), t;
    },
    useTransition: function() {
      return Ch(), [
        false,
        Jrt
      ];
    },
    useId: function() {
      var t = xN.treeContext, e = t.overflow;
      t = t.id, t = (t & ~(1 << 32 - Pb(t) - 1)).toString(32) + e;
      var n = _b;
      if (n === null)
        throw Error(ct(404));
      return e = LO++, t = ":" + n.idPrefix + "R" + t, 0 < e && (t += "H" + e.toString(32)), t + ":";
    },
    useMutableSource: function(t, e) {
      return Ch(), e(t._source);
    },
    useSyncExternalStore: function(t, e, n) {
      if (n === void 0)
        throw Error(ct(407));
      return n();
    }
  }, _b = null, A$ = Yce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;
  function eit(t) {
    return console.error(t), null;
  }
  function A0() {
  }
  function tit(t, e, n, r, i, s, o, a, l) {
    var c = [], u = /* @__PURE__ */ new Set();
    return e = {
      destination: null,
      responseState: e,
      progressiveChunkSize: r === void 0 ? 12800 : r,
      status: 0,
      fatalError: null,
      nextSegmentId: 0,
      allPendingTasks: 0,
      pendingRootTasks: 0,
      completedRootSegment: null,
      abortableTasks: u,
      pingedTasks: c,
      clientRenderedBoundaries: [],
      completedBoundaries: [],
      partialBoundaries: [],
      onError: i === void 0 ? eit : i,
      onAllReady: s === void 0 ? A0 : s,
      onShellReady: o === void 0 ? A0 : o,
      onShellError: a === void 0 ? A0 : a,
      onFatalError: l === void 0 ? A0 : l
    }, n = LP(e, 0, null, n, false, false), n.parentFlushed = true, t = PN(e, t, null, n, u, lue, null, Wrt), c.push(t), e;
  }
  function PN(t, e, n, r, i, s, o, a) {
    t.allPendingTasks++, n === null ? t.pendingRootTasks++ : n.pendingTasks++;
    var l = {
      node: e,
      ping: function() {
        var c = t.pingedTasks;
        c.push(l), c.length === 1 && mue(t);
      },
      blockedBoundary: n,
      blockedSegment: r,
      abortSet: i,
      legacyContext: s,
      context: o,
      treeContext: a
    };
    return i.add(l), l;
  }
  function LP(t, e, n, r, i, s) {
    return {
      status: 0,
      id: -1,
      index: e,
      parentFlushed: false,
      chunks: [],
      children: [],
      formatContext: r,
      boundary: n,
      lastPushedText: i,
      textEmbedded: s
    };
  }
  function jO(t, e) {
    if (t = t.onError(e), t != null && typeof t != "string")
      throw Error('onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' + typeof t + '" instead');
    return t;
  }
  function jP(t, e) {
    var n = t.onShellError;
    n(e), n = t.onFatalError, n(e), t.destination !== null ? (t.status = 2, t.destination.destroy(e)) : (t.status = 1, t.fatalError = e);
  }
  function _X(t, e, n, r, i) {
    for (Kc = {}, xN = e, LO = 0, t = n(r, i); DP; )
      DP = false, LO = 0, B2 += 1, ln = null, t = n(r, i);
    return kN(), t;
  }
  function TX(t, e, n, r) {
    var i = n.render(), s = r.childContextTypes;
    if (s != null) {
      var o = e.legacyContext;
      if (typeof n.getChildContext != "function")
        r = o;
      else {
        n = n.getChildContext();
        for (var a in n)
          if (!(a in s))
            throw Error(ct(108, ED(r) || "Unknown", a));
        r = mv({}, o, n);
      }
      e.legacyContext = r, Xs(t, e, i), e.legacyContext = o;
    } else
      Xs(t, e, i);
  }
  function EX(t, e) {
    if (t && t.defaultProps) {
      e = mv({}, e), t = t.defaultProps;
      for (var n in t)
        e[n] === void 0 && (e[n] = t[n]);
      return e;
    }
    return e;
  }
  function $D(t, e, n, r, i) {
    if (typeof n == "function")
      if (n.prototype && n.prototype.isReactComponent) {
        i = SX(n, e.legacyContext);
        var s = n.contextType;
        s = new n(r, typeof s == "object" && s !== null ? s._currentValue2 : i), xX(s, n, r, i), TX(t, e, s, n);
      } else {
        s = SX(n, e.legacyContext), i = _X(t, e, n, r, s);
        var o = LO !== 0;
        if (typeof i == "object" && i !== null && typeof i.render == "function" && i.$$typeof === void 0)
          xX(i, n, r, s), TX(t, e, i, n);
        else if (o) {
          r = e.treeContext, e.treeContext = ID(r, 1, 0);
          try {
            Xs(t, e, i);
          } finally {
            e.treeContext = r;
          }
        } else
          Xs(t, e, i);
      }
    else if (typeof n == "string") {
      switch (i = e.blockedSegment, s = Lrt(i.chunks, n, r, t.responseState, i.formatContext), i.lastPushedText = false, o = i.formatContext, i.formatContext = Rrt(o, n, r), AD(t, e, s), i.formatContext = o, n) {
        case "area":
        case "base":
        case "br":
        case "col":
        case "embed":
        case "hr":
        case "img":
        case "input":
        case "keygen":
        case "link":
        case "meta":
        case "param":
        case "source":
        case "track":
        case "wbr":
          break;
        default:
          i.chunks.push("</", n, ">");
      }
      i.lastPushedText = false;
    } else {
      switch (n) {
        case Vrt:
        case Urt:
        case eue:
        case tue:
        case Jce:
          Xs(t, e, r.children);
          return;
        case oue:
          Xs(t, e, r.children);
          return;
        case Brt:
          throw Error(ct(343));
        case sue:
          e: {
            n = e.blockedBoundary, i = e.blockedSegment, s = r.fallback, r = r.children, o = /* @__PURE__ */ new Set();
            var a = {
              id: null,
              rootSegmentID: -1,
              parentFlushed: false,
              pendingTasks: 0,
              forceClientRender: false,
              completedSegments: [],
              byteSize: 0,
              fallbackAbortableTasks: o,
              errorDigest: null
            }, l = LP(t, i.chunks.length, a, i.formatContext, false, false);
            i.children.push(l), i.lastPushedText = false;
            var c = LP(t, 0, null, i.formatContext, false, false);
            c.parentFlushed = true, e.blockedBoundary = a, e.blockedSegment = c;
            try {
              if (AD(t, e, r), t.responseState.generateStaticMarkup || c.lastPushedText && c.textEmbedded && c.chunks.push("<!-- -->"), c.status = 1, NP(a, c), a.pendingTasks === 0)
                break e;
            } catch (u) {
              c.status = 4, a.forceClientRender = true, a.errorDigest = jO(t, u);
            } finally {
              e.blockedBoundary = n, e.blockedSegment = i;
            }
            e = PN(t, s, n, l, o, e.legacyContext, e.context, e.treeContext), t.pingedTasks.push(e);
          }
          return;
      }
      if (typeof n == "object" && n !== null)
        switch (n.$$typeof) {
          case iue:
            if (r = _X(t, e, n.render, r, i), LO !== 0) {
              n = e.treeContext, e.treeContext = ID(n, 1, 0);
              try {
                Xs(t, e, r);
              } finally {
                e.treeContext = n;
              }
            } else
              Xs(t, e, r);
            return;
          case aue:
            n = n.type, r = EX(n, r), $D(t, e, n, r, i);
            return;
          case nue:
            if (i = r.children, n = n._context, r = r.value, s = n._currentValue2, n._currentValue2 = r, o = Nh, Nh = r = {
              parent: o,
              depth: o === null ? 0 : o.depth + 1,
              context: n,
              parentValue: s,
              value: r
            }, e.context = r, Xs(t, e, i), t = Nh, t === null)
              throw Error(ct(403));
            r = t.parentValue, t.context._currentValue2 = r === Xrt ? t.context._defaultValue : r, t = Nh = t.parent, e.context = t;
            return;
          case rue:
            r = r.children, r = r(n._currentValue2), Xs(t, e, r);
            return;
          case wN:
            i = n._init, n = i(n._payload), r = EX(n, r), $D(t, e, n, r, void 0);
            return;
        }
      throw Error(ct(130, n == null ? n : typeof n, ""));
    }
  }
  function Xs(t, e, n) {
    if (e.node = n, typeof n == "object" && n !== null) {
      switch (n.$$typeof) {
        case Frt:
          $D(t, e, n.type, n.props, n.ref);
          return;
        case Kce:
          throw Error(ct(257));
        case wN:
          var r = n._init;
          n = r(n._payload), Xs(t, e, n);
          return;
      }
      if (TD(n)) {
        IX(t, e, n);
        return;
      }
      if (n === null || typeof n != "object" ? r = null : (r = OX && n[OX] || n["@@iterator"], r = typeof r == "function" ? r : null), r && (r = r.call(n))) {
        if (n = r.next(), !n.done) {
          var i = [];
          do
            i.push(n.value), n = r.next();
          while (!n.done);
          IX(t, e, i);
        }
        return;
      }
      throw t = Object.prototype.toString.call(n), Error(ct(31, t === "[object Object]" ? "object with keys {" + Object.keys(n).join(", ") + "}" : t));
    }
    typeof n == "string" ? (r = e.blockedSegment, r.lastPushedText = vX(e.blockedSegment.chunks, n, t.responseState, r.lastPushedText)) : typeof n == "number" && (r = e.blockedSegment, r.lastPushedText = vX(e.blockedSegment.chunks, "" + n, t.responseState, r.lastPushedText));
  }
  function IX(t, e, n) {
    for (var r = n.length, i = 0; i < r; i++) {
      var s = e.treeContext;
      e.treeContext = ID(s, r, i);
      try {
        AD(t, e, n[i]);
      } finally {
        e.treeContext = s;
      }
    }
  }
  function AD(t, e, n) {
    var r = e.blockedSegment.formatContext, i = e.legacyContext, s = e.context;
    try {
      return Xs(t, e, n);
    } catch (l) {
      if (kN(), typeof l == "object" && l !== null && typeof l.then == "function") {
        n = l;
        var o = e.blockedSegment, a = LP(t, o.chunks.length, null, o.formatContext, o.lastPushedText, true);
        o.children.push(a), o.lastPushedText = false, t = PN(t, e.node, e.blockedBoundary, a, e.abortSet, e.legacyContext, e.context, e.treeContext).ping, n.then(t, t), e.blockedSegment.formatContext = r, e.legacyContext = i, e.context = s, MP(s);
      } else
        throw e.blockedSegment.formatContext = r, e.legacyContext = i, e.context = s, MP(s), l;
    }
  }
  function nit(t) {
    var e = t.blockedBoundary;
    t = t.blockedSegment, t.status = 3, gue(this, e, t);
  }
  function pue(t, e, n) {
    var r = t.blockedBoundary;
    t.blockedSegment.status = 3, r === null ? (e.allPendingTasks--, e.status !== 2 && (e.status = 2, e.destination !== null && e.destination.push(null))) : (r.pendingTasks--, r.forceClientRender || (r.forceClientRender = true, t = n === void 0 ? Error(ct(432)) : n, r.errorDigest = e.onError(t), r.parentFlushed && e.clientRenderedBoundaries.push(r)), r.fallbackAbortableTasks.forEach(function(i) {
      return pue(i, e, n);
    }), r.fallbackAbortableTasks.clear(), e.allPendingTasks--, e.allPendingTasks === 0 && (r = e.onAllReady, r()));
  }
  function NP(t, e) {
    if (e.chunks.length === 0 && e.children.length === 1 && e.children[0].boundary === null) {
      var n = e.children[0];
      n.id = e.id, n.parentFlushed = true, n.status === 1 && NP(t, n);
    } else
      t.completedSegments.push(e);
  }
  function gue(t, e, n) {
    if (e === null) {
      if (n.parentFlushed) {
        if (t.completedRootSegment !== null)
          throw Error(ct(389));
        t.completedRootSegment = n;
      }
      t.pendingRootTasks--, t.pendingRootTasks === 0 && (t.onShellError = A0, e = t.onShellReady, e());
    } else
      e.pendingTasks--, e.forceClientRender || (e.pendingTasks === 0 ? (n.parentFlushed && n.status === 1 && NP(e, n), e.parentFlushed && t.completedBoundaries.push(e), e.fallbackAbortableTasks.forEach(nit, t), e.fallbackAbortableTasks.clear()) : n.parentFlushed && n.status === 1 && (NP(e, n), e.completedSegments.length === 1 && e.parentFlushed && t.partialBoundaries.push(e)));
    t.allPendingTasks--, t.allPendingTasks === 0 && (t = t.onAllReady, t());
  }
  function mue(t) {
    if (t.status !== 2) {
      var e = Nh, n = A$.current;
      A$.current = CX;
      var r = _b;
      _b = t.responseState;
      try {
        var i = t.pingedTasks, s;
        for (s = 0; s < i.length; s++) {
          var o = i[s], a = t, l = o.blockedSegment;
          if (l.status === 0) {
            MP(o.context);
            try {
              Xs(a, o, o.node), a.responseState.generateStaticMarkup || l.lastPushedText && l.textEmbedded && l.chunks.push("<!-- -->"), o.abortSet.delete(o), l.status = 1, gue(a, o.blockedBoundary, l);
            } catch (y) {
              if (kN(), typeof y == "object" && y !== null && typeof y.then == "function") {
                var c = o.ping;
                y.then(c, c);
              } else {
                o.abortSet.delete(o), l.status = 4;
                var u = o.blockedBoundary, d = y, h = jO(a, d);
                if (u === null ? jP(a, d) : (u.pendingTasks--, u.forceClientRender || (u.forceClientRender = true, u.errorDigest = h, u.parentFlushed && a.clientRenderedBoundaries.push(u))), a.allPendingTasks--, a.allPendingTasks === 0) {
                  var f = a.onAllReady;
                  f();
                }
              }
            } finally {
            }
          }
        }
        i.splice(0, s), t.destination !== null && CN(t, t.destination);
      } catch (y) {
        jO(t, y), jP(t, y);
      } finally {
        _b = r, A$.current = n, n === CX && MP(e);
      }
    }
  }
  function Px(t, e, n) {
    switch (n.parentFlushed = true, n.status) {
      case 0:
        var r = n.id = t.nextSegmentId++;
        return n.lastPushedText = false, n.textEmbedded = false, t = t.responseState, e.push('<template id="'), e.push(t.placeholderPrefix), t = r.toString(16), e.push(t), e.push('"></template>');
      case 1:
        n.status = 2;
        var i = true;
        r = n.chunks;
        var s = 0;
        n = n.children;
        for (var o = 0; o < n.length; o++) {
          for (i = n[o]; s < i.index; s++)
            e.push(r[s]);
          i = U2(t, e, i);
        }
        for (; s < r.length - 1; s++)
          e.push(r[s]);
        return s < r.length && (i = e.push(r[s])), i;
      default:
        throw Error(ct(390));
    }
  }
  function U2(t, e, n) {
    var r = n.boundary;
    if (r === null)
      return Px(t, e, n);
    if (r.parentFlushed = true, r.forceClientRender)
      return t.responseState.generateStaticMarkup || (r = r.errorDigest, e.push("<!--$!-->"), e.push("<template"), r && (e.push(' data-dgst="'), r = Fi(r), e.push(r), e.push('"')), e.push("></template>")), Px(t, e, n), t = t.responseState.generateStaticMarkup ? true : e.push("<!--/$-->"), t;
    if (0 < r.pendingTasks) {
      r.rootSegmentID = t.nextSegmentId++, 0 < r.completedSegments.length && t.partialBoundaries.push(r);
      var i = t.responseState, s = i.nextSuspenseID++;
      return i = i.boundaryPrefix + s.toString(16), r = r.id = i, yX(e, t.responseState, r), Px(t, e, n), e.push("<!--/$-->");
    }
    if (r.byteSize > t.progressiveChunkSize)
      return r.rootSegmentID = t.nextSegmentId++, t.completedBoundaries.push(r), yX(e, t.responseState, r.id), Px(t, e, n), e.push("<!--/$-->");
    if (t.responseState.generateStaticMarkup || e.push("<!--$-->"), n = r.completedSegments, n.length !== 1)
      throw Error(ct(391));
    return U2(t, e, n[0]), t = t.responseState.generateStaticMarkup ? true : e.push("<!--/$-->"), t;
  }
  function $X(t, e, n) {
    return jrt(e, t.responseState, n.formatContext, n.id), U2(t, e, n), Nrt(e, n.formatContext);
  }
  function AX(t, e, n) {
    for (var r = n.completedSegments, i = 0; i < r.length; i++)
      yue(t, e, n, r[i]);
    if (r.length = 0, t = t.responseState, r = n.id, n = n.rootSegmentID, e.push(t.startInlineScript), t.sentCompleteBoundaryFunction ? e.push('$RC("') : (t.sentCompleteBoundaryFunction = true, e.push('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("')), r === null)
      throw Error(ct(395));
    return n = n.toString(16), e.push(r), e.push('","'), e.push(t.segmentPrefix), e.push(n), e.push('")<\/script>');
  }
  function yue(t, e, n, r) {
    if (r.status === 2)
      return true;
    var i = r.id;
    if (i === -1) {
      if ((r.id = n.rootSegmentID) === -1)
        throw Error(ct(392));
      return $X(t, e, r);
    }
    return $X(t, e, r), t = t.responseState, e.push(t.startInlineScript), t.sentCompleteSegmentFunction ? e.push('$RS("') : (t.sentCompleteSegmentFunction = true, e.push('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("')), e.push(t.segmentPrefix), i = i.toString(16), e.push(i), e.push('","'), e.push(t.placeholderPrefix), e.push(i), e.push('")<\/script>');
  }
  function CN(t, e) {
    try {
      var n = t.completedRootSegment;
      if (n !== null && t.pendingRootTasks === 0) {
        U2(t, e, n), t.completedRootSegment = null;
        var r = t.responseState.bootstrapChunks;
        for (n = 0; n < r.length - 1; n++)
          e.push(r[n]);
        n < r.length && e.push(r[n]);
      }
      var i = t.clientRenderedBoundaries, s;
      for (s = 0; s < i.length; s++) {
        var o = i[s];
        r = e;
        var a = t.responseState, l = o.id, c = o.errorDigest, u = o.errorMessage, d = o.errorComponentStack;
        if (r.push(a.startInlineScript), a.sentClientRenderFunction ? r.push('$RX("') : (a.sentClientRenderFunction = true, r.push('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("')), l === null)
          throw Error(ct(395));
        if (r.push(l), r.push('"'), c || u || d) {
          r.push(",");
          var h = $$(c || "");
          r.push(h);
        }
        if (u || d) {
          r.push(",");
          var f = $$(u || "");
          r.push(f);
        }
        if (d) {
          r.push(",");
          var y = $$(d);
          r.push(y);
        }
        if (!r.push(")<\/script>")) {
          t.destination = null, s++, i.splice(0, s);
          return;
        }
      }
      i.splice(0, s);
      var g = t.completedBoundaries;
      for (s = 0; s < g.length; s++)
        if (!AX(t, e, g[s])) {
          t.destination = null, s++, g.splice(0, s);
          return;
        }
      g.splice(0, s);
      var O = t.partialBoundaries;
      for (s = 0; s < O.length; s++) {
        var S = O[s];
        e: {
          i = t, o = e;
          var w = S.completedSegments;
          for (a = 0; a < w.length; a++)
            if (!yue(i, o, S, w[a])) {
              a++, w.splice(0, a);
              var x = false;
              break e;
            }
          w.splice(0, a), x = true;
        }
        if (!x) {
          t.destination = null, s++, O.splice(0, s);
          return;
        }
      }
      O.splice(0, s);
      var P = t.completedBoundaries;
      for (s = 0; s < P.length; s++)
        if (!AX(t, e, P[s])) {
          t.destination = null, s++, P.splice(0, s);
          return;
        }
      P.splice(0, s);
    } finally {
      t.allPendingTasks === 0 && t.pingedTasks.length === 0 && t.clientRenderedBoundaries.length === 0 && t.completedBoundaries.length === 0 && e.push(null);
    }
  }
  function rit(t, e) {
    try {
      var n = t.abortableTasks;
      n.forEach(function(r) {
        return pue(r, t, e);
      }), n.clear(), t.destination !== null && CN(t, t.destination);
    } catch (r) {
      jO(t, r), jP(t, r);
    }
  }
  function iit() {
  }
  function vue(t, e, n, r) {
    var i = false, s = null, o = "", a = {
      push: function(c) {
        return c !== null && (o += c), true;
      },
      destroy: function(c) {
        i = true, s = c;
      }
    }, l = false;
    if (t = tit(t, zrt(n, e ? e.identifierPrefix : void 0), {
      insertionMode: 1,
      selectedValue: null
    }, 1 / 0, iit, void 0, function() {
      l = true;
    }, void 0, void 0), mue(t), rit(t, r), t.status === 1)
      t.status = 2, a.destroy(t.fatalError);
    else if (t.status !== 2 && t.destination === null) {
      t.destination = a;
      try {
        CN(t, a);
      } catch (c) {
        jO(t, c), jP(t, c);
      }
    }
    if (i)
      throw s;
    if (!l)
      throw Error(ct(426));
    return o;
  }
  Zm.renderToNodeStream = function() {
    throw Error(ct(207));
  };
  Zm.renderToStaticMarkup = function(t, e) {
    return vue(t, e, true, 'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server');
  };
  Zm.renderToStaticNodeStream = function() {
    throw Error(ct(208));
  };
  Zm.renderToString = function(t, e) {
    return vue(t, e, false, 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server');
  };
  Zm.version = "18.3.1";
  var _N = {};
  var Oue = b;
  function mt(t) {
    for (var e = "https://reactjs.org/docs/error-decoder.html?invariant=" + t, n = 1; n < arguments.length; n++)
      e += "&args[]=" + encodeURIComponent(arguments[n]);
    return "Minified React error #" + t + "; visit " + e + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  var Ws = null, Zs = 0;
  function Ne(t, e) {
    if (e.length !== 0)
      if (512 < e.length)
        0 < Zs && (t.enqueue(new Uint8Array(Ws.buffer, 0, Zs)), Ws = new Uint8Array(512), Zs = 0), t.enqueue(e);
      else {
        var n = Ws.length - Zs;
        n < e.length && (n === 0 ? t.enqueue(Ws) : (Ws.set(e.subarray(0, n), Zs), t.enqueue(Ws), e = e.subarray(n)), Ws = new Uint8Array(512), Zs = 0), Ws.set(e, Zs), Zs += e.length;
      }
  }
  function Sn(t, e) {
    return Ne(t, e), true;
  }
  function RX(t) {
    Ws && 0 < Zs && (t.enqueue(new Uint8Array(Ws.buffer, 0, Zs)), Ws = null, Zs = 0);
  }
  var Sue = new TextEncoder();
  function yt(t) {
    return Sue.encode(t);
  }
  function Ce(t) {
    return Sue.encode(t);
  }
  function wue(t, e) {
    typeof t.error == "function" ? t.error(e) : t.close();
  }
  var os = Object.prototype.hasOwnProperty, sit = /^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/, MX = {}, DX = {};
  function xue(t) {
    return os.call(DX, t) ? true : os.call(MX, t) ? false : sit.test(t) ? DX[t] = true : (MX[t] = true, false);
  }
  function Gi(t, e, n, r, i, s, o) {
    this.acceptsBooleans = e === 2 || e === 3 || e === 4, this.attributeName = r, this.attributeNamespace = i, this.mustUseProperty = n, this.propertyName = t, this.type = e, this.sanitizeURL = s, this.removeEmptyString = o;
  }
  var qr = {};
  "children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t) {
    qr[t] = new Gi(t, 0, false, t, null, false, false);
  });
  [
    [
      "acceptCharset",
      "accept-charset"
    ],
    [
      "className",
      "class"
    ],
    [
      "htmlFor",
      "for"
    ],
    [
      "httpEquiv",
      "http-equiv"
    ]
  ].forEach(function(t) {
    var e = t[0];
    qr[e] = new Gi(e, 1, false, t[1], null, false, false);
  });
  [
    "contentEditable",
    "draggable",
    "spellCheck",
    "value"
  ].forEach(function(t) {
    qr[t] = new Gi(t, 2, false, t.toLowerCase(), null, false, false);
  });
  [
    "autoReverse",
    "externalResourcesRequired",
    "focusable",
    "preserveAlpha"
  ].forEach(function(t) {
    qr[t] = new Gi(t, 2, false, t, null, false, false);
  });
  "allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t) {
    qr[t] = new Gi(t, 3, false, t.toLowerCase(), null, false, false);
  });
  [
    "checked",
    "multiple",
    "muted",
    "selected"
  ].forEach(function(t) {
    qr[t] = new Gi(t, 3, true, t, null, false, false);
  });
  [
    "capture",
    "download"
  ].forEach(function(t) {
    qr[t] = new Gi(t, 4, false, t, null, false, false);
  });
  [
    "cols",
    "rows",
    "size",
    "span"
  ].forEach(function(t) {
    qr[t] = new Gi(t, 6, false, t, null, false, false);
  });
  [
    "rowSpan",
    "start"
  ].forEach(function(t) {
    qr[t] = new Gi(t, 5, false, t.toLowerCase(), null, false, false);
  });
  var TN = /[\-:]([a-z])/g;
  function EN(t) {
    return t[1].toUpperCase();
  }
  "accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t) {
    var e = t.replace(TN, EN);
    qr[e] = new Gi(e, 1, false, t, null, false, false);
  });
  "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t) {
    var e = t.replace(TN, EN);
    qr[e] = new Gi(e, 1, false, t, "http://www.w3.org/1999/xlink", false, false);
  });
  [
    "xml:base",
    "xml:lang",
    "xml:space"
  ].forEach(function(t) {
    var e = t.replace(TN, EN);
    qr[e] = new Gi(e, 1, false, t, "http://www.w3.org/XML/1998/namespace", false, false);
  });
  [
    "tabIndex",
    "crossOrigin"
  ].forEach(function(t) {
    qr[t] = new Gi(t, 1, false, t.toLowerCase(), null, false, false);
  });
  qr.xlinkHref = new Gi("xlinkHref", 1, false, "xlink:href", "http://www.w3.org/1999/xlink", true, false);
  [
    "src",
    "href",
    "action",
    "formAction"
  ].forEach(function(t) {
    qr[t] = new Gi(t, 1, false, t.toLowerCase(), null, true, true);
  });
  var Tb = {
    animationIterationCount: true,
    aspectRatio: true,
    borderImageOutset: true,
    borderImageSlice: true,
    borderImageWidth: true,
    boxFlex: true,
    boxFlexGroup: true,
    boxOrdinalGroup: true,
    columnCount: true,
    columns: true,
    flex: true,
    flexGrow: true,
    flexPositive: true,
    flexShrink: true,
    flexNegative: true,
    flexOrder: true,
    gridArea: true,
    gridRow: true,
    gridRowEnd: true,
    gridRowSpan: true,
    gridRowStart: true,
    gridColumn: true,
    gridColumnEnd: true,
    gridColumnSpan: true,
    gridColumnStart: true,
    fontWeight: true,
    lineClamp: true,
    lineHeight: true,
    opacity: true,
    order: true,
    orphans: true,
    tabSize: true,
    widows: true,
    zIndex: true,
    zoom: true,
    fillOpacity: true,
    floodOpacity: true,
    stopOpacity: true,
    strokeDasharray: true,
    strokeDashoffset: true,
    strokeMiterlimit: true,
    strokeOpacity: true,
    strokeWidth: true
  }, oit = [
    "Webkit",
    "ms",
    "Moz",
    "O"
  ];
  Object.keys(Tb).forEach(function(t) {
    oit.forEach(function(e) {
      e = e + t.charAt(0).toUpperCase() + t.substring(1), Tb[e] = Tb[t];
    });
  });
  var ait = /["'&<>]/;
  function Vr(t) {
    if (typeof t == "boolean" || typeof t == "number")
      return "" + t;
    t = "" + t;
    var e = ait.exec(t);
    if (e) {
      var n = "", r, i = 0;
      for (r = e.index; r < t.length; r++) {
        switch (t.charCodeAt(r)) {
          case 34:
            e = "&quot;";
            break;
          case 38:
            e = "&amp;";
            break;
          case 39:
            e = "&#x27;";
            break;
          case 60:
            e = "&lt;";
            break;
          case 62:
            e = "&gt;";
            break;
          default:
            continue;
        }
        i !== r && (n += t.substring(i, r)), i = r + 1, n += e;
      }
      t = i !== r ? n + t.substring(i, r) : n;
    }
    return t;
  }
  var lit = /([A-Z])/g, cit = /^ms-/, RD = Array.isArray, uit = Ce("<script>"), dit = Ce("<\/script>"), hit = Ce('<script src="'), fit = Ce('<script type="module" src="'), LX = Ce('" async=""><\/script>'), pit = /(<\/|<)(s)(cript)/gi;
  function git(t, e, n, r) {
    return "" + e + (n === "s" ? "\\u0073" : "\\u0053") + r;
  }
  function mit(t, e, n, r, i) {
    t = t === void 0 ? "" : t, e = e === void 0 ? uit : Ce('<script nonce="' + Vr(e) + '">');
    var s = [];
    if (n !== void 0 && s.push(e, yt(("" + n).replace(pit, git)), dit), r !== void 0)
      for (n = 0; n < r.length; n++)
        s.push(hit, yt(Vr(r[n])), LX);
    if (i !== void 0)
      for (r = 0; r < i.length; r++)
        s.push(fit, yt(Vr(i[r])), LX);
    return {
      bootstrapChunks: s,
      startInlineScript: e,
      placeholderPrefix: Ce(t + "P:"),
      segmentPrefix: Ce(t + "S:"),
      boundaryPrefix: t + "B:",
      idPrefix: t,
      nextSuspenseID: 0,
      sentCompleteSegmentFunction: false,
      sentCompleteBoundaryFunction: false,
      sentClientRenderFunction: false
    };
  }
  function pl(t, e) {
    return {
      insertionMode: t,
      selectedValue: e
    };
  }
  function yit(t) {
    return pl(t === "http://www.w3.org/2000/svg" ? 2 : t === "http://www.w3.org/1998/Math/MathML" ? 3 : 0, null);
  }
  function vit(t, e, n) {
    switch (e) {
      case "select":
        return pl(1, n.value != null ? n.value : n.defaultValue);
      case "svg":
        return pl(2, null);
      case "math":
        return pl(3, null);
      case "foreignObject":
        return pl(1, null);
      case "table":
        return pl(4, null);
      case "thead":
      case "tbody":
      case "tfoot":
        return pl(5, null);
      case "colgroup":
        return pl(7, null);
      case "tr":
        return pl(6, null);
    }
    return 4 <= t.insertionMode || t.insertionMode === 0 ? pl(1, null) : t;
  }
  var IN = Ce("<!-- -->");
  function jX(t, e, n, r) {
    return e === "" ? r : (r && t.push(IN), t.push(yt(Vr(e))), true);
  }
  var NX = /* @__PURE__ */ new Map(), Oit = Ce(' style="'), QX = Ce(":"), Sit = Ce(";");
  function bue(t, e, n) {
    if (typeof n != "object")
      throw Error(mt(62));
    e = true;
    for (var r in n)
      if (os.call(n, r)) {
        var i = n[r];
        if (i != null && typeof i != "boolean" && i !== "") {
          if (r.indexOf("--") === 0) {
            var s = yt(Vr(r));
            i = yt(Vr(("" + i).trim()));
          } else {
            s = r;
            var o = NX.get(s);
            o !== void 0 || (o = Ce(Vr(s.replace(lit, "-$1").toLowerCase().replace(cit, "-ms-"))), NX.set(s, o)), s = o, i = typeof i == "number" ? i === 0 || os.call(Tb, r) ? yt("" + i) : yt(i + "px") : yt(Vr(("" + i).trim()));
          }
          e ? (e = false, t.push(Oit, s, QX, i)) : t.push(Sit, s, QX, i);
        }
      }
    e || t.push(_h);
  }
  var $u = Ce(" "), jp = Ce('="'), _h = Ce('"'), zX = Ce('=""');
  function Fs(t, e, n, r) {
    switch (n) {
      case "style":
        bue(t, e, r);
        return;
      case "defaultValue":
      case "defaultChecked":
      case "innerHTML":
      case "suppressContentEditableWarning":
      case "suppressHydrationWarning":
        return;
    }
    if (!(2 < n.length) || n[0] !== "o" && n[0] !== "O" || n[1] !== "n" && n[1] !== "N") {
      if (e = qr.hasOwnProperty(n) ? qr[n] : null, e !== null) {
        switch (typeof r) {
          case "function":
          case "symbol":
            return;
          case "boolean":
            if (!e.acceptsBooleans)
              return;
        }
        switch (n = yt(e.attributeName), e.type) {
          case 3:
            r && t.push($u, n, zX);
            break;
          case 4:
            r === true ? t.push($u, n, zX) : r !== false && t.push($u, n, jp, yt(Vr(r)), _h);
            break;
          case 5:
            isNaN(r) || t.push($u, n, jp, yt(Vr(r)), _h);
            break;
          case 6:
            !isNaN(r) && 1 <= r && t.push($u, n, jp, yt(Vr(r)), _h);
            break;
          default:
            e.sanitizeURL && (r = "" + r), t.push($u, n, jp, yt(Vr(r)), _h);
        }
      } else if (xue(n)) {
        switch (typeof r) {
          case "function":
          case "symbol":
            return;
          case "boolean":
            if (e = n.toLowerCase().slice(0, 5), e !== "data-" && e !== "aria-")
              return;
        }
        t.push($u, yt(n), jp, yt(Vr(r)), _h);
      }
    }
  }
  var Au = Ce(">"), FX = Ce("/>");
  function Eb(t, e, n) {
    if (e != null) {
      if (n != null)
        throw Error(mt(60));
      if (typeof e != "object" || !("__html" in e))
        throw Error(mt(61));
      e = e.__html, e != null && t.push(yt("" + e));
    }
  }
  function wit(t) {
    var e = "";
    return Oue.Children.forEach(t, function(n) {
      n != null && (e += n);
    }), e;
  }
  var R$ = Ce(' selected=""');
  function M$(t, e, n, r) {
    t.push(gl(n));
    var i = n = null, s;
    for (s in e)
      if (os.call(e, s)) {
        var o = e[s];
        if (o != null)
          switch (s) {
            case "children":
              n = o;
              break;
            case "dangerouslySetInnerHTML":
              i = o;
              break;
            default:
              Fs(t, r, s, o);
          }
      }
    return t.push(Au), Eb(t, i, n), typeof n == "string" ? (t.push(yt(Vr(n))), null) : n;
  }
  var D$ = Ce(`
`), xit = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/, BX = /* @__PURE__ */ new Map();
  function gl(t) {
    var e = BX.get(t);
    if (e === void 0) {
      if (!xit.test(t))
        throw Error(mt(65, t));
      e = Ce("<" + t), BX.set(t, e);
    }
    return e;
  }
  var bit = Ce("<!DOCTYPE html>");
  function kit(t, e, n, r, i) {
    switch (e) {
      case "select":
        t.push(gl("select"));
        var s = null, o = null;
        for (u in n)
          if (os.call(n, u)) {
            var a = n[u];
            if (a != null)
              switch (u) {
                case "children":
                  s = a;
                  break;
                case "dangerouslySetInnerHTML":
                  o = a;
                  break;
                case "defaultValue":
                case "value":
                  break;
                default:
                  Fs(t, r, u, a);
              }
          }
        return t.push(Au), Eb(t, o, s), s;
      case "option":
        o = i.selectedValue, t.push(gl("option"));
        var l = a = null, c = null, u = null;
        for (s in n)
          if (os.call(n, s)) {
            var d = n[s];
            if (d != null)
              switch (s) {
                case "children":
                  a = d;
                  break;
                case "selected":
                  c = d;
                  break;
                case "dangerouslySetInnerHTML":
                  u = d;
                  break;
                case "value":
                  l = d;
                default:
                  Fs(t, r, s, d);
              }
          }
        if (o != null)
          if (n = l !== null ? "" + l : wit(a), RD(o)) {
            for (r = 0; r < o.length; r++)
              if ("" + o[r] === n) {
                t.push(R$);
                break;
              }
          } else
            "" + o === n && t.push(R$);
        else
          c && t.push(R$);
        return t.push(Au), Eb(t, u, a), a;
      case "textarea":
        t.push(gl("textarea")), u = o = s = null;
        for (a in n)
          if (os.call(n, a) && (l = n[a], l != null))
            switch (a) {
              case "children":
                u = l;
                break;
              case "value":
                s = l;
                break;
              case "defaultValue":
                o = l;
                break;
              case "dangerouslySetInnerHTML":
                throw Error(mt(91));
              default:
                Fs(t, r, a, l);
            }
        if (s === null && o !== null && (s = o), t.push(Au), u != null) {
          if (s != null)
            throw Error(mt(92));
          if (RD(u) && 1 < u.length)
            throw Error(mt(93));
          s = "" + u;
        }
        return typeof s == "string" && s[0] === `
` && t.push(D$), s !== null && t.push(yt(Vr("" + s))), null;
      case "input":
        t.push(gl("input")), l = u = a = s = null;
        for (o in n)
          if (os.call(n, o) && (c = n[o], c != null))
            switch (o) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(mt(399, "input"));
              case "defaultChecked":
                l = c;
                break;
              case "defaultValue":
                a = c;
                break;
              case "checked":
                u = c;
                break;
              case "value":
                s = c;
                break;
              default:
                Fs(t, r, o, c);
            }
        return u !== null ? Fs(t, r, "checked", u) : l !== null && Fs(t, r, "checked", l), s !== null ? Fs(t, r, "value", s) : a !== null && Fs(t, r, "value", a), t.push(FX), null;
      case "menuitem":
        t.push(gl("menuitem"));
        for (var h in n)
          if (os.call(n, h) && (s = n[h], s != null))
            switch (h) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(mt(400));
              default:
                Fs(t, r, h, s);
            }
        return t.push(Au), null;
      case "title":
        t.push(gl("title")), s = null;
        for (d in n)
          if (os.call(n, d) && (o = n[d], o != null))
            switch (d) {
              case "children":
                s = o;
                break;
              case "dangerouslySetInnerHTML":
                throw Error(mt(434));
              default:
                Fs(t, r, d, o);
            }
        return t.push(Au), s;
      case "listing":
      case "pre":
        t.push(gl(e)), o = s = null;
        for (l in n)
          if (os.call(n, l) && (a = n[l], a != null))
            switch (l) {
              case "children":
                s = a;
                break;
              case "dangerouslySetInnerHTML":
                o = a;
                break;
              default:
                Fs(t, r, l, a);
            }
        if (t.push(Au), o != null) {
          if (s != null)
            throw Error(mt(60));
          if (typeof o != "object" || !("__html" in o))
            throw Error(mt(61));
          n = o.__html, n != null && (typeof n == "string" && 0 < n.length && n[0] === `
` ? t.push(D$, yt(n)) : t.push(yt("" + n)));
        }
        return typeof s == "string" && s[0] === `
` && t.push(D$), s;
      case "area":
      case "base":
      case "br":
      case "col":
      case "embed":
      case "hr":
      case "img":
      case "keygen":
      case "link":
      case "meta":
      case "param":
      case "source":
      case "track":
      case "wbr":
        t.push(gl(e));
        for (var f in n)
          if (os.call(n, f) && (s = n[f], s != null))
            switch (f) {
              case "children":
              case "dangerouslySetInnerHTML":
                throw Error(mt(399, e));
              default:
                Fs(t, r, f, s);
            }
        return t.push(FX), null;
      case "annotation-xml":
      case "color-profile":
      case "font-face":
      case "font-face-src":
      case "font-face-uri":
      case "font-face-format":
      case "font-face-name":
      case "missing-glyph":
        return M$(t, n, e, r);
      case "html":
        return i.insertionMode === 0 && t.push(bit), M$(t, n, e, r);
      default:
        if (e.indexOf("-") === -1 && typeof n.is != "string")
          return M$(t, n, e, r);
        t.push(gl(e)), o = s = null;
        for (c in n)
          if (os.call(n, c) && (a = n[c], a != null))
            switch (c) {
              case "children":
                s = a;
                break;
              case "dangerouslySetInnerHTML":
                o = a;
                break;
              case "style":
                bue(t, r, a);
                break;
              case "suppressContentEditableWarning":
              case "suppressHydrationWarning":
                break;
              default:
                xue(c) && typeof a != "function" && typeof a != "symbol" && t.push($u, yt(c), jp, yt(Vr(a)), _h);
            }
        return t.push(Au), Eb(t, o, s), s;
    }
  }
  var Pit = Ce("</"), Cit = Ce(">"), _it = Ce('<template id="'), Tit = Ce('"></template>'), Eit = Ce("<!--$-->"), Iit = Ce('<!--$?--><template id="'), $it = Ce('"></template>'), Ait = Ce("<!--$!-->"), Rit = Ce("<!--/$-->"), Mit = Ce("<template"), Dit = Ce('"'), Lit = Ce(' data-dgst="');
  Ce(' data-msg="');
  Ce(' data-stck="');
  var jit = Ce("></template>");
  function UX(t, e, n) {
    if (Ne(t, Iit), n === null)
      throw Error(mt(395));
    return Ne(t, n), Sn(t, $it);
  }
  var Nit = Ce('<div hidden id="'), Qit = Ce('">'), zit = Ce("</div>"), Fit = Ce('<svg aria-hidden="true" style="display:none" id="'), Bit = Ce('">'), Uit = Ce("</svg>"), Vit = Ce('<math aria-hidden="true" style="display:none" id="'), Xit = Ce('">'), Wit = Ce("</math>"), Zit = Ce('<table hidden id="'), Hit = Ce('">'), Yit = Ce("</table>"), Git = Ce('<table hidden><tbody id="'), qit = Ce('">'), Kit = Ce("</tbody></table>"), Jit = Ce('<table hidden><tr id="'), est = Ce('">'), tst = Ce("</tr></table>"), nst = Ce('<table hidden><colgroup id="'), rst = Ce('">'), ist = Ce("</colgroup></table>");
  function sst(t, e, n, r) {
    switch (n.insertionMode) {
      case 0:
      case 1:
        return Ne(t, Nit), Ne(t, e.segmentPrefix), Ne(t, yt(r.toString(16))), Sn(t, Qit);
      case 2:
        return Ne(t, Fit), Ne(t, e.segmentPrefix), Ne(t, yt(r.toString(16))), Sn(t, Bit);
      case 3:
        return Ne(t, Vit), Ne(t, e.segmentPrefix), Ne(t, yt(r.toString(16))), Sn(t, Xit);
      case 4:
        return Ne(t, Zit), Ne(t, e.segmentPrefix), Ne(t, yt(r.toString(16))), Sn(t, Hit);
      case 5:
        return Ne(t, Git), Ne(t, e.segmentPrefix), Ne(t, yt(r.toString(16))), Sn(t, qit);
      case 6:
        return Ne(t, Jit), Ne(t, e.segmentPrefix), Ne(t, yt(r.toString(16))), Sn(t, est);
      case 7:
        return Ne(t, nst), Ne(t, e.segmentPrefix), Ne(t, yt(r.toString(16))), Sn(t, rst);
      default:
        throw Error(mt(397));
    }
  }
  function ost(t, e) {
    switch (e.insertionMode) {
      case 0:
      case 1:
        return Sn(t, zit);
      case 2:
        return Sn(t, Uit);
      case 3:
        return Sn(t, Wit);
      case 4:
        return Sn(t, Yit);
      case 5:
        return Sn(t, Kit);
      case 6:
        return Sn(t, tst);
      case 7:
        return Sn(t, ist);
      default:
        throw Error(mt(397));
    }
  }
  var ast = Ce('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'), lst = Ce('$RS("'), cst = Ce('","'), ust = Ce('")<\/script>'), dst = Ce('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'), hst = Ce('$RC("'), fst = Ce('","'), pst = Ce('")<\/script>'), gst = Ce('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'), mst = Ce('$RX("'), yst = Ce('"'), vst = Ce(")<\/script>"), L$ = Ce(","), Ost = /[<\u2028\u2029]/g;
  function j$(t) {
    return JSON.stringify(t).replace(Ost, function(e) {
      switch (e) {
        case "<":
          return "\\u003c";
        case "\u2028":
          return "\\u2028";
        case "\u2029":
          return "\\u2029";
        default:
          throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React");
      }
    });
  }
  var yv = Object.assign, Sst = Symbol.for("react.element"), kue = Symbol.for("react.portal"), Pue = Symbol.for("react.fragment"), Cue = Symbol.for("react.strict_mode"), _ue = Symbol.for("react.profiler"), Tue = Symbol.for("react.provider"), Eue = Symbol.for("react.context"), Iue = Symbol.for("react.forward_ref"), $ue = Symbol.for("react.suspense"), Aue = Symbol.for("react.suspense_list"), Rue = Symbol.for("react.memo"), $N = Symbol.for("react.lazy"), wst = Symbol.for("react.scope"), xst = Symbol.for("react.debug_trace_mode"), bst = Symbol.for("react.legacy_hidden"), kst = Symbol.for("react.default_value"), VX = Symbol.iterator;
  function MD(t) {
    if (t == null)
      return null;
    if (typeof t == "function")
      return t.displayName || t.name || null;
    if (typeof t == "string")
      return t;
    switch (t) {
      case Pue:
        return "Fragment";
      case kue:
        return "Portal";
      case _ue:
        return "Profiler";
      case Cue:
        return "StrictMode";
      case $ue:
        return "Suspense";
      case Aue:
        return "SuspenseList";
    }
    if (typeof t == "object")
      switch (t.$$typeof) {
        case Eue:
          return (t.displayName || "Context") + ".Consumer";
        case Tue:
          return (t._context.displayName || "Context") + ".Provider";
        case Iue:
          var e = t.render;
          return t = t.displayName, t || (t = e.displayName || e.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
        case Rue:
          return e = t.displayName || null, e !== null ? e : MD(t.type) || "Memo";
        case $N:
          e = t._payload, t = t._init;
          try {
            return MD(t(e));
          } catch {
          }
      }
    return null;
  }
  var Mue = {};
  function XX(t, e) {
    if (t = t.contextTypes, !t)
      return Mue;
    var n = {}, r;
    for (r in t)
      n[r] = e[r];
    return n;
  }
  var Qh = null;
  function V2(t, e) {
    if (t !== e) {
      t.context._currentValue = t.parentValue, t = t.parent;
      var n = e.parent;
      if (t === null) {
        if (n !== null)
          throw Error(mt(401));
      } else {
        if (n === null)
          throw Error(mt(401));
        V2(t, n);
      }
      e.context._currentValue = e.value;
    }
  }
  function Due(t) {
    t.context._currentValue = t.parentValue, t = t.parent, t !== null && Due(t);
  }
  function Lue(t) {
    var e = t.parent;
    e !== null && Lue(e), t.context._currentValue = t.value;
  }
  function jue(t, e) {
    if (t.context._currentValue = t.parentValue, t = t.parent, t === null)
      throw Error(mt(402));
    t.depth === e.depth ? V2(t, e) : jue(t, e);
  }
  function Nue(t, e) {
    var n = e.parent;
    if (n === null)
      throw Error(mt(402));
    t.depth === n.depth ? V2(t, n) : Nue(t, n), e.context._currentValue = e.value;
  }
  function QP(t) {
    var e = Qh;
    e !== t && (e === null ? Lue(t) : t === null ? Due(e) : e.depth === t.depth ? V2(e, t) : e.depth > t.depth ? jue(e, t) : Nue(e, t), Qh = t);
  }
  var WX = {
    isMounted: function() {
      return false;
    },
    enqueueSetState: function(t, e) {
      t = t._reactInternals, t.queue !== null && t.queue.push(e);
    },
    enqueueReplaceState: function(t, e) {
      t = t._reactInternals, t.replace = true, t.queue = [
        e
      ];
    },
    enqueueForceUpdate: function() {
    }
  };
  function ZX(t, e, n, r) {
    var i = t.state !== void 0 ? t.state : null;
    t.updater = WX, t.props = n, t.state = i;
    var s = {
      queue: [],
      replace: false
    };
    t._reactInternals = s;
    var o = e.contextType;
    if (t.context = typeof o == "object" && o !== null ? o._currentValue : r, o = e.getDerivedStateFromProps, typeof o == "function" && (o = o(n, i), i = o == null ? i : yv({}, i, o), t.state = i), typeof e.getDerivedStateFromProps != "function" && typeof t.getSnapshotBeforeUpdate != "function" && (typeof t.UNSAFE_componentWillMount == "function" || typeof t.componentWillMount == "function"))
      if (e = t.state, typeof t.componentWillMount == "function" && t.componentWillMount(), typeof t.UNSAFE_componentWillMount == "function" && t.UNSAFE_componentWillMount(), e !== t.state && WX.enqueueReplaceState(t, t.state, null), s.queue !== null && 0 < s.queue.length)
        if (e = s.queue, o = s.replace, s.queue = null, s.replace = false, o && e.length === 1)
          t.state = e[0];
        else {
          for (s = o ? e[0] : t.state, i = true, o = o ? 1 : 0; o < e.length; o++) {
            var a = e[o];
            a = typeof a == "function" ? a.call(t, s, n, r) : a, a != null && (i ? (i = false, s = yv({}, s, a)) : yv(s, a));
          }
          t.state = s;
        }
      else
        s.queue = null;
  }
  var Pst = {
    id: 1,
    overflow: ""
  };
  function DD(t, e, n) {
    var r = t.id;
    t = t.overflow;
    var i = 32 - Ib(r) - 1;
    r &= ~(1 << i), n += 1;
    var s = 32 - Ib(e) + i;
    if (30 < s) {
      var o = i - i % 5;
      return s = (r & (1 << o) - 1).toString(32), r >>= o, i -= o, {
        id: 1 << 32 - Ib(e) + i | n << i | r,
        overflow: s + t
      };
    }
    return {
      id: 1 << s | n << i | r,
      overflow: t
    };
  }
  var Ib = Math.clz32 ? Math.clz32 : Tst, Cst = Math.log, _st = Math.LN2;
  function Tst(t) {
    return t >>>= 0, t === 0 ? 32 : 31 - (Cst(t) / _st | 0) | 0;
  }
  function Est(t, e) {
    return t === e && (t !== 0 || 1 / t === 1 / e) || t !== t && e !== e;
  }
  var Ist = typeof Object.is == "function" ? Object.is : Est, Jc = null, AN = null, $b = null, cn = null, R0 = false, zP = false, NO = 0, od = null, X2 = 0;
  function Th() {
    if (Jc === null)
      throw Error(mt(321));
    return Jc;
  }
  function HX() {
    if (0 < X2)
      throw Error(mt(312));
    return {
      memoizedState: null,
      queue: null,
      next: null
    };
  }
  function RN() {
    return cn === null ? $b === null ? (R0 = false, $b = cn = HX()) : (R0 = true, cn = $b) : cn.next === null ? (R0 = false, cn = cn.next = HX()) : (R0 = true, cn = cn.next), cn;
  }
  function MN() {
    AN = Jc = null, zP = false, $b = null, X2 = 0, cn = od = null;
  }
  function Que(t, e) {
    return typeof e == "function" ? e(t) : e;
  }
  function YX(t, e, n) {
    if (Jc = Th(), cn = RN(), R0) {
      var r = cn.queue;
      if (e = r.dispatch, od !== null && (n = od.get(r), n !== void 0)) {
        od.delete(r), r = cn.memoizedState;
        do
          r = t(r, n.action), n = n.next;
        while (n !== null);
        return cn.memoizedState = r, [
          r,
          e
        ];
      }
      return [
        cn.memoizedState,
        e
      ];
    }
    return t = t === Que ? typeof e == "function" ? e() : e : n !== void 0 ? n(e) : e, cn.memoizedState = t, t = cn.queue = {
      last: null,
      dispatch: null
    }, t = t.dispatch = $st.bind(null, Jc, t), [
      cn.memoizedState,
      t
    ];
  }
  function GX(t, e) {
    if (Jc = Th(), cn = RN(), e = e === void 0 ? null : e, cn !== null) {
      var n = cn.memoizedState;
      if (n !== null && e !== null) {
        var r = n[1];
        e:
          if (r === null)
            r = false;
          else {
            for (var i = 0; i < r.length && i < e.length; i++)
              if (!Ist(e[i], r[i])) {
                r = false;
                break e;
              }
            r = true;
          }
        if (r)
          return n[0];
      }
    }
    return t = t(), cn.memoizedState = [
      t,
      e
    ], t;
  }
  function $st(t, e, n) {
    if (25 <= X2)
      throw Error(mt(301));
    if (t === Jc)
      if (zP = true, t = {
        action: n,
        next: null
      }, od === null && (od = /* @__PURE__ */ new Map()), n = od.get(e), n === void 0)
        od.set(e, t);
      else {
        for (e = n; e.next !== null; )
          e = e.next;
        e.next = t;
      }
  }
  function Ast() {
    throw Error(mt(394));
  }
  function Cx() {
  }
  var qX = {
    readContext: function(t) {
      return t._currentValue;
    },
    useContext: function(t) {
      return Th(), t._currentValue;
    },
    useMemo: GX,
    useReducer: YX,
    useRef: function(t) {
      Jc = Th(), cn = RN();
      var e = cn.memoizedState;
      return e === null ? (t = {
        current: t
      }, cn.memoizedState = t) : e;
    },
    useState: function(t) {
      return YX(Que, t);
    },
    useInsertionEffect: Cx,
    useLayoutEffect: function() {
    },
    useCallback: function(t, e) {
      return GX(function() {
        return t;
      }, e);
    },
    useImperativeHandle: Cx,
    useEffect: Cx,
    useDebugValue: Cx,
    useDeferredValue: function(t) {
      return Th(), t;
    },
    useTransition: function() {
      return Th(), [
        false,
        Ast
      ];
    },
    useId: function() {
      var t = AN.treeContext, e = t.overflow;
      t = t.id, t = (t & ~(1 << 32 - Ib(t) - 1)).toString(32) + e;
      var n = Ab;
      if (n === null)
        throw Error(mt(404));
      return e = NO++, t = ":" + n.idPrefix + "R" + t, 0 < e && (t += "H" + e.toString(32)), t + ":";
    },
    useMutableSource: function(t, e) {
      return Th(), e(t._source);
    },
    useSyncExternalStore: function(t, e, n) {
      if (n === void 0)
        throw Error(mt(407));
      return n();
    }
  }, Ab = null, N$ = Oue.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;
  function Rst(t) {
    return console.error(t), null;
  }
  function M0() {
  }
  function Mst(t, e, n, r, i, s, o, a, l) {
    var c = [], u = /* @__PURE__ */ new Set();
    return e = {
      destination: null,
      responseState: e,
      progressiveChunkSize: r === void 0 ? 12800 : r,
      status: 0,
      fatalError: null,
      nextSegmentId: 0,
      allPendingTasks: 0,
      pendingRootTasks: 0,
      completedRootSegment: null,
      abortableTasks: u,
      pingedTasks: c,
      clientRenderedBoundaries: [],
      completedBoundaries: [],
      partialBoundaries: [],
      onError: i === void 0 ? Rst : i,
      onAllReady: s === void 0 ? M0 : s,
      onShellReady: o === void 0 ? M0 : o,
      onShellError: a === void 0 ? M0 : a,
      onFatalError: l === void 0 ? M0 : l
    }, n = FP(e, 0, null, n, false, false), n.parentFlushed = true, t = DN(e, t, null, n, u, Mue, null, Pst), c.push(t), e;
  }
  function DN(t, e, n, r, i, s, o, a) {
    t.allPendingTasks++, n === null ? t.pendingRootTasks++ : n.pendingTasks++;
    var l = {
      node: e,
      ping: function() {
        var c = t.pingedTasks;
        c.push(l), c.length === 1 && Bue(t);
      },
      blockedBoundary: n,
      blockedSegment: r,
      abortSet: i,
      legacyContext: s,
      context: o,
      treeContext: a
    };
    return i.add(l), l;
  }
  function FP(t, e, n, r, i, s) {
    return {
      status: 0,
      id: -1,
      index: e,
      parentFlushed: false,
      chunks: [],
      children: [],
      formatContext: r,
      boundary: n,
      lastPushedText: i,
      textEmbedded: s
    };
  }
  function QO(t, e) {
    if (t = t.onError(e), t != null && typeof t != "string")
      throw Error('onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' + typeof t + '" instead');
    return t;
  }
  function BP(t, e) {
    var n = t.onShellError;
    n(e), n = t.onFatalError, n(e), t.destination !== null ? (t.status = 2, wue(t.destination, e)) : (t.status = 1, t.fatalError = e);
  }
  function KX(t, e, n, r, i) {
    for (Jc = {}, AN = e, NO = 0, t = n(r, i); zP; )
      zP = false, NO = 0, X2 += 1, cn = null, t = n(r, i);
    return MN(), t;
  }
  function JX(t, e, n, r) {
    var i = n.render(), s = r.childContextTypes;
    if (s != null) {
      var o = e.legacyContext;
      if (typeof n.getChildContext != "function")
        r = o;
      else {
        n = n.getChildContext();
        for (var a in n)
          if (!(a in s))
            throw Error(mt(108, MD(r) || "Unknown", a));
        r = yv({}, o, n);
      }
      e.legacyContext = r, Hs(t, e, i), e.legacyContext = o;
    } else
      Hs(t, e, i);
  }
  function eW(t, e) {
    if (t && t.defaultProps) {
      e = yv({}, e), t = t.defaultProps;
      for (var n in t)
        e[n] === void 0 && (e[n] = t[n]);
      return e;
    }
    return e;
  }
  function LD(t, e, n, r, i) {
    if (typeof n == "function")
      if (n.prototype && n.prototype.isReactComponent) {
        i = XX(n, e.legacyContext);
        var s = n.contextType;
        s = new n(r, typeof s == "object" && s !== null ? s._currentValue : i), ZX(s, n, r, i), JX(t, e, s, n);
      } else {
        s = XX(n, e.legacyContext), i = KX(t, e, n, r, s);
        var o = NO !== 0;
        if (typeof i == "object" && i !== null && typeof i.render == "function" && i.$$typeof === void 0)
          ZX(i, n, r, s), JX(t, e, i, n);
        else if (o) {
          r = e.treeContext, e.treeContext = DD(r, 1, 0);
          try {
            Hs(t, e, i);
          } finally {
            e.treeContext = r;
          }
        } else
          Hs(t, e, i);
      }
    else if (typeof n == "string") {
      switch (i = e.blockedSegment, s = kit(i.chunks, n, r, t.responseState, i.formatContext), i.lastPushedText = false, o = i.formatContext, i.formatContext = vit(o, n, r), jD(t, e, s), i.formatContext = o, n) {
        case "area":
        case "base":
        case "br":
        case "col":
        case "embed":
        case "hr":
        case "img":
        case "input":
        case "keygen":
        case "link":
        case "meta":
        case "param":
        case "source":
        case "track":
        case "wbr":
          break;
        default:
          i.chunks.push(Pit, yt(n), Cit);
      }
      i.lastPushedText = false;
    } else {
      switch (n) {
        case bst:
        case xst:
        case Cue:
        case _ue:
        case Pue:
          Hs(t, e, r.children);
          return;
        case Aue:
          Hs(t, e, r.children);
          return;
        case wst:
          throw Error(mt(343));
        case $ue:
          e: {
            n = e.blockedBoundary, i = e.blockedSegment, s = r.fallback, r = r.children, o = /* @__PURE__ */ new Set();
            var a = {
              id: null,
              rootSegmentID: -1,
              parentFlushed: false,
              pendingTasks: 0,
              forceClientRender: false,
              completedSegments: [],
              byteSize: 0,
              fallbackAbortableTasks: o,
              errorDigest: null
            }, l = FP(t, i.chunks.length, a, i.formatContext, false, false);
            i.children.push(l), i.lastPushedText = false;
            var c = FP(t, 0, null, i.formatContext, false, false);
            c.parentFlushed = true, e.blockedBoundary = a, e.blockedSegment = c;
            try {
              if (jD(t, e, r), c.lastPushedText && c.textEmbedded && c.chunks.push(IN), c.status = 1, UP(a, c), a.pendingTasks === 0)
                break e;
            } catch (u) {
              c.status = 4, a.forceClientRender = true, a.errorDigest = QO(t, u);
            } finally {
              e.blockedBoundary = n, e.blockedSegment = i;
            }
            e = DN(t, s, n, l, o, e.legacyContext, e.context, e.treeContext), t.pingedTasks.push(e);
          }
          return;
      }
      if (typeof n == "object" && n !== null)
        switch (n.$$typeof) {
          case Iue:
            if (r = KX(t, e, n.render, r, i), NO !== 0) {
              n = e.treeContext, e.treeContext = DD(n, 1, 0);
              try {
                Hs(t, e, r);
              } finally {
                e.treeContext = n;
              }
            } else
              Hs(t, e, r);
            return;
          case Rue:
            n = n.type, r = eW(n, r), LD(t, e, n, r, i);
            return;
          case Tue:
            if (i = r.children, n = n._context, r = r.value, s = n._currentValue, n._currentValue = r, o = Qh, Qh = r = {
              parent: o,
              depth: o === null ? 0 : o.depth + 1,
              context: n,
              parentValue: s,
              value: r
            }, e.context = r, Hs(t, e, i), t = Qh, t === null)
              throw Error(mt(403));
            r = t.parentValue, t.context._currentValue = r === kst ? t.context._defaultValue : r, t = Qh = t.parent, e.context = t;
            return;
          case Eue:
            r = r.children, r = r(n._currentValue), Hs(t, e, r);
            return;
          case $N:
            i = n._init, n = i(n._payload), r = eW(n, r), LD(t, e, n, r, void 0);
            return;
        }
      throw Error(mt(130, n == null ? n : typeof n, ""));
    }
  }
  function Hs(t, e, n) {
    if (e.node = n, typeof n == "object" && n !== null) {
      switch (n.$$typeof) {
        case Sst:
          LD(t, e, n.type, n.props, n.ref);
          return;
        case kue:
          throw Error(mt(257));
        case $N:
          var r = n._init;
          n = r(n._payload), Hs(t, e, n);
          return;
      }
      if (RD(n)) {
        tW(t, e, n);
        return;
      }
      if (n === null || typeof n != "object" ? r = null : (r = VX && n[VX] || n["@@iterator"], r = typeof r == "function" ? r : null), r && (r = r.call(n))) {
        if (n = r.next(), !n.done) {
          var i = [];
          do
            i.push(n.value), n = r.next();
          while (!n.done);
          tW(t, e, i);
        }
        return;
      }
      throw t = Object.prototype.toString.call(n), Error(mt(31, t === "[object Object]" ? "object with keys {" + Object.keys(n).join(", ") + "}" : t));
    }
    typeof n == "string" ? (r = e.blockedSegment, r.lastPushedText = jX(e.blockedSegment.chunks, n, t.responseState, r.lastPushedText)) : typeof n == "number" && (r = e.blockedSegment, r.lastPushedText = jX(e.blockedSegment.chunks, "" + n, t.responseState, r.lastPushedText));
  }
  function tW(t, e, n) {
    for (var r = n.length, i = 0; i < r; i++) {
      var s = e.treeContext;
      e.treeContext = DD(s, r, i);
      try {
        jD(t, e, n[i]);
      } finally {
        e.treeContext = s;
      }
    }
  }
  function jD(t, e, n) {
    var r = e.blockedSegment.formatContext, i = e.legacyContext, s = e.context;
    try {
      return Hs(t, e, n);
    } catch (l) {
      if (MN(), typeof l == "object" && l !== null && typeof l.then == "function") {
        n = l;
        var o = e.blockedSegment, a = FP(t, o.chunks.length, null, o.formatContext, o.lastPushedText, true);
        o.children.push(a), o.lastPushedText = false, t = DN(t, e.node, e.blockedBoundary, a, e.abortSet, e.legacyContext, e.context, e.treeContext).ping, n.then(t, t), e.blockedSegment.formatContext = r, e.legacyContext = i, e.context = s, QP(s);
      } else
        throw e.blockedSegment.formatContext = r, e.legacyContext = i, e.context = s, QP(s), l;
    }
  }
  function Dst(t) {
    var e = t.blockedBoundary;
    t = t.blockedSegment, t.status = 3, Fue(this, e, t);
  }
  function zue(t, e, n) {
    var r = t.blockedBoundary;
    t.blockedSegment.status = 3, r === null ? (e.allPendingTasks--, e.status !== 2 && (e.status = 2, e.destination !== null && e.destination.close())) : (r.pendingTasks--, r.forceClientRender || (r.forceClientRender = true, t = n === void 0 ? Error(mt(432)) : n, r.errorDigest = e.onError(t), r.parentFlushed && e.clientRenderedBoundaries.push(r)), r.fallbackAbortableTasks.forEach(function(i) {
      return zue(i, e, n);
    }), r.fallbackAbortableTasks.clear(), e.allPendingTasks--, e.allPendingTasks === 0 && (r = e.onAllReady, r()));
  }
  function UP(t, e) {
    if (e.chunks.length === 0 && e.children.length === 1 && e.children[0].boundary === null) {
      var n = e.children[0];
      n.id = e.id, n.parentFlushed = true, n.status === 1 && UP(t, n);
    } else
      t.completedSegments.push(e);
  }
  function Fue(t, e, n) {
    if (e === null) {
      if (n.parentFlushed) {
        if (t.completedRootSegment !== null)
          throw Error(mt(389));
        t.completedRootSegment = n;
      }
      t.pendingRootTasks--, t.pendingRootTasks === 0 && (t.onShellError = M0, e = t.onShellReady, e());
    } else
      e.pendingTasks--, e.forceClientRender || (e.pendingTasks === 0 ? (n.parentFlushed && n.status === 1 && UP(e, n), e.parentFlushed && t.completedBoundaries.push(e), e.fallbackAbortableTasks.forEach(Dst, t), e.fallbackAbortableTasks.clear()) : n.parentFlushed && n.status === 1 && (UP(e, n), e.completedSegments.length === 1 && e.parentFlushed && t.partialBoundaries.push(e)));
    t.allPendingTasks--, t.allPendingTasks === 0 && (t = t.onAllReady, t());
  }
  function Bue(t) {
    if (t.status !== 2) {
      var e = Qh, n = N$.current;
      N$.current = qX;
      var r = Ab;
      Ab = t.responseState;
      try {
        var i = t.pingedTasks, s;
        for (s = 0; s < i.length; s++) {
          var o = i[s], a = t, l = o.blockedSegment;
          if (l.status === 0) {
            QP(o.context);
            try {
              Hs(a, o, o.node), l.lastPushedText && l.textEmbedded && l.chunks.push(IN), o.abortSet.delete(o), l.status = 1, Fue(a, o.blockedBoundary, l);
            } catch (y) {
              if (MN(), typeof y == "object" && y !== null && typeof y.then == "function") {
                var c = o.ping;
                y.then(c, c);
              } else {
                o.abortSet.delete(o), l.status = 4;
                var u = o.blockedBoundary, d = y, h = QO(a, d);
                if (u === null ? BP(a, d) : (u.pendingTasks--, u.forceClientRender || (u.forceClientRender = true, u.errorDigest = h, u.parentFlushed && a.clientRenderedBoundaries.push(u))), a.allPendingTasks--, a.allPendingTasks === 0) {
                  var f = a.onAllReady;
                  f();
                }
              }
            } finally {
            }
          }
        }
        i.splice(0, s), t.destination !== null && LN(t, t.destination);
      } catch (y) {
        QO(t, y), BP(t, y);
      } finally {
        Ab = r, N$.current = n, n === qX && QP(e);
      }
    }
  }
  function _x(t, e, n) {
    switch (n.parentFlushed = true, n.status) {
      case 0:
        var r = n.id = t.nextSegmentId++;
        return n.lastPushedText = false, n.textEmbedded = false, t = t.responseState, Ne(e, _it), Ne(e, t.placeholderPrefix), t = yt(r.toString(16)), Ne(e, t), Sn(e, Tit);
      case 1:
        n.status = 2;
        var i = true;
        r = n.chunks;
        var s = 0;
        n = n.children;
        for (var o = 0; o < n.length; o++) {
          for (i = n[o]; s < i.index; s++)
            Ne(e, r[s]);
          i = W2(t, e, i);
        }
        for (; s < r.length - 1; s++)
          Ne(e, r[s]);
        return s < r.length && (i = Sn(e, r[s])), i;
      default:
        throw Error(mt(390));
    }
  }
  function W2(t, e, n) {
    var r = n.boundary;
    if (r === null)
      return _x(t, e, n);
    if (r.parentFlushed = true, r.forceClientRender)
      r = r.errorDigest, Sn(e, Ait), Ne(e, Mit), r && (Ne(e, Lit), Ne(e, yt(Vr(r))), Ne(e, Dit)), Sn(e, jit), _x(t, e, n);
    else if (0 < r.pendingTasks) {
      r.rootSegmentID = t.nextSegmentId++, 0 < r.completedSegments.length && t.partialBoundaries.push(r);
      var i = t.responseState, s = i.nextSuspenseID++;
      i = Ce(i.boundaryPrefix + s.toString(16)), r = r.id = i, UX(e, t.responseState, r), _x(t, e, n);
    } else if (r.byteSize > t.progressiveChunkSize)
      r.rootSegmentID = t.nextSegmentId++, t.completedBoundaries.push(r), UX(e, t.responseState, r.id), _x(t, e, n);
    else {
      if (Sn(e, Eit), n = r.completedSegments, n.length !== 1)
        throw Error(mt(391));
      W2(t, e, n[0]);
    }
    return Sn(e, Rit);
  }
  function nW(t, e, n) {
    return sst(e, t.responseState, n.formatContext, n.id), W2(t, e, n), ost(e, n.formatContext);
  }
  function rW(t, e, n) {
    for (var r = n.completedSegments, i = 0; i < r.length; i++)
      Uue(t, e, n, r[i]);
    if (r.length = 0, t = t.responseState, r = n.id, n = n.rootSegmentID, Ne(e, t.startInlineScript), t.sentCompleteBoundaryFunction ? Ne(e, hst) : (t.sentCompleteBoundaryFunction = true, Ne(e, dst)), r === null)
      throw Error(mt(395));
    return n = yt(n.toString(16)), Ne(e, r), Ne(e, fst), Ne(e, t.segmentPrefix), Ne(e, n), Sn(e, pst);
  }
  function Uue(t, e, n, r) {
    if (r.status === 2)
      return true;
    var i = r.id;
    if (i === -1) {
      if ((r.id = n.rootSegmentID) === -1)
        throw Error(mt(392));
      return nW(t, e, r);
    }
    return nW(t, e, r), t = t.responseState, Ne(e, t.startInlineScript), t.sentCompleteSegmentFunction ? Ne(e, lst) : (t.sentCompleteSegmentFunction = true, Ne(e, ast)), Ne(e, t.segmentPrefix), i = yt(i.toString(16)), Ne(e, i), Ne(e, cst), Ne(e, t.placeholderPrefix), Ne(e, i), Sn(e, ust);
  }
  function LN(t, e) {
    Ws = new Uint8Array(512), Zs = 0;
    try {
      var n = t.completedRootSegment;
      if (n !== null && t.pendingRootTasks === 0) {
        W2(t, e, n), t.completedRootSegment = null;
        var r = t.responseState.bootstrapChunks;
        for (n = 0; n < r.length - 1; n++)
          Ne(e, r[n]);
        n < r.length && Sn(e, r[n]);
      }
      var i = t.clientRenderedBoundaries, s;
      for (s = 0; s < i.length; s++) {
        var o = i[s];
        r = e;
        var a = t.responseState, l = o.id, c = o.errorDigest, u = o.errorMessage, d = o.errorComponentStack;
        if (Ne(r, a.startInlineScript), a.sentClientRenderFunction ? Ne(r, mst) : (a.sentClientRenderFunction = true, Ne(r, gst)), l === null)
          throw Error(mt(395));
        Ne(r, l), Ne(r, yst), (c || u || d) && (Ne(r, L$), Ne(r, yt(j$(c || "")))), (u || d) && (Ne(r, L$), Ne(r, yt(j$(u || "")))), d && (Ne(r, L$), Ne(r, yt(j$(d)))), Sn(r, vst);
      }
      i.splice(0, s);
      var h = t.completedBoundaries;
      for (s = 0; s < h.length; s++)
        rW(t, e, h[s]);
      h.splice(0, s), RX(e), Ws = new Uint8Array(512), Zs = 0;
      var f = t.partialBoundaries;
      for (s = 0; s < f.length; s++) {
        var y = f[s];
        e: {
          i = t, o = e;
          var g = y.completedSegments;
          for (a = 0; a < g.length; a++)
            if (!Uue(i, o, y, g[a])) {
              a++, g.splice(0, a);
              var O = false;
              break e;
            }
          g.splice(0, a), O = true;
        }
        if (!O) {
          t.destination = null, s++, f.splice(0, s);
          return;
        }
      }
      f.splice(0, s);
      var S = t.completedBoundaries;
      for (s = 0; s < S.length; s++)
        rW(t, e, S[s]);
      S.splice(0, s);
    } finally {
      RX(e), t.allPendingTasks === 0 && t.pingedTasks.length === 0 && t.clientRenderedBoundaries.length === 0 && t.completedBoundaries.length === 0 && e.close();
    }
  }
  function iW(t, e) {
    try {
      var n = t.abortableTasks;
      n.forEach(function(r) {
        return zue(r, t, e);
      }), n.clear(), t.destination !== null && LN(t, t.destination);
    } catch (r) {
      QO(t, r), BP(t, r);
    }
  }
  _N.renderToReadableStream = function(t, e) {
    return new Promise(function(n, r) {
      var i, s, o = new Promise(function(u, d) {
        s = u, i = d;
      }), a = Mst(t, mit(e ? e.identifierPrefix : void 0, e ? e.nonce : void 0, e ? e.bootstrapScriptContent : void 0, e ? e.bootstrapScripts : void 0, e ? e.bootstrapModules : void 0), yit(e ? e.namespaceURI : void 0), e ? e.progressiveChunkSize : void 0, e ? e.onError : void 0, s, function() {
        var u = new ReadableStream({
          type: "bytes",
          pull: function(d) {
            if (a.status === 1)
              a.status = 2, wue(d, a.fatalError);
            else if (a.status !== 2 && a.destination === null) {
              a.destination = d;
              try {
                LN(a, d);
              } catch (h) {
                QO(a, h), BP(a, h);
              }
            }
          },
          cancel: function() {
            iW(a);
          }
        }, {
          highWaterMark: 0
        });
        u.allReady = o, n(u);
      }, function(u) {
        o.catch(function() {
        }), r(u);
      }, i);
      if (e && e.signal) {
        var l = e.signal, c = function() {
          iW(a, l.reason), l.removeEventListener("abort", c);
        };
        l.addEventListener("abort", c);
      }
      Bue(a);
    });
  };
  _N.version = "18.3.1";
  var Hm, Vue;
  Hm = Zm, Vue = _N;
  $f.version = Hm.version;
  $f.renderToString = Hm.renderToString;
  $f.renderToStaticMarkup = Hm.renderToStaticMarkup;
  $f.renderToNodeStream = Hm.renderToNodeStream;
  $f.renderToStaticNodeStream = Hm.renderToStaticNodeStream;
  $f.renderToReadableStream = Vue.renderToReadableStream;
  function Lst(t, e = navigator.language) {
    const n = typeof t == "number" ? t : t.getTime(), r = Math.round((n - Date.now()) / 1e3), i = [
      60,
      3600,
      86400,
      86400 * 7,
      86400 * 30,
      86400 * 365,
      1 / 0
    ], s = [
      "second",
      "minute",
      "hour",
      "day",
      "week",
      "month",
      "year"
    ], o = i.findIndex((c) => c > Math.abs(r)), a = o ? i[o - 1] : 1;
    return new Intl.RelativeTimeFormat(e, {
      numeric: "auto"
    }).format(Math.floor(r / a), s[o]);
  }
  const gh = (t) => {
    const n = t.comments.map((s) => 64 + Math.floor(s.content.length / 60) * 20).reduce((s, o) => s + o, 0);
    return 32 + 40 + n + 20;
  }, jst = (t, e) => Object.values(t.commentThreads ?? {}).filter((n) => !n.resolved).flatMap((n) => {
    let r = 0, i = 0;
    try {
      r = QQ(t, [
        "content"
      ], n.fromCursor), i = QQ(t, [
        "content"
      ], n.toCursor);
    } catch (s) {
      if (s instanceof RangeError)
        return [];
      throw s;
    }
    return [
      {
        ...n,
        from: r,
        to: i,
        active: n.id === e
      }
    ];
  }).filter((n) => n.to > n.from), Nst = ({ threads: t, doc: e, view: n, activeThreadId: r }) => {
    const i = t.flatMap((o) => {
      var _a3, _b3;
      const a = ((_a3 = n == null ? void 0 : n.scrollDOM.getBoundingClientRect()) == null ? void 0 : _a3.top) ?? 0, l = (_b3 = n == null ? void 0 : n.coordsAtPos(Math.min(o.from, e.content.length - 1))) == null ? void 0 : _b3.top;
      if (l === void 0)
        return [];
      const c = 40, u = -1 * a + l + c - 16;
      return [
        {
          ...o,
          yCoord: u
        }
      ];
    });
    i.sort((o, a) => o.from - a.from);
    let s = i.findIndex((o) => o.id === r);
    s === -1 && (s = 0);
    for (let o = s - 1; o >= 0; o--)
      i[o].yCoord + gh(i[o]) > i[o + 1].yCoord && (i[o].yCoord = i[o + 1].yCoord - gh(i[o]));
    for (let o = s + 1; o < i.length; o++)
      i[o].yCoord < i[o - 1].yCoord + gh(i[o - 1]) && (i[o].yCoord = i[o - 1].yCoord + gh(i[o - 1]));
    for (let o = 1; o < i.length; o++)
      i[o].yCoord < i[o - 1].yCoord + gh(i[o - 1]) && (i[o].id === r ? i[o - 1].yCoord = i[o].yCoord - gh(i[o - 1]) : i[o].yCoord = i[o - 1].yCoord + gh(i[o - 1]));
    return i;
  }, Qst = (t) => {
    const [e, n] = b.useState(0);
    return b.useEffect(() => {
      if (!t.current)
        return;
      const r = t.current, i = () => {
        n(r.scrollTop);
      };
      return r.addEventListener("scroll", () => i()), i(), () => r.removeEventListener("scroll", i);
    }, [
      t,
      t.current
    ]), e;
  }, zst = (t) => ({
    from: t.from,
    to: t.to - 1
  }), Fst = (t) => ({
    from: t.from,
    to: t.to + 1
  }), Bst = (t) => {
    const e = $f.renderToStaticMarkup(t), n = document.createElement("div");
    return n.innerHTML = e, n.firstElementChild;
  }, Ust = ({ doc: t, view: e, activeThreadId: n, editorRef: r }) => {
    const i = b.useMemo(() => t ? jst(t, n) : [], [
      t,
      n
    ]), s = Qst(r);
    return b.useMemo(() => e ? Nst({
      threads: i,
      doc: t,
      view: e,
      activeThreadId: n
    }) : [], [
      t,
      e,
      n,
      i,
      s
    ]);
  };
  class Vst extends Yl {
    constructor(e) {
      super(), this.headings = e;
    }
    toDOM() {
      return Bst(m.jsxs("div", {
        className: "font-sans bg-customGray py-1 px-8 mx-[-20px]",
        children: [
          m.jsx("h2", {
            children: "Contents"
          }),
          this.headings.map((e) => m.jsxs("div", {
            children: [
              m.jsx("h3", {
                children: e.content
              }),
              e.children.length > 0 && m.jsx("ul", {
                children: e.children.map((n) => m.jsx("li", {
                  children: n.content
                }, `${n.from}-${n.to}`))
              })
            ]
          }, `${e.from}-${e.to}`))
        ]
      }));
    }
    eq(e) {
      return ym.isEqual(e.headings, this.headings);
    }
    ignoreEvent() {
      return true;
    }
  }
  const Xst = /<!--endintro-->/;
  function sW(t) {
    const e = [];
    for (const { from: n, to: r } of t.visibleRanges) {
      const s = t.state.sliceDoc(n, r).match(Xst);
      if (s) {
        const o = s.index + n, a = UGe(t.state, t.state.doc.length), l = [], c = (h, f) => {
          let y = 0;
          switch (h.type.name) {
            case "ATXHeading1": {
              y = 1;
              break;
            }
            case "ATXHeading2": {
              y = 2;
              break;
            }
            case "ATXHeading3": {
              y = 3;
              break;
            }
            case "ATXHeading4": {
              y = 4;
              break;
            }
          }
          if (y !== 0) {
            const g = f + h.children[0].length, O = f + h.length, S = t.state.doc.sliceString(g, O);
            l.push({
              level: y,
              content: S,
              from: g,
              to: O
            });
          }
          h.positions.forEach((g, O) => {
            const S = h.children[O];
            S instanceof Fa && c(S, f + g);
          });
        };
        c(a, 0);
        const u = [];
        l.forEach((h) => {
          h.level === 2 ? u.push({
            level: "h2",
            content: h.content,
            children: [],
            from: h.from,
            to: h.to
          }) : h.level === 3 && u.length && u[u.length - 1].children.push({
            level: "h3",
            content: h.content,
            from: h.from,
            to: h.to
          });
        });
        const d = Qe.widget({
          widget: new Vst(u),
          side: 1
        }).range(o + s[0].length);
        e.push(d);
      }
    }
    return Qe.set(e.sort((n, r) => n.from - r.from));
  }
  const Wst = ur.fromClass(class {
    constructor(t) {
      __publicField(this, "decorations");
      this.decorations = sW(t);
    }
    update(t) {
      (t.docChanged || t.viewportChanged) && (this.decorations = sW(t.view));
    }
  }, {
    decorations: (t) => t.decorations
  }), Zst = {
    "&": {},
    "&.cm-editor.cm-focused": {
      outline: "none"
    },
    "&.cm-editor": {
      height: "100%"
    },
    ".cm-scroller": {
      height: "100%"
    },
    ".cm-gutters": {
      display: "none"
    },
    ".cm-content": {
      height: "100%",
      fontFamily: '"Merriweather", serif',
      padding: "10px 0",
      margin: "0 var(--cm-padding-x)",
      textWrap: "pretty",
      lineHeight: "24px"
    },
    ".cm-content li": {
      marginBottom: 0
    },
    ".cm-activeLine": {
      backgroundColor: "inherit"
    },
    ".cm-comment-thread": {
      backgroundColor: "rgb(255 249 194)"
    },
    ".cm-comment-thread.active": {
      backgroundColor: "rgb(255 227 135)"
    },
    ".cm-comment-thread.active .cm-comment-thread": {
      backgroundColor: "rgb(255 227 135)"
    },
    ".frontmatter": {
      fontFamily: "monospace",
      color: "#666",
      textDecoration: "none",
      fontWeight: "normal",
      lineHeight: "0.8em"
    }
  }, Hst = Re.theme(Zst), Tx = {
    fontFamily: '"Merriweather Sans", sans-serif',
    fontWeight: 400,
    textDecoration: "none"
  }, Oa = {
    fontFamily: "monospace",
    fontSize: "14px"
  }, Yst = _S.define([
    {
      tag: V.heading1,
      ...Tx,
      fontSize: "1.5rem",
      lineHeight: "2rem",
      marginBottom: "1rem",
      marginTop: "2rem"
    },
    {
      tag: V.heading2,
      ...Tx,
      fontSize: "1.5rem",
      lineHeight: "2rem",
      marginBottom: "1rem",
      marginTop: "2rem"
    },
    {
      tag: V.heading3,
      ...Tx,
      fontSize: "1.25rem",
      lineHeight: "1.75rem",
      marginBottom: "1rem",
      marginTop: "2rem"
    },
    {
      tag: V.heading4,
      ...Tx,
      fontSize: "1.1rem",
      marginBottom: "1rem",
      marginTop: "2rem"
    },
    {
      tag: V.comment,
      color: "#555",
      fontFamily: "monospace"
    },
    {
      tag: V.strong,
      fontWeight: "bold"
    },
    {
      tag: V.emphasis,
      fontStyle: "italic"
    },
    {
      tag: V.strikethrough,
      textDecoration: "line-through"
    },
    {
      tag: [
        V.meta
      ],
      fontWeight: 300,
      color: "#888",
      fontFamily: '"Merriweather Sans", sans-serif'
    },
    {
      tag: V.keyword,
      ...Oa,
      color: "#708"
    },
    {
      tag: [
        V.atom,
        V.bool,
        V.url,
        V.contentSeparator,
        V.labelName
      ],
      ...Oa,
      color: "#219"
    },
    {
      tag: [
        V.literal,
        V.inserted
      ],
      ...Oa,
      color: "#164"
    },
    {
      tag: [
        V.string,
        V.deleted
      ],
      ...Oa,
      color: "#5f67b5"
    },
    {
      tag: [
        V.regexp,
        V.escape,
        V.special(V.string)
      ],
      ...Oa,
      color: "#e40"
    },
    {
      tag: V.definition(V.variableName),
      ...Oa,
      color: "#00f"
    },
    {
      tag: V.local(V.variableName),
      ...Oa,
      color: "#30a"
    },
    {
      tag: [
        V.typeName,
        V.namespace
      ],
      ...Oa,
      color: "#085"
    },
    {
      tag: V.className,
      ...Oa,
      color: "#167"
    },
    {
      tag: [
        V.special(V.variableName),
        V.macroName
      ],
      ...Oa,
      color: "#256"
    },
    {
      tag: V.definition(V.propertyName),
      ...Oa,
      color: "#00c"
    }
  ]), Gst = ur.fromClass(class {
    constructor(t) {
      __publicField(this, "decorations");
      this.decorations = oW(t);
    }
    update(t) {
      (t.docChanged || t.viewportChanged) && (this.decorations = oW(t.view));
    }
  }, {
    decorations: (t) => t.decorations
  }), qst = /TODO|@Paul|@Geoffrey|@Alex/g;
  function oW(t) {
    const e = [];
    for (const { from: n, to: r } of t.visibleRanges) {
      const i = t.state.sliceDoc(n, r);
      let s;
      for (; s = qst.exec(i); ) {
        const o = s.index + n;
        e.push(Qe.mark({
          class: "bg-red-200 p-1 rounded-sm"
        }).range(o, o + s[0].length));
      }
    }
    return Qe.set(e.sort((n, r) => n.from - r.from));
  }
  const Kst = ur.fromClass(class {
    constructor(t) {
      __publicField(this, "decorations");
      this.decorations = aW(t);
    }
    update(t) {
      (t.docChanged || t.viewportChanged) && (this.decorations = aW(t.view));
    }
  }, {
    decorations: (t) => t.decorations
  }), Jst = /^---.*---/s;
  function aW(t) {
    const e = [];
    for (const { from: n, to: r } of t.visibleRanges) {
      const s = t.state.sliceDoc(n, r).match(Jst);
      if (s) {
        const o = s.index + n;
        e.push(Qe.mark({
          class: "frontmatter"
        }).range(o, o + s[0].length));
      }
    }
    return Qe.set(e.sort((n, r) => n.from - r.from));
  }
  const eot = /```.*?```/gs;
  function lW(t) {
    const e = [], r = t.state.doc.sliceString(0).matchAll(eot);
    for (const i of r) {
      const s = i.index;
      e.push(Qe.mark({
        class: "font-mono text-sm text-left inline-block"
      }).range(s, s + i[0].length));
    }
    return Qe.set(e.sort((i, s) => i.from - s.from));
  }
  const tot = ur.fromClass(class {
    constructor(t) {
      __publicField(this, "decorations");
      this.decorations = lW(t);
    }
    update(t) {
      (t.docChanged || t.viewportChanged) && (this.decorations = lW(t.view));
    }
  }, {
    decorations: (t) => t.decorations
  }), Xue = Dt.define(), VP = Hi.define({
    create() {
      return [];
    },
    update(t, e) {
      for (const n of e.effects)
        if (n.is(Xue))
          return n.value;
      return t;
    }
  }), not = Qe.mark({
    class: "cm-comment-thread"
  }), rot = Qe.mark({
    class: "cm-comment-thread active"
  }), iot = Re.decorations.compute([
    VP
  ], (t) => {
    var _a3;
    const e = t.field(VP), n = ((_a3 = ym.sortBy(e ?? [], (r) => r.from)) == null ? void 0 : _a3.flatMap((r) => {
      const i = Fst(r);
      return r.to > r.from ? r.active ? rot.range(i.from, i.to) : not.range(i.from, i.to) : [];
    })) ?? [];
    return Qe.set(n);
  }), sot = 4, oot = 48, aot = Hi.define({
    create() {
      return Qe.none;
    },
    update(t, e) {
      const n = e.state.tabSize, r = sot;
      if (!e.docChanged && t !== Qe.none)
        return t;
      const i = [];
      for (const s of ul.range(0, e.state.doc.lines)) {
        const o = e.state.doc.line(s + 1);
        if (o.length === 0)
          continue;
        let a = 0;
        for (const d of o.text)
          if (d === "	")
            a = a + n;
          else if (d === " ")
            a = a + 1;
          else
            break;
        const l = Math.min(a, oot) * r, c = document.createElement("span").style;
        c.setProperty("--idented", `${l}px`), c.setProperty("text-indent", "calc(-1 * var(--idented) - 1px)"), c.setProperty("padding-left", "calc(var(--idented) + var(--cm-left-padding, 4px))");
        const u = Qe.line({
          attributes: {
            style: c.cssText
          }
        });
        i.push(u.range(o.from, o.from));
      }
      return Qe.set(i, true);
    },
    provide: (t) => Re.decorations.from(t)
  }), lot = [
    aot
  ], cot = ({ createFileReference: t }) => {
    let e;
    const n = (s) => {
      e.state.selection, s.preventDefault(), s.dataTransfer.dropEffect = "copy";
    }, r = (s) => {
      s.preventDefault();
    }, i = (s) => {
      const o = s.dataTransfer.files;
      if (o.length > 0) {
        const a = o[0];
        t(a).then((l) => {
          if (l) {
            const c = e.posAtCoords({
              x: s.clientX,
              y: s.clientY
            });
            e.dispatch({
              changes: {
                from: c,
                insert: l
              }
            });
          }
        });
      }
      return true;
    };
    return ur.fromClass(class {
      constructor(s) {
        e = s, e.dom.addEventListener("dragenter", n), e.dom.addEventListener("dragover", r), e.dom.addEventListener("drop", i);
      }
      destroy() {
        e.dom.removeEventListener("dragenter", n), e.dom.removeEventListener("dragover", r), e.dom.removeEventListener("drop", i);
      }
    });
  };
  let uot = class extends Yl {
    constructor(e, n, r) {
      super(), this.heads = e, this.url = n, this.caption = r;
    }
    toDOM() {
      const e = document.createElement("div"), n = document.createElement("img");
      if (n.crossOrigin = "anonymous", n.src = this.url, n.className = "min-w-0", n.onerror = () => {
        n.style.opacity = "0";
      }, e.append(n), e.className = "w-fit border border-gray-200", this.caption.length > 0) {
        const r = document.createElement("div");
        r.append(document.createTextNode(this.caption)), r.className = "p-4 bg-gray-100 text-sm font-sans", e.append(r);
      }
      return e;
    }
    eq(e) {
      return e.url === this.url && e.caption === this.caption && hW(e.heads, this.heads);
    }
    ignoreEvent() {
      return true;
    }
  };
  const dot = /!\[(?<caption>.*?)\]\((?<url>.*?)\)/gs;
  function cW(t, e, n) {
    const r = [];
    for (const { from: i, to: s } of n.visibleRanges) {
      const o = n.state.sliceDoc(i, s);
      let a;
      for (; a = dot.exec(o); ) {
        const l = a.index + i, c = a.groups.url, u = a.groups.caption, d = new uot(t, e && c.startsWith("./assets") ? `https://automerge/${e}/files/${c.split("/")[2]}` : "", u), h = Qe.widget({
          widget: d,
          side: -1
        }).range(l);
        r.push(h), r.push(Qe.mark({
          class: "text-gray-500 font-mono text-left text-sm leading-snug inline-block opacity-70 mb-1"
        }).range(l, l + a[0].length));
      }
    }
    return Qe.set(r, true);
  }
  const Rb = Dt.define(), uW = Hi.define({
    create() {
      return [];
    },
    update(t, e) {
      for (const n of e.effects)
        if (n.is(Rb))
          return n.value;
      return t;
    }
  }), hot = (t, e) => [
    uW,
    ur.fromClass(class {
      constructor(n) {
        __publicField(this, "decorations", Qe.set([]));
        __publicField(this, "images", []);
        __publicField(this, "assetsDocHandle");
        if (this.view = n, this.decorations = cW([], void 0, n), this.onChangeDoc = this.onChangeDoc.bind(this), this.onRemoteHeadsChanged = this.onRemoteHeadsChanged.bind(this), t.isReady()) {
          const r = t.docSync().assetsDocUrl;
          this.onChangeAssetsDocUrl(r);
        }
        t.on("change", this.onChangeDoc);
      }
      onChangeDoc({ doc: n }) {
        this.assetsDocHandle && this.assetsDocHandle.url === n.assetsDocUrl || (this.assetsDocHandle && this.assetsDocHandle.off("remote-heads", this.onRemoteHeadsChanged), n.assetsDocUrl && this.onChangeAssetsDocUrl(n.assetsDocUrl));
      }
      onChangeAssetsDocUrl(n) {
        this.assetsDocHandle && this.assetsDocHandle.off("remote-heads", this.onRemoteHeadsChanged), n && (this.assetsDocHandle = e.find(n), this.assetsDocHandle.on("remote-heads", this.onRemoteHeadsChanged), this.assetsDocHandle.whenReady().then(() => {
          const r = _g(this.assetsDocHandle.docSync());
          this.view.dispatch({
            effects: Rb.of(r)
          });
        }));
      }
      async onRemoteHeadsChanged({ heads: n, storageId: r }) {
        await e.storageId() === r && this.view.dispatch({
          effects: Rb.of(n)
        });
      }
      update(n) {
        var _a3;
        if (n.docChanged || n.viewportChanged || n.transactions.some((r) => r.effects.some((i) => i.is(Rb)))) {
          const r = n.state.field(uW);
          this.decorations = cW(r, (_a3 = this.assetsDocHandle) == null ? void 0 : _a3.documentId, n.view);
        }
      }
    }, {
      decorations: (n) => n.decorations
    })
  ], Wue = Dt.define({
    map(t, e) {
      return t == null ? null : e.mapPos(t);
    }
  }), D0 = Hi.define({
    create() {
      return null;
    },
    update(t, e) {
      return t != null && (t = e.changes.mapPos(t)), e.effects.reduce((n, r) => r.is(Wue) ? r.value : n, t);
    }
  }), fot = ur.fromClass(class {
    constructor(t) {
      __publicField(this, "cursor", null);
      __publicField(this, "measureReq");
      this.view = t, this.measureReq = {
        read: this.readPos.bind(this),
        write: this.drawCursor.bind(this)
      }, this.onDragOver = this.onDragOver.bind(this), this.onDragLeave = this.onDragLeave.bind(this), this.onDragEnd = this.onDragEnd.bind(this), this.onDrop = this.onDrop.bind(this), t.dom.addEventListener("dragover", this.onDragOver), t.dom.addEventListener("dragenter", this.onDragLeave), t.dom.addEventListener("dragenter", this.onDragEnd), t.dom.addEventListener("drop", this.onDrop);
    }
    onDragOver(t) {
      this.setDropPos(this.view.posAtCoords({
        x: t.clientX,
        y: t.clientY
      }));
    }
    onDragLeave(t) {
      (t.target == this.view.contentDOM || !this.view.contentDOM.contains(t.relatedTarget)) && this.setDropPos(null);
    }
    onDragEnd(t) {
      this.setDropPos(null);
    }
    onDrop(t) {
      this.setDropPos(null);
    }
    update(t) {
      var _a3;
      let e = t.state.field(D0);
      e == null ? this.cursor != null && ((_a3 = this.cursor) == null ? void 0 : _a3.remove(), this.cursor = null) : (this.cursor || (this.cursor = this.view.scrollDOM.appendChild(document.createElement("div")), this.cursor.className = "cm-dropCursor"), (t.startState.field(D0) != e || t.docChanged || t.geometryChanged) && this.view.requestMeasure(this.measureReq));
    }
    readPos() {
      let { view: t } = this, e = t.state.field(D0), n = e != null && t.coordsAtPos(e);
      if (!n)
        return null;
      let r = t.scrollDOM.getBoundingClientRect();
      return {
        left: n.left - r.left + t.scrollDOM.scrollLeft * t.scaleX,
        top: n.top - r.top + t.scrollDOM.scrollTop * t.scaleY,
        height: n.bottom - n.top
      };
    }
    drawCursor(t) {
      if (this.cursor) {
        let { scaleX: e, scaleY: n } = this.view;
        t ? (this.cursor.style.left = t.left / e + "px", this.cursor.style.top = t.top / n + "px", this.cursor.style.height = t.height / n + "px") : this.cursor.style.left = "-100000px";
      }
    }
    destroy() {
      this.cursor && this.cursor.remove(), this.view.dom.removeEventListener("dragover", this.onDragOver), this.view.dom.removeEventListener("dragenter", this.onDragLeave), this.view.dom.removeEventListener("dragenter", this.onDragEnd), this.view.dom.removeEventListener("drop", this.onDrop);
    }
    setDropPos(t) {
      this.view.state.field(D0) != t && this.view.dispatch({
        effects: Wue.of(t)
      });
    }
  });
  function pot() {
    return [
      D0,
      fot
    ];
  }
  function got({ handle: t, path: e, setSelection: n, setView: r, setActiveThreadId: i, threadsWithPositions: s }) {
    const o = Xl(), a = b.useRef(null), l = b.useRef(null), [c, u] = b.useState(false), d = t.isReady();
    return b.useEffect(() => {
      var _a3;
      (_a3 = l.current) == null ? void 0 : _a3.dispatch({
        effects: Xue.of(s)
      });
    }, [
      s
    ]), b.useEffect(() => {
      if (!d)
        return;
      const f = t.docSync().content, y = new Re({
        doc: f,
        extensions: [
          Att(),
          pot(),
          cot({
            createFileReference: async (g) => {
              const O = t.docSync();
              let S;
              O.assetsDocUrl ? S = o.find(O.assetsDocUrl) : (S = o.create(), S.change((P) => {
                P.files = {};
              }), t.change((P) => {
                P.assetsDocUrl = S.url;
              })), await S.whenReady();
              const w = S.docSync();
              if (!yot(g)) {
                alert(`Only the following image files are supported:
.png, .jpg, .jpeg, .gif, .webp .bmp, .tiff, .tif`);
                return;
              }
              if (w.files[g.name]) {
                alert(`a file with the name "${g.name}" already exists in the document`);
                return;
              }
              return mot(g).then((P) => {
                S.change((C) => {
                  C.files[g.name] = {
                    contentType: g.type,
                    contents: P
                  };
                });
              }), `![](./assets/${g.name})`;
            }
          }),
          nqe(),
          E2.of([
            ...ynt,
            ...Dnt,
            ...Ftt,
            ...uqe,
            ...lrt,
            ...yrt,
            vnt
          ]),
          Re.lineWrapping,
          Hst,
          Ele({
            codeLanguages: Get
          }),
          Fm.of("    "),
          gqe(Yst),
          stt({
            handle: t,
            path: [
              "content"
            ]
          }),
          Kst,
          VP,
          iot,
          _rt,
          Gst,
          Wst,
          tot,
          lot,
          hot(t, o)
        ],
        dispatch(g, O) {
          var _a3;
          try {
            const S = g.newSelection.ranges[0];
            if (g.newSelection !== O.state.selection)
              for (const P of O.state.field(VP)) {
                if (P.from <= S.from && P.to >= S.to) {
                  i(P.id);
                  break;
                }
                i(null);
              }
            O.update([
              g
            ]);
            const w = O.state.selection.ranges[0], x = O.coordsAtPos(w.from);
            x && n({
              from: w.from,
              to: w.to,
              yCoord: -1 * O.scrollDOM.getBoundingClientRect().top + x.top
            });
          } catch (S) {
            console.error("Encountered an error in dispatch function; crashing the editor to notify the user and avoid data loss."), console.error(S), u(true), (_a3 = l.current) == null ? void 0 : _a3.destroy();
          }
        },
        parent: a.current
      });
      return l.current = y, r(y), y.focus(), () => {
        y.destroy();
      };
    }, [
      t,
      d
    ]), c ? m.jsxs("div", {
      className: "bg-red-100 p-4 rounded-md",
      children: [
        m.jsx("p", {
          className: "mb-2",
          children: "\u26D4\uFE0F Error: editor crashed!"
        }),
        false,
        m.jsx("p", {
          className: "mb-2",
          children: "We're sorry for the inconvenience. Please reload to keep working. Your data was most likely saved before the crash."
        }),
        m.jsx("p", {
          className: "mb-2",
          children: "If you'd like you can screenshot the dev console as a bug report."
        })
      ]
    }) : m.jsx("div", {
      className: "flex flex-col items-stretch min-h-screen",
      children: m.jsx("div", {
        className: "codemirror-editor flex-grow relative min-h-screen",
        ref: a,
        onKeyDown: (h) => {
          h.key === "s" && (h.metaKey || h.ctrlKey) || h.key === "\\" && (h.metaKey || h.ctrlKey) || h.stopPropagation();
        }
      })
    });
  }
  const mot = (t) => new Promise((e) => {
    const n = new FileReader();
    n.onload = function(r) {
      const i = r.target.result;
      e(new Uint8Array(i));
    }, n.readAsArrayBuffer(t);
  }), yot = (t) => {
    switch (t.type) {
      case "image/png":
      case "image/jpeg":
      case "image/gif":
      case "image/webp":
      case "image/bmp":
      case "image/tiff":
        return true;
      default:
        return false;
    }
  }, ND = b.forwardRef(({ className: t, ...e }, n) => m.jsx("textarea", {
    className: on("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", t),
    ref: n,
    ...e
  }));
  ND.displayName = "Textarea";
  const vot = ({ doc: t, changeDoc: e, selection: n, threadsWithPositions: r, activeThreadId: i, setActiveThreadId: s }) => {
    const o = BO(), [a, l] = b.useState(""), [c, u] = b.useState(false), [d, h] = b.useState(), [f, y] = b.useState(false), g = n && n.from !== n.to && !f;
    b.useEffect(() => {
      y(false);
    }, [
      n == null ? void 0 : n.from,
      n == null ? void 0 : n.to
    ]);
    const O = (w) => {
      if (!n)
        return;
      const x = zst(n), P = zQ(t, [
        "content"
      ], x.from), C = zQ(t, [
        "content"
      ], x.to), _ = {
        id: bT(),
        content: w,
        userId: null,
        contactUrl: o == null ? void 0 : o.contactHandle.url,
        timestamp: Date.now()
      }, T = {
        id: bT(),
        comments: [
          _
        ],
        resolved: false,
        fromCursor: P,
        toCursor: C
      };
      e(($) => {
        $.commentThreads[T.id] = T;
      }), l("");
    }, S = (w) => {
      const x = {
        id: bT(),
        content: a,
        contactUrl: o == null ? void 0 : o.contactHandle.url,
        timestamp: Date.now()
      };
      e((P) => {
        P.commentThreads[w].comments.push(x);
      }), l("");
    };
    return m.jsxs("div", {
      children: [
        r.map((w) => m.jsxs("div", {
          className: `bg-white hover:border-gray-400 hover:bg-gray-50 p-4 mr-2 absolute border border-gray-300 rounded-sm max-w-lg transition-all duration-100 ease-in-out ${w.id === i ? "z-50 shadow-sm border-gray-500" : "z-0"}`,
          style: {
            top: w.yCoord
          },
          onClick: (x) => {
            s(w.id), x.stopPropagation();
          },
          children: [
            m.jsx("div", {
              children: w.comments.map((x) => {
                var _a3, _b3;
                const P = ((_b3 = (_a3 = t.users) == null ? void 0 : _a3.find((C) => C.id === x.userId)) == null ? void 0 : _b3.name) ?? "Anonymous";
                return m.jsxs("div", {
                  className: "mb-3 pb-3  rounded-md border-b border-b-gray-200 last:border-b-0",
                  children: [
                    m.jsxs("div", {
                      className: "text-xs text-gray-600 mb-1 cursor-default flex items-center",
                      children: [
                        x.contactUrl ? m.jsx(k0, {
                          url: x.contactUrl,
                          showName: true,
                          size: "sm"
                        }) : P,
                        m.jsx("span", {
                          className: "ml-2 text-gray-400",
                          children: Lst(x.timestamp)
                        })
                      ]
                    }),
                    m.jsx("div", {
                      className: "cursor-default text-sm whitespace-pre-wrap mt-2",
                      children: x.content
                    })
                  ]
                }, x.id);
              })
            }),
            m.jsxs("div", {
              className: "mt-2",
              children: [
                m.jsxs(yg, {
                  open: d === w.id,
                  onOpenChange: (x) => h(x ? w.id : null),
                  children: [
                    m.jsx(vg, {
                      asChild: true,
                      children: m.jsxs(Ea, {
                        className: "mr-2",
                        variant: "outline",
                        children: [
                          m.jsx(F7e, {
                            className: "mr-2 "
                          }),
                          " Reply"
                        ]
                      })
                    }),
                    m.jsxs(Hh, {
                      children: [
                        m.jsx(ND, {
                          className: "mb-4",
                          value: a,
                          onChange: (x) => l(x.target.value),
                          onKeyDown: (x) => {
                            x.key === "Enter" && x.metaKey && (S(w.id), h(null), x.preventDefault());
                          }
                        }),
                        m.jsx(kB, {
                          children: m.jsxs(Ea, {
                            variant: "outline",
                            onClick: () => S(w.id),
                            children: [
                              "Comment",
                              m.jsx("span", {
                                className: "text-gray-400 ml-2 text-xs",
                                children: "\u2318\u23CE"
                              })
                            ]
                          })
                        })
                      ]
                    })
                  ]
                }),
                m.jsxs(Ea, {
                  variant: "outline",
                  onClick: () => e((x) => x.commentThreads[w.id].resolved = true),
                  children: [
                    m.jsx(zne, {
                      className: "mr-2"
                    }),
                    " Resolve"
                  ]
                })
              ]
            })
          ]
        }, w.id)),
        m.jsxs(yg, {
          open: c,
          onOpenChange: () => u((w) => !w),
          children: [
            m.jsx(vg, {
              asChild: true,
              children: g && m.jsxs(Ea, {
                className: "relative shadow-md w-44",
                variant: "outline",
                style: {
                  top: ((n == null ? void 0 : n.yCoord) ?? 0) + 23,
                  left: -50
                },
                children: [
                  m.jsx(N7e, {
                    size: 24,
                    className: "mr-2"
                  }),
                  "Add comment"
                ]
              })
            }),
            m.jsxs(Hh, {
              children: [
                m.jsx(ND, {
                  className: "mb-4",
                  value: a,
                  onChange: (w) => l(w.target.value),
                  onKeyDown: (w) => {
                    w.key === "Enter" && w.metaKey && (O(a), y(true), u(false), w.preventDefault());
                  }
                }),
                m.jsx(kB, {
                  children: m.jsxs(Ea, {
                    variant: "outline",
                    onClick: () => {
                      O(a), y(true);
                    },
                    children: [
                      "Comment",
                      m.jsx("span", {
                        className: "text-gray-400 ml-2 text-xs",
                        children: "\u2318\u23CE"
                      })
                    ]
                  })
                })
              ]
            })
          ]
        })
      ]
    });
  };
  const Oot = ({ docUrl: t }) => {
    const [e, n] = Ba(t), r = JP(t), [i, s] = b.useState(), [o, a] = b.useState(), [l, c] = b.useState(), u = b.useRef(null), d = Ust({
      doc: e,
      view: l,
      activeThreadId: o,
      editorRef: u
    });
    return e ? m.jsx("div", {
      className: "h-full overflow-auto",
      ref: u,
      children: m.jsxs("div", {
        className: "@container flex bg-gray-50 justify-center",
        children: [
          m.jsx("div", {
            className: "bg-white border border-gray-200 box-border rounded-md w-full @xl:w-4/5 @xl:mt-4 @xl:mr-2 @xl:mb-8 max-w-[722px]  @xl:ml-[-100px] @4xl:ml-[-200px] px-8 py-4 ",
            children: m.jsx(got, {
              handle: r,
              path: [
                "content"
              ],
              setSelection: s,
              setView: c,
              threadsWithPositions: d,
              setActiveThreadId: a
            })
          }),
          m.jsx("div", {
            className: "w-0",
            children: m.jsx(vot, {
              doc: e,
              changeDoc: n,
              selection: i,
              activeThreadId: o,
              setActiveThreadId: a,
              threadsWithPositions: d
            })
          })
        ]
      })
    }) : m.jsx(Uie, {
      docUrl: t,
      handle: r
    });
  };
  const Sot = ({ docUrl: t }) => {
    Ba(t);
    const e = JP(t), n = BO(), r = n ? n.contactHandle.url : "no-account", i = k7e({
      handle: e,
      userId: r
    });
    return m.jsx("div", {
      className: "tldraw__editor h-full overflow-auto",
      children: m.jsx(p7e, {
        autoFocus: true,
        store: i
      })
    });
  }, wot = ({ docUrl: t, selectedDocLink: e, selectDocLink: n }) => {
    const [r] = Ba(t);
    return r ? m.jsxs("div", {
      className: "p-2 h-full overflow-hidden",
      children: [
        m.jsxs("div", {
          className: "text-gray-500 text-sm mb-4 pb-2 border-b border-gray-300",
          children: [
            r.docs.length,
            " documents"
          ]
        }),
        m.jsx("div", {
          className: "flex flex-col gap-10 px-4 h-full overflow-y-auto pb-24",
          children: r.docs.map((i) => {
            var _a3;
            const s = (_a3 = Zue[i.type]) == null ? void 0 : _a3[0].component, o = ws[i.type].icon;
            return m.jsxs("div", {
              children: [
                m.jsxs("div", {
                  className: "flex gap-2 items-center font-medium mb-1",
                  children: [
                    m.jsx(o, {
                      size: 16
                    }),
                    m.jsx("div", {
                      children: i.name
                    }),
                    m.jsx("div", {
                      className: "text-sm text-gray-500 underline align-bottom cursor-pointer",
                      onClick: () => n({
                        ...i,
                        folderPath: [
                          ...e.folderPath,
                          t
                        ]
                      }),
                      children: "Open"
                    })
                  ]
                }),
                m.jsxs("div", {
                  className: "h-72 border border-gray-300",
                  children: [
                    !s && m.jsx("div", {
                      children: "No editor available"
                    }),
                    s && i.type !== "folder" && m.jsx(s, {
                      docUrl: i.url
                    }),
                    i.type === "folder" && m.jsx("div", {
                      className: "bg-gray-50 justify-center items-center flex h-full",
                      children: 'Click "open" to see nested folder contents'
                    })
                  ]
                })
              ]
            }, i.url);
          })
        })
      ]
    }) : null;
  }, Zue = {
    essay: [
      {
        id: "essay",
        name: "Editor",
        component: Oot
      }
    ],
    tldraw: [
      {
        id: "tldraw",
        name: "Drawing",
        component: Sot
      }
    ],
    folder: [
      {
        id: "folder",
        name: "Folder",
        component: wot
      }
    ]
  }, xot = () => {
    var _a3, _b3;
    const t = Xl(), e = BO(), [n] = e3(), r = _ve(), { doc: i, rootFolderUrl: s } = r, [o, a] = b.useState(true), { selectedDocLink: l, selectDocLink: c } = nHe({
      folderDocWithMetadata: r,
      repo: t
    }), u = l == null ? void 0 : l.url, d = JP(u), [h] = Ba(u), f = l == null ? void 0 : l.name, y = l == null ? void 0 : l.type, O = (_a3 = b.useMemo(() => {
      var _a4;
      return y ? (_a4 = Zue[y]) == null ? void 0 : _a4[0] : null;
    }, [
      y
    ])) == null ? void 0 : _a3.component, S = b.useCallback(({ type: x }) => {
      if (!ws[x])
        throw new Error(`Unsupported document type: ${x}`);
      const P = t.create();
      P.change(($) => ws[x].init($, t));
      let C, _;
      l ? l.type === "folder" ? (C = l.url, _ = [
        ...l.folderPath,
        l.url
      ]) : (C = l == null ? void 0 : l.folderPath[l.folderPath.length - 1], _ = l.folderPath) : (C = s, _ = [
        s
      ]);
      const T = {
        url: P.url,
        type: x,
        name: "Untitled document"
      };
      t.find(C).change(($) => $.docs.unshift(T)), c({
        ...T,
        folderPath: _
      });
    }, [
      t,
      l,
      c
    ]);
    rHe({
      selectedDocLink: l,
      selectedDocHandle: d,
      selectedDoc: h,
      selectDocLink: c,
      repo: t
    }), b.useEffect(() => {
      document.title = f ?? "Essay Editor";
    }, [
      f
    ]), b.useEffect(() => {
      const x = (P) => {
        P.key === "\\" && P.metaKey && a((C) => !C), !u && P.key === "Enter" && S({
          type: "essay"
        });
      };
      return window.addEventListener("keydown", x), () => {
        window.removeEventListener("keydown", x);
      };
    }, [
      S,
      u
    ]);
    const w = async (x) => {
      const P = t.find(x.folderPath[x.folderPath.length - 1]);
      await P.whenReady();
      const C = P.docSync().docs.findIndex((_) => _.url === x.url);
      C >= 0 && (C < P.docSync().docs.length - 1 ? c({
        ...P.docSync().docs[C + 1],
        folderPath: x.folderPath
      }) : C > 1 ? c({
        ...P.docSync().docs[C - 1],
        folderPath: x.folderPath
      }) : c(null), setTimeout(() => {
        P.change((_) => {
          _.docs.splice(C, 1);
        });
      }, 0));
    };
    return !n || !i ? m.jsx(Uie, {
      docUrl: (_b3 = e == null ? void 0 : e.handle) == null ? void 0 : _b3.url,
      handle: e == null ? void 0 : e.handle
    }) : m.jsx("div", {
      children: m.jsxs("div", {
        className: "flex flex-row w-screen h-screen overflow-hidden",
        children: [
          m.jsx("div", {
            className: `${o ? "w-64" : "w-0 translate-x-[-100%]"} flex-shrink-0 bg-gray-100 border-r border-gray-400 transition-all duration-100 overflow-hidden  `,
            children: m.jsx(lZe, {
              rootFolderDoc: r,
              selectedDocLink: l,
              selectDocLink: c,
              hideSidebar: () => a(false),
              addNewDocument: S
            })
          }),
          m.jsx("div", {
            className: `flex-grow relative h-screen ${u ? "" : "bg-gray-200"}`,
            children: m.jsxs("div", {
              className: "flex flex-col h-screen",
              children: [
                m.jsx(MZe, {
                  showSidebar: o,
                  setShowSidebar: a,
                  selectDocLink: c,
                  selectedDocLink: l,
                  selectedDoc: h,
                  selectedDocHandle: d,
                  removeDocLink: w,
                  addNewDocument: S
                }),
                m.jsxs("div", {
                  className: "flex-grow overflow-hidden z-0",
                  children: [
                    !u && m.jsx("div", {
                      className: "flex items-center justify-center h-full text-gray-500",
                      children: m.jsxs("div", {
                        children: [
                          m.jsx("p", {
                            className: "text-center cursor-default select-none mb-4",
                            children: "No document selected"
                          }),
                          m.jsxs(Ea, {
                            onClick: () => S({
                              type: "essay"
                            }),
                            variant: "outline",
                            children: [
                              "Create new document",
                              m.jsx("span", {
                                className: "ml-2",
                                children: "(\u23CE)"
                              })
                            ]
                          })
                        ]
                      })
                    }),
                    u && h && O && m.jsx(O, {
                      docUrl: u,
                      selectedDocLink: l,
                      selectDocLink: c
                    }, u),
                    !O && m.jsx("div", {
                      className: "flex items-center justify-center h-full bg-gray-100 text-gray-500 text-sm cursor-default",
                      children: "No editor available for this datatype"
                    })
                  ]
                })
              ]
            })
          })
        ]
      })
    });
  };
  function bot(t, e) {
    !e.docUrl && e.documentUrl && (e.docUrl = e.documentUrl), G$.createRoot(t).render($e.createElement(xW.Provider, {
      value: repo
    }, $e.createElement(xot, Object.assign({}, e))));
  }
  const jN = await kot();
  if (!jN)
    throw new Error("Failed to setup service worker");
  const NN = await Pot();
  Hue(jN);
  async function kot() {
    return navigator.serviceWorker.register("/service-worker.js", {
      type: "module"
    }).then((t) => t.installing ? new Promise((e) => {
      t.installing.onstatechange = (n) => {
        const r = n.target;
        r.state === "activated" && e(r);
      };
    }) : t.active);
  }
  async function Pot() {
    return await Lye, jye(Bye), new Nye({
      storage: new Qye(),
      network: [],
      peerId: "frontend-" + Math.round(Math.random() * 1e4),
      sharePolicy: async (e) => e.includes("service-worker"),
      enableRemoteHeadsGossiping: true
    });
  }
  navigator.serviceWorker.addEventListener("controllerchange", (t) => {
    const e = t.target.controller;
    e !== jN && Hue(e);
  });
  function Hue(t) {
    const e = new MessageChannel();
    NN.networkSubsystem.addNetworkAdapter(new zye(e.port1)), t.postMessage({
      type: "INIT_PORT"
    }, [
      e.port2
    ]), console.log("Connected to service worker");
  }
  let XP = "c4lliope";
  HW(NN).then((t) => {
    XP = t.contactHandle.url, t.on("change", () => {
      XP = t.contactHandle.url;
    });
  });
  const Cot = WP.prototype.change;
  WP.prototype.change = function(t, e = {}) {
    const n = {
      time: Date.now(),
      message: JSON.stringify({
        author: XP
      }),
      ...e
    };
    Cot.call(this, t, n);
  };
  const _ot = WP.prototype.changeAt;
  WP.prototype.changeAt = function(t, e, n = {}) {
    const r = {
      time: Date.now(),
      message: JSON.stringify({
        author: XP
      }),
      ...n
    };
    return _ot.call(this, t, e, r);
  };
  window.Automerge = Fye;
  window.repo = NN;
  bot(document.getElementById("root"), {});
});
export {
  $ae as C,
  po as E,
  dn as I,
  om as L,
  Loe as N,
  __tla,
  cm as a,
  dm as b,
  yb as c,
  Eqe as d,
  Tqe as e,
  Um as f,
  Un as g,
  eqe as h,
  Bm as i,
  JGe as j,
  Xoe as k,
  SP as l,
  is as m,
  Zae as n,
  Re as o,
  Ve as p,
  yle as q,
  joe as r,
  zm as s,
  V as t,
  vqe as u,
  qo as v
};
