import _e, { createContext as ir, useRef as je, useEffect as V, useMemo as S, useContext as ur, Component as Lr, createElement as rr, isValidElement as Ur, useState as H, useCallback as ne, memo as cr } from "react";
import { LazyActive as lr, useRefState as Kr, useEffectCallback as Ce } from "@easy-coder/sdk/helper";
import { useStateById as Te, useEnv as le, useRootId as fe, useActiveGlobalStyleVarGroup as de, SlotProvider as zr, useStore as Se, useElement as Gr, useSlotContext as Jr, isRefVariableDefine as qr, getValueByPath as Hr, parseEvent as Xr, getElementVariable as Zr, ElementProvider as Qr, useVariableDefine as fr, useVariableValue as dr, useGlobalClassName as et, useChangeModalVisible as rt, useGetModalContainer as tt, useVisibleModals as nt } from "@easy-coder/sdk/store";
import { StyleConvert as ae } from "@easy-coder/sdk/style";
import { executeEvent as Oe } from "@easy-coder/sdk/event";
import { isFxValue as vr, computedFormula as pr, computedCondition as at } from "@easy-coder/sdk/variable";
import ot from "react-dom";
function st(s) {
  return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
}
var Pe = { exports: {} }, re = {};
/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var tr;
function it() {
  if (tr)
    return re;
  tr = 1;
  var s = _e, t = Symbol.for("react.element"), o = Symbol.for("react.fragment"), u = Object.prototype.hasOwnProperty, f = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = {
    key: !0,
    ref: !0,
    __self: !0,
    __source: !0
  };
  function c(n, v, w) {
    var y, m = {}, x = null, b = null;
    w !== void 0 && (x = "" + w), v.key !== void 0 && (x = "" + v.key), v.ref !== void 0 && (b = v.ref);
    for (y in v)
      u.call(v, y) && !i.hasOwnProperty(y) && (m[y] = v[y]);
    if (n && n.defaultProps)
      for (y in v = n.defaultProps, v)
        m[y] === void 0 && (m[y] = v[y]);
    return {
      $$typeof: t,
      type: n,
      key: x,
      ref: b,
      props: m,
      _owner: f.current
    };
  }
  return re.Fragment = o, re.jsx = c, re.jsxs = c, re;
}
var te = {};
/**
 * @license React
 * react-jsx-runtime.development.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var nr;
function ut() {
  return nr || (nr = 1, process.env.NODE_ENV !== "production" && function() {
    var s = _e, t = Symbol.for("react.element"), o = Symbol.for("react.portal"), u = Symbol.for("react.fragment"), f = Symbol.for("react.strict_mode"), i = Symbol.for("react.profiler"), c = Symbol.for("react.provider"), n = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), y = Symbol.for("react.suspense_list"), m = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), I = Symbol.iterator, k = "@@iterator";
    function K(e) {
      if (e === null || typeof e != "object")
        return null;
      var r = I && e[I] || e[k];
      return typeof r == "function" ? r : null;
    }
    var B = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
    function E(e) {
      {
        for (var r = arguments.length, a = new Array(r > 1 ? r - 1 : 0), l = 1; l < r; l++)
          a[l - 1] = arguments[l];
        z("error", e, a);
      }
    }
    function z(e, r, a) {
      {
        var l = B.ReactDebugCurrentFrame, g = l.getStackAddendum();
        g !== "" && (r += "%s", a = a.concat([g]));
        var R = a.map(function(h) {
          return String(h);
        });
        R.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, R);
      }
    }
    var G = !1, F = !1, Y = !1, W = !1, P = !1, _;
    _ = Symbol.for("react.module.reference");
    function O(e) {
      return !!(typeof e == "string" || typeof e == "function" || e === u || e === i || P || e === f || e === w || e === y || W || e === b || G || F || Y || typeof e == "object" && e !== null && (e.$$typeof === x || e.$$typeof === m || e.$$typeof === c || e.$$typeof === n || e.$$typeof === v || // This needs to include all possible module reference object
      // types supported by any Flight configuration anywhere since
      // we don't know which Flight build this will end up being used
      // with.
      e.$$typeof === _ || e.getModuleId !== void 0));
    }
    function A(e, r, a) {
      var l = e.displayName;
      if (l)
        return l;
      var g = r.displayName || r.name || "";
      return g !== "" ? a + "(" + g + ")" : a;
    }
    function D(e) {
      return e.displayName || "Context";
    }
    function T(e) {
      if (e == null)
        return null;
      if (typeof e.tag == "number" && E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
        return e.displayName || e.name || null;
      if (typeof e == "string")
        return e;
      switch (e) {
        case u:
          return "Fragment";
        case o:
          return "Portal";
        case i:
          return "Profiler";
        case f:
          return "StrictMode";
        case w:
          return "Suspense";
        case y:
          return "SuspenseList";
      }
      if (typeof e == "object")
        switch (e.$$typeof) {
          case n:
            var r = e;
            return D(r) + ".Consumer";
          case c:
            var a = e;
            return D(a._context) + ".Provider";
          case v:
            return A(e, e.render, "ForwardRef");
          case m:
            var l = e.displayName || null;
            return l !== null ? l : T(e.type) || "Memo";
          case x: {
            var g = e, R = g._payload, h = g._init;
            try {
              return T(h(R));
            } catch {
              return null;
            }
          }
        }
      return null;
    }
    var L = Object.assign, M = 0, oe, Ie, Fe, Ne, Me, $e, Ve;
    function We() {
    }
    We.__reactDisabledLog = !0;
    function mr() {
      {
        if (M === 0) {
          oe = console.log, Ie = console.info, Fe = console.warn, Ne = console.error, Me = console.group, $e = console.groupCollapsed, Ve = console.groupEnd;
          var e = {
            configurable: !0,
            enumerable: !0,
            value: We,
            writable: !0
          };
          Object.defineProperties(console, {
            info: e,
            log: e,
            warn: e,
            error: e,
            group: e,
            groupCollapsed: e,
            groupEnd: e
          });
        }
        M++;
      }
    }
    function gr() {
      {
        if (M--, M === 0) {
          var e = {
            configurable: !0,
            enumerable: !0,
            writable: !0
          };
          Object.defineProperties(console, {
            log: L({}, e, {
              value: oe
            }),
            info: L({}, e, {
              value: Ie
            }),
            warn: L({}, e, {
              value: Fe
            }),
            error: L({}, e, {
              value: Ne
            }),
            group: L({}, e, {
              value: Me
            }),
            groupCollapsed: L({}, e, {
              value: $e
            }),
            groupEnd: L({}, e, {
              value: Ve
            })
          });
        }
        M < 0 && E("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
      }
    }
    var pe = B.ReactCurrentDispatcher, he;
    function se(e, r, a) {
      {
        if (he === void 0)
          try {
            throw Error();
          } catch (g) {
            var l = g.stack.trim().match(/\n( *(at )?)/);
            he = l && l[1] || "";
          }
        return `
` + he + e;
      }
    }
    var me = !1, ie;
    {
      var yr = typeof WeakMap == "function" ? WeakMap : Map;
      ie = new yr();
    }
    function Be(e, r) {
      if (!e || me)
        return "";
      {
        var a = ie.get(e);
        if (a !== void 0)
          return a;
      }
      var l;
      me = !0;
      var g = Error.prepareStackTrace;
      Error.prepareStackTrace = void 0;
      var R;
      R = pe.current, pe.current = null, mr();
      try {
        if (r) {
          var h = function() {
            throw Error();
          };
          if (Object.defineProperty(h.prototype, "props", {
            set: function() {
              throw Error();
            }
          }), typeof Reflect == "object" && Reflect.construct) {
            try {
              Reflect.construct(h, []);
            } catch ($) {
              l = $;
            }
            Reflect.construct(e, [], h);
          } else {
            try {
              h.call();
            } catch ($) {
              l = $;
            }
            e.call(h.prototype);
          }
        } else {
          try {
            throw Error();
          } catch ($) {
            l = $;
          }
          e();
        }
      } catch ($) {
        if ($ && l && typeof $.stack == "string") {
          for (var p = $.stack.split(`
`), N = l.stack.split(`
`), j = p.length - 1, C = N.length - 1; j >= 1 && C >= 0 && p[j] !== N[C]; )
            C--;
          for (; j >= 1 && C >= 0; j--, C--)
            if (p[j] !== N[C]) {
              if (j !== 1 || C !== 1)
                do
                  if (j--, C--, C < 0 || p[j] !== N[C]) {
                    var U = `
` + p[j].replace(" at new ", " at ");
                    return e.displayName && U.includes("<anonymous>") && (U = U.replace("<anonymous>", e.displayName)), typeof e == "function" && ie.set(e, U), U;
                  }
                while (j >= 1 && C >= 0);
              break;
            }
        }
      } finally {
        me = !1, pe.current = R, gr(), Error.prepareStackTrace = g;
      }
      var Z = e ? e.displayName || e.name : "", q = Z ? se(Z) : "";
      return typeof e == "function" && ie.set(e, q), q;
    }
    function br(e, r, a) {
      return Be(e, !1);
    }
    function Rr(e) {
      var r = e.prototype;
      return !!(r && r.isReactComponent);
    }
    function ue(e, r, a) {
      if (e == null)
        return "";
      if (typeof e == "function")
        return Be(e, Rr(e));
      if (typeof e == "string")
        return se(e);
      switch (e) {
        case w:
          return se("Suspense");
        case y:
          return se("SuspenseList");
      }
      if (typeof e == "object")
        switch (e.$$typeof) {
          case v:
            return br(e.render);
          case m:
            return ue(e.type, r, a);
          case x: {
            var l = e, g = l._payload, R = l._init;
            try {
              return ue(R(g), r, a);
            } catch {
            }
          }
        }
      return "";
    }
    var Q = Object.prototype.hasOwnProperty, Ye = {}, Le = B.ReactDebugCurrentFrame;
    function ce(e) {
      if (e) {
        var r = e._owner, a = ue(e.type, e._source, r ? r.type : null);
        Le.setExtraStackFrame(a);
      } else
        Le.setExtraStackFrame(null);
    }
    function Er(e, r, a, l, g) {
      {
        var R = Function.call.bind(Q);
        for (var h in e)
          if (R(e, h)) {
            var p = void 0;
            try {
              if (typeof e[h] != "function") {
                var N = Error((l || "React class") + ": " + a + " type `" + h + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[h] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
                throw N.name = "Invariant Violation", N;
              }
              p = e[h](r, h, l, a, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
            } catch (j) {
              p = j;
            }
            p && !(p instanceof Error) && (ce(g), E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", l || "React class", a, h, typeof p), ce(null)), p instanceof Error && !(p.message in Ye) && (Ye[p.message] = !0, ce(g), E("Failed %s type: %s", a, p.message), ce(null));
          }
      }
    }
    var xr = Array.isArray;
    function ge(e) {
      return xr(e);
    }
    function wr(e) {
      {
        var r = typeof Symbol == "function" && Symbol.toStringTag, a = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
        return a;
      }
    }
    function Pr(e) {
      try {
        return Ue(e), !1;
      } catch {
        return !0;
      }
    }
    function Ue(e) {
      return "" + e;
    }
    function Ke(e) {
      if (Pr(e))
        return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", wr(e)), Ue(e);
    }
    var ee = B.ReactCurrentOwner, _r = {
      key: !0,
      ref: !0,
      __self: !0,
      __source: !0
    }, ze, Ge, ye;
    ye = {};
    function jr(e) {
      if (Q.call(e, "ref")) {
        var r = Object.getOwnPropertyDescriptor(e, "ref").get;
        if (r && r.isReactWarning)
          return !1;
      }
      return e.ref !== void 0;
    }
    function Cr(e) {
      if (Q.call(e, "key")) {
        var r = Object.getOwnPropertyDescriptor(e, "key").get;
        if (r && r.isReactWarning)
          return !1;
      }
      return e.key !== void 0;
    }
    function Tr(e, r) {
      if (typeof e.ref == "string" && ee.current && r && ee.current.stateNode !== r) {
        var a = T(ee.current.type);
        ye[a] || (E('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', T(ee.current.type), e.ref), ye[a] = !0);
      }
    }
    function Sr(e, r) {
      {
        var a = function() {
          ze || (ze = !0, E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
        };
        a.isReactWarning = !0, Object.defineProperty(e, "key", {
          get: a,
          configurable: !0
        });
      }
    }
    function Or(e, r) {
      {
        var a = function() {
          Ge || (Ge = !0, E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
        };
        a.isReactWarning = !0, Object.defineProperty(e, "ref", {
          get: a,
          configurable: !0
        });
      }
    }
    var kr = function(e, r, a, l, g, R, h) {
      var p = {
        // This tag allows us to uniquely identify this as a React Element
        $$typeof: t,
        // Built-in properties that belong on the element
        type: e,
        key: r,
        ref: a,
        props: h,
        // Record the component responsible for creating this element.
        _owner: R
      };
      return p._store = {}, Object.defineProperty(p._store, "validated", {
        configurable: !1,
        enumerable: !1,
        writable: !0,
        value: !1
      }), Object.defineProperty(p, "_self", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: l
      }), Object.defineProperty(p, "_source", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: g
      }), Object.freeze && (Object.freeze(p.props), Object.freeze(p)), p;
    };
    function Ar(e, r, a, l, g) {
      {
        var R, h = {}, p = null, N = null;
        a !== void 0 && (Ke(a), p = "" + a), Cr(r) && (Ke(r.key), p = "" + r.key), jr(r) && (N = r.ref, Tr(r, g));
        for (R in r)
          Q.call(r, R) && !_r.hasOwnProperty(R) && (h[R] = r[R]);
        if (e && e.defaultProps) {
          var j = e.defaultProps;
          for (R in j)
            h[R] === void 0 && (h[R] = j[R]);
        }
        if (p || N) {
          var C = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
          p && Sr(h, C), N && Or(h, C);
        }
        return kr(e, p, N, g, l, ee.current, h);
      }
    }
    var be = B.ReactCurrentOwner, Je = B.ReactDebugCurrentFrame;
    function X(e) {
      if (e) {
        var r = e._owner, a = ue(e.type, e._source, r ? r.type : null);
        Je.setExtraStackFrame(a);
      } else
        Je.setExtraStackFrame(null);
    }
    var Re;
    Re = !1;
    function Ee(e) {
      return typeof e == "object" && e !== null && e.$$typeof === t;
    }
    function qe() {
      {
        if (be.current) {
          var e = T(be.current.type);
          if (e)
            return `

Check the render method of \`` + e + "`.";
        }
        return "";
      }
    }
    function Dr(e) {
      {
        if (e !== void 0) {
          var r = e.fileName.replace(/^.*[\\\/]/, ""), a = e.lineNumber;
          return `

Check your code at ` + r + ":" + a + ".";
        }
        return "";
      }
    }
    var He = {};
    function Ir(e) {
      {
        var r = qe();
        if (!r) {
          var a = typeof e == "string" ? e : e.displayName || e.name;
          a && (r = `

Check the top-level render call using <` + a + ">.");
        }
        return r;
      }
    }
    function Xe(e, r) {
      {
        if (!e._store || e._store.validated || e.key != null)
          return;
        e._store.validated = !0;
        var a = Ir(r);
        if (He[a])
          return;
        He[a] = !0;
        var l = "";
        e && e._owner && e._owner !== be.current && (l = " It was passed a child from " + T(e._owner.type) + "."), X(e), E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', a, l), X(null);
      }
    }
    function Ze(e, r) {
      {
        if (typeof e != "object")
          return;
        if (ge(e))
          for (var a = 0; a < e.length; a++) {
            var l = e[a];
            Ee(l) && Xe(l, r);
          }
        else if (Ee(e))
          e._store && (e._store.validated = !0);
        else if (e) {
          var g = K(e);
          if (typeof g == "function" && g !== e.entries)
            for (var R = g.call(e), h; !(h = R.next()).done; )
              Ee(h.value) && Xe(h.value, r);
        }
      }
    }
    function Fr(e) {
      {
        var r = e.type;
        if (r == null || typeof r == "string")
          return;
        var a;
        if (typeof r == "function")
          a = r.propTypes;
        else if (typeof r == "object" && (r.$$typeof === v || // Note: Memo only checks outer props here.
        // Inner props are checked in the reconciler.
        r.$$typeof === m))
          a = r.propTypes;
        else
          return;
        if (a) {
          var l = T(r);
          Er(a, e.props, "prop", l, e);
        } else if (r.PropTypes !== void 0 && !Re) {
          Re = !0;
          var g = T(r);
          E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", g || "Unknown");
        }
        typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
      }
    }
    function Nr(e) {
      {
        for (var r = Object.keys(e.props), a = 0; a < r.length; a++) {
          var l = r[a];
          if (l !== "children" && l !== "key") {
            X(e), E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", l), X(null);
            break;
          }
        }
        e.ref !== null && (X(e), E("Invalid attribute `ref` supplied to `React.Fragment`."), X(null));
      }
    }
    var Qe = {};
    function er(e, r, a, l, g, R) {
      {
        var h = O(e);
        if (!h) {
          var p = "";
          (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (p += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
          var N = Dr(g);
          N ? p += N : p += qe();
          var j;
          e === null ? j = "null" : ge(e) ? j = "array" : e !== void 0 && e.$$typeof === t ? (j = "<" + (T(e.type) || "Unknown") + " />", p = " Did you accidentally export a JSX literal instead of a component?") : j = typeof e, E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", j, p);
        }
        var C = Ar(e, r, a, g, R);
        if (C == null)
          return C;
        if (h) {
          var U = r.children;
          if (U !== void 0)
            if (l)
              if (ge(U)) {
                for (var Z = 0; Z < U.length; Z++)
                  Ze(U[Z], e);
                Object.freeze && Object.freeze(U);
              } else
                E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
            else
              Ze(U, e);
        }
        if (Q.call(r, "key")) {
          var q = T(e), $ = Object.keys(r).filter(function(Yr) {
            return Yr !== "key";
          }), xe = $.length > 0 ? "{key: someKey, " + $.join(": ..., ") + ": ...}" : "{key: someKey}";
          if (!Qe[q + xe]) {
            var Br = $.length > 0 ? "{" + $.join(": ..., ") + ": ...}" : "{}";
            E(`A props object containing a "key" prop is being spread into JSX:
  let props = %s;
  <%s {...props} />
React keys must be passed directly to JSX without using spread:
  let props = %s;
  <%s key={someKey} {...props} />`, xe, q, Br, q), Qe[q + xe] = !0;
          }
        }
        return e === u ? Nr(C) : Fr(C), C;
      }
    }
    function Mr(e, r, a) {
      return er(e, r, a, !0);
    }
    function $r(e, r, a) {
      return er(e, r, a, !1);
    }
    var Vr = $r, Wr = Mr;
    te.Fragment = u, te.jsx = Vr, te.jsxs = Wr;
  }()), te;
}
process.env.NODE_ENV === "production" ? Pe.exports = it() : Pe.exports = ut();
var d = Pe.exports;
const ke = ir({
  extra: new lr([])
});
function ct({
  children: s,
  extra: t
}) {
  const o = je(new lr([]));
  V(() => {
    o.current.updateValue(t || []);
  }, [t]);
  const u = S(() => ({
    extra: o.current
  }), []);
  return /* @__PURE__ */ d.jsx(ke.Provider, {
    value: u,
    children: s
  });
}
function It() {
  return ur(ke);
}
function ve(s, t) {
  const {
    extra: o
  } = ur(ke), [u, f, i] = Kr(ar(o.getValue(), s, t));
  return V(() => o.addChangeListener(() => {
    const c = ar(o.getValue(), s, t);
    c !== f.current && i(c);
  }), [s, t]), u;
}
function ar(s, t, o) {
  return s == null ? void 0 : s.find((u) => u.type === t && u.id === o);
}
var hr = { exports: {} };
/*!
	Copyright (c) 2018 Jed Watson.
	Licensed under the MIT License (MIT), see
	http://jedwatson.github.io/classnames
*/
(function(s) {
  (function() {
    var t = {}.hasOwnProperty;
    function o() {
      for (var i = "", c = 0; c < arguments.length; c++) {
        var n = arguments[c];
        n && (i = f(i, u(n)));
      }
      return i;
    }
    function u(i) {
      if (typeof i == "string" || typeof i == "number")
        return i;
      if (typeof i != "object")
        return "";
      if (Array.isArray(i))
        return o.apply(null, i);
      if (i.toString !== Object.prototype.toString && !i.toString.toString().includes("[native code]"))
        return i.toString();
      var c = "";
      for (var n in i)
        t.call(i, n) && i[n] && (c = f(c, n));
      return c;
    }
    function f(i, c) {
      return c ? i ? i + " " + c : i + c : i;
    }
    s.exports ? (o.default = o, s.exports = o) : window.classNames = o;
  })();
})(hr);
var lt = hr.exports;
const J = /* @__PURE__ */ st(lt), ft = ir(null), we = {
  didCatch: !1,
  error: null
};
class dt extends Lr {
  constructor(t) {
    super(t), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = we;
  }
  static getDerivedStateFromError(t) {
    return {
      didCatch: !0,
      error: t
    };
  }
  resetErrorBoundary() {
    const {
      error: t
    } = this.state;
    if (t !== null) {
      for (var o, u, f = arguments.length, i = new Array(f), c = 0; c < f; c++)
        i[c] = arguments[c];
      (o = (u = this.props).onReset) === null || o === void 0 || o.call(u, {
        args: i,
        reason: "imperative-api"
      }), this.setState(we);
    }
  }
  componentDidCatch(t, o) {
    var u, f;
    (u = (f = this.props).onError) === null || u === void 0 || u.call(f, t, o);
  }
  componentDidUpdate(t, o) {
    const {
      didCatch: u
    } = this.state, {
      resetKeys: f
    } = this.props;
    if (u && o.error !== null && vt(t.resetKeys, f)) {
      var i, c;
      (i = (c = this.props).onReset) === null || i === void 0 || i.call(c, {
        next: f,
        prev: t.resetKeys,
        reason: "keys"
      }), this.setState(we);
    }
  }
  render() {
    const {
      children: t,
      fallbackRender: o,
      FallbackComponent: u,
      fallback: f
    } = this.props, {
      didCatch: i,
      error: c
    } = this.state;
    let n = t;
    if (i) {
      const v = {
        error: c,
        resetErrorBoundary: this.resetErrorBoundary
      };
      if (typeof o == "function")
        n = o(v);
      else if (u)
        n = rr(u, v);
      else if (f === null || Ur(f))
        n = f;
      else
        throw c;
    }
    return rr(ft.Provider, {
      value: {
        didCatch: i,
        error: c,
        resetErrorBoundary: this.resetErrorBoundary
      }
    }, n);
  }
}
function vt() {
  let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
  return s.length !== t.length || s.some((o, u) => !Object.is(o, t[u]));
}
const Ae = "data-edit-id", pt = "data-element-id", Ft = "data-slot-order";
function ht({
  id: s,
  payload: t
}) {
  const o = Te("editor", s), u = le(), f = fe(), i = ve("editor", s), c = de(), n = S(() => new ae().toString(o.style, c == null ? void 0 : c.vars), [o.style, c == null ? void 0 : c.vars]), v = S(() => {
    var m;
    return (m = o.classNames) == null ? void 0 : m.map((x) => `${f}${x}`);
  }, [o.classNames, f]), w = S(() => o.elements.map((m) => /* @__PURE__ */ d.jsx(De, {
    id: m
  }, m)), [o.elements]), y = S(() => {
    if (u.isPreviewing)
      return {
        [Ae]: s
      };
  }, [s, u.isPreviewing]);
  return !u.isPreviewing && !o.elements.length ? null : /* @__PURE__ */ d.jsx("div", {
    ...y,
    className: J("easy-coder-slot", v),
    style: n,
    children: /* @__PURE__ */ d.jsxs(zr, {
      id: s,
      payload: t,
      children: [w, i && /* @__PURE__ */ d.jsx(i.Render, {
        ...i.renderProps
      })]
    })
  });
}
function mt({
  reset: s,
  error: t,
  resetErrorBoundary: o,
  ...u
}) {
  return V(() => {
    s && o();
  }, [s]), /* @__PURE__ */ d.jsx("div", {
    ...u,
    style: {
      padding: 8,
      borderRadius: 4,
      backgroundColor: "red",
      fontSize: "1rem",
      fontWeight: "bold",
      display: "inline-block",
      color: "#fff"
    },
    children: "渲染组件失败"
  });
}
function gt({
  id: s,
  element: t,
  env: o,
  variableDefine: u,
  variableValue: f,
  addDependent: i
}) {
  const c = Se(), n = Gr(t.type), v = Jr(), w = de(), y = fe(), m = ve("element", s), x = je(!1), [b, I] = H(!1), [k, K] = H({});
  V(() => {
    x.current && I(!0);
  }, [k]);
  const B = ne(async (P, _, O, A) => {
    const D = {};
    for (const T in P.attr) {
      const L = P.attr[T], M = A == null ? void 0 : A[T];
      if (qr(L)) {
        i(M), D[T] = M != null && M.length ? Hr(M, O) : void 0;
        continue;
      }
      if (vr(M)) {
        const oe = await pr({
          context: O,
          contextDefine: _,
          code: M.code,
          onVariablePath: i
        });
        D[T] = oe;
      } else
        D[T] = M;
    }
    K(D);
  }, []);
  V(() => {
    n && B(n, u, f, t.props);
  }, [t.props, n, u, f]);
  const E = S(() => {
    var _;
    const P = {};
    for (const O in n == null ? void 0 : n.slot) {
      const A = (_ = t.slotMap) == null ? void 0 : _[O];
      A && (P[O] = (D) => /* @__PURE__ */ d.jsx(ht, {
        id: A,
        payload: D
      }));
    }
    return P;
  }, [t.slotMap, n]), z = S(() => {
    var _;
    const P = {};
    for (const O in n == null ? void 0 : n.style)
      P[O] = new ae().toString((_ = t.props) == null ? void 0 : _[O], w == null ? void 0 : w.vars) || {};
    return P;
  }, [t.props, w == null ? void 0 : w.vars, n]), G = S(() => {
    var _, O;
    const P = {};
    for (const A in n == null ? void 0 : n.className)
      P[A] = J((O = (_ = t.props) == null ? void 0 : _[A]) == null ? void 0 : O.map((D) => `${y}${D}`));
    return P;
  }, [t.props, n, y]), F = Ce(async (P, _, O) => {
    if (o.isPreviewing)
      return;
    const A = await Xr(s, P, c.state.getValue(), c.elements.getValue(), u);
    try {
      return await Oe({
        value: _,
        triggerMethod: A,
        triggerParams: O,
        variables: u,
        variableContext: Zr(c.variableStore, v),
        store: c
      });
    } catch (D) {
      console.error(D);
    }
  }, [s, v, u, o.isPreviewing]), Y = S(() => {
    const P = {};
    for (const _ in n == null ? void 0 : n.event)
      P[_] = (...O) => {
        var T, L;
        const A = (T = n == null ? void 0 : n.event) == null ? void 0 : T[_], D = (L = t.props) == null ? void 0 : L[_];
        !A || !D || F(A, D, O);
      };
    return P;
  }, [t, n]), W = S(() => {
    if (!n)
      return;
    const P = o.isPreviewing ? {
      [pt]: s
    } : void 0;
    return /* @__PURE__ */ d.jsx(dt, {
      onError: () => x.current = !0,
      onReset: () => {
        x.current = !1, I(!1);
      },
      fallbackRender: (_) => /* @__PURE__ */ d.jsx(mt, {
        reset: b,
        ..._,
        ...P
      }),
      children: /* @__PURE__ */ d.jsx(Qr, {
        id: s,
        children: /* @__PURE__ */ d.jsx(n.Render, {
          ...z,
          ...G,
          ...k,
          ...E,
          ...Y,
          ...P
        })
      })
    });
  }, [k, b, E, s, n, o.isPreviewing]);
  return /* @__PURE__ */ d.jsxs(d.Fragment, {
    children: [W, m && /* @__PURE__ */ d.jsx(m.Render, {
      ...m.renderProps
    })]
  });
}
function De({
  id: s
}) {
  var y;
  const t = le(), o = Te("element", s), {
    initComplete: u,
    variableDefine: f
  } = fr(), {
    variableValue: i,
    addDependent: c
  } = dr(), [n, v] = H(((y = o.visibleCondition) == null ? void 0 : y.type) !== "condition"), w = ne(async (m, x, b) => {
    if ((b == null ? void 0 : b.type) !== "condition")
      return;
    const I = await at({
      condition: b.condition,
      context: m,
      contextDefine: x,
      onVariablePath: c
    });
    v(I);
  }, []);
  if (V(() => {
    !u || t.isPreviewing || w(i, f, o.visibleCondition);
  }, [u, f, i, o.visibleCondition, t.isPreviewing]), !(!u || !n && !t.isPreviewing))
    return /* @__PURE__ */ d.jsx(gt, {
      id: s,
      element: o,
      env: t,
      variableDefine: f,
      variableValue: i,
      addDependent: c
    });
}
function yt() {
  const s = fe(), t = je(document.createElement("style")), o = Se(), u = le(), f = ve("editor", s || ""), i = de(), c = et(), n = Te("editor", s || ""), v = Ce(async (b) => {
    const I = {
      label: ""
    };
    try {
      await Oe({
        value: b,
        triggerMethod: I,
        variables: o.variableDefine.getValue(),
        variableContext: o.variableStore.getValue(),
        store: o
      });
    } catch (k) {
      console.error(k);
    }
  }, []);
  V(() => {
    if (!((n == null ? void 0 : n.type) !== "root" || u.isPreviewing))
      return n.onInit && v(n.onInit), () => {
        n.onDestroy && v(n.onDestroy);
      };
  }, [n, u]), V(() => (t.current.setAttribute("type", "text/css"), document.head.appendChild(t.current), () => {
    document.head.removeChild(t.current);
  }), []), V(() => {
    s && (t.current.innerText = new ae().globalStyleToString(c, i == null ? void 0 : i.vars, [s]));
  }, [s, c, i == null ? void 0 : i.vars]);
  const w = S(() => new ae().toString(n == null ? void 0 : n.style, i == null ? void 0 : i.vars), [n == null ? void 0 : n.style, i == null ? void 0 : i.vars]), y = S(() => {
    var b;
    return (b = n == null ? void 0 : n.classNames) == null ? void 0 : b.map((I) => `${s}${I}`);
  }, [n == null ? void 0 : n.classNames, s]), m = S(() => n == null ? void 0 : n.elements.map((b) => /* @__PURE__ */ d.jsx(De, {
    id: b
  }, b)), [n == null ? void 0 : n.elements]), x = S(() => {
    if (u.isPreviewing)
      return {
        [Ae]: s
      };
  }, [s, u.isPreviewing]);
  return s ? /* @__PURE__ */ d.jsxs("div", {
    ...x,
    className: J("easy-coder-root", y),
    style: w,
    children: [m, f && /* @__PURE__ */ d.jsx(f.Render, {
      ...f.renderProps
    })]
  }) : /* @__PURE__ */ d.jsx("span", {
    children: "未找到根节点"
  });
}
const bt = cr(yt, () => !0);
const Rt = {
  close: `<path
      d="M504.224 470.288l207.84-207.84a16 16 0 0 1 22.608 0l11.328 11.328a16 16 0 0 1 0 22.624l-207.84 207.824 207.84 207.84a16 16 0 0 1 0 22.608l-11.328 11.328a16 16 0 0 1-22.624 0l-207.824-207.84-207.84 207.84a16 16 0 0 1-22.608 0l-11.328-11.328a16 16 0 0 1 0-22.624l207.84-207.824-207.84-207.84a16 16 0 0 1 0-22.608l11.328-11.328a16 16 0 0 1 22.624 0l207.824 207.84z"
      />`,
  refresh: `<path
      d="M927.999436 531.028522a31.998984 31.998984 0 0 0-31.998984 31.998984c0 51.852948-10.147341 102.138098-30.163865 149.461048a385.47252 385.47252 0 0 1-204.377345 204.377345c-47.32295 20.016524-97.6081 30.163865-149.461048 30.163865s-102.138098-10.147341-149.461048-30.163865a385.47252 385.47252 0 0 1-204.377345-204.377345c-20.016524-47.32295-30.163865-97.6081-30.163865-149.461048s10.147341-102.138098 30.163865-149.461048a385.47252 385.47252 0 0 1 204.377345-204.377345c47.32295-20.016524 97.6081-30.163865 149.461048-30.163865a387.379888 387.379888 0 0 1 59.193424 4.533611l-56.538282 22.035878A31.998984 31.998984 0 1 0 537.892156 265.232491l137.041483-53.402685a31.998984 31.998984 0 0 0 18.195855-41.434674L639.723197 33.357261a31.998984 31.998984 0 1 0-59.630529 23.23882l26.695923 68.502679a449.969005 449.969005 0 0 0-94.786785-10.060642c-60.465003 0-119.138236 11.8488-174.390489 35.217667a449.214005 449.214005 0 0 0-238.388457 238.388457c-23.361643 55.252253-35.22128 113.925486-35.22128 174.390489s11.8488 119.138236 35.217668 174.390489a449.214005 449.214005 0 0 0 238.388457 238.388457c55.252253 23.368867 113.925486 35.217667 174.390489 35.217667s119.138236-11.8488 174.390489-35.217667A449.210393 449.210393 0 0 0 924.784365 737.42522c23.368867-55.270316 35.217667-113.925486 35.217667-174.390489a31.998984 31.998984 0 0 0-32.002596-32.006209z"
      />`
};
function Et({
  type: s,
  className: t,
  ...o
}, u) {
  return /* @__PURE__ */ d.jsx("svg", {
    className: J("rabbit-icon", "rabbit-component", t),
    viewBox: "0 0 1024 1024",
    version: "1.1",
    xmlns: "http://www.w3.org/2000/svg",
    ...o,
    ref: u,
    dangerouslySetInnerHTML: {
      __html: Rt[s]
    }
  });
}
const xt = _e.forwardRef(Et);
const or = 200, sr = {
  left: 0,
  top: 0,
  width: "100vw",
  height: "100vh"
};
function wt({
  header: s,
  content: t,
  visible: o,
  width: u,
  height: f,
  placement: i = "center",
  style: c,
  className: n,
  zIndex: v,
  preventMouseOver: w,
  preventAutoClose: y,
  onClose: m,
  onVisibleChange: x,
  getContainer: b = () => document.body,
  ...I
}) {
  const [k, K] = H(!!o), [B, E] = H(!o), [z, G] = H(sr);
  V(() => {
    k !== o && o !== void 0 && (o ? (setTimeout(() => {
      E(!1);
    }, 60), K(!0)) : (E(!0), Y(!1)));
  }, [o]), V(() => {
    k !== o && (x == null || x(k));
  }, [k]), V(() => {
    b() === document.body ? G(sr) : G(b().getBoundingClientRect());
  }, [b]);
  const F = ne(() => {
    y || (E(!0), Y(!1)), m == null || m();
  }, [y, m]), Y = ne((W) => {
    setTimeout(() => {
      K(W);
    }, or);
  }, []);
  return k ? ot.createPortal(/* @__PURE__ */ d.jsx("div", {
    className: J("rabbit-modal-wrapper", "rabbit-component", `placement-${i}`),
    style: {
      zIndex: v
    },
    onMouseOverCapture: (W) => w && W.preventDefault(),
    children: /* @__PURE__ */ d.jsx("div", {
      className: J("modal-container", n),
      style: {
        width: z.width,
        height: z.height
        // left: containerRect.left,
        // top: containerRect.top,
      },
      children: /* @__PURE__ */ d.jsxs("div", {
        ...I,
        className: J("modal-content", {
          "is-hidden": B
        }),
        style: {
          ...c || {},
          width: u,
          height: f,
          "--animation-time": `${or / 1e3}s`
        },
        children: [s && /* @__PURE__ */ d.jsxs("div", {
          className: "modal-header",
          children: [/* @__PURE__ */ d.jsx("div", {
            children: s
          }), /* @__PURE__ */ d.jsx(xt, {
            type: "close",
            style: {
              fontSize: "1.5rem"
            },
            onClick: F
          })]
        }), /* @__PURE__ */ d.jsx("div", {
          className: "modal-body",
          children: t
        })]
      })
    })
  }), b()) : /* @__PURE__ */ d.jsx(d.Fragment, {});
}
function Pt({
  id: s,
  modal: t
}) {
  const o = Se(), u = le(), f = fe(), i = ve("editor", s), c = rt(), n = tt(), v = de(), [w, y] = H(), {
    initComplete: m,
    variableDefine: x
  } = fr(), {
    variableValue: b,
    addDependent: I
  } = dr(), k = Ce(async (F) => {
    const Y = {
      label: ""
    };
    try {
      await Oe({
        value: F,
        triggerMethod: Y,
        variables: o.variableDefine.getValue(),
        variableContext: o.variableStore.getValue(),
        store: o
      });
    } catch (W) {
      console.error(W);
    }
  }, []);
  V(() => {
    if (!u.isPreviewing)
      return t.onInit && k(t.onInit), () => {
        t.onDestroy && k(t.onDestroy);
      };
  }, [t, u]);
  const K = ne(async (F, Y, W) => {
    if (vr(W)) {
      const P = await pr({
        context: Y,
        contextDefine: F,
        code: W.code,
        onVariablePath: I
      });
      y(P);
    } else
      y(W);
  }, []);
  V(() => {
    m && K(x, b, t.header);
  }, [m, x, b, t.header]);
  const B = S(() => new ae().toString(t.style, v == null ? void 0 : v.vars), [t.style, v == null ? void 0 : v.vars]), E = S(() => {
    var F;
    return (F = t.classNames) == null ? void 0 : F.map((Y) => `${f}${Y}`);
  }, [t.classNames, f]), z = S(() => t.elements.map((F) => /* @__PURE__ */ d.jsx(De, {
    id: F
  }, F)), [t.elements]), G = S(() => {
    if (u.isPreviewing)
      return {
        [Ae]: s
      };
  }, [s, u.isPreviewing]);
  return /* @__PURE__ */ d.jsx(wt, {
    ...G,
    visible: !0,
    placement: t.placement,
    width: t.width,
    getContainer: n,
    onClose: () => c(s, !1),
    header: w || /* @__PURE__ */ d.jsx("span", {}),
    content: /* @__PURE__ */ d.jsxs("div", {
      style: B,
      className: J(E),
      children: [z, i && /* @__PURE__ */ d.jsx(i.Render, {
        ...i.renderProps
      })]
    })
  });
}
function _t() {
  const s = nt();
  return /* @__PURE__ */ d.jsx(d.Fragment, {
    children: s.map(({
      id: t,
      modal: o
    }) => /* @__PURE__ */ d.jsx(Pt, {
      id: t,
      modal: o
    }, t))
  });
}
const jt = cr(_t);
function Nt(s) {
  return /* @__PURE__ */ d.jsxs(ct, {
    ...s,
    children: [/* @__PURE__ */ d.jsx(bt, {}), /* @__PURE__ */ d.jsx(jt, {})]
  });
}
export {
  Ae as DATA_EDITOR_ID,
  pt as DATA_ELEMENT_ID,
  Ft as DATA_SLOT_ORDER,
  Nt as EasyCoderRender,
  ct as RenderProvider,
  ve as useExtraRender,
  It as useRenderContext
};
