import T, { memo as ie, useState as V, useRef as p, useCallback as ne, useEffect as j } from "react";
function Oe(e, t, r) {
  return t in e ? Object.defineProperty(e, t, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = r, e;
}
function ce(e, t) {
  var r = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    t && (n = n.filter(function(i) {
      return Object.getOwnPropertyDescriptor(e, i).enumerable;
    })), r.push.apply(r, n);
  }
  return r;
}
function le(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t] != null ? arguments[t] : {};
    t % 2 ? ce(Object(r), !0).forEach(function(n) {
      Oe(e, n, r[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ce(Object(r)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
    });
  }
  return e;
}
function je(e, t) {
  if (e == null) return {};
  var r = {}, n = Object.keys(e), i, o;
  for (o = 0; o < n.length; o++)
    i = n[o], !(t.indexOf(i) >= 0) && (r[i] = e[i]);
  return r;
}
function Me(e, t) {
  if (e == null) return {};
  var r = je(e, t), n, i;
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(e);
    for (i = 0; i < o.length; i++)
      n = o[i], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]);
  }
  return r;
}
function Pe(e, t) {
  return Se(e) || Ee(e, t) || Ie(e, t) || Te();
}
function Se(e) {
  if (Array.isArray(e)) return e;
}
function Ee(e, t) {
  if (!(typeof Symbol > "u" || !(Symbol.iterator in Object(e)))) {
    var r = [], n = !0, i = !1, o = void 0;
    try {
      for (var u = e[Symbol.iterator](), l; !(n = (l = u.next()).done) && (r.push(l.value), !(t && r.length === t)); n = !0)
        ;
    } catch (f) {
      i = !0, o = f;
    } finally {
      try {
        !n && u.return != null && u.return();
      } finally {
        if (i) throw o;
      }
    }
    return r;
  }
}
function Ie(e, t) {
  if (e) {
    if (typeof e == "string") return se(e, t);
    var r = Object.prototype.toString.call(e).slice(8, -1);
    if (r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set") return Array.from(e);
    if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return se(e, t);
  }
}
function se(e, t) {
  (t == null || t > e.length) && (t = e.length);
  for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
  return n;
}
function Te() {
  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 Le(e, t, r) {
  return t in e ? Object.defineProperty(e, t, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = r, e;
}
function fe(e, t) {
  var r = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    t && (n = n.filter(function(i) {
      return Object.getOwnPropertyDescriptor(e, i).enumerable;
    })), r.push.apply(r, n);
  }
  return r;
}
function de(e) {
  for (var t = 1; t < arguments.length; t++) {
    var r = arguments[t] != null ? arguments[t] : {};
    t % 2 ? fe(Object(r), !0).forEach(function(n) {
      Le(e, n, r[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : fe(Object(r)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
    });
  }
  return e;
}
function Ce() {
  for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
    t[r] = arguments[r];
  return function(n) {
    return t.reduceRight(function(i, o) {
      return o(i);
    }, n);
  };
}
function D(e) {
  return function t() {
    for (var r = this, n = arguments.length, i = new Array(n), o = 0; o < n; o++)
      i[o] = arguments[o];
    return i.length >= e.length ? e.apply(this, i) : function() {
      for (var u = arguments.length, l = new Array(u), f = 0; f < u; f++)
        l[f] = arguments[f];
      return t.apply(r, [].concat(i, l));
    };
  };
}
function H(e) {
  return {}.toString.call(e).includes("Object");
}
function Ae(e) {
  return !Object.keys(e).length;
}
function x(e) {
  return typeof e == "function";
}
function $e(e, t) {
  return Object.prototype.hasOwnProperty.call(e, t);
}
function De(e, t) {
  return H(t) || P("changeType"), Object.keys(t).some(function(r) {
    return !$e(e, r);
  }) && P("changeField"), t;
}
function Re(e) {
  x(e) || P("selectorType");
}
function Ve(e) {
  x(e) || H(e) || P("handlerType"), H(e) && Object.values(e).some(function(t) {
    return !x(t);
  }) && P("handlersType");
}
function xe(e) {
  e || P("initialIsRequired"), H(e) || P("initialType"), Ae(e) && P("initialContent");
}
function qe(e, t) {
  throw new Error(e[t] || e.default);
}
var ze = {
  initialIsRequired: "initial state is required",
  initialType: "initial state should be an object",
  initialContent: "initial state shouldn't be an empty object",
  handlerType: "handler should be an object or a function",
  handlersType: "all handlers should be a functions",
  selectorType: "selector should be a function",
  changeType: "provided value of changes should be an object",
  changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
  default: "an unknown error accured in `state-local` package"
}, P = D(qe)(ze), N = {
  changes: De,
  selector: Re,
  handler: Ve,
  initial: xe
};
function Fe(e) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  N.initial(e), N.handler(t);
  var r = {
    current: e
  }, n = D(He)(r, t), i = D(Ue)(r), o = D(N.changes)(e), u = D(Ne)(r);
  function l() {
    var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(S) {
      return S;
    };
    return N.selector(b), b(r.current);
  }
  function f(b) {
    Ce(n, i, o, u)(b);
  }
  return [l, f];
}
function Ne(e, t) {
  return x(t) ? t(e.current) : t;
}
function Ue(e, t) {
  return e.current = de(de({}, e.current), t), t;
}
function He(e, t, r) {
  return x(t) ? t(e.current) : Object.keys(r).forEach(function(n) {
    var i;
    return (i = t[n]) === null || i === void 0 ? void 0 : i.call(t, e.current[n]);
  }), r;
}
var We = {
  create: Fe
}, _e = {
  paths: {
    vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"
  }
};
function Be(e) {
  return function t() {
    for (var r = this, n = arguments.length, i = new Array(n), o = 0; o < n; o++)
      i[o] = arguments[o];
    return i.length >= e.length ? e.apply(this, i) : function() {
      for (var u = arguments.length, l = new Array(u), f = 0; f < u; f++)
        l[f] = arguments[f];
      return t.apply(r, [].concat(i, l));
    };
  };
}
function Ge(e) {
  return {}.toString.call(e).includes("Object");
}
function Ke(e) {
  return e || pe("configIsRequired"), Ge(e) || pe("configType"), e.urls ? (Ye(), {
    paths: {
      vs: e.urls.monacoBase
    }
  }) : e;
}
function Ye() {
  console.warn(ge.deprecation);
}
function Je(e, t) {
  throw new Error(e[t] || e.default);
}
var ge = {
  configIsRequired: "the configuration object is required",
  configType: "the configuration object should be an object",
  default: "an unknown error accured in `@monaco-editor/loader` package",
  deprecation: `Deprecation warning!
    You are using deprecated way of configuration.

    Instead of using
      monaco.config({ urls: { monacoBase: '...' } })
    use
      monaco.config({ paths: { vs: '...' } })

    For more please check the link https://github.com/suren-atoyan/monaco-loader#config
  `
}, pe = Be(Je)(ge), Qe = {
  config: Ke
}, Xe = function() {
  for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
    r[n] = arguments[n];
  return function(i) {
    return r.reduceRight(function(o, u) {
      return u(o);
    }, i);
  };
};
function he(e, t) {
  return Object.keys(t).forEach(function(r) {
    t[r] instanceof Object && e[r] && Object.assign(t[r], he(e[r], t[r]));
  }), le(le({}, e), t);
}
var Ze = {
  type: "cancelation",
  msg: "operation is manually canceled"
};
function ee(e) {
  var t = !1, r = new Promise(function(n, i) {
    e.then(function(o) {
      return t ? i(Ze) : n(o);
    }), e.catch(i);
  });
  return r.cancel = function() {
    return t = !0;
  }, r;
}
var ke = We.create({
  config: _e,
  isInitialized: !1,
  resolve: null,
  reject: null,
  monaco: null
}), ve = Pe(ke, 2), q = ve[0], _ = ve[1];
function et(e) {
  var t = Qe.config(e), r = t.monaco, n = Me(t, ["monaco"]);
  _(function(i) {
    return {
      config: he(i.config, n),
      monaco: r
    };
  });
}
function tt() {
  var e = q(function(t) {
    var r = t.monaco, n = t.isInitialized, i = t.resolve;
    return {
      monaco: r,
      isInitialized: n,
      resolve: i
    };
  });
  if (!e.isInitialized) {
    if (_({
      isInitialized: !0
    }), e.monaco)
      return e.resolve(e.monaco), ee(te);
    if (window.monaco && window.monaco.editor)
      return me(window.monaco), e.resolve(window.monaco), ee(te);
    Xe(rt, it)(ot);
  }
  return ee(te);
}
function rt(e) {
  return document.body.appendChild(e);
}
function nt(e) {
  var t = document.createElement("script");
  return e && (t.src = e), t;
}
function it(e) {
  var t = q(function(n) {
    var i = n.config, o = n.reject;
    return {
      config: i,
      reject: o
    };
  }), r = nt("".concat(t.config.paths.vs, "/loader.js"));
  return r.onload = function() {
    return e();
  }, r.onerror = t.reject, r;
}
function ot() {
  var e = q(function(r) {
    var n = r.config, i = r.resolve, o = r.reject;
    return {
      config: n,
      resolve: i,
      reject: o
    };
  }), t = window.require;
  t.config(e.config), t(["vs/editor/editor.main"], function(r) {
    me(r), e.resolve(r);
  }, function(r) {
    e.reject(r);
  });
}
function me(e) {
  q().monaco || _({
    monaco: e
  });
}
function at() {
  return q(function(e) {
    var t = e.monaco;
    return t;
  });
}
var te = new Promise(function(e, t) {
  return _({
    resolve: e,
    reject: t
  });
}), W = {
  config: et,
  init: tt,
  __getMonacoInstance: at
}, ut = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, re = ut, ct = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, lt = ct;
function st({ children: e }) {
  return T.createElement("div", { style: lt.container }, e);
}
var ft = st, dt = ft;
function pt({ width: e, height: t, isEditorReady: r, loading: n, _ref: i, className: o, wrapperProps: u }) {
  return T.createElement("section", { style: { ...re.wrapper, width: e, height: t }, ...u }, !r && T.createElement(dt, null, n), T.createElement("div", { ref: i, style: { ...re.fullWidth, ...!r && re.hide }, className: o }));
}
var gt = pt, be = ie(gt);
function ht(e) {
  j(e, []);
}
var oe = ht;
function vt(e, t, r = !0) {
  let n = p(!0);
  j(n.current || !r ? () => {
    n.current = !1;
  } : e, t);
}
var y = vt;
function R() {
}
function I(e, t, r, n) {
  return mt(e, n) || bt(e, t, r, n);
}
function mt(e, t) {
  return e.editor.getModel(we(e, t));
}
function bt(e, t, r, n) {
  return e.editor.createModel(t, r, n ? we(e, n) : void 0);
}
function we(e, t) {
  return e.Uri.parse(t);
}
function wt({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: i, originalModelPath: o, modifiedModelPath: u, keepCurrentOriginalModel: l = !1, keepCurrentModifiedModel: f = !1, theme: b = "light", loading: S = "Loading...", options: O = {}, height: B = "100%", width: G = "100%", className: K, wrapperProps: Y = {}, beforeMount: J = R, onMount: Q = R }) {
  let [w, L] = V(!1), [C, d] = V(!0), g = p(null), s = p(null), A = p(null), v = p(Q), a = p(J), E = p(!1);
  oe(() => {
    let c = W.init();
    return c.then((h) => (s.current = h) && d(!1)).catch((h) => h?.type !== "cancelation" && console.error("Monaco initialization: error:", h)), () => g.current ? $() : c.cancel();
  }), y(() => {
    if (g.current && s.current) {
      let c = g.current.getOriginalEditor(), h = I(s.current, e || "", n || r || "text", o || "");
      h !== c.getModel() && c.setModel(h);
    }
  }, [o], w), y(() => {
    if (g.current && s.current) {
      let c = g.current.getModifiedEditor(), h = I(s.current, t || "", i || r || "text", u || "");
      h !== c.getModel() && c.setModel(h);
    }
  }, [u], w), y(() => {
    let c = g.current.getModifiedEditor();
    c.getOption(s.current.editor.EditorOption.readOnly) ? c.setValue(t || "") : t !== c.getValue() && (c.executeEdits("", [{ range: c.getModel().getFullModelRange(), text: t || "", forceMoveMarkers: !0 }]), c.pushUndoStop());
  }, [t], w), y(() => {
    g.current?.getModel()?.original.setValue(e || "");
  }, [e], w), y(() => {
    let { original: c, modified: h } = g.current.getModel();
    s.current.editor.setModelLanguage(c, n || r || "text"), s.current.editor.setModelLanguage(h, i || r || "text");
  }, [r, n, i], w), y(() => {
    s.current?.editor.setTheme(b);
  }, [b], w), y(() => {
    g.current?.updateOptions(O);
  }, [O], w);
  let z = ne(() => {
    if (!s.current) return;
    a.current(s.current);
    let c = I(s.current, e || "", n || r || "text", o || ""), h = I(s.current, t || "", i || r || "text", u || "");
    g.current?.setModel({ original: c, modified: h });
  }, [r, t, i, e, n, o, u]), F = ne(() => {
    !E.current && A.current && (g.current = s.current.editor.createDiffEditor(A.current, { automaticLayout: !0, ...O }), z(), s.current?.editor.setTheme(b), L(!0), E.current = !0);
  }, [O, b, z]);
  j(() => {
    w && v.current(g.current, s.current);
  }, [w]), j(() => {
    !C && !w && F();
  }, [C, w, F]);
  function $() {
    let c = g.current?.getModel();
    l || c?.original?.dispose(), f || c?.modified?.dispose(), g.current?.dispose();
  }
  return T.createElement(be, { width: G, height: B, isEditorReady: w, loading: S, _ref: A, className: K, wrapperProps: Y });
}
var yt = wt;
ie(yt);
function Ot() {
  let [e, t] = V(W.__getMonacoInstance());
  return oe(() => {
    let r;
    return e || (r = W.init(), r.then((n) => {
      t(n);
    })), () => r?.cancel();
  }), e;
}
var Tt = Ot;
function jt(e) {
  let t = p();
  return j(() => {
    t.current = e;
  }, [e]), t.current;
}
var Mt = jt, U = /* @__PURE__ */ new Map();
function Pt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: i, path: o, theme: u = "light", line: l, loading: f = "Loading...", options: b = {}, overrideServices: S = {}, saveViewState: O = !0, keepCurrentModel: B = !1, width: G = "100%", height: K = "100%", className: Y, wrapperProps: J = {}, beforeMount: Q = R, onMount: w = R, onChange: L, onValidate: C = R }) {
  let [d, g] = V(!1), [s, A] = V(!0), v = p(null), a = p(null), E = p(null), z = p(w), F = p(Q), $ = p(), c = p(n), h = Mt(o), ae = p(!1), X = p(!1);
  oe(() => {
    let m = W.init();
    return m.then((M) => (v.current = M) && A(!1)).catch((M) => M?.type !== "cancelation" && console.error("Monaco initialization: error:", M)), () => a.current ? ye() : m.cancel();
  }), y(() => {
    let m = I(v.current, e || n || "", t || i || "", o || r || "");
    m !== a.current?.getModel() && (O && U.set(h, a.current?.saveViewState()), a.current?.setModel(m), O && a.current?.restoreViewState(U.get(o)));
  }, [o], d), y(() => {
    a.current?.updateOptions(b);
  }, [b], d), y(() => {
    !a.current || n === void 0 || (a.current.getOption(v.current.editor.EditorOption.readOnly) ? a.current.setValue(n) : n !== a.current.getValue() && (X.current = !0, a.current.executeEdits("", [{ range: a.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), a.current.pushUndoStop(), X.current = !1));
  }, [n], d), y(() => {
    let m = a.current?.getModel();
    m && i && v.current?.editor.setModelLanguage(m, i);
  }, [i], d), y(() => {
    l !== void 0 && a.current?.revealLine(l);
  }, [l], d), y(() => {
    v.current?.editor.setTheme(u);
  }, [u], d);
  let ue = ne(() => {
    if (!(!E.current || !v.current) && !ae.current) {
      F.current(v.current);
      let m = o || r, M = I(v.current, n || e || "", t || i || "", m || "");
      a.current = v.current?.editor.create(E.current, { model: M, automaticLayout: !0, ...b }, S), O && a.current.restoreViewState(U.get(m)), v.current.editor.setTheme(u), l !== void 0 && a.current.revealLine(l), g(!0), ae.current = !0;
    }
  }, [e, t, r, n, i, o, b, S, O, u, l]);
  j(() => {
    d && z.current(a.current, v.current);
  }, [d]), j(() => {
    !s && !d && ue();
  }, [s, d, ue]), c.current = n, j(() => {
    d && L && ($.current?.dispose(), $.current = a.current?.onDidChangeModelContent((m) => {
      X.current || L(a.current.getValue(), m);
    }));
  }, [d, L]), j(() => {
    if (d) {
      let m = v.current.editor.onDidChangeMarkers((M) => {
        let Z = a.current.getModel()?.uri;
        if (Z && M.find((k) => k.path === Z.path)) {
          let k = v.current.editor.getModelMarkers({ resource: Z });
          C?.(k);
        }
      });
      return () => {
        m?.dispose();
      };
    }
    return () => {
    };
  }, [d, C]);
  function ye() {
    $.current?.dispose(), B ? O && U.set(o, a.current.saveViewState()) : a.current.getModel()?.dispose(), a.current.dispose();
  }
  return T.createElement(be, { width: G, height: K, isEditorReady: d, loading: f, _ref: E, className: Y, wrapperProps: J });
}
var St = Pt, Et = ie(St), Lt = Et;
export {
  Lt as F,
  Tt as L,
  Et as d
};
//# sourceMappingURL=index-DgLlxXt5.mjs.map
