@commercelayer/app-elements 6.11.1 → 6.11.2

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.
@@ -0,0 +1,742 @@
1
+ "use client";
2
+ import { u as Pe, j as le, I as Se } from "./main-Q1klqbeV.js";
3
+ import $, { memo as ie, useState as N, useRef as h, useCallback as ne, useEffect as S, forwardRef as Ce } from "react";
4
+ import { f as Ee, a as Ie } from "./fetchCoreResourcesSuggestions-CAoQMAh8.js";
5
+ function se(e, t) {
6
+ (t == null || t > e.length) && (t = e.length);
7
+ for (var r = 0, n = Array(t); r < t; r++) n[r] = e[r];
8
+ return n;
9
+ }
10
+ function Te(e) {
11
+ if (Array.isArray(e)) return e;
12
+ }
13
+ function Le(e, t, r) {
14
+ return (t = Ve(t)) in e ? Object.defineProperty(e, t, {
15
+ value: r,
16
+ enumerable: !0,
17
+ configurable: !0,
18
+ writable: !0
19
+ }) : e[t] = r, e;
20
+ }
21
+ function De(e, t) {
22
+ var r = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
23
+ if (r != null) {
24
+ var n, o, i, c, d = [], g = !0, l = !1;
25
+ try {
26
+ if (i = (r = r.call(e)).next, t !== 0) for (; !(g = (n = i.call(r)).done) && (d.push(n.value), d.length !== t); g = !0) ;
27
+ } catch (M) {
28
+ l = !0, o = M;
29
+ } finally {
30
+ try {
31
+ if (!g && r.return != null && (c = r.return(), Object(c) !== c)) return;
32
+ } finally {
33
+ if (l) throw o;
34
+ }
35
+ }
36
+ return d;
37
+ }
38
+ }
39
+ function xe() {
40
+ throw new TypeError(`Invalid attempt to destructure non-iterable instance.
41
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
42
+ }
43
+ function de(e, t) {
44
+ var r = Object.keys(e);
45
+ if (Object.getOwnPropertySymbols) {
46
+ var n = Object.getOwnPropertySymbols(e);
47
+ t && (n = n.filter(function(o) {
48
+ return Object.getOwnPropertyDescriptor(e, o).enumerable;
49
+ })), r.push.apply(r, n);
50
+ }
51
+ return r;
52
+ }
53
+ function fe(e) {
54
+ for (var t = 1; t < arguments.length; t++) {
55
+ var r = arguments[t] != null ? arguments[t] : {};
56
+ t % 2 ? de(Object(r), !0).forEach(function(n) {
57
+ Le(e, n, r[n]);
58
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : de(Object(r)).forEach(function(n) {
59
+ Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
60
+ });
61
+ }
62
+ return e;
63
+ }
64
+ function Ae(e, t) {
65
+ if (e == null) return {};
66
+ var r, n, o = Re(e, t);
67
+ if (Object.getOwnPropertySymbols) {
68
+ var i = Object.getOwnPropertySymbols(e);
69
+ for (n = 0; n < i.length; n++) r = i[n], t.indexOf(r) === -1 && {}.propertyIsEnumerable.call(e, r) && (o[r] = e[r]);
70
+ }
71
+ return o;
72
+ }
73
+ function Re(e, t) {
74
+ if (e == null) return {};
75
+ var r = {};
76
+ for (var n in e) if ({}.hasOwnProperty.call(e, n)) {
77
+ if (t.indexOf(n) !== -1) continue;
78
+ r[n] = e[n];
79
+ }
80
+ return r;
81
+ }
82
+ function $e(e, t) {
83
+ return Te(e) || De(e, t) || qe(e, t) || xe();
84
+ }
85
+ function Ne(e, t) {
86
+ if (typeof e != "object" || !e) return e;
87
+ var r = e[Symbol.toPrimitive];
88
+ if (r !== void 0) {
89
+ var n = r.call(e, t);
90
+ if (typeof n != "object") return n;
91
+ throw new TypeError("@@toPrimitive must return a primitive value.");
92
+ }
93
+ return (t === "string" ? String : Number)(e);
94
+ }
95
+ function Ve(e) {
96
+ var t = Ne(e, "string");
97
+ return typeof t == "symbol" ? t : t + "";
98
+ }
99
+ function qe(e, t) {
100
+ if (e) {
101
+ if (typeof e == "string") return se(e, t);
102
+ var r = {}.toString.call(e).slice(8, -1);
103
+ return r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set" ? Array.from(e) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? se(e, t) : void 0;
104
+ }
105
+ }
106
+ function ze(e, t, r) {
107
+ return t in e ? Object.defineProperty(e, t, {
108
+ value: r,
109
+ enumerable: !0,
110
+ configurable: !0,
111
+ writable: !0
112
+ }) : e[t] = r, e;
113
+ }
114
+ function pe(e, t) {
115
+ var r = Object.keys(e);
116
+ if (Object.getOwnPropertySymbols) {
117
+ var n = Object.getOwnPropertySymbols(e);
118
+ t && (n = n.filter(function(o) {
119
+ return Object.getOwnPropertyDescriptor(e, o).enumerable;
120
+ })), r.push.apply(r, n);
121
+ }
122
+ return r;
123
+ }
124
+ function ge(e) {
125
+ for (var t = 1; t < arguments.length; t++) {
126
+ var r = arguments[t] != null ? arguments[t] : {};
127
+ t % 2 ? pe(Object(r), !0).forEach(function(n) {
128
+ ze(e, n, r[n]);
129
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : pe(Object(r)).forEach(function(n) {
130
+ Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
131
+ });
132
+ }
133
+ return e;
134
+ }
135
+ function Ue() {
136
+ for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
137
+ t[r] = arguments[r];
138
+ return function(n) {
139
+ return t.reduceRight(function(o, i) {
140
+ return i(o);
141
+ }, n);
142
+ };
143
+ }
144
+ function F(e) {
145
+ return function t() {
146
+ for (var r = this, n = arguments.length, o = new Array(n), i = 0; i < n; i++)
147
+ o[i] = arguments[i];
148
+ return o.length >= e.length ? e.apply(this, o) : function() {
149
+ for (var c = arguments.length, d = new Array(c), g = 0; g < c; g++)
150
+ d[g] = arguments[g];
151
+ return t.apply(r, [].concat(o, d));
152
+ };
153
+ };
154
+ }
155
+ function J(e) {
156
+ return {}.toString.call(e).includes("Object");
157
+ }
158
+ function Fe(e) {
159
+ return !Object.keys(e).length;
160
+ }
161
+ function k(e) {
162
+ return typeof e == "function";
163
+ }
164
+ function We(e, t) {
165
+ return Object.prototype.hasOwnProperty.call(e, t);
166
+ }
167
+ function ke(e, t) {
168
+ return J(t) || L("changeType"), Object.keys(t).some(function(r) {
169
+ return !We(e, r);
170
+ }) && L("changeField"), t;
171
+ }
172
+ function He(e) {
173
+ k(e) || L("selectorType");
174
+ }
175
+ function _e(e) {
176
+ k(e) || J(e) || L("handlerType"), J(e) && Object.values(e).some(function(t) {
177
+ return !k(t);
178
+ }) && L("handlersType");
179
+ }
180
+ function Be(e) {
181
+ e || L("initialIsRequired"), J(e) || L("initialType"), Fe(e) && L("initialContent");
182
+ }
183
+ function Ke(e, t) {
184
+ throw new Error(e[t] || e.default);
185
+ }
186
+ var Je = {
187
+ initialIsRequired: "initial state is required",
188
+ initialType: "initial state should be an object",
189
+ initialContent: "initial state shouldn't be an empty object",
190
+ handlerType: "handler should be an object or a function",
191
+ handlersType: "all handlers should be a functions",
192
+ selectorType: "selector should be a function",
193
+ changeType: "provided value of changes should be an object",
194
+ changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
195
+ default: "an unknown error accured in `state-local` package"
196
+ }, L = F(Ke)(Je), B = {
197
+ changes: ke,
198
+ selector: He,
199
+ handler: _e,
200
+ initial: Be
201
+ };
202
+ function Ge(e) {
203
+ var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
204
+ B.initial(e), B.handler(t);
205
+ var r = {
206
+ current: e
207
+ }, n = F(Xe)(r, t), o = F(Qe)(r), i = F(B.changes)(e), c = F(Ye)(r);
208
+ function d() {
209
+ var l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(M) {
210
+ return M;
211
+ };
212
+ return B.selector(l), l(r.current);
213
+ }
214
+ function g(l) {
215
+ Ue(n, o, i, c)(l);
216
+ }
217
+ return [d, g];
218
+ }
219
+ function Ye(e, t) {
220
+ return k(t) ? t(e.current) : t;
221
+ }
222
+ function Qe(e, t) {
223
+ return e.current = ge(ge({}, e.current), t), t;
224
+ }
225
+ function Xe(e, t, r) {
226
+ return k(t) ? t(e.current) : Object.keys(r).forEach(function(n) {
227
+ var o;
228
+ return (o = t[n]) === null || o === void 0 ? void 0 : o.call(t, e.current[n]);
229
+ }), r;
230
+ }
231
+ var Ze = {
232
+ create: Ge
233
+ }, et = {
234
+ paths: {
235
+ vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"
236
+ }
237
+ };
238
+ function tt(e) {
239
+ return function t() {
240
+ for (var r = this, n = arguments.length, o = new Array(n), i = 0; i < n; i++)
241
+ o[i] = arguments[i];
242
+ return o.length >= e.length ? e.apply(this, o) : function() {
243
+ for (var c = arguments.length, d = new Array(c), g = 0; g < c; g++)
244
+ d[g] = arguments[g];
245
+ return t.apply(r, [].concat(o, d));
246
+ };
247
+ };
248
+ }
249
+ function rt(e) {
250
+ return {}.toString.call(e).includes("Object");
251
+ }
252
+ function nt(e) {
253
+ return e || me("configIsRequired"), rt(e) || me("configType"), e.urls ? (ot(), {
254
+ paths: {
255
+ vs: e.urls.monacoBase
256
+ }
257
+ }) : e;
258
+ }
259
+ function ot() {
260
+ console.warn(ve.deprecation);
261
+ }
262
+ function it(e, t) {
263
+ throw new Error(e[t] || e.default);
264
+ }
265
+ var ve = {
266
+ configIsRequired: "the configuration object is required",
267
+ configType: "the configuration object should be an object",
268
+ default: "an unknown error accured in `@monaco-editor/loader` package",
269
+ deprecation: `Deprecation warning!
270
+ You are using deprecated way of configuration.
271
+
272
+ Instead of using
273
+ monaco.config({ urls: { monacoBase: '...' } })
274
+ use
275
+ monaco.config({ paths: { vs: '...' } })
276
+
277
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
278
+ `
279
+ }, me = tt(it)(ve), at = {
280
+ config: nt
281
+ }, ut = function() {
282
+ for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
283
+ r[n] = arguments[n];
284
+ return function(o) {
285
+ return r.reduceRight(function(i, c) {
286
+ return c(i);
287
+ }, o);
288
+ };
289
+ };
290
+ function be(e, t) {
291
+ return Object.keys(t).forEach(function(r) {
292
+ t[r] instanceof Object && e[r] && Object.assign(t[r], be(e[r], t[r]));
293
+ }), fe(fe({}, e), t);
294
+ }
295
+ var ct = {
296
+ type: "cancelation",
297
+ msg: "operation is manually canceled"
298
+ };
299
+ function ee(e) {
300
+ var t = !1, r = new Promise(function(n, o) {
301
+ e.then(function(i) {
302
+ return t ? o(ct) : n(i);
303
+ }), e.catch(o);
304
+ });
305
+ return r.cancel = function() {
306
+ return t = !0;
307
+ }, r;
308
+ }
309
+ var lt = ["monaco"], st = Ze.create({
310
+ config: et,
311
+ isInitialized: !1,
312
+ resolve: null,
313
+ reject: null,
314
+ monaco: null
315
+ }), ye = $e(st, 2), H = ye[0], Y = ye[1];
316
+ function dt(e) {
317
+ var t = at.config(e), r = t.monaco, n = Ae(t, lt);
318
+ Y(function(o) {
319
+ return {
320
+ config: be(o.config, n),
321
+ monaco: r
322
+ };
323
+ });
324
+ }
325
+ function ft() {
326
+ var e = H(function(t) {
327
+ var r = t.monaco, n = t.isInitialized, o = t.resolve;
328
+ return {
329
+ monaco: r,
330
+ isInitialized: n,
331
+ resolve: o
332
+ };
333
+ });
334
+ if (!e.isInitialized) {
335
+ if (Y({
336
+ isInitialized: !0
337
+ }), e.monaco)
338
+ return e.resolve(e.monaco), ee(te);
339
+ if (window.monaco && window.monaco.editor)
340
+ return we(window.monaco), e.resolve(window.monaco), ee(te);
341
+ ut(pt, mt)(ht);
342
+ }
343
+ return ee(te);
344
+ }
345
+ function pt(e) {
346
+ return document.body.appendChild(e);
347
+ }
348
+ function gt(e) {
349
+ var t = document.createElement("script");
350
+ return e && (t.src = e), t;
351
+ }
352
+ function mt(e) {
353
+ var t = H(function(n) {
354
+ var o = n.config, i = n.reject;
355
+ return {
356
+ config: o,
357
+ reject: i
358
+ };
359
+ }), r = gt("".concat(t.config.paths.vs, "/loader.js"));
360
+ return r.onload = function() {
361
+ return e();
362
+ }, r.onerror = t.reject, r;
363
+ }
364
+ function ht() {
365
+ var e = H(function(r) {
366
+ var n = r.config, o = r.resolve, i = r.reject;
367
+ return {
368
+ config: n,
369
+ resolve: o,
370
+ reject: i
371
+ };
372
+ }), t = window.require;
373
+ t.config(e.config), t(["vs/editor/editor.main"], function(r) {
374
+ var n = r.m || r;
375
+ we(n), e.resolve(n);
376
+ }, function(r) {
377
+ e.reject(r);
378
+ });
379
+ }
380
+ function we(e) {
381
+ H().monaco || Y({
382
+ monaco: e
383
+ });
384
+ }
385
+ function vt() {
386
+ return H(function(e) {
387
+ var t = e.monaco;
388
+ return t;
389
+ });
390
+ }
391
+ var te = new Promise(function(e, t) {
392
+ return Y({
393
+ resolve: e,
394
+ reject: t
395
+ });
396
+ }), G = {
397
+ config: dt,
398
+ init: ft,
399
+ __getMonacoInstance: vt
400
+ }, bt = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, re = bt, yt = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, wt = yt;
401
+ function Ot({ children: e }) {
402
+ return $.createElement("div", { style: wt.container }, e);
403
+ }
404
+ var jt = Ot, Mt = jt;
405
+ function Pt({ width: e, height: t, isEditorReady: r, loading: n, _ref: o, className: i, wrapperProps: c }) {
406
+ return $.createElement("section", { style: { ...re.wrapper, width: e, height: t }, ...c }, !r && $.createElement(Mt, null, n), $.createElement("div", { ref: o, style: { ...re.fullWidth, ...!r && re.hide }, className: i }));
407
+ }
408
+ var St = Pt, Oe = ie(St);
409
+ function Ct(e) {
410
+ S(e, []);
411
+ }
412
+ var ae = Ct;
413
+ function Et(e, t, r = !0) {
414
+ let n = h(!0);
415
+ S(n.current || !r ? () => {
416
+ n.current = !1;
417
+ } : e, t);
418
+ }
419
+ var j = Et;
420
+ function W() {
421
+ }
422
+ function R(e, t, r, n) {
423
+ return It(e, n) || Tt(e, t, r, n);
424
+ }
425
+ function It(e, t) {
426
+ return e.editor.getModel(je(e, t));
427
+ }
428
+ function Tt(e, t, r, n) {
429
+ return e.editor.createModel(t, r, n ? je(e, n) : void 0);
430
+ }
431
+ function je(e, t) {
432
+ return e.Uri.parse(t);
433
+ }
434
+ function Lt({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: o, originalModelPath: i, modifiedModelPath: c, keepCurrentOriginalModel: d = !1, keepCurrentModifiedModel: g = !1, theme: l = "light", loading: M = "Loading...", options: b = {}, height: A = "100%", width: V = "100%", className: q, wrapperProps: z = {}, beforeMount: E = W, onMount: D = W }) {
435
+ let [f, C] = N(!1), [I, s] = N(!0), v = h(null), m = h(null), x = h(null), u = h(D), a = h(E), O = h(!1);
436
+ ae(() => {
437
+ let p = G.init();
438
+ return p.then((y) => (m.current = y) && s(!1)).catch((y) => y?.type !== "cancelation" && console.error("Monaco initialization: error:", y)), () => v.current ? U() : p.cancel();
439
+ }), j(() => {
440
+ if (v.current && m.current) {
441
+ let p = v.current.getOriginalEditor(), y = R(m.current, e || "", n || r || "text", i || "");
442
+ y !== p.getModel() && p.setModel(y);
443
+ }
444
+ }, [i], f), j(() => {
445
+ if (v.current && m.current) {
446
+ let p = v.current.getModifiedEditor(), y = R(m.current, t || "", o || r || "text", c || "");
447
+ y !== p.getModel() && p.setModel(y);
448
+ }
449
+ }, [c], f), j(() => {
450
+ let p = v.current.getModifiedEditor();
451
+ p.getOption(m.current.editor.EditorOption.readOnly) ? p.setValue(t || "") : t !== p.getValue() && (p.executeEdits("", [{ range: p.getModel().getFullModelRange(), text: t || "", forceMoveMarkers: !0 }]), p.pushUndoStop());
452
+ }, [t], f), j(() => {
453
+ v.current?.getModel()?.original.setValue(e || "");
454
+ }, [e], f), j(() => {
455
+ let { original: p, modified: y } = v.current.getModel();
456
+ m.current.editor.setModelLanguage(p, n || r || "text"), m.current.editor.setModelLanguage(y, o || r || "text");
457
+ }, [r, n, o], f), j(() => {
458
+ m.current?.editor.setTheme(l);
459
+ }, [l], f), j(() => {
460
+ v.current?.updateOptions(b);
461
+ }, [b], f);
462
+ let P = ne(() => {
463
+ if (!m.current) return;
464
+ a.current(m.current);
465
+ let p = R(m.current, e || "", n || r || "text", i || ""), y = R(m.current, t || "", o || r || "text", c || "");
466
+ v.current?.setModel({ original: p, modified: y });
467
+ }, [r, t, o, e, n, i, c]), _ = ne(() => {
468
+ !O.current && x.current && (v.current = m.current.editor.createDiffEditor(x.current, { automaticLayout: !0, ...b }), P(), m.current?.editor.setTheme(l), C(!0), O.current = !0);
469
+ }, [b, l, P]);
470
+ S(() => {
471
+ f && u.current(v.current, m.current);
472
+ }, [f]), S(() => {
473
+ !I && !f && _();
474
+ }, [I, f, _]);
475
+ function U() {
476
+ let p = v.current?.getModel();
477
+ d || p?.original?.dispose(), g || p?.modified?.dispose(), v.current?.dispose();
478
+ }
479
+ return $.createElement(Oe, { width: V, height: A, isEditorReady: f, loading: M, _ref: x, className: q, wrapperProps: z });
480
+ }
481
+ var Dt = Lt;
482
+ ie(Dt);
483
+ function xt() {
484
+ let [e, t] = N(G.__getMonacoInstance());
485
+ return ae(() => {
486
+ let r;
487
+ return e || (r = G.init(), r.then((n) => {
488
+ t(n);
489
+ })), () => r?.cancel();
490
+ }), e;
491
+ }
492
+ var At = xt;
493
+ function Rt(e) {
494
+ let t = h();
495
+ return S(() => {
496
+ t.current = e;
497
+ }, [e]), t.current;
498
+ }
499
+ var $t = Rt, K = /* @__PURE__ */ new Map();
500
+ function Nt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: o, path: i, theme: c = "light", line: d, loading: g = "Loading...", options: l = {}, overrideServices: M = {}, saveViewState: b = !0, keepCurrentModel: A = !1, width: V = "100%", height: q = "100%", className: z, wrapperProps: E = {}, beforeMount: D = W, onMount: f = W, onChange: C, onValidate: I = W }) {
501
+ let [s, v] = N(!1), [m, x] = N(!0), u = h(null), a = h(null), O = h(null), P = h(f), _ = h(D), U = h(), p = h(n), y = $t(i), ue = h(!1), Q = h(!1);
502
+ ae(() => {
503
+ let w = G.init();
504
+ return w.then((T) => (u.current = T) && x(!1)).catch((T) => T?.type !== "cancelation" && console.error("Monaco initialization: error:", T)), () => a.current ? Me() : w.cancel();
505
+ }), j(() => {
506
+ let w = R(u.current, e || n || "", t || o || "", i || r || "");
507
+ w !== a.current?.getModel() && (b && K.set(y, a.current?.saveViewState()), a.current?.setModel(w), b && a.current?.restoreViewState(K.get(i)));
508
+ }, [i], s), j(() => {
509
+ a.current?.updateOptions(l);
510
+ }, [l], s), j(() => {
511
+ !a.current || n === void 0 || (a.current.getOption(u.current.editor.EditorOption.readOnly) ? a.current.setValue(n) : n !== a.current.getValue() && (Q.current = !0, a.current.executeEdits("", [{ range: a.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), a.current.pushUndoStop(), Q.current = !1));
512
+ }, [n], s), j(() => {
513
+ let w = a.current?.getModel();
514
+ w && o && u.current?.editor.setModelLanguage(w, o);
515
+ }, [o], s), j(() => {
516
+ d !== void 0 && a.current?.revealLine(d);
517
+ }, [d], s), j(() => {
518
+ u.current?.editor.setTheme(c);
519
+ }, [c], s);
520
+ let ce = ne(() => {
521
+ if (!(!O.current || !u.current) && !ue.current) {
522
+ _.current(u.current);
523
+ let w = i || r, T = R(u.current, n || e || "", t || o || "", w || "");
524
+ a.current = u.current?.editor.create(O.current, { model: T, automaticLayout: !0, ...l }, M), b && a.current.restoreViewState(K.get(w)), u.current.editor.setTheme(c), d !== void 0 && a.current.revealLine(d), v(!0), ue.current = !0;
525
+ }
526
+ }, [e, t, r, n, o, i, l, M, b, c, d]);
527
+ S(() => {
528
+ s && P.current(a.current, u.current);
529
+ }, [s]), S(() => {
530
+ !m && !s && ce();
531
+ }, [m, s, ce]), p.current = n, S(() => {
532
+ s && C && (U.current?.dispose(), U.current = a.current?.onDidChangeModelContent((w) => {
533
+ Q.current || C(a.current.getValue(), w);
534
+ }));
535
+ }, [s, C]), S(() => {
536
+ if (s) {
537
+ let w = u.current.editor.onDidChangeMarkers((T) => {
538
+ let X = a.current.getModel()?.uri;
539
+ if (X && T.find((Z) => Z.path === X.path)) {
540
+ let Z = u.current.editor.getModelMarkers({ resource: X });
541
+ I?.(Z);
542
+ }
543
+ });
544
+ return () => {
545
+ w?.dispose();
546
+ };
547
+ }
548
+ return () => {
549
+ };
550
+ }, [s, I]);
551
+ function Me() {
552
+ U.current?.dispose(), A ? b && K.set(i, a.current.saveViewState()) : a.current.getModel()?.dispose(), a.current.dispose();
553
+ }
554
+ return $.createElement(Oe, { width: V, height: q, isEditorReady: s, loading: g, _ref: O, className: z, wrapperProps: E });
555
+ }
556
+ var Vt = Nt, qt = ie(Vt), zt = qt;
557
+ const Ut = Wt(500), Ft = Ce(
558
+ ({
559
+ feedback: e,
560
+ hint: t,
561
+ inline: r,
562
+ label: n,
563
+ defaultValue: o,
564
+ readOnly: i,
565
+ value: c,
566
+ language: d = "plaintext",
567
+ height: g = "220px",
568
+ jsonSchema: l = "none",
569
+ onValidate: M,
570
+ onValid: b,
571
+ onChange: A,
572
+ onFocus: V,
573
+ onBlur: q,
574
+ noRounding: z = !1,
575
+ ...E
576
+ }, D) => {
577
+ const f = At(), C = h(null), I = h(null), [s, v] = N(
578
+ null
579
+ ), {
580
+ settings: { domain: m }
581
+ } = Pe(), x = (u) => {
582
+ u != null && D != null && typeof D == "object" && (D.current = u), v(u), u.onDidBlurEditorText(q ?? (() => {
583
+ })), u.onDidFocusEditorText(V ?? (() => {
584
+ })), u.layout(), u.onDidPaste(() => {
585
+ u.getAction("editor.action.formatDocument")?.run();
586
+ });
587
+ };
588
+ return S(
589
+ function() {
590
+ s != null && f != null && (I.current?.dispose(), I.current = s.onDidChangeModelContent(
591
+ () => {
592
+ const a = s.getModel(), O = f.editor.getModelMarkers({
593
+ resource: a?.uri
594
+ }), P = s.getValue();
595
+ Ut(() => {
596
+ M?.(O.length > 0 ? O : null), A?.(P), O.length === 0 && b?.(P);
597
+ });
598
+ }
599
+ ));
600
+ },
601
+ [s, f, A]
602
+ ), S(() => ((async () => {
603
+ const u = s?.getModel()?.uri.toString();
604
+ if (f != null && u != null && l != null) {
605
+ C.current?.dispose();
606
+ const a = f.languages.json.jsonDefaults.diagnosticsOptions.schemas ?? [], O = await Ee(l, m).then(
607
+ (P) => P != null ? oe(P) : P
608
+ );
609
+ switch (l) {
610
+ case "none":
611
+ break;
612
+ case "organization-config": {
613
+ a.push({
614
+ schema: O,
615
+ uri: `file:///json-schema--${l}.json`,
616
+ fileMatch: [u]
617
+ });
618
+ break;
619
+ }
620
+ case "order-rules": {
621
+ a.push({
622
+ schema: O,
623
+ uri: `file:///json-schema--${l}.json`,
624
+ fileMatch: [u]
625
+ }), C.current = he(f, u, ["order"]);
626
+ break;
627
+ }
628
+ case "price-rules": {
629
+ a.push({
630
+ schema: O,
631
+ uri: `file:///json-schema--${l}.json`,
632
+ fileMatch: [u]
633
+ }), C.current = he(f, u, ["price"]);
634
+ break;
635
+ }
636
+ }
637
+ f.languages.json.jsonDefaults.setDiagnosticsOptions({
638
+ enableSchemaRequest: !0,
639
+ schemaRequest: "ignore",
640
+ schemaValidation: "error",
641
+ validate: !0,
642
+ schemas: a
643
+ });
644
+ }
645
+ })(), () => {
646
+ C.current?.dispose();
647
+ }), [f, s, l, m]), /* @__PURE__ */ le.jsx(
648
+ Se,
649
+ {
650
+ label: n,
651
+ hint: t,
652
+ feedback: e,
653
+ name: E.id ?? E.name,
654
+ inline: r,
655
+ className: "h-full [&>div:first-of-type]:h-full",
656
+ children: /* @__PURE__ */ le.jsx(
657
+ zt,
658
+ {
659
+ defaultPath: E.id ?? E.name,
660
+ className: z ? void 0 : "[&>.monaco-editor]:rounded [&>.monaco-editor>.overflow-guard]:rounded",
661
+ theme: "vs-dark",
662
+ language: d,
663
+ height: g,
664
+ defaultValue: o,
665
+ value: c,
666
+ onMount: x,
667
+ options: {
668
+ quickSuggestions: !0,
669
+ readOnly: i,
670
+ domReadOnly: !0,
671
+ automaticLayout: !0,
672
+ insertSpaces: !0,
673
+ tabSize: 2,
674
+ lineNumbers: "on",
675
+ padding: { top: 18, bottom: 18 },
676
+ scrollBeyondLastLine: !1,
677
+ pasteAs: { enabled: !0 },
678
+ minimap: {
679
+ enabled: !1
680
+ }
681
+ }
682
+ }
683
+ )
684
+ }
685
+ );
686
+ }
687
+ );
688
+ Ft.displayName = "CodeEditor";
689
+ function Wt(e = 100) {
690
+ let t = null;
691
+ return function(n) {
692
+ t !== null && clearTimeout(t), t = setTimeout(() => {
693
+ n(), t = null;
694
+ }, e);
695
+ };
696
+ }
697
+ function oe(e, t) {
698
+ return typeof e != "object" || e === null ? e : Array.isArray(e) ? e.map((r) => oe(r)) : Object.entries(e).reduce((r, [n, o]) => t !== "properties" && ["examples", "default"].includes(n) ? r : {
699
+ ...r,
700
+ [n]: oe(o, n)
701
+ }, {});
702
+ }
703
+ function he(e, t, r) {
704
+ return e.languages.registerCompletionItemProvider("json", {
705
+ triggerCharacters: ['"', ":", "."],
706
+ provideCompletionItems: async (o, i) => {
707
+ if (o.uri.toString() !== t.toString())
708
+ return {
709
+ suggestions: []
710
+ };
711
+ const c = o.getWordUntilPosition(i), d = o.getLineContent(i.lineNumber).substring(0, i.column - 1);
712
+ if (/"(field|selector)"\s*:\s*"[^"]*$/.test(d)) {
713
+ const l = c.word;
714
+ if (l != null)
715
+ return {
716
+ incomplete: !1,
717
+ suggestions: (await Ie(
718
+ r,
719
+ l
720
+ )).map((b) => ({
721
+ kind: b.type === "relationship" ? e.languages.CompletionItemKind.Module : e.languages.CompletionItemKind.Value,
722
+ label: b.value,
723
+ insertText: b.value,
724
+ // documentation: `Field: ${suggestion}`,
725
+ range: {
726
+ startLineNumber: i.lineNumber,
727
+ startColumn: c.startColumn,
728
+ endLineNumber: i.lineNumber,
729
+ endColumn: c.endColumn
730
+ }
731
+ }))
732
+ };
733
+ }
734
+ return {
735
+ suggestions: []
736
+ };
737
+ }
738
+ });
739
+ }
740
+ export {
741
+ Ft as CodeEditor
742
+ };