jedison 1.16.2 → 1.17.0

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.
@@ -96,7 +96,7 @@ function isBoolean(value) {
96
96
  function isArray(value) {
97
97
  return Array.isArray(value);
98
98
  }
99
- function isObject(value) {
99
+ function isObject$1(value) {
100
100
  return !isNull(value) && !isArray(value) && typeof value === "object";
101
101
  }
102
102
  function getType(value) {
@@ -111,7 +111,7 @@ function getType(value) {
111
111
  type2 = "array";
112
112
  } else if (isNull(value)) {
113
113
  type2 = "null";
114
- } else if (isObject(value)) {
114
+ } else if (isObject$1(value)) {
115
115
  type2 = "object";
116
116
  }
117
117
  return type2;
@@ -133,7 +133,7 @@ function filterAttributes(attributes, options = {}) {
133
133
  allowedPrefixes = DEFAULT_ATTRIBUTE_ALLOWED_PREFIXES
134
134
  } = options;
135
135
  const result = {};
136
- if (!isObject(attributes)) {
136
+ if (!isObject$1(attributes)) {
137
137
  return result;
138
138
  }
139
139
  const allowed = new Set(allowlist.map((name) => name.toLowerCase()));
@@ -150,10 +150,10 @@ const UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "protot
150
150
  function mergeDeep(target, ...sources) {
151
151
  if (!sources.length) return target;
152
152
  const source = sources.shift();
153
- if (isObject(target) && isObject(source)) {
153
+ if (isObject$1(target) && isObject$1(source)) {
154
154
  Object.keys(source).forEach((key) => {
155
155
  if (UNSAFE_KEYS.has(key)) return;
156
- if (isObject(source[key])) {
156
+ if (isObject$1(source[key])) {
157
157
  if (!target[key]) {
158
158
  Object.assign(target, {
159
159
  [key]: {}
@@ -174,11 +174,11 @@ function combineDeep(target, ...sources) {
174
174
  const source = sources.shift();
175
175
  if (Array.isArray(target) && Array.isArray(source)) {
176
176
  target.push(...source);
177
- } else if (isObject(target) && isObject(source)) {
177
+ } else if (isObject$1(target) && isObject$1(source)) {
178
178
  Object.keys(source).forEach((key) => {
179
179
  if (UNSAFE_KEYS.has(key)) return;
180
- if (isObject(source[key])) {
181
- if (!isObject(target[key])) {
180
+ if (isObject$1(source[key])) {
181
+ if (!isObject$1(target[key])) {
182
182
  Object.assign(target, {
183
183
  [key]: {}
184
184
  });
@@ -201,8 +201,8 @@ function combineDeep(target, ...sources) {
201
201
  const overwriteExistingProperties = (obj1, obj2) => {
202
202
  Object.keys(obj2).forEach((key) => {
203
203
  if (key in obj1) {
204
- if (isSet(obj1[key]) && isSet(obj2[key]) && (isObject(obj1[key]) && isObject(obj2[key]) || isArray(obj1[key]) && isArray(obj2[key]) || isString(obj1[key]) && isString(obj2[key]) || isNumber(obj1[key]) && isNumber(obj2[key]) || isBoolean(obj1[key]) && isBoolean(obj2[key]) || isNull(obj1[key]) && isNull(obj2[key]))) {
205
- if (isObject(obj1[key]) && isObject(obj2[key])) {
204
+ if (isSet(obj1[key]) && isSet(obj2[key]) && (isObject$1(obj1[key]) && isObject$1(obj2[key]) || isArray(obj1[key]) && isArray(obj2[key]) || isString(obj1[key]) && isString(obj2[key]) || isNumber(obj1[key]) && isNumber(obj2[key]) || isBoolean(obj1[key]) && isBoolean(obj2[key]) || isNull(obj1[key]) && isNull(obj2[key]))) {
205
+ if (isObject$1(obj1[key]) && isObject$1(obj2[key])) {
206
206
  overwriteExistingProperties(obj1[key], obj2[key]);
207
207
  } else {
208
208
  obj1[key] = obj2[key];
@@ -302,7 +302,7 @@ const Utils = {
302
302
  isString,
303
303
  isBoolean,
304
304
  isArray,
305
- isObject,
305
+ isObject: isObject$1,
306
306
  getType,
307
307
  mergeDeep,
308
308
  combineDeep,
@@ -330,10 +330,10 @@ function getSchemaSchema(schema) {
330
330
  return isString(schema.$schema) ? clone(schema.$schema) : void 0;
331
331
  }
332
332
  function getSchemaAdditionalProperties(schema) {
333
- return isObject(schema.additionalProperties) || isBoolean(schema.additionalProperties) ? clone(schema.additionalProperties) : void 0;
333
+ return isObject$1(schema.additionalProperties) || isBoolean(schema.additionalProperties) ? clone(schema.additionalProperties) : void 0;
334
334
  }
335
335
  function getSchemaPropertyNames(schema) {
336
- return isObject(schema.propertyNames) || isBoolean(schema.propertyNames) ? clone(schema.propertyNames) : void 0;
336
+ return isObject$1(schema.propertyNames) || isBoolean(schema.propertyNames) ? clone(schema.propertyNames) : void 0;
337
337
  }
338
338
  function getSchemaAllOf(schema) {
339
339
  return isArray(schema.allOf) ? clone(schema.allOf) : void 0;
@@ -345,22 +345,22 @@ function getSchemaConst(schema) {
345
345
  return clone(schema.const);
346
346
  }
347
347
  function getSchemaContains(schema) {
348
- return isObject(schema.contains) || isBoolean(schema.contains) ? clone(schema.contains) : void 0;
348
+ return isObject$1(schema.contains) || isBoolean(schema.contains) ? clone(schema.contains) : void 0;
349
349
  }
350
350
  function getSchemaDefault(schema) {
351
351
  return clone(schema.default);
352
352
  }
353
353
  function getSchemaDependentRequired(schema) {
354
- return isObject(schema.dependentRequired) ? clone(schema.dependentRequired) : void 0;
354
+ return isObject$1(schema.dependentRequired) ? clone(schema.dependentRequired) : void 0;
355
355
  }
356
356
  function getSchemaDependentSchemas(schema) {
357
- return isObject(schema.dependentSchemas) ? clone(schema.dependentSchemas) : void 0;
357
+ return isObject$1(schema.dependentSchemas) ? clone(schema.dependentSchemas) : void 0;
358
358
  }
359
359
  function getSchemaDescription(schema) {
360
360
  return isString(schema.description) ? clone(schema.description) : void 0;
361
361
  }
362
362
  function getSchemaElse(schema) {
363
- return isObject(schema.else) || isBoolean(schema.else) ? clone(schema.else) : void 0;
363
+ return isObject$1(schema.else) || isBoolean(schema.else) ? clone(schema.else) : void 0;
364
364
  }
365
365
  function getSchemaEnum(schema) {
366
366
  if (isArray(schema.enum) && schema.enum.length > 0) {
@@ -378,7 +378,7 @@ function getSchemaFormat(schema) {
378
378
  return isString(schema.format) ? clone(schema.format) : void 0;
379
379
  }
380
380
  function getSchemaIf(schema) {
381
- if (isObject(schema.if)) {
381
+ if (isObject$1(schema.if)) {
382
382
  return clone(schema.if);
383
383
  }
384
384
  if (isBoolean(schema.if)) {
@@ -387,7 +387,7 @@ function getSchemaIf(schema) {
387
387
  return void 0;
388
388
  }
389
389
  function getSchemaItems(schema) {
390
- return isObject(schema.items) || isBoolean(schema.items) ? clone(schema.items) : void 0;
390
+ return isObject$1(schema.items) || isBoolean(schema.items) ? clone(schema.items) : void 0;
391
391
  }
392
392
  function getSchemaMaximum(schema) {
393
393
  return isNumber(schema.maximum) ? clone(schema.maximum) : void 0;
@@ -450,7 +450,7 @@ function getSchemaMultipleOf(schema) {
450
450
  return void 0;
451
451
  }
452
452
  function getSchemaNot(schema) {
453
- return isObject(schema.not) || isBoolean(schema.not) ? clone(schema.not) : void 0;
453
+ return isObject$1(schema.not) || isBoolean(schema.not) ? clone(schema.not) : void 0;
454
454
  }
455
455
  function getSchemaXOption(schema, option) {
456
456
  const xOption = "x-" + option;
@@ -481,13 +481,13 @@ function getSchemaPattern(schema) {
481
481
  return isString(schema.pattern) ? clone(schema.pattern) : void 0;
482
482
  }
483
483
  function getSchemaPatternProperties(schema) {
484
- return isObject(schema.patternProperties) ? clone(schema.patternProperties) : void 0;
484
+ return isObject$1(schema.patternProperties) ? clone(schema.patternProperties) : void 0;
485
485
  }
486
486
  function getSchemaPrefixItems(schema) {
487
487
  return isArray(schema.prefixItems) ? clone(schema.prefixItems) : void 0;
488
488
  }
489
489
  function getSchemaProperties(schema) {
490
- return isObject(schema.properties) ? clone(schema.properties) : void 0;
490
+ return isObject$1(schema.properties) ? clone(schema.properties) : void 0;
491
491
  }
492
492
  function getSchemaReadOnly(schema) {
493
493
  return isBoolean(schema.readOnly) ? clone(schema.readOnly) : void 0;
@@ -496,7 +496,7 @@ function getSchemaRequired(schema) {
496
496
  return isArray(schema.required) ? [...new Set(schema.required)] : void 0;
497
497
  }
498
498
  function getSchemaThen(schema) {
499
- return isObject(schema.then) || isBoolean(schema.then) ? clone(schema.then) : void 0;
499
+ return isObject$1(schema.then) || isBoolean(schema.then) ? clone(schema.then) : void 0;
500
500
  }
501
501
  function getSchemaTitle(schema) {
502
502
  return isString(schema.title) ? clone(schema.title) : void 0;
@@ -795,7 +795,7 @@ function items(context) {
795
795
  constraint: "items",
796
796
  messages: [context.translator.translate("errorItems")]
797
797
  });
798
- } else if (isObject(items2)) {
798
+ } else if (isObject$1(items2)) {
799
799
  const enableSubErrors = getSchemaXOption(context.schema, "subErrors") ?? context.validator.subErrors;
800
800
  context.value.slice(prefixItemsSchemasCount).forEach((itemValue, i) => {
801
801
  const index2 = prefixItemsSchemasCount + i;
@@ -863,7 +863,7 @@ function maxLength(context) {
863
863
  function maxProperties(context) {
864
864
  const errors = [];
865
865
  const maxProperties2 = getSchemaMaxProperties(context.schema);
866
- if (isObject(context.value) && isSet(maxProperties2)) {
866
+ if (isObject$1(context.value) && isSet(maxProperties2)) {
867
867
  const propertiesCount = Object.keys(context.value).length;
868
868
  const invalid = propertiesCount > maxProperties2;
869
869
  if (invalid) {
@@ -924,7 +924,7 @@ function minItems(context) {
924
924
  function minProperties(context) {
925
925
  const errors = [];
926
926
  const minProperties2 = getSchemaMinProperties(context.schema);
927
- if (isObject(context.value) && isSet(minProperties2)) {
927
+ if (isObject$1(context.value) && isSet(minProperties2)) {
928
928
  const propertiesCount = Object.keys(context.value).length;
929
929
  const invalid = propertiesCount < minProperties2;
930
930
  if (invalid) {
@@ -1076,7 +1076,7 @@ function pattern(context) {
1076
1076
  function patternProperties(context) {
1077
1077
  let errors = [];
1078
1078
  const patternProperties2 = getSchemaPatternProperties(context.schema);
1079
- if (isObject(context.value) && isSet(patternProperties2)) {
1079
+ if (isObject$1(context.value) && isSet(patternProperties2)) {
1080
1080
  Object.keys(context.value).forEach((propertyName) => {
1081
1081
  Object.keys(patternProperties2).forEach((pattern2) => {
1082
1082
  const regexp = new RegExp(pattern2);
@@ -1102,7 +1102,7 @@ function properties(context) {
1102
1102
  const invalidProperties = [];
1103
1103
  const enableSubErrors = getSchemaXOption(context.schema, "subErrors") ?? context.validator.subErrors;
1104
1104
  const propertySubErrors = [];
1105
- if (isObject(context.value) && isSet(schemaProperties)) {
1105
+ if (isObject$1(context.value) && isSet(schemaProperties)) {
1106
1106
  Object.keys(schemaProperties).forEach((propertyName) => {
1107
1107
  if (hasOwn(context.value, propertyName)) {
1108
1108
  const propertySchema = schemaProperties[propertyName];
@@ -1140,7 +1140,7 @@ function properties(context) {
1140
1140
  function required(context) {
1141
1141
  const errors = [];
1142
1142
  const required2 = getSchemaRequired(context.schema);
1143
- if (isObject(context.value) && isSet(required2)) {
1143
+ if (isObject$1(context.value) && isSet(required2)) {
1144
1144
  const missingProperties = [];
1145
1145
  const keys = Object.keys(context.value);
1146
1146
  required2.forEach((key) => {
@@ -1177,7 +1177,7 @@ function type(context) {
1177
1177
  integer: (value) => isInteger(value),
1178
1178
  boolean: (value) => isBoolean(value),
1179
1179
  array: (value) => isArray(value),
1180
- object: (value) => isObject(value),
1180
+ object: (value) => isObject$1(value),
1181
1181
  null: (value) => isNull(value)
1182
1182
  };
1183
1183
  let valid = true;
@@ -1232,7 +1232,7 @@ function uniqueItems(context) {
1232
1232
  let hasDuplicatedItems = false;
1233
1233
  for (let i = 0; i < context.value.length; i++) {
1234
1234
  let item = context.value[i];
1235
- if (isObject(item)) {
1235
+ if (isObject$1(item)) {
1236
1236
  item = sortObject(item);
1237
1237
  }
1238
1238
  const itemStringified = JSON.stringify(item);
@@ -1262,7 +1262,7 @@ function additionalProperties(context) {
1262
1262
  const schemaAdditionalProperties = getSchemaAdditionalProperties(context.schema);
1263
1263
  const schemaPatternProperties = getSchemaPatternProperties(context.schema);
1264
1264
  const schemaProperties = getSchemaProperties(context.schema);
1265
- if (isObject(context.value) && isSet(schemaAdditionalProperties)) {
1265
+ if (isObject$1(context.value) && isSet(schemaAdditionalProperties)) {
1266
1266
  const properties2 = schemaProperties || {};
1267
1267
  const additionalProperties2 = schemaAdditionalProperties;
1268
1268
  const patternProperties2 = schemaPatternProperties || {};
@@ -1282,7 +1282,7 @@ function additionalProperties(context) {
1282
1282
  compileTemplate(context.translator.translate("errorAdditionalProperties"), { property })
1283
1283
  ]
1284
1284
  });
1285
- } else if (isObject(additionalProperties2)) {
1285
+ } else if (isObject$1(additionalProperties2)) {
1286
1286
  const additionalPropertyErrors = context.validator.getErrors(context.value[property], additionalProperties2, property, context.path + "/" + property).map((error) => ({
1287
1287
  type: "error",
1288
1288
  path: `${context.path}.${property}`,
@@ -1405,7 +1405,7 @@ function contains(context) {
1405
1405
  function dependentRequired(context) {
1406
1406
  const errors = [];
1407
1407
  const dependentRequired2 = getSchemaDependentRequired(context.schema);
1408
- if (isObject(context.value) && isSet(dependentRequired2)) {
1408
+ if (isObject$1(context.value) && isSet(dependentRequired2)) {
1409
1409
  let missingProperties = [];
1410
1410
  Object.keys(dependentRequired2).forEach((key) => {
1411
1411
  if (isSet(context.value[key])) {
@@ -1436,7 +1436,7 @@ function dependentRequired(context) {
1436
1436
  function dependentSchemas(context) {
1437
1437
  let errors = [];
1438
1438
  const dependentSchemas2 = getSchemaDependentSchemas(context.schema);
1439
- if (isObject(context.value) && isSet(dependentSchemas2)) {
1439
+ if (isObject$1(context.value) && isSet(dependentSchemas2)) {
1440
1440
  Object.keys(dependentSchemas2).forEach((key) => {
1441
1441
  if (isSet(context.value[key])) {
1442
1442
  const dependentSchema = dependentSchemas2[key];
@@ -1573,7 +1573,7 @@ function unevaluatedProperties(context) {
1573
1573
  const schemaAllOf = getSchemaAllOf(context.schema);
1574
1574
  const schemaAnyOf = getSchemaAnyOf(context.schema);
1575
1575
  const schemaOneOf = getSchemaOneOf(context.schema);
1576
- if (isObject(context.value) && isSet(schemaUnevaluatedProperties)) {
1576
+ if (isObject$1(context.value) && isSet(schemaUnevaluatedProperties)) {
1577
1577
  let properties2 = isSet(schemaProperties) ? schemaProperties : {};
1578
1578
  const unevaluatedProperties2 = schemaUnevaluatedProperties;
1579
1579
  const patternProperties2 = schemaPatternProperties;
@@ -1612,7 +1612,7 @@ function unevaluatedProperties(context) {
1612
1612
  ]
1613
1613
  });
1614
1614
  }
1615
- if (!definedInPatternProperty && isObject(unevaluatedProperties2) && !hasOwn(properties2, property)) {
1615
+ if (!definedInPatternProperty && isObject$1(unevaluatedProperties2) && !hasOwn(properties2, property)) {
1616
1616
  const unevaluatedPropertiesErrors = context.validator.getErrors(context.value[property], unevaluatedProperties2, property, context.path + "/" + property).map((error) => {
1617
1617
  return {
1618
1618
  type: "error",
@@ -1665,7 +1665,7 @@ const draft201909 = {
1665
1665
  function propertyNames(context) {
1666
1666
  const errors = [];
1667
1667
  const schemaPropertyNames = getSchemaPropertyNames(context.schema);
1668
- if (isObject(context.value) && isSet(schemaPropertyNames)) {
1668
+ if (isObject$1(context.value) && isSet(schemaPropertyNames)) {
1669
1669
  Object.keys(context.value).forEach((propertyName) => {
1670
1670
  const invalid = context.validator.getErrors(propertyName, schemaPropertyNames, propertyName, context.path).length > 0;
1671
1671
  if (invalid) {
@@ -1748,7 +1748,7 @@ class Validator {
1748
1748
  path
1749
1749
  }];
1750
1750
  }
1751
- if (this.refParser && isObject(schema) && hasOwn(schema, "$ref")) {
1751
+ if (this.refParser && isObject$1(schema) && hasOwn(schema, "$ref")) {
1752
1752
  schema = this.refParser.expand(schema);
1753
1753
  }
1754
1754
  const allConstraints = { ...this.draft, ...this.constraints };
@@ -1770,7 +1770,7 @@ class Validator {
1770
1770
  }
1771
1771
  const schemaOptionsMessages = getSchemaXOption(schema, "messages");
1772
1772
  if (isSet(schemaOptionsMessages)) {
1773
- if (isObject(schemaOptionsMessages)) {
1773
+ if (isObject$1(schemaOptionsMessages)) {
1774
1774
  schemaErrors.forEach((schemaError) => {
1775
1775
  var _a, _b;
1776
1776
  const schemaMessageListedByLanguage = (_b = schemaOptionsMessages == null ? void 0 : schemaOptionsMessages[(_a = this.translator) == null ? void 0 : _a.language]) == null ? void 0 : _b[schemaError == null ? void 0 : schemaError.constraint];
@@ -2250,7 +2250,7 @@ class Editor {
2250
2250
  this.control.container.setAttribute("data-path", this.instance.path);
2251
2251
  this.control.container.setAttribute("data-type", getSchemaType(this.instance.schema));
2252
2252
  const schemaContainerAttributes = getSchemaXOption(this.instance.schema, "containerAttributes");
2253
- if (isSet(schemaContainerAttributes) && isObject(schemaContainerAttributes)) {
2253
+ if (isSet(schemaContainerAttributes) && isObject$1(schemaContainerAttributes)) {
2254
2254
  for (const [key, value] of Object.entries(schemaContainerAttributes)) {
2255
2255
  if (key === "class") {
2256
2256
  const classes = value.split(" ");
@@ -2291,7 +2291,7 @@ class Editor {
2291
2291
  }
2292
2292
  const domPurifyOptions = this.instance.jedison.getOption("domPurifyOptions");
2293
2293
  buttons.forEach((config) => {
2294
- if (!isObject(config)) {
2294
+ if (!isObject$1(config)) {
2295
2295
  return;
2296
2296
  }
2297
2297
  const rawLabel = isString(config.label) ? config.label : "";
@@ -2299,7 +2299,7 @@ class Editor {
2299
2299
  const attributes = filterAttributes(config.attributes);
2300
2300
  const button = this.theme.getXButton({ label, attributes });
2301
2301
  this.control.container.appendChild(button);
2302
- const eventName = isObject(config.event) && isString(config.event.name) ? config.event.name : null;
2302
+ const eventName = isObject$1(config.event) && isString(config.event.name) ? config.event.name : null;
2303
2303
  if (!eventName) {
2304
2304
  return;
2305
2305
  }
@@ -2336,7 +2336,7 @@ class Editor {
2336
2336
  const input = this.control.input;
2337
2337
  if (isSet(input)) {
2338
2338
  const inputAttributes = getSchemaXOption(this.instance.schema, "inputAttributes");
2339
- if (isObject(inputAttributes)) {
2339
+ if (isObject$1(inputAttributes)) {
2340
2340
  for (const [key, value] of Object.entries(inputAttributes)) {
2341
2341
  input.setAttribute(key, value);
2342
2342
  }
@@ -2517,6 +2517,20 @@ class Editor {
2517
2517
  }
2518
2518
  return schemaInfo;
2519
2519
  }
2520
+ // Per-path view state on the shared root, so it survives an editor being
2521
+ // rebuilt or replaced (e.g. an if/then/else branch swap).
2522
+ getPersistentState(key, fallback) {
2523
+ const pathState = this.instance.jedison.persistentState[this.instance.path];
2524
+ const value = isSet(pathState) ? pathState[key] : void 0;
2525
+ return isSet(value) ? value : fallback;
2526
+ }
2527
+ setPersistentState(key, value) {
2528
+ const store = this.instance.jedison.persistentState;
2529
+ if (!isSet(store[this.instance.path])) {
2530
+ store[this.instance.path] = {};
2531
+ }
2532
+ store[this.instance.path][key] = value;
2533
+ }
2520
2534
  refreshLegendWarning() {
2521
2535
  }
2522
2536
  /**
@@ -2625,8 +2639,11 @@ class EditorIfThenElse extends Editor {
2625
2639
  }
2626
2640
  refreshUI() {
2627
2641
  this.refreshDisabledState();
2628
- this.control.childrenSlot.innerHTML = "";
2629
- this.control.childrenSlot.appendChild(this.instance.activeInstance.ui.control.container);
2642
+ const activeContainer = this.instance.activeInstance.ui.control.container;
2643
+ if (this.control.childrenSlot.firstChild !== activeContainer) {
2644
+ this.control.childrenSlot.innerHTML = "";
2645
+ this.control.childrenSlot.appendChild(activeContainer);
2646
+ }
2630
2647
  this.control.switcherSlot = this.instance.activeInstance.ui.control.switcherSlot;
2631
2648
  if (this.disabled || this.instance.isReadOnly()) {
2632
2649
  this.instance.activeInstance.ui.disable();
@@ -2701,7 +2718,7 @@ class InstanceIfThenElse extends Instance {
2701
2718
  this.activeInstance.register();
2702
2719
  this.instances.forEach((instance, index2) => {
2703
2720
  instance.off("notifyParent");
2704
- if (instance.children && isObject(value)) {
2721
+ if (instance.children && isObject$1(value)) {
2705
2722
  instance.children.forEach((child) => {
2706
2723
  const shouldUpdateValue = child.isMultiple && hasOwn(value, child.getKey());
2707
2724
  if (shouldUpdateValue) {
@@ -2711,7 +2728,7 @@ class InstanceIfThenElse extends Instance {
2711
2728
  }
2712
2729
  const startingValue = this.instanceStartingValues[index2];
2713
2730
  let instanceValue = value;
2714
- if (isObject(startingValue) && isObject(value)) {
2731
+ if (isObject$1(startingValue) && isObject$1(value)) {
2715
2732
  if (indexChanged && initiator !== "api") {
2716
2733
  instanceValue = overwriteExistingProperties(startingValue, withoutIf);
2717
2734
  } else {
@@ -2743,7 +2760,7 @@ class InstanceIfThenElse extends Instance {
2743
2760
  }
2744
2761
  getWithoutIfValueFromValue(value) {
2745
2762
  let withoutIf = this.instanceWithoutIf.getValue();
2746
- if (isObject(withoutIf) && isObject(value)) {
2763
+ if (isObject$1(withoutIf) && isObject$1(value)) {
2747
2764
  withoutIf = overwriteExistingProperties(withoutIf, value);
2748
2765
  return withoutIf;
2749
2766
  }
@@ -2964,7 +2981,7 @@ class InstanceMultiple extends Instance {
2964
2981
  */
2965
2982
  getFittestIndex(value) {
2966
2983
  const discriminator = getSchemaXOption(this.schema, "discriminator");
2967
- if (isSet(discriminator) && isObject(value)) {
2984
+ if (isSet(discriminator) && isObject$1(value)) {
2968
2985
  const propName = isString(discriminator) ? discriminator : discriminator.propertyName;
2969
2986
  const discriminatorValue = value[propName];
2970
2987
  if (isSet(discriminatorValue)) {
@@ -3222,7 +3239,7 @@ class InstanceObject extends Instance {
3222
3239
  const wasRefreshing = this.refreshingInstances;
3223
3240
  this.refreshingInstances = true;
3224
3241
  const value = this.getValue();
3225
- if (!isObject(value)) {
3242
+ if (!isObject$1(value)) {
3226
3243
  this.refreshingInstances = wasRefreshing;
3227
3244
  return;
3228
3245
  }
@@ -3264,7 +3281,7 @@ class InstanceObject extends Instance {
3264
3281
  class InstanceArray extends Instance {
3265
3282
  prepare() {
3266
3283
  this.schemaItems = getSchemaItems(this.schema);
3267
- if (isObject(this.schemaItems) && this.jedison.refParser && this.jedison.refParser.hasRef(this.schemaItems) && !this.schemaItems["x-recursive"]) {
3284
+ if (isObject$1(this.schemaItems) && this.jedison.refParser && this.jedison.refParser.hasRef(this.schemaItems) && !this.schemaItems["x-recursive"]) {
3268
3285
  this.schemaItems = this.jedison.refParser.expand(this.schemaItems);
3269
3286
  this.schema.items = this.schemaItems;
3270
3287
  }
@@ -3637,7 +3654,7 @@ class EditorStringRadios extends EditorString {
3637
3654
  getEnumSourceValues() {
3638
3655
  if (this.enumSourceValues !== void 0) {
3639
3656
  if (isArray(this.enumSourceValues)) return this.enumSourceValues;
3640
- if (isObject(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
3657
+ if (isObject$1(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
3641
3658
  return [];
3642
3659
  }
3643
3660
  return getSchemaEnum(this.instance.schema) || [];
@@ -3750,7 +3767,7 @@ class EditorStringSelect extends EditorString {
3750
3767
  getEnumSourceValues() {
3751
3768
  if (this.enumSourceValues !== void 0) {
3752
3769
  if (isArray(this.enumSourceValues)) return this.enumSourceValues;
3753
- if (isObject(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
3770
+ if (isObject$1(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
3754
3771
  return [];
3755
3772
  }
3756
3773
  return getSchemaEnum(this.instance.schema) || [];
@@ -4078,7 +4095,7 @@ class EditorNumberSelect extends EditorNumber {
4078
4095
  getEnumSourceValues() {
4079
4096
  if (this.enumSourceValues !== void 0) {
4080
4097
  if (isArray(this.enumSourceValues)) return this.enumSourceValues;
4081
- if (isObject(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
4098
+ if (isObject$1(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
4082
4099
  return [];
4083
4100
  }
4084
4101
  return getSchemaEnum(this.instance.schema) || [];
@@ -4330,7 +4347,7 @@ class EditorObject extends Editor {
4330
4347
  });
4331
4348
  }
4332
4349
  sanitize(value) {
4333
- if (isObject(value)) {
4350
+ if (isObject$1(value)) {
4334
4351
  return value;
4335
4352
  }
4336
4353
  return {};
@@ -4657,6 +4674,12 @@ class EditorObjectNav extends EditorObject {
4657
4674
  init() {
4658
4675
  super.init();
4659
4676
  this.activeTabIndex = 0;
4677
+ this.navTabs = /* @__PURE__ */ new Map();
4678
+ }
4679
+ // Persisted so the tab survives an if/then/else branch swap (issue #65).
4680
+ setActiveTabIndex(index2) {
4681
+ this.activeTabIndex = index2;
4682
+ this.setPersistentState("activeTab", index2);
4660
4683
  }
4661
4684
  isChildVisible(child) {
4662
4685
  if (!child.isActive) return false;
@@ -4671,7 +4694,7 @@ class EditorObjectNav extends EditorObject {
4671
4694
  }
4672
4695
  ensureActiveTabIsVisible(visibleIndices) {
4673
4696
  if (!visibleIndices.includes(this.activeTabIndex)) {
4674
- this.activeTabIndex = visibleIndices[0] ?? 0;
4697
+ this.setActiveTabIndex(visibleIndices[0] ?? 0);
4675
4698
  }
4676
4699
  }
4677
4700
  navigateTo(path) {
@@ -4679,16 +4702,13 @@ class EditorObjectNav extends EditorObject {
4679
4702
  if (nextChildPath) {
4680
4703
  const childIndex = this.instance.children.findIndex((c) => c.path === nextChildPath);
4681
4704
  if (childIndex !== -1) {
4682
- this.activeTabIndex = childIndex;
4705
+ this.setActiveTabIndex(childIndex);
4683
4706
  this.refreshUI();
4684
4707
  }
4685
4708
  }
4686
4709
  super.navigateTo(path);
4687
4710
  }
4688
- refreshEditors() {
4689
- while (this.control.childrenSlot.firstChild) {
4690
- this.control.childrenSlot.removeChild(this.control.childrenSlot.lastChild);
4691
- }
4711
+ buildNavShell() {
4692
4712
  const format2 = getSchemaXOption(this.instance.schema, "format");
4693
4713
  const formatParts = format2.split("-");
4694
4714
  const variant = formatParts[1];
@@ -4697,43 +4717,85 @@ class EditorObjectNav extends EditorObject {
4697
4717
  const row = this.theme.getRow();
4698
4718
  const tabListCol = this.theme.getCol(12, 12, navColumns, navColumns);
4699
4719
  const tabContentCol = this.theme.getCol(12, 12, 12 - navColumns, 12 - navColumns);
4700
- const tabContent = this.theme.getTabContent();
4701
- const tabList = this.theme.getTabList({
4702
- variant
4703
- });
4704
- this.control.childrenSlot.appendChild(row);
4720
+ this.navTabContent = this.theme.getTabContent();
4721
+ this.navTabList = this.theme.getTabList({ variant });
4705
4722
  row.appendChild(tabListCol);
4706
4723
  row.appendChild(tabContentCol);
4707
- tabListCol.appendChild(tabList);
4708
- tabContentCol.appendChild(tabContent);
4724
+ tabListCol.appendChild(this.navTabList);
4725
+ tabContentCol.appendChild(this.navTabContent);
4726
+ this.control.childrenSlot.appendChild(row);
4727
+ }
4728
+ createTab(child) {
4729
+ const tab = this.theme.getTab({
4730
+ title: this.getChildTitle(child),
4731
+ id: this.getIdFromPath(child.path)
4732
+ });
4733
+ tab.list.addEventListener("click", () => {
4734
+ this.setActiveTabIndex(this.instance.children.indexOf(child));
4735
+ });
4736
+ return tab;
4737
+ }
4738
+ getChildTitle(child) {
4739
+ const schemaTitle = getSchemaTitle(child.schema);
4740
+ return isSet(schemaTitle) ? schemaTitle : child.getKey();
4741
+ }
4742
+ updateTab(tab, child, active) {
4743
+ tab.list.classList.toggle("active", active);
4744
+ tab.link.classList.toggle("active", active);
4745
+ tab.text.textContent = this.getChildTitle(child);
4746
+ const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
4747
+ const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
4748
+ const hasErrors = navWarning && child.hasNestedValidationErrors();
4749
+ const existing = tab.link.querySelector(".jedi-nav-warning");
4750
+ if (existing) existing.parentNode.removeChild(existing);
4751
+ if (hasErrors) {
4752
+ const warning = document.createElement("span");
4753
+ warning.classList.add("jedi-nav-warning");
4754
+ warning.textContent = "⚠ ";
4755
+ tab.link.appendChild(warning);
4756
+ if (navWarningMessage) tab.list.setAttribute("title", navWarningMessage);
4757
+ } else {
4758
+ tab.list.removeAttribute("title");
4759
+ }
4760
+ }
4761
+ refreshEditors() {
4762
+ this.activeTabIndex = this.getPersistentState("activeTab", this.activeTabIndex);
4763
+ if (!this.navTabContent) this.buildNavShell();
4709
4764
  const visibleIndices = this.getVisibleChildIndices();
4710
4765
  this.ensureActiveTabIsVisible(visibleIndices);
4766
+ const currentPaths = new Set(this.instance.children.map((child) => child.path));
4711
4767
  this.instance.children.forEach((child, index2) => {
4712
- if (!this.isChildVisible(child)) return;
4768
+ let tab = this.navTabs.get(child.path);
4769
+ if (!this.isChildVisible(child)) {
4770
+ if (tab && tab.list.parentNode) tab.list.parentNode.removeChild(tab.list);
4771
+ if (child.ui.control.container.parentNode === this.navTabContent) {
4772
+ this.navTabContent.removeChild(child.ui.control.container);
4773
+ }
4774
+ return;
4775
+ }
4776
+ if (!tab) {
4777
+ tab = this.createTab(child);
4778
+ this.navTabs.set(child.path, tab);
4779
+ }
4713
4780
  const active = index2 === this.activeTabIndex;
4714
- const id = this.getIdFromPath(child.path);
4715
- const schemaTitle = getSchemaTitle(child.schema);
4716
- const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
4717
- const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
4718
- const tab = this.theme.getTab({
4719
- hasErrors: navWarning && child.hasNestedValidationErrors(),
4720
- navWarningMessage,
4721
- title: isSet(schemaTitle) ? schemaTitle : child.getKey(),
4722
- id,
4723
- active
4724
- });
4725
- tab.list.addEventListener("click", () => {
4726
- this.activeTabIndex = index2;
4727
- });
4728
- this.theme.setTabPaneAttributes(child.ui.control.container, active, id);
4729
- tabList.appendChild(tab.list);
4730
- tabContent.appendChild(child.ui.control.container);
4781
+ this.updateTab(tab, child, active);
4782
+ this.theme.setTabPaneAttributes(child.ui.control.container, active, this.getIdFromPath(child.path));
4783
+ if (tab.list.parentNode !== this.navTabList) this.navTabList.appendChild(tab.list);
4784
+ if (child.ui.control.container.parentNode !== this.navTabContent) {
4785
+ this.navTabContent.appendChild(child.ui.control.container);
4786
+ }
4731
4787
  if (this.disabled || this.instance.isReadOnly()) {
4732
4788
  child.ui.disable();
4733
4789
  } else {
4734
4790
  child.ui.enable();
4735
4791
  }
4736
4792
  });
4793
+ this.navTabs.forEach((tab, path) => {
4794
+ if (!currentPaths.has(path)) {
4795
+ if (tab.list.parentNode) tab.list.parentNode.removeChild(tab.list);
4796
+ this.navTabs.delete(path);
4797
+ }
4798
+ });
4737
4799
  }
4738
4800
  }
4739
4801
  class EditorObjectAccordion extends EditorObject {
@@ -4872,6 +4934,11 @@ class EditorArray extends Editor {
4872
4934
  super.init();
4873
4935
  this.activeItemIndex = 0;
4874
4936
  }
4937
+ // Persisted so EditorArrayNav's item survives an if/then/else swap (issue #65).
4938
+ setActiveItemIndex(index2) {
4939
+ this.activeItemIndex = index2;
4940
+ this.setPersistentState("activeItem", index2);
4941
+ }
4875
4942
  build() {
4876
4943
  this.control = this.theme.getArrayControl({
4877
4944
  title: this.getTitle(),
@@ -4987,7 +5054,7 @@ class EditorArray extends Editor {
4987
5054
  const globalConfirm = this.instance.jedison.getOption("arrayDeleteConfirm");
4988
5055
  const shouldConfirm = isSet(schemaConfirm) ? schemaConfirm : globalConfirm;
4989
5056
  const doDelete = () => {
4990
- this.activeItemIndex = clamp(index2 - 1, 0, this.instance.value.length - 1);
5057
+ this.setActiveItemIndex(clamp(index2 - 1, 0, this.instance.value.length - 1));
4991
5058
  this.instance.deleteItem(index2, "user");
4992
5059
  };
4993
5060
  if (shouldConfirm) {
@@ -5000,16 +5067,16 @@ class EditorArray extends Editor {
5000
5067
  });
5001
5068
  moveUpBtn.addEventListener("click", () => {
5002
5069
  const toIndex = index2 - 1;
5003
- this.activeItemIndex = toIndex;
5070
+ this.setActiveItemIndex(toIndex);
5004
5071
  this.instance.move(index2, toIndex, "user");
5005
5072
  });
5006
5073
  moveDownBtn.addEventListener("click", () => {
5007
5074
  const toIndex = index2 + 1;
5008
- this.activeItemIndex = toIndex;
5075
+ this.setActiveItemIndex(toIndex);
5009
5076
  this.instance.move(index2, toIndex, "user");
5010
5077
  });
5011
5078
  addAfterBtn.addEventListener("click", () => {
5012
- this.activeItemIndex = index2 + 1;
5079
+ this.setActiveItemIndex(index2 + 1);
5013
5080
  this.instance.addItemAfter(index2, "user");
5014
5081
  });
5015
5082
  if (index2 === 0) {
@@ -5524,7 +5591,7 @@ class EditorArrayChoices extends Editor {
5524
5591
  getEnumSourceValues() {
5525
5592
  if (this.enumSourceValues !== void 0) {
5526
5593
  if (isArray(this.enumSourceValues)) return this.enumSourceValues;
5527
- if (isObject(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
5594
+ if (isObject$1(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
5528
5595
  return [];
5529
5596
  }
5530
5597
  return this.instance.schema.items && this.instance.schema.items.enum || [];
@@ -5624,7 +5691,7 @@ class EditorArrayNav extends EditorArray {
5624
5691
  if (nextChildPath) {
5625
5692
  const childIndex = this.instance.children.findIndex((c) => c.path === nextChildPath);
5626
5693
  if (childIndex !== -1) {
5627
- this.activeItemIndex = childIndex;
5694
+ this.setActiveItemIndex(childIndex);
5628
5695
  this.refreshUI();
5629
5696
  }
5630
5697
  }
@@ -5632,28 +5699,33 @@ class EditorArrayNav extends EditorArray {
5632
5699
  }
5633
5700
  addEventListeners() {
5634
5701
  this.control.addBtn.addEventListener("click", () => {
5635
- this.activeItemIndex = this.instance.value.length;
5702
+ this.setActiveItemIndex(this.instance.value.length);
5636
5703
  this.instance.addItem("user");
5637
5704
  });
5638
5705
  this.control.footerAddBtn.addEventListener("click", () => {
5639
- this.activeItemIndex = this.instance.value.length;
5706
+ this.setActiveItemIndex(this.instance.value.length);
5640
5707
  this.instance.addItem("user");
5641
5708
  });
5642
5709
  if (this.control.deleteAllBtn) {
5643
5710
  this.control.deleteAllBtn.addEventListener("click", () => {
5644
- this.activeItemIndex = 0;
5711
+ this.setActiveItemIndex(0);
5645
5712
  this.deleteAllItems();
5646
5713
  });
5647
5714
  }
5648
5715
  if (this.control.footerDeleteAllBtn) {
5649
5716
  this.control.footerDeleteAllBtn.addEventListener("click", () => {
5650
- this.activeItemIndex = 0;
5717
+ this.setActiveItemIndex(0);
5651
5718
  this.deleteAllItems();
5652
5719
  });
5653
5720
  }
5654
5721
  this.addJsonDataEventListeners();
5655
5722
  }
5656
5723
  refreshUI() {
5724
+ this.activeItemIndex = this.getPersistentState("activeItem", this.activeItemIndex);
5725
+ const lastIndex = this.instance.children.length - 1;
5726
+ if (this.activeItemIndex > lastIndex) {
5727
+ this.setActiveItemIndex(lastIndex < 0 ? 0 : lastIndex);
5728
+ }
5657
5729
  this.control.childrenSlot.innerHTML = "";
5658
5730
  this.clearStoredEventListeners();
5659
5731
  const format2 = getSchemaXOption(this.instance.schema, "format");
@@ -5714,7 +5786,7 @@ class EditorArrayNav extends EditorArray {
5714
5786
  });
5715
5787
  arrayActions.appendChild(btnGroup);
5716
5788
  const clickHandler = () => {
5717
- this.activeItemIndex = index2;
5789
+ this.setActiveItemIndex(index2);
5718
5790
  };
5719
5791
  list.addEventListener("click", clickHandler);
5720
5792
  this.storedEventListeners.push({
@@ -5757,7 +5829,7 @@ class EditorArrayNav extends EditorArray {
5757
5829
  handle: ".jedi-array-drag",
5758
5830
  disabled: this.disabled || this.readOnly,
5759
5831
  onEnd: (evt) => {
5760
- this.activeItemIndex = evt.newIndex;
5832
+ this.setActiveItemIndex(evt.newIndex);
5761
5833
  this.instance.move(evt.oldIndex, evt.newIndex);
5762
5834
  }
5763
5835
  });
@@ -5841,8 +5913,11 @@ class EditorMultiple extends Editor {
5841
5913
  }
5842
5914
  refreshUI() {
5843
5915
  this.refreshDisabledState();
5844
- this.control.childrenSlot.innerHTML = "";
5845
- this.control.childrenSlot.appendChild(this.instance.activeInstance.ui.control.container);
5916
+ const activeContainer = this.instance.activeInstance.ui.control.container;
5917
+ if (this.control.childrenSlot.firstChild !== activeContainer) {
5918
+ this.control.childrenSlot.innerHTML = "";
5919
+ this.control.childrenSlot.appendChild(activeContainer);
5920
+ }
5846
5921
  const slot = this.instance.activeInstance.ui.control.switcherSlot;
5847
5922
  this.control.switcherSlot = slot;
5848
5923
  if (this.embedSwitcher || this.switcherInput === "modal" || this.switcherInput === "select-inline") {
@@ -6416,7 +6491,7 @@ class EditorArrayCheckboxes extends Editor {
6416
6491
  getEnumSourceValues() {
6417
6492
  if (this.enumSourceValues !== void 0) {
6418
6493
  if (isArray(this.enumSourceValues)) return this.enumSourceValues;
6419
- if (isObject(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
6494
+ if (isObject$1(this.enumSourceValues)) return Object.keys(this.enumSourceValues);
6420
6495
  return [];
6421
6496
  }
6422
6497
  return getSchemaEnum(this.instance.schema.items) || [];
@@ -7201,6 +7276,7 @@ class Jedison extends EventEmitter {
7201
7276
  this.pathSeparator = "/";
7202
7277
  this.instances = /* @__PURE__ */ new Map();
7203
7278
  this.root = null;
7279
+ this.persistentState = {};
7204
7280
  this.translator = new Translator({
7205
7281
  language: this.options.language,
7206
7282
  translations: this.options.translations
@@ -7366,7 +7442,7 @@ class Jedison extends EventEmitter {
7366
7442
  this.hiddenInput.setAttribute("name", "json");
7367
7443
  this.hiddenInput.removeAttribute("aria-describedby");
7368
7444
  this.hiddenInput.removeAttribute("aria-hidden", "true");
7369
- if (this.options.hiddenInputAttributes && isObject(this.options.hiddenInputAttributes)) {
7445
+ if (this.options.hiddenInputAttributes && isObject$1(this.options.hiddenInputAttributes)) {
7370
7446
  Object.keys(this.options.hiddenInputAttributes).forEach((attr) => {
7371
7447
  this.hiddenInput.setAttribute(attr, this.options.hiddenInputAttributes[attr]);
7372
7448
  });
@@ -7469,7 +7545,7 @@ class Jedison extends EventEmitter {
7469
7545
  }
7470
7546
  });
7471
7547
  this.walker.traverse(config.schema, (node) => {
7472
- if (node.not && isObject(node.not)) {
7548
+ if (node.not && isObject$1(node.not)) {
7473
7549
  const nodeClone = clone(node);
7474
7550
  delete nodeClone.not;
7475
7551
  node.not = combineDeep({}, nodeClone, node.not);
@@ -8391,7 +8467,7 @@ class Theme {
8391
8467
  label.classList.add("jedi-x-button-label");
8392
8468
  label.innerHTML = config.label ?? "";
8393
8469
  button.appendChild(label);
8394
- const attributes = isObject(config.attributes) ? config.attributes : {};
8470
+ const attributes = isObject$1(config.attributes) ? config.attributes : {};
8395
8471
  for (const [key, value] of Object.entries(attributes)) {
8396
8472
  if (key === "class") {
8397
8473
  String(value).split(" ").forEach((cls) => {
@@ -8511,7 +8587,7 @@ class Theme {
8511
8587
  container.style.display = "inline-block";
8512
8588
  info.setAttribute("href", "#");
8513
8589
  info.classList.add("jedi-info-button");
8514
- if (isObject(config.attributes)) {
8590
+ if (isObject$1(config.attributes)) {
8515
8591
  for (const [key, value] of Object.entries(config.attributes)) {
8516
8592
  info.setAttribute(key, value);
8517
8593
  }
@@ -8605,7 +8681,7 @@ class Theme {
8605
8681
  this.infoAsModal(info, config.id, config.info);
8606
8682
  }
8607
8683
  container.appendChild(label);
8608
- if (isObject(config.info)) {
8684
+ if (isObject$1(config.info)) {
8609
8685
  container.appendChild(info.container);
8610
8686
  }
8611
8687
  container.appendChild(switcherSlot);
@@ -8699,7 +8775,7 @@ class Theme {
8699
8775
  container.appendChild(jsonData.dialog);
8700
8776
  }
8701
8777
  fieldset.appendChild(legend);
8702
- if (isObject(config.info)) {
8778
+ if (isObject$1(config.info)) {
8703
8779
  while (info.container.firstChild) {
8704
8780
  infoContainer.appendChild(info.container.firstChild);
8705
8781
  }
@@ -9024,7 +9100,7 @@ class Theme {
9024
9100
  container.appendChild(jsonData.dialog);
9025
9101
  }
9026
9102
  fieldset.appendChild(legend);
9027
- if (isObject(config.info)) {
9103
+ if (isObject$1(config.info)) {
9028
9104
  while (info.container.firstChild) {
9029
9105
  infoContainer.appendChild(info.container.firstChild);
9030
9106
  }
@@ -9236,7 +9312,7 @@ class Theme {
9236
9312
  this.infoAsModal(info, config.id, config.info);
9237
9313
  }
9238
9314
  container.appendChild(label);
9239
- if (isObject(config.info)) {
9315
+ if (isObject$1(config.info)) {
9240
9316
  container.appendChild(info.container);
9241
9317
  }
9242
9318
  container.appendChild(switcherSlot);
@@ -9280,7 +9356,7 @@ class Theme {
9280
9356
  this.infoAsModal(info, config.id, config.info);
9281
9357
  }
9282
9358
  container.appendChild(label);
9283
- if (isObject(config.info)) {
9359
+ if (isObject$1(config.info)) {
9284
9360
  container.appendChild(info.container);
9285
9361
  }
9286
9362
  container.appendChild(switcherSlot);
@@ -9330,7 +9406,7 @@ class Theme {
9330
9406
  if (((_a = config == null ? void 0 : config.info) == null ? void 0 : _a.variant) === "modal") {
9331
9407
  this.infoAsModal(info, config.id, config.info);
9332
9408
  }
9333
- if (isObject(config.info)) {
9409
+ if (isObject$1(config.info)) {
9334
9410
  container.appendChild(info.container);
9335
9411
  }
9336
9412
  container.appendChild(switcherSlot);
@@ -9412,7 +9488,7 @@ class Theme {
9412
9488
  container.appendChild(fieldset);
9413
9489
  fieldset.appendChild(legend);
9414
9490
  legend.appendChild(switcherSlot);
9415
- if (isObject(config.info)) {
9491
+ if (isObject$1(config.info)) {
9416
9492
  legendText.after(info.container);
9417
9493
  }
9418
9494
  radioControls.forEach((radioControl, index2) => {
@@ -9480,7 +9556,7 @@ class Theme {
9480
9556
  container.appendChild(actions);
9481
9557
  formGroup.appendChild(input);
9482
9558
  formGroup.appendChild(label);
9483
- if (isObject(config.info)) {
9559
+ if (isObject$1(config.info)) {
9484
9560
  formGroup.appendChild(info.container);
9485
9561
  }
9486
9562
  formGroup.appendChild(switcherSlot);
@@ -9547,7 +9623,7 @@ class Theme {
9547
9623
  container.appendChild(fieldset);
9548
9624
  fieldset.appendChild(legend);
9549
9625
  legend.appendChild(switcherSlot);
9550
- if (isObject(config.info)) {
9626
+ if (isObject$1(config.info)) {
9551
9627
  legendText.after(info.container);
9552
9628
  }
9553
9629
  checkboxControls.forEach((checkboxControl, index2) => {
@@ -9617,7 +9693,7 @@ class Theme {
9617
9693
  this.infoAsModal(info, config.id, config.info);
9618
9694
  }
9619
9695
  container.appendChild(label);
9620
- if (isObject(config.info)) {
9696
+ if (isObject$1(config.info)) {
9621
9697
  container.appendChild(info.container);
9622
9698
  }
9623
9699
  container.appendChild(switcherSlot);
@@ -10799,7 +10875,7 @@ class ThemeBootstrap4 extends Theme {
10799
10875
  container.appendChild(formGroup);
10800
10876
  formGroup.appendChild(input);
10801
10877
  formGroup.appendChild(label);
10802
- if (isObject(config.info)) {
10878
+ if (isObject$1(config.info)) {
10803
10879
  label.appendChild(info.container);
10804
10880
  }
10805
10881
  container.appendChild(description);
@@ -11355,7 +11431,7 @@ class ThemeBootstrap5 extends Theme {
11355
11431
  container.appendChild(formGroup);
11356
11432
  formGroup.appendChild(input);
11357
11433
  formGroup.appendChild(label);
11358
- if (isObject(config.info)) {
11434
+ if (isObject$1(config.info)) {
11359
11435
  label.appendChild(info.container);
11360
11436
  }
11361
11437
  container.appendChild(description);
@@ -11549,6 +11625,225 @@ class ThemeBootstrap5 extends Theme {
11549
11625
  element.classList.remove("visually-hidden");
11550
11626
  }
11551
11627
  }
11628
+ function isObject(value) {
11629
+ return value !== null && typeof value === "object" && !Array.isArray(value);
11630
+ }
11631
+ function isContainer(value) {
11632
+ return value !== null && typeof value === "object";
11633
+ }
11634
+ function unsupported(path, detail) {
11635
+ throw new Error(`Jedison: unsupported JSONPath "${path}" — ${detail}. Supported: $, .name, ['name'], [n], *, and .. (no filters, slices, or functions).`);
11636
+ }
11637
+ function splitUnion(content) {
11638
+ const parts = [];
11639
+ let current = "";
11640
+ let quote = null;
11641
+ for (let i = 0; i < content.length; i++) {
11642
+ const char = content[i];
11643
+ if (quote) {
11644
+ if (char === quote) quote = null;
11645
+ current += char;
11646
+ } else if (char === "'" || char === '"') {
11647
+ quote = char;
11648
+ current += char;
11649
+ } else if (char === ",") {
11650
+ parts.push(current);
11651
+ current = "";
11652
+ } else {
11653
+ current += char;
11654
+ }
11655
+ }
11656
+ parts.push(current);
11657
+ return parts;
11658
+ }
11659
+ function parseBracket(content, path) {
11660
+ const trimmed = content.trim();
11661
+ if (trimmed === "*") {
11662
+ return [{ type: "wildcard" }];
11663
+ }
11664
+ if (trimmed.includes("?")) unsupported(path, "filter expressions are not supported");
11665
+ if (trimmed.includes("(")) unsupported(path, "function extensions are not supported");
11666
+ return splitUnion(trimmed).map((raw) => {
11667
+ const part = raw.trim();
11668
+ if (part.startsWith("'") && part.endsWith("'") || part.startsWith('"') && part.endsWith('"')) {
11669
+ return { type: "name", value: part.slice(1, -1) };
11670
+ }
11671
+ if (/^-?\d+$/.test(part)) {
11672
+ return { type: "index", value: parseInt(part, 10) };
11673
+ }
11674
+ if (part.includes(":")) unsupported(path, "array slices are not supported");
11675
+ unsupported(path, `cannot parse selector "${part}"`);
11676
+ });
11677
+ }
11678
+ function tokenize(path) {
11679
+ if (typeof path !== "string" || path[0] !== "$") {
11680
+ unsupported(path, 'must start with "$"');
11681
+ }
11682
+ const steps = [];
11683
+ let i = 1;
11684
+ const readName = () => {
11685
+ const start = i;
11686
+ while (i < path.length && path[i] !== "." && path[i] !== "[") i++;
11687
+ const name = path.slice(start, i);
11688
+ if (name === "") unsupported(path, 'empty name after "."');
11689
+ if (name.includes("(")) unsupported(path, "function extensions are not supported");
11690
+ return name;
11691
+ };
11692
+ const readDotSelector = (descendant) => {
11693
+ if (path[i] === "*") {
11694
+ i++;
11695
+ steps.push({ descendant, selectors: [{ type: "wildcard" }] });
11696
+ } else {
11697
+ steps.push({ descendant, selectors: [{ type: "name", value: readName() }] });
11698
+ }
11699
+ };
11700
+ const readBracket = (descendant) => {
11701
+ i++;
11702
+ let content = "";
11703
+ let quote = null;
11704
+ while (i < path.length && (quote || path[i] !== "]")) {
11705
+ const char = path[i];
11706
+ if (quote) {
11707
+ if (char === quote) quote = null;
11708
+ } else if (char === "'" || char === '"') {
11709
+ quote = char;
11710
+ }
11711
+ content += char;
11712
+ i++;
11713
+ }
11714
+ if (path[i] !== "]") unsupported(path, 'unterminated "["');
11715
+ i++;
11716
+ steps.push({ descendant, selectors: parseBracket(content, path) });
11717
+ };
11718
+ while (i < path.length) {
11719
+ if (path[i] === "." && path[i + 1] === ".") {
11720
+ i += 2;
11721
+ if (path[i] === "[") readBracket(true);
11722
+ else readDotSelector(true);
11723
+ } else if (path[i] === ".") {
11724
+ i++;
11725
+ readDotSelector(false);
11726
+ } else if (path[i] === "[") {
11727
+ readBracket(false);
11728
+ } else {
11729
+ unsupported(path, `unexpected character "${path[i]}"`);
11730
+ }
11731
+ }
11732
+ return steps;
11733
+ }
11734
+ function withDescendants(nodeRef) {
11735
+ const list = [nodeRef];
11736
+ const walk = (container) => {
11737
+ if (Array.isArray(container)) {
11738
+ container.forEach((value, index2) => {
11739
+ list.push({ parent: container, key: index2, value });
11740
+ walk(value);
11741
+ });
11742
+ } else if (isObject(container)) {
11743
+ Object.keys(container).forEach((key) => {
11744
+ list.push({ parent: container, key, value: container[key] });
11745
+ walk(container[key]);
11746
+ });
11747
+ }
11748
+ };
11749
+ walk(nodeRef.value);
11750
+ return list;
11751
+ }
11752
+ function applySelector(container, selector, out) {
11753
+ if (!isContainer(container)) return;
11754
+ if (selector.type === "wildcard") {
11755
+ if (Array.isArray(container)) {
11756
+ container.forEach((value, index2) => out.push({ parent: container, key: index2, value }));
11757
+ } else {
11758
+ Object.keys(container).forEach((key) => out.push({ parent: container, key, value: container[key] }));
11759
+ }
11760
+ return;
11761
+ }
11762
+ if (selector.type === "name") {
11763
+ if (isObject(container) && Object.prototype.hasOwnProperty.call(container, selector.value)) {
11764
+ out.push({ parent: container, key: selector.value, value: container[selector.value] });
11765
+ }
11766
+ return;
11767
+ }
11768
+ if (selector.type === "index") {
11769
+ if (Array.isArray(container)) {
11770
+ const index2 = selector.value < 0 ? container.length + selector.value : selector.value;
11771
+ if (index2 >= 0 && index2 < container.length) {
11772
+ out.push({ parent: container, key: index2, value: container[index2] });
11773
+ }
11774
+ }
11775
+ }
11776
+ }
11777
+ function selectNodes(root, path) {
11778
+ const steps = tokenize(path);
11779
+ let current = [{ parent: null, key: null, value: root }];
11780
+ for (const step of steps) {
11781
+ const bases = step.descendant ? current.flatMap(withDescendants) : current;
11782
+ const next = [];
11783
+ for (const node of bases) {
11784
+ for (const selector of step.selectors) {
11785
+ applySelector(node.value, selector, next);
11786
+ }
11787
+ }
11788
+ current = next;
11789
+ }
11790
+ return current;
11791
+ }
11792
+ function applyUpdate(nodeRef, update) {
11793
+ const { parent, key, value } = nodeRef;
11794
+ const incoming = clone(update);
11795
+ if (isArray(value)) {
11796
+ if (isArray(incoming)) value.push(...incoming);
11797
+ else value.push(incoming);
11798
+ return;
11799
+ }
11800
+ if (isObject$1(value) && isObject$1(incoming)) {
11801
+ combineDeep(value, incoming);
11802
+ return;
11803
+ }
11804
+ if (parent === null) {
11805
+ throw new Error("Jedison: overlay cannot replace the root schema with a non-object update.");
11806
+ }
11807
+ parent[key] = incoming;
11808
+ }
11809
+ function applyRemove(nodes) {
11810
+ if (nodes.some((node) => node.parent === null)) {
11811
+ throw new Error("Jedison: overlay cannot remove the root schema.");
11812
+ }
11813
+ nodes.filter((node) => node.parent && !isArray(node.parent)).forEach((node) => {
11814
+ delete node.parent[node.key];
11815
+ });
11816
+ const arrayGroups = /* @__PURE__ */ new Map();
11817
+ nodes.filter((node) => isArray(node.parent)).forEach((node) => {
11818
+ if (!arrayGroups.has(node.parent)) arrayGroups.set(node.parent, []);
11819
+ arrayGroups.get(node.parent).push(node.key);
11820
+ });
11821
+ arrayGroups.forEach((indices, array) => {
11822
+ indices.sort((a, b) => b - a).forEach((index2) => array.splice(index2, 1));
11823
+ });
11824
+ }
11825
+ function applyOverlay(schema, overlay) {
11826
+ const result = clone(schema);
11827
+ if (overlay === null || typeof overlay === "undefined") {
11828
+ return result;
11829
+ }
11830
+ if (!isObject$1(overlay) || !isArray(overlay.actions)) {
11831
+ throw new Error('Jedison: overlay must be an object with an "actions" array.');
11832
+ }
11833
+ overlay.actions.forEach((action, index2) => {
11834
+ if (!isObject$1(action) || typeof action.target !== "string") {
11835
+ throw new Error(`Jedison: overlay action ${index2} must be an object with a string "target".`);
11836
+ }
11837
+ const nodes = selectNodes(result, action.target);
11838
+ if (nodes.length === 0) return;
11839
+ if (action.remove === true) {
11840
+ applyRemove(nodes);
11841
+ } else if (typeof action.update !== "undefined") {
11842
+ nodes.forEach((node) => applyUpdate(node, action.update));
11843
+ }
11844
+ });
11845
+ return result;
11846
+ }
11552
11847
  const index = {
11553
11848
  Schema,
11554
11849
  Utils,
@@ -11588,7 +11883,8 @@ const index = {
11588
11883
  ThemeBootstrap5,
11589
11884
  RefParser,
11590
11885
  Create: Jedison,
11591
- SchemaGenerator
11886
+ SchemaGenerator,
11887
+ applyOverlay
11592
11888
  };
11593
11889
  export {
11594
11890
  index as default