proskomma-core 0.10.10 → 0.10.12

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.
Files changed (3) hide show
  1. package/dist/index.js +644 -579
  2. package/dist/index.mjs +644 -579
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1237,10 +1237,7 @@ function getAugmentedNamespace(n) {
1237
1237
  if (typeof f == "function") {
1238
1238
  var a = function a2() {
1239
1239
  if (this instanceof a2) {
1240
- var args = [null];
1241
- args.push.apply(args, arguments);
1242
- var Ctor = Function.bind.apply(f, args);
1243
- return new Ctor();
1240
+ return Reflect.construct(f, arguments, this.constructor);
1244
1241
  }
1245
1242
  return f.apply(this, arguments);
1246
1243
  };
@@ -1477,6 +1474,7 @@ var categories = [
1477
1474
  "bmp": "    -    "
1478
1475
  }
1479
1476
  ];
1477
+ const categories$1 = /* @__PURE__ */ getDefaultExportFromCjs(categories);
1480
1478
  /*!
1481
1479
  * XRegExp Unicode Categories 5.1.1
1482
1480
  * <xregexp.com>
@@ -1487,7 +1485,7 @@ const unicodeCategories = (XRegExp2) => {
1487
1485
  if (!XRegExp2.addUnicodeData) {
1488
1486
  throw new ReferenceError("Unicode Base must be loaded before Unicode Categories");
1489
1487
  }
1490
- XRegExp2.addUnicodeData(categories);
1488
+ XRegExp2.addUnicodeData(categories$1);
1491
1489
  };
1492
1490
  var properties$o = [
1493
1491
  {
@@ -1530,6 +1528,7 @@ var properties$o = [
1530
1528
  "bmp": " -\r …   - \u2028\u2029   "
1531
1529
  }
1532
1530
  ];
1531
+ const properties$p = /* @__PURE__ */ getDefaultExportFromCjs(properties$o);
1533
1532
  /*!
1534
1533
  * XRegExp Unicode Properties 5.1.1
1535
1534
  * <xregexp.com>
@@ -1540,7 +1539,7 @@ const unicodeProperties = (XRegExp2) => {
1540
1539
  if (!XRegExp2.addUnicodeData) {
1541
1540
  throw new ReferenceError("Unicode Base must be loaded before Unicode Properties");
1542
1541
  }
1543
- const unicodeData = properties$o;
1542
+ const unicodeData = properties$p;
1544
1543
  unicodeData.push({
1545
1544
  name: "Assigned",
1546
1545
  // Since this is defined as the inverse of Unicode category Cn (Unassigned), the Unicode
@@ -2211,6 +2210,7 @@ var scripts$1 = [
2211
2210
  "astral": "\uD806[\uDE00-\uDE47]"
2212
2211
  }
2213
2212
  ];
2213
+ const scripts$2 = /* @__PURE__ */ getDefaultExportFromCjs(scripts$1);
2214
2214
  /*!
2215
2215
  * XRegExp Unicode Scripts 5.1.1
2216
2216
  * <xregexp.com>
@@ -2221,7 +2221,7 @@ const unicodeScripts = (XRegExp2) => {
2221
2221
  if (!XRegExp2.addUnicodeData) {
2222
2222
  throw new ReferenceError("Unicode Base must be loaded before Unicode Scripts");
2223
2223
  }
2224
- XRegExp2.addUnicodeData(scripts$1, "Script");
2224
+ XRegExp2.addUnicodeData(scripts$2, "Script");
2225
2225
  };
2226
2226
  build(XRegExp);
2227
2227
  matchRecursive(XRegExp);
@@ -3380,8 +3380,7 @@ function getObjectTag$1(object) {
3380
3380
  const instanceOf = (
3381
3381
  /* c8 ignore next 6 */
3382
3382
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
3383
- // eslint-disable-next-line no-undef
3384
- process.env.NODE_ENV === "production" ? function instanceOf2(value, constructor) {
3383
+ globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function instanceOf2(value, constructor) {
3385
3384
  return value instanceof constructor;
3386
3385
  } : function instanceOf3(value, constructor) {
3387
3386
  if (value instanceof constructor) {
@@ -8852,7 +8851,7 @@ function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPai
8852
8851
  [node2]
8853
8852
  ];
8854
8853
  }
8855
- if (stringifyArguments(node1) !== stringifyArguments(node2)) {
8854
+ if (!sameArguments(node1, node2)) {
8856
8855
  return [
8857
8856
  [responseName, "they have differing arguments"],
8858
8857
  [node1],
@@ -8890,21 +8889,30 @@ function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPai
8890
8889
  return subfieldConflicts(conflicts, responseName, node1, node2);
8891
8890
  }
8892
8891
  }
8893
- function stringifyArguments(fieldNode) {
8894
- var _fieldNode$arguments;
8895
- const args = (
8896
- /* c8 ignore next */
8897
- (_fieldNode$arguments = fieldNode.arguments) !== null && _fieldNode$arguments !== void 0 ? _fieldNode$arguments : []
8898
- );
8899
- const inputObjectWithArgs = {
8900
- kind: Kind.OBJECT,
8901
- fields: args.map((argNode) => ({
8902
- kind: Kind.OBJECT_FIELD,
8903
- name: argNode.name,
8904
- value: argNode.value
8905
- }))
8906
- };
8907
- return print(sortValueNode(inputObjectWithArgs));
8892
+ function sameArguments(node1, node2) {
8893
+ const args1 = node1.arguments;
8894
+ const args2 = node2.arguments;
8895
+ if (args1 === void 0 || args1.length === 0) {
8896
+ return args2 === void 0 || args2.length === 0;
8897
+ }
8898
+ if (args2 === void 0 || args2.length === 0) {
8899
+ return false;
8900
+ }
8901
+ if (args1.length !== args2.length) {
8902
+ return false;
8903
+ }
8904
+ const values2 = new Map(args2.map(({ name: name2, value }) => [name2.value, value]));
8905
+ return args1.every((arg1) => {
8906
+ const value1 = arg1.value;
8907
+ const value2 = values2.get(arg1.name.value);
8908
+ if (value2 === void 0) {
8909
+ return false;
8910
+ }
8911
+ return stringifyValue(value1) === stringifyValue(value2);
8912
+ });
8913
+ }
8914
+ function stringifyValue(value) {
8915
+ return print(sortValueNode(value));
8908
8916
  }
8909
8917
  function doTypesConflict(type1, type2) {
8910
8918
  if (isListType(type1)) {
@@ -9605,7 +9613,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
9605
9613
  onError(
9606
9614
  new GraphQLError(prefix + "; " + error2.message, {
9607
9615
  nodes: varDefNode,
9608
- originalError: error2.originalError
9616
+ originalError: error2
9609
9617
  })
9610
9618
  );
9611
9619
  }
@@ -11011,21 +11019,30 @@ function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields
11011
11019
  function executeFields(exeContext, parentType, sourceValue, path, fields) {
11012
11020
  const results = /* @__PURE__ */ Object.create(null);
11013
11021
  let containsPromise = false;
11014
- for (const [responseName, fieldNodes] of fields.entries()) {
11015
- const fieldPath = addPath(path, responseName, parentType.name);
11016
- const result = executeField(
11017
- exeContext,
11018
- parentType,
11019
- sourceValue,
11020
- fieldNodes,
11021
- fieldPath
11022
- );
11023
- if (result !== void 0) {
11024
- results[responseName] = result;
11025
- if (isPromise(result)) {
11026
- containsPromise = true;
11022
+ try {
11023
+ for (const [responseName, fieldNodes] of fields.entries()) {
11024
+ const fieldPath = addPath(path, responseName, parentType.name);
11025
+ const result = executeField(
11026
+ exeContext,
11027
+ parentType,
11028
+ sourceValue,
11029
+ fieldNodes,
11030
+ fieldPath
11031
+ );
11032
+ if (result !== void 0) {
11033
+ results[responseName] = result;
11034
+ if (isPromise(result)) {
11035
+ containsPromise = true;
11036
+ }
11027
11037
  }
11028
11038
  }
11039
+ } catch (error2) {
11040
+ if (containsPromise) {
11041
+ return promiseForObject(results).finally(() => {
11042
+ throw error2;
11043
+ });
11044
+ }
11045
+ throw error2;
11029
11046
  }
11030
11047
  if (!containsPromise) {
11031
11048
  return results;
@@ -14116,17 +14133,19 @@ function mergeResolvers(resolversDefinitions, options2) {
14116
14133
  return result;
14117
14134
  }
14118
14135
  function mergeArguments$1(args1, args2, config) {
14119
- const result = deduplicateArguments([...args2, ...args1].filter(isSome));
14136
+ const result = deduplicateArguments([...args2, ...args1].filter(isSome), config);
14120
14137
  if (config && config.sort) {
14121
14138
  result.sort(compareNodes);
14122
14139
  }
14123
14140
  return result;
14124
14141
  }
14125
- function deduplicateArguments(args) {
14142
+ function deduplicateArguments(args, config) {
14126
14143
  return args.reduce((acc, current) => {
14127
- const dup = acc.find((arg) => arg.name.value === current.name.value);
14128
- if (!dup) {
14144
+ const dupIndex = acc.findIndex((arg) => arg.name.value === current.name.value);
14145
+ if (dupIndex === -1) {
14129
14146
  return acc.concat([current]);
14147
+ } else if (!(config === null || config === void 0 ? void 0 : config.reverseArguments)) {
14148
+ acc[dupIndex] = current;
14130
14149
  }
14131
14150
  return acc;
14132
14151
  }, []);
@@ -14134,6 +14153,10 @@ function deduplicateArguments(args) {
14134
14153
  function directiveAlreadyExists(directivesArr, otherDirective) {
14135
14154
  return !!directivesArr.find((directive) => directive.name.value === otherDirective.name.value);
14136
14155
  }
14156
+ function isRepeatableDirective(directive, directives) {
14157
+ var _a;
14158
+ return !!((_a = directives === null || directives === void 0 ? void 0 : directives[directive.name.value]) === null || _a === void 0 ? void 0 : _a.repeatable);
14159
+ }
14137
14160
  function nameAlreadyExists(name2, namesArr) {
14138
14161
  return namesArr.some(({ value }) => value === name2.value);
14139
14162
  }
@@ -14159,10 +14182,10 @@ function mergeArguments(a1, a2) {
14159
14182
  }
14160
14183
  return result;
14161
14184
  }
14162
- function deduplicateDirectives(directives) {
14185
+ function deduplicateDirectives(directives, definitions2) {
14163
14186
  return directives.map((directive, i, all) => {
14164
14187
  const firstAt = all.findIndex((d) => d.name.value === directive.name.value);
14165
- if (firstAt !== i) {
14188
+ if (firstAt !== i && !isRepeatableDirective(directive, definitions2)) {
14166
14189
  const dup = all[firstAt];
14167
14190
  directive.arguments = mergeArguments(directive.arguments, dup.arguments);
14168
14191
  return null;
@@ -14170,13 +14193,13 @@ function deduplicateDirectives(directives) {
14170
14193
  return directive;
14171
14194
  }).filter(isSome);
14172
14195
  }
14173
- function mergeDirectives(d1 = [], d2 = [], config) {
14196
+ function mergeDirectives(d1 = [], d2 = [], config, directives) {
14174
14197
  const reverseOrder = config && config.reverseDirectives;
14175
14198
  const asNext = reverseOrder ? d1 : d2;
14176
14199
  const asFirst = reverseOrder ? d2 : d1;
14177
- const result = deduplicateDirectives([...asNext]);
14200
+ const result = deduplicateDirectives([...asNext], directives);
14178
14201
  for (const directive of asFirst) {
14179
- if (directiveAlreadyExists(result, directive)) {
14202
+ if (directiveAlreadyExists(result, directive) && !isRepeatableDirective(directive, directives)) {
14180
14203
  const existingDirectiveIndex = result.findIndex((d) => d.name.value === directive.name.value);
14181
14204
  const existingDirective = result[existingDirectiveIndex];
14182
14205
  result[existingDirectiveIndex].arguments = mergeArguments(directive.arguments || [], existingDirective.arguments || []);
@@ -14196,8 +14219,8 @@ function validateInputs(node, existingNode) {
14196
14219
  description: void 0
14197
14220
  });
14198
14221
  const leaveInputs = new RegExp("(directive @w*d*)|( on .*$)", "g");
14199
- const sameArguments = printedNode.replace(leaveInputs, "") === printedExistingNode.replace(leaveInputs, "");
14200
- if (!sameArguments) {
14222
+ const sameArguments2 = printedNode.replace(leaveInputs, "") === printedExistingNode.replace(leaveInputs, "");
14223
+ if (!sameArguments2) {
14201
14224
  throw new Error(`Unable to merge GraphQL directive "${node.name.value}".
14202
14225
  Existing directive:
14203
14226
  ${printedExistingNode}
@@ -14221,7 +14244,7 @@ function mergeDirective(node, existingNode) {
14221
14244
  function deduplicateLists(source, target, filterFn) {
14222
14245
  return source.concat(target.filter((val) => filterFn(val, source)));
14223
14246
  }
14224
- function mergeEnumValues(first, second, config) {
14247
+ function mergeEnumValues(first, second, config, directives) {
14225
14248
  if (config === null || config === void 0 ? void 0 : config.consistentEnumMerge) {
14226
14249
  const reversed = [];
14227
14250
  if (first) {
@@ -14242,7 +14265,7 @@ function mergeEnumValues(first, second, config) {
14242
14265
  if (enumValueMap.has(enumValue)) {
14243
14266
  const firstValue = enumValueMap.get(enumValue);
14244
14267
  firstValue.description = secondValue.description || firstValue.description;
14245
- firstValue.directives = mergeDirectives(secondValue.directives, firstValue.directives);
14268
+ firstValue.directives = mergeDirectives(secondValue.directives, firstValue.directives, directives);
14246
14269
  } else {
14247
14270
  enumValueMap.set(enumValue, secondValue);
14248
14271
  }
@@ -14254,14 +14277,14 @@ function mergeEnumValues(first, second, config) {
14254
14277
  }
14255
14278
  return result;
14256
14279
  }
14257
- function mergeEnum(e1, e2, config) {
14280
+ function mergeEnum(e1, e2, config, directives) {
14258
14281
  if (e2) {
14259
14282
  return {
14260
14283
  name: e1.name,
14261
14284
  description: e1["description"] || e2["description"],
14262
14285
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || e1.kind === "EnumTypeDefinition" || e2.kind === "EnumTypeDefinition" ? "EnumTypeDefinition" : "EnumTypeExtension",
14263
14286
  loc: e1.loc,
14264
- directives: mergeDirectives(e1.directives, e2.directives, config),
14287
+ directives: mergeDirectives(e1.directives, e2.directives, config, directives),
14265
14288
  values: mergeEnumValues(e1.values, e2.values, config)
14266
14289
  };
14267
14290
  }
@@ -14323,39 +14346,24 @@ function defaultStringComparator(a, b) {
14323
14346
  return CompareVal.A_GREATER_THAN_B;
14324
14347
  return CompareVal.A_EQUALS_B;
14325
14348
  }
14326
- function fieldAlreadyExists(fieldsArr, otherField, config) {
14327
- const result = fieldsArr.find((field) => field.name.value === otherField.name.value);
14328
- if (result && !(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14329
- const t1 = extractType(result.type);
14330
- const t2 = extractType(otherField.type);
14331
- if (t1.name.value !== t2.name.value) {
14332
- throw new Error(`Field "${otherField.name.value}" already defined with a different type. Declared as "${t1.name.value}", but you tried to override with "${t2.name.value}"`);
14333
- }
14334
- }
14335
- return !!result;
14349
+ function fieldAlreadyExists(fieldsArr, otherField) {
14350
+ const resultIndex = fieldsArr.findIndex((field) => field.name.value === otherField.name.value);
14351
+ return [resultIndex > -1 ? fieldsArr[resultIndex] : null, resultIndex];
14336
14352
  }
14337
- function mergeFields(type2, f1, f2, config) {
14353
+ function mergeFields(type2, f1, f2, config, directives) {
14338
14354
  const result = [];
14339
14355
  if (f2 != null) {
14340
14356
  result.push(...f2);
14341
14357
  }
14342
14358
  if (f1 != null) {
14343
14359
  for (const field of f1) {
14344
- if (fieldAlreadyExists(result, field, config)) {
14345
- const existing = result.find((f) => f.name.value === field.name.value);
14346
- if (!(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14347
- if (config === null || config === void 0 ? void 0 : config.throwOnConflict) {
14348
- preventConflicts(type2, existing, field, false);
14349
- } else {
14350
- preventConflicts(type2, existing, field, true);
14351
- }
14352
- if (isNonNullTypeNode(field.type) && !isNonNullTypeNode(existing.type)) {
14353
- existing.type = field.type;
14354
- }
14355
- }
14356
- existing.arguments = mergeArguments$1(field["arguments"] || [], existing.arguments || [], config);
14357
- existing.directives = mergeDirectives(field.directives, existing.directives, config);
14358
- existing.description = field.description || existing.description;
14360
+ const [existing, existingIndex] = fieldAlreadyExists(result, field);
14361
+ if (existing && !(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) {
14362
+ const newField = (config === null || config === void 0 ? void 0 : config.onFieldTypeConflict) && config.onFieldTypeConflict(existing, field, type2, config === null || config === void 0 ? void 0 : config.throwOnConflict) || preventConflicts(type2, existing, field, config === null || config === void 0 ? void 0 : config.throwOnConflict);
14363
+ newField.arguments = mergeArguments$1(field["arguments"] || [], existing["arguments"] || [], config);
14364
+ newField.directives = mergeDirectives(field.directives, existing.directives, config, directives);
14365
+ newField.description = field.description || existing.description;
14366
+ result[existingIndex] = newField;
14359
14367
  } else {
14360
14368
  result.push(field);
14361
14369
  }
@@ -14373,9 +14381,20 @@ function mergeFields(type2, f1, f2, config) {
14373
14381
  function preventConflicts(type2, a, b, ignoreNullability = false) {
14374
14382
  const aType = printTypeNode(a.type);
14375
14383
  const bType = printTypeNode(b.type);
14376
- if (aType !== bType && !safeChangeForFieldType(a.type, b.type, ignoreNullability)) {
14377
- throw new Error(`Field '${type2.name.value}.${a.name.value}' changed type from '${aType}' to '${bType}'`);
14384
+ if (aType !== bType) {
14385
+ const t1 = extractType(a.type);
14386
+ const t2 = extractType(b.type);
14387
+ if (t1.name.value !== t2.name.value) {
14388
+ throw new Error(`Field "${b.name.value}" already defined with a different type. Declared as "${t1.name.value}", but you tried to override with "${t2.name.value}"`);
14389
+ }
14390
+ if (!safeChangeForFieldType(a.type, b.type, !ignoreNullability)) {
14391
+ throw new Error(`Field '${type2.name.value}.${a.name.value}' changed type from '${aType}' to '${bType}'`);
14392
+ }
14393
+ }
14394
+ if (isNonNullTypeNode(b.type) && !isNonNullTypeNode(a.type)) {
14395
+ a.type = b.type;
14378
14396
  }
14397
+ return a;
14379
14398
  }
14380
14399
  function safeChangeForFieldType(oldType, newType, ignoreNullability = false) {
14381
14400
  if (!isWrappingTypeNode(oldType) && !isWrappingTypeNode(newType)) {
@@ -14393,7 +14412,7 @@ function safeChangeForFieldType(oldType, newType, ignoreNullability = false) {
14393
14412
  }
14394
14413
  return false;
14395
14414
  }
14396
- function mergeInputType(node, existingNode, config) {
14415
+ function mergeInputType(node, existingNode, config, directives) {
14397
14416
  if (existingNode) {
14398
14417
  try {
14399
14418
  return {
@@ -14402,7 +14421,7 @@ function mergeInputType(node, existingNode, config) {
14402
14421
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "InputObjectTypeDefinition" || existingNode.kind === "InputObjectTypeDefinition" ? "InputObjectTypeDefinition" : "InputObjectTypeExtension",
14403
14422
  loc: node.loc,
14404
14423
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14405
- directives: mergeDirectives(node.directives, existingNode.directives, config)
14424
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives)
14406
14425
  };
14407
14426
  } catch (e) {
14408
14427
  throw new Error(`Unable to merge GraphQL input type "${node.name.value}": ${e.message}`);
@@ -14423,7 +14442,7 @@ function mergeNamedTypeArray(first = [], second = [], config = {}) {
14423
14442
  }
14424
14443
  return result;
14425
14444
  }
14426
- function mergeInterface(node, existingNode, config) {
14445
+ function mergeInterface(node, existingNode, config, directives) {
14427
14446
  if (existingNode) {
14428
14447
  try {
14429
14448
  return {
@@ -14432,7 +14451,7 @@ function mergeInterface(node, existingNode, config) {
14432
14451
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "InterfaceTypeDefinition" || existingNode.kind === "InterfaceTypeDefinition" ? "InterfaceTypeDefinition" : "InterfaceTypeExtension",
14433
14452
  loc: node.loc,
14434
14453
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14435
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14454
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14436
14455
  interfaces: node["interfaces"] ? mergeNamedTypeArray(node["interfaces"], existingNode["interfaces"], config) : void 0
14437
14456
  };
14438
14457
  } catch (e) {
@@ -14444,7 +14463,7 @@ function mergeInterface(node, existingNode, config) {
14444
14463
  kind: Kind.INTERFACE_TYPE_DEFINITION
14445
14464
  } : node;
14446
14465
  }
14447
- function mergeType(node, existingNode, config) {
14466
+ function mergeType(node, existingNode, config, directives) {
14448
14467
  if (existingNode) {
14449
14468
  try {
14450
14469
  return {
@@ -14453,7 +14472,7 @@ function mergeType(node, existingNode, config) {
14453
14472
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "ObjectTypeDefinition" || existingNode.kind === "ObjectTypeDefinition" ? "ObjectTypeDefinition" : "ObjectTypeExtension",
14454
14473
  loc: node.loc,
14455
14474
  fields: mergeFields(node, node.fields, existingNode.fields, config),
14456
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14475
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14457
14476
  interfaces: mergeNamedTypeArray(node.interfaces, existingNode.interfaces, config)
14458
14477
  };
14459
14478
  } catch (e) {
@@ -14465,14 +14484,14 @@ function mergeType(node, existingNode, config) {
14465
14484
  kind: Kind.OBJECT_TYPE_DEFINITION
14466
14485
  } : node;
14467
14486
  }
14468
- function mergeScalar(node, existingNode, config) {
14487
+ function mergeScalar(node, existingNode, config, directives) {
14469
14488
  if (existingNode) {
14470
14489
  return {
14471
14490
  name: node.name,
14472
14491
  description: node["description"] || existingNode["description"],
14473
14492
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || node.kind === "ScalarTypeDefinition" || existingNode.kind === "ScalarTypeDefinition" ? "ScalarTypeDefinition" : "ScalarTypeExtension",
14474
14493
  loc: node.loc,
14475
- directives: mergeDirectives(node.directives, existingNode.directives, config)
14494
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives)
14476
14495
  };
14477
14496
  }
14478
14497
  return (config === null || config === void 0 ? void 0 : config.convertExtensions) ? {
@@ -14480,13 +14499,13 @@ function mergeScalar(node, existingNode, config) {
14480
14499
  kind: Kind.SCALAR_TYPE_DEFINITION
14481
14500
  } : node;
14482
14501
  }
14483
- function mergeUnion(first, second, config) {
14502
+ function mergeUnion(first, second, config, directives) {
14484
14503
  if (second) {
14485
14504
  return {
14486
14505
  name: first.name,
14487
14506
  description: first["description"] || second["description"],
14488
14507
  // ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
14489
- directives: mergeDirectives(first.directives, second.directives, config),
14508
+ directives: mergeDirectives(first.directives, second.directives, config, directives),
14490
14509
  kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || first.kind === "UnionTypeDefinition" || second.kind === "UnionTypeDefinition" ? Kind.UNION_TYPE_DEFINITION : Kind.UNION_TYPE_EXTENSION,
14491
14510
  loc: first.loc,
14492
14511
  types: mergeNamedTypeArray(first.types, second.types, config)
@@ -14512,12 +14531,12 @@ function mergeOperationTypes(opNodeList = [], existingOpNodeList = []) {
14512
14531
  }
14513
14532
  return finalOpNodeList;
14514
14533
  }
14515
- function mergeSchemaDefs(node, existingNode, config) {
14534
+ function mergeSchemaDefs(node, existingNode, config, directives) {
14516
14535
  if (existingNode) {
14517
14536
  return {
14518
14537
  kind: node.kind === Kind.SCHEMA_DEFINITION || existingNode.kind === Kind.SCHEMA_DEFINITION ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
14519
14538
  description: node["description"] || existingNode["description"],
14520
- directives: mergeDirectives(node.directives, existingNode.directives, config),
14539
+ directives: mergeDirectives(node.directives, existingNode.directives, config, directives),
14521
14540
  operationTypes: mergeOperationTypes(node.operationTypes, existingNode.operationTypes)
14522
14541
  };
14523
14542
  }
@@ -14530,9 +14549,9 @@ const schemaDefSymbol = "SCHEMA_DEF_SYMBOL";
14530
14549
  function isNamedDefinitionNode(definitionNode) {
14531
14550
  return "name" in definitionNode;
14532
14551
  }
14533
- function mergeGraphQLNodes(nodes, config) {
14552
+ function mergeGraphQLNodes(nodes, config, directives = {}) {
14534
14553
  var _a, _b, _c;
14535
- const mergedResultMap = {};
14554
+ const mergedResultMap = directives;
14536
14555
  for (const nodeDefinition of nodes) {
14537
14556
  if (isNamedDefinitionNode(nodeDefinition)) {
14538
14557
  const name2 = (_a = nodeDefinition.name) === null || _a === void 0 ? void 0 : _a.value;
@@ -14548,27 +14567,27 @@ function mergeGraphQLNodes(nodes, config) {
14548
14567
  switch (nodeDefinition.kind) {
14549
14568
  case Kind.OBJECT_TYPE_DEFINITION:
14550
14569
  case Kind.OBJECT_TYPE_EXTENSION:
14551
- mergedResultMap[name2] = mergeType(nodeDefinition, mergedResultMap[name2], config);
14570
+ mergedResultMap[name2] = mergeType(nodeDefinition, mergedResultMap[name2], config, directives);
14552
14571
  break;
14553
14572
  case Kind.ENUM_TYPE_DEFINITION:
14554
14573
  case Kind.ENUM_TYPE_EXTENSION:
14555
- mergedResultMap[name2] = mergeEnum(nodeDefinition, mergedResultMap[name2], config);
14574
+ mergedResultMap[name2] = mergeEnum(nodeDefinition, mergedResultMap[name2], config, directives);
14556
14575
  break;
14557
14576
  case Kind.UNION_TYPE_DEFINITION:
14558
14577
  case Kind.UNION_TYPE_EXTENSION:
14559
- mergedResultMap[name2] = mergeUnion(nodeDefinition, mergedResultMap[name2], config);
14578
+ mergedResultMap[name2] = mergeUnion(nodeDefinition, mergedResultMap[name2], config, directives);
14560
14579
  break;
14561
14580
  case Kind.SCALAR_TYPE_DEFINITION:
14562
14581
  case Kind.SCALAR_TYPE_EXTENSION:
14563
- mergedResultMap[name2] = mergeScalar(nodeDefinition, mergedResultMap[name2], config);
14582
+ mergedResultMap[name2] = mergeScalar(nodeDefinition, mergedResultMap[name2], config, directives);
14564
14583
  break;
14565
14584
  case Kind.INPUT_OBJECT_TYPE_DEFINITION:
14566
14585
  case Kind.INPUT_OBJECT_TYPE_EXTENSION:
14567
- mergedResultMap[name2] = mergeInputType(nodeDefinition, mergedResultMap[name2], config);
14586
+ mergedResultMap[name2] = mergeInputType(nodeDefinition, mergedResultMap[name2], config, directives);
14568
14587
  break;
14569
14588
  case Kind.INTERFACE_TYPE_DEFINITION:
14570
14589
  case Kind.INTERFACE_TYPE_EXTENSION:
14571
- mergedResultMap[name2] = mergeInterface(nodeDefinition, mergedResultMap[name2], config);
14590
+ mergedResultMap[name2] = mergeInterface(nodeDefinition, mergedResultMap[name2], config, directives);
14572
14591
  break;
14573
14592
  case Kind.DIRECTIVE_DEFINITION:
14574
14593
  mergedResultMap[name2] = mergeDirective(nodeDefinition, mergedResultMap[name2]);
@@ -14602,36 +14621,41 @@ function mergeTypeDefs(typeSource, config) {
14602
14621
  resetComments();
14603
14622
  return result;
14604
14623
  }
14605
- function visitTypeSources(typeSource, options2, allNodes = [], visitedTypeSources = /* @__PURE__ */ new Set()) {
14624
+ function visitTypeSources(typeSource, options2, allDirectives = [], allNodes = [], visitedTypeSources = /* @__PURE__ */ new Set()) {
14606
14625
  if (typeSource && !visitedTypeSources.has(typeSource)) {
14607
14626
  visitedTypeSources.add(typeSource);
14608
14627
  if (typeof typeSource === "function") {
14609
- visitTypeSources(typeSource(), options2, allNodes, visitedTypeSources);
14628
+ visitTypeSources(typeSource(), options2, allDirectives, allNodes, visitedTypeSources);
14610
14629
  } else if (Array.isArray(typeSource)) {
14611
14630
  for (const type2 of typeSource) {
14612
- visitTypeSources(type2, options2, allNodes, visitedTypeSources);
14631
+ visitTypeSources(type2, options2, allDirectives, allNodes, visitedTypeSources);
14613
14632
  }
14614
14633
  } else if (isSchema(typeSource)) {
14615
14634
  const documentNode = getDocumentNodeFromSchema(typeSource, options2);
14616
- visitTypeSources(documentNode.definitions, options2, allNodes, visitedTypeSources);
14635
+ visitTypeSources(documentNode.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14617
14636
  } else if (isStringTypes(typeSource) || isSourceTypes(typeSource)) {
14618
14637
  const documentNode = parse(typeSource, options2);
14619
- visitTypeSources(documentNode.definitions, options2, allNodes, visitedTypeSources);
14638
+ visitTypeSources(documentNode.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14620
14639
  } else if (typeof typeSource === "object" && isDefinitionNode(typeSource)) {
14621
- allNodes.push(typeSource);
14640
+ if (typeSource.kind === Kind.DIRECTIVE_DEFINITION) {
14641
+ allDirectives.push(typeSource);
14642
+ } else {
14643
+ allNodes.push(typeSource);
14644
+ }
14622
14645
  } else if (isDocumentNode(typeSource)) {
14623
- visitTypeSources(typeSource.definitions, options2, allNodes, visitedTypeSources);
14646
+ visitTypeSources(typeSource.definitions, options2, allDirectives, allNodes, visitedTypeSources);
14624
14647
  } else {
14625
14648
  throw new Error(`typeDefs must contain only strings, documents, schemas, or functions, got ${typeof typeSource}`);
14626
14649
  }
14627
14650
  }
14628
- return allNodes;
14651
+ return { allDirectives, allNodes };
14629
14652
  }
14630
14653
  function mergeGraphQLTypes(typeSource, config) {
14631
14654
  var _a, _b, _c;
14632
14655
  resetComments();
14633
- const allNodes = visitTypeSources(typeSource, config);
14634
- const mergedNodes = mergeGraphQLNodes(allNodes, config);
14656
+ const { allDirectives, allNodes } = visitTypeSources(typeSource, config);
14657
+ const mergedDirectives = mergeGraphQLNodes(allDirectives, config);
14658
+ const mergedNodes = mergeGraphQLNodes(allNodes, config, mergedDirectives);
14635
14659
  if (config === null || config === void 0 ? void 0 : config.useSchemaDefinition) {
14636
14660
  const schemaDef = mergedNodes[schemaDefSymbol] || {
14637
14661
  kind: Kind.SCHEMA_DEFINITION,
@@ -14934,17 +14958,8 @@ class Mutex {
14934
14958
  return this._semaphore.cancel();
14935
14959
  }
14936
14960
  }
14937
- var easyCrc32Exports = {};
14938
- var easyCrc32$1 = {
14939
- get exports() {
14940
- return easyCrc32Exports;
14941
- },
14942
- set exports(v) {
14943
- easyCrc32Exports = v;
14944
- }
14945
- };
14946
- var easyCrc32 = {};
14947
- easyCrc32.calculate = function(str) {
14961
+ var easyCrc32$1 = {};
14962
+ easyCrc32$1.calculate = function(str) {
14948
14963
  if (str == null)
14949
14964
  return null;
14950
14965
  var utf8CharCodes = utf8encode(str), crc = -1;
@@ -15227,19 +15242,9 @@ var crcTable = [
15227
15242
  1510334235,
15228
15243
  755167117
15229
15244
  ];
15230
- (function(module2) {
15231
- module2.exports = easyCrc32;
15232
- })(easyCrc32$1);
15233
- const crc32 = /* @__PURE__ */ getDefaultExportFromCjs(easyCrc32Exports);
15234
- var bitsetExports = {};
15235
- var bitset = {
15236
- get exports() {
15237
- return bitsetExports;
15238
- },
15239
- set exports(v) {
15240
- bitsetExports = v;
15241
- }
15242
- };
15245
+ var easyCrc32 = easyCrc32$1;
15246
+ const crc32 = /* @__PURE__ */ getDefaultExportFromCjs(easyCrc32);
15247
+ var bitset = { exports: {} };
15243
15248
  /**
15244
15249
  * @license BitSet.js v5.1.1 2/1/2020
15245
15250
  * http://www.xarg.org/2014/03/javascript-bit-array/
@@ -15983,10 +15988,11 @@ var bitset = {
15983
15988
  module2["exports"] = BitSet2;
15984
15989
  }
15985
15990
  })();
15986
- })(bitset, bitsetExports);
15991
+ })(bitset, bitset.exports);
15992
+ var bitsetExports = bitset.exports;
15987
15993
  const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
15988
15994
  const name = "proskomma-core";
15989
- const version = "0.10.10";
15995
+ const version = "0.10.12";
15990
15996
  const description$b = "A Scripture Runtime Engine";
15991
15997
  const files = [
15992
15998
  "dist"
@@ -16580,18 +16586,10 @@ const enumRegexIndexTuples = (enumSuccinct, regex) => {
16580
16586
  return ret;
16581
16587
  };
16582
16588
  const enums = { enumStringIndex, enumRegexIndexTuples };
16583
- var uuidExports = {};
16584
- var uuid = {
16585
- get exports() {
16586
- return uuidExports;
16587
- },
16588
- set exports(v) {
16589
- uuidExports = v;
16590
- }
16591
- };
16589
+ var uuid = { exports: {} };
16592
16590
  /*!
16593
16591
  ** Pure-UUID -- Pure JavaScript Based Universally Unique Identifier (UUID)
16594
- ** Copyright (c) 2004-2021 Dr. Ralf S. Engelschall <rse@engelschall.com>
16592
+ ** Copyright (c) 2004-2023 Dr. Ralf S. Engelschall <rse@engelschall.com>
16595
16593
  **
16596
16594
  ** Permission is hereby granted, free of charge, to any person obtaining
16597
16595
  ** a copy of this software and associated documentation files (the
@@ -17159,7 +17157,21 @@ var uuid = {
17159
17157
  this.state = ui64_clone(this.inc);
17160
17158
  this.next();
17161
17159
  ui64_and(this.state, this.mask);
17162
- seed = ui64_n2i(seed !== void 0 ? seed >>> 0 : Math.random() * 4294967295 >>> 0);
17160
+ var arr;
17161
+ if (seed !== void 0)
17162
+ seed = ui64_n2i(seed >>> 0);
17163
+ else if (typeof window === "object" && typeof window.crypto === "object" && typeof window.crypto.getRandomValues === "function") {
17164
+ arr = new Uint32Array(2);
17165
+ window.crypto.getRandomValues(arr);
17166
+ seed = ui64_or(ui64_n2i(arr[0] >>> 0), ui64_ror(ui64_n2i(arr[1] >>> 0), 32));
17167
+ } else if (typeof globalThis === "object" && typeof globalThis.crypto === "object" && typeof globalThis.crypto.getRandomValues === "function") {
17168
+ arr = new Uint32Array(2);
17169
+ globalThis.crypto.getRandomValues(arr);
17170
+ seed = ui64_or(ui64_n2i(arr[0] >>> 0), ui64_ror(ui64_n2i(arr[1] >>> 0), 32));
17171
+ } else {
17172
+ seed = ui64_n2i(Math.random() * 4294967295 >>> 0);
17173
+ ui64_or(seed, ui64_ror(ui64_n2i((/* @__PURE__ */ new Date()).getTime()), 32));
17174
+ }
17163
17175
  ui64_or(this.state, seed);
17164
17176
  this.next();
17165
17177
  };
@@ -17181,7 +17193,17 @@ var uuid = {
17181
17193
  ui64_xor(output, output2);
17182
17194
  return ui64_i2n(output);
17183
17195
  };
17196
+ PCG.prototype.reseed = function(seed) {
17197
+ if (typeof seed !== "string")
17198
+ throw new Error("UUID: PCG: seed: invalid argument (string expected)");
17199
+ var arr = sha1_core(s2a(seed, { ibits: 8, obits: 32, obigendian: true }), seed.length * 8);
17200
+ for (var i = 0; i < arr.length; i++)
17201
+ ui64_xor(pcg.state, ui64_n2i(arr[i] >>> 0));
17202
+ };
17184
17203
  var pcg = new PCG();
17204
+ PCG.reseed = function(seed) {
17205
+ pcg.reseed(seed);
17206
+ };
17185
17207
  var prng = function(len, radix) {
17186
17208
  var bytes = [];
17187
17209
  for (var i = 0; i < len; i++)
@@ -17212,7 +17234,7 @@ var uuid = {
17212
17234
  var i;
17213
17235
  var uuid2 = this;
17214
17236
  if (version2 === 1) {
17215
- var date = new Date();
17237
+ var date = /* @__PURE__ */ new Date();
17216
17238
  var time_now = date.getTime();
17217
17239
  if (time_now !== time_last)
17218
17240
  time_seq = 0;
@@ -17383,17 +17405,11 @@ var uuid = {
17383
17405
  return UUID2;
17384
17406
  });
17385
17407
  })(uuid);
17386
- const UUID = uuidExports;
17387
- var base64Exports = {};
17388
- var base64$1 = {
17389
- get exports() {
17390
- return base64Exports;
17391
- },
17392
- set exports(v) {
17393
- base64Exports = v;
17394
- }
17395
- };
17408
+ var uuidExports = uuid.exports;
17409
+ const UUID = /* @__PURE__ */ getDefaultExportFromCjs(uuidExports);
17410
+ var base64$1 = { exports: {} };
17396
17411
  /*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */
17412
+ base64$1.exports;
17397
17413
  (function(module2, exports2) {
17398
17414
  (function(root) {
17399
17415
  var freeExports = exports2;
@@ -17491,8 +17507,9 @@ var base64$1 = {
17491
17507
  root.base64 = base642;
17492
17508
  }
17493
17509
  })(commonjsGlobal);
17494
- })(base64$1, base64Exports);
17495
- const base64 = base64Exports;
17510
+ })(base64$1, base64$1.exports);
17511
+ var base64Exports = base64$1.exports;
17512
+ const base64 = /* @__PURE__ */ getDefaultExportFromCjs(base64Exports);
17496
17513
  const generateId = () => base64.encode(new UUID(4)).substring(0, 12);
17497
17514
  const graftLocation = {
17498
17515
  heading: "block",
@@ -19723,15 +19740,7 @@ class DocSet {
19723
19740
  return crc32.calculate(docIdsString);
19724
19741
  }
19725
19742
  }
19726
- var ajvExports = {};
19727
- var ajv = {
19728
- get exports() {
19729
- return ajvExports;
19730
- },
19731
- set exports(v) {
19732
- ajvExports = v;
19733
- }
19734
- };
19743
+ var ajv = { exports: {} };
19735
19744
  var core$2 = {};
19736
19745
  var validate = {};
19737
19746
  var boolSchema = {};
@@ -19902,7 +19911,7 @@ var scope = {};
19902
19911
  (function(UsedValueState2) {
19903
19912
  UsedValueState2[UsedValueState2["Started"] = 0] = "Started";
19904
19913
  UsedValueState2[UsedValueState2["Completed"] = 1] = "Completed";
19905
- })(UsedValueState = exports2.UsedValueState || (exports2.UsedValueState = {}));
19914
+ })(UsedValueState || (exports2.UsedValueState = UsedValueState = {}));
19906
19915
  exports2.varKinds = {
19907
19916
  const: new code_12.Name("const"),
19908
19917
  let: new code_12.Name("let"),
@@ -20744,193 +20753,197 @@ var scope = {};
20744
20753
  }
20745
20754
  })(codegen);
20746
20755
  var util = {};
20747
- (function(exports2) {
20748
- Object.defineProperty(exports2, "__esModule", { value: true });
20749
- exports2.checkStrictMode = exports2.getErrorPath = exports2.Type = exports2.useFunc = exports2.setEvaluated = exports2.evaluatedPropsToName = exports2.mergeEvaluated = exports2.eachItem = exports2.unescapeJsonPointer = exports2.escapeJsonPointer = exports2.escapeFragment = exports2.unescapeFragment = exports2.schemaRefOrVal = exports2.schemaHasRulesButRef = exports2.schemaHasRules = exports2.checkUnknownRules = exports2.alwaysValidSchema = exports2.toHash = void 0;
20750
- const codegen_12 = codegen;
20751
- const code_12 = code$1;
20752
- function toHash(arr) {
20753
- const hash = {};
20754
- for (const item of arr)
20755
- hash[item] = true;
20756
- return hash;
20757
- }
20758
- exports2.toHash = toHash;
20759
- function alwaysValidSchema(it, schema) {
20760
- if (typeof schema == "boolean")
20761
- return schema;
20762
- if (Object.keys(schema).length === 0)
20763
- return true;
20764
- checkUnknownRules(it, schema);
20765
- return !schemaHasRules(schema, it.self.RULES.all);
20766
- }
20767
- exports2.alwaysValidSchema = alwaysValidSchema;
20768
- function checkUnknownRules(it, schema = it.schema) {
20769
- const { opts, self: self2 } = it;
20770
- if (!opts.strictSchema)
20771
- return;
20772
- if (typeof schema === "boolean")
20773
- return;
20774
- const rules2 = self2.RULES.keywords;
20775
- for (const key in schema) {
20776
- if (!rules2[key])
20777
- checkStrictMode(it, `unknown keyword: "${key}"`);
20778
- }
20779
- }
20780
- exports2.checkUnknownRules = checkUnknownRules;
20781
- function schemaHasRules(schema, rules2) {
20782
- if (typeof schema == "boolean")
20783
- return !schema;
20784
- for (const key in schema)
20785
- if (rules2[key])
20786
- return true;
20787
- return false;
20788
- }
20789
- exports2.schemaHasRules = schemaHasRules;
20790
- function schemaHasRulesButRef(schema, RULES) {
20791
- if (typeof schema == "boolean")
20792
- return !schema;
20793
- for (const key in schema)
20794
- if (key !== "$ref" && RULES.all[key])
20795
- return true;
20796
- return false;
20756
+ Object.defineProperty(util, "__esModule", { value: true });
20757
+ util.checkStrictMode = util.getErrorPath = util.Type = util.useFunc = util.setEvaluated = util.evaluatedPropsToName = util.mergeEvaluated = util.eachItem = util.unescapeJsonPointer = util.escapeJsonPointer = util.escapeFragment = util.unescapeFragment = util.schemaRefOrVal = util.schemaHasRulesButRef = util.schemaHasRules = util.checkUnknownRules = util.alwaysValidSchema = util.toHash = void 0;
20758
+ const codegen_1$v = codegen;
20759
+ const code_1$a = code$1;
20760
+ function toHash(arr) {
20761
+ const hash = {};
20762
+ for (const item of arr)
20763
+ hash[item] = true;
20764
+ return hash;
20765
+ }
20766
+ util.toHash = toHash;
20767
+ function alwaysValidSchema(it, schema) {
20768
+ if (typeof schema == "boolean")
20769
+ return schema;
20770
+ if (Object.keys(schema).length === 0)
20771
+ return true;
20772
+ checkUnknownRules(it, schema);
20773
+ return !schemaHasRules(schema, it.self.RULES.all);
20774
+ }
20775
+ util.alwaysValidSchema = alwaysValidSchema;
20776
+ function checkUnknownRules(it, schema = it.schema) {
20777
+ const { opts, self: self2 } = it;
20778
+ if (!opts.strictSchema)
20779
+ return;
20780
+ if (typeof schema === "boolean")
20781
+ return;
20782
+ const rules2 = self2.RULES.keywords;
20783
+ for (const key in schema) {
20784
+ if (!rules2[key])
20785
+ checkStrictMode(it, `unknown keyword: "${key}"`);
20797
20786
  }
20798
- exports2.schemaHasRulesButRef = schemaHasRulesButRef;
20799
- function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
20800
- if (!$data) {
20801
- if (typeof schema == "number" || typeof schema == "boolean")
20802
- return schema;
20803
- if (typeof schema == "string")
20804
- return (0, codegen_12._)`${schema}`;
20805
- }
20806
- return (0, codegen_12._)`${topSchemaRef}${schemaPath}${(0, codegen_12.getProperty)(keyword2)}`;
20807
- }
20808
- exports2.schemaRefOrVal = schemaRefOrVal;
20809
- function unescapeFragment(str) {
20810
- return unescapeJsonPointer(decodeURIComponent(str));
20811
- }
20812
- exports2.unescapeFragment = unescapeFragment;
20813
- function escapeFragment(str) {
20814
- return encodeURIComponent(escapeJsonPointer(str));
20815
- }
20816
- exports2.escapeFragment = escapeFragment;
20817
- function escapeJsonPointer(str) {
20818
- if (typeof str == "number")
20819
- return `${str}`;
20820
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
20821
- }
20822
- exports2.escapeJsonPointer = escapeJsonPointer;
20823
- function unescapeJsonPointer(str) {
20824
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
20825
- }
20826
- exports2.unescapeJsonPointer = unescapeJsonPointer;
20827
- function eachItem(xs, f) {
20828
- if (Array.isArray(xs)) {
20829
- for (const x of xs)
20830
- f(x);
20831
- } else {
20832
- f(xs);
20833
- }
20787
+ }
20788
+ util.checkUnknownRules = checkUnknownRules;
20789
+ function schemaHasRules(schema, rules2) {
20790
+ if (typeof schema == "boolean")
20791
+ return !schema;
20792
+ for (const key in schema)
20793
+ if (rules2[key])
20794
+ return true;
20795
+ return false;
20796
+ }
20797
+ util.schemaHasRules = schemaHasRules;
20798
+ function schemaHasRulesButRef(schema, RULES) {
20799
+ if (typeof schema == "boolean")
20800
+ return !schema;
20801
+ for (const key in schema)
20802
+ if (key !== "$ref" && RULES.all[key])
20803
+ return true;
20804
+ return false;
20805
+ }
20806
+ util.schemaHasRulesButRef = schemaHasRulesButRef;
20807
+ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
20808
+ if (!$data) {
20809
+ if (typeof schema == "number" || typeof schema == "boolean")
20810
+ return schema;
20811
+ if (typeof schema == "string")
20812
+ return (0, codegen_1$v._)`${schema}`;
20834
20813
  }
20835
- exports2.eachItem = eachItem;
20836
- function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
20837
- return (gen, from, to, toName) => {
20838
- const res = to === void 0 ? from : to instanceof codegen_12.Name ? (from instanceof codegen_12.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_12.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
20839
- return toName === codegen_12.Name && !(res instanceof codegen_12.Name) ? resultToName(gen, res) : res;
20840
- };
20814
+ return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
20815
+ }
20816
+ util.schemaRefOrVal = schemaRefOrVal;
20817
+ function unescapeFragment(str) {
20818
+ return unescapeJsonPointer(decodeURIComponent(str));
20819
+ }
20820
+ util.unescapeFragment = unescapeFragment;
20821
+ function escapeFragment(str) {
20822
+ return encodeURIComponent(escapeJsonPointer(str));
20823
+ }
20824
+ util.escapeFragment = escapeFragment;
20825
+ function escapeJsonPointer(str) {
20826
+ if (typeof str == "number")
20827
+ return `${str}`;
20828
+ return str.replace(/~/g, "~0").replace(/\//g, "~1");
20829
+ }
20830
+ util.escapeJsonPointer = escapeJsonPointer;
20831
+ function unescapeJsonPointer(str) {
20832
+ return str.replace(/~1/g, "/").replace(/~0/g, "~");
20833
+ }
20834
+ util.unescapeJsonPointer = unescapeJsonPointer;
20835
+ function eachItem(xs, f) {
20836
+ if (Array.isArray(xs)) {
20837
+ for (const x of xs)
20838
+ f(x);
20839
+ } else {
20840
+ f(xs);
20841
20841
  }
20842
- exports2.mergeEvaluated = {
20843
- props: makeMergeEvaluated({
20844
- mergeNames: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true && ${from} !== undefined`, () => {
20845
- gen.if((0, codegen_12._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_12._)`${to} || {}`).code((0, codegen_12._)`Object.assign(${to}, ${from})`));
20846
- }),
20847
- mergeToName: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true`, () => {
20848
- if (from === true) {
20849
- gen.assign(to, true);
20850
- } else {
20851
- gen.assign(to, (0, codegen_12._)`${to} || {}`);
20852
- setEvaluated(gen, to, from);
20853
- }
20854
- }),
20855
- mergeValues: (from, to) => from === true ? true : { ...from, ...to },
20856
- resultToName: evaluatedPropsToName
20857
- }),
20858
- items: makeMergeEvaluated({
20859
- mergeNames: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_12._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
20860
- mergeToName: (gen, from, to) => gen.if((0, codegen_12._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_12._)`${to} > ${from} ? ${to} : ${from}`)),
20861
- mergeValues: (from, to) => from === true ? true : Math.max(from, to),
20862
- resultToName: (gen, items2) => gen.var("items", items2)
20863
- })
20842
+ }
20843
+ util.eachItem = eachItem;
20844
+ function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
20845
+ return (gen, from, to, toName) => {
20846
+ const res = to === void 0 ? from : to instanceof codegen_1$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
20847
+ return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
20864
20848
  };
20865
- function evaluatedPropsToName(gen, ps) {
20866
- if (ps === true)
20867
- return gen.var("props", true);
20868
- const props = gen.var("props", (0, codegen_12._)`{}`);
20869
- if (ps !== void 0)
20870
- setEvaluated(gen, props, ps);
20871
- return props;
20872
- }
20873
- exports2.evaluatedPropsToName = evaluatedPropsToName;
20874
- function setEvaluated(gen, props, ps) {
20875
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_12._)`${props}${(0, codegen_12.getProperty)(p)}`, true));
20876
- }
20877
- exports2.setEvaluated = setEvaluated;
20878
- const snippets = {};
20879
- function useFunc(gen, f) {
20880
- return gen.scopeValue("func", {
20881
- ref: f,
20882
- code: snippets[f.code] || (snippets[f.code] = new code_12._Code(f.code))
20883
- });
20884
- }
20885
- exports2.useFunc = useFunc;
20886
- var Type;
20887
- (function(Type2) {
20888
- Type2[Type2["Num"] = 0] = "Num";
20889
- Type2[Type2["Str"] = 1] = "Str";
20890
- })(Type = exports2.Type || (exports2.Type = {}));
20891
- function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
20892
- if (dataProp instanceof codegen_12.Name) {
20893
- const isNumber = dataPropType === Type.Num;
20894
- return jsPropertySyntax ? isNumber ? (0, codegen_12._)`"[" + ${dataProp} + "]"` : (0, codegen_12._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_12._)`"/" + ${dataProp}` : (0, codegen_12._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
20895
- }
20896
- return jsPropertySyntax ? (0, codegen_12.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
20897
- }
20898
- exports2.getErrorPath = getErrorPath;
20899
- function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
20900
- if (!mode)
20901
- return;
20902
- msg = `strict mode: ${msg}`;
20903
- if (mode === true)
20904
- throw new Error(msg);
20905
- it.self.logger.warn(msg);
20906
- }
20907
- exports2.checkStrictMode = checkStrictMode;
20908
- })(util);
20849
+ }
20850
+ util.mergeEvaluated = {
20851
+ props: makeMergeEvaluated({
20852
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
20853
+ gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`Object.assign(${to}, ${from})`));
20854
+ }),
20855
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
20856
+ if (from === true) {
20857
+ gen.assign(to, true);
20858
+ } else {
20859
+ gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
20860
+ setEvaluated(gen, to, from);
20861
+ }
20862
+ }),
20863
+ mergeValues: (from, to) => from === true ? true : { ...from, ...to },
20864
+ resultToName: evaluatedPropsToName
20865
+ }),
20866
+ items: makeMergeEvaluated({
20867
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
20868
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${to} > ${from} ? ${to} : ${from}`)),
20869
+ mergeValues: (from, to) => from === true ? true : Math.max(from, to),
20870
+ resultToName: (gen, items2) => gen.var("items", items2)
20871
+ })
20872
+ };
20873
+ function evaluatedPropsToName(gen, ps) {
20874
+ if (ps === true)
20875
+ return gen.var("props", true);
20876
+ const props = gen.var("props", (0, codegen_1$v._)`{}`);
20877
+ if (ps !== void 0)
20878
+ setEvaluated(gen, props, ps);
20879
+ return props;
20880
+ }
20881
+ util.evaluatedPropsToName = evaluatedPropsToName;
20882
+ function setEvaluated(gen, props, ps) {
20883
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
20884
+ }
20885
+ util.setEvaluated = setEvaluated;
20886
+ const snippets = {};
20887
+ function useFunc(gen, f) {
20888
+ return gen.scopeValue("func", {
20889
+ ref: f,
20890
+ code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
20891
+ });
20892
+ }
20893
+ util.useFunc = useFunc;
20894
+ var Type;
20895
+ (function(Type2) {
20896
+ Type2[Type2["Num"] = 0] = "Num";
20897
+ Type2[Type2["Str"] = 1] = "Str";
20898
+ })(Type || (util.Type = Type = {}));
20899
+ function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
20900
+ if (dataProp instanceof codegen_1$v.Name) {
20901
+ const isNumber = dataPropType === Type.Num;
20902
+ return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
20903
+ }
20904
+ return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
20905
+ }
20906
+ util.getErrorPath = getErrorPath;
20907
+ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
20908
+ if (!mode)
20909
+ return;
20910
+ msg = `strict mode: ${msg}`;
20911
+ if (mode === true)
20912
+ throw new Error(msg);
20913
+ it.self.logger.warn(msg);
20914
+ }
20915
+ util.checkStrictMode = checkStrictMode;
20909
20916
  var names$1 = {};
20910
20917
  Object.defineProperty(names$1, "__esModule", { value: true });
20911
- const codegen_1$t = codegen;
20918
+ const codegen_1$u = codegen;
20912
20919
  const names = {
20913
20920
  // validation function arguments
20914
- data: new codegen_1$t.Name("data"),
20921
+ data: new codegen_1$u.Name("data"),
20922
+ // data passed to validation function
20915
20923
  // args passed from referencing schema
20916
- valCxt: new codegen_1$t.Name("valCxt"),
20917
- instancePath: new codegen_1$t.Name("instancePath"),
20918
- parentData: new codegen_1$t.Name("parentData"),
20919
- parentDataProperty: new codegen_1$t.Name("parentDataProperty"),
20920
- rootData: new codegen_1$t.Name("rootData"),
20921
- dynamicAnchors: new codegen_1$t.Name("dynamicAnchors"),
20924
+ valCxt: new codegen_1$u.Name("valCxt"),
20925
+ // validation/data context - should not be used directly, it is destructured to the names below
20926
+ instancePath: new codegen_1$u.Name("instancePath"),
20927
+ parentData: new codegen_1$u.Name("parentData"),
20928
+ parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
20929
+ rootData: new codegen_1$u.Name("rootData"),
20930
+ // root data - same as the data passed to the first/top validation function
20931
+ dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
20932
+ // used to support recursiveRef and dynamicRef
20922
20933
  // function scoped variables
20923
- vErrors: new codegen_1$t.Name("vErrors"),
20924
- errors: new codegen_1$t.Name("errors"),
20925
- this: new codegen_1$t.Name("this"),
20934
+ vErrors: new codegen_1$u.Name("vErrors"),
20935
+ // null or array of validation errors
20936
+ errors: new codegen_1$u.Name("errors"),
20937
+ // counter of validation errors
20938
+ this: new codegen_1$u.Name("this"),
20926
20939
  // "globals"
20927
- self: new codegen_1$t.Name("self"),
20928
- scope: new codegen_1$t.Name("scope"),
20940
+ self: new codegen_1$u.Name("self"),
20941
+ scope: new codegen_1$u.Name("scope"),
20929
20942
  // JTD serialize/parse name for JSON string and position
20930
- json: new codegen_1$t.Name("json"),
20931
- jsonPos: new codegen_1$t.Name("jsonPos"),
20932
- jsonLen: new codegen_1$t.Name("jsonLen"),
20933
- jsonPart: new codegen_1$t.Name("jsonPart")
20943
+ json: new codegen_1$u.Name("json"),
20944
+ jsonPos: new codegen_1$u.Name("jsonPos"),
20945
+ jsonLen: new codegen_1$u.Name("jsonLen"),
20946
+ jsonPart: new codegen_1$u.Name("jsonPart")
20934
20947
  };
20935
20948
  names$1.default = names;
20936
20949
  (function(exports2) {
@@ -21003,6 +21016,7 @@ names$1.default = names;
21003
21016
  const E = {
21004
21017
  keyword: new codegen_12.Name("keyword"),
21005
21018
  schemaPath: new codegen_12.Name("schemaPath"),
21019
+ // also used in JTD errors
21006
21020
  params: new codegen_12.Name("params"),
21007
21021
  propertyName: new codegen_12.Name("propertyName"),
21008
21022
  message: new codegen_12.Name("message"),
@@ -21051,8 +21065,8 @@ names$1.default = names;
21051
21065
  })(errors);
21052
21066
  Object.defineProperty(boolSchema, "__esModule", { value: true });
21053
21067
  boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
21054
- const errors_1$2 = errors;
21055
- const codegen_1$s = codegen;
21068
+ const errors_1$3 = errors;
21069
+ const codegen_1$t = codegen;
21056
21070
  const names_1$6 = names$1;
21057
21071
  const boolError = {
21058
21072
  message: "boolean schema is false"
@@ -21064,7 +21078,7 @@ function topBoolOrEmptySchema(it) {
21064
21078
  } else if (typeof schema == "object" && schema.$async === true) {
21065
21079
  gen.return(names_1$6.default.data);
21066
21080
  } else {
21067
- gen.assign((0, codegen_1$s._)`${validateName2}.errors`, null);
21081
+ gen.assign((0, codegen_1$t._)`${validateName2}.errors`, null);
21068
21082
  gen.return(true);
21069
21083
  }
21070
21084
  }
@@ -21091,7 +21105,7 @@ function falseSchemaError(it, overrideAllErrors) {
21091
21105
  params: {},
21092
21106
  it
21093
21107
  };
21094
- (0, errors_1$2.reportError)(cxt, boolError, void 0, overrideAllErrors);
21108
+ (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
21095
21109
  }
21096
21110
  var dataType = {};
21097
21111
  var rules = {};
@@ -21136,185 +21150,183 @@ function shouldUseRule(schema, rule) {
21136
21150
  return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
21137
21151
  }
21138
21152
  applicability.shouldUseRule = shouldUseRule;
21139
- (function(exports2) {
21140
- Object.defineProperty(exports2, "__esModule", { value: true });
21141
- exports2.reportTypeError = exports2.checkDataTypes = exports2.checkDataType = exports2.coerceAndCheckDataType = exports2.getJSONTypes = exports2.getSchemaTypes = exports2.DataType = void 0;
21142
- const rules_1 = rules;
21143
- const applicability_12 = applicability;
21144
- const errors_12 = errors;
21145
- const codegen_12 = codegen;
21146
- const util_12 = util;
21147
- var DataType;
21148
- (function(DataType2) {
21149
- DataType2[DataType2["Correct"] = 0] = "Correct";
21150
- DataType2[DataType2["Wrong"] = 1] = "Wrong";
21151
- })(DataType = exports2.DataType || (exports2.DataType = {}));
21152
- function getSchemaTypes(schema) {
21153
- const types2 = getJSONTypes(schema.type);
21154
- const hasNull = types2.includes("null");
21155
- if (hasNull) {
21156
- if (schema.nullable === false)
21157
- throw new Error("type: null contradicts nullable: false");
21158
- } else {
21159
- if (!types2.length && schema.nullable !== void 0) {
21160
- throw new Error('"nullable" cannot be used without "type"');
21161
- }
21162
- if (schema.nullable === true)
21163
- types2.push("null");
21153
+ Object.defineProperty(dataType, "__esModule", { value: true });
21154
+ dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
21155
+ const rules_1 = rules;
21156
+ const applicability_1$1 = applicability;
21157
+ const errors_1$2 = errors;
21158
+ const codegen_1$s = codegen;
21159
+ const util_1$q = util;
21160
+ var DataType;
21161
+ (function(DataType2) {
21162
+ DataType2[DataType2["Correct"] = 0] = "Correct";
21163
+ DataType2[DataType2["Wrong"] = 1] = "Wrong";
21164
+ })(DataType || (dataType.DataType = DataType = {}));
21165
+ function getSchemaTypes(schema) {
21166
+ const types2 = getJSONTypes(schema.type);
21167
+ const hasNull = types2.includes("null");
21168
+ if (hasNull) {
21169
+ if (schema.nullable === false)
21170
+ throw new Error("type: null contradicts nullable: false");
21171
+ } else {
21172
+ if (!types2.length && schema.nullable !== void 0) {
21173
+ throw new Error('"nullable" cannot be used without "type"');
21164
21174
  }
21165
- return types2;
21175
+ if (schema.nullable === true)
21176
+ types2.push("null");
21166
21177
  }
21167
- exports2.getSchemaTypes = getSchemaTypes;
21168
- function getJSONTypes(ts) {
21169
- const types2 = Array.isArray(ts) ? ts : ts ? [ts] : [];
21170
- if (types2.every(rules_1.isJSONType))
21171
- return types2;
21172
- throw new Error("type must be JSONType or JSONType[]: " + types2.join(","));
21173
- }
21174
- exports2.getJSONTypes = getJSONTypes;
21175
- function coerceAndCheckDataType(it, types2) {
21176
- const { gen, data, opts } = it;
21177
- const coerceTo = coerceToTypes(types2, opts.coerceTypes);
21178
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_12.schemaHasRulesForType)(it, types2[0]));
21179
- if (checkTypes) {
21180
- const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
21181
- gen.if(wrongType, () => {
21182
- if (coerceTo.length)
21183
- coerceData(it, types2, coerceTo);
21184
- else
21185
- reportTypeError(it);
21186
- });
21187
- }
21188
- return checkTypes;
21178
+ return types2;
21179
+ }
21180
+ dataType.getSchemaTypes = getSchemaTypes;
21181
+ function getJSONTypes(ts) {
21182
+ const types2 = Array.isArray(ts) ? ts : ts ? [ts] : [];
21183
+ if (types2.every(rules_1.isJSONType))
21184
+ return types2;
21185
+ throw new Error("type must be JSONType or JSONType[]: " + types2.join(","));
21186
+ }
21187
+ dataType.getJSONTypes = getJSONTypes;
21188
+ function coerceAndCheckDataType(it, types2) {
21189
+ const { gen, data, opts } = it;
21190
+ const coerceTo = coerceToTypes(types2, opts.coerceTypes);
21191
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
21192
+ if (checkTypes) {
21193
+ const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
21194
+ gen.if(wrongType, () => {
21195
+ if (coerceTo.length)
21196
+ coerceData(it, types2, coerceTo);
21197
+ else
21198
+ reportTypeError(it);
21199
+ });
21189
21200
  }
21190
- exports2.coerceAndCheckDataType = coerceAndCheckDataType;
21191
- const COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
21192
- function coerceToTypes(types2, coerceTypes) {
21193
- return coerceTypes ? types2.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
21201
+ return checkTypes;
21202
+ }
21203
+ dataType.coerceAndCheckDataType = coerceAndCheckDataType;
21204
+ const COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
21205
+ function coerceToTypes(types2, coerceTypes) {
21206
+ return coerceTypes ? types2.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
21207
+ }
21208
+ function coerceData(it, types2, coerceTo) {
21209
+ const { gen, data, opts } = it;
21210
+ const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
21211
+ const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
21212
+ if (opts.coerceTypes === "array") {
21213
+ gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$s._)`${data}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
21194
21214
  }
21195
- function coerceData(it, types2, coerceTo) {
21196
- const { gen, data, opts } = it;
21197
- const dataType2 = gen.let("dataType", (0, codegen_12._)`typeof ${data}`);
21198
- const coerced = gen.let("coerced", (0, codegen_12._)`undefined`);
21199
- if (opts.coerceTypes === "array") {
21200
- gen.if((0, codegen_12._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_12._)`${data}[0]`).assign(dataType2, (0, codegen_12._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
21201
- }
21202
- gen.if((0, codegen_12._)`${coerced} !== undefined`);
21203
- for (const t of coerceTo) {
21204
- if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
21205
- coerceSpecificType(t);
21206
- }
21207
- }
21208
- gen.else();
21209
- reportTypeError(it);
21210
- gen.endIf();
21211
- gen.if((0, codegen_12._)`${coerced} !== undefined`, () => {
21212
- gen.assign(data, coerced);
21213
- assignParentData(it, coerced);
21214
- });
21215
- function coerceSpecificType(t) {
21216
- switch (t) {
21217
- case "string":
21218
- gen.elseIf((0, codegen_12._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_12._)`"" + ${data}`).elseIf((0, codegen_12._)`${data} === null`).assign(coerced, (0, codegen_12._)`""`);
21219
- return;
21220
- case "number":
21221
- gen.elseIf((0, codegen_12._)`${dataType2} == "boolean" || ${data} === null
21222
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_12._)`+${data}`);
21223
- return;
21224
- case "integer":
21225
- gen.elseIf((0, codegen_12._)`${dataType2} === "boolean" || ${data} === null
21226
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_12._)`+${data}`);
21227
- return;
21228
- case "boolean":
21229
- gen.elseIf((0, codegen_12._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_12._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
21230
- return;
21231
- case "null":
21232
- gen.elseIf((0, codegen_12._)`${data} === "" || ${data} === 0 || ${data} === false`);
21233
- gen.assign(coerced, null);
21234
- return;
21235
- case "array":
21236
- gen.elseIf((0, codegen_12._)`${dataType2} === "string" || ${dataType2} === "number"
21237
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_12._)`[${data}]`);
21238
- }
21215
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
21216
+ for (const t of coerceTo) {
21217
+ if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
21218
+ coerceSpecificType(t);
21239
21219
  }
21240
21220
  }
21241
- function assignParentData({ gen, parentData, parentDataProperty }, expr) {
21242
- gen.if((0, codegen_12._)`${parentData} !== undefined`, () => gen.assign((0, codegen_12._)`${parentData}[${parentDataProperty}]`, expr));
21243
- }
21244
- function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
21245
- const EQ = correct === DataType.Correct ? codegen_12.operators.EQ : codegen_12.operators.NEQ;
21246
- let cond;
21247
- switch (dataType2) {
21221
+ gen.else();
21222
+ reportTypeError(it);
21223
+ gen.endIf();
21224
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
21225
+ gen.assign(data, coerced);
21226
+ assignParentData(it, coerced);
21227
+ });
21228
+ function coerceSpecificType(t) {
21229
+ switch (t) {
21230
+ case "string":
21231
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data}`).elseIf((0, codegen_1$s._)`${data} === null`).assign(coerced, (0, codegen_1$s._)`""`);
21232
+ return;
21233
+ case "number":
21234
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
21235
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
21236
+ return;
21237
+ case "integer":
21238
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
21239
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
21240
+ return;
21241
+ case "boolean":
21242
+ gen.elseIf((0, codegen_1$s._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
21243
+ return;
21248
21244
  case "null":
21249
- return (0, codegen_12._)`${data} ${EQ} null`;
21245
+ gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
21246
+ gen.assign(coerced, null);
21247
+ return;
21250
21248
  case "array":
21251
- cond = (0, codegen_12._)`Array.isArray(${data})`;
21252
- break;
21253
- case "object":
21254
- cond = (0, codegen_12._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
21255
- break;
21256
- case "integer":
21257
- cond = numCond((0, codegen_12._)`!(${data} % 1) && !isNaN(${data})`);
21258
- break;
21259
- case "number":
21260
- cond = numCond();
21261
- break;
21262
- default:
21263
- return (0, codegen_12._)`typeof ${data} ${EQ} ${dataType2}`;
21264
- }
21265
- return correct === DataType.Correct ? cond : (0, codegen_12.not)(cond);
21266
- function numCond(_cond = codegen_12.nil) {
21267
- return (0, codegen_12.and)((0, codegen_12._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_12._)`isFinite(${data})` : codegen_12.nil);
21268
- }
21269
- }
21270
- exports2.checkDataType = checkDataType;
21271
- function checkDataTypes(dataTypes, data, strictNums, correct) {
21272
- if (dataTypes.length === 1) {
21273
- return checkDataType(dataTypes[0], data, strictNums, correct);
21274
- }
21275
- let cond;
21276
- const types2 = (0, util_12.toHash)(dataTypes);
21277
- if (types2.array && types2.object) {
21278
- const notObj = (0, codegen_12._)`typeof ${data} != "object"`;
21279
- cond = types2.null ? notObj : (0, codegen_12._)`!${data} || ${notObj}`;
21280
- delete types2.null;
21281
- delete types2.array;
21282
- delete types2.object;
21283
- } else {
21284
- cond = codegen_12.nil;
21285
- }
21286
- if (types2.number)
21287
- delete types2.integer;
21288
- for (const t in types2)
21289
- cond = (0, codegen_12.and)(cond, checkDataType(t, data, strictNums, correct));
21290
- return cond;
21291
- }
21292
- exports2.checkDataTypes = checkDataTypes;
21293
- const typeError = {
21294
- message: ({ schema }) => `must be ${schema}`,
21295
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_12._)`{type: ${schema}}` : (0, codegen_12._)`{type: ${schemaValue}}`
21296
- };
21297
- function reportTypeError(it) {
21298
- const cxt = getTypeErrorContext(it);
21299
- (0, errors_12.reportError)(cxt, typeError);
21300
- }
21301
- exports2.reportTypeError = reportTypeError;
21302
- function getTypeErrorContext(it) {
21303
- const { gen, data, schema } = it;
21304
- const schemaCode = (0, util_12.schemaRefOrVal)(it, schema, "type");
21305
- return {
21306
- gen,
21307
- keyword: "type",
21308
- data,
21309
- schema: schema.type,
21310
- schemaCode,
21311
- schemaValue: schemaCode,
21312
- parentSchema: schema,
21313
- params: {},
21314
- it
21315
- };
21249
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
21250
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
21251
+ }
21316
21252
  }
21317
- })(dataType);
21253
+ }
21254
+ function assignParentData({ gen, parentData, parentDataProperty }, expr) {
21255
+ gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
21256
+ }
21257
+ function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
21258
+ const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
21259
+ let cond;
21260
+ switch (dataType2) {
21261
+ case "null":
21262
+ return (0, codegen_1$s._)`${data} ${EQ} null`;
21263
+ case "array":
21264
+ cond = (0, codegen_1$s._)`Array.isArray(${data})`;
21265
+ break;
21266
+ case "object":
21267
+ cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
21268
+ break;
21269
+ case "integer":
21270
+ cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
21271
+ break;
21272
+ case "number":
21273
+ cond = numCond();
21274
+ break;
21275
+ default:
21276
+ return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
21277
+ }
21278
+ return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
21279
+ function numCond(_cond = codegen_1$s.nil) {
21280
+ return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data})` : codegen_1$s.nil);
21281
+ }
21282
+ }
21283
+ dataType.checkDataType = checkDataType;
21284
+ function checkDataTypes(dataTypes, data, strictNums, correct) {
21285
+ if (dataTypes.length === 1) {
21286
+ return checkDataType(dataTypes[0], data, strictNums, correct);
21287
+ }
21288
+ let cond;
21289
+ const types2 = (0, util_1$q.toHash)(dataTypes);
21290
+ if (types2.array && types2.object) {
21291
+ const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
21292
+ cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
21293
+ delete types2.null;
21294
+ delete types2.array;
21295
+ delete types2.object;
21296
+ } else {
21297
+ cond = codegen_1$s.nil;
21298
+ }
21299
+ if (types2.number)
21300
+ delete types2.integer;
21301
+ for (const t in types2)
21302
+ cond = (0, codegen_1$s.and)(cond, checkDataType(t, data, strictNums, correct));
21303
+ return cond;
21304
+ }
21305
+ dataType.checkDataTypes = checkDataTypes;
21306
+ const typeError = {
21307
+ message: ({ schema }) => `must be ${schema}`,
21308
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
21309
+ };
21310
+ function reportTypeError(it) {
21311
+ const cxt = getTypeErrorContext(it);
21312
+ (0, errors_1$2.reportError)(cxt, typeError);
21313
+ }
21314
+ dataType.reportTypeError = reportTypeError;
21315
+ function getTypeErrorContext(it) {
21316
+ const { gen, data, schema } = it;
21317
+ const schemaCode = (0, util_1$q.schemaRefOrVal)(it, schema, "type");
21318
+ return {
21319
+ gen,
21320
+ keyword: "type",
21321
+ data,
21322
+ schema: schema.type,
21323
+ schemaCode,
21324
+ schemaValue: schemaCode,
21325
+ parentSchema: schema,
21326
+ params: {},
21327
+ it
21328
+ };
21329
+ }
21318
21330
  var defaults = {};
21319
21331
  Object.defineProperty(defaults, "__esModule", { value: true });
21320
21332
  defaults.assignDefaults = void 0;
@@ -21701,15 +21713,7 @@ var fastDeepEqual = function equal(a, b) {
21701
21713
  }
21702
21714
  return a !== a && b !== b;
21703
21715
  };
21704
- var jsonSchemaTraverseExports = {};
21705
- var jsonSchemaTraverse = {
21706
- get exports() {
21707
- return jsonSchemaTraverseExports;
21708
- },
21709
- set exports(v) {
21710
- jsonSchemaTraverseExports = v;
21711
- }
21712
- };
21716
+ var jsonSchemaTraverse = { exports: {} };
21713
21717
  var traverse$1 = jsonSchemaTraverse.exports = function(schema, opts, cb) {
21714
21718
  if (typeof opts == "function") {
21715
21719
  cb = opts;
@@ -21791,6 +21795,7 @@ function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr,
21791
21795
  function escapeJsonPtr(str) {
21792
21796
  return str.replace(/~/g, "~0").replace(/\//g, "~1");
21793
21797
  }
21798
+ var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
21794
21799
  Object.defineProperty(resolve$1, "__esModule", { value: true });
21795
21800
  resolve$1.getSchemaRefs = resolve$1.resolveUrl = resolve$1.normalizeId = resolve$1._getFullPath = resolve$1.getFullPath = resolve$1.inlineRef = void 0;
21796
21801
  const util_1$m = util;
@@ -21895,15 +21900,15 @@ function getSchemaRefs(schema, baseId) {
21895
21900
  if (parentJsonPtr === void 0)
21896
21901
  return;
21897
21902
  const fullPath = pathPrefix + jsonPtr;
21898
- let baseId2 = baseIds[parentJsonPtr];
21903
+ let innerBaseId = baseIds[parentJsonPtr];
21899
21904
  if (typeof sch[schemaId] == "string")
21900
- baseId2 = addRef.call(this, sch[schemaId]);
21905
+ innerBaseId = addRef.call(this, sch[schemaId]);
21901
21906
  addAnchor.call(this, sch.$anchor);
21902
21907
  addAnchor.call(this, sch.$dynamicAnchor);
21903
- baseIds[jsonPtr] = baseId2;
21908
+ baseIds[jsonPtr] = innerBaseId;
21904
21909
  function addRef(ref2) {
21905
21910
  const _resolve = this.opts.uriResolver.resolve;
21906
- ref2 = normalizeId(baseId2 ? _resolve(baseId2, ref2) : ref2);
21911
+ ref2 = normalizeId(innerBaseId ? _resolve(innerBaseId, ref2) : ref2);
21907
21912
  if (schemaRefs.has(ref2))
21908
21913
  throw ambiguos(ref2);
21909
21914
  schemaRefs.add(ref2);
@@ -22515,6 +22520,7 @@ function compileSchema(sch) {
22515
22520
  parentDataProperty: names_1$2.default.parentDataProperty,
22516
22521
  dataNames: [names_1$2.default.data],
22517
22522
  dataPathArr: [codegen_1$m.nil],
22523
+ // TODO can its length be used as dataLevel if nil is removed?
22518
22524
  dataLevel: 0,
22519
22525
  dataTypes: [],
22520
22526
  definedProperties: /* @__PURE__ */ new Set(),
@@ -22707,15 +22713,7 @@ const require$$9$1 = {
22707
22713
  additionalProperties: additionalProperties$a
22708
22714
  };
22709
22715
  var uri$1 = {};
22710
- var uri_allExports = {};
22711
- var uri_all = {
22712
- get exports() {
22713
- return uri_allExports;
22714
- },
22715
- set exports(v) {
22716
- uri_allExports = v;
22717
- }
22718
- };
22716
+ var uri_all = { exports: {} };
22719
22717
  /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
22720
22718
  (function(module2, exports2) {
22721
22719
  (function(global2, factory) {
@@ -23755,7 +23753,8 @@ var uri_all = {
23755
23753
  exports3.unescapeComponent = unescapeComponent;
23756
23754
  Object.defineProperty(exports3, "__esModule", { value: true });
23757
23755
  });
23758
- })(uri_all, uri_allExports);
23756
+ })(uri_all, uri_all.exports);
23757
+ var uri_allExports = uri_all.exports;
23759
23758
  Object.defineProperty(uri$1, "__esModule", { value: true });
23760
23759
  const uri = uri_allExports;
23761
23760
  uri.code = 'require("ajv/dist/runtime/uri").default';
@@ -23788,7 +23787,7 @@ uri$1.default = uri;
23788
23787
  } });
23789
23788
  const validation_error_12 = validation_error;
23790
23789
  const ref_error_12 = ref_error;
23791
- const rules_1 = rules;
23790
+ const rules_12 = rules;
23792
23791
  const compile_12 = compile;
23793
23792
  const codegen_2 = codegen;
23794
23793
  const resolve_12 = resolve$1;
@@ -23879,7 +23878,7 @@ uri$1.default = uri;
23879
23878
  this.logger = getLogger(opts.logger);
23880
23879
  const formatOpt = opts.validateFormats;
23881
23880
  opts.validateFormats = false;
23882
- this.RULES = (0, rules_1.getRules)();
23881
+ this.RULES = (0, rules_12.getRules)();
23883
23882
  checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED");
23884
23883
  checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn");
23885
23884
  this._metaOpts = getMetaSchemaOptions.call(this);
@@ -24235,9 +24234,9 @@ uri$1.default = uri;
24235
24234
  }
24236
24235
  }
24237
24236
  }
24238
- exports2.default = Ajv2;
24239
24237
  Ajv2.ValidationError = validation_error_12.default;
24240
24238
  Ajv2.MissingRefError = ref_error_12.default;
24239
+ exports2.default = Ajv2;
24241
24240
  function checkOptions(checkOpts, options2, msg, log = "error") {
24242
24241
  for (const key in checkOpts) {
24243
24242
  const opt = key;
@@ -25831,14 +25830,13 @@ const draft7Vocabularies = [
25831
25830
  draft7.default = draft7Vocabularies;
25832
25831
  var discriminator = {};
25833
25832
  var types = {};
25834
- (function(exports2) {
25835
- Object.defineProperty(exports2, "__esModule", { value: true });
25836
- exports2.DiscrError = void 0;
25837
- (function(DiscrError) {
25838
- DiscrError["Tag"] = "tag";
25839
- DiscrError["Mapping"] = "mapping";
25840
- })(exports2.DiscrError || (exports2.DiscrError = {}));
25841
- })(types);
25833
+ Object.defineProperty(types, "__esModule", { value: true });
25834
+ types.DiscrError = void 0;
25835
+ var DiscrError;
25836
+ (function(DiscrError2) {
25837
+ DiscrError2["Tag"] = "tag";
25838
+ DiscrError2["Mapping"] = "mapping";
25839
+ })(DiscrError || (types.DiscrError = DiscrError = {}));
25842
25840
  Object.defineProperty(discriminator, "__esModule", { value: true });
25843
25841
  const codegen_1 = codegen;
25844
25842
  const types_1 = types;
@@ -26182,7 +26180,7 @@ const require$$3$2 = {
26182
26180
  };
26183
26181
  (function(module2, exports2) {
26184
26182
  Object.defineProperty(exports2, "__esModule", { value: true });
26185
- exports2.MissingRefError = exports2.ValidationError = exports2.CodeGen = exports2.Name = exports2.nil = exports2.stringify = exports2.str = exports2._ = exports2.KeywordCxt = void 0;
26183
+ exports2.MissingRefError = exports2.ValidationError = exports2.CodeGen = exports2.Name = exports2.nil = exports2.stringify = exports2.str = exports2._ = exports2.KeywordCxt = exports2.Ajv = void 0;
26186
26184
  const core_12 = core$2;
26187
26185
  const draft7_1 = draft7;
26188
26186
  const discriminator_1 = discriminator;
@@ -26208,7 +26206,9 @@ const require$$3$2 = {
26208
26206
  return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
26209
26207
  }
26210
26208
  }
26209
+ exports2.Ajv = Ajv2;
26211
26210
  module2.exports = exports2 = Ajv2;
26211
+ module2.exports.Ajv = Ajv2;
26212
26212
  Object.defineProperty(exports2, "__esModule", { value: true });
26213
26213
  exports2.default = Ajv2;
26214
26214
  var validate_12 = validate;
@@ -26242,7 +26242,8 @@ const require$$3$2 = {
26242
26242
  Object.defineProperty(exports2, "MissingRefError", { enumerable: true, get: function() {
26243
26243
  return ref_error_12.default;
26244
26244
  } });
26245
- })(ajv, ajvExports);
26245
+ })(ajv, ajv.exports);
26246
+ var ajvExports = ajv.exports;
26246
26247
  const title$9 = "Root";
26247
26248
  const type$p = "object";
26248
26249
  const description$9 = "Root Element";
@@ -32323,6 +32324,7 @@ function deepCopy(e, t = defaultOpts) {
32323
32324
  return t.detectCircular && s.setAsCopied(e, n), copyObjectContents(e, { destObject: n, srcType: c, watcher: s, options: t }, 0), n;
32324
32325
  }
32325
32326
  var deepCopyAll_min = deepCopy;
32327
+ const deepCopy$1 = /* @__PURE__ */ getDefaultExportFromCjs(deepCopyAll_min);
32326
32328
  var _deepCopyAll = _interopRequireDefault$1(deepCopyAll_min);
32327
32329
  function _interopRequireDefault$1(obj) {
32328
32330
  return obj && obj.__esModule ? obj : { default: obj };
@@ -34184,7 +34186,7 @@ const parseUsfm = (str, parser) => {
34184
34186
  parser.parseItem(preTokenObjectForFragment(matches[n], lexingRegexes));
34185
34187
  }
34186
34188
  };
34187
- var sax = {};
34189
+ var sax$1 = {};
34188
34190
  var emitterComponent;
34189
34191
  var hasRequiredEmitterComponent;
34190
34192
  function requireEmitterComponent() {
@@ -34338,15 +34340,7 @@ function requireStream() {
34338
34340
  return stream;
34339
34341
  }
34340
34342
  var string_decoder = {};
34341
- var safeBufferExports = {};
34342
- var safeBuffer = {
34343
- get exports() {
34344
- return safeBufferExports;
34345
- },
34346
- set exports(v) {
34347
- safeBufferExports = v;
34348
- }
34349
- };
34343
+ var safeBuffer = { exports: {} };
34350
34344
  var buffer = {};
34351
34345
  var ieee754 = {};
34352
34346
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -36141,7 +36135,7 @@ function requireBuffer() {
36141
36135
  var hasRequiredSafeBuffer;
36142
36136
  function requireSafeBuffer() {
36143
36137
  if (hasRequiredSafeBuffer)
36144
- return safeBufferExports;
36138
+ return safeBuffer.exports;
36145
36139
  hasRequiredSafeBuffer = 1;
36146
36140
  (function(module2, exports2) {
36147
36141
  var buffer2 = requireBuffer();
@@ -36196,8 +36190,8 @@ function requireSafeBuffer() {
36196
36190
  }
36197
36191
  return buffer2.SlowBuffer(size);
36198
36192
  };
36199
- })(safeBuffer, safeBufferExports);
36200
- return safeBufferExports;
36193
+ })(safeBuffer, safeBuffer.exports);
36194
+ return safeBuffer.exports;
36201
36195
  }
36202
36196
  var hasRequiredString_decoder;
36203
36197
  function requireString_decoder() {
@@ -36615,6 +36609,9 @@ function requireString_decoder() {
36615
36609
  Stream = function() {
36616
36610
  };
36617
36611
  }
36612
+ if (!Stream)
36613
+ Stream = function() {
36614
+ };
36618
36615
  var streamWraps = sax2.EVENTS.filter(function(ev) {
36619
36616
  return ev !== "error" && ev !== "end";
36620
36617
  });
@@ -37825,9 +37822,16 @@ function requireString_decoder() {
37825
37822
  break;
37826
37823
  }
37827
37824
  if (c === ";") {
37828
- parser[buffer2] += parseEntity(parser);
37829
- parser.entity = "";
37830
- parser.state = returnState;
37825
+ if (parser.opt.unparsedEntities) {
37826
+ var parsedEntity = parseEntity(parser);
37827
+ parser.entity = "";
37828
+ parser.state = returnState;
37829
+ parser.write(parsedEntity);
37830
+ } else {
37831
+ parser[buffer2] += parseEntity(parser);
37832
+ parser.entity = "";
37833
+ parser.state = returnState;
37834
+ }
37831
37835
  } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
37832
37836
  parser.entity += c;
37833
37837
  } else {
@@ -37837,8 +37841,9 @@ function requireString_decoder() {
37837
37841
  parser.state = returnState;
37838
37842
  }
37839
37843
  continue;
37840
- default:
37844
+ default: {
37841
37845
  throw new Error(parser, "Unknown state: " + parser.state);
37846
+ }
37842
37847
  }
37843
37848
  }
37844
37849
  if (parser.position >= parser.bufferCheckPosition) {
@@ -37897,7 +37902,8 @@ function requireString_decoder() {
37897
37902
  })();
37898
37903
  }
37899
37904
  })(exports2);
37900
- })(sax);
37905
+ })(sax$1);
37906
+ const sax = /* @__PURE__ */ getDefaultExportFromCjs(sax$1);
37901
37907
  class UsxLexer {
37902
37908
  constructor() {
37903
37909
  this.sax = sax.parser(true);
@@ -39023,6 +39029,7 @@ const parseNodes = (str, parser, bookCode) => {
39023
39029
  });
39024
39030
  };
39025
39031
  const { labelForScope: labelForScope$2 } = utils.scopeDefs;
39032
+ const idTest = new RegExp(/^[A-Z0-9_]+$/);
39026
39033
  const buildSpecLookup = (specs2) => {
39027
39034
  const ret = {};
39028
39035
  for (const spec of specs2) {
@@ -39067,9 +39074,9 @@ const specs = (pt) => [
39067
39074
  onEnd: (parser, label) => {
39068
39075
  parser.headers[label] = parser.current.sequence.plainText();
39069
39076
  if (label === "id") {
39070
- if (parser.headers[label].length === 3 || parser.headers[label].length > 3 && parser.headers[label].substring(3, 4) === " ") {
39071
- const bookCode = parser.headers[label].substring(0, 3);
39072
- parser.headers["bookCode"] = bookCode;
39077
+ const idBits = parser.headers[label].split(" ", 2);
39078
+ if (idBits[0].length >= 3 && idBits[0].length <= 12 && idTest.test(idBits[0])) {
39079
+ parser.headers["bookCode"] = idBits[0];
39073
39080
  }
39074
39081
  }
39075
39082
  }
@@ -41467,7 +41474,7 @@ const pushModifiedBlocks = (oldSequence, newSequence2, blockFilterFunc, itemFilt
41467
41474
  newSequence2.blocks = [];
41468
41475
  for (const [blockN, block2] of oldSequence.blocks.entries()) {
41469
41476
  if (blockFilterFunc(oldSequence, blockN, block2)) {
41470
- const newBlock2 = blockRewriteFunc(oldSequence, blockN, deepCopyAll_min(block2));
41477
+ const newBlock2 = blockRewriteFunc(oldSequence, blockN, deepCopy$1(block2));
41471
41478
  newBlock2.c.clear();
41472
41479
  modifyBlockItems(
41473
41480
  oldSequence,
@@ -42056,6 +42063,18 @@ const keyValueResolvers = {
42056
42063
  key: (root) => root[0],
42057
42064
  value: (root) => root[1]
42058
42065
  };
42066
+ const keyCountSchemaString = `
42067
+ """Key/Count tuple"""
42068
+ type KeyCount {
42069
+ """The key"""
42070
+ key: String!
42071
+ """The number of occurrences"""
42072
+ count: Int!
42073
+ }`;
42074
+ const keyCountResolvers = {
42075
+ key: (root) => root[0],
42076
+ count: (root) => root[1]
42077
+ };
42059
42078
  const cvSchemaString = `
42060
42079
  """A chapter-verse reference"""
42061
42080
  type cv {
@@ -44523,6 +44542,13 @@ type Sequence {
44523
44542
  """Whether to coerce the strings (toLower|toUpper|none)"""
44524
44543
  coerceCase: String
44525
44544
  ) : [String!]!
44545
+ """A list of token strings the sequence with counts"""
44546
+ uniqueTokenCounts(
44547
+ """Whether to coerce the strings (toLower|toUpper|none)"""
44548
+ coerceCase: String
44549
+ ) : [KeyCount!]!
44550
+ """A list of unique characters in the sequence with counts"""
44551
+ uniqueCharacterCounts: [KeyCount!]!
44526
44552
  """Returns true if a main sequence contains the specified tokens"""
44527
44553
  hasChars(
44528
44554
  """Token strings to be matched exactly"""
@@ -44695,6 +44721,43 @@ const sequenceResolvers = {
44695
44721
  }
44696
44722
  return Array.from(tokens2).sort();
44697
44723
  },
44724
+ uniqueCharacterCounts: (root, args, context) => {
44725
+ const characters = {};
44726
+ root.blocks.forEach(
44727
+ (b) => context.docSet.unsuccinctifyItems(b.c, { tokens: true }, null).forEach(
44728
+ (t) => {
44729
+ const chars = t[2].split("");
44730
+ for (const char of chars) {
44731
+ characters[char] ? characters[char] += 1 : characters[char] = 1;
44732
+ }
44733
+ }
44734
+ )
44735
+ );
44736
+ return Object.entries(characters).sort((a, b) => b[1] - a[1]);
44737
+ },
44738
+ uniqueTokenCounts: (root, args, context) => {
44739
+ const wordlikes = {};
44740
+ root.blocks.forEach(
44741
+ (b) => context.docSet.unsuccinctifyItems(b.c, { tokens: true }, null).forEach(
44742
+ (t) => {
44743
+ let wordlike = t[2];
44744
+ if (args.coerceCase && !["toLower", "toUpper", "none"].includes(args.coerceCase)) {
44745
+ throw new Error(
44746
+ `coerceCase, when present, must be 'toLower', 'toUpper' or 'none', not '${args.coerceCase}'`
44747
+ );
44748
+ }
44749
+ if (args.coerceCase === "toLower") {
44750
+ wordlike = wordlike.toLowerCase();
44751
+ }
44752
+ if (args.coerceCase === "toUpper") {
44753
+ wordlike = wordlike.toUpperCase();
44754
+ }
44755
+ wordlikes[wordlike] ? wordlikes[wordlike] += 1 : wordlikes[wordlike] = 1;
44756
+ }
44757
+ )
44758
+ );
44759
+ return Object.entries(wordlikes).sort((a, b) => b[1] - a[1]);
44760
+ },
44698
44761
  hasChars: (root, args, context) => {
44699
44762
  if (root.type !== "main") {
44700
44763
  throw new Error(`Only available for the main sequence, not ${root.type}`);
@@ -49898,6 +49961,7 @@ const typeDefs = `
49898
49961
  ${querySchemaString}
49899
49962
  ${mutationsSchemaString}
49900
49963
  ${keyValueSchemaString}
49964
+ ${keyCountSchemaString}
49901
49965
  ${cvSchemaString}
49902
49966
  ${idPartsSchemaString}
49903
49967
  ${inputAttSpecSchemaString}
@@ -49939,6 +50003,7 @@ const resolvers = {
49939
50003
  Mutation: mutationsResolvers,
49940
50004
  Query: queryResolvers,
49941
50005
  KeyValue: keyValueResolvers,
50006
+ KeyCount: keyCountResolvers,
49942
50007
  cv: cvResolvers,
49943
50008
  idParts: idPartsResolvers,
49944
50009
  Item: itemResolvers,