@mieweb/forms-editor 1.3.0 → 2.0.1

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.js CHANGED
@@ -47,35 +47,35 @@ function It() {
47
47
  return a.$$typeof === P ? null : a.displayName || a.name || null;
48
48
  if (typeof a == "string") return a;
49
49
  switch (a) {
50
- case O:
50
+ case k:
51
51
  return "Fragment";
52
- case j:
52
+ case w:
53
53
  return "Profiler";
54
54
  case R:
55
55
  return "StrictMode";
56
- case x:
56
+ case b:
57
57
  return "Suspense";
58
58
  case f:
59
59
  return "SuspenseList";
60
- case k:
60
+ case I:
61
61
  return "Activity";
62
62
  }
63
63
  if (typeof a == "object")
64
64
  switch (typeof a.tag == "number" && console.error(
65
65
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
66
66
  ), a.$$typeof) {
67
- case N:
67
+ case j:
68
68
  return "Portal";
69
- case S:
69
+ case T:
70
70
  return a.displayName || "Context";
71
- case I:
71
+ case A:
72
72
  return (a._context.displayName || "Context") + ".Consumer";
73
- case b:
73
+ case x:
74
74
  var v = a.render;
75
75
  return a = a.displayName, a || (a = v.displayName || v.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
76
- case T:
76
+ case O:
77
77
  return v = a.displayName || null, v !== null ? v : e(a.type) || "Memo";
78
- case w:
78
+ case E:
79
79
  v = a._payload, a = a._init;
80
80
  try {
81
81
  return e(a(v));
@@ -105,8 +105,8 @@ function It() {
105
105
  }
106
106
  }
107
107
  function n(a) {
108
- if (a === O) return "<>";
109
- if (typeof a == "object" && a !== null && a.$$typeof === w)
108
+ if (a === k) return "<>";
109
+ if (typeof a == "object" && a !== null && a.$$typeof === E)
110
110
  return "<...>";
111
111
  try {
112
112
  var v = e(a);
@@ -148,14 +148,14 @@ function It() {
148
148
  )), a = this.props.ref, a !== void 0 ? a : null;
149
149
  }
150
150
  function u(a, v, y, D, oe, be) {
151
- var q = y.ref;
151
+ var L = y.ref;
152
152
  return a = {
153
153
  $$typeof: _,
154
154
  type: a,
155
155
  key: v,
156
156
  props: y,
157
157
  _owner: D
158
- }, (q !== void 0 ? q : null) !== null ? Object.defineProperty(a, "ref", {
158
+ }, (L !== void 0 ? L : null) !== null ? Object.defineProperty(a, "ref", {
159
159
  enumerable: !1,
160
160
  get: c
161
161
  }) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
@@ -181,24 +181,24 @@ function It() {
181
181
  }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
182
182
  }
183
183
  function h(a, v, y, D, oe, be) {
184
- var q = v.children;
185
- if (q !== void 0)
184
+ var L = v.children;
185
+ if (L !== void 0)
186
186
  if (D)
187
- if (M(q)) {
188
- for (D = 0; D < q.length; D++)
189
- g(q[D]);
190
- Object.freeze && Object.freeze(q);
187
+ if (M(L)) {
188
+ for (D = 0; D < L.length; D++)
189
+ g(L[D]);
190
+ Object.freeze && Object.freeze(L);
191
191
  } else
192
192
  console.error(
193
193
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
194
194
  );
195
- else g(q);
195
+ else g(L);
196
196
  if (C.call(v, "key")) {
197
- q = e(a);
197
+ L = e(a);
198
198
  var X = Object.keys(v).filter(function(et) {
199
199
  return et !== "key";
200
200
  });
201
- D = 0 < X.length ? "{key: someKey, " + X.join(": ..., ") + ": ...}" : "{key: someKey}", Y[q + D] || (X = 0 < X.length ? "{" + X.join(": ..., ") + ": ...}" : "{}", console.error(
201
+ D = 0 < X.length ? "{key: someKey, " + X.join(": ..., ") + ": ...}" : "{key: someKey}", Y[L + D] || (X = 0 < X.length ? "{" + X.join(": ..., ") + ": ...}" : "{}", console.error(
202
202
  `A props object containing a "key" prop is being spread into JSX:
203
203
  let props = %s;
204
204
  <%s {...props} />
@@ -206,22 +206,22 @@ React keys must be passed directly to JSX without using spread:
206
206
  let props = %s;
207
207
  <%s key={someKey} {...props} />`,
208
208
  D,
209
- q,
209
+ L,
210
210
  X,
211
- q
212
- ), Y[q + D] = !0);
211
+ L
212
+ ), Y[L + D] = !0);
213
213
  }
214
- if (q = null, y !== void 0 && (r(y), q = "" + y), d(v) && (r(v.key), q = "" + v.key), "key" in v) {
214
+ if (L = null, y !== void 0 && (r(y), L = "" + y), d(v) && (r(v.key), L = "" + v.key), "key" in v) {
215
215
  y = {};
216
216
  for (var ge in v)
217
217
  ge !== "key" && (y[ge] = v[ge]);
218
218
  } else y = v;
219
- return q && m(
219
+ return L && m(
220
220
  y,
221
221
  typeof a == "function" ? a.displayName || a.name || "Unknown" : a
222
222
  ), u(
223
223
  a,
224
- q,
224
+ L,
225
225
  y,
226
226
  s(),
227
227
  oe,
@@ -229,24 +229,24 @@ React keys must be passed directly to JSX without using spread:
229
229
  );
230
230
  }
231
231
  function g(a) {
232
- A(a) ? a._store && (a._store.validated = 1) : typeof a == "object" && a !== null && a.$$typeof === w && (a._payload.status === "fulfilled" ? A(a._payload.value) && a._payload.value._store && (a._payload.value._store.validated = 1) : a._store && (a._store.validated = 1));
232
+ S(a) ? a._store && (a._store.validated = 1) : typeof a == "object" && a !== null && a.$$typeof === E && (a._payload.status === "fulfilled" ? S(a._payload.value) && a._payload.value._store && (a._payload.value._store.validated = 1) : a._store && (a._store.validated = 1));
233
233
  }
234
- function A(a) {
234
+ function S(a) {
235
235
  return typeof a == "object" && a !== null && a.$$typeof === _;
236
236
  }
237
- var L = l, _ = /* @__PURE__ */ Symbol.for("react.transitional.element"), N = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), R = /* @__PURE__ */ Symbol.for("react.strict_mode"), j = /* @__PURE__ */ Symbol.for("react.profiler"), I = /* @__PURE__ */ Symbol.for("react.consumer"), S = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), f = /* @__PURE__ */ Symbol.for("react.suspense_list"), T = /* @__PURE__ */ Symbol.for("react.memo"), w = /* @__PURE__ */ Symbol.for("react.lazy"), k = /* @__PURE__ */ Symbol.for("react.activity"), P = /* @__PURE__ */ Symbol.for("react.client.reference"), p = L.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, M = Array.isArray, E = console.createTask ? console.createTask : function() {
237
+ var q = l, _ = /* @__PURE__ */ Symbol.for("react.transitional.element"), j = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), R = /* @__PURE__ */ Symbol.for("react.strict_mode"), w = /* @__PURE__ */ Symbol.for("react.profiler"), A = /* @__PURE__ */ Symbol.for("react.consumer"), T = /* @__PURE__ */ Symbol.for("react.context"), x = /* @__PURE__ */ Symbol.for("react.forward_ref"), b = /* @__PURE__ */ Symbol.for("react.suspense"), f = /* @__PURE__ */ Symbol.for("react.suspense_list"), O = /* @__PURE__ */ Symbol.for("react.memo"), E = /* @__PURE__ */ Symbol.for("react.lazy"), I = /* @__PURE__ */ Symbol.for("react.activity"), P = /* @__PURE__ */ Symbol.for("react.client.reference"), p = q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
238
238
  return null;
239
239
  };
240
- L = {
240
+ q = {
241
241
  react_stack_bottom_frame: function(a) {
242
242
  return a();
243
243
  }
244
244
  };
245
- var F, $ = {}, z = L.react_stack_bottom_frame.bind(
246
- L,
245
+ var F, $ = {}, z = q.react_stack_bottom_frame.bind(
246
+ q,
247
247
  o
248
- )(), H = E(n(o)), Y = {};
249
- ee.Fragment = O, ee.jsx = function(a, v, y) {
248
+ )(), H = N(n(o)), Y = {};
249
+ ee.Fragment = k, ee.jsx = function(a, v, y) {
250
250
  var D = 1e4 > p.recentlyCreatedOwnerStacks++;
251
251
  return h(
252
252
  a,
@@ -254,7 +254,7 @@ React keys must be passed directly to JSX without using spread:
254
254
  y,
255
255
  !1,
256
256
  D ? Error("react-stack-top-frame") : z,
257
- D ? E(n(a)) : H
257
+ D ? N(n(a)) : H
258
258
  );
259
259
  }, ee.jsxs = function(a, v, y) {
260
260
  var D = 1e4 > p.recentlyCreatedOwnerStacks++;
@@ -264,7 +264,7 @@ React keys must be passed directly to JSX without using spread:
264
264
  y,
265
265
  !0,
266
266
  D ? Error("react-stack-top-frame") : z,
267
- D ? E(n(a)) : H
267
+ D ? N(n(a)) : H
268
268
  );
269
269
  };
270
270
  })()), ee;
@@ -275,73 +275,73 @@ function St() {
275
275
  }
276
276
  var t = St();
277
277
  function kt() {
278
- const [e, i] = l.useState(!1), [r, n] = l.useState(null), s = V((j) => j.replaceAll), o = $e(), { showAlert: d } = Ue(), m = B(), c = m.state.isPreview, u = m.state.isCodeEditor ?? !1, h = m.state.codeEditorHasError ?? !1, g = (j) => {
278
+ const [e, i] = l.useState(!1), [r, n] = l.useState(null), s = V((w) => w.replaceAll), o = $e(), { showAlert: d } = Ue(), m = B(), c = m.state.isPreview, u = m.state.isCodeEditor ?? !1, h = m.state.codeEditorHasError ?? !1, g = (w) => {
279
279
  try {
280
- const I = String(j).replace(/^\uFEFF/, "").trim(), { data: S, schemaType: b } = fe(I);
281
- if (b !== "mieforms" && b !== "surveyjs") {
280
+ const A = String(w).replace(/^\uFEFF/, "").trim(), { data: T, schemaType: x } = fe(A);
281
+ if (x !== "mieforms" && x !== "surveyjs") {
282
282
  d(
283
283
  `Expected: MIE Forms or SurveyJS
284
- Detected: ${b}`,
284
+ Detected: ${x}`,
285
285
  { title: "Unsupported Schema Format" }
286
286
  );
287
287
  return;
288
288
  }
289
- n({ data: S, detectedSchemaType: b }), i(!0);
290
- } catch (I) {
289
+ n({ data: T, detectedSchemaType: x }), i(!0);
290
+ } catch (A) {
291
291
  d(
292
- I?.message || "Invalid file format",
292
+ A?.message || "Invalid file format",
293
293
  { title: "Failed to Parse File" }
294
294
  );
295
295
  }
296
- }, A = (j) => {
296
+ }, S = (w) => {
297
297
  if (r)
298
298
  try {
299
- const { data: I } = r, S = pe(I, j), b = S.fields || [];
300
- if (!Array.isArray(b))
299
+ const { data: A } = r, T = pe(A, w), x = T.fields || [];
300
+ if (!Array.isArray(x))
301
301
  throw new Error("Expected array of fields");
302
- S.conversionReport && m.setConversionReport(S.conversionReport);
303
- const x = {
304
- schemaType: j === "surveyjs" ? "mieforms-v1.0" : I.schemaType || "mieforms-v1.0",
305
- ...S.conversionReport?.surveyMetadata || {},
306
- fields: b
302
+ T.conversionReport && m.setConversionReport(T.conversionReport);
303
+ const b = {
304
+ schemaType: w === "surveyjs" ? "mieforms-v1.0" : A.schemaType || "mieforms-v1.0",
305
+ ...T.conversionReport?.surveyMetadata || {},
306
+ fields: x
307
307
  };
308
- if (j === "mieforms") {
309
- const { fields: f, schemaType: T, ...w } = I;
310
- Object.keys(w).length > 0 && Object.assign(x, w);
308
+ if (w === "mieforms") {
309
+ const { fields: f, schemaType: O, ...E } = A;
310
+ Object.keys(E).length > 0 && Object.assign(b, E);
311
311
  }
312
- if (s(x), m.selectedFieldId.clear(), m.preview.set(!1), j === "surveyjs" && S.conversionReport) {
313
- const f = S.conversionReport, T = f.unsupportedFields?.length || 0;
312
+ if (s(b), m.selectedFieldId.clear(), m.preview.set(!1), w === "surveyjs" && T.conversionReport) {
313
+ const f = T.conversionReport, O = f.unsupportedFields?.length || 0;
314
314
  d(
315
315
  `Format: SurveyJS → MIE Forms
316
316
 
317
317
  Converted: ${f.convertedFields || 0} field(s)
318
- Unsupported: ${T} field(s)${T > 0 ? " ⚠️" : ""}`,
318
+ Unsupported: ${O} field(s)${O > 0 ? " ⚠️" : ""}`,
319
319
  { title: "✅ Import Successful" }
320
320
  );
321
321
  } else
322
322
  d(
323
- `Format: ${j === "surveyjs" ? "SurveyJS" : "MIE Forms"}
324
- Loaded ${b.length} field(s)`,
323
+ `Format: ${w === "surveyjs" ? "SurveyJS" : "MIE Forms"}
324
+ Loaded ${x.length} field(s)`,
325
325
  { title: "✅ Import Successful" }
326
326
  );
327
327
  i(!1), n(null);
328
- } catch (I) {
328
+ } catch (A) {
329
329
  d(
330
- I?.message || "Invalid format",
330
+ A?.message || "Invalid format",
331
331
  { title: "Import Failed" }
332
332
  ), i(!1), n(null);
333
333
  }
334
- }, L = () => {
334
+ }, q = () => {
335
335
  i(!1), n(null);
336
336
  }, _ = () => {
337
337
  m.preview.set(!1), m.codeEditor.set(!1);
338
- }, N = () => {
338
+ }, j = () => {
339
339
  m.preview.set(!1), m.codeEditor.set(!0);
340
- }, O = () => {
340
+ }, k = () => {
341
341
  m.preview.set(!0), m.codeEditor.set(!1), m.selectedFieldId.clear();
342
342
  }, R = () => {
343
- const j = JSON.stringify(o, null, 2), I = new Blob([j], { type: "application/json" }), S = URL.createObjectURL(I), b = document.createElement("a");
344
- b.href = S, b.download = "questionnaire.json", b.click(), URL.revokeObjectURL(S);
343
+ const w = JSON.stringify(o, null, 2), A = new Blob([w], { type: "application/json" }), T = URL.createObjectURL(A), x = document.createElement("a");
344
+ x.href = T, x.download = "questionnaire.json", x.click(), URL.revokeObjectURL(T);
345
345
  };
346
346
  return /* @__PURE__ */ t.jsxs("header", { className: "editor-header mie:w-full mie:bg-miesurface mie:border mie:border-mieborder mie:rounded-lg mie:shadow-sm", children: [
347
347
  /* @__PURE__ */ t.jsx("div", { className: "mie:px-4 mie:py-4", children: /* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:flex-wrap mie:items-center mie:justify-between mie:gap-3", children: [
@@ -363,7 +363,7 @@ Loaded ${b.length} field(s)`,
363
363
  "button",
364
364
  {
365
365
  className: `mie:flex mie:items-center mie:justify-center mie:gap-2 mie:px-2 mie:lg:px-4 mie:py-2 mie:lg:py-2 mie:rounded-lg mie:text-xs mie:lg:text-sm mie:font-medium mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none ${u ? "mie:bg-mieprimary mie:text-mietextsecondary mie:shadow-sm" : "mie:bg-transparent mie:text-mietextmuted mie:hover:text-mietext mie:hover:bg-miesurface"}`,
366
- onClick: N,
366
+ onClick: j,
367
367
  title: "Code Editor",
368
368
  children: [
369
369
  /* @__PURE__ */ t.jsx(it, { className: "mie:w-5 mie:h-5" }),
@@ -375,7 +375,7 @@ Loaded ${b.length} field(s)`,
375
375
  "button",
376
376
  {
377
377
  className: `mie:flex mie:items-center mie:justify-center mie:gap-2 mie:px-2 mie:lg:px-4 mie:py-2 mie:lg:py-2 mie:rounded-lg mie:text-xs mie:lg:text-sm mie:font-medium mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none ${c ? "mie:bg-mieprimary mie:text-mietextsecondary mie:shadow-sm" : h ? "mie:bg-transparent mie:text-mietextmuted/50 mie:cursor-not-allowed" : "mie:bg-transparent mie:text-mietextmuted mie:hover:text-mietext mie:hover:bg-miesurface"}`,
378
- onClick: O,
378
+ onClick: k,
379
379
  disabled: h,
380
380
  title: h ? "Fix code errors before switching" : "Preview Form",
381
381
  children: [
@@ -395,11 +395,11 @@ Loaded ${b.length} field(s)`,
395
395
  className: "mie:hidden",
396
396
  type: "file",
397
397
  accept: ".json,.yaml,.yml,application/json,text/yaml",
398
- onChange: (j) => {
399
- const I = j.target.files?.[0];
400
- if (!I) return;
401
- const S = new FileReader();
402
- S.onload = (b) => g(b.target?.result ?? ""), S.readAsText(I), j.target.value = "";
398
+ onChange: (w) => {
399
+ const A = w.target.files?.[0];
400
+ if (!A) return;
401
+ const T = new FileReader();
402
+ T.onload = (x) => g(x.target?.result ?? ""), T.readAsText(A), w.target.value = "";
403
403
  }
404
404
  }
405
405
  )
@@ -432,7 +432,7 @@ Loaded ${b.length} field(s)`,
432
432
  /* @__PURE__ */ t.jsx(
433
433
  "button",
434
434
  {
435
- onClick: () => A(r.detectedSchemaType),
435
+ onClick: () => S(r.detectedSchemaType),
436
436
  className: "mie:flex-1 mie:px-6 mie:py-3 mie:rounded-xl mie:bg-mieprimary mie:text-miesurface mie:font-semibold mie:hover:bg-mieprimary/90 mie:transition-colors mie:shadow-sm mie:hover:shadow",
437
437
  children: "Yes, Import"
438
438
  }
@@ -440,7 +440,7 @@ Loaded ${b.length} field(s)`,
440
440
  /* @__PURE__ */ t.jsx(
441
441
  "button",
442
442
  {
443
- onClick: L,
443
+ onClick: q,
444
444
  className: "mie:flex-1 mie:px-6 mie:py-3 mie:rounded-xl mie:border-2 mie:border-mieborder mie:bg-miesurface mie:hover:bg-miebackground mie:text-mietext mie:font-semibold mie:transition-colors",
445
445
  children: "Abort"
446
446
  }
@@ -485,8 +485,8 @@ const Rt = (e) => {
485
485
  const m = Ee(() => {
486
486
  const u = {};
487
487
  return Object.entries(K).filter(([h]) => h !== "unsupported").forEach(([h, g]) => {
488
- const A = g.category || "Other";
489
- u[A] || (u[A] = []), u[A].push({
488
+ const S = g.category || "Other";
489
+ u[S] || (u[S] = []), u[S].push({
490
490
  type: h,
491
491
  label: g.label
492
492
  });
@@ -530,18 +530,18 @@ const Rt = (e) => {
530
530
  })(),
531
531
  u
532
532
  ] }),
533
- /* @__PURE__ */ t.jsx("div", { className: "tool-items mie:grid mie:grid-cols-1 mie:gap-2 mie:px-4 mie:py-3", children: h.map(({ type: g, label: A }) => {
534
- const L = s && g === "section";
533
+ /* @__PURE__ */ t.jsx("div", { className: "tool-items mie:grid mie:grid-cols-1 mie:gap-2 mie:px-4 mie:py-3", children: h.map(({ type: g, label: S }) => {
534
+ const q = s && g === "section";
535
535
  return /* @__PURE__ */ t.jsxs(
536
536
  "button",
537
537
  {
538
- disabled: L,
539
- className: `mie:px-3 mie:py-2 mie:text-sm mie:text-left mie:border mie:rounded-md mie:transition-colors mie:duration-150 ${L ? "mie:border-mieborder mie:bg-miebackground mie:text-mietextmuted/50 mie:cursor-not-allowed" : "mie:bg-miesurface mie:text-mietext mie:border-mieborder mie:hover:bg-mieprimary/10 mie:hover:border-mieprimary/50 mie:hover:text-mieprimary"}`,
538
+ disabled: q,
539
+ className: `mie:px-3 mie:py-2 mie:text-sm mie:text-left mie:border mie:rounded-md mie:transition-colors mie:duration-150 ${q ? "mie:border-mieborder mie:bg-miebackground mie:text-mietextmuted/50 mie:cursor-not-allowed" : "mie:bg-miesurface mie:text-mietext mie:border-mieborder mie:hover:bg-mieprimary/10 mie:hover:border-mieprimary/50 mie:hover:text-mieprimary"}`,
540
540
  onClick: c[g],
541
- title: L ? "Cannot add section to a section" : `Add ${A}`,
541
+ title: q ? "Cannot add section to a section" : `Add ${S}`,
542
542
  children: [
543
543
  "+ ",
544
- A
544
+ S
545
545
  ]
546
546
  },
547
547
  g
@@ -572,9 +572,9 @@ function ze({
572
572
  }
573
573
  if (g !== (e ?? "")) {
574
574
  if (typeof n == "function") {
575
- const A = n(g, e ?? "");
576
- if (A) {
577
- u(A);
575
+ const S = n(g, e ?? "");
576
+ if (S) {
577
+ u(S);
578
578
  return;
579
579
  }
580
580
  }
@@ -885,7 +885,7 @@ function _t({ f: e }) {
885
885
  function Dt({ section: e, onActiveChildChange: i }) {
886
886
  const r = Ne(e.id), n = l.useContext(Oe), s = B();
887
887
  if (!n) throw new Error("Missing FormStoreContext.Provider in the tree");
888
- const o = Array.isArray(e.fields) ? e.fields : [], d = s.selectedChildId.ParentId, m = s.selectedChildId.ChildId, c = l.useMemo(() => d === e.id && m && o.some((x) => x.id === m) ? m : o[0]?.id || null, []), [u, h] = l.useState(c), g = l.useRef(m);
888
+ const o = Array.isArray(e.fields) ? e.fields : [], d = s.selectedChildId.ParentId, m = s.selectedChildId.ChildId, c = l.useMemo(() => d === e.id && m && o.some((b) => b.id === m) ? m : o[0]?.id || null, []), [u, h] = l.useState(c), g = l.useRef(m);
889
889
  l.useEffect(() => {
890
890
  g.current !== m && (g.current = m, d === e.id && m && m !== u && h(m));
891
891
  }, [d, m, e.id, u]), l.useEffect(() => {
@@ -897,51 +897,51 @@ function Dt({ section: e, onActiveChildChange: i }) {
897
897
  }, [o, u]), l.useEffect(() => {
898
898
  i?.(e.id, u || null);
899
899
  }, [e.id, u, i]);
900
- const A = l.useCallback(
901
- (x) => {
902
- h(x), s.selectedChildId.set(e.id, x);
900
+ const S = l.useCallback(
901
+ (b) => {
902
+ h(b), s.selectedChildId.set(e.id, b);
903
903
  },
904
904
  [e.id, s.selectedChildId]
905
- ), L = l.useCallback((x) => x.question?.trim() || K[x.fieldType]?.label || "Untitled", []), _ = l.useCallback(
906
- (x, f) => r.field.update(x, f),
905
+ ), q = l.useCallback((b) => b.question?.trim() || K[b.fieldType]?.label || "Untitled", []), _ = l.useCallback(
906
+ (b, f) => r.field.update(b, f),
907
907
  [r]
908
- ), N = l.useMemo(
909
- () => o.find((x) => x.id === u) || null,
908
+ ), j = l.useMemo(
909
+ () => o.find((b) => b.id === u) || null,
910
910
  [o, u]
911
- ), O = Ne(N?.id || "", e.id), R = N && O ? O : null, j = l.useCallback(
912
- (x, f) => {
913
- if (N) {
914
- if (x === "id") {
915
- const T = String(f ?? "").trim();
916
- if (!T) return;
911
+ ), k = Ne(j?.id || "", e.id), R = j && k ? k : null, w = l.useCallback(
912
+ (b, f) => {
913
+ if (j) {
914
+ if (b === "id") {
915
+ const O = String(f ?? "").trim();
916
+ if (!O) return;
917
917
  n.getState().updateField(
918
- N.id,
919
- { id: T },
918
+ j.id,
919
+ { id: O },
920
920
  {
921
921
  sectionId: e.id,
922
- onIdChange: (w, k) => {
923
- h((P) => P === k ? w : P);
922
+ onIdChange: (E, I) => {
923
+ h((P) => P === I ? E : P);
924
924
  }
925
925
  }
926
926
  );
927
927
  return;
928
928
  }
929
929
  n.getState().updateField(
930
- N.id,
931
- { [x]: f },
930
+ j.id,
931
+ { [b]: f },
932
932
  { sectionId: e.id }
933
933
  );
934
934
  }
935
935
  },
936
- [N, e.id, n]
937
- ), I = l.useCallback(() => {
938
- N && n.getState().deleteField(N.id, { sectionId: e.id });
939
- }, [N, e.id, n]), S = l.useMemo(
940
- () => N && (K[N.fieldType] || {}).hasOptions || !1,
941
- [N]
942
- ), b = l.useMemo(
943
- () => N && (K[N.fieldType] || {}).hasMatrix || !1,
944
- [N]
936
+ [j, e.id, n]
937
+ ), A = l.useCallback(() => {
938
+ j && n.getState().deleteField(j.id, { sectionId: e.id });
939
+ }, [j, e.id, n]), T = l.useMemo(
940
+ () => j && (K[j.fieldType] || {}).hasOptions || !1,
941
+ [j]
942
+ ), x = l.useMemo(
943
+ () => j && (K[j.fieldType] || {}).hasMatrix || !1,
944
+ [j]
945
945
  );
946
946
  return /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-4", children: [
947
947
  /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-3", children: [
@@ -950,7 +950,7 @@ function Dt({ section: e, onActiveChildChange: i }) {
950
950
  ze,
951
951
  {
952
952
  id: e.id,
953
- onCommit: (x) => r.field.renameId(x)
953
+ onCommit: (b) => r.field.renameId(b)
954
954
  }
955
955
  ),
956
956
  /* @__PURE__ */ t.jsxs("div", { className: "section-editor-title", children: [
@@ -960,7 +960,7 @@ function Dt({ section: e, onActiveChildChange: i }) {
960
960
  {
961
961
  className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:bg-miesurface mie:text-mietext mie:rounded mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none",
962
962
  value: e.title || "",
963
- onChange: (x) => _("title", x.target.value),
963
+ onChange: (b) => _("title", b.target.value),
964
964
  placeholder: "e.g., Patient Information"
965
965
  }
966
966
  )
@@ -982,24 +982,24 @@ function Dt({ section: e, onActiveChildChange: i }) {
982
982
  {
983
983
  className: "mie:w-full mie:px-3 mie:py-2 mie:pr-10 mie:border mie:border-mieborder mie:rounded mie:bg-miesurface mie:text-mietext mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:appearance-none mie:cursor-pointer",
984
984
  value: u || "",
985
- onChange: (x) => A(x.target.value),
986
- children: o.map((x) => /* @__PURE__ */ t.jsxs("option", { value: x.id, children: [
987
- L(x),
985
+ onChange: (b) => S(b.target.value),
986
+ children: o.map((b) => /* @__PURE__ */ t.jsxs("option", { value: b.id, children: [
987
+ q(b),
988
988
  " — ",
989
- K[x.fieldType]?.label
990
- ] }, x.id))
989
+ K[b.fieldType]?.label
990
+ ] }, b.id))
991
991
  }
992
992
  ),
993
993
  /* @__PURE__ */ t.jsx(ht, { className: "mie:absolute mie:right-3 mie:top-1/2 mie:-translate-y-1/2 mie:w-4 mie:h-4 mie:text-mietextmuted mie:pointer-events-none" })
994
994
  ] }),
995
- N && /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-4 mie:p-4 mie:bg-miebackground mie:border mie:border-mieborder mie:rounded-lg", children: [
995
+ j && /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-4 mie:p-4 mie:bg-miebackground mie:border mie:border-mieborder mie:rounded-lg", children: [
996
996
  /* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:items-center mie:justify-between", children: [
997
- /* @__PURE__ */ t.jsx("span", { className: "mie:inline-flex mie:items-center mie:px-2.5 mie:py-0.5 mie:rounded-full mie:text-xs mie:font-medium mie:bg-mieprimary/10 mie:text-mieprimary", children: K[N.fieldType]?.label || N.fieldType }),
997
+ /* @__PURE__ */ t.jsx("span", { className: "mie:inline-flex mie:items-center mie:px-2.5 mie:py-0.5 mie:rounded-full mie:text-xs mie:font-medium mie:bg-mieprimary/10 mie:text-mieprimary", children: K[j.fieldType]?.label || j.fieldType }),
998
998
  /* @__PURE__ */ t.jsxs(
999
999
  "button",
1000
1000
  {
1001
1001
  className: "mie:flex mie:items-center mie:gap-1.5 mie:px-3 mie:py-1.5 mie:text-xs mie:font-medium mie:bg-miesurface mie:text-miedanger mie:hover:text-miedanger mie:hover:bg-miedanger/10 mie:border mie:border-miedanger/50 mie:rounded mie:transition-colors",
1002
- onClick: I,
1002
+ onClick: A,
1003
1003
  title: "Delete this field",
1004
1004
  children: [
1005
1005
  /* @__PURE__ */ t.jsx(re, { className: "mie:w-3.5 mie:h-3.5" }),
@@ -1008,21 +1008,21 @@ function Dt({ section: e, onActiveChildChange: i }) {
1008
1008
  }
1009
1009
  )
1010
1010
  ] }),
1011
- /* @__PURE__ */ t.jsx(We, { f: N, onUpdateField: j }),
1012
- N.fieldType === "input" && /* @__PURE__ */ t.jsxs("div", { className: "section-editor-default-answer", children: [
1011
+ /* @__PURE__ */ t.jsx(We, { f: j, onUpdateField: w }),
1012
+ j.fieldType === "input" && /* @__PURE__ */ t.jsxs("div", { className: "section-editor-default-answer", children: [
1013
1013
  /* @__PURE__ */ t.jsx("label", { className: "mie:block mie:text-sm mie:font-medium mie:text-mietext mie:mb-1", children: "Default Answer" }),
1014
1014
  /* @__PURE__ */ t.jsx(
1015
1015
  "input",
1016
1016
  {
1017
1017
  className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:bg-miesurface mie:text-mietext mie:rounded mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none",
1018
- value: N.answer || "",
1019
- onChange: (x) => j("answer", x.target.value),
1018
+ value: j.answer || "",
1019
+ onChange: (b) => w("answer", b.target.value),
1020
1020
  placeholder: "Default value"
1021
1021
  }
1022
1022
  )
1023
1023
  ] }),
1024
- S && R && /* @__PURE__ */ t.jsx(Ve, { field: N, api: R }),
1025
- b && R && /* @__PURE__ */ t.jsx(He, { field: N, api: R })
1024
+ T && R && /* @__PURE__ */ t.jsx(Ve, { field: j, api: R }),
1025
+ x && R && /* @__PURE__ */ t.jsx(He, { field: j, api: R })
1026
1026
  ] })
1027
1027
  ] })
1028
1028
  ] })
@@ -1050,7 +1050,7 @@ function Re(e, i, r) {
1050
1050
  return ["equals", "notEquals"];
1051
1051
  }
1052
1052
  }
1053
- function Lt(e) {
1053
+ function qt(e) {
1054
1054
  switch (e) {
1055
1055
  case "check":
1056
1056
  case "multiselectdropdown":
@@ -1063,7 +1063,7 @@ function Lt(e) {
1063
1063
  return [];
1064
1064
  }
1065
1065
  }
1066
- function qt(e) {
1066
+ function Lt(e) {
1067
1067
  switch (e) {
1068
1068
  case "equals":
1069
1069
  return "= (equals)";
@@ -1100,31 +1100,31 @@ function Ae(e) {
1100
1100
  function $t() {
1101
1101
  const e = B(), i = V((p) => p.byId), r = V((p) => p.setEnableWhen), n = V((p) => p.updateField), s = e?.selectedFieldId?.value ?? null;
1102
1102
  e?.selectedChildId?.ParentId;
1103
- const o = e?.selectedChildId?.ChildId ?? null, d = s ? i[s] : null, m = d?.fieldType === "section", c = l.useMemo(() => m ? Array.isArray(d?.fields) ? d.fields : [] : [], [m, d]), u = l.useMemo(() => !m || !o ? !1 : c.some((p) => p.id === o), [m, o, c]), h = l.useMemo(() => m && u ? `child:${o}` : "", [m, u, o]), [g, A] = l.useState(h);
1103
+ const o = e?.selectedChildId?.ChildId ?? null, d = s ? i[s] : null, m = d?.fieldType === "section", c = l.useMemo(() => m ? Array.isArray(d?.fields) ? d.fields : [] : [], [m, d]), u = l.useMemo(() => !m || !o ? !1 : c.some((p) => p.id === o), [m, o, c]), h = l.useMemo(() => m && u ? `child:${o}` : "", [m, u, o]), [g, S] = l.useState(h);
1104
1104
  l.useEffect(() => {
1105
- A(h);
1105
+ S(h);
1106
1106
  }, [h]);
1107
- const L = l.useCallback((p) => {
1108
- if (A(p), !!m)
1107
+ const q = l.useCallback((p) => {
1108
+ if (S(p), !!m)
1109
1109
  if (p && p.startsWith("child:")) {
1110
1110
  const C = p.slice(6);
1111
1111
  e.selectedChildId.set(s, C);
1112
1112
  } else
1113
1113
  e.selectedChildId.set(null, null);
1114
- }, [m, s, e]), _ = !!(m && g && g.startsWith("child:")), N = _ ? g.slice(6) : null, O = _ ? N : s, R = l.useMemo(() => O ? _ ? c.find((p) => p.id === N) ?? null : i[O] ?? null : null, [i, O, _, N, c]), j = l.useMemo(() => {
1114
+ }, [m, s, e]), _ = !!(m && g && g.startsWith("child:")), j = _ ? g.slice(6) : null, k = _ ? j : s, R = l.useMemo(() => k ? _ ? c.find((p) => p.id === j) ?? null : i[k] ?? null : null, [i, k, _, j, c]), w = l.useMemo(() => {
1115
1115
  const p = [];
1116
1116
  for (const C of Object.values(i))
1117
1117
  if (C)
1118
1118
  if (C.fieldType === "section" && Array.isArray(C.fields)) {
1119
1119
  const M = C.title?.trim() || "Section";
1120
- C.fields.forEach((E) => {
1120
+ C.fields.forEach((N) => {
1121
1121
  p.push({
1122
- id: E.id,
1122
+ id: N.id,
1123
1123
  parentId: C.id,
1124
- label: `${M} › ${E.question?.trim() || E.id}`,
1125
- fieldType: E.fieldType,
1126
- displayFormat: E.displayFormat,
1127
- options: Array.isArray(E.options) ? E.options : []
1124
+ label: `${M} › ${N.question?.trim() || N.id}`,
1125
+ fieldType: N.fieldType,
1126
+ displayFormat: N.displayFormat,
1127
+ options: Array.isArray(N.options) ? N.options : []
1128
1128
  });
1129
1129
  });
1130
1130
  } else
@@ -1137,47 +1137,47 @@ function $t() {
1137
1137
  options: Array.isArray(C.options) ? C.options : []
1138
1138
  });
1139
1139
  return p;
1140
- }, [i]), I = l.useCallback(
1141
- (p) => j.find((C) => C.id === p) || null,
1142
- [j]
1143
- ), S = l.useCallback(
1140
+ }, [i]), A = l.useCallback(
1141
+ (p) => w.find((C) => C.id === p) || null,
1142
+ [w]
1143
+ ), T = l.useCallback(
1144
1144
  (p) => {
1145
- if (!O) return;
1145
+ if (!k) return;
1146
1146
  const C = p && Array.isArray(p.conditions) ? { logic: p.logic || "AND", conditions: p.conditions } : void 0;
1147
- _ && s ? n(O, { enableWhen: C }, { sectionId: s }) : r(O, C);
1147
+ _ && s ? n(k, { enableWhen: C }, { sectionId: s }) : r(k, C);
1148
1148
  },
1149
- [O, _, s, r, n]
1150
- ), b = l.useMemo(() => R?.enableWhen && Array.isArray(R.enableWhen.conditions) ? { logic: R.enableWhen.logic || "AND", conditions: R.enableWhen.conditions } : { logic: "AND", conditions: [] }, [R]), x = l.useCallback(() => {
1149
+ [k, _, s, r, n]
1150
+ ), x = l.useMemo(() => R?.enableWhen && Array.isArray(R.enableWhen.conditions) ? { logic: R.enableWhen.logic || "AND", conditions: R.enableWhen.conditions } : { logic: "AND", conditions: [] }, [R]), b = l.useCallback(() => {
1151
1151
  const p = {
1152
- logic: b.logic || "AND",
1152
+ logic: x.logic || "AND",
1153
1153
  conditions: [
1154
- ...Array.isArray(b.conditions) ? b.conditions : [],
1154
+ ...Array.isArray(x.conditions) ? x.conditions : [],
1155
1155
  { targetId: "", operator: "equals", value: "" }
1156
1156
  ]
1157
1157
  };
1158
- S(p);
1159
- }, [b, S]), f = l.useCallback(() => S(null), [S]), T = l.useCallback(
1158
+ T(p);
1159
+ }, [x, T]), f = l.useCallback(() => T(null), [T]), O = l.useCallback(
1160
1160
  (p) => {
1161
- const M = (Array.isArray(b.conditions) ? b.conditions : []).filter((E, F) => F !== p);
1162
- S({ ...b, conditions: M });
1161
+ const M = (Array.isArray(x.conditions) ? x.conditions : []).filter((N, F) => F !== p);
1162
+ T({ ...x, conditions: M });
1163
1163
  },
1164
- [b, S]
1165
- ), w = l.useCallback(
1164
+ [x, T]
1165
+ ), E = l.useCallback(
1166
1166
  (p, C) => {
1167
- const E = [...Array.isArray(b.conditions) ? b.conditions : []], $ = { ...E[p] || { targetId: "", operator: "equals", value: "" }, ...C };
1167
+ const N = [...Array.isArray(x.conditions) ? x.conditions : []], $ = { ...N[p] || { targetId: "", operator: "equals", value: "" }, ...C };
1168
1168
  if ("targetId" in C) {
1169
- const z = I($.targetId), H = Re(z?.fieldType, z?.displayFormat, z?.inputType);
1169
+ const z = A($.targetId), H = Re(z?.fieldType, z?.displayFormat, z?.inputType);
1170
1170
  H.includes($.operator) || ($.operator = H[0] || "equals");
1171
1171
  const Y = Array.isArray(z?.options) ? z.options.map(Ae) : [];
1172
1172
  Y.length > 0 && (new Set(Y.map((v) => v.id)).has($.value) || ($.value = ""));
1173
1173
  }
1174
- E[p] = $, S({ ...b, conditions: E });
1174
+ N[p] = $, T({ ...x, conditions: N });
1175
1175
  },
1176
- [b, I, S]
1177
- ), k = l.useMemo(
1178
- () => j.filter((p) => p.id !== O),
1179
- [j, O]
1180
- ), P = !R || !O;
1176
+ [x, A, T]
1177
+ ), I = l.useMemo(
1178
+ () => w.filter((p) => p.id !== k),
1179
+ [w, k]
1180
+ ), P = !R || !k;
1181
1181
  return /* @__PURE__ */ t.jsxs("div", { className: "logic-editor-container mie:space-y-4", children: [
1182
1182
  m && /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-2", children: [
1183
1183
  /* @__PURE__ */ t.jsx("label", { className: "mie:block mie:text-sm mie:font-medium mie:text-mietext", children: "Target Field" }),
@@ -1186,7 +1186,7 @@ function $t() {
1186
1186
  {
1187
1187
  className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:cursor-pointer mie:transition-colors",
1188
1188
  value: g,
1189
- onChange: (p) => L(p.target.value),
1189
+ onChange: (p) => q(p.target.value),
1190
1190
  children: [
1191
1191
  /* @__PURE__ */ t.jsx("option", { value: "", children: "Section (this)" }),
1192
1192
  c.map((p) => /* @__PURE__ */ t.jsx("option", { value: `child:${p.id}`, children: p.question?.trim() || p.title?.trim() || p.id }, p.id))
@@ -1200,8 +1200,8 @@ function $t() {
1200
1200
  /* @__PURE__ */ t.jsxs(
1201
1201
  "select",
1202
1202
  {
1203
- value: b.logic || "AND",
1204
- onChange: (p) => S({ ...b, logic: p.target.value }),
1203
+ value: x.logic || "AND",
1204
+ onChange: (p) => T({ ...x, logic: p.target.value }),
1205
1205
  className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:cursor-pointer mie:transition-colors",
1206
1206
  disabled: P,
1207
1207
  children: [
@@ -1217,7 +1217,7 @@ function $t() {
1217
1217
  {
1218
1218
  type: "button",
1219
1219
  className: "mie:flex-1 mie:px-3 mie:py-2 mie:text-sm mie:font-medium mie:bg-miesurface mie:text-mieprimary mie:border mie:border-mieprimary/50 mie:rounded-lg mie:hover:bg-mieprimary/10 mie:transition-colors mie:disabled:opacity-50 mie:disabled:cursor-not-allowed",
1220
- onClick: x,
1220
+ onClick: b,
1221
1221
  disabled: P,
1222
1222
  children: "+ Add Condition"
1223
1223
  }
@@ -1234,14 +1234,14 @@ function $t() {
1234
1234
  )
1235
1235
  ] })
1236
1236
  ] }),
1237
- b.conditions.length > 0 && /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-3", children: [
1237
+ x.conditions.length > 0 && /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-3", children: [
1238
1238
  /* @__PURE__ */ t.jsxs("h4", { className: "mie:text-sm mie:font-medium mie:text-mietext", children: [
1239
1239
  "Conditions (",
1240
- b.conditions.length,
1240
+ x.conditions.length,
1241
1241
  ")"
1242
1242
  ] }),
1243
- /* @__PURE__ */ t.jsx("div", { className: "mie:space-y-3", children: b.conditions.map((p, C) => {
1244
- const M = I(p.targetId), E = Re(M?.fieldType, M?.displayFormat, M?.inputType), F = M ? Lt(M.fieldType) : [], $ = F.length > 0, z = Array.isArray(M?.options) ? M.options.map(Ae) : [], H = z.length > 0, Y = !["empty", "notEmpty"].includes(p.operator), v = ["greaterThan", "greaterThanOrEqual", "lessThan", "lessThanOrEqual"].includes(p.operator);
1243
+ /* @__PURE__ */ t.jsx("div", { className: "mie:space-y-3", children: x.conditions.map((p, C) => {
1244
+ const M = A(p.targetId), N = Re(M?.fieldType, M?.displayFormat, M?.inputType), F = M ? qt(M.fieldType) : [], $ = F.length > 0, z = Array.isArray(M?.options) ? M.options.map(Ae) : [], H = z.length > 0, Y = !["empty", "notEmpty"].includes(p.operator), v = ["greaterThan", "greaterThanOrEqual", "lessThan", "lessThanOrEqual"].includes(p.operator);
1245
1245
  return /* @__PURE__ */ t.jsxs("div", { className: "mie:p-3 mie:bg-miebackground mie:border mie:border-mieborder mie:rounded-lg mie:space-y-2", children: [
1246
1246
  /* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:items-center mie:justify-between mie:mb-2", children: [
1247
1247
  /* @__PURE__ */ t.jsxs("span", { className: "mie:text-xs mie:font-semibold mie:text-mietextmuted mie:uppercase mie:tracking-wide", children: [
@@ -1252,7 +1252,7 @@ function $t() {
1252
1252
  "button",
1253
1253
  {
1254
1254
  type: "button",
1255
- onClick: () => T(C),
1255
+ onClick: () => O(C),
1256
1256
  className: "mie:bg-transparent mie:text-mietextmuted/70 mie:hover:text-miedanger mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none",
1257
1257
  title: "Remove condition",
1258
1258
  disabled: P,
@@ -1268,11 +1268,11 @@ function $t() {
1268
1268
  {
1269
1269
  className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:text-sm mie:cursor-pointer mie:transition-colors",
1270
1270
  value: p.targetId,
1271
- onChange: (y) => w(C, { targetId: y.target.value }),
1271
+ onChange: (y) => E(C, { targetId: y.target.value }),
1272
1272
  disabled: P,
1273
1273
  children: [
1274
1274
  /* @__PURE__ */ t.jsx("option", { value: "", children: "— Select field —" }),
1275
- k.map((y) => /* @__PURE__ */ t.jsx("option", { value: y.id, children: y.label }, y.id))
1275
+ I.map((y) => /* @__PURE__ */ t.jsx("option", { value: y.id, children: y.label }, y.id))
1276
1276
  ]
1277
1277
  }
1278
1278
  )
@@ -1284,7 +1284,7 @@ function $t() {
1284
1284
  {
1285
1285
  className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:text-sm mie:cursor-pointer mie:transition-colors",
1286
1286
  value: p.propertyAccessor || "",
1287
- onChange: (y) => w(C, { propertyAccessor: y.target.value || void 0 }),
1287
+ onChange: (y) => E(C, { propertyAccessor: y.target.value || void 0 }),
1288
1288
  disabled: P || !M,
1289
1289
  children: [
1290
1290
  /* @__PURE__ */ t.jsx("option", { value: "", children: "— Direct value —" }),
@@ -1308,9 +1308,9 @@ function $t() {
1308
1308
  {
1309
1309
  className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:text-sm mie:cursor-pointer mie:transition-colors",
1310
1310
  value: p.operator,
1311
- onChange: (y) => w(C, { operator: y.target.value }),
1311
+ onChange: (y) => E(C, { operator: y.target.value }),
1312
1312
  disabled: P || !M,
1313
- children: (M ? E : ["equals"]).map((y) => /* @__PURE__ */ t.jsx("option", { value: y, children: qt(y) }, y))
1313
+ children: (M ? N : ["equals"]).map((y) => /* @__PURE__ */ t.jsx("option", { value: y, children: Lt(y) }, y))
1314
1314
  }
1315
1315
  )
1316
1316
  ] }),
@@ -1321,7 +1321,7 @@ function $t() {
1321
1321
  {
1322
1322
  className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:text-sm mie:cursor-pointer mie:transition-colors",
1323
1323
  value: p.value,
1324
- onChange: (y) => w(C, { value: y.target.value }),
1324
+ onChange: (y) => E(C, { value: y.target.value }),
1325
1325
  disabled: P || !M,
1326
1326
  children: [
1327
1327
  /* @__PURE__ */ t.jsx("option", { value: "", children: "— Select option —" }),
@@ -1335,7 +1335,7 @@ function $t() {
1335
1335
  placeholder: p.propertyAccessor || v ? "Enter number" : "Enter value",
1336
1336
  type: p.propertyAccessor || v ? "number" : "text",
1337
1337
  value: p.value,
1338
- onChange: (y) => w(C, { value: y.target.value }),
1338
+ onChange: (y) => E(C, { value: y.target.value }),
1339
1339
  disabled: P || !M
1340
1340
  }
1341
1341
  ) : /* @__PURE__ */ t.jsx("div", { className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:bg-miebackground mie:text-sm mie:text-mietextmuted mie:flex mie:items-center", children: "(no value needed)" })
@@ -1586,7 +1586,7 @@ function De(e, i) {
1586
1586
  }
1587
1587
  return r;
1588
1588
  }
1589
- function Le(e) {
1589
+ function qe(e) {
1590
1590
  for (var i = 1; i < arguments.length; i++) {
1591
1591
  var r = arguments[i] != null ? arguments[i] : {};
1592
1592
  i % 2 ? De(Object(r), !0).forEach(function(n) {
@@ -1685,7 +1685,7 @@ function di(e, i) {
1685
1685
  return ne(i) ? i(e.current) : i;
1686
1686
  }
1687
1687
  function ui(e, i) {
1688
- return e.current = Le(Le({}, e.current), i), i;
1688
+ return e.current = qe(qe({}, e.current), i), i;
1689
1689
  }
1690
1690
  function fi(e, i, r) {
1691
1691
  return ne(i) ? i(e.current) : Object.keys(r).forEach(function(n) {
@@ -1715,7 +1715,7 @@ function bi(e) {
1715
1715
  return {}.toString.call(e).includes("Object");
1716
1716
  }
1717
1717
  function gi(e) {
1718
- return e || qe("configIsRequired"), bi(e) || qe("configType"), e.urls ? (vi(), {
1718
+ return e || Le("configIsRequired"), bi(e) || Le("configType"), e.urls ? (vi(), {
1719
1719
  paths: {
1720
1720
  vs: e.urls.monacoBase
1721
1721
  }
@@ -1741,7 +1741,7 @@ var Ye = {
1741
1741
 
1742
1742
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
1743
1743
  `
1744
- }, qe = xi(yi)(Ye), ji = {
1744
+ }, Le = xi(yi)(Ye), ji = {
1745
1745
  config: gi
1746
1746
  }, wi = function() {
1747
1747
  for (var i = arguments.length, r = new Array(i), n = 0; n < i; n++)
@@ -1866,11 +1866,11 @@ var je = new Promise(function(e, i) {
1866
1866
  function _i({ children: e }) {
1867
1867
  return l.createElement("div", { style: Fi.container }, e);
1868
1868
  }
1869
- var Di = _i, Li = Di;
1870
- function qi({ width: e, height: i, isEditorReady: r, loading: n, _ref: s, className: o, wrapperProps: d }) {
1871
- return l.createElement("section", { style: { ...we.wrapper, width: e, height: i }, ...d }, !r && l.createElement(Li, null, n), l.createElement("div", { ref: s, style: { ...we.fullWidth, ...!r && we.hide }, className: o }));
1869
+ var Di = _i, qi = Di;
1870
+ function Li({ width: e, height: i, isEditorReady: r, loading: n, _ref: s, className: o, wrapperProps: d }) {
1871
+ return l.createElement("section", { style: { ...we.wrapper, width: e, height: i }, ...d }, !r && l.createElement(qi, null, n), l.createElement("div", { ref: s, style: { ...we.fullWidth, ...!r && we.hide }, className: o }));
1872
1872
  }
1873
- var $i = qi, Xe = Ce($i);
1873
+ var $i = Li, Xe = Ce($i);
1874
1874
  function Ui(e) {
1875
1875
  J(e, []);
1876
1876
  }
@@ -1896,52 +1896,52 @@ function Vi(e, i, r, n) {
1896
1896
  function Ze(e, i) {
1897
1897
  return e.Uri.parse(i);
1898
1898
  }
1899
- function Hi({ original: e, modified: i, language: r, originalLanguage: n, modifiedLanguage: s, originalModelPath: o, modifiedModelPath: d, keepCurrentOriginalModel: m = !1, keepCurrentModifiedModel: c = !1, theme: u = "light", loading: h = "Loading...", options: g = {}, height: A = "100%", width: L = "100%", className: _, wrapperProps: N = {}, beforeMount: O = ie, onMount: R = ie }) {
1900
- let [j, I] = ue(!1), [S, b] = ue(!0), x = U(null), f = U(null), T = U(null), w = U(R), k = U(O), P = U(!1);
1899
+ function Hi({ original: e, modified: i, language: r, originalLanguage: n, modifiedLanguage: s, originalModelPath: o, modifiedModelPath: d, keepCurrentOriginalModel: m = !1, keepCurrentModifiedModel: c = !1, theme: u = "light", loading: h = "Loading...", options: g = {}, height: S = "100%", width: q = "100%", className: _, wrapperProps: j = {}, beforeMount: k = ie, onMount: R = ie }) {
1900
+ let [w, A] = ue(!1), [T, x] = ue(!0), b = U(null), f = U(null), O = U(null), E = U(R), I = U(k), P = U(!1);
1901
1901
  Qe(() => {
1902
- let E = Ke.init();
1903
- return E.then((F) => (f.current = F) && b(!1)).catch((F) => F?.type !== "cancelation" && console.error("Monaco initialization: error:", F)), () => x.current ? M() : E.cancel();
1902
+ let N = Ke.init();
1903
+ return N.then((F) => (f.current = F) && x(!1)).catch((F) => F?.type !== "cancelation" && console.error("Monaco initialization: error:", F)), () => b.current ? M() : N.cancel();
1904
1904
  }), W(() => {
1905
- if (x.current && f.current) {
1906
- let E = x.current.getOriginalEditor(), F = Q(f.current, e || "", n || r || "text", o || "");
1907
- F !== E.getModel() && E.setModel(F);
1905
+ if (b.current && f.current) {
1906
+ let N = b.current.getOriginalEditor(), F = Q(f.current, e || "", n || r || "text", o || "");
1907
+ F !== N.getModel() && N.setModel(F);
1908
1908
  }
1909
- }, [o], j), W(() => {
1910
- if (x.current && f.current) {
1911
- let E = x.current.getModifiedEditor(), F = Q(f.current, i || "", s || r || "text", d || "");
1912
- F !== E.getModel() && E.setModel(F);
1909
+ }, [o], w), W(() => {
1910
+ if (b.current && f.current) {
1911
+ let N = b.current.getModifiedEditor(), F = Q(f.current, i || "", s || r || "text", d || "");
1912
+ F !== N.getModel() && N.setModel(F);
1913
1913
  }
1914
- }, [d], j), W(() => {
1915
- let E = x.current.getModifiedEditor();
1916
- E.getOption(f.current.editor.EditorOption.readOnly) ? E.setValue(i || "") : i !== E.getValue() && (E.executeEdits("", [{ range: E.getModel().getFullModelRange(), text: i || "", forceMoveMarkers: !0 }]), E.pushUndoStop());
1917
- }, [i], j), W(() => {
1918
- x.current?.getModel()?.original.setValue(e || "");
1919
- }, [e], j), W(() => {
1920
- let { original: E, modified: F } = x.current.getModel();
1921
- f.current.editor.setModelLanguage(E, n || r || "text"), f.current.editor.setModelLanguage(F, s || r || "text");
1922
- }, [r, n, s], j), W(() => {
1914
+ }, [d], w), W(() => {
1915
+ let N = b.current.getModifiedEditor();
1916
+ N.getOption(f.current.editor.EditorOption.readOnly) ? N.setValue(i || "") : i !== N.getValue() && (N.executeEdits("", [{ range: N.getModel().getFullModelRange(), text: i || "", forceMoveMarkers: !0 }]), N.pushUndoStop());
1917
+ }, [i], w), W(() => {
1918
+ b.current?.getModel()?.original.setValue(e || "");
1919
+ }, [e], w), W(() => {
1920
+ let { original: N, modified: F } = b.current.getModel();
1921
+ f.current.editor.setModelLanguage(N, n || r || "text"), f.current.editor.setModelLanguage(F, s || r || "text");
1922
+ }, [r, n, s], w), W(() => {
1923
1923
  f.current?.editor.setTheme(u);
1924
- }, [u], j), W(() => {
1925
- x.current?.updateOptions(g);
1926
- }, [g], j);
1924
+ }, [u], w), W(() => {
1925
+ b.current?.updateOptions(g);
1926
+ }, [g], w);
1927
1927
  let p = de(() => {
1928
1928
  if (!f.current) return;
1929
- k.current(f.current);
1930
- let E = Q(f.current, e || "", n || r || "text", o || ""), F = Q(f.current, i || "", s || r || "text", d || "");
1931
- x.current?.setModel({ original: E, modified: F });
1929
+ I.current(f.current);
1930
+ let N = Q(f.current, e || "", n || r || "text", o || ""), F = Q(f.current, i || "", s || r || "text", d || "");
1931
+ b.current?.setModel({ original: N, modified: F });
1932
1932
  }, [r, i, s, e, n, o, d]), C = de(() => {
1933
- !P.current && T.current && (x.current = f.current.editor.createDiffEditor(T.current, { automaticLayout: !0, ...g }), p(), f.current?.editor.setTheme(u), I(!0), P.current = !0);
1933
+ !P.current && O.current && (b.current = f.current.editor.createDiffEditor(O.current, { automaticLayout: !0, ...g }), p(), f.current?.editor.setTheme(u), A(!0), P.current = !0);
1934
1934
  }, [g, u, p]);
1935
1935
  J(() => {
1936
- j && w.current(x.current, f.current);
1937
- }, [j]), J(() => {
1938
- !S && !j && C();
1939
- }, [S, j, C]);
1936
+ w && E.current(b.current, f.current);
1937
+ }, [w]), J(() => {
1938
+ !T && !w && C();
1939
+ }, [T, w, C]);
1940
1940
  function M() {
1941
- let E = x.current?.getModel();
1942
- m || E?.original?.dispose(), c || E?.modified?.dispose(), x.current?.dispose();
1941
+ let N = b.current?.getModel();
1942
+ m || N?.original?.dispose(), c || N?.modified?.dispose(), b.current?.dispose();
1943
1943
  }
1944
- return l.createElement(Xe, { width: L, height: A, isEditorReady: j, loading: h, _ref: T, className: _, wrapperProps: N });
1944
+ return l.createElement(Xe, { width: q, height: S, isEditorReady: w, loading: h, _ref: O, className: _, wrapperProps: j });
1945
1945
  }
1946
1946
  var Yi = Hi;
1947
1947
  Ce(Yi);
@@ -1952,48 +1952,48 @@ function Ji(e) {
1952
1952
  }, [e]), i.current;
1953
1953
  }
1954
1954
  var Bi = Ji, ce = /* @__PURE__ */ new Map();
1955
- function Gi({ defaultValue: e, defaultLanguage: i, defaultPath: r, value: n, language: s, path: o, theme: d = "light", line: m, loading: c = "Loading...", options: u = {}, overrideServices: h = {}, saveViewState: g = !0, keepCurrentModel: A = !1, width: L = "100%", height: _ = "100%", className: N, wrapperProps: O = {}, beforeMount: R = ie, onMount: j = ie, onChange: I, onValidate: S = ie }) {
1956
- let [b, x] = ue(!1), [f, T] = ue(!0), w = U(null), k = U(null), P = U(null), p = U(j), C = U(R), M = U(), E = U(n), F = Bi(o), $ = U(!1), z = U(!1);
1955
+ function Gi({ defaultValue: e, defaultLanguage: i, defaultPath: r, value: n, language: s, path: o, theme: d = "light", line: m, loading: c = "Loading...", options: u = {}, overrideServices: h = {}, saveViewState: g = !0, keepCurrentModel: S = !1, width: q = "100%", height: _ = "100%", className: j, wrapperProps: k = {}, beforeMount: R = ie, onMount: w = ie, onChange: A, onValidate: T = ie }) {
1956
+ let [x, b] = ue(!1), [f, O] = ue(!0), E = U(null), I = U(null), P = U(null), p = U(w), C = U(R), M = U(), N = U(n), F = Bi(o), $ = U(!1), z = U(!1);
1957
1957
  Qe(() => {
1958
1958
  let a = Ke.init();
1959
- return a.then((v) => (w.current = v) && T(!1)).catch((v) => v?.type !== "cancelation" && console.error("Monaco initialization: error:", v)), () => k.current ? Y() : a.cancel();
1959
+ return a.then((v) => (E.current = v) && O(!1)).catch((v) => v?.type !== "cancelation" && console.error("Monaco initialization: error:", v)), () => I.current ? Y() : a.cancel();
1960
1960
  }), W(() => {
1961
- let a = Q(w.current, e || n || "", i || s || "", o || r || "");
1962
- a !== k.current?.getModel() && (g && ce.set(F, k.current?.saveViewState()), k.current?.setModel(a), g && k.current?.restoreViewState(ce.get(o)));
1963
- }, [o], b), W(() => {
1964
- k.current?.updateOptions(u);
1965
- }, [u], b), W(() => {
1966
- !k.current || n === void 0 || (k.current.getOption(w.current.editor.EditorOption.readOnly) ? k.current.setValue(n) : n !== k.current.getValue() && (z.current = !0, k.current.executeEdits("", [{ range: k.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), k.current.pushUndoStop(), z.current = !1));
1967
- }, [n], b), W(() => {
1968
- let a = k.current?.getModel();
1969
- a && s && w.current?.editor.setModelLanguage(a, s);
1970
- }, [s], b), W(() => {
1971
- m !== void 0 && k.current?.revealLine(m);
1972
- }, [m], b), W(() => {
1973
- w.current?.editor.setTheme(d);
1974
- }, [d], b);
1961
+ let a = Q(E.current, e || n || "", i || s || "", o || r || "");
1962
+ a !== I.current?.getModel() && (g && ce.set(F, I.current?.saveViewState()), I.current?.setModel(a), g && I.current?.restoreViewState(ce.get(o)));
1963
+ }, [o], x), W(() => {
1964
+ I.current?.updateOptions(u);
1965
+ }, [u], x), W(() => {
1966
+ !I.current || n === void 0 || (I.current.getOption(E.current.editor.EditorOption.readOnly) ? I.current.setValue(n) : n !== I.current.getValue() && (z.current = !0, I.current.executeEdits("", [{ range: I.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), I.current.pushUndoStop(), z.current = !1));
1967
+ }, [n], x), W(() => {
1968
+ let a = I.current?.getModel();
1969
+ a && s && E.current?.editor.setModelLanguage(a, s);
1970
+ }, [s], x), W(() => {
1971
+ m !== void 0 && I.current?.revealLine(m);
1972
+ }, [m], x), W(() => {
1973
+ E.current?.editor.setTheme(d);
1974
+ }, [d], x);
1975
1975
  let H = de(() => {
1976
- if (!(!P.current || !w.current) && !$.current) {
1977
- C.current(w.current);
1978
- let a = o || r, v = Q(w.current, n || e || "", i || s || "", a || "");
1979
- k.current = w.current?.editor.create(P.current, { model: v, automaticLayout: !0, ...u }, h), g && k.current.restoreViewState(ce.get(a)), w.current.editor.setTheme(d), m !== void 0 && k.current.revealLine(m), x(!0), $.current = !0;
1976
+ if (!(!P.current || !E.current) && !$.current) {
1977
+ C.current(E.current);
1978
+ let a = o || r, v = Q(E.current, n || e || "", i || s || "", a || "");
1979
+ I.current = E.current?.editor.create(P.current, { model: v, automaticLayout: !0, ...u }, h), g && I.current.restoreViewState(ce.get(a)), E.current.editor.setTheme(d), m !== void 0 && I.current.revealLine(m), b(!0), $.current = !0;
1980
1980
  }
1981
1981
  }, [e, i, r, n, s, o, u, h, g, d, m]);
1982
1982
  J(() => {
1983
- b && p.current(k.current, w.current);
1984
- }, [b]), J(() => {
1985
- !f && !b && H();
1986
- }, [f, b, H]), E.current = n, J(() => {
1987
- b && I && (M.current?.dispose(), M.current = k.current?.onDidChangeModelContent((a) => {
1988
- z.current || I(k.current.getValue(), a);
1983
+ x && p.current(I.current, E.current);
1984
+ }, [x]), J(() => {
1985
+ !f && !x && H();
1986
+ }, [f, x, H]), N.current = n, J(() => {
1987
+ x && A && (M.current?.dispose(), M.current = I.current?.onDidChangeModelContent((a) => {
1988
+ z.current || A(I.current.getValue(), a);
1989
1989
  }));
1990
- }, [b, I]), J(() => {
1991
- if (b) {
1992
- let a = w.current.editor.onDidChangeMarkers((v) => {
1993
- let y = k.current.getModel()?.uri;
1990
+ }, [x, A]), J(() => {
1991
+ if (x) {
1992
+ let a = E.current.editor.onDidChangeMarkers((v) => {
1993
+ let y = I.current.getModel()?.uri;
1994
1994
  if (y && v.find((D) => D.path === y.path)) {
1995
- let D = w.current.editor.getModelMarkers({ resource: y });
1996
- S?.(D);
1995
+ let D = E.current.editor.getModelMarkers({ resource: y });
1996
+ T?.(D);
1997
1997
  }
1998
1998
  });
1999
1999
  return () => {
@@ -2002,11 +2002,11 @@ function Gi({ defaultValue: e, defaultLanguage: i, defaultPath: r, value: n, lan
2002
2002
  }
2003
2003
  return () => {
2004
2004
  };
2005
- }, [b, S]);
2005
+ }, [x, T]);
2006
2006
  function Y() {
2007
- M.current?.dispose(), A ? g && ce.set(o, k.current.saveViewState()) : k.current.getModel()?.dispose(), k.current.dispose();
2007
+ M.current?.dispose(), S ? g && ce.set(o, I.current.saveViewState()) : I.current.getModel()?.dispose(), I.current.dispose();
2008
2008
  }
2009
- return l.createElement(Xe, { width: L, height: _, isEditorReady: b, loading: c, _ref: P, className: N, wrapperProps: O });
2009
+ return l.createElement(Xe, { width: q, height: _, isEditorReady: x, loading: c, _ref: P, className: j, wrapperProps: k });
2010
2010
  }
2011
2011
  var Ki = Gi, Xi = Ce(Ki), Qi = Xi;
2012
2012
  function Zi() {
@@ -2014,57 +2014,57 @@ function Zi() {
2014
2014
  l.useEffect(() => {
2015
2015
  const f = document.querySelector(".qb-editor-root");
2016
2016
  if (!f) return;
2017
- const T = () => {
2017
+ const O = () => {
2018
2018
  g(f.classList.contains("dark"));
2019
2019
  };
2020
- T();
2021
- const w = new MutationObserver(T);
2022
- return w.observe(f, { attributes: !0, attributeFilter: ["class"] }), () => w.disconnect();
2020
+ O();
2021
+ const E = new MutationObserver(O);
2022
+ return E.observe(f, { attributes: !0, attributeFilter: ["class"] }), () => E.disconnect();
2023
2023
  }, []);
2024
- const [A, L] = l.useState(640), [_, N] = l.useState(() => {
2024
+ const [S, q] = l.useState(640), [_, j] = l.useState(() => {
2025
2025
  try {
2026
2026
  return ae.dump(e, { indent: 2, lineWidth: -1 });
2027
2027
  } catch {
2028
2028
  return "";
2029
2029
  }
2030
- }), [O, R] = l.useState("");
2030
+ }), [k, R] = l.useState("");
2031
2031
  l.useEffect(() => {
2032
2032
  r.setCodeEditorHasError(!1);
2033
2033
  }, []);
2034
- const j = l.useCallback((f) => c === "json" ? JSON.parse(f) : ae.load(f), [c]), I = l.useCallback((f) => c === "json" ? JSON.stringify(f, null, 2) : ae.dump(f, { indent: 2, lineWidth: -1 }), [c]);
2034
+ const w = l.useCallback((f) => c === "json" ? JSON.parse(f) : ae.load(f), [c]), A = l.useCallback((f) => c === "json" ? JSON.stringify(f, null, 2) : ae.dump(f, { indent: 2, lineWidth: -1 }), [c]);
2035
2035
  l.useEffect(() => {
2036
2036
  const f = () => {
2037
2037
  if (s.current) {
2038
- const T = s.current.getBoundingClientRect().top, w = window.innerHeight - T - 20;
2039
- L(Math.max(400, w));
2038
+ const O = s.current.getBoundingClientRect().top, E = window.innerHeight - O - 20;
2039
+ q(Math.max(400, E));
2040
2040
  }
2041
2041
  };
2042
2042
  return f(), window.addEventListener("resize", f), () => window.removeEventListener("resize", f);
2043
2043
  }, []), l.useEffect(() => {
2044
2044
  if (!m.current)
2045
2045
  try {
2046
- const f = I(e);
2047
- N(f), o.current = f, R(""), r.setCodeEditorHasError(!1);
2046
+ const f = A(e);
2047
+ j(f), o.current = f, R(""), r.setCodeEditorHasError(!1);
2048
2048
  } catch (f) {
2049
2049
  R(`Failed to serialize: ${f.message}`), r.setCodeEditorHasError(!0);
2050
2050
  }
2051
- }, [e, I, r]);
2052
- const S = (f) => {
2053
- N(f || ""), o.current = f || "", m.current = !0;
2051
+ }, [e, A, r]);
2052
+ const T = (f) => {
2053
+ j(f || ""), o.current = f || "", m.current = !0;
2054
2054
  try {
2055
- const T = j(f || "{}");
2056
- if (!T || typeof T != "object")
2055
+ const O = w(f || "{}");
2056
+ if (!O || typeof O != "object")
2057
2057
  throw new Error("Invalid form data: must be an object");
2058
2058
  R(""), r.setCodeEditorHasError(!1);
2059
- } catch (T) {
2060
- const w = `Invalid ${c.toUpperCase()}: ${T.message}`;
2061
- R(w), r.setCodeEditorHasError(!0);
2059
+ } catch (O) {
2060
+ const E = `Invalid ${c.toUpperCase()}: ${O.message}`;
2061
+ R(E), r.setCodeEditorHasError(!0);
2062
2062
  }
2063
- }, b = (f) => {
2064
- d.current = f, f.onDidPaste((T) => {
2065
- const w = _, k = f.getModel().getValue();
2063
+ }, x = (f) => {
2064
+ d.current = f, f.onDidPaste((O) => {
2065
+ const E = _, I = f.getModel().getValue();
2066
2066
  try {
2067
- const P = j(k);
2067
+ const P = w(I);
2068
2068
  if (P && typeof P == "object") {
2069
2069
  const { schemaType: p } = fe(P);
2070
2070
  p === "surveyjs" && n(
@@ -2076,14 +2076,14 @@ Do you want to proceed with the conversion?`,
2076
2076
  confirmText: "Yes, Convert",
2077
2077
  cancelText: "No, Cancel Paste",
2078
2078
  onConfirm: () => {
2079
- const { fields: C, conversionReport: M } = pe(P, p), E = {
2079
+ const { fields: C, conversionReport: M } = pe(P, p), N = {
2080
2080
  schemaType: P.schemaType || ve,
2081
2081
  ...M?.surveyMetadata || {},
2082
2082
  fields: C
2083
2083
  };
2084
- i(E);
2085
- const F = I(E);
2086
- N(F), o.current = F, f.setValue(F), R(""), m.current = !1, M && (r.setConversionReport(M), setTimeout(() => {
2084
+ i(N);
2085
+ const F = A(N);
2086
+ j(F), o.current = F, f.setValue(F), R(""), m.current = !1, M && (r.setConversionReport(M), setTimeout(() => {
2087
2087
  const $ = M?.unsupportedFields?.length || 0;
2088
2088
  n(
2089
2089
  `This schema has been converted to MIE Forms format.
@@ -2097,7 +2097,7 @@ Please use MIE Forms schema inside of code editor for the best experience in the
2097
2097
  }, 100));
2098
2098
  },
2099
2099
  onCancel: () => {
2100
- f.setValue(w), N(w), o.current = w;
2100
+ f.setValue(E), j(E), o.current = E;
2101
2101
  }
2102
2102
  }
2103
2103
  );
@@ -2105,12 +2105,12 @@ Please use MIE Forms schema inside of code editor for the best experience in the
2105
2105
  } catch {
2106
2106
  }
2107
2107
  });
2108
- }, x = (f) => {
2108
+ }, b = (f) => {
2109
2109
  try {
2110
- const T = j(_), w = f === "json" ? JSON.stringify(T, null, 2) : ae.dump(T, { indent: 2, lineWidth: -1 });
2111
- N(w), o.current = w, u(f), R(""), r.setCodeEditorHasError(!1);
2112
- } catch (T) {
2113
- R(`Cannot convert: ${T.message}`), r.setCodeEditorHasError(!0);
2110
+ const O = w(_), E = f === "json" ? JSON.stringify(O, null, 2) : ae.dump(O, { indent: 2, lineWidth: -1 });
2111
+ j(E), o.current = E, u(f), R(""), r.setCodeEditorHasError(!1);
2112
+ } catch (O) {
2113
+ R(`Cannot convert: ${O.message}`), r.setCodeEditorHasError(!0);
2114
2114
  }
2115
2115
  };
2116
2116
  return l.useEffect(() => () => {
@@ -2120,23 +2120,23 @@ Please use MIE Forms schema inside of code editor for the best experience in the
2120
2120
  return;
2121
2121
  }
2122
2122
  try {
2123
- const T = j(f);
2124
- if (!T || typeof T != "object" || JSON.stringify(e) === JSON.stringify(T)) return;
2125
- const { schemaType: w } = fe(T), { fields: k, conversionReport: P } = pe(T, w), p = {
2126
- schemaType: T.schemaType || ve,
2123
+ const O = w(f);
2124
+ if (!O || typeof O != "object" || JSON.stringify(e) === JSON.stringify(O)) return;
2125
+ const { schemaType: E } = fe(O), { fields: I, conversionReport: P } = pe(O, E), p = {
2126
+ schemaType: O.schemaType || ve,
2127
2127
  ...P?.surveyMetadata || {},
2128
- fields: k
2128
+ fields: I
2129
2129
  };
2130
2130
  P && r.setConversionReport(P), i(p), r.setCodeEditorHasError(!1), m.current = !1;
2131
2131
  } catch {
2132
2132
  }
2133
- }, [j, i, r, e]), /* @__PURE__ */ t.jsxs("div", { ref: s, className: "code-editor-container mie:flex mie:flex-col mie:bg-miebackground mie:max-w-7xl mie:w-full", style: { height: `${A}px` }, children: [
2133
+ }, [w, i, r, e]), /* @__PURE__ */ t.jsxs("div", { ref: s, className: "code-editor-container mie:flex mie:flex-col mie:bg-miebackground mie:max-w-7xl mie:w-full", style: { height: `${S}px` }, children: [
2134
2134
  /* @__PURE__ */ t.jsxs("div", { className: "code-editor-header mie:flex mie:items-center mie:justify-between mie:gap-3 mie:p-4 mie:bg-miesurface mie:border-b mie:border-mieborder", children: [
2135
2135
  /* @__PURE__ */ t.jsx("div", { className: "mie:flex mie:items-center mie:gap-2", children: /* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:gap-1 mie:rounded-lg mie:border mie:border-mieborder mie:bg-miebackground mie:p-1", children: [
2136
2136
  /* @__PURE__ */ t.jsx(
2137
2137
  "button",
2138
2138
  {
2139
- onClick: () => x("yaml"),
2139
+ onClick: () => b("yaml"),
2140
2140
  className: `mie:px-3 mie:py-1 mie:rounded-md mie:text-sm mie:font-medium mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none ${c === "yaml" ? "mie:bg-mieprimary mie:text-mietextsecondary mie:shadow-sm" : "mie:bg-transparent mie:text-mietextmuted mie:hover:text-mietext mie:hover:bg-miesurface"}`,
2141
2141
  children: "YAML"
2142
2142
  }
@@ -2144,7 +2144,7 @@ Please use MIE Forms schema inside of code editor for the best experience in the
2144
2144
  /* @__PURE__ */ t.jsx(
2145
2145
  "button",
2146
2146
  {
2147
- onClick: () => x("json"),
2147
+ onClick: () => b("json"),
2148
2148
  className: `mie:px-3 mie:py-1 mie:rounded-md mie:text-sm mie:font-medium mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none ${c === "json" ? "mie:bg-mieprimary mie:text-mietextsecondary mie:shadow-sm" : "mie:bg-transparent mie:text-mietextmuted mie:hover:text-mietext mie:hover:bg-miesurface"}`,
2149
2149
  children: "JSON"
2150
2150
  }
@@ -2152,7 +2152,7 @@ Please use MIE Forms schema inside of code editor for the best experience in the
2152
2152
  ] }) }),
2153
2153
  /* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:items-center mie:gap-2", children: [
2154
2154
  /* @__PURE__ */ t.jsx("div", { className: "mie:text-xs mie:text-mietextmuted mie:px-3 mie:py-1", children: "Auto-saves when switching tabs" }),
2155
- O && /* @__PURE__ */ t.jsx("div", { className: "mie:text-xs mie:text-miedanger mie:bg-miedanger/10 mie:px-3 mie:py-1 mie:rounded-lg", children: O })
2155
+ k && /* @__PURE__ */ t.jsx("div", { className: "mie:text-xs mie:text-miedanger mie:bg-miedanger/10 mie:px-3 mie:py-1 mie:rounded-lg", children: k })
2156
2156
  ] })
2157
2157
  ] }),
2158
2158
  /* @__PURE__ */ t.jsx("div", { className: "code-editor-content mie:flex-1 mie:overflow-hidden", children: /* @__PURE__ */ t.jsx(
@@ -2161,8 +2161,8 @@ Please use MIE Forms schema inside of code editor for the best experience in the
2161
2161
  height: "100%",
2162
2162
  language: c,
2163
2163
  value: _,
2164
- onChange: S,
2165
- onMount: b,
2164
+ onChange: T,
2165
+ onMount: x,
2166
2166
  theme: h ? "vs-dark" : "light",
2167
2167
  options: {
2168
2168
  minimap: { enabled: !1 },
@@ -2230,60 +2230,50 @@ function tr({
2230
2230
  showHeader: s = !0,
2231
2231
  startInPreview: o = !1,
2232
2232
  hideUnsupportedFields: d = !1,
2233
- theme: m = "auto"
2233
+ theme: m = "light"
2234
2234
  }) {
2235
- const [c, u] = l.useState("json"), h = B(), g = l.useRef(!1), A = l.useContext(Oe);
2235
+ const [c, u] = l.useState("json"), h = B(), g = l.useRef(!1), S = l.useContext(Oe);
2236
2236
  l.useEffect(() => {
2237
- if (!(g.current || !A)) {
2237
+ if (!(g.current || !S)) {
2238
2238
  if (e)
2239
2239
  try {
2240
- const { data: O, schemaType: R } = fe(e, i), j = pe(O, R);
2241
- j.conversionReport && h.setConversionReport(j.conversionReport);
2242
- const I = {
2243
- schemaType: R === "surveyjs" ? "mieforms-v1.0" : O.schemaType || "mieforms-v1.0",
2244
- fields: j.fields || []
2240
+ const { data: j, schemaType: k } = fe(e, i), R = pe(j, k);
2241
+ R.conversionReport && h.setConversionReport(R.conversionReport);
2242
+ const w = {
2243
+ schemaType: k === "surveyjs" ? "mieforms-v1.0" : j.schemaType || "mieforms-v1.0",
2244
+ fields: R.fields || []
2245
2245
  };
2246
- if (R === "surveyjs" && j.conversionReport?.surveyMetadata)
2247
- Object.assign(I, j.conversionReport.surveyMetadata);
2248
- else if (R === "mieforms") {
2249
- const { fields: S, schemaType: b, ...x } = O;
2250
- Object.keys(x).length > 0 && Object.assign(I, x);
2246
+ if (k === "surveyjs" && R.conversionReport?.surveyMetadata)
2247
+ Object.assign(w, R.conversionReport.surveyMetadata);
2248
+ else if (k === "mieforms") {
2249
+ const { fields: A, schemaType: T, ...x } = j;
2250
+ Object.keys(x).length > 0 && Object.assign(w, x);
2251
2251
  }
2252
- Array.isArray(I.fields) && I.fields.length && A.getState().replaceAll(I);
2252
+ Array.isArray(w.fields) && w.fields.length && S.getState().replaceAll(w);
2253
2253
  } catch {
2254
- A.getState().replaceAll({ schemaType: "mieforms-v1.0", fields: [] });
2254
+ S.getState().replaceAll({ schemaType: "mieforms-v1.0", fields: [] });
2255
2255
  }
2256
2256
  h.preview.set(!!o), g.current = !0;
2257
2257
  }
2258
- }, [e, i, o, h, A]), l.useEffect(() => {
2258
+ }, [e, i, o, h, S]), l.useEffect(() => {
2259
2259
  h.setHideUnsupportedFields(d);
2260
2260
  }, [d, h]), l.useEffect(() => {
2261
- if (!(!r || !A))
2262
- return A.subscribe((O) => {
2261
+ if (!(!r || !S))
2262
+ return S.subscribe((j) => {
2263
2263
  r({
2264
- schemaType: O.schemaType || "mieforms-v1.0",
2265
- ...O.schemaMetadata,
2266
- fields: O.order.map((R) => O.byId[R])
2264
+ schemaType: j.schemaType || "mieforms-v1.0",
2265
+ ...j.schemaMetadata,
2266
+ fields: j.order.map((k) => j.byId[k])
2267
2267
  });
2268
2268
  });
2269
- }, [r, A]);
2270
- const L = Ot(
2271
- A,
2272
- (O) => h.selectedFieldId.value ? O.byId[h.selectedFieldId.value] : null
2273
- ), [_, N] = l.useState(() => m === "dark" ? !0 : m === "light" ? !1 : typeof document < "u" ? document.documentElement.getAttribute("data-theme") === "dark" || document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") : !1);
2274
- return l.useEffect(() => {
2275
- if (m !== "auto") {
2276
- N(m === "dark");
2277
- return;
2278
- }
2279
- const O = new MutationObserver(() => {
2280
- const R = document.documentElement.getAttribute("data-theme") === "dark" || document.documentElement.classList.contains("dark") || document.body.classList.contains("dark");
2281
- N(R);
2282
- });
2283
- return O.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-theme", "class"] }), O.observe(document.body, { attributes: !0, attributeFilter: ["class"] }), () => O.disconnect();
2284
- }, [m]), /* @__PURE__ */ t.jsx("div", { className: `qb-editor-root editor-container mie:w-full mie:max-w-7xl mie:mx-auto mie:bg-miebackground mie:font-titillium ${_ ? "dark" : ""} ${n}`, children: /* @__PURE__ */ t.jsxs(Ct, { children: [
2269
+ }, [r, S]);
2270
+ const q = Ot(
2271
+ S,
2272
+ (j) => h.selectedFieldId.value ? j.byId[h.selectedFieldId.value] : null
2273
+ ), _ = m === "dark";
2274
+ return /* @__PURE__ */ t.jsx("div", { className: `qb-editor-root editor-container mie:w-full mie:max-w-7xl mie:mx-auto mie:bg-miebackground mie:font-titillium ${_ ? "dark" : ""} ${n}`, children: /* @__PURE__ */ t.jsxs(Ct, { children: [
2285
2275
  s && /* @__PURE__ */ t.jsx(kt, { codeFormat: c, onCodeFormatChange: u }),
2286
- /* @__PURE__ */ t.jsx(er, { selectedField: L, codeFormat: c })
2276
+ /* @__PURE__ */ t.jsx(er, { selectedField: q, codeFormat: c })
2287
2277
  ] }) });
2288
2278
  }
2289
2279
  function or(e) {