legend-state-dev-tools 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,1402 @@
1
+ import { jsx as c, jsxs as $, Fragment as vt } from "react/jsx-runtime";
2
+ import Tn, { useState as de, useEffect as Re, useRef as Ce, useMemo as De, useCallback as Ke, createContext as en, useContext as tn, Component as Nn } from "react";
3
+ import { createRoot as An } from "react-dom/client";
4
+ var ct = { exports: {} }, _n = ct.exports, Ht;
5
+ function Pn() {
6
+ return Ht || (Ht = 1, (function(t, e) {
7
+ (function(n, r) {
8
+ r(e);
9
+ })(_n, function(n) {
10
+ function r() {
11
+ return r = Object.assign ? Object.assign.bind() : function(f) {
12
+ for (var d = 1; d < arguments.length; d++) {
13
+ var l = arguments[d];
14
+ for (var m in l) Object.prototype.hasOwnProperty.call(l, m) && (f[m] = l[m]);
15
+ }
16
+ return f;
17
+ }, r.apply(this, arguments);
18
+ }
19
+ function o(f, d) {
20
+ f.prototype = Object.create(d.prototype), f.prototype.constructor = f, i(f, d);
21
+ }
22
+ function a(f) {
23
+ return a = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(d) {
24
+ return d.__proto__ || Object.getPrototypeOf(d);
25
+ }, a(f);
26
+ }
27
+ function i(f, d) {
28
+ return i = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(l, m) {
29
+ return l.__proto__ = m, l;
30
+ }, i(f, d);
31
+ }
32
+ function g(f, d, l) {
33
+ return g = (function() {
34
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
35
+ if (typeof Proxy == "function") return !0;
36
+ try {
37
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
38
+ })), !0;
39
+ } catch {
40
+ return !1;
41
+ }
42
+ })() ? Reflect.construct.bind() : function(m, E, k) {
43
+ var M = [null];
44
+ M.push.apply(M, E);
45
+ var L = new (Function.bind.apply(m, M))();
46
+ return k && i(L, k.prototype), L;
47
+ }, g.apply(null, arguments);
48
+ }
49
+ function h(f) {
50
+ var d = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
51
+ return h = function(l) {
52
+ if (l === null || Function.toString.call(l).indexOf("[native code]") === -1) return l;
53
+ if (typeof l != "function") throw new TypeError("Super expression must either be null or a function");
54
+ if (d !== void 0) {
55
+ if (d.has(l)) return d.get(l);
56
+ d.set(l, m);
57
+ }
58
+ function m() {
59
+ return g(l, arguments, a(this).constructor);
60
+ }
61
+ return m.prototype = Object.create(l.prototype, { constructor: { value: m, enumerable: !1, writable: !0, configurable: !0 } }), i(m, l);
62
+ }, h(f);
63
+ }
64
+ var s = /* @__PURE__ */ (function() {
65
+ function f(l) {
66
+ this.cache = void 0, this.cache = l;
67
+ }
68
+ var d = f.prototype;
69
+ return d.define = function(l, m) {
70
+ this.cache[l] = m;
71
+ }, d.get = function(l) {
72
+ return this.cache[l];
73
+ }, d.remove = function(l) {
74
+ delete this.cache[l];
75
+ }, d.reset = function() {
76
+ this.cache = {};
77
+ }, d.load = function(l) {
78
+ this.cache = r({}, this.cache, l);
79
+ }, f;
80
+ })(), u = /* @__PURE__ */ (function(f) {
81
+ function d(l) {
82
+ var m;
83
+ return (m = f.call(this, l) || this).name = "Eta Error", m;
84
+ }
85
+ return o(d, f), d;
86
+ })(/* @__PURE__ */ h(Error)), p = /* @__PURE__ */ (function(f) {
87
+ function d(l) {
88
+ var m;
89
+ return (m = f.call(this, l) || this).name = "EtaParser Error", m;
90
+ }
91
+ return o(d, f), d;
92
+ })(u), y = /* @__PURE__ */ (function(f) {
93
+ function d(l) {
94
+ var m;
95
+ return (m = f.call(this, l) || this).name = "EtaRuntime Error", m;
96
+ }
97
+ return o(d, f), d;
98
+ })(u), j = /* @__PURE__ */ (function(f) {
99
+ function d(l) {
100
+ var m;
101
+ return (m = f.call(this, l) || this).name = "EtaNameResolution Error", m;
102
+ }
103
+ return o(d, f), d;
104
+ })(u);
105
+ function b(f, d, l) {
106
+ var m = d.slice(0, l).split(/\n/), E = m.length, k = m[E - 1].length + 1;
107
+ throw f += " at line " + E + " col " + k + `:
108
+
109
+ ` + d.split(/\n/)[E - 1] + `
110
+ ` + Array(k).join(" ") + "^", new p(f);
111
+ }
112
+ function w(f, d, l, m) {
113
+ var E = d.split(`
114
+ `), k = Math.max(l - 3, 0), M = Math.min(E.length, l + 3), L = m, he = E.slice(k, M).map(function(je, Te) {
115
+ var re = Te + k + 1;
116
+ return (re == l ? " >> " : " ") + re + "| " + je;
117
+ }).join(`
118
+ `), U = new y((L ? L + ":" + l + `
119
+ ` : "line " + l + `
120
+ `) + he + `
121
+
122
+ ` + f.message);
123
+ throw U.name = f.name, U;
124
+ }
125
+ var T = (function() {
126
+ return Promise.resolve();
127
+ }).constructor;
128
+ function N(f, d) {
129
+ var l = this.config, m = d && d.async ? T : Function;
130
+ try {
131
+ return new m(l.varName, "options", this.compileToString.call(this, f, d));
132
+ } catch (E) {
133
+ throw E instanceof SyntaxError ? new p(`Bad template syntax
134
+
135
+ ` + E.message + `
136
+ ` + Array(E.message.length + 1).join("=") + `
137
+ ` + this.compileToString.call(this, f, d) + `
138
+ `) : E;
139
+ }
140
+ }
141
+ function x(f, d) {
142
+ var l = this.config, m = d && d.async, E = this.compileBody, k = this.parse.call(this, f), M = l.functionHeader + `
143
+ let include = (template, data) => this.render(template, data, options);
144
+ let includeAsync = (template, data) => this.renderAsync(template, data, options);
145
+
146
+ let __eta = {res: "", e: this.config.escapeFunction, f: this.config.filterFunction` + (l.debug ? ', line: 1, templateStr: "' + f.replace(/\\|"/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n") + '"' : "") + `};
147
+
148
+ function layout(path, data) {
149
+ __eta.layout = path;
150
+ __eta.layoutData = data;
151
+ }` + (l.debug ? "try {" : "") + (l.useWith ? "with(" + l.varName + "||{}){" : "") + `
152
+
153
+ ` + E.call(this, k) + `
154
+ if (__eta.layout) {
155
+ __eta.res = ` + (m ? "await includeAsync" : "include") + " (__eta.layout, {..." + l.varName + `, body: __eta.res, ...__eta.layoutData});
156
+ }
157
+ ` + (l.useWith ? "}" : "") + (l.debug ? "} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }" : "") + `
158
+ return __eta.res;
159
+ `;
160
+ if (l.plugins) for (var L = 0; L < l.plugins.length; L++) {
161
+ var he = l.plugins[L];
162
+ he.processFnString && (M = he.processFnString(M, l));
163
+ }
164
+ return M;
165
+ }
166
+ function P(f) {
167
+ for (var d = this.config, l = 0, m = f.length, E = ""; l < m; l++) {
168
+ var k = f[l];
169
+ if (typeof k == "string") E += "__eta.res+='" + k + `'
170
+ `;
171
+ else {
172
+ var M = k.t, L = k.val || "";
173
+ d.debug && (E += "__eta.line=" + k.lineNo + `
174
+ `), M === "r" ? (d.autoFilter && (L = "__eta.f(" + L + ")"), E += "__eta.res+=" + L + `
175
+ `) : M === "i" ? (d.autoFilter && (L = "__eta.f(" + L + ")"), d.autoEscape && (L = "__eta.e(" + L + ")"), E += "__eta.res+=" + L + `
176
+ `) : M === "e" && (E += L + `
177
+ `);
178
+ }
179
+ }
180
+ return E;
181
+ }
182
+ var G = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
183
+ function te(f) {
184
+ return G[f];
185
+ }
186
+ var Y = { autoEscape: !0, autoFilter: !1, autoTrim: [!1, "nl"], cache: !1, cacheFilepaths: !0, debug: !1, escapeFunction: function(f) {
187
+ var d = String(f);
188
+ return /[&<>"']/.test(d) ? d.replace(/[&<>"']/g, te) : d;
189
+ }, filterFunction: function(f) {
190
+ return String(f);
191
+ }, functionHeader: "", parse: { exec: "", interpolate: "=", raw: "~" }, plugins: [], rmWhitespace: !1, tags: ["<%", "%>"], useWith: !1, varName: "it", defaultExtension: ".eta" }, J = /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g, ee = /'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g, H = /"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;
192
+ function A(f) {
193
+ return f.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
194
+ }
195
+ function I(f, d) {
196
+ return f.slice(0, d).split(`
197
+ `).length;
198
+ }
199
+ function X(f) {
200
+ var d = this.config, l = [], m = !1, E = 0, k = d.parse;
201
+ if (d.plugins) for (var M = 0; M < d.plugins.length; M++) {
202
+ var L = d.plugins[M];
203
+ L.processTemplate && (f = L.processTemplate(f, d));
204
+ }
205
+ function he(ae, me) {
206
+ ae && (ae = (function(se, Oe, Ne, Ae) {
207
+ var ce, q;
208
+ return Array.isArray(Oe.autoTrim) ? (ce = Oe.autoTrim[1], q = Oe.autoTrim[0]) : ce = q = Oe.autoTrim, (Ne || Ne === !1) && (ce = Ne), (Ae || Ae === !1) && (q = Ae), q || ce ? ce === "slurp" && q === "slurp" ? se.trim() : (ce === "_" || ce === "slurp" ? se = se.trimStart() : ce !== "-" && ce !== "nl" || (se = se.replace(/^(?:\r\n|\n|\r)/, "")), q === "_" || q === "slurp" ? se = se.trimEnd() : q !== "-" && q !== "nl" || (se = se.replace(/(?:\r\n|\n|\r)$/, "")), se) : se;
209
+ })(ae, d, m, me), ae && (ae = ae.replace(/\\|'/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n"), l.push(ae)));
210
+ }
211
+ d.rmWhitespace && (f = f.replace(/[\r\n]+/g, `
212
+ `).replace(/^\s+|\s+$/gm, "")), J.lastIndex = 0, ee.lastIndex = 0, H.lastIndex = 0;
213
+ for (var U, je = [k.exec, k.interpolate, k.raw].reduce(function(ae, me) {
214
+ return ae && me ? ae + "|" + A(me) : me ? A(me) : ae;
215
+ }, ""), Te = new RegExp(A(d.tags[0]) + "(-|_)?\\s*(" + je + ")?\\s*", "g"), re = new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?" + A(d.tags[1]) + ")", "g"); U = Te.exec(f); ) {
216
+ var Me = f.slice(E, U.index);
217
+ E = U[0].length + U.index;
218
+ var Fe = U[2] || "";
219
+ he(Me, U[1]), re.lastIndex = E;
220
+ for (var z = void 0, ge = !1; z = re.exec(f); ) {
221
+ if (z[1]) {
222
+ var Se = f.slice(E, z.index);
223
+ Te.lastIndex = E = re.lastIndex, m = z[2], ge = { t: Fe === k.exec ? "e" : Fe === k.raw ? "r" : Fe === k.interpolate ? "i" : "", val: Se };
224
+ break;
225
+ }
226
+ var be = z[0];
227
+ if (be === "/*") {
228
+ var R = f.indexOf("*/", re.lastIndex);
229
+ R === -1 && b("unclosed comment", f, z.index), re.lastIndex = R;
230
+ } else be === "'" ? (ee.lastIndex = z.index, ee.exec(f) ? re.lastIndex = ee.lastIndex : b("unclosed string", f, z.index)) : be === '"' ? (H.lastIndex = z.index, H.exec(f) ? re.lastIndex = H.lastIndex : b("unclosed string", f, z.index)) : be === "`" && (J.lastIndex = z.index, J.exec(f) ? re.lastIndex = J.lastIndex : b("unclosed string", f, z.index));
231
+ }
232
+ ge ? (d.debug && (ge.lineNo = I(f, U.index)), l.push(ge)) : b("unclosed tag", f, U.index);
233
+ }
234
+ if (he(f.slice(E, f.length), !1), d.plugins) for (var B = 0; B < d.plugins.length; B++) {
235
+ var ie = d.plugins[B];
236
+ ie.processAST && (l = ie.processAST(l, d));
237
+ }
238
+ return l;
239
+ }
240
+ function ne(f, d) {
241
+ var l = d && d.async ? this.templatesAsync : this.templatesSync;
242
+ if (this.resolvePath && this.readFile && !f.startsWith("@")) {
243
+ var m = d.filepath, E = l.get(m);
244
+ if (this.config.cache && E) return E;
245
+ var k = this.readFile(m), M = this.compile(k, d);
246
+ return this.config.cache && l.define(m, M), M;
247
+ }
248
+ var L = l.get(f);
249
+ if (L) return L;
250
+ throw new j("Failed to get template '" + f + "'");
251
+ }
252
+ function pe(f, d, l) {
253
+ var m, E = r({}, l, { async: !1 });
254
+ return typeof f == "string" ? (this.resolvePath && this.readFile && !f.startsWith("@") && (E.filepath = this.resolvePath(f, E)), m = ne.call(this, f, E)) : m = f, m.call(this, d, E);
255
+ }
256
+ function oe(f, d, l) {
257
+ var m, E = r({}, l, { async: !0 });
258
+ typeof f == "string" ? (this.resolvePath && this.readFile && !f.startsWith("@") && (E.filepath = this.resolvePath(f, E)), m = ne.call(this, f, E)) : m = f;
259
+ var k = m.call(this, d, E);
260
+ return Promise.resolve(k);
261
+ }
262
+ function fe(f, d) {
263
+ var l = this.compile(f, { async: !1 });
264
+ return pe.call(this, l, d);
265
+ }
266
+ function le(f, d) {
267
+ var l = this.compile(f, { async: !0 });
268
+ return oe.call(this, l, d);
269
+ }
270
+ var Z = /* @__PURE__ */ (function() {
271
+ function f(l) {
272
+ this.config = void 0, this.RuntimeErr = w, this.compile = N, this.compileToString = x, this.compileBody = P, this.parse = X, this.render = pe, this.renderAsync = oe, this.renderString = fe, this.renderStringAsync = le, this.filepathCache = {}, this.templatesSync = new s({}), this.templatesAsync = new s({}), this.resolvePath = null, this.readFile = null, this.config = l ? r({}, Y, l) : r({}, Y);
273
+ }
274
+ var d = f.prototype;
275
+ return d.configure = function(l) {
276
+ this.config = r({}, this.config, l);
277
+ }, d.withConfig = function(l) {
278
+ return r({}, this, { config: r({}, this.config, l) });
279
+ }, d.loadTemplate = function(l, m, E) {
280
+ if (typeof m == "string") (E && E.async ? this.templatesAsync : this.templatesSync).define(l, this.compile(m, E));
281
+ else {
282
+ var k = this.templatesSync;
283
+ (m.constructor.name === "AsyncFunction" || E && E.async) && (k = this.templatesAsync), k.define(l, m);
284
+ }
285
+ }, f;
286
+ })(), Q = /* @__PURE__ */ (function(f) {
287
+ function d() {
288
+ return f.apply(this, arguments) || this;
289
+ }
290
+ return o(d, f), d;
291
+ })(Z);
292
+ n.Eta = Q;
293
+ });
294
+ })(ct, ct.exports)), ct.exports;
295
+ }
296
+ var Rn = /* @__PURE__ */ Pn();
297
+ const In = `<div class="lsdt-toolbar-header">
298
+ <div class="lsdt-toolbar-title">
299
+ <span class="lsdt-toolbar-indicator"></span>
300
+ Legend State
301
+ </div>
302
+ <button
303
+ class="lsdt-toggle-btn <%= it.panelVisible ? 'active' : '' %>"
304
+ data-action="toggle-panel"
305
+ title="<%= it.panelVisible ? 'Hide panel' : 'Show panel' %>"
306
+ >
307
+ <%= it.panelVisible ? 'Hide' : 'Show' %> <%= it.rootName %>
308
+ </button>
309
+ </div>
310
+ `, Ln = `<div class="lsdt-panel-header">
311
+ <h3><%= it.rootName %></h3>
312
+ <div class="lsdt-panel-actions">
313
+ <% if (it.readOnly) { %>
314
+ <span class="lsdt-readonly-badge">Read-only</span>
315
+ <% } %>
316
+ <button class="lsdt-close-btn" data-action="close-panel" title="Close">&times;</button>
317
+ </div>
318
+ </div>
319
+ <div class="lsdt-panel-content">
320
+ <div id="lsdt-json-editor-root"></div>
321
+ </div>
322
+ `, Vn = new Rn.Eta({
323
+ autoEscape: !0,
324
+ autoTrim: !1
325
+ }), Fn = {
326
+ toolbar: In,
327
+ panel: Ln
328
+ };
329
+ function nn(t, e) {
330
+ const n = Fn[t];
331
+ if (!n)
332
+ return console.error(`[LSDT] Template not found: ${t}`), "";
333
+ try {
334
+ return Vn.renderString(n, e);
335
+ } catch (r) {
336
+ return console.error(`[LSDT] Error rendering template ${t}:`, r), "";
337
+ }
338
+ }
339
+ function Kn(t) {
340
+ return nn("toolbar", t);
341
+ }
342
+ function Mn(t) {
343
+ return nn("panel", t);
344
+ }
345
+ const zn = "lsdt";
346
+ function Bn(t, e) {
347
+ const n = localStorage.getItem(`${zn}-${t}`);
348
+ return n === null ? e : n === "true";
349
+ }
350
+ function Wn() {
351
+ const t = [];
352
+ return {
353
+ add: (e) => t.push(e),
354
+ run: () => {
355
+ t.forEach((e) => {
356
+ try {
357
+ e();
358
+ } catch (n) {
359
+ console.error("[Legend State DevTools] Cleanup error:", n);
360
+ }
361
+ }), t.length = 0;
362
+ }
363
+ };
364
+ }
365
+ class $n {
366
+ constructor(e = {}) {
367
+ this.container = null, this.isDragging = !1, this.offsetX = 0, this.offsetY = 0, this.isMinimized = Bn("toolbar-minimized", !1), this.panelVisible = !1, this.handleClick = (n) => {
368
+ var i;
369
+ const o = n.target.closest("[data-action]");
370
+ if (!o) return;
371
+ o.getAttribute("data-action") === "toggle-panel" && ((i = this.onTogglePanel) == null || i.call(this));
372
+ }, this.handleMouseDown = (n) => {
373
+ if (n.target.tagName !== "BUTTON" && (this.isDragging = !0, this.container)) {
374
+ this.container.classList.add("dragging");
375
+ const o = this.container.getBoundingClientRect();
376
+ this.offsetX = n.clientX - o.left, this.offsetY = n.clientY - o.top;
377
+ }
378
+ }, this.handleMouseMove = (n) => {
379
+ !this.isDragging || !this.container || (this.container.style.left = `${n.clientX - this.offsetX}px`, this.container.style.top = `${n.clientY - this.offsetY}px`, this.container.style.right = "auto", this.container.style.bottom = "auto");
380
+ }, this.handleMouseUp = () => {
381
+ var n;
382
+ this.isDragging = !1, (n = this.container) == null || n.classList.remove("dragging");
383
+ }, this.onTogglePanel = e.onTogglePanel, this.rootName = e.rootName || "state$";
384
+ }
385
+ mount() {
386
+ this.container || (this.container = document.createElement("div"), this.container.id = "lsdt-toolbar", this.isMinimized && this.container.classList.add("lsdt-toolbar-minimized"), document.body.appendChild(this.container), this.render(), this.attachEventListeners());
387
+ }
388
+ render() {
389
+ if (!this.container) return;
390
+ const e = {
391
+ isMinimized: this.isMinimized,
392
+ panelVisible: this.panelVisible,
393
+ rootName: this.rootName
394
+ };
395
+ this.container.innerHTML = Kn(e);
396
+ }
397
+ attachEventListeners() {
398
+ this.container && (this.container.addEventListener("click", this.handleClick), this.container.addEventListener("mousedown", this.handleMouseDown), document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("mouseup", this.handleMouseUp));
399
+ }
400
+ setPanelVisible(e) {
401
+ this.panelVisible = e, this.render();
402
+ }
403
+ unmount() {
404
+ this.container && (this.container.removeEventListener("click", this.handleClick), this.container.removeEventListener("mousedown", this.handleMouseDown), this.container.remove(), this.container = null), document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp);
405
+ }
406
+ }
407
+ class Gn {
408
+ constructor(e = {}) {
409
+ this.container = null, this.visible = !1, this.handleClick = (n) => {
410
+ var i;
411
+ const o = n.target.closest("[data-action]");
412
+ if (!o) return;
413
+ o.getAttribute("data-action") === "close-panel" && ((i = this.onClose) == null || i.call(this));
414
+ }, this.rootName = e.rootName || "state$", this.readOnly = e.readOnly || !1, this.onClose = e.onClose, this.position = e.position || "right";
415
+ }
416
+ toggle() {
417
+ this.visible ? this.hide() : this.show();
418
+ }
419
+ show() {
420
+ this.visible = !0, this.container || (this.container = document.createElement("div"), this.container.id = "lsdt-panel", this.position === "left" && this.container.classList.add("lsdt-panel-left"), document.body.appendChild(this.container), this.attachEventListeners()), this.render();
421
+ }
422
+ hide() {
423
+ var e;
424
+ this.visible = !1, (e = this.container) == null || e.remove(), this.container = null;
425
+ }
426
+ isVisible() {
427
+ return this.visible;
428
+ }
429
+ getEditorRoot() {
430
+ var e;
431
+ return ((e = this.container) == null ? void 0 : e.querySelector("#lsdt-json-editor-root")) || null;
432
+ }
433
+ render() {
434
+ if (!this.container) return;
435
+ const e = {
436
+ rootName: this.rootName,
437
+ readOnly: this.readOnly
438
+ };
439
+ this.container.innerHTML = Mn(e);
440
+ }
441
+ attachEventListeners() {
442
+ this.container && this.container.addEventListener("click", this.handleClick);
443
+ }
444
+ unmount() {
445
+ this.container && (this.container.removeEventListener("click", this.handleClick), this.container.remove(), this.container = null), this.visible = !1;
446
+ }
447
+ }
448
+ function Hn(t, e) {
449
+ const n = () => {
450
+ try {
451
+ return JSON.parse(JSON.stringify(t.peek()));
452
+ } catch {
453
+ return;
454
+ }
455
+ };
456
+ let r = null;
457
+ try {
458
+ r = t.onChange(
459
+ () => {
460
+ const o = n();
461
+ e.onSnapshot(o);
462
+ },
463
+ { trackingType: !1 }
464
+ );
465
+ } catch {
466
+ console.warn("[Legend State DevTools] Could not subscribe to observable changes via onChange");
467
+ }
468
+ return {
469
+ getSnapshot: n,
470
+ setData: (o) => {
471
+ try {
472
+ t.set(o);
473
+ } catch (a) {
474
+ console.error("[Legend State DevTools] Failed to set data:", a);
475
+ }
476
+ },
477
+ destroy: () => {
478
+ r && (r(), r = null);
479
+ }
480
+ };
481
+ }
482
+ const He = (t, e, n, r, o) => {
483
+ if (!r) throw new Error(o ?? `Invalid property path: ${e}
484
+ Couldn't access "${n}" in ${JSON.stringify(t)}`);
485
+ }, Ut = (t) => typeof t == "object" && t !== null && !Array.isArray(t), mt = (t) => Array.isArray(t), rn = (t, e) => t.filter(((n, r) => r !== e)), Un = (t, e, n, r = {}) => {
486
+ const { remove: o = !1, createNew: a = !0, noError: i = !1 } = r, g = t, h = typeof (s = e) == "string" ? s : typeof s == "number" ? String(s) : s.reduce(((y, j) => typeof j == "number" ? `${y}[${j}]` : y === "" ? j : `${y}.${j}`), "");
487
+ var s;
488
+ const u = Object.assign(Object.assign({}, r), { remove: o, createNew: a, noError: i, fullData: g, fullPath: h }), p = Array.isArray(e) ? e : ((y) => Array.isArray(y) ? y : y.split(/(\.|\[\d+\])/).filter(((j) => j !== "." && j !== "")).map(((j) => {
489
+ const b = /\[(\d+)\]/.exec(j);
490
+ return b ? Number(b[1]) : j;
491
+ })).flat())(e).filter(((y) => y !== ""));
492
+ return mt(t) && o && p.length === 1 ? rn(t, p[0]) : ut(t, p, n, u);
493
+ }, ut = (t, e, n, r) => {
494
+ const o = Ut(t) ? Object.assign({}, t) : null, a = mt(t) ? [...t] : null;
495
+ if (e.length === 0) return t;
496
+ if (!o && !a) throw new Error("Can't assign property -- invalid input object");
497
+ const { createNew: i, remove: g, noError: h, fullData: s, fullPath: u } = r, p = e[0];
498
+ if (a && typeof p == "string") return a.map(((w) => ut(w, e, n, r)));
499
+ if (e.length === 1) {
500
+ if (o && typeof p == "string") {
501
+ const w = Yn(o, p, n, r);
502
+ return w ?? o;
503
+ }
504
+ return a && typeof p == "number" ? (Jn(a, p, n, r), a) : (He(s, u, p, h), t);
505
+ }
506
+ const y = o || a || [];
507
+ if (g && e.length === 2 && typeof e[1] == "number") {
508
+ const w = y[p], T = e[1];
509
+ return mt(w) ? y[p] = rn(w, T) : He(s, u, p, h, "Trying to remove an indexed item from an object that is not an array"), y;
510
+ }
511
+ const j = e.slice(1);
512
+ if (p in t) {
513
+ if (b = y[p], !mt(b) && !Ut(b)) {
514
+ if (!i) return He(s, u, p, h), y;
515
+ y[p] = {};
516
+ }
517
+ return y[p] = ut(y[p], j, n, r), y;
518
+ }
519
+ var b;
520
+ if (i) {
521
+ const w = typeof j[0] == "number" ? [] : {};
522
+ if (o) return y[p] = w, y[p] = ut(y[p], j, n, r), y;
523
+ if (a && Array.isArray(y)) {
524
+ y.push(w);
525
+ const T = y.length - 1;
526
+ return y[T] = ut(y[T], j, n, r), y;
527
+ }
528
+ }
529
+ return He(s, u, p, h), y;
530
+ }, Yn = (t, e, n, r) => {
531
+ const { remove: o, createNew: a, noError: i, insertAfter: g, insertBefore: h, fullData: s, fullPath: u } = r;
532
+ if (h !== void 0 || g !== void 0) {
533
+ const y = Object.entries(t);
534
+ let j = 1 / 0;
535
+ return j = typeof h == "number" ? h : typeof g == "number" ? g : y.findIndex((([b, w]) => b === (h ?? g))), g && j++, y.splice(j, 0, [e, n]), Object.fromEntries(y);
536
+ }
537
+ const p = e in t;
538
+ o ? p ? delete t[e] : He(s, u, e, i) : a || p ? t[e] = n : He(s, u, e, i);
539
+ }, Jn = (t, e, n, r) => {
540
+ const { noError: o, fullData: a, fullPath: i, createNew: g, insert: h } = r;
541
+ h && t.splice(e, 0, n), e in t ? t[e] = n : g ? t.push(n) : He(a, i, e, o);
542
+ }, nt = (t, e, n) => {
543
+ const r = Array.isArray(e) ? e : Xn(e);
544
+ if (r.length === 0) return t;
545
+ const o = r[0];
546
+ if (Array.isArray(t) && typeof o != "number") return t.map(((i) => nt(i, r)));
547
+ if (typeof t != "object" || t === null || !(o in t)) return Zn(t, o);
548
+ const a = t[o];
549
+ return r.length === 1 ? a : nt(a, r.slice(1));
550
+ }, Xn = (t) => t.split(/(\.|\[\d+\])/).filter(((e) => e !== "." && e !== "")).map(((e) => {
551
+ const n = /\[(\d+)\]/.exec(e);
552
+ return n ? Number(n[1]) : e;
553
+ })).flat(), Zn = (t, e, n) => {
554
+ throw new Error(`Unable to extract object property
555
+ Looking for property: ${e}
556
+ In object: ${JSON.stringify(t)}`);
557
+ };
558
+ function on(t, e) {
559
+ var n = {};
560
+ for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
561
+ if (t != null && typeof Object.getOwnPropertySymbols == "function") {
562
+ var o = 0;
563
+ for (r = Object.getOwnPropertySymbols(t); o < r.length; o++) e.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[o]) && (n[r[o]] = t[r[o]]);
564
+ }
565
+ return n;
566
+ }
567
+ function tt(t, e, n, r) {
568
+ return new (n || (n = Promise))((function(o, a) {
569
+ function i(s) {
570
+ try {
571
+ h(r.next(s));
572
+ } catch (u) {
573
+ a(u);
574
+ }
575
+ }
576
+ function g(s) {
577
+ try {
578
+ h(r.throw(s));
579
+ } catch (u) {
580
+ a(u);
581
+ }
582
+ }
583
+ function h(s) {
584
+ var u;
585
+ s.done ? o(s.value) : (u = s.value, u instanceof n ? u : new n((function(p) {
586
+ p(u);
587
+ }))).then(i, g);
588
+ }
589
+ h((r = r.apply(t, [])).next());
590
+ }));
591
+ }
592
+ const an = ({ className: t, name: e, value: n, setValue: r, handleKeyPress: o, styles: a, textAreaRef: i }) => {
593
+ if (typeof n != "string") return null;
594
+ const g = n.slice(-1) === `
595
+ ` ? n + "." : n;
596
+ return $("div", { style: { display: "grid" }, children: [c("textarea", { id: `${e}_textarea`, ref: i, style: Object.assign({ height: "auto", gridArea: "1 / 1 / 2 / 2", overflowY: "auto", whiteSpace: "pre-wrap" }, a), rows: 1, className: t, name: `${e}_textarea`, value: n, onChange: (h) => r(h.target.value), autoFocus: !0, onFocus: (h) => {
597
+ n.length < 40 && h.target.select();
598
+ }, onKeyDown: o }), c("span", { className: t, style: Object.assign({ visibility: "hidden", height: "auto", gridArea: "1 / 1 / 2 / 2", color: "red", opacity: 0.9, whiteSpace: "pre-wrap", overflowY: "auto", border: "1px solid transparent" }, a), children: g })] });
599
+ }, rt = (t) => t !== null && typeof t == "object", sn = (t, e, n, r = "") => {
600
+ if (!n && !r) return !0;
601
+ switch (t) {
602
+ case "collection":
603
+ if (n) {
604
+ if (n(e, r)) return !0;
605
+ if (!Tt(r, e, n)) return !1;
606
+ }
607
+ if (!n && r && !Tt(r, e)) return !1;
608
+ break;
609
+ case "value":
610
+ if (n && !n(e, r) || !n && r && !ot(e, r)) return !1;
611
+ }
612
+ return !0;
613
+ }, Tt = (t = "", e, n = ot) => {
614
+ const r = e.value;
615
+ return Object.entries(r).some((([o, a]) => {
616
+ const i = [...e.path, o], g = Object.assign(Object.assign({}, e), { key: o, path: i, level: e.level + 1, value: a, size: i.length, parentData: r });
617
+ return rt(a) ? Tt(t, g, n) : n(g, t);
618
+ }));
619
+ }, ot = (t, e = "") => {
620
+ const { value: n } = t;
621
+ if (n === null && "null".includes(e.toLowerCase())) return !0;
622
+ switch (typeof n) {
623
+ case "string":
624
+ return n.toLowerCase().includes(e.toLowerCase());
625
+ case "number":
626
+ return !!String(n).includes(e);
627
+ case "boolean":
628
+ return n ? "true".includes(e.toLowerCase()) || e === "1" : "false".includes(e.toLowerCase()) || e === "0";
629
+ default:
630
+ return !1;
631
+ }
632
+ }, Yt = ({ key: t, path: e }, n = "") => !!ot({ value: t }, n) || !!e.some(((r) => ot({ value: r }, n))), Xe = (t, e) => (e ?? "") + t.map(((n) => n === "" ? "\0" : n)).join("."), Pt = (t) => t.shiftKey ? "Shift" : t.metaKey ? "Meta" : t.ctrlKey ? "Control" : t.altKey ? "Alt" : void 0, Qn = (t, e, n) => {
633
+ const r = t.key, o = Pt(t);
634
+ if (Array.isArray(e)) return !!o && e.includes(o);
635
+ const { key: a, modifier: i } = e;
636
+ return (n !== "stringLineBreak" || r !== "Enter" || o !== "Shift" || a !== "Enter" || !(i != null && i.includes("Shift"))) && r === a && (i === o || Array.isArray(i) && i.includes(o));
637
+ }, Ge = { key: "Enter" }, Jt = { confirm: Ge, cancel: { key: "Escape" }, objectConfirm: Object.assign(Object.assign({}, Ge), { modifier: ["Meta", "Shift", "Control"] }), objectLineBreak: Ge, stringConfirm: Ge, stringLineBreak: Object.assign(Object.assign({}, Ge), { modifier: ["Shift"] }), numberConfirm: Ge, numberUp: { key: "ArrowUp" }, numberDown: { key: "ArrowDown" }, tabForward: { key: "Tab" }, tabBack: { key: "Tab", modifier: "Shift" }, booleanConfirm: Ge, booleanToggle: { key: " " }, clipboardModifier: ["Meta", "Control"], collapseModifier: ["Alt"] }, Ue = (t, e, n = "next", r) => {
638
+ const o = e.slice(0, e.length - 1), a = e.slice(-1)[0];
639
+ if (a === void 0) return null;
640
+ const i = nt(t, o), g = qn(i);
641
+ Array.isArray(i) || r(g, (({ key: u, value: p }) => [u, p]));
642
+ const h = g.findIndex(((u) => u.key === a)), s = g[h + (n === "next" ? 1 : -1)];
643
+ return s ? rt(s.value) ? Object.keys(s.value).length === 0 ? Ue(t, [...o, s.key], n, r) : ln(t, [...o, s.key], n, r) : [...o, s.key] : o.length === 0 ? null : Ue(t, o, n, r);
644
+ }, ln = (t, e, n = "next", r) => {
645
+ const o = nt(t, e);
646
+ if (!rt(o)) return e;
647
+ const a = Array.isArray(o) ? o.map(((g, h) => h)) : Object.keys(o);
648
+ r(a, ((g) => [g, o]));
649
+ const i = n === "next" ? a[0] : a[a.length - 1];
650
+ return ln(t, [...e, i], n, r);
651
+ }, qn = (t) => Array.isArray(t) ? t.map(((e, n) => ({ index: n, value: e, key: n }))) : Object.entries(t).map((([e, n], r) => ({ key: e, value: n, index: r }))), cn = (t, e) => {
652
+ var n, r, o, a;
653
+ const i = t.current, g = (n = i == null ? void 0 : i.selectionStart) !== null && n !== void 0 ? n : 1 / 0, h = (r = i == null ? void 0 : i.selectionEnd) !== null && r !== void 0 ? r : 1 / 0, s = ((o = i == null ? void 0 : i.textContent) === null || o === void 0 ? void 0 : o.slice(0, g)) + e + ((a = i == null ? void 0 : i.textContent) === null || a === void 0 ? void 0 : a.slice(h));
654
+ return i.value = s, i == null || i.setSelectionRange(g + 1, g + 1), s;
655
+ }, Nt = (t) => {
656
+ if (t !== un) {
657
+ if (Array.isArray(t)) return t.map(((e) => Nt(e)));
658
+ if (t && typeof t == "object") for (const e in t) t[e] = Nt(t[e]);
659
+ return t;
660
+ }
661
+ }, un = "__​undefined__", Rt = { displayName: "Default", fragments: { edit: "rgb(42, 161, 152)" }, styles: { container: { backgroundColor: "#f6f6f6", fontFamily: "monospace" }, collection: {}, collectionInner: {}, collectionElement: {}, dropZone: {}, property: "#292929", bracket: { color: "rgb(0, 43, 54)", fontWeight: "bold" }, itemCount: { color: "rgba(0, 0, 0, 0.3)", fontStyle: "italic" }, string: "rgb(203, 75, 22)", number: "rgb(38, 139, 210)", boolean: "green", null: { color: "rgb(220, 50, 47)", fontVariant: "small-caps", fontWeight: "bold" }, input: ["#292929"], inputHighlight: "#b3d8ff", error: { fontSize: "0.8em", color: "red", fontWeight: "bold" }, iconCollection: "rgb(0, 43, 54)", iconEdit: "edit", iconDelete: "rgb(203, 75, 22)", iconAdd: "edit", iconCopy: "rgb(38, 139, 210)", iconOk: "green", iconCancel: "rgb(203, 75, 22)" } }, dn = en({ getStyles: () => ({}), icons: {} }), er = ({ theme: t = Rt, icons: e = {}, docRoot: n, children: r }) => {
662
+ const o = tr(t, n);
663
+ return c(dn.Provider, { value: { getStyles: (a, i) => typeof o[a] == "function" ? o[a](i) : o[a], icons: e }, children: r });
664
+ }, Ve = () => tn(dn), tr = (t, e) => {
665
+ var n, r, o, a;
666
+ const i = {}, g = (Array.isArray(t) ? t : [t]).map(((u) => nr(u) ? xt({ fragments: {}, styles: u }, i) : xt(u, i))), h = xt(Rt, {});
667
+ Object.keys(h).forEach(((u) => {
668
+ const p = u;
669
+ g.forEach(((y) => {
670
+ y[p] && (h[p] = Object.assign(Object.assign({}, h[p]), y[p]));
671
+ }));
672
+ }));
673
+ const s = Object.assign({}, h);
674
+ return Object.entries(i).forEach((([u, p]) => {
675
+ const y = u;
676
+ s[y] = (j) => {
677
+ const b = p(j) || {};
678
+ return Object.assign(Object.assign({}, h[y]), b);
679
+ };
680
+ })), typeof (s == null ? void 0 : s.inputHighlight) != "function" && (!((n = s == null ? void 0 : s.inputHighlight) === null || n === void 0) && n.backgroundColor) && e.style.setProperty("--jer-highlight-color", (r = s == null ? void 0 : s.inputHighlight) === null || r === void 0 ? void 0 : r.backgroundColor), typeof (s == null ? void 0 : s.iconCopy) != "function" && (!((o = s == null ? void 0 : s.iconCopy) === null || o === void 0) && o.color) && e.style.setProperty("--jer-icon-copy-color", (a = s == null ? void 0 : s.iconCopy) === null || a === void 0 ? void 0 : a.color), s;
681
+ }, xt = (t, e) => {
682
+ const { fragments: n, styles: r } = t, o = {};
683
+ return Object.entries(r).forEach((([a, i]) => {
684
+ const g = (Array.isArray(i) ? i : [i]).reduce(((h, s) => {
685
+ var u, p;
686
+ if (typeof s == "function") return e[a] = s, Object.assign({}, h);
687
+ if (typeof s == "string") {
688
+ const y = (u = n == null ? void 0 : n[s]) !== null && u !== void 0 ? u : s;
689
+ return typeof y == "string" ? Object.assign(Object.assign({}, h), { [(p = rr[a]) !== null && p !== void 0 ? p : "color"]: y }) : Object.assign(Object.assign({}, h), y);
690
+ }
691
+ return Object.assign(Object.assign({}, h), s);
692
+ }), {});
693
+ o[a] = g;
694
+ })), o;
695
+ }, nr = (t) => !("styles" in t), rr = { container: "backgroundColor", collection: "backgroundColor", collectionInner: "backgroundColor", collectionElement: "backgroundColor", dropZone: "borderColor", inputHighlight: "backgroundColor" }, hn = en(null), or = ({ children: t, onEditEvent: e, onCollapse: n }) => {
696
+ const [r, o] = de(null), [a, i] = de(null), [g, h] = de(null), [s, u] = de({ path: null, pathString: null }), p = Ce(null), y = Ce("next"), j = Ce(null);
697
+ return c(hn.Provider, { value: { collapseState: r, setCollapseState: (b) => {
698
+ o(b), n && b !== null && (Array.isArray(b) ? b.forEach(((w) => n(w))) : n(b)), b !== null && setTimeout((() => o(null)), 2e3);
699
+ }, getMatchingCollapseState: (b) => {
700
+ if (Array.isArray(r)) {
701
+ for (const w of r) if (Xt(b, w)) return w;
702
+ return null;
703
+ }
704
+ return Xt(b, r) ? r : null;
705
+ }, currentlyEditingElement: a, setCurrentlyEditingElement: (b, w) => {
706
+ const T = typeof b == "string" || b === null ? b : Xe(b, w === "key" ? "key_" : void 0);
707
+ a !== null && T !== null && p.current !== null && p.current(), i(T), e && (Array.isArray(b) || b === null) && e(b, w === "key"), p.current = typeof w == "function" ? w : null;
708
+ }, areChildrenBeingEdited: (b) => a !== null && a.includes(b), previouslyEditedElement: j.current, setPreviouslyEditedElement: (b) => {
709
+ j.current = b;
710
+ }, tabDirection: y.current, setTabDirection: (b) => {
711
+ y.current = b;
712
+ }, previousValue: g, setPreviousValue: h, dragSource: s, setDragSource: u }, children: t });
713
+ }, Je = () => {
714
+ const t = tn(hn);
715
+ if (!t) throw new Error("Missing Context Provider");
716
+ return t;
717
+ }, Xt = (t, e) => {
718
+ if (e === null) return !1;
719
+ if (!e.includeChildren) return e.path.every(((n, r) => t[r] === n)) && e.path.length === t.length;
720
+ for (const [n, r] of e.path.entries()) if (r !== t[n]) return !1;
721
+ return !0;
722
+ }, At = "**INVALID_FUNCTION**", ir = ({ nodeData: t, showStringQuotes: e = !0, stringTruncate: n = 200, pathString: r, canEdit: o, setIsEditing: a, styles: i, translate: g, value: h, TextWrapper: s = ({ children: u }) => u }) => {
723
+ const u = h ?? t.value, [p, y] = de(!1), j = e ? '"' : "", b = u.length > n, w = () => {
724
+ o ? a(!0) : y(!p);
725
+ };
726
+ return $("div", { id: `${r}_display`, onDoubleClick: w, onClick: (T) => {
727
+ (T.getModifierState("Control") || T.getModifierState("Meta")) && w();
728
+ }, className: "jer-value-string", style: i, children: [j, b ? $(vt, p ? { children: [c(s, { children: $("span", { children: [u, j] }) }), $("span", { className: "jer-string-expansion jer-show-less", onClick: () => y(!1), children: [" ", g("SHOW_LESS", t)] })] } : { children: [$(s, { children: [c("span", { children: u.slice(0, n - 2).trimEnd() }), " "] }), c("span", { className: "jer-string-expansion jer-ellipsis", onClick: () => y(!0), children: "..." }), j] }) : c(s, { children: `${u}${j}` })] });
729
+ }, ar = ({ styles: t, pathString: e, value: n, setValue: r, handleEdit: o, handleKeyboard: a, keyboardCommon: i }) => {
730
+ const g = Ce(null);
731
+ return c(an, { className: "jer-input-text", textAreaRef: g, name: e, value: n, setValue: r, handleKeyPress: (h) => {
732
+ a(h, Object.assign({ stringConfirm: o, stringLineBreak: () => {
733
+ const s = cn(g, `
734
+ `);
735
+ r(s);
736
+ } }, i));
737
+ }, styles: t });
738
+ }, sr = (t) => {
739
+ var { isEditing: e, path: n, enumType: r } = t, o = on(t, ["isEditing", "path", "enumType"]);
740
+ const { getStyles: a } = Ve(), i = Xe(n), { value: g, setValue: h, nodeData: s, handleEdit: u, handleKeyboard: p, keyboardCommon: y } = o;
741
+ return e && r ? $("div", { className: "jer-select jer-select-enums", children: [c("select", { name: `${i}-value-select`, className: "jer-select-inner", onChange: (j) => h(j.target.value), value: g, autoFocus: !0, onKeyDown: (j) => {
742
+ p(j, Object.assign({ stringConfirm: u }, y));
743
+ }, children: r.values.map(((j) => c("option", { value: j, children: j }, j))) }), c("span", { className: "focus" })] }) : e ? c(ar, Object.assign({ styles: a("input", s), pathString: i }, o, { setValue: o.setValue })) : c(ir, Object.assign({ pathString: i, styles: a("string", s) }, o));
744
+ }, lr = ({ value: t, setValue: e, isEditing: n, path: r, setIsEditing: o, handleEdit: a, nodeData: i, handleKeyboard: g, keyboardCommon: h }) => {
745
+ const { getStyles: s } = Ve();
746
+ return n ? c("input", { className: "jer-input-number", type: "text", name: Xe(r), value: t, onChange: (u) => e(u.target.value.replace(/[^0-9.-]/g, "")), autoFocus: !0, onFocus: (u) => setTimeout((() => u.target.select()), 10), onKeyDown: (u) => g(u, Object.assign({ numberConfirm: a, numberUp: () => e(Number(t) + 1), numberDown: () => e(Number(t) - 1) }, h)), style: Object.assign({ width: String(t).length / 1.5 + 2 + "em" }, s("input", i)) }) : c("span", { onDoubleClick: () => o(!0), className: "jer-value-number", style: s("number", i), children: t });
747
+ }, cr = ({ value: t, setValue: e, isEditing: n, path: r, setIsEditing: o, handleEdit: a, nodeData: i, handleKeyboard: g, keyboardCommon: h }) => {
748
+ const { getStyles: s } = Ve();
749
+ return typeof t != "boolean" ? null : n ? c("input", { className: "jer-input-boolean", type: "checkbox", name: Xe(r), checked: t, onChange: () => e(!t), onKeyDown: (u) => {
750
+ u.key === " " && u.preventDefault(), g(u, Object.assign({ booleanConfirm: a, booleanToggle: () => e(!t) }, h));
751
+ }, autoFocus: !0 }) : c("span", { onDoubleClick: () => o(!0), className: "jer-value-boolean", style: s("boolean", i), children: String(t) });
752
+ }, ur = (t, e) => {
753
+ const n = Ce(void 0), r = Ce(e);
754
+ Re((() => {
755
+ r.current = e;
756
+ }), [e]);
757
+ const o = (a) => {
758
+ r.current(a);
759
+ };
760
+ Re((() => {
761
+ if (window.clearTimeout(n.current), t) return n.current = window.setTimeout((() => {
762
+ window.addEventListener("keydown", o);
763
+ }), 100), () => {
764
+ window.clearTimeout(n.current), window.removeEventListener("keydown", o);
765
+ };
766
+ }), [t]);
767
+ }, dr = ({ value: t, isEditing: e, setIsEditing: n, handleEdit: r, nodeData: o, handleKeyboard: a, keyboardCommon: i }) => {
768
+ const { getStyles: g } = Ve();
769
+ return ur(e, ((h) => a(h, Object.assign({ confirm: r }, i)))), c("div", { onDoubleClick: () => n(!0), className: "jer-value-null", style: g("null", o), children: String(t) });
770
+ }, hr = ({ value: t }) => {
771
+ let e = "Error!";
772
+ switch (typeof t) {
773
+ case "string":
774
+ t === At && (e = "Function");
775
+ break;
776
+ case "undefined":
777
+ e = "Undefined";
778
+ break;
779
+ case "symbol":
780
+ e = "Symbol";
781
+ }
782
+ return c("span", { className: "jer-value-invalid", children: e });
783
+ }, pr = ({ size: t, style: e, className: n }) => $("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: t, height: t, className: n, style: e, children: [c("path", { d: "M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z" }), c("path", { d: "M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z" })] }), fr = ({ size: t, style: e, className: n }) => $("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: t, height: t, className: n, style: e, transform: "translate(0, 0.5)", children: [c("path", { d: "M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z" }), c("path", { d: "M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z" })] }), gr = ({ size: t, style: e, className: n }) => c("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: t, height: t, className: n, style: e, children: c("path", { d: "M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z" }) }), mr = ({ size: t, style: e, className: n }) => $("svg", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, viewBox: "0 0 24 24", width: t, height: t, className: n, style: e, children: [c("path", { d: "M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z" }), c("path", { d: "M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11" }), c("path", { d: "M15 10l-4 4 4 4" })] }), yr = ({ size: t, style: e, className: n }) => $("svg", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, viewBox: "0 0 24 24", width: t, height: t, className: n, style: e, children: [c("path", { d: "M22 11.08V12a10 10 0 11-5.93-9.14" }), c("path", { d: "M22 4L12 14.01l-3-3" })] }), vr = ({ size: t, style: e, className: n }) => c("svg", { baseProfile: "tiny", viewBox: "0 0 24 24", fill: "currentColor", width: t, height: t, className: n, style: e, children: c("path", { d: "M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z" }) }), br = ({ size: t, style: e, className: n }) => c("svg", { viewBox: "0 0 512 512", fill: "currentColor", width: t, height: t, className: n, style: e, children: c("path", { d: "M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z" }) }), Ye = ({ name: t, nodeData: e }) => {
784
+ var n, r, o, a, i, g, h;
785
+ const { getStyles: s, icons: u } = Ve(), p = { size: "1.4em", className: "jer-icon" };
786
+ switch (t) {
787
+ case "add":
788
+ return (n = u == null ? void 0 : u.add) !== null && n !== void 0 ? n : c(pr, Object.assign({}, p, { style: s("iconAdd", e) }));
789
+ case "edit":
790
+ return (r = u == null ? void 0 : u.edit) !== null && r !== void 0 ? r : c(fr, Object.assign({}, p, { style: s("iconEdit", e) }));
791
+ case "delete":
792
+ return (o = u == null ? void 0 : u.delete) !== null && o !== void 0 ? o : c(gr, Object.assign({}, p, { style: s("iconDelete", e), size: "1.45em" }));
793
+ case "copy":
794
+ return (a = u == null ? void 0 : u.copy) !== null && a !== void 0 ? a : c(mr, Object.assign({}, p, { style: s("iconCopy", e), size: "1.2em" }));
795
+ case "ok":
796
+ return (i = u == null ? void 0 : u.ok) !== null && i !== void 0 ? i : c(yr, Object.assign({}, p, { style: Object.assign({ fontSize: "90%" }, s("iconOk", e)) }));
797
+ case "cancel":
798
+ return (g = u == null ? void 0 : u.cancel) !== null && g !== void 0 ? g : c(vr, Object.assign({}, p, { style: Object.assign({ fontSize: "130%" }, s("iconCancel", e)) }));
799
+ case "chevron":
800
+ return (h = u == null ? void 0 : u.chevron) !== null && h !== void 0 ? h : c(br, { size: "1em", style: s("iconCollection", e) });
801
+ default:
802
+ return c(vt, {});
803
+ }
804
+ }, pn = ({ startEdit: t, handleDelete: e, handleAdd: n, enableClipboard: r, type: o, customButtons: a, nodeData: i, translate: g, keyboardControls: h, handleKeyboard: s, editConfirmRef: u, getNewKeyOptions: p, jsonStringify: y, onEditEvent: j, showIconTooltips: b }) => {
805
+ const { getStyles: w } = Ve(), T = g("KEY_NEW", i), [N, x] = de(T), [P, G] = de(!1), { key: te, path: Y, value: J } = i, ee = Array.isArray(P), H = (A) => {
806
+ var I;
807
+ if (j && j(A ? [...Y, null] : null, A), !A) return void G(!1);
808
+ const X = Object.keys(nt(i.fullData, Y)), ne = p ? (I = p(i)) === null || I === void 0 ? void 0 : I.filter(((pe) => !X.includes(pe))) : null;
809
+ ne && x(""), G(ne == null || ne);
810
+ };
811
+ return $("div", { className: "jer-edit-buttons", style: { opacity: P ? 1 : void 0 }, onClick: (A) => A.stopPropagation(), children: [r && c("div", { onClick: (A) => {
812
+ var I;
813
+ A.stopPropagation();
814
+ let X, ne, pe = "value", oe = "", fe = null;
815
+ if (r) {
816
+ const le = Pt(A);
817
+ if (le && h.clipboardModifier.includes(le) ? (X = Er(Y), oe = X, pe = "path") : (X = J, oe = typeof X == "object" ? y(J) : String(X)), !navigator.clipboard) return void (typeof r == "function" && r({ success: !1, value: X, stringValue: oe, path: Y, key: te, type: pe, errorMessage: "Can't access clipboard API" }));
818
+ (I = navigator.clipboard) === null || I === void 0 || I.writeText(oe).then((() => ne = !0)).catch(((Z) => {
819
+ ne = !1, fe = Z.message;
820
+ })).finally((() => {
821
+ typeof r == "function" && r({ success: ne, errorMessage: fe, value: X, stringValue: oe, path: Y, key: te, type: pe });
822
+ }));
823
+ }
824
+ }, className: "jer-copy-pulse", title: b ? g("TOOLTIP_COPY", i) : "", children: c(Ye, { name: "copy", nodeData: i }) }), t && c("div", { onClick: t, title: b ? g("TOOLTIP_EDIT", i) : "", children: c(Ye, { name: "edit", nodeData: i }) }), e && c("div", { onClick: e, title: b ? g("TOOLTIP_DELETE", i) : "", children: c(Ye, { name: "delete", nodeData: i }) }), n && c("div", { onClick: () => {
825
+ o === "object" ? H(!0) : n("");
826
+ }, title: b ? g("TOOLTIP_ADD", i) : "", children: c(Ye, { name: "add", nodeData: i }) }), a == null ? void 0 : a.map((({ Element: A, onClick: I }, X) => c("div", { onClick: (ne) => I && I(i, ne), children: c(A, { nodeData: i }) }, X))), P && n && o === "object" && $(vt, { children: [ee ? $("div", { className: "jer-select jer-select-keys", children: [$("select", { name: "new-key-select", className: "jer-select-inner", onChange: (A) => {
827
+ n(A.target.value), H(!1);
828
+ }, defaultValue: "", autoFocus: !0, onKeyDown: (A) => {
829
+ s(A, { cancel: () => H(!1) });
830
+ }, children: [c("option", { value: "", disabled: !0, children: P.length > 0 ? g("KEY_SELECT", i) : g("NO_KEY_OPTIONS", i) }), P.map(((A) => c("option", { value: A, children: A }, A)))] }), c("span", { className: "focus" })] }) : c("input", { className: "jer-input-new-key", type: "text", name: "new-object-key", value: N, onChange: (A) => x(A.target.value), autoFocus: !0, onFocus: (A) => A.target.select(), onKeyDown: (A) => {
831
+ s(A, { stringConfirm: () => {
832
+ n && (H(!1), n(N), x(T));
833
+ }, cancel: () => {
834
+ H(!1), x(T);
835
+ } });
836
+ }, style: w("input", i) }), c(It, { onOk: () => {
837
+ ee && !N || (H(!1), n(N));
838
+ }, onCancel: () => {
839
+ H(!1);
840
+ }, nodeData: i, editConfirmRef: u, hideOk: ee })] })] });
841
+ }, It = ({ onOk: t, onCancel: e, nodeData: n, editConfirmRef: r, hideOk: o = !1 }) => $("div", { className: "jer-confirm-buttons", children: [!o && c("div", { onClick: t, ref: r, children: c(Ye, { name: "ok", nodeData: n }) }), c("div", { onClick: e, children: c(Ye, { name: "cancel", nodeData: n }) })] }), Er = (t) => t.reduce(((e, n) => typeof n == "number" ? `${e}[${n}]` : e === "" ? n : `${e}.${n}`), ""), jr = ["string", "number", "boolean", "null", "object", "array"], fn = ({ props: t, collapsed: e }) => {
842
+ const { data: n, nodeData: r, parentData: o, onEdit: a, onError: i, showErrorMessages: g, restrictEditFilter: h, restrictDeleteFilter: s, restrictAddFilter: u, restrictDragFilter: p, translate: y, errorMessageTimeout: j } = t, { currentlyEditingElement: b, setCurrentlyEditingElement: w } = Je(), [T, N] = de(null), x = Object.assign(Object.assign({}, r), { collapsed: e }), { path: P, key: G, size: te } = x, Y = Xe(P), J = !h(x), ee = !s(x), H = !u(x), A = !p(x) && ee && b === null, I = (Z) => {
843
+ g && (N(Z), setTimeout((() => N(null)), j)), console.warn("Error", Z);
844
+ }, X = Ke(((Z, Q) => {
845
+ I(Z.message), i && i({ currentData: x.fullData, errorValue: Q, currentValue: n, name: G, path: P, error: Z });
846
+ }), [i, g]), ne = b === Y, pe = b === `key_${Y}`, oe = typeof P.slice(-1)[0] == "number", fe = { isEditing: ne, isEditingKey: pe, isArray: oe, canEditKey: o !== null && J && H && ee && !oe }, le = G === "" && P.length > 0 ? y("EMPTY_STRING", x) : null;
847
+ return { pathString: Y, nodeData: x, path: P, name: G, size: te, canEdit: J, canDelete: ee, canAdd: H, canDrag: A, error: T, showError: I, onError: X, setError: N, handleEditKey: (Z) => {
848
+ if (w(null), G === Z || !o) return;
849
+ const Q = P.slice(0, -1);
850
+ if (Object.keys(o).includes(Z)) return void X({ code: "KEY_EXISTS", message: y("ERROR_KEY_EXISTS", x) }, Z);
851
+ const f = Object.fromEntries(Object.entries(o).map((([d, l]) => d === G ? [Z, l] : [d, l])));
852
+ a(f, Q).then(((d) => {
853
+ d && X({ code: "UPDATE_ERROR", message: d }, Z);
854
+ }));
855
+ }, derivedValues: fe, emptyStringKey: le };
856
+ }, gn = ({ canDrag: t, canDragOnto: e, path: n, nodeData: r, onMove: o, onError: a, translate: i }) => {
857
+ const { getStyles: g } = Ve(), { dragSource: h, setDragSource: s } = Je(), [u, p] = de(!1), y = Xe(n), j = De((() => t ? { onDragStart: (N) => {
858
+ N.stopPropagation(), s({ path: n, pathString: y });
859
+ }, onDragEnd: (N) => {
860
+ N.stopPropagation(), s({ path: null, pathString: null });
861
+ } } : {}), [t, y]), b = De((() => (N) => e ? { onDragOver: (x) => {
862
+ x.stopPropagation(), x.preventDefault();
863
+ }, onDrop: (x) => {
864
+ x.stopPropagation(), T(N), s({ path: null, pathString: null }), p(!1);
865
+ }, onDragEnter: (x) => {
866
+ var P;
867
+ x.stopPropagation(), y.startsWith((P = h.pathString) !== null && P !== void 0 ? P : "") || p(N);
868
+ }, onDragExit: (x) => {
869
+ x.stopPropagation(), p(!1);
870
+ } } : {}), [h, e, y]), w = De((() => e && h.pathString !== null ? c("div", Object.assign({ className: "jer-drop-target-bottom", style: { height: "50%", position: "absolute", width: "100%", top: "50%", zIndex: n.length } }, b("below"))) : null), [h, e, n.length]), T = (N) => {
871
+ var x, P;
872
+ const G = (x = h.path) === null || x === void 0 ? void 0 : x.slice(-1)[0], te = (P = h.path) === null || P === void 0 ? void 0 : P.slice(0, -1).join("."), Y = n.slice(0, -1).join(""), { parentData: J } = r;
873
+ typeof G == "string" && J && !Array.isArray(J) && Object.keys(J).includes(G) && G in J && te !== Y ? a({ code: "KEY_EXISTS", message: i("ERROR_KEY_EXISTS", r) }, G) : o(h.path, n, N).then(((ee) => {
874
+ ee && a({ code: "UPDATE_ERROR", message: ee }, r.value);
875
+ }));
876
+ };
877
+ return { dragSourceProps: j, getDropTargetProps: b, BottomDropTarget: w, DropTargetPadding: ({ position: N, nodeData: x }) => u === N ? c("div", { className: "jer-drag-n-drop-padding", style: g("dropZone", x) }) : null, handleDrop: T };
878
+ }, wr = (t, e, n, r) => {
879
+ var o, a, i;
880
+ if (!e.current) return 0;
881
+ const g = parseInt((o = getComputedStyle(n.current).getPropertyValue("line-height")) !== null && o !== void 0 ? o : "16px"), h = ((i = (a = e.current) === null || a === void 0 ? void 0 : a.offsetWidth) !== null && i !== void 0 ? i : 0) / (0.5 * g), s = r(t).replace(/\\n/g, `
882
+ `).split(`
883
+ `).map(((u) => Math.ceil(u.length / h))).reduce(((u, p) => u + p), 0) * g;
884
+ return Math.min(s + 30, window.innerHeight - 50);
885
+ }, yt = ({ isEditingKey: t, canEditKey: e, pathString: n, path: r, name: o, arrayIndexFromOne: a, handleKeyboard: i, handleEditKey: g, handleCancel: h, handleClick: s, keyValueArray: u, styles: p, getNextOrPrevious: y, emptyStringKey: j }) => {
886
+ const { setCurrentlyEditingElement: b } = Je(), w = typeof o == "number" ? String(o + (a ? 1 : 0)) : o;
887
+ return t ? c("input", { className: "jer-input-text jer-key-edit", type: "text", name: n, defaultValue: w, autoFocus: !0, onFocus: (T) => T.target.select(), onKeyDown: (T) => i(T, { stringConfirm: () => g(T.target.value), cancel: h, tabForward: () => {
888
+ if (g(T.target.value), u) {
889
+ const N = u == null ? void 0 : u[0][0];
890
+ b(N ? [...r, N] : y("next"));
891
+ } else b(r);
892
+ }, tabBack: () => {
893
+ g(T.target.value), b(y("prev"));
894
+ } }), style: { width: w.length / 1.5 + 0.5 + "em" } }) : $("span", { className: "jer-key-text", style: Object.assign(Object.assign({}, p), { minWidth: `${Math.min(w.length + 1, 5)}ch`, flexShrink: w.length > 10 ? 1 : 0 }), onDoubleClick: () => e && b(r, "key"), onClick: s, children: [j ? c("span", { className: "jer-empty-string", children: j }) : w, w !== "" || j ? c("span", { className: "jer-key-colon", children: ":" }) : null] });
895
+ }, mn = (t) => {
896
+ const { data: e, parentData: n, onEdit: r, onDelete: o, onChange: a, onMove: i, enableClipboard: g, canDragOnto: h, restrictTypeSelection: s, searchFilter: u, searchText: p, showLabel: y, stringTruncate: j, showStringQuotes: b, arrayIndexFromOne: w, indent: T, translate: N, customNodeDefinitions: x, customNodeData: P, handleKeyboard: G, keyboardControls: te, sort: Y, editConfirmRef: J, jsonStringify: ee, showIconTooltips: H } = t, { getStyles: A } = Ve(), { setCurrentlyEditingElement: I, setCollapseState: X, previouslyEditedElement: ne, setPreviouslyEditedElement: pe, tabDirection: oe, setTabDirection: fe, previousValue: le, setPreviousValue: Z } = Je(), [Q, f] = de(typeof e == "function" ? At : e), { pathString: d, nodeData: l, path: m, name: E, canEdit: k, canDelete: M, canDrag: L, error: he, onError: U, handleEditKey: je, emptyStringKey: Te, derivedValues: re } = fn({ props: t }), { dragSourceProps: Me, getDropTargetProps: Fe, BottomDropTarget: z, DropTargetPadding: ge } = gn({ canDrag: L, canDragOnto: h, path: m, nodeData: l, onMove: i, onError: U, translate: N }), [Se, be] = de(_t(e, P)), R = Ke(((v) => {
897
+ if (!a) return void f(v);
898
+ const O = a({ currentData: l.fullData, newValue: v, currentValue: Q, name: E, path: m });
899
+ f(O);
900
+ }), [a]);
901
+ Re((() => {
902
+ f(typeof e == "function" ? At : e), be(_t(e, P));
903
+ }), [e, he]);
904
+ const { CustomNode: B, customNodeProps: ie, hideKey: ae, showEditTools: me = !0, showOnEdit: se, showOnView: Oe, passOriginalNode: Ne } = P, Ae = [...jr, ...x.filter((({ showInTypesSelector: v = !1, name: O }) => v && !!O)).map((({ name: v }) => v))], ce = De((() => {
905
+ if (typeof s == "boolean") return s ? [] : Ae;
906
+ if (Array.isArray(s)) return s;
907
+ const v = s(l);
908
+ return typeof v == "boolean" ? v ? [] : Ae : v;
909
+ }), [l, s]), [q, ze] = de(((v, O) => {
910
+ var K;
911
+ if (typeof v != "string") return null;
912
+ const Ee = O.filter(((ue) => ue instanceof Object && ue.enum && ue.values.includes(v) && ue.matchPriority));
913
+ return Ee.sort(((ue, ve) => {
914
+ var We, $e;
915
+ return ((We = ve.matchPriority) !== null && We !== void 0 ? We : 0) - (($e = ue.matchPriority) !== null && $e !== void 0 ? $e : 0);
916
+ })), (K = Ee[0]) !== null && K !== void 0 ? K : null;
917
+ })(Q, ce)), { isEditing: we } = re, Ze = sn("value", l, u, p);
918
+ if (we && (!Ze || !k)) {
919
+ const v = Ue(l.fullData, m, oe, Y);
920
+ I(v || ne);
921
+ }
922
+ if (!Ze) return null;
923
+ const Ie = (v) => {
924
+ let O;
925
+ if (I(null), Z(null), v === void 0 || ((K) => K && typeof K == "object" && "type" in K && "target" in K && "preventDefault" in K && typeof K.preventDefault == "function")(v)) switch (Se) {
926
+ case "object":
927
+ O = { [N("DEFAULT_NEW_KEY", l)]: Q };
928
+ break;
929
+ case "array":
930
+ O = Q ?? [];
931
+ break;
932
+ case "number": {
933
+ const K = Number(Q);
934
+ O = isNaN(K) ? 0 : K;
935
+ break;
936
+ }
937
+ default:
938
+ O = Q;
939
+ }
940
+ else O = v;
941
+ r(O, m).then(((K) => {
942
+ K && U({ code: "UPDATE_ERROR", message: K }, O);
943
+ }));
944
+ }, _e = () => {
945
+ I(null), le === null ? (f(e), Z(null)) : r(le, m);
946
+ }, { isEditingKey: Qe, canEditKey: qe } = re, ke = !we && he, ye = we && ce.length > 1, Be = (Se !== "invalid" || B) && !he && me, S = y && !ae, C = B && (we && se || !we && Oe), _ = { value: Q, parentData: n, setValue: R, isEditing: we, canEdit: k, setIsEditing: k ? () => I(m) : () => {
947
+ }, handleEdit: Ie, handleCancel: _e, path: m, stringTruncate: j, showStringQuotes: b, nodeData: l, enumType: q, translate: N, handleKeyboard: G, keyboardCommon: { cancel: _e, tabForward: () => {
948
+ fe("next"), pe(d);
949
+ const v = Ue(l.fullData, m, "next", Y);
950
+ v && (Ie(), I(v));
951
+ }, tabBack: () => {
952
+ fe("prev"), pe(d);
953
+ const v = Ue(l.fullData, m, "prev", Y);
954
+ v && (Ie(), I(v));
955
+ } } }, F = { canEditKey: qe, isEditingKey: Qe, pathString: d, path: m, name: E, arrayIndexFromOne: w, handleKeyboard: G, handleEditKey: je, handleCancel: _e, styles: A("property", l), getNextOrPrevious: (v) => Ue(l.fullData, m, v, Y), emptyStringKey: Te }, V = C ? c(B, Object.assign({}, t, { value: Q, customNodeProps: ie, setValue: R, handleEdit: Ie, handleCancel: _e, handleKeyPress: (v) => G(v, { stringConfirm: Ie, cancel: _e }), isEditing: we, setIsEditing: () => I(m), getStyles: A, originalNode: Ne ? Zt(e, _) : void 0, originalNodeKey: Ne ? c(yt, Object.assign({}, F)) : void 0, canEdit: k, keyboardCommon: _.keyboardCommon, onError: U })) : Zt(e, _);
956
+ return $("div", Object.assign({ className: "jer-component jer-value-component", style: { marginLeft: n !== null ? T / 2 + "em" : 0, position: "relative" }, draggable: L }, Me, Fe("above"), { children: [z, c(ge, { position: "above", nodeData: l }), $("div", { className: "jer-value-main-row", style: { flexWrap: E.length > 10 ? "wrap" : "nowrap" }, children: [S && c(yt, Object.assign({}, F)), $("div", { className: "jer-value-and-buttons", children: [c("div", { className: "jer-input-component", children: V }), we ? c(It, { onOk: Ie, onCancel: _e, nodeData: l, editConfirmRef: J }) : Be && c(pn, { startEdit: k ? () => {
957
+ Z(le), I(m, _e);
958
+ } : void 0, handleDelete: M ? () => {
959
+ o(Q, m).then(((v) => {
960
+ v && U({ code: "DELETE_ERROR", message: v }, Q);
961
+ }));
962
+ } : void 0, enableClipboard: g, translate: N, customButtons: t.customButtons, nodeData: l, handleKeyboard: G, keyboardControls: te, editConfirmRef: J, jsonStringify: ee, showIconTooltips: H }), ye && $("div", { className: "jer-select jer-select-types", children: [c("select", { name: `${E}-type-select`, className: "jer-select-inner", onChange: (v) => ((O) => {
963
+ const K = x.find(((ve) => ve.name === O));
964
+ if (K) return r(K.defaultValue, m), be(O), ze(null), I(null), void X({ path: m, collapsed: !1, includeChildren: !1 });
965
+ const Ee = ce.find(((ve) => ve instanceof Object && ve.enum === O));
966
+ if (Ee) return typeof Q == "string" && Ee.values.includes(Q) || r(Ee.values[0], m).then(((ve) => {
967
+ ve && (U({ code: "UPDATE_ERROR", message: ve }, ue), I(null));
968
+ })), void ze(Ee);
969
+ const ue = Dr(Q, O, N("DEFAULT_NEW_KEY", l), P != null && P.CustomNode ? N("DEFAULT_STRING", l) : void 0);
970
+ ["string", "number", "boolean"].includes(O) || I(null), r(ue, m).then(((ve) => {
971
+ ve ? (U({ code: "UPDATE_ERROR", message: ve }, ue), I(null)) : ze(null);
972
+ }));
973
+ })(v.target.value), value: q ? q.enum : Se, children: ce.map(((v) => v instanceof Object && "enum" in v ? c("option", { value: v.enum, children: v.enum }, v.enum) : c("option", { value: v, children: v }, v))) }), c("span", { className: "focus" })] }), ke && c("span", { className: "jer-error-slug", style: A("error", l), children: he })] })] }), c(ge, { position: "below", nodeData: l })] }));
974
+ }, _t = (t, e) => e != null && e.CustomNode && (e != null && e.name) && e.showInTypesSelector ? e.name : typeof t == "string" ? "string" : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null ? "null" : "invalid", Zt = (t, e) => {
975
+ const n = _t(t), { value: r } = e;
976
+ switch (n) {
977
+ case "string":
978
+ return c(sr, Object.assign({}, e, { value: r }));
979
+ case "number":
980
+ return c(lr, Object.assign({}, e, { value: r }));
981
+ case "boolean":
982
+ return c(cr, Object.assign({}, e, { value: r }));
983
+ case "null":
984
+ return c(dr, Object.assign({}, e));
985
+ default:
986
+ return c(hr, Object.assign({}, e));
987
+ }
988
+ }, Dr = (t, e, n, r) => {
989
+ switch (e) {
990
+ case "string":
991
+ return r ?? String(t);
992
+ case "number": {
993
+ const o = Number(t);
994
+ return isNaN(o) ? 0 : o;
995
+ }
996
+ case "boolean":
997
+ return !!t;
998
+ case "null":
999
+ return null;
1000
+ case "object":
1001
+ return { [n]: t };
1002
+ case "array":
1003
+ return [t];
1004
+ default:
1005
+ return String(t);
1006
+ }
1007
+ }, yn = (t = [], e) => {
1008
+ const n = t.filter((({ condition: b }) => b(e)));
1009
+ if (n.length === 0) return {};
1010
+ const r = n[0], { element: o, wrapperElement: a, customNodeProps: i, wrapperProps: g, hideKey: h = !1, showEditTools: s = !0, showOnEdit: u = !1, showOnView: p = !0, showCollectionWrapper: y = !0 } = r, j = on(r, ["element", "wrapperElement", "customNodeProps", "wrapperProps", "hideKey", "showEditTools", "showOnEdit", "showOnView", "showCollectionWrapper"]);
1011
+ return Object.assign({ CustomNode: o, CustomWrapper: a, customNodeProps: i, wrapperProps: g, hideKey: h, showEditTools: s, showOnEdit: u, showOnView: p, showCollectionWrapper: y }, j);
1012
+ }, vn = (t) => {
1013
+ const { getStyles: e } = Ve(), { collapseState: n, setCollapseState: r, getMatchingCollapseState: o, currentlyEditingElement: a, setCurrentlyEditingElement: i, areChildrenBeingEdited: g, previousValue: h, setPreviousValue: s } = Je(), { mainContainerRef: u, data: p, nodeData: y, parentData: j, showCollectionCount: b, onEdit: w, onAdd: T, onDelete: N, canDragOnto: x, collapseFilter: P, collapseAnimationTime: G, onMove: te, enableClipboard: Y, onEditEvent: J, showIconTooltips: ee, searchFilter: H, searchText: A, indent: I, sort: X, showArrayIndices: ne, arrayIndexFromOne: pe, defaultValue: oe, newKeyOptions: fe, translate: le, customNodeDefinitions: Z, customNodeData: Q, jsonParse: f, jsonStringify: d, TextEditor: l, keyboardControls: m, handleKeyboard: E, insertAtTop: k, onCollapse: M, editConfirmRef: L, collapseClickZones: he } = t, [U, je] = de(d(p)), Te = P(y), { contentRef: re, isAnimating: Me, maxHeight: Fe, collapsed: z, animateCollapse: ge, cssTransitionValue: Se } = ((D, W, Pe, xe, Le) => {
1014
+ const [On, ft] = de(Pe ? 0 : void 0), [gt, Sn] = de(Pe), Dt = Ce(!1), Ct = Ce(null), Wt = Ce(0), $t = Ce(0), kn = W / 1e3 + "s", xn = Ke(((Ot) => {
1015
+ var St, kt;
1016
+ if (gt !== Ot) {
1017
+ switch (window.clearTimeout($t.current), Dt.current = !0, Ot) {
1018
+ case !0: {
1019
+ const Gt = (kt = (St = Ct.current) === null || St === void 0 ? void 0 : St.offsetHeight) !== null && kt !== void 0 ? kt : 0;
1020
+ Wt.current = Gt, ft(Gt), setTimeout((() => {
1021
+ ft(0);
1022
+ }), 5);
1023
+ break;
1024
+ }
1025
+ case !1:
1026
+ ft(Wt.current || wr(D, Ct, xe, Le));
1027
+ }
1028
+ Sn(!gt), $t.current = window.setTimeout((() => {
1029
+ Dt.current = !1, Ot || ft(void 0);
1030
+ }), W);
1031
+ }
1032
+ }), [W, gt, D, xe, Le]);
1033
+ return { contentRef: Ct, isAnimating: Dt.current, animateCollapse: xn, maxHeight: On, collapsed: gt, cssTransitionValue: kn };
1034
+ })(p, G, Te, u, d), { pathString: be, nodeData: R, path: B, name: ie, size: ae, canEdit: me, canDelete: se, canAdd: Oe, canDrag: Ne, error: Ae, setError: ce, onError: q, handleEditKey: ze, emptyStringKey: we, derivedValues: Ze } = fn({ props: t, collapsed: z }), { dragSourceProps: Ie, getDropTargetProps: _e, BottomDropTarget: Qe, DropTargetPadding: qe } = gn({ canDrag: Ne, canDragOnto: x, path: B, nodeData: R, onMove: te, onError: q, translate: le }), ke = Ce(!Te), { isEditing: ye, isEditingKey: Be, isArray: S, canEditKey: C } = Ze;
1035
+ Re((() => {
1036
+ je(d(p));
1037
+ }), [p, d]), Re((() => {
1038
+ const D = P(R) && !ye;
1039
+ ke.current = !D, ge(D);
1040
+ }), [P]), Re((() => {
1041
+ if (n !== null) {
1042
+ const D = o(B);
1043
+ D && (ke.current = !0, ge(D.collapsed));
1044
+ }
1045
+ }), [n]);
1046
+ const _ = Ce(null), F = Ke(((D, W) => {
1047
+ if (typeof oe != "function") return oe;
1048
+ const Pe = oe(D, W);
1049
+ return Pe !== void 0 ? Pe : null;
1050
+ }), [oe]), V = Ke(((D) => fe ? typeof fe != "function" ? fe : fe(D) : null), [fe]), { CustomNode: v, customNodeProps: O, CustomWrapper: K, wrapperProps: Ee = {}, hideKey: ue, showEditTools: ve = !0, showOnEdit: We, showOnView: $e, showCollectionWrapper: bt = !0 } = Q, dt = g(be);
1051
+ if (dt && z && ge(!1), !(sn("collection", R, H, A) || R.level === 0) && !dt) return null;
1052
+ const et = Array.isArray(p) ? "array" : "object", Et = et === "array" ? { open: "[", close: "]" } : { open: "{", close: "}" }, Lt = (D) => {
1053
+ if (D.key !== "Tab" || D.getModifierState("Shift")) E(D, { objectConfirm: pt, cancel: it });
1054
+ else {
1055
+ D.preventDefault();
1056
+ const W = cn(_, " ");
1057
+ je(W);
1058
+ }
1059
+ }, ht = (D) => {
1060
+ D.stopPropagation();
1061
+ const W = Pt(D);
1062
+ if (W && m.collapseModifier.includes(W)) return ke.current = !0, void r({ collapsed: !z, path: B, includeChildren: !0 });
1063
+ a && a.includes(be) || (ke.current = !0, r(null), M && M({ path: B, collapsed: !z, includeChildren: !1 }), ge(!z));
1064
+ }, pt = () => {
1065
+ try {
1066
+ const D = f(U);
1067
+ if (i(null), s(null), ce(null), d(D) === d(p)) return;
1068
+ w(D, B).then(((W) => {
1069
+ W && q({ code: "UPDATE_ERROR", message: W }, D);
1070
+ }));
1071
+ } catch {
1072
+ q({ code: "INVALID_JSON", message: le("ERROR_INVALID_JSON", R) }, U);
1073
+ }
1074
+ }, En = B.length > 0 ? () => {
1075
+ N(p, B).then(((D) => {
1076
+ D && q({ code: "DELETE_ERROR", message: D }, p);
1077
+ }));
1078
+ } : void 0, it = () => {
1079
+ i(null), h === null ? (ce(null), je(d(p)), s(null)) : w(h, B);
1080
+ }, Vt = b === "when-closed" ? z : b, jn = !ye && ve, wn = (ne || !S) && !ue && ie !== void 0, Dn = v && (ye && We || !ye && $e), jt = Object.entries(p).map((([D, W]) => [et === "array" ? Number(D) : D, W]));
1081
+ et === "object" && X(jt, ((D) => D));
1082
+ const Ft = ke.current ? ye ? $("div", { className: "jer-collection-text-edit", children: [l ? c(l, { value: U, onChange: je, onKeyDown: (D) => E(D, { objectConfirm: pt, cancel: it }) }) : c(an, { textAreaRef: _, className: "jer-collection-text-area", name: be, value: U, setValue: je, handleKeyPress: Lt, styles: e("input", R) }), c("div", { className: "jer-collection-input-button-row", children: c(It, { onOk: pt, onCancel: it, nodeData: R, editConfirmRef: L }) })] }) : jt.map((([D, W], Pe) => {
1083
+ const xe = { key: D, value: W, path: [...B, D], level: B.length + 1, index: Pe, size: rt(W) ? Object.keys(W).length : null, parentData: p, fullData: R.fullData }, Le = yn(Z, xe);
1084
+ return c("div", { className: "jer-collection-element", style: e("collectionElement", xe), children: rt(W) && !(Le != null && Le.renderCollectionAsValue) ? c(vn, Object.assign({}, t, { data: W, parentData: p, nodeData: xe, showCollectionCount: b, canDragOnto: me, customNodeData: Le }), D) : c(mn, Object.assign({}, t, { data: W, parentData: p, nodeData: xe, canDragOnto: me, showLabel: et === "object" || ne, customNodeData: Le }), D) }, D);
1085
+ })) : null, wt = !!bt && z && !dt;
1086
+ wt || (ke.current = !0);
1087
+ const Kt = Object.assign(Object.assign({}, t), { data: p, value: p, parentData: j, nodeData: R, setValue: (D) => tt(void 0, void 0, void 0, (function* () {
1088
+ return yield w(D, B);
1089
+ })), handleEdit: pt, handleCancel: it, handleKeyPress: Lt, isEditing: ye, setIsEditing: () => i(B), getStyles: e, canDragOnto: me, canEdit: me, keyboardCommon: {}, onError: q }), Cn = Dn ? c(v, Object.assign({ customNodeProps: O }, Kt, { children: Ft })) : Ft, Mt = jn && c(pn, { startEdit: me ? () => {
1090
+ ke.current = !0, s(null), i(B);
1091
+ } : void 0, handleAdd: Oe ? (D) => {
1092
+ ge(!1);
1093
+ const W = F(R, D);
1094
+ if (et === "array") {
1095
+ const Pe = k.array ? 0 : p.length, xe = k.array ? { insert: !0 } : {};
1096
+ T(W, [...B, Pe], xe).then(((Le) => {
1097
+ Le && q({ code: "ADD_ERROR", message: Le }, W);
1098
+ }));
1099
+ } else if (D in p) q({ code: "KEY_EXISTS", message: le("ERROR_KEY_EXISTS", R) }, D);
1100
+ else {
1101
+ const Pe = k.object ? { insertBefore: 0 } : {};
1102
+ T(W, [...B, D], Pe).then(((xe) => {
1103
+ xe && q({ code: "ADD_ERROR", message: xe }, W);
1104
+ }));
1105
+ }
1106
+ } : void 0, handleDelete: se ? En : void 0, enableClipboard: Y, type: et, nodeData: R, translate: le, customButtons: t.customButtons, keyboardControls: m, handleKeyboard: E, getNewKeyOptions: V, editConfirmRef: L, jsonStringify: d, onEditEvent: J, showIconTooltips: ee }), zt = { canEditKey: C, isEditingKey: Be, pathString: be, path: B, name: ie, arrayIndexFromOne: pe, handleKeyboard: E, handleEditKey: ze, handleCancel: it, keyValueArray: jt, styles: e("property", R), getNextOrPrevious: (D) => Ue(R.fullData, B, D, X), handleClick: he.includes("property") ? ht : (D) => D.stopPropagation(), emptyStringKey: we }, Bt = $("div", Object.assign({ className: "jer-component jer-collection-component", style: Object.assign(Object.assign({ marginLeft: (B.length === 0 ? 0 : I / 2) + "em" }, e("collection", R)), { position: "relative" }), draggable: Ne }, Ie, _e("above"), { children: [c("div", { className: "jer-clickzone", style: { width: I / 2 + 1 + "em", zIndex: 10 + 2 * R.level }, onClick: he.includes("left") ? ht : void 0 }), !ye && Qe, c(qe, { position: "above", nodeData: R }), bt ? $("div", { className: "jer-collection-header-row", style: { position: "relative" }, onClick: he.includes("header") ? ht : void 0, children: [$("div", { className: "jer-collection-name", children: [c("div", { className: "jer-collapse-icon jer-accordion-icon" + (z ? " jer-rotate-90" : ""), style: { zIndex: 11 + 2 * R.level, transition: Se }, onClick: ht, children: c(Ye, { name: "chevron", rotate: z, nodeData: R }) }), wn && c(yt, Object.assign({}, zt)), !ye && c("span", { className: "jer-brackets jer-bracket-open", style: e("bracket", R), children: Et.open })] }), !ye && Vt && c("div", { className: "jer-collection-item-count" + (Vt ? " jer-visible" : " jer-hidden"), style: Object.assign(Object.assign({}, e("itemCount", R)), { transition: Se }), children: ae === 1 ? le("ITEM_SINGLE", Object.assign(Object.assign({}, R), { size: 1 }), 1) : le("ITEMS_MULTIPLE", R, ae) }), c("div", { className: "jer-brackets" + (wt ? " jer-visible" : " jer-hidden"), style: Object.assign(Object.assign({}, e("bracket", R)), { transition: Se }), children: Et.close }), Mt] }) : ue ? c(vt, {}) : $("div", { className: "jer-collection-header-row", style: { position: "relative" }, children: [c(yt, Object.assign({}, zt)), Mt] }), $("div", { className: "jer-collection-inner", style: Object.assign(Object.assign({ overflowY: wt || Me ? "clip" : "visible", maxHeight: dt ? void 0 : Fe }, e("collectionInner", R)), { transition: Se }), ref: re, children: [Cn, c("div", { className: ye ? "jer-collection-error-row" : "jer-collection-error-row-edit", children: Ae && c("span", { className: "jer-error-slug", style: e("error", R), children: Ae }) }), !ye && bt && c("div", { className: "jer-brackets jer-bracket-outside", style: Object.assign(Object.assign({}, e("bracket", R)), { marginLeft: (I < 3 ? -1 : I < 6 ? -0.5 : 0) + "em" }), children: Et.close })] }), c(qe, { position: "below", nodeData: R })] }));
1107
+ return K ? c(K, Object.assign({ customNodeProps: Ee }, Kt, { children: Bt })) : Bt;
1108
+ }, Cr = { ITEM_SINGLE: "{{count}} item", ITEMS_MULTIPLE: "{{count}} items", KEY_NEW: "Enter new key", KEY_SELECT: "Select key", NO_KEY_OPTIONS: "No key options", ERROR_KEY_EXISTS: "Key already exists", ERROR_INVALID_JSON: "Invalid JSON", ERROR_UPDATE: "Update unsuccessful", ERROR_DELETE: "Delete unsuccessful", ERROR_ADD: "Adding node unsuccessful", DEFAULT_STRING: "New data!", DEFAULT_NEW_KEY: "key", SHOW_LESS: "(Show less)", EMPTY_STRING: "<empty string>", TOOLTIP_COPY: "Copy to clipboard", TOOLTIP_EDIT: "Edit", TOOLTIP_DELETE: "Delete", TOOLTIP_ADD: "Add" }, Or = (t, e) => (n, r, o) => ((a, i, g, h, s) => {
1109
+ if (i[h]) {
1110
+ const p = i[h](g);
1111
+ if (p !== null) return p;
1112
+ }
1113
+ const u = h in a ? a[h] : Cr[h];
1114
+ return s === void 0 ? u : u == null ? void 0 : u.replace("{{count}}", String(s));
1115
+ })(t, e, r, n, o);
1116
+ var Qt = [], at = [];
1117
+ (function(t, e) {
1118
+ if (t && typeof document < "u") {
1119
+ var n, r = e.prepend === !0 ? "prepend" : "append", o = e.singleTag === !0, a = typeof e.container == "string" ? document.querySelector(e.container) : document.getElementsByTagName("head")[0];
1120
+ if (o) {
1121
+ var i = Qt.indexOf(a);
1122
+ i === -1 && (i = Qt.push(a) - 1, at[i] = {}), n = at[i] && at[i][r] ? at[i][r] : at[i][r] = g();
1123
+ } else n = g();
1124
+ t.charCodeAt(0) === 65279 && (t = t.substring(1)), n.styleSheet ? n.styleSheet.cssText += t : n.appendChild(document.createTextNode(t));
1125
+ }
1126
+ function g() {
1127
+ var h = document.createElement("style");
1128
+ if (h.setAttribute("type", "text/css"), e.attributes) for (var s = Object.keys(e.attributes), u = 0; u < s.length; u++) h.setAttribute(s[u], e.attributes[s[u]]);
1129
+ var p = r === "prepend" ? "afterbegin" : "beforeend";
1130
+ return a.insertAdjacentElement(p, h), h;
1131
+ }
1132
+ })(':root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-area{font-family:inherit;font-size:.85em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-rotate-90{transform:rotate(-90deg)}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}', {});
1133
+ const Sr = ({ data: t, setData: e, rootName: n = "root", onUpdate: r = () => {
1134
+ }, onEdit: o = r, onDelete: a = r, onAdd: i = r, onChange: g, onError: h, onEditEvent: s, showErrorMessages: u = !0, enableClipboard: p = !0, indent: y = 2, collapse: j = !1, collapseAnimationTime: b = 300, showCollectionCount: w = !0, restrictEdit: T = !1, restrictDelete: N = !1, restrictAdd: x = !1, restrictTypeSelection: P = !1, restrictDrag: G = !0, viewOnly: te, searchFilter: Y, searchText: J, searchDebounceTime: ee = 350, keySort: H = !1, showArrayIndices: A = !0, arrayIndexFromOne: I = !1, showStringQuotes: X = !0, showIconTooltips: ne = !1, defaultValue: pe = null, newKeyOptions: oe, minWidth: fe = 250, maxWidth: le = "min(600px, 90vw)", rootFontSize: Z, stringTruncate: Q = 250, translations: f = {}, className: d, id: l, customText: m = {}, customNodeDefinitions: E = [], customButtons: k = [], jsonParse: M = JSON.parse, jsonStringify: L = (z, ge) => JSON.stringify(z, ge, 2), TextEditor: he, errorMessageTimeout: U = 2500, keyboardControls: je = {}, externalTriggers: Te, insertAtTop: re = !1, onCollapse: Me, collapseClickZones: Fe = ["header", "left"] }) => {
1135
+ const { getStyles: z } = Ve(), { setCurrentlyEditingElement: ge } = Je(), Se = De((() => lt(j)), [j]), be = De((() => Or(f, m)), [f, m]), [R, B] = de(J), [ie, ae] = (({ setData: S, data: C }) => {
1136
+ const [_, F] = de(S ? void 0 : C), V = Ke(((v) => {
1137
+ S ? S(v) : F(v);
1138
+ }), [S]);
1139
+ return Re((() => {
1140
+ S || F(C);
1141
+ }), [C]), [S ? C : _, V];
1142
+ })({ setData: e, data: t }), me = Ce(null);
1143
+ Re((() => {
1144
+ ge(null);
1145
+ const S = setTimeout((() => B(J)), ee);
1146
+ return () => clearTimeout(S);
1147
+ }), [J, ee]);
1148
+ const se = { key: n, path: [], level: 0, index: 0, value: ie, size: typeof ie == "object" && ie !== null ? Object.keys(ie).length : 1, parentData: null, fullData: ie }, Oe = (S, C) => tt(void 0, void 0, void 0, (function* () {
1149
+ const _ = yield S(C);
1150
+ if (_ === !0 || _ === void 0) return void ae(C.newData);
1151
+ const F = Tr(_) ? _ : ["error", _], [V, v] = F;
1152
+ if (V === "error") return ae(C.currentData), v === !1 ? be("ERROR_UPDATE", se) : String(v);
1153
+ ae(v);
1154
+ })), Ne = De((() => lt(T, te)), [T, te]), Ae = De((() => lt(N, te)), [N, te]), ce = De((() => lt(x, te)), [x, te]), q = De((() => lt(G, te)), [G, te]), ze = De((() => xr(Y)), [Y]), we = De((() => ((S) => {
1155
+ const C = Object.assign({}, Jt);
1156
+ for (const _ of Object.keys(Jt)) {
1157
+ const F = _;
1158
+ if (S[F]) {
1159
+ const V = S[F], v = ["clipboardModifier", "collapseModifier"].includes(_) ? Array.isArray(V) ? V : [V] : typeof V == "string" ? { key: V } : V;
1160
+ C[F] = v, ["stringConfirm", "numberConfirm", "booleanConfirm"].forEach(((O) => {
1161
+ !S[O] && S.confirm && (C[O] = C.confirm);
1162
+ }));
1163
+ }
1164
+ }
1165
+ return C;
1166
+ })(je)), [je]), Ze = Ke(((S, C) => ((_, F, V) => {
1167
+ const v = Object.entries(F);
1168
+ for (const [O, K] of v) if (Qn(V, _[O], O)) {
1169
+ V.preventDefault(), K();
1170
+ break;
1171
+ }
1172
+ })(we, C, S)), [we]), Ie = De((() => {
1173
+ const S = qt(E, "stringifyReplacer");
1174
+ return (C) => L(C, S);
1175
+ }), [E, L]), _e = De((() => {
1176
+ const S = qt(E, "parseReviver");
1177
+ return (C) => {
1178
+ const _ = M(C, S);
1179
+ return Nt(_);
1180
+ };
1181
+ }), [E, M]), Qe = Ce(null);
1182
+ ((S, C) => {
1183
+ const { setCurrentlyEditingElement: _, currentlyEditingElement: F, setCollapseState: V } = Je();
1184
+ Re((() => {
1185
+ if (!S) return;
1186
+ const { collapse: v, edit: O } = S;
1187
+ v && V(v);
1188
+ const K = !(O != null && O.path) || Xe(O.path) === F;
1189
+ switch (O == null ? void 0 : O.action) {
1190
+ case "accept":
1191
+ K && (C.current && C.current.click(), _(null));
1192
+ break;
1193
+ case "cancel":
1194
+ K && _(null);
1195
+ break;
1196
+ default:
1197
+ O != null && O.path && _(O.path);
1198
+ }
1199
+ }), [S]);
1200
+ })(Te, Qe);
1201
+ const qe = Ke(((S, C) => {
1202
+ H !== !1 && (typeof H != "function" ? S.sort(((_, F) => {
1203
+ const V = C(_)[0], v = C(F)[0];
1204
+ return V < v ? -1 : V > v ? 1 : 0;
1205
+ })) : S.sort(((_, F) => H(C(_), C(F)))));
1206
+ }), [H]), ke = yn(E, se), ye = { mainContainerRef: me, name: n, nodeData: se, onEdit: (S, C) => tt(void 0, void 0, void 0, (function* () {
1207
+ const { currentData: _, newData: F, currentValue: V, newValue: v } = st(ie, C, S, "update");
1208
+ if (V !== v) return yield Oe(o, { currentData: _, newData: F, currentValue: V, newValue: v, name: C.slice(-1)[0], path: C });
1209
+ })), onDelete: (S, C) => tt(void 0, void 0, void 0, (function* () {
1210
+ const { currentData: _, newData: F, currentValue: V, newValue: v } = st(ie, C, S, "delete");
1211
+ return yield Oe(a, { currentData: _, newData: F, currentValue: V, newValue: v, name: C.slice(-1)[0], path: C });
1212
+ })), onAdd: (S, C, _) => tt(void 0, void 0, void 0, (function* () {
1213
+ const { currentData: F, newData: V, currentValue: v, newValue: O } = st(ie, C, S, "add", _);
1214
+ return yield Oe(i, { currentData: F, newData: V, currentValue: v, newValue: O, name: C.slice(-1)[0], path: C });
1215
+ })), onChange: g, onError: h, onEditEvent: s, showErrorMessages: u, onMove: (S, C, _) => tt(void 0, void 0, void 0, (function* () {
1216
+ if (S === null) return;
1217
+ const { currentData: F, newData: V, currentValue: v } = st(ie, S, "", "delete"), O = S.slice(-1)[0], K = C.slice(0, -1), Ee = C.slice(-1)[0];
1218
+ let ue = typeof Ee == "number" ? _ === "above" ? Ee : Ee + 1 : typeof O == "number" ? `arr_${O}` : O;
1219
+ S.slice(0, -1).join(".") === C.slice(0, -1).join(".") && typeof O == "number" && typeof ue == "number" && O < ue && (ue -= 1);
1220
+ const ve = typeof ue == "number" ? { insert: !0 } : _ === "above" ? { insertBefore: Ee } : { insertAfter: Ee }, { newData: We, newValue: $e } = st(V, [...K, ue], v, "add", ve);
1221
+ return yield Oe(o, { currentData: F, newData: We, currentValue: v, newValue: $e, name: C.slice(-1)[0], path: C });
1222
+ })), showCollectionCount: w, collapseFilter: Se, collapseAnimationTime: b, restrictEditFilter: Ne, restrictDeleteFilter: Ae, restrictAddFilter: ce, restrictTypeSelection: P, restrictDragFilter: q, canDragOnto: !1, searchFilter: ze, searchText: R, enableClipboard: p, keySort: H, sort: qe, showArrayIndices: A, arrayIndexFromOne: I, showStringQuotes: X, showIconTooltips: ne, indent: y, defaultValue: pe, newKeyOptions: oe, stringTruncate: Q, translate: be, customNodeDefinitions: E, customNodeData: ke, customButtons: k, parentData: null, jsonParse: _e, jsonStringify: Ie, TextEditor: he, errorMessageTimeout: U, handleKeyboard: Ze, keyboardControls: we, insertAtTop: { object: re === !0 || re === "object", array: re === !0 || re === "array" }, onCollapse: Me, editConfirmRef: Qe, collapseClickZones: Fe }, Be = Object.assign(Object.assign({}, z("container", se)), { minWidth: fe, maxWidth: le });
1223
+ return Be.fontSize = Z ?? Be.fontSize, c("div", { id: l, ref: me, className: `jer-editor-container ${d ?? ""}`, style: Be, children: rt(ie) && !ke.renderCollectionAsValue ? c(vn, Object.assign({ data: ie }, ye)) : c(mn, Object.assign({ data: ie, showLabel: !0 }, ye)) });
1224
+ }, kr = (t) => {
1225
+ var e;
1226
+ const [n, r] = de();
1227
+ return Re((() => {
1228
+ const o = document.documentElement;
1229
+ r(o);
1230
+ }), []), n ? c(er, { theme: (e = t.theme) !== null && e !== void 0 ? e : Rt, icons: t.icons, docRoot: n, children: c(or, { onEditEvent: t.onEditEvent, onCollapse: t.onCollapse, children: c(Sr, Object.assign({}, t)) }) }) : null;
1231
+ }, st = (t, e, n, r, o = {}) => {
1232
+ if (e.length === 0) return { currentData: t, newData: n, currentValue: t, newValue: n };
1233
+ const a = Object.assign({ remove: r === "delete" }, o), i = r !== "add" ? nt(t, e) : void 0;
1234
+ return { currentData: t, newData: Un(t, e, n, a), currentValue: i, newValue: r !== "delete" ? n : void 0 };
1235
+ }, lt = (t, e) => e ? () => !0 : typeof t == "boolean" ? () => t : typeof t == "number" ? ({ level: n }) => n >= t : t, xr = (t) => {
1236
+ if (t !== void 0) return t === "value" ? ot : t === "key" ? Yt : t === "all" ? (e, n) => ot(e, n) || Yt(e, n) : t;
1237
+ }, Tr = (t) => Array.isArray(t) && t.length === 2 && ["error", "value"].includes(t[0]), qt = (t, e) => {
1238
+ const n = e === "stringifyReplacer" ? [(r) => r === void 0 ? un : r] : [];
1239
+ if (n.push(...t.map(((r) => r[e])).filter(((r) => !!r))), n.length !== 0) return (r, o) => {
1240
+ let a = o;
1241
+ for (const i of n) a = i(a);
1242
+ return a;
1243
+ };
1244
+ }, bn = { displayName: "Github Dark", styles: { container: { backgroundColor: "#0d1117", color: "white" }, dropZone: "rgba(165, 214, 255, 0.17)", property: "#E6EDF3", bracket: "#56d364", itemCount: "#8B949E", string: "#A5D6FF", number: "#D2A8FF", boolean: { color: "#FF7B72", fontSize: "90%", fontWeight: "bold" }, null: "green", iconCollection: "#D2A8FF", iconEdit: "#D2A8FF", iconDelete: "rgb(203, 75, 22)", iconAdd: "rgb(203, 75, 22)", iconCopy: "#A5D6FF", iconOk: "#56d364", iconCancel: "rgb(203, 75, 22)" } }, Nr = { displayName: "Github Light", styles: { container: "white", property: "#1F2328", bracket: "#00802e", itemCount: "#8B949E", string: "#0A3069", number: "#953800", boolean: { color: "#CF222E", fontSize: "90%", fontWeight: "bold" }, null: "#FF7B72", iconCollection: "#8250DF", iconEdit: "#8250DF", iconDelete: "rgb(203, 75, 22)", iconAdd: "#8250DF", iconCopy: "#57606A" } }, Ar = { displayName: "Black & White", fragments: { lightText: { color: "white" }, midGrey: "#5c5c5c" }, styles: { container: ["lightText", { backgroundColor: "black" }], dropZone: "#e0e0e029", property: "lightText", bracket: "midGrey", itemCount: "#4a4a4a", string: "#a8a8a8", number: "#666666", boolean: { color: "#848484", fontStyle: "italic" }, null: "#333333", iconCollection: "midGrey", iconEdit: "midGrey", iconDelete: "midGrey", iconAdd: "midGrey", iconCopy: "midGrey", iconOk: "midGrey", iconCancel: "midGrey" } }, _r = { fragments: { midGrey: "#a3a3a3" }, displayName: "White & Black", styles: { container: "white", property: "black", bracket: "midGrey", itemCount: "#b5b5b5", string: "#575757", number: "#999999", boolean: { color: "#7b7b7b", fontStyle: "italic" }, null: "#cccccc", iconCollection: "midGrey", iconEdit: "midGrey", iconDelete: "midGrey", iconAdd: "midGrey", iconCopy: "midGrey", iconOk: "midGrey", iconCancel: "midGrey" } }, Pr = {
1245
+ githubDark: bn,
1246
+ githubLight: Nr,
1247
+ monoDark: Ar,
1248
+ monoLight: _r
1249
+ };
1250
+ class Rr extends Nn {
1251
+ constructor() {
1252
+ super(...arguments), this.state = { error: null };
1253
+ }
1254
+ static getDerivedStateFromError(e) {
1255
+ return { error: e };
1256
+ }
1257
+ componentDidCatch(e, n) {
1258
+ console.error("[Legend State DevTools] React error:", e, n);
1259
+ }
1260
+ render() {
1261
+ return this.state.error ? Tn.createElement(
1262
+ "pre",
1263
+ { style: { color: "#ff6b6b", padding: 16, fontSize: 12 } },
1264
+ `DevTools Error: ${this.state.error.message}
1265
+ ${this.state.error.stack}`
1266
+ ) : this.props.children;
1267
+ }
1268
+ }
1269
+ function Ir({
1270
+ data: t,
1271
+ onEdit: e,
1272
+ readOnly: n,
1273
+ theme: r,
1274
+ rootName: o
1275
+ }) {
1276
+ const a = Pr[r] ?? bn;
1277
+ return /* @__PURE__ */ c(
1278
+ kr,
1279
+ {
1280
+ data: t,
1281
+ setData: e,
1282
+ rootName: o,
1283
+ theme: a,
1284
+ collapse: 2,
1285
+ restrictEdit: n,
1286
+ restrictDelete: n,
1287
+ restrictAdd: n,
1288
+ restrictTypeSelection: n ? !0 : void 0
1289
+ }
1290
+ );
1291
+ }
1292
+ function Lr(t) {
1293
+ const [e, n] = de(t.initialData);
1294
+ return Re(() => {
1295
+ t.registerUpdater((o) => {
1296
+ n(o);
1297
+ });
1298
+ }, []), /* @__PURE__ */ c(
1299
+ Ir,
1300
+ {
1301
+ data: e,
1302
+ onEdit: (o) => {
1303
+ n(o), t.onEdit(o);
1304
+ },
1305
+ readOnly: t.readOnly,
1306
+ theme: t.theme,
1307
+ rootName: t.rootName
1308
+ }
1309
+ );
1310
+ }
1311
+ function Vr(t, e) {
1312
+ let n = null, r = null;
1313
+ return n = An(t), n.render(
1314
+ /* @__PURE__ */ c(Rr, { children: /* @__PURE__ */ c(
1315
+ Lr,
1316
+ {
1317
+ initialData: e.initialData,
1318
+ onEdit: e.onEdit,
1319
+ readOnly: e.readOnly,
1320
+ theme: e.theme,
1321
+ rootName: e.rootName,
1322
+ registerUpdater: (o) => {
1323
+ r = o;
1324
+ }
1325
+ }
1326
+ ) })
1327
+ ), {
1328
+ updateData: (o) => {
1329
+ r == null || r(o);
1330
+ },
1331
+ destroy: () => {
1332
+ n && (n.unmount(), n = null);
1333
+ }
1334
+ };
1335
+ }
1336
+ function zr(t, e = {}) {
1337
+ const {
1338
+ enabled: n = !0,
1339
+ readOnly: r = !1,
1340
+ theme: o = "githubDark",
1341
+ rootName: a = "state$",
1342
+ position: i = "right"
1343
+ } = e;
1344
+ if (!n)
1345
+ return { destroy: () => {
1346
+ } };
1347
+ const g = Wn();
1348
+ let h = null, s = null, u = null, p = null;
1349
+ h = new Gn({
1350
+ rootName: a,
1351
+ readOnly: r,
1352
+ position: i,
1353
+ onClose: () => {
1354
+ j();
1355
+ }
1356
+ });
1357
+ const y = () => {
1358
+ if (!h) return;
1359
+ h.show(), s == null || s.setPanelVisible(!0);
1360
+ const w = (T = 10) => {
1361
+ const N = h == null ? void 0 : h.getEditorRoot();
1362
+ if (!N) {
1363
+ T > 0 ? setTimeout(() => w(T - 1), 16) : console.warn("[Legend State DevTools] Could not find #lsdt-json-editor-root after retries");
1364
+ return;
1365
+ }
1366
+ if (p) return;
1367
+ const x = (u == null ? void 0 : u.getSnapshot()) ?? {};
1368
+ p = Vr(N, {
1369
+ initialData: x,
1370
+ onEdit: (P) => {
1371
+ u == null || u.setData(P);
1372
+ },
1373
+ readOnly: r,
1374
+ theme: o,
1375
+ rootName: a
1376
+ });
1377
+ };
1378
+ w();
1379
+ }, j = () => {
1380
+ p && (p.destroy(), p = null), h == null || h.hide(), s == null || s.setPanelVisible(!1);
1381
+ }, b = () => {
1382
+ h != null && h.isVisible() ? j() : y();
1383
+ };
1384
+ return s = new $n({
1385
+ onTogglePanel: b,
1386
+ rootName: a
1387
+ }), s.mount(), g.add(() => s == null ? void 0 : s.unmount()), u = Hn(t, {
1388
+ onSnapshot: (w) => {
1389
+ p == null || p.updateData(w);
1390
+ }
1391
+ }), g.add(() => u == null ? void 0 : u.destroy()), g.add(() => {
1392
+ p && (p.destroy(), p = null);
1393
+ }), g.add(() => h == null ? void 0 : h.unmount()), {
1394
+ destroy: () => {
1395
+ g.run();
1396
+ }
1397
+ };
1398
+ }
1399
+ export {
1400
+ zr as init
1401
+ };
1402
+ //# sourceMappingURL=index.mjs.map