UNPKG

@lanyue/react-object-viewer

Version:

A flexible and lightweight object viewer component for React.

984 lines (980 loc) 40.3 kB
import De, { useMemo as Y, useState as U, useEffect as ae, createContext as Mr, useContext as Dr, Fragment as Le } from "react"; var ie = { exports: {} }, F = {}; /** * @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 Pe; function Lr() { if (Pe) return F; Pe = 1; var r = De, s = Symbol.for("react.element"), i = Symbol.for("react.fragment"), x = Object.prototype.hasOwnProperty, f = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, l = { key: !0, ref: !0, __self: !0, __source: !0 }; function v(y, d, b) { var g, R = {}, T = null, z = null; b !== void 0 && (T = "" + b), d.key !== void 0 && (T = "" + d.key), d.ref !== void 0 && (z = d.ref); for (g in d) x.call(d, g) && !l.hasOwnProperty(g) && (R[g] = d[g]); if (y && y.defaultProps) for (g in d = y.defaultProps, d) R[g] === void 0 && (R[g] = d[g]); return { $$typeof: s, type: y, key: T, ref: z, props: R, _owner: f.current }; } return F.Fragment = i, F.jsx = v, F.jsxs = v, F; } var V = {}; /** * @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 Ae; function Fr() { return Ae || (Ae = 1, process.env.NODE_ENV !== "production" && function() { var r = De, s = Symbol.for("react.element"), i = Symbol.for("react.portal"), x = Symbol.for("react.fragment"), f = Symbol.for("react.strict_mode"), l = Symbol.for("react.profiler"), v = Symbol.for("react.provider"), y = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), b = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), T = Symbol.for("react.lazy"), z = Symbol.for("react.offscreen"), oe = Symbol.iterator, Ze = "@@iterator"; function Qe(e) { if (e === null || typeof e != "object") return null; var t = oe && e[oe] || e[Ze]; return typeof t == "function" ? t : null; } var k = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function w(e) { { for (var t = arguments.length, a = new Array(t > 1 ? t - 1 : 0), o = 1; o < t; o++) a[o - 1] = arguments[o]; er("error", e, a); } } function er(e, t, a) { { var o = k.ReactDebugCurrentFrame, h = o.getStackAddendum(); h !== "" && (t += "%s", a = a.concat([h])); var m = a.map(function(u) { return String(u); }); m.unshift("Warning: " + t), Function.prototype.apply.call(console[e], console, m); } } var rr = !1, tr = !1, nr = !1, ar = !1, ir = !1, le; le = Symbol.for("react.module.reference"); function sr(e) { return !!(typeof e == "string" || typeof e == "function" || e === x || e === l || ir || e === f || e === b || e === g || ar || e === z || rr || tr || nr || typeof e == "object" && e !== null && (e.$$typeof === T || e.$$typeof === R || e.$$typeof === v || e.$$typeof === y || e.$$typeof === d || // 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 === le || e.getModuleId !== void 0)); } function or(e, t, a) { var o = e.displayName; if (o) return o; var h = t.displayName || t.name || ""; return h !== "" ? a + "(" + h + ")" : a; } function ce(e) { return e.displayName || "Context"; } function S(e) { if (e == null) return null; if (typeof e.tag == "number" && w("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 x: return "Fragment"; case i: return "Portal"; case l: return "Profiler"; case f: return "StrictMode"; case b: return "Suspense"; case g: return "SuspenseList"; } if (typeof e == "object") switch (e.$$typeof) { case y: var t = e; return ce(t) + ".Consumer"; case v: var a = e; return ce(a._context) + ".Provider"; case d: return or(e, e.render, "ForwardRef"); case R: var o = e.displayName || null; return o !== null ? o : S(e.type) || "Memo"; case T: { var h = e, m = h._payload, u = h._init; try { return S(u(m)); } catch { return null; } } } return null; } var C = Object.assign, M = 0, ue, fe, de, he, ve, me, ge; function ye() { } ye.__reactDisabledLog = !0; function lr() { { if (M === 0) { ue = console.log, fe = console.info, de = console.warn, he = console.error, ve = console.group, me = console.groupCollapsed, ge = console.groupEnd; var e = { configurable: !0, enumerable: !0, value: ye, writable: !0 }; Object.defineProperties(console, { info: e, log: e, warn: e, error: e, group: e, groupCollapsed: e, groupEnd: e }); } M++; } } function cr() { { if (M--, M === 0) { var e = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: C({}, e, { value: ue }), info: C({}, e, { value: fe }), warn: C({}, e, { value: de }), error: C({}, e, { value: he }), group: C({}, e, { value: ve }), groupCollapsed: C({}, e, { value: me }), groupEnd: C({}, e, { value: ge }) }); } M < 0 && w("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var G = k.ReactCurrentDispatcher, K; function $(e, t, a) { { if (K === void 0) try { throw Error(); } catch (h) { var o = h.stack.trim().match(/\n( *(at )?)/); K = o && o[1] || ""; } return ` ` + K + e; } } var X = !1, B; { var ur = typeof WeakMap == "function" ? WeakMap : Map; B = new ur(); } function xe(e, t) { if (!e || X) return ""; { var a = B.get(e); if (a !== void 0) return a; } var o; X = !0; var h = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var m; m = G.current, G.current = null, lr(); try { if (t) { var u = function() { throw Error(); }; if (Object.defineProperty(u.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(u, []); } catch (_) { o = _; } Reflect.construct(e, [], u); } else { try { u.call(); } catch (_) { o = _; } e.call(u.prototype); } } else { try { throw Error(); } catch (_) { o = _; } e(); } } catch (_) { if (_ && o && typeof _.stack == "string") { for (var c = _.stack.split(` `), E = o.stack.split(` `), p = c.length - 1, j = E.length - 1; p >= 1 && j >= 0 && c[p] !== E[j]; ) j--; for (; p >= 1 && j >= 0; p--, j--) if (c[p] !== E[j]) { if (p !== 1 || j !== 1) do if (p--, j--, j < 0 || c[p] !== E[j]) { var O = ` ` + c[p].replace(" at new ", " at "); return e.displayName && O.includes("<anonymous>") && (O = O.replace("<anonymous>", e.displayName)), typeof e == "function" && B.set(e, O), O; } while (p >= 1 && j >= 0); break; } } } finally { X = !1, G.current = m, cr(), Error.prepareStackTrace = h; } var A = e ? e.displayName || e.name : "", N = A ? $(A) : ""; return typeof e == "function" && B.set(e, N), N; } function fr(e, t, a) { return xe(e, !1); } function dr(e) { var t = e.prototype; return !!(t && t.isReactComponent); } function W(e, t, a) { if (e == null) return ""; if (typeof e == "function") return xe(e, dr(e)); if (typeof e == "string") return $(e); switch (e) { case b: return $("Suspense"); case g: return $("SuspenseList"); } if (typeof e == "object") switch (e.$$typeof) { case d: return fr(e.render); case R: return W(e.type, t, a); case T: { var o = e, h = o._payload, m = o._init; try { return W(m(h), t, a); } catch { } } } return ""; } var D = Object.prototype.hasOwnProperty, pe = {}, be = k.ReactDebugCurrentFrame; function H(e) { if (e) { var t = e._owner, a = W(e.type, e._source, t ? t.type : null); be.setExtraStackFrame(a); } else be.setExtraStackFrame(null); } function hr(e, t, a, o, h) { { var m = Function.call.bind(D); for (var u in e) if (m(e, u)) { var c = void 0; try { if (typeof e[u] != "function") { var E = Error((o || "React class") + ": " + a + " type `" + u + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[u] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw E.name = "Invariant Violation", E; } c = e[u](t, u, o, a, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (p) { c = p; } c && !(c instanceof Error) && (H(h), w("%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).", o || "React class", a, u, typeof c), H(null)), c instanceof Error && !(c.message in pe) && (pe[c.message] = !0, H(h), w("Failed %s type: %s", a, c.message), H(null)); } } } var vr = Array.isArray; function Z(e) { return vr(e); } function mr(e) { { var t = typeof Symbol == "function" && Symbol.toStringTag, a = t && e[Symbol.toStringTag] || e.constructor.name || "Object"; return a; } } function gr(e) { try { return je(e), !1; } catch { return !0; } } function je(e) { return "" + e; } function we(e) { if (gr(e)) return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", mr(e)), je(e); } var L = k.ReactCurrentOwner, yr = { key: !0, ref: !0, __self: !0, __source: !0 }, Ee, Re, Q; Q = {}; function xr(e) { if (D.call(e, "ref")) { var t = Object.getOwnPropertyDescriptor(e, "ref").get; if (t && t.isReactWarning) return !1; } return e.ref !== void 0; } function pr(e) { if (D.call(e, "key")) { var t = Object.getOwnPropertyDescriptor(e, "key").get; if (t && t.isReactWarning) return !1; } return e.key !== void 0; } function br(e, t) { if (typeof e.ref == "string" && L.current && t && L.current.stateNode !== t) { var a = S(L.current.type); Q[a] || (w('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', S(L.current.type), e.ref), Q[a] = !0); } } function jr(e, t) { { var a = function() { Ee || (Ee = !0, w("%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)", t)); }; a.isReactWarning = !0, Object.defineProperty(e, "key", { get: a, configurable: !0 }); } } function wr(e, t) { { var a = function() { Re || (Re = !0, w("%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)", t)); }; a.isReactWarning = !0, Object.defineProperty(e, "ref", { get: a, configurable: !0 }); } } var Er = function(e, t, a, o, h, m, u) { var c = { // This tag allows us to uniquely identify this as a React Element $$typeof: s, // Built-in properties that belong on the element type: e, key: t, ref: a, props: u, // Record the component responsible for creating this element. _owner: m }; return c._store = {}, Object.defineProperty(c._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(c, "_self", { configurable: !1, enumerable: !1, writable: !1, value: o }), Object.defineProperty(c, "_source", { configurable: !1, enumerable: !1, writable: !1, value: h }), Object.freeze && (Object.freeze(c.props), Object.freeze(c)), c; }; function Rr(e, t, a, o, h) { { var m, u = {}, c = null, E = null; a !== void 0 && (we(a), c = "" + a), pr(t) && (we(t.key), c = "" + t.key), xr(t) && (E = t.ref, br(t, h)); for (m in t) D.call(t, m) && !yr.hasOwnProperty(m) && (u[m] = t[m]); if (e && e.defaultProps) { var p = e.defaultProps; for (m in p) u[m] === void 0 && (u[m] = p[m]); } if (c || E) { var j = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; c && jr(u, j), E && wr(u, j); } return Er(e, c, E, h, o, L.current, u); } } var ee = k.ReactCurrentOwner, _e = k.ReactDebugCurrentFrame; function P(e) { if (e) { var t = e._owner, a = W(e.type, e._source, t ? t.type : null); _e.setExtraStackFrame(a); } else _e.setExtraStackFrame(null); } var re; re = !1; function te(e) { return typeof e == "object" && e !== null && e.$$typeof === s; } function Oe() { { if (ee.current) { var e = S(ee.current.type); if (e) return ` Check the render method of \`` + e + "`."; } return ""; } } function _r(e) { { if (e !== void 0) { var t = e.fileName.replace(/^.*[\\\/]/, ""), a = e.lineNumber; return ` Check your code at ` + t + ":" + a + "."; } return ""; } } var Se = {}; function Or(e) { { var t = Oe(); if (!t) { var a = typeof e == "string" ? e : e.displayName || e.name; a && (t = ` Check the top-level render call using <` + a + ">."); } return t; } } function Te(e, t) { { if (!e._store || e._store.validated || e.key != null) return; e._store.validated = !0; var a = Or(t); if (Se[a]) return; Se[a] = !0; var o = ""; e && e._owner && e._owner !== ee.current && (o = " It was passed a child from " + S(e._owner.type) + "."), P(e), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', a, o), P(null); } } function Ce(e, t) { { if (typeof e != "object") return; if (Z(e)) for (var a = 0; a < e.length; a++) { var o = e[a]; te(o) && Te(o, t); } else if (te(e)) e._store && (e._store.validated = !0); else if (e) { var h = Qe(e); if (typeof h == "function" && h !== e.entries) for (var m = h.call(e), u; !(u = m.next()).done; ) te(u.value) && Te(u.value, t); } } } function Sr(e) { { var t = e.type; if (t == null || typeof t == "string") return; var a; if (typeof t == "function") a = t.propTypes; else if (typeof t == "object" && (t.$$typeof === d || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. t.$$typeof === R)) a = t.propTypes; else return; if (a) { var o = S(t); hr(a, e.props, "prop", o, e); } else if (t.PropTypes !== void 0 && !re) { re = !0; var h = S(t); w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", h || "Unknown"); } typeof t.getDefaultProps == "function" && !t.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function Tr(e) { { for (var t = Object.keys(e.props), a = 0; a < t.length; a++) { var o = t[a]; if (o !== "children" && o !== "key") { P(e), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", o), P(null); break; } } e.ref !== null && (P(e), w("Invalid attribute `ref` supplied to `React.Fragment`."), P(null)); } } var Ne = {}; function ke(e, t, a, o, h, m) { { var u = sr(e); if (!u) { var c = ""; (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (c += " 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 E = _r(h); E ? c += E : c += Oe(); var p; e === null ? p = "null" : Z(e) ? p = "array" : e !== void 0 && e.$$typeof === s ? (p = "<" + (S(e.type) || "Unknown") + " />", c = " Did you accidentally export a JSX literal instead of a component?") : p = typeof e, w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", p, c); } var j = Rr(e, t, a, h, m); if (j == null) return j; if (u) { var O = t.children; if (O !== void 0) if (o) if (Z(O)) { for (var A = 0; A < O.length; A++) Ce(O[A], e); Object.freeze && Object.freeze(O); } else w("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 Ce(O, e); } if (D.call(t, "key")) { var N = S(e), _ = Object.keys(t).filter(function(Ir) { return Ir !== "key"; }), ne = _.length > 0 ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}"; if (!Ne[N + ne]) { var Ar = _.length > 0 ? "{" + _.join(": ..., ") + ": ...}" : "{}"; w(`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} />`, ne, N, Ar, N), Ne[N + ne] = !0; } } return e === x ? Tr(j) : Sr(j), j; } } function Cr(e, t, a) { return ke(e, t, a, !0); } function Nr(e, t, a) { return ke(e, t, a, !1); } var kr = Nr, Pr = Cr; V.Fragment = x, V.jsx = kr, V.jsxs = Pr; }()), V; } process.env.NODE_ENV === "production" ? ie.exports = Lr() : ie.exports = Fr(); var n = ie.exports; function Vr(r) { const s = Object.getOwnPropertyDescriptors(r), i = []; for (const f in s) i.push({ key: f, descriptor: s[f] }); r instanceof Set && i.push({ key: "[[Values]]", descriptor: { enumerable: !0, value: [...r.entries()].reduce((f, l) => (f[l[0] - 1] = l[1], f), {}) } }), r instanceof Map && i.push({ key: "[[Entries]]", descriptor: { enumerable: !0, value: [...r.entries()].reduce((f, l, v) => (f[v] = { key: l[0], value: l[1] }, f), {}) } }); const x = Object.getPrototypeOf(r); if (x !== null) { const f = Object.getOwnPropertyDescriptors(x); for (const l in f) !f[l].enumerable && !f[l].get || l !== "__proto__" && i.push({ key: l, descriptor: f[l] }); i.push({ key: "[[Prototype]]", descriptor: { enumerable: !1, value: x } }); } return i; } function se(r) { const s = typeof r; if (s === "object") { if (r === null) return "null"; if (Array.isArray(r)) return "array"; } return s; } function Fe(r) { try { return Object.getPrototypeOf(r).constructor.name; } catch { return "<Blocked>"; } } function I(r) { if (Array.isArray(r)) return r.filter((i) => !!i).join(" "); const s = []; for (const i in r) i && r[i] && s.push(i); return s.join(" "); } function Ve() { return /* @__PURE__ */ n.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "5", height: "7", viewBox: "0 0 5 7", className: "icon-arrow", children: /* @__PURE__ */ n.jsx("path", { d: "M4.64 2.732l-3-2.5A1 1 0 0 0 0 1v5a1 1 0 0 0 1.64.768l3-2.5a1 1 0 0 0 0-1.536z", fillRule: "evenodd", opacity: ".675" }) }); } function ze() { return /* @__PURE__ */ n.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512", className: "icon-ellipsis", fill: "currentColor", children: /* @__PURE__ */ n.jsx("path", { d: "M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z" }) }); } function $e() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16 16", children: [ /* @__PURE__ */ n.jsx("path", { d: "M16 12a4 4 0 0 1-4 4H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4", className: "icon-object" }), /* @__PURE__ */ n.jsx("path", { d: "M13.1 7.31l-1.15-.5V5.3A2.21 2.21 0 0 0 9.6 3.15a.75.75 0 0 0 0 1.5c.26 0 .86.08.86.65v2a.75.75 0 0 0 .44.7.75.75 0 0 0-.45.69v2c0 .3-.17.66-.85.66a.75.75 0 1 0 0 1.5 2.18 2.18 0 0 0 2.35-2.15V9.19l1.15-.5a.75.75 0 0 0 0-1.37zM5.55 7.3v-2c0-.57.6-.65.86-.65a.75.75 0 0 0 0-1.5A2.21 2.21 0 0 0 4.05 5.3v1.51l-1.15.5a.75.75 0 0 0 0 1.38l1.15.5v1.51a2.18 2.18 0 0 0 2.35 2.15.75.75 0 0 0 0-1.5c-.68 0-.84-.36-.85-.65v-2A.75.75 0 0 0 5.1 8a.75.75 0 0 0 .45-.7z", className: "icon-inner" }) ] }); } function Be() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16 16", children: [ /* @__PURE__ */ n.jsx("path", { d: "M12 16H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v8a4 4 0 0 1-4 4z", className: "icon-array" }), /* @__PURE__ */ n.jsx("path", { d: "M6.7 12.65h-2a.75.75 0 0 1-.75-.75v-7a.75.75 0 0 1 .75-.75h2a.75.75 0 0 1 0 1.5H5.45v5.5H6.7a.75.75 0 1 1 0 1.5zM11.7 12.65h-2a.75.75 0 0 1 0-1.5h1.25v-5.5H9.7a.75.75 0 0 1 0-1.5h2a.75.75 0 0 1 .75.75v7a.75.75 0 0 1-.75.75z", className: "icon-inner" }) ] }); } function We() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16 16", children: [ /* @__PURE__ */ n.jsx("path", { d: "M16 12a4 4 0 0 1-4 4H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4", className: "icon-string" }), /* @__PURE__ */ n.jsx("path", { d: "M6.4 5.65h.2a.75.75 0 0 0 0-1.5h-.2A2.55 2.55 0 0 0 3.85 6.7v4.2a.75.75 0 0 0 .75.75.74.74 0 0 0 .25-.05v.05H6.1a1.2 1.2 0 0 0 1.25-1.25A1.2 1.2 0 0 0 6.1 9.15h-.75V6.7A1 1 0 0 1 6.4 5.65zM11.1 9.15h-.75V6.3a.61.61 0 0 1 .65-.65h.6a.75.75 0 0 0 0-1.5H11A2.13 2.13 0 0 0 8.85 6.3v4.6a.75.75 0 0 0 .75.75.74.74 0 0 0 .25-.05v.05h1.25a1.2 1.2 0 0 0 1.25-1.25 1.2 1.2 0 0 0-1.25-1.25z", className: "icon-inner" }) ] }); } function He() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16 16", children: [ /* @__PURE__ */ n.jsx("path", { d: "M12 16H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v8a4 4 0 0 1-4 4z", className: "icon-number" }), /* @__PURE__ */ n.jsx("path", { d: "M12 6h-1l.26-1a.75.75 0 1 0-1.45-.38L9.41 6H7.87l.26-1a.75.75 0 1 0-1.45-.37L6.32 6H5a.75.75 0 0 0 0 1.5h.9l-.42 1.75H4a.75.75 0 0 0 0 1.5h1.1l-.22.86a.75.75 0 0 0 .54.91h.19a.75.75 0 0 0 .72-.52l.32-1.24h1.52l-.2.76a.75.75 0 0 0 .54.92h.19a.75.75 0 0 0 .72-.56l.3-1.14H11a.75.75 0 0 0 0-1.5h-.89l.46-1.75H12A.75.75 0 0 0 12 6zM8.56 9.25H7l.48-1.75H9z", className: "icon-inner" }) ] }); } function Ye() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16.05 16.05", children: [ /* @__PURE__ */ n.jsx("path", { d: "M12 16.05L4 16a4 4 0 0 1-4-4l.05-8a4 4 0 0 1 4-4l8 .05a4 4 0 0 1 4 4l-.05 8a4 4 0 0 1-4 4z", className: "icon-boolean" }), /* @__PURE__ */ n.jsx("path", { d: "M7.53 4.28h-4a.75.75 0 0 0 0 1.5h1.24v5.25a.75.75 0 0 0 .75.75.75.75 0 0 0 .72-.78V5.75h1.29a.75.75 0 0 0 0-1.5zM12.51 7.32h-2.25V5.8h2.25a.75.75 0 0 0 0-1.5h-3a.75.75 0 0 0-.73.7v6a.75.75 0 0 0 .75.75.75.75 0 0 0 .75-.75V8.8h2.25a.75.75 0 0 0 0-1.5z", className: "icon-inner" }) ] }); } function Ue() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16 16", children: [ /* @__PURE__ */ n.jsx("path", { d: "M16 12.3a3.76 3.76 0 0 1-3.7 3.7H3.7A3.69 3.69 0 0 1 0 12.3V3.7A3.69 3.69 0 0 1 3.7 0h8.6A3.69 3.69 0 0 1 16 3.7z", className: "icon-null" }), /* @__PURE__ */ n.jsx("path", { d: "M10.68 4.73l.48-.86a.75.75 0 1 0-1.31-.73L9.37 4A4.2 4.2 0 0 0 8 3.75a4.23 4.23 0 0 0-2.68 7.52l-.48.86a.75.75 0 1 0 1.31.73l.48-.86a4.2 4.2 0 0 0 1.37.25 4.23 4.23 0 0 0 2.68-7.52zM5.25 8a2.73 2.73 0 0 1 3.38-2.67L6.06 9.95A2.74 2.74 0 0 1 5.25 8zM8 10.75a2.73 2.73 0 0 1-.63-.08l2.57-4.62A2.75 2.75 0 0 1 8 10.75z", className: "icon-inner" }) ] }); } function Je() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16 16", children: [ /* @__PURE__ */ n.jsx("path", { d: "M12.3 16H3.7A3.69 3.69 0 0 1 0 12.3V3.7A3.69 3.69 0 0 1 3.7 0h8.6A3.69 3.69 0 0 1 16 3.7v8.6a3.63 3.63 0 0 1-3.7 3.7z", className: "icon-undefined" }), /* @__PURE__ */ n.jsx("path", { d: "M7.9 10.35a.75.75 0 0 1-.75-.75V8.3a.75.75 0 0 1 .57-.73c.07 0 1.83-.49 1.83-2 0-.5-.27-1.25-1.75-1.25a1.39 1.39 0 0 0-1.31.75.76.76 0 0 1-1 .38.74.74 0 0 1-.4-1 2.88 2.88 0 0 1 2.71-1.6c1.9 0 3.12 1 3.25 2.69a3.62 3.62 0 0 1-2.4 3.29v.77a.75.75 0 0 1-.75.75z", className: "icon-inner" }), /* @__PURE__ */ n.jsx("circle", { cx: "7.9", cy: "12", r: ".9", className: "icon-inner" }) ] }); } function qe() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16 16", children: [ /* @__PURE__ */ n.jsx("path", { d: "M12 16H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v8a4 4 0 0 1-4 4z", className: "icon-symbol" }), /* @__PURE__ */ n.jsx("path", { d: "M8.3 4l1.1 2.2c.1.1.2.2.3.2l2.5.4a.35.35 0 0 1 .2.6l-1.8 1.7a.37.37 0 0 0-.1.3l.4 2.5c.1.3-.3.5-.5.4l-2.2-1.2a.19.19 0 0 0-.3 0l-2.2 1.2c-.3.1-.6-.1-.5-.4l.4-2.5a.37.37 0 0 0-.1-.3L3.7 7.4a.35.35 0 0 1 .2-.6l2.5-.4c.1 0 .2-.1.3-.2L7.8 4c0-.3.4-.3.5 0z", className: "icon-inner" }) ] }); } function Ge() { return /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 16 16", children: [ /* @__PURE__ */ n.jsx("path", { d: "M12 16H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v8a4 4 0 0 1-4 4z", className: "icon-function" }), /* @__PURE__ */ n.jsx("path", { d: "M7.4 3.62a2.61 2.61 0 0 0-1.78.8 3.52 3.52 0 0 0-.88 2.3H4.5a.78.78 0 1 0 0 1.56h.24v.59a.78.78 0 0 0 0 .25 7.32 7.32 0 0 1-.31 2.62.78.78 0 0 0 .19 1.54 1.22 1.22 0 0 0 .89-.39 5 5 0 0 0 .79-3V9.57 8.28h.2a.78.78 0 0 0 0-1.56h-.2c.12-1.4.93-1.53 1.12-1.54a.78.78 0 0 0 0-1.56zM12.88 9.17L11.78 8l1-1.28a.78.78 0 1 0-1.21-1l-.86 1.08-.94-1a.78.78 0 1 0-1.15 1.02L9.72 8l-1 1.28a.78.78 0 1 0 1.21 1l.88-1.09.94 1a.78.78 0 0 0 1.15-1.05z", className: "icon-inner" }) ] }); } const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, IconArray: Be, IconArrow: Ve, IconBoolean: Ye, IconEllipsis: ze, IconFunction: Ge, IconNull: Ue, IconNumber: He, IconObject: $e, IconString: We, IconSymbol: qe, IconUndefined: Je }, Symbol.toStringTag, { value: "Module" })); function zr({ children: r, showLine: s, ...i }) { return /* @__PURE__ */ n.jsx("div", { ...i, className: I([i.className, "tree", s && "show-line"]), children: r }); } function $r(r) { const s = Y(() => r.children, [r.children]), [i, x] = U(!!r.expand), f = (l) => { var v; if (l) { const y = getSelection(); if (y && y.anchorOffset !== y.focusOffset) return; } s && (x(!i), (v = r.onExpand) == null || v.call(r, !i)); }; return ae(() => { x(!!r.expand); }, [r.expand]), /* @__PURE__ */ n.jsxs("div", { className: I(["tree-item", r.className]), ...r.attrs, children: [ /* @__PURE__ */ n.jsxs("div", { className: "tree-item-label", onMouseUp: () => { r.canClickLabelExtend && f(!0); }, children: [ s && /* @__PURE__ */ n.jsx( "button", { className: I(["tree-item-fold-btn", i && "is-expand"]), onMouseUp: (l) => { l.stopPropagation(); }, onClick: () => { f(); }, children: /* @__PURE__ */ n.jsx(Ve, {}) } ), !s && !r.hideSpece && /* @__PURE__ */ n.jsx("span", { className: "tree-item-space" }), r.icon && /* @__PURE__ */ n.jsx("i", { className: "tree-item-icon", children: r.icon }), r.label ] }), s && i && /* @__PURE__ */ n.jsx("div", { className: "tree-item-content", children: r.children }) ] }); } var Br = /* @__PURE__ */ ((r) => (r[r.DEFAULT = 0] = "DEFAULT", r[r.DESC = 1] = "DESC", r[r.ASC = 2] = "ASC", r))(Br || {}); const Ke = Mr({ showLine: !0, showLevel: 0, showItems: 20, showInlineMax: 5, showIcon: !1, hideNonEnumerability: !1, sort: 0 /* DEFAULT */ }), J = () => Dr(Ke); function q({ type: r, descriptor: s }) { const i = s.value; return r === "object" ? i instanceof Date ? i.toISOString() : i instanceof RegExp ? i.toString() : i instanceof Set ? `Set(${i.size})` : i instanceof ArrayBuffer ? `ArrayBuffer(${i.byteLength})` : Fe(i) : r === "array" ? `Array(${i.length})` : r === "string" ? JSON.stringify(i) : r === "number" ? String(i) : r === "bigint" ? `${String(i)}n` : r === "boolean" ? String(i) : r === "null" ? "null" : r === "undefined" ? s.get ? "(...)" : s.set ? "ƒ setter(v)" : "undefined" : r === "symbol" ? i.toString() : r === "function" ? `${i}` : String(i); } function Ie({ type: r }) { return r === "object" ? /* @__PURE__ */ n.jsx($e, {}) : r === "array" ? /* @__PURE__ */ n.jsx(Be, {}) : r === "string" ? /* @__PURE__ */ n.jsx(We, {}) : r === "number" || r === "bigint" ? /* @__PURE__ */ n.jsx(He, {}) : r === "boolean" ? /* @__PURE__ */ n.jsx(Ye, {}) : r === "null" ? /* @__PURE__ */ n.jsx(Ue, {}) : r === "undefined" ? /* @__PURE__ */ n.jsx(Je, {}) : r === "symbol" ? /* @__PURE__ */ n.jsx(qe, {}) : r === "function" ? /* @__PURE__ */ n.jsx(Ge, {}) : null; } function Wr(r) { const s = J(), i = r.descriptor.value, x = s.showInlineMax, f = Math.min(x, i.length); return /* @__PURE__ */ n.jsxs("div", { className: "object-inline", children: [ /* @__PURE__ */ n.jsx("span", { className: "type-system", children: "(" }), i.length, /* @__PURE__ */ n.jsx("span", { className: "type-system", children: ")" }), /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: "[" }), /* @__PURE__ */ n.jsx("div", { className: "object-inline-items", children: i.slice(0, x).map((l, v) => { const y = se(l); return /* @__PURE__ */ n.jsxs(Le, { children: [ /* @__PURE__ */ n.jsx("span", { className: "type-" + y + " is-italic", children: q({ type: y, descriptor: { value: l, enumerable: !0 } }) }), v < f - 1 ? /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: ", " }) : i.length > f && /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: ", …" }) ] }, v); }) }), /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: "]" }) ] }); } function Hr(r) { const s = J(), i = r.descriptor.value, x = s.showInlineMax, f = Object.keys(i), l = Math.min(f.length, x), v = []; for (let y = 0; y < l; y++) { const d = f[y]; let b; try { b = se(i[d]); } catch { continue; } const g = Object.getOwnPropertyDescriptor(i, d); g && v.push(/* @__PURE__ */ n.jsxs(Le, { children: [ /* @__PURE__ */ n.jsx("span", { className: I(["type-property is-italic"]), children: d }), /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: ": " }), /* @__PURE__ */ n.jsx("span", { className: "type-" + b + " is-italic", children: q({ type: b, descriptor: { value: i[d], enumerable: g.enumerable } }) }), y < l - 1 ? /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: ", " }) : f.length > l && /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: ", …" }) ] }, y)); } return /* @__PURE__ */ n.jsxs("div", { className: "object-inline", children: [ i.constructor === Object ? null : /* @__PURE__ */ n.jsxs("span", { className: "is-italic", children: [ Fe(i), " " ] }), /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: "{" }), /* @__PURE__ */ n.jsx("div", { className: "object-inline-items", children: v }), /* @__PURE__ */ n.jsx("span", { className: "type-system is-italic", children: "}" }) ] }); } function Me(r) { const s = r.descriptor.value; return r.type === "array" ? /* @__PURE__ */ n.jsx(Wr, { type: r.type, descriptor: r.descriptor }) : r.type === "object" && !(s instanceof Date) && !(s instanceof RegExp) && !(s instanceof Set) && !(s instanceof ArrayBuffer) ? /* @__PURE__ */ n.jsx(Hr, { type: r.type, descriptor: r.descriptor }) : /* @__PURE__ */ n.jsx("span", { className: "type-value type-" + r.type, onClick: r.loadGetter, children: q({ type: r.type, descriptor: r.descriptor }) }); } function Yr(r) { const s = J(), [i, x] = U(s.showItems); let l = Y(() => Vr(r.object), [r.object]).filter((d) => s.hideNonEnumerability ? d.descriptor.enumerable : !0); s.sort && (l = l.sort((d, b) => s.sort === 1 ? d.key < b.key ? 1 : -1 : d.key > b.key ? 1 : -1)); const v = l.filter((d, b) => b < i), y = v.length < l.length; return /* @__PURE__ */ n.jsxs(n.Fragment, { children: [ v.map((d, b) => /* @__PURE__ */ n.jsx( Xe, { level: r.level + 1, field: d.key, descriptor: d.descriptor, top: r.top }, b )), y && /* @__PURE__ */ n.jsx("div", { children: /* @__PURE__ */ n.jsx("button", { className: "more-btn", title: "Load more", onClick: () => x(i + s.showItems), children: /* @__PURE__ */ n.jsx(ze, {}) }) }, "more") ] }); } function Xe(r) { const s = J(), [i, x] = U(r.descriptor), [f, l] = U(r.level < s.showLevel), v = Y(() => se(i.value), [i]), y = Y(() => { if (!s.showIcon) return null; let g; return s.renderTypeIcon ? g = s.renderTypeIcon(v, i, r.level, Ie) : g = /* @__PURE__ */ n.jsx(Ie, { type: v, descriptor: i }), g === null ? null : /* @__PURE__ */ n.jsx("i", { className: "type-icon", children: g }); }, [r.level, v, i, s.showIcon, s.renderTypeIcon]), d = v === "array" || v === "object" || v === "function", b = () => { if (!i.get) return; console.log(r.top); let g; try { g = i.get.call(r.top); } catch (T) { g = `[${T.message}]`; } const R = { ...i }; R.get = void 0, R.value = g, x(R); }; return ae(() => { x(r.descriptor); }, [r.descriptor]), ae(() => { l(r.level < s.showLevel); }, [r.level, s.showLevel]), /* @__PURE__ */ n.jsx( $r, { className: i.enumerable ? "" : "is-no-enumerable", label: /* @__PURE__ */ n.jsxs(n.Fragment, { children: [ r.field ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [ /* @__PURE__ */ n.jsx("span", { className: I(["type-property"]), children: r.field }), /* @__PURE__ */ n.jsx("span", { className: "type-system", children: ": " }) ] }) : null, s.renderValue ? s.renderValue(v, i, { level: r.level, expand: f, canExpand: d, loadGetter: b, setExpand: l, getValueString: q, DefaultRenderValue: Me }) : /* @__PURE__ */ n.jsx(Me, { type: v, descriptor: i, loadGetter: b }) ] }), icon: y, expand: f, onExpand: l, hideSpece: r.level === 0, canClickLabelExtend: s.canClickLabelExtend, children: d && /* @__PURE__ */ n.jsx( Yr, { level: r.level, object: i.value, top: r.field === "[[Prototype]]" ? r.top : i.value } ) } ); } function qr(r) { var s; return /* @__PURE__ */ n.jsxs(zr, { ...r.attrs, className: I(["object-viewer", (s = r.attrs) == null ? void 0 : s.className]), showLine: r.showLine, children: [ r.header, /* @__PURE__ */ n.jsx(Ke.Provider, { value: { showLine: !!r.showLine, showLevel: r.showLevel === void 0 ? 1 : r.showLevel, showItems: r.showItems || 20, showInlineMax: r.showInlineMax || 50, showIcon: !!r.showIcon, hideNonEnumerability: !!r.hideNonEnumerability, sort: r.sort === void 0 ? 0 : r.sort, canClickLabelExtend: !!r.canClickLabelExtend, renderValue: r.renderValue, renderTypeIcon: r.renderTypeIcon }, children: /* @__PURE__ */ n.jsx(Xe, { level: 0, descriptor: { enumerable: !0, value: r.value }, top: r.value }) }), r.footer ] }); } export { qr as ObjectViewer, Br as Sort, zr as Tree, $r as TreeItem, Jr as icons };