@react-querybuilder/core 8.21.1 → 8.22.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.
Files changed (88) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +1426 -56
  3. package/dist/cjs/react-querybuilder_core.cjs.development.js +2241 -83
  4. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  5. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +1426 -56
  6. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  7. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  8. package/dist/formatQuery.d.mts +17 -2
  9. package/dist/formatQuery.d.ts +17 -2
  10. package/dist/formatQuery.js +68 -45
  11. package/dist/formatQuery.js.map +1 -1
  12. package/dist/formatQuery.mjs +67 -46
  13. package/dist/formatQuery.mjs.map +1 -1
  14. package/dist/{import-Ddc3d_8q.d.ts → import-6ExjhifL.d.ts} +2 -2
  15. package/dist/{import-BVdxeIBO.d.mts → import-DVWI7Fdh.d.mts} +2 -2
  16. package/dist/{index-BSwFvkeI.d.mts → index-CX9mehdL.d.mts} +15 -1
  17. package/dist/{index-BSwFvkeI.d.ts → index-CX9mehdL.d.ts} +15 -1
  18. package/dist/parseCEL.d.mts +2 -2
  19. package/dist/parseCEL.d.ts +2 -2
  20. package/dist/parseCEL.js +6 -8
  21. package/dist/parseCEL.js.map +1 -1
  22. package/dist/parseCEL.mjs +6 -8
  23. package/dist/parseCEL.mjs.map +1 -1
  24. package/dist/parseCypher.d.mts +1 -1
  25. package/dist/parseCypher.d.ts +1 -1
  26. package/dist/parseCypher.js.map +1 -1
  27. package/dist/parseGremlin.d.mts +1 -1
  28. package/dist/parseGremlin.d.ts +1 -1
  29. package/dist/parseJSONata.d.mts +2 -2
  30. package/dist/parseJSONata.d.ts +2 -2
  31. package/dist/parseJSONata.js +2 -2
  32. package/dist/parseJSONata.js.map +1 -1
  33. package/dist/parseJSONata.mjs +1 -1
  34. package/dist/parseJsonLogic.d.mts +2 -2
  35. package/dist/parseJsonLogic.d.ts +2 -2
  36. package/dist/parseJsonLogic.js +3 -3
  37. package/dist/parseJsonLogic.js.map +1 -1
  38. package/dist/parseJsonLogic.mjs +3 -3
  39. package/dist/parseJsonLogic.mjs.map +1 -1
  40. package/dist/parseMongoDB.d.mts +2 -2
  41. package/dist/parseMongoDB.d.ts +2 -2
  42. package/dist/parseMongoDB.js +2 -2
  43. package/dist/parseMongoDB.mjs +2 -2
  44. package/dist/parseSPARQL.d.mts +1 -1
  45. package/dist/parseSPARQL.d.ts +1 -1
  46. package/dist/parseSPARQL.js +0 -1
  47. package/dist/parseSPARQL.js.map +1 -1
  48. package/dist/parseSPARQL.mjs +0 -1
  49. package/dist/parseSPARQL.mjs.map +1 -1
  50. package/dist/parseSQL.d.mts +2 -2
  51. package/dist/parseSQL.d.ts +2 -2
  52. package/dist/parseSQL.js +54 -62
  53. package/dist/parseSQL.js.map +1 -1
  54. package/dist/parseSQL.mjs +54 -62
  55. package/dist/parseSQL.mjs.map +1 -1
  56. package/dist/parseSpEL.d.mts +2 -2
  57. package/dist/parseSpEL.d.ts +2 -2
  58. package/dist/parseSpEL.js +3 -3
  59. package/dist/parseSpEL.js.map +1 -1
  60. package/dist/parseSpEL.mjs +3 -3
  61. package/dist/parseSpEL.mjs.map +1 -1
  62. package/dist/{prepareQueryObjects-C2-kTZvR.js → prepareQueryObjects-BnGL91Tt.js} +9 -5
  63. package/dist/{prepareQueryObjects-C2-kTZvR.js.map → prepareQueryObjects-BnGL91Tt.js.map} +1 -1
  64. package/dist/{prepareQueryObjects-Q18lHCKl.mjs → prepareQueryObjects-ChINDIap.mjs} +9 -5
  65. package/dist/{prepareQueryObjects-Q18lHCKl.mjs.map → prepareQueryObjects-ChINDIap.mjs.map} +1 -1
  66. package/dist/query-builder-layout.css +1 -1
  67. package/dist/query-builder-layout.css.map +1 -1
  68. package/dist/query-builder.css +1 -1
  69. package/dist/query-builder.css.map +1 -1
  70. package/dist/react-querybuilder_core.d.mts +1426 -56
  71. package/dist/react-querybuilder_core.legacy-esm.d.ts +1426 -56
  72. package/dist/react-querybuilder_core.legacy-esm.js +2279 -92
  73. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  74. package/dist/react-querybuilder_core.mjs +2198 -85
  75. package/dist/react-querybuilder_core.mjs.map +1 -1
  76. package/dist/react-querybuilder_core.production.d.mts +1426 -56
  77. package/dist/react-querybuilder_core.production.mjs +1 -1
  78. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  79. package/dist/styles/_layout.scss +5 -2
  80. package/dist/transformQuery.d.mts +1 -1
  81. package/dist/transformQuery.d.ts +1 -1
  82. package/dist/{utils-Dt0D_DMV.mjs → utils-4k-j5FBa.mjs} +20 -3
  83. package/dist/utils-4k-j5FBa.mjs.map +1 -0
  84. package/dist/{utils-DEwV7F6B.js → utils-C79dxwZb.js} +31 -2
  85. package/dist/utils-C79dxwZb.js.map +1 -0
  86. package/package.json +9 -8
  87. package/dist/utils-DEwV7F6B.js.map +0 -1
  88. package/dist/utils-Dt0D_DMV.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { numericQuantity, numericRegex as numericRegex$1 } from "numeric-quantity";
2
- import { current, isDraft, produce } from "immer";
2
+ import { current, freeze, isDraft, produce } from "immer";
3
3
  //#region src/defaults.ts
4
4
  /**
5
5
  * @group Defaults
@@ -130,6 +130,14 @@ const defaultTranslations = {
130
130
  label: "˅",
131
131
  title: "Shift down"
132
132
  },
133
+ undo: {
134
+ label: "↶",
135
+ title: "Undo"
136
+ },
137
+ redo: {
138
+ label: "↷",
139
+ title: "Redo"
140
+ },
133
141
  dragHandle: {
134
142
  label: "⁞⁞",
135
143
  title: "Drag handle"
@@ -454,6 +462,9 @@ const standardClassnames = {
454
462
  valid: "queryBuilder-valid",
455
463
  invalid: "queryBuilder-invalid",
456
464
  shiftActions: "shiftActions",
465
+ undoRedoActions: "undoRedoActions",
466
+ undoAction: "undoRedoActions-undo",
467
+ redoAction: "undoRedoActions-redo",
457
468
  dndDragging: "dndDragging",
458
469
  dndOver: "dndOver",
459
470
  dndCopy: "dndCopy",
@@ -502,6 +513,9 @@ const defaultControlClassnames = {
502
513
  value: "",
503
514
  removeRule: "",
504
515
  shiftActions: "",
516
+ undoRedoActions: "",
517
+ undoAction: "",
518
+ redoAction: "",
505
519
  dragHandle: "",
506
520
  lockRule: "",
507
521
  lockGroup: "",
@@ -559,6 +573,9 @@ const TestID = {
559
573
  valueEditor: "value-editor",
560
574
  notToggle: "not-toggle",
561
575
  shiftActions: "shift-actions",
576
+ undoRedoActions: "undo-redo-actions",
577
+ undoAction: "undo-action",
578
+ redoAction: "redo-action",
562
579
  dragHandle: "drag-handle",
563
580
  lockRule: "lock-rule",
564
581
  lockGroup: "lock-group",
@@ -605,6 +622,7 @@ const queryBuilderFlagDefaults = {
605
622
  enableDragAndDrop: false,
606
623
  enableMountQueryChange: true,
607
624
  listsAsArrays: false,
625
+ preserveQueryStateOnUnmount: false,
608
626
  resetOnFieldChange: true,
609
627
  resetOnOperatorChange: false,
610
628
  showCloneButtons: false,
@@ -613,8 +631,22 @@ const queryBuilderFlagDefaults = {
613
631
  showMuteButtons: false,
614
632
  showNotToggle: false,
615
633
  showShiftActions: false,
634
+ showUndoRedo: false,
616
635
  suppressStandardClassnames: false
617
636
  };
637
+ /**
638
+ * Default maximum number of undo steps retained by query history.
639
+ *
640
+ * @group Defaults
641
+ */
642
+ const defaultMaxHistory = 50;
643
+ /**
644
+ * Default time window (in milliseconds) within which consecutive changes to the same
645
+ * property of the same rule are coalesced into a single undo step.
646
+ *
647
+ * @group Defaults
648
+ */
649
+ const defaultCoalesceMs = 500;
618
650
  //#endregion
619
651
  //#region src/utils/arrayUtils.ts
620
652
  /**
@@ -718,7 +750,7 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
718
750
  */
719
751
  const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
720
752
  //#endregion
721
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
753
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
722
754
  function _typeof(o) {
723
755
  "@babel/helpers - typeof";
724
756
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -728,7 +760,7 @@ function _typeof(o) {
728
760
  }, _typeof(o);
729
761
  }
730
762
  //#endregion
731
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
763
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
732
764
  function toPrimitive(t, r) {
733
765
  if ("object" != _typeof(t) || !t) return t;
734
766
  var e = t[Symbol.toPrimitive];
@@ -740,13 +772,13 @@ function toPrimitive(t, r) {
740
772
  return ("string" === r ? String : Number)(t);
741
773
  }
742
774
  //#endregion
743
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
775
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
744
776
  function toPropertyKey(t) {
745
777
  var i = toPrimitive(t, "string");
746
778
  return "symbol" == _typeof(i) ? i : i + "";
747
779
  }
748
780
  //#endregion
749
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
781
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
750
782
  function _defineProperty(e, r, t) {
751
783
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
752
784
  value: t,
@@ -756,7 +788,7 @@ function _defineProperty(e, r, t) {
756
788
  }) : e[r] = t, e;
757
789
  }
758
790
  //#endregion
759
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/objectSpread2.js
791
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectSpread2.js
760
792
  function ownKeys(e, r) {
761
793
  var t = Object.keys(e);
762
794
  if (Object.getOwnPropertySymbols) {
@@ -779,7 +811,7 @@ function _objectSpread2(e) {
779
811
  return e;
780
812
  }
781
813
  //#endregion
782
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/objectWithoutPropertiesLoose.js
814
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectWithoutPropertiesLoose.js
783
815
  function _objectWithoutPropertiesLoose(r, e) {
784
816
  if (null == r) return {};
785
817
  var t = {};
@@ -790,7 +822,7 @@ function _objectWithoutPropertiesLoose(r, e) {
790
822
  return t;
791
823
  }
792
824
  //#endregion
793
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/objectWithoutProperties.js
825
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectWithoutProperties.js
794
826
  function _objectWithoutProperties(e, t) {
795
827
  if (null == e) return {};
796
828
  var o, r, i = _objectWithoutPropertiesLoose(e, t);
@@ -802,7 +834,7 @@ function _objectWithoutProperties(e, t) {
802
834
  }
803
835
  //#endregion
804
836
  //#region src/utils/convertQuery.ts
805
- const _excluded = ["combinator"];
837
+ const _excluded$1 = ["combinator"];
806
838
  const combinatorLevels = [
807
839
  "or",
808
840
  "xor",
@@ -862,7 +894,7 @@ const convertFromIC = (rg) => {
862
894
  */
863
895
  const convertToIC = (rg) => {
864
896
  if (isRuleGroupTypeIC(rg)) return rg;
865
- const { combinator } = rg, queryWithoutCombinator = _objectWithoutProperties(rg, _excluded);
897
+ const { combinator } = rg, queryWithoutCombinator = _objectWithoutProperties(rg, _excluded$1);
866
898
  const rules = [];
867
899
  const { length } = rg.rules;
868
900
  for (let idx = 0; idx < length; idx++) {
@@ -877,6 +909,181 @@ function convertQuery(query) {
877
909
  return isRuleGroupTypeIC(query) ? convertFromIC(query) : convertToIC(query);
878
910
  }
879
911
  //#endregion
912
+ //#region src/utils/deriveClassNames.ts
913
+ const ruleClassnameSources = {
914
+ shiftActions: ["shiftActions"],
915
+ dragHandle: ["dragHandle"],
916
+ fields: ["valueSelector", "fields"],
917
+ matchMode: ["valueSelector", "matchMode"],
918
+ matchThreshold: ["valueSelector", "matchThreshold"],
919
+ operators: ["valueSelector", "operators"],
920
+ valueSource: ["valueSelector", "valueSource"],
921
+ value: ["value"],
922
+ cloneRule: ["actionElement", "cloneRule"],
923
+ lockRule: ["actionElement", "lockRule"],
924
+ muteRule: ["actionElement", "muteRule"],
925
+ removeRule: ["actionElement", "removeRule"],
926
+ valueListItem: ["valueListItem"]
927
+ };
928
+ const ruleGroupClassnameSources = {
929
+ header: {
930
+ sources: ["header"],
931
+ conditions: [
932
+ {
933
+ key: "dndOver",
934
+ when: (s) => s.isOver,
935
+ standardOnly: true
936
+ },
937
+ {
938
+ key: "dndCopy",
939
+ when: (s) => s.isOver && s.dropEffect === "copy"
940
+ },
941
+ {
942
+ key: "dndDropNotAllowed",
943
+ when: (s) => s.dropNotAllowed
944
+ }
945
+ ]
946
+ },
947
+ shiftActions: ["shiftActions"],
948
+ undoRedoActions: ["undoRedoActions"],
949
+ undoAction: ["actionElement", "undoAction"],
950
+ redoAction: ["actionElement", "redoAction"],
951
+ dragHandle: ["dragHandle"],
952
+ combinators: ["valueSelector", "combinators"],
953
+ notToggle: ["notToggle"],
954
+ addRule: ["actionElement", "addRule"],
955
+ addGroup: ["actionElement", "addGroup"],
956
+ cloneGroup: ["actionElement", "cloneGroup"],
957
+ lockGroup: ["actionElement", "lockGroup"],
958
+ muteGroup: ["actionElement", "muteGroup"],
959
+ removeGroup: ["actionElement", "removeGroup"],
960
+ body: ["body"]
961
+ };
962
+ /**
963
+ * Conditional classes applied to a rule's wrapper element.
964
+ *
965
+ * Note that this is deliberately _not_ the same set as {@link ruleGroupOuterConditions}: a rule
966
+ * reflects more drag-and-drop states than a group does. Declaring each set separately is what
967
+ * keeps an implementation from assuming they're symmetric.
968
+ */
969
+ const ruleOuterConditions = [
970
+ {
971
+ key: "disabled",
972
+ when: (s) => s.disabled
973
+ },
974
+ {
975
+ key: "muted",
976
+ when: (s) => s.muted
977
+ },
978
+ {
979
+ key: "dndDragging",
980
+ when: (s) => s.isDragging
981
+ },
982
+ {
983
+ key: "dndOver",
984
+ when: (s) => s.isOver
985
+ },
986
+ {
987
+ key: "dndCopy",
988
+ when: (s) => s.isOver && s.dropEffect === "copy"
989
+ },
990
+ {
991
+ key: "dndGroup",
992
+ when: (s) => s.isOver && s.groupItems
993
+ },
994
+ {
995
+ key: "dndDropNotAllowed",
996
+ when: (s) => s.dropNotAllowed
997
+ },
998
+ {
999
+ key: "hasSubQuery",
1000
+ when: (s) => s.hasSubQuery
1001
+ }
1002
+ ];
1003
+ /** Conditional classes applied to a rule group's wrapper element. */
1004
+ const ruleGroupOuterConditions = [
1005
+ {
1006
+ key: "disabled",
1007
+ when: (s) => s.disabled
1008
+ },
1009
+ {
1010
+ key: "muted",
1011
+ when: (s) => s.muted
1012
+ },
1013
+ {
1014
+ key: "dndDragging",
1015
+ when: (s) => s.isDragging
1016
+ },
1017
+ {
1018
+ key: "dndGroup",
1019
+ when: (s) => s.isOver && s.groupItems
1020
+ }
1021
+ ];
1022
+ /**
1023
+ * Expands conditions into `clsx` arguments: every custom class first (in declaration order),
1024
+ * then a single object of standard classes.
1025
+ */
1026
+ const conditionArgs = (conditions, state, { classNames, suppressStandardClassnames }) => {
1027
+ const evaluated = conditions.map((condition) => [condition, !!condition.when(state)]);
1028
+ return [...evaluated.filter(([condition]) => !condition.standardOnly).map(([condition, active]) => active && (classNames === null || classNames === void 0 ? void 0 : classNames[condition.key])), suppressStandardClassnames || Object.fromEntries(evaluated.map(([condition, active]) => [standardClassnames[condition.key], active]))];
1029
+ };
1030
+ /** Composes the classname for a single entry of a spec map. */
1031
+ const deriveFromSpec = (key, spec, state, options) => {
1032
+ const { sources, conditions } = Array.isArray(spec) ? { sources: spec } : spec;
1033
+ return clsx(options.suppressStandardClassnames || standardClassnames[key], ...sources.map((source) => {
1034
+ var _options$classNames;
1035
+ return (_options$classNames = options.classNames) === null || _options$classNames === void 0 ? void 0 : _options$classNames[source];
1036
+ }), ...conditions ? conditionArgs(conditions, state, options) : []);
1037
+ };
1038
+ const deriveFromSpecs = (specs, state, options) => {
1039
+ const result = {};
1040
+ for (const [key, spec] of Object.entries(specs)) result[key] = deriveFromSpec(key, spec, state, options);
1041
+ return result;
1042
+ };
1043
+ /**
1044
+ * Classnames for each element rendered by a rule. This is the framework-agnostic core of the
1045
+ * `classNames` object returned by the `useRule` hook.
1046
+ *
1047
+ * @group Query Tools
1048
+ */
1049
+ const deriveRuleClassNames = (options) => deriveFromSpecs(ruleClassnameSources, {}, options);
1050
+ /**
1051
+ * The classname for a single element of a rule, composed from the same table as
1052
+ * {@link deriveRuleClassNames}. Useful where only one is needed, such as the items of a
1053
+ * multi-value editor.
1054
+ *
1055
+ * @group Query Tools
1056
+ */
1057
+ const deriveRuleClassName = (key, options) => deriveFromSpec(key, ruleClassnameSources[key], {}, options);
1058
+ /**
1059
+ * Classnames for each element rendered by a rule group, including its conditionally-classed
1060
+ * `header`. This is the framework-agnostic core of the `classNames` object returned by the
1061
+ * `useRuleGroup` hook.
1062
+ *
1063
+ * @group Query Tools
1064
+ */
1065
+ const deriveRuleGroupClassNames = (options) => deriveFromSpecs(ruleGroupClassnameSources, options, options);
1066
+ const deriveOuterClassName = (standardKey, conditions, options) => {
1067
+ const { classNames, suppressStandardClassnames, leadingClassNames = [], validationClassName } = options;
1068
+ return clsx(...leadingClassNames, suppressStandardClassnames || standardClassnames[standardKey], classNames === null || classNames === void 0 ? void 0 : classNames[standardKey], ...conditionArgs(conditions, options, options), validationClassName);
1069
+ };
1070
+ /**
1071
+ * The outer (wrapper) classname for a rule, including every conditional state class.
1072
+ *
1073
+ * @group Query Tools
1074
+ */
1075
+ const deriveRuleOuterClassName = (options) => deriveOuterClassName("rule", ruleOuterConditions, options);
1076
+ /**
1077
+ * The outer (wrapper) classname for a rule group, including every conditional state class.
1078
+ *
1079
+ * A group reflects fewer drag-and-drop states than a rule—`dndOver`, `dndCopy`,
1080
+ * `dndDropNotAllowed`, and `hasSubQuery` do not apply—so this is not interchangeable with
1081
+ * {@link deriveRuleOuterClassName}.
1082
+ *
1083
+ * @group Query Tools
1084
+ */
1085
+ const deriveRuleGroupOuterClassName = (options) => deriveOuterClassName("ruleGroup", ruleGroupOuterConditions, options);
1086
+ //#endregion
880
1087
  //#region src/utils/defaultValidator.ts
881
1088
  /**
882
1089
  * This is an example validation function you can pass to {@link react-querybuilder!QueryBuilder QueryBuilder} in the
@@ -1183,7 +1390,7 @@ const filterFieldsByComparator = (field, fields, operator) => {
1183
1390
  if (!field.comparator) {
1184
1391
  const filterOutSameField = (f) => {
1185
1392
  var _f$value, _field$value;
1186
- return ((_f$value = f.value) !== null && _f$value !== void 0 ? _f$value : /* v8 ignore start -- @preserve */ f.name) !== ((_field$value = field.value) !== null && _field$value !== void 0 ? _field$value :
1393
+ return ((_f$value = f.value) !== null && _f$value !== void 0 ? _f$value : /* v8 ignore start -- @preserve */ f.name) !== ((_field$value = field.value) !== null && _field$value !== void 0 ? _field$value :
1187
1394
  /* v8 ignore start -- @preserve */ field.name);
1188
1395
  };
1189
1396
  if (isFlexibleOptionGroupArray(fields)) return fields.map((og) => _objectSpread2(_objectSpread2({}, og), {}, { options: og.options.filter((v) => filterOutSameField(v)) }));
@@ -1193,6 +1400,142 @@ const filterFieldsByComparator = (field, fields, operator) => {
1193
1400
  return fields.filter((f) => filterByComparator(field, operator, f));
1194
1401
  };
1195
1402
  //#endregion
1403
+ //#region src/utils/deriveRuleContext.ts
1404
+ /**
1405
+ * Resolves the field configuration for a rule's `field`, falling back to a minimal option object
1406
+ * when the field isn't present in the field map.
1407
+ */
1408
+ const getFieldData = (field, fieldMap) => {
1409
+ var _fieldMap$field;
1410
+ return (_fieldMap$field = fieldMap === null || fieldMap === void 0 ? void 0 : fieldMap[field]) !== null && _fieldMap$field !== void 0 ? _fieldMap$field : {
1411
+ name: field,
1412
+ value: field,
1413
+ label: field
1414
+ };
1415
+ };
1416
+ /**
1417
+ * The input type for a rule. A field's own `inputType` takes precedence over `getInputType`.
1418
+ */
1419
+ const getRuleInputType = (field, operator, fieldData, getInputType) => {
1420
+ var _fieldData$inputType;
1421
+ return (_fieldData$inputType = fieldData.inputType) !== null && _fieldData$inputType !== void 0 ? _fieldData$inputType : getInputType(field, operator, { fieldData });
1422
+ };
1423
+ /**
1424
+ * Whether the value editor(s) should be hidden for an operator, based on its `arity`.
1425
+ */
1426
+ const hideValueControlsForOperator = (operatorObject) => {
1427
+ const arity = operatorObject === null || operatorObject === void 0 ? void 0 : operatorObject.arity;
1428
+ return typeof arity === "string" && arity === "unary" || typeof arity === "number" && arity < 2;
1429
+ };
1430
+ /**
1431
+ * Value source options for a rule. A `valueSource` present on the rule but absent from the
1432
+ * configured list is appended, so the current selection is always representable.
1433
+ */
1434
+ const getRuleValueSourceOptions = (rule, fieldData, getValueSources) => {
1435
+ const configuredVSs = getValueSources(rule.field, rule.operator, { fieldData });
1436
+ if (rule.valueSource && !getOption(configuredVSs, rule.valueSource)) return [...configuredVSs, {
1437
+ name: rule.valueSource,
1438
+ value: rule.valueSource,
1439
+ label: rule.valueSource
1440
+ }];
1441
+ return configuredVSs;
1442
+ };
1443
+ /**
1444
+ * Normalizes the result of `getParameters` to a non-empty list or `null`.
1445
+ */
1446
+ const getParametersAsList = (parameters) => parameters && parameters.length > 0 ? parameters : null;
1447
+ /**
1448
+ * The value editor type for a rule. `valueSource: "field"` always uses a select list, and
1449
+ * `valueSource: "parameter"` uses a (multi)select when parameters are available.
1450
+ */
1451
+ const getRuleValueEditorType = (rule, fieldData, parametersAsList, getValueEditorType) => rule.valueSource === "field" ? "select" : rule.valueSource === "parameter" ? parametersAsList ? lc(rule.operator) === "in" || lc(rule.operator) === "notin" ? "multiselect" : "select" : "text" : getValueEditorType(rule.field, rule.operator, { fieldData });
1452
+ /**
1453
+ * The option list presented by a rule's value editor, resolved from its `valueSource`.
1454
+ */
1455
+ const getRuleValues = (rule, fieldData, fields, parametersAsList, getValues) => {
1456
+ const v = rule.valueSource === "field" ? filterFieldsByComparator(fieldData, fields, rule.operator) : rule.valueSource === "parameter" ? parametersAsList !== null && parametersAsList !== void 0 ? parametersAsList : [] : getValues(rule.field, rule.operator, { fieldData });
1457
+ return isFlexibleOptionArray(v) || isFlexibleOptionGroupArray(v) ? toFullOptionList(v) : v;
1458
+ };
1459
+ /**
1460
+ * The validation result for a rule: the entry from a query-level {@link ValidationMap} if present,
1461
+ * otherwise the field's own `validator` result, otherwise `null`.
1462
+ */
1463
+ const getRuleValidationResult = (rule, fieldData, validationMap = {}, id = ((_rule$id) => (_rule$id = rule.id) !== null && _rule$id !== void 0 ? _rule$id : "")()) => {
1464
+ var _validationMap$id;
1465
+ return (_validationMap$id = validationMap[id]) !== null && _validationMap$id !== void 0 ? _validationMap$id : typeof fieldData.validator === "function" ? fieldData.validator(rule) : null;
1466
+ };
1467
+ /**
1468
+ * Resolves everything about a single rule that depends on the field/operator configuration:
1469
+ * its field data, operators, value editor type, value list, value sources, match modes, and
1470
+ * validation result.
1471
+ *
1472
+ * This is the framework-agnostic core of the `useRule` hook, shared with
1473
+ * {@link QueryManager.getRuleContext} so that non-React implementations derive identical results.
1474
+ * It performs no memoization; callers are responsible for caching as appropriate.
1475
+ *
1476
+ * @group Query Tools
1477
+ */
1478
+ const deriveRuleContext = (rule, resolvers, options = {}) => {
1479
+ var _fieldData$inputType2, _getSubQueryBuilderPr;
1480
+ const { fields, fieldMap, getInputType, getMatchModes, getOperators, getParameters, getValueEditorType, getValues, getValueSources, getSubQueryBuilderProps } = resolvers;
1481
+ const fieldData = getFieldData(rule.field, fieldMap);
1482
+ const inputType = (_fieldData$inputType2 = fieldData.inputType) !== null && _fieldData$inputType2 !== void 0 ? _fieldData$inputType2 : getInputType(rule.field, rule.operator, { fieldData });
1483
+ const matchModes = getMatchModes(rule.field, { fieldData });
1484
+ const operators = getOperators(rule.field, { fieldData });
1485
+ const operatorObject = getOption(operators, rule.operator);
1486
+ const valueSourceOptions = getRuleValueSourceOptions(rule, fieldData, getValueSources);
1487
+ const parameters = getParametersAsList(getParameters(rule.field, rule.operator, { fieldData }));
1488
+ return {
1489
+ fieldData,
1490
+ hideValueControls: hideValueControlsForOperator(operatorObject),
1491
+ inputType,
1492
+ matchModes,
1493
+ operatorObject,
1494
+ operators,
1495
+ parameters,
1496
+ validationResult: getRuleValidationResult(rule, fieldData, options.validationMap, options.id),
1497
+ valueEditorType: getRuleValueEditorType(rule, fieldData, parameters, getValueEditorType),
1498
+ values: getRuleValues(rule, fieldData, fields, parameters, getValues),
1499
+ valueSourceOptions,
1500
+ valueSources: valueSourceOptions.map(({ value }) => value),
1501
+ subQueryBuilderProps: (_getSubQueryBuilderPr = getSubQueryBuilderProps === null || getSubQueryBuilderProps === void 0 ? void 0 : getSubQueryBuilderProps(rule.field, { fieldData })) !== null && _getSubQueryBuilderPr !== void 0 ? _getSubQueryBuilderPr : {}
1502
+ };
1503
+ };
1504
+ /**
1505
+ * The effective combinator for a group: its own `combinator` when it has one, otherwise the
1506
+ * first configured combinator (which is the case for groups with independent combinators).
1507
+ *
1508
+ * This intentionally covers only the current property-based API. The `RuleGroup` component
1509
+ * additionally falls back to its deprecated `combinator` prop; that fallback stays in the hook.
1510
+ */
1511
+ const getRuleGroupCombinator = (ruleGroup, combinators) => {
1512
+ var _getFirstOption;
1513
+ return isRuleGroupType(ruleGroup) ? ruleGroup.combinator : (_getFirstOption = getFirstOption(combinators)) !== null && _getFirstOption !== void 0 ? _getFirstOption : "";
1514
+ };
1515
+ /**
1516
+ * Resolves everything about a rule group that depends on the combinator configuration, plus its
1517
+ * validation result.
1518
+ *
1519
+ * Note that unlike {@link deriveRuleContext}, there is no field-level validator fallback—a
1520
+ * group's validation result comes only from the query-level {@link ValidationMap}.
1521
+ *
1522
+ * @group Query Tools
1523
+ */
1524
+ const deriveRuleGroupContext = (ruleGroup, combinators, options = {}) => {
1525
+ var _combinatorObject$cla, _ref, _options$validationMa, _ref2, _options$id;
1526
+ const independentCombinators = isRuleGroupTypeIC(ruleGroup);
1527
+ const combinator = getRuleGroupCombinator(ruleGroup, combinators);
1528
+ const combinatorObject = getOption(combinators, combinator);
1529
+ return {
1530
+ combinator,
1531
+ combinatorObject,
1532
+ combinators,
1533
+ combinatorBasedClassName: independentCombinators ? null : (_combinatorObject$cla = combinatorObject === null || combinatorObject === void 0 ? void 0 : combinatorObject.className) !== null && _combinatorObject$cla !== void 0 ? _combinatorObject$cla : "",
1534
+ independentCombinators,
1535
+ validationResult: (_ref = ((_options$validationMa = options.validationMap) !== null && _options$validationMa !== void 0 ? _options$validationMa : {})[(_ref2 = (_options$id = options.id) !== null && _options$id !== void 0 ? _options$id : ruleGroup.id) !== null && _ref2 !== void 0 ? _ref2 : ""]) !== null && _ref !== void 0 ? _ref : null
1536
+ };
1537
+ };
1538
+ //#endregion
1196
1539
  //#region src/utils/parseNumber.ts
1197
1540
  /**
1198
1541
  * Converts a string to a number. Uses native `parseFloat` if `parseNumbers` is "native",
@@ -1212,6 +1555,108 @@ const parseNumber = (val, { parseNumbers, bigIntOnOverflow } = {}) => {
1212
1555
  return typeof valAsNum === "bigint" || !Number.isNaN(valAsNum) ? valAsNum : val;
1213
1556
  };
1214
1557
  //#endregion
1558
+ //#region src/utils/deriveValueEditor.ts
1559
+ /** Operators whose value is a list rather than a single scalar. */
1560
+ const multiValueOperators = /* @__PURE__ */ new Set([
1561
+ "between",
1562
+ "notBetween",
1563
+ "in",
1564
+ "notIn"
1565
+ ]);
1566
+ /**
1567
+ * Whether an operator's value is a list of two bounds.
1568
+ *
1569
+ * @group Value Editors
1570
+ */
1571
+ const isBetweenOperator = (operator) => operator === "between" || operator === "notBetween";
1572
+ /**
1573
+ * Determines whether a rule's `value` needs to be collapsed to a single element because it no
1574
+ * longer represents a list, and what it should become.
1575
+ *
1576
+ * This happens when the value is an array (or a comma-containing string in a `number` input,
1577
+ * which `<input type="number">` can't display) while the operator is not one of the multi-value
1578
+ * operators and the editor is not a multiselect—typically right after the operator changes from
1579
+ * `"in"` or `"between"` to something else.
1580
+ *
1581
+ * The React `useValueEditor` hook applies the result in an effect; other implementations may
1582
+ * apply it wherever is idiomatic.
1583
+ *
1584
+ * @group Value Editors
1585
+ */
1586
+ const getValueEditorReset = ({ skipHook, type, operator, value, inputType }) => {
1587
+ var _toArray$;
1588
+ return !skipHook && type !== "multiselect" && !multiValueOperators.has(operator) && (Array.isArray(value) || inputType === "number" && typeof value === "string" && value.includes(",")) ? {
1589
+ reset: true,
1590
+ value: (_toArray$ = toArray(value, { retainEmptyStrings: true })[0]) !== null && _toArray$ !== void 0 ? _toArray$ : ""
1591
+ } : {
1592
+ reset: false,
1593
+ value
1594
+ };
1595
+ };
1596
+ /**
1597
+ * Produces the next value for a series of value editors when the editor at `index` changes.
1598
+ *
1599
+ * For `between`/`notBetween`, editing the first bound guarantees an array of at least two
1600
+ * elements, seeding the second from the first available option. The result is a comma-joined
1601
+ * string unless `listsAsArrays` is `true`.
1602
+ *
1603
+ * @group Value Editors
1604
+ */
1605
+ const getMultiValueUpdate = ({ value, index, valueAsArray, operator, values, listsAsArrays, parseNumberMethod }) => {
1606
+ const parsedVal = parseNumber(value, { parseNumbers: parseNumberMethod });
1607
+ const needsBetweenFix = index === 0 && isBetweenOperator(operator) && (valueAsArray.length < 2 || valueAsArray[1] === void 0);
1608
+ if (valueAsArray[index] === parsedVal && !needsBetweenFix) return listsAsArrays ? valueAsArray : joinWith(valueAsArray, ",");
1609
+ const v = [...valueAsArray];
1610
+ v[index] = parsedVal;
1611
+ if (needsBetweenFix) {
1612
+ var _getFirstOption;
1613
+ v[1] = (_getFirstOption = getFirstOption(values)) !== null && _getFirstOption !== void 0 ? _getFirstOption : "";
1614
+ }
1615
+ return listsAsArrays ? v : joinWith(v, ",");
1616
+ };
1617
+ /**
1618
+ * Coerces a value to a `bigint`, falling back to the parsed number when it can't be represented
1619
+ * as one (an empty string or a decimal, for example).
1620
+ *
1621
+ * @group Value Editors
1622
+ */
1623
+ const coerceBigIntValue = (value, parseNumberMethod) => {
1624
+ const valAsMaybeNumber = parseNumber(value, {
1625
+ parseNumbers: parseNumberMethod,
1626
+ bigIntOnOverflow: true
1627
+ });
1628
+ try {
1629
+ return BigInt(valAsMaybeNumber);
1630
+ } catch (_unused) {
1631
+ return valAsMaybeNumber;
1632
+ }
1633
+ };
1634
+ /**
1635
+ * The `type` attribute an `<input>` should use for a rule. `bigint` values and the `in`/`notIn`
1636
+ * operators (whose value is a comma-separated list) both require a text input.
1637
+ *
1638
+ * @group Value Editors
1639
+ */
1640
+ const coerceInputType = (inputType, operator) => inputType === "bigint" || operator === "in" || operator === "notIn" ? "text" : inputType || "text";
1641
+ /**
1642
+ * Produces the next value for a value selector. Multiselect values are normalized to an array
1643
+ * first, then comma-joined unless `listsAsArrays` is `true`. Single-select values pass through.
1644
+ *
1645
+ * @group Value Editors
1646
+ */
1647
+ const getValueSelectorUpdate = (value, { multiple, listsAsArrays } = {}) => {
1648
+ if (!multiple) return value;
1649
+ const valueAsArray = toArray(value);
1650
+ return listsAsArrays ? valueAsArray : joinWith(valueAsArray, ",");
1651
+ };
1652
+ /**
1653
+ * Normalizes a value selector's current value for display. Multiselect values become an array of
1654
+ * strings so they match option names, which are always strings (e.g. `[42]` becomes `["42"]`).
1655
+ *
1656
+ * @group Value Editors
1657
+ */
1658
+ const normalizeValueSelectorValue = (value, multiple) => multiple ? toArray(value).map(String) : value;
1659
+ //#endregion
1215
1660
  //#region src/utils/transformQuery.ts
1216
1661
  const remapProperties = (obj, propertyMap, deleteRemappedProperties) => {
1217
1662
  const result = {};
@@ -1571,6 +2016,21 @@ const processMatchMode = (rule) => {
1571
2016
  };
1572
2017
  };
1573
2018
  /**
2019
+ * Base alias assigned to the element binding of a subquery generated for a rule's
2020
+ * {@link MatchMode `match` mode} (e.g. `unnest(field) as elem_alias`).
2021
+ */
2022
+ const subqueryElementAliasBase = "elem_alias";
2023
+ /**
2024
+ * Returns the element alias for a subquery at the given nesting depth. Depth 0 (the common,
2025
+ * non-nested case) uses {@link subqueryElementAliasBase} unchanged; deeper levels are suffixed
2026
+ * with the depth, so a subquery nested within a subquery cannot shadow its parent's binding.
2027
+ *
2028
+ * Deterministic by depth rather than randomized, so output remains stable and snapshot-friendly.
2029
+ *
2030
+ * @group Export
2031
+ */
2032
+ const getSubqueryElementAlias = (subqueryDepth = 0) => subqueryDepth > 0 ? `${subqueryElementAliasBase}_${subqueryDepth}` : subqueryElementAliasBase;
2033
+ /**
1574
2034
  * "Replacer" method for JSON.stringify's second argument. Converts `bigint` values to
1575
2035
  * objects with a `$bigint` property having a value of a string representation of
1576
2036
  * the actual `bigint`-type value.
@@ -1600,7 +2060,7 @@ const defaultRuleGroupProcessorCEL = (ruleGroup, options) => {
1600
2060
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1601
2061
  const processRuleGroup = (rg, outermost) => {
1602
2062
  var _rg$id;
1603
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2063
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
1604
2064
  const processedRules = [];
1605
2065
  let precedingCombinator = "";
1606
2066
  let firstRule = true;
@@ -1663,9 +2123,12 @@ const defaultRuleProcessorCEL = (rule, opts = {}) => {
1663
2123
  const matchEval = processMatchMode(rule);
1664
2124
  if (matchEval === false) return "";
1665
2125
  else if (matchEval) {
2126
+ var _opts$subqueryDepth;
1666
2127
  const { mode, threshold } = matchEval;
1667
- const arrayElementAlias = "elem_alias";
1668
- const nestedArrayFilter = defaultRuleGroupProcessorCEL(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: `${arrayElementAlias}${r.field ? `.${r.field}` : ""}` }) }), opts);
2128
+ const subqueryDepth = (_opts$subqueryDepth = opts.subqueryDepth) !== null && _opts$subqueryDepth !== void 0 ? _opts$subqueryDepth : 0;
2129
+ const arrayElementAlias = getSubqueryElementAlias(subqueryDepth);
2130
+ const celQuery = transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: `${arrayElementAlias}${r.field ? `.${r.field}` : ""}` }) });
2131
+ const nestedArrayFilter = defaultRuleGroupProcessorCEL(celQuery, _objectSpread2(_objectSpread2({}, opts), {}, { subqueryDepth: subqueryDepth + 1 }));
1669
2132
  switch (mode) {
1670
2133
  case "all": return `${field}.all(${arrayElementAlias}, ${nestedArrayFilter})`;
1671
2134
  case "none":
@@ -1740,7 +2203,7 @@ const defaultRuleGroupProcessorMongoDBQuery = (ruleGroup, options, meta) => {
1740
2203
  const { inExpressionContext } = context !== null && context !== void 0 ? context : {};
1741
2204
  const processRuleGroup = (rg, outermost) => {
1742
2205
  var _rg$id;
1743
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? mongoDbFallback : false;
2206
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? mongoDbFallback : false;
1744
2207
  const combinator = `$${lc(rg.combinator)}`;
1745
2208
  let hasChildRules = false;
1746
2209
  const expressions = rg.rules.map((rule) => {
@@ -1906,7 +2369,7 @@ const defaultRuleGroupProcessorSpEL = (ruleGroup, options) => {
1906
2369
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
1907
2370
  const processRuleGroup = (rg, outermost) => {
1908
2371
  var _rg$id;
1909
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2372
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
1910
2373
  const processedRules = [];
1911
2374
  let precedingCombinator = "";
1912
2375
  let firstRule = true;
@@ -2147,7 +2610,7 @@ const defaultRuleGroupProcessorCypher = (ruleGroup, options) => {
2147
2610
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2148
2611
  const processRuleGroup = (rg, outermost) => {
2149
2612
  var _rg$id;
2150
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2613
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2151
2614
  const processedRules = [];
2152
2615
  let precedingCombinator = "";
2153
2616
  let firstRule = true;
@@ -2212,7 +2675,7 @@ const defaultRuleGroupProcessorDrizzle = (ruleGroup, options, _meta) => (columns
2212
2675
  const { and, not, or } = drizzleOperators;
2213
2676
  const processRuleGroup = (rg, _outermost) => {
2214
2677
  var _rg$id;
2215
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return;
2678
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return;
2216
2679
  const processedRules = rg.rules.map((rule) => {
2217
2680
  if (isRuleGroup(rule)) return processRuleGroup(rule);
2218
2681
  const [validationResult, fieldValidator] = validateRule(rule);
@@ -2244,7 +2707,7 @@ const defaultRuleGroupProcessorElasticSearch = (ruleGroup, options) => {
2244
2707
  const { fields, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2245
2708
  const processRuleGroup = (rg) => {
2246
2709
  var _rg$id;
2247
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return false;
2710
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return false;
2248
2711
  const processedRules = rg.rules.map((rule) => {
2249
2712
  if (isRuleGroup(rule)) return processRuleGroup(rule);
2250
2713
  const [validationResult, fieldValidator] = validateRule(rule);
@@ -2280,7 +2743,9 @@ const defaultRuleGroupProcessorGremlin = (ruleGroup, options) => {
2280
2743
  // v8 ignore next -- @preserve
2281
2744
  if (typeof rule === "string" || isRuleGroup(rule)) return void 0;
2282
2745
  const [validationResult, fieldValidator] = validateRule(rule);
2283
- if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) || rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return;
2746
+ if (!isRuleOrGroupValid(rule, validationResult, fieldValidator) ||
2747
+ /* v8 ignore next 2 -- @preserve */
2748
+ rule.field === placeholderFieldName || rule.operator === placeholderOperatorName || placeholderValueName !== void 0 && rule.value === placeholderValueName) return;
2284
2749
  const fieldData = getOption(fields, rule.field);
2285
2750
  return ruleProcessor(rule, _objectSpread2(_objectSpread2({}, options), {}, {
2286
2751
  parseNumbers: getParseNumberBoolean(fieldData === null || fieldData === void 0 ? void 0 : fieldData.inputType),
@@ -2291,7 +2756,7 @@ const defaultRuleGroupProcessorGremlin = (ruleGroup, options) => {
2291
2756
  /** Recursively processes a nested group into `.and()`/`.or()`/`.not()` form. */
2292
2757
  const processNested = (rg) => {
2293
2758
  var _rg$id, _combinator;
2294
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return "";
2759
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return "";
2295
2760
  const predicates = [];
2296
2761
  for (const rule of rg.rules) {
2297
2762
  if (typeof rule === "string") continue;
@@ -2309,7 +2774,7 @@ const defaultRuleGroupProcessorGremlin = (ruleGroup, options) => {
2309
2774
  if (predicates.length === 1 && !rg.not) return predicates[0];
2310
2775
  return `.${prefix}(${predicates.map((p) => p.startsWith(".") ? `__${p}` : p).join(", ")})`;
2311
2776
  };
2312
- if (!isRuleOrGroupValid(ruleGroup, validationMap[(_ruleGroup$id = ruleGroup.id) !== null && _ruleGroup$id !== void 0 ? _ruleGroup$id : /* v8 ignore start -- @preserve */ ""])) return fallbackExpression;
2777
+ if (!isRuleOrGroupValid(ruleGroup, validationMap[(_ruleGroup$id = ruleGroup.id) !== null && _ruleGroup$id !== void 0 ? _ruleGroup$id : /* v8 ignore start -- @preserve */ ""])) return fallbackExpression;
2313
2778
  const steps = [];
2314
2779
  for (const rule of ruleGroup.rules) {
2315
2780
  if (typeof rule === "string") continue;
@@ -2335,7 +2800,7 @@ const defaultRuleGroupProcessorJSONata = (ruleGroup, options) => {
2335
2800
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2336
2801
  const processRuleGroup = (rg, outermost) => {
2337
2802
  var _rg$id;
2338
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2803
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2339
2804
  const processedRules = [];
2340
2805
  let precedingCombinator = "";
2341
2806
  let firstRule = true;
@@ -2392,7 +2857,7 @@ const defaultRuleGroupProcessorJsonLogic = (ruleGroup, options) => {
2392
2857
  const query = convertFromIC(ruleGroup);
2393
2858
  const processRuleGroup = (rg, _outermost) => {
2394
2859
  var _rg$id;
2395
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return false;
2860
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return false;
2396
2861
  const processedRules = rg.rules.map((rule) => {
2397
2862
  if (isRuleGroup(rule)) return processRuleGroup(rule);
2398
2863
  const [validationResult, fieldValidator] = validateRule(rule);
@@ -2420,7 +2885,7 @@ const defaultRuleGroupProcessorLDAP = (ruleGroup, options) => {
2420
2885
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2421
2886
  const processRuleGroup = (rg, outermost) => {
2422
2887
  var _rg$id;
2423
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2888
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2424
2889
  const rules = rg.rules.map((rule) => {
2425
2890
  var _rule$valueSource;
2426
2891
  if (isRuleGroup(rule)) return processRuleGroup(rule);
@@ -2454,7 +2919,7 @@ const defaultRuleGroupProcessorMongoDB = (ruleGroup, options, meta) => {
2454
2919
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2455
2920
  const processRuleGroup = (rg, outermost) => {
2456
2921
  var _rg$id;
2457
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2922
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2458
2923
  const combinator = `"$${lc(rg.combinator)}"`;
2459
2924
  let hasChildRules = false;
2460
2925
  const expressions = rg.rules.map((rule) => {
@@ -2491,7 +2956,7 @@ const defaultRuleGroupProcessorNL = (ruleGroup, options) => {
2491
2956
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, translations, validateRule, validationMap } = options;
2492
2957
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2493
2958
  var _rg$id, _rg2$combinator2, _translations$ruleSep2, _translations2;
2494
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2959
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2495
2960
  const rg2 = isRuleGroupTypeIC(rg) && rg.rules.some((r) => typeof r === "string" && lc(r) === "xor") ? convertFromIC(rg) : rg;
2496
2961
  const processedRules = [];
2497
2962
  let precedingCombinator = "";
@@ -2593,7 +3058,7 @@ const defaultRuleGroupProcessorParameterized = (ruleGroup, options) => {
2593
3058
  };
2594
3059
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2595
3060
  var _rg$id;
2596
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
3061
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2597
3062
  const processedRules = [];
2598
3063
  let precedingCombinator = "";
2599
3064
  let firstRule = true;
@@ -2654,7 +3119,7 @@ const defaultRuleGroupProcessorPrisma = (ruleGroup, options) => {
2654
3119
  const { fields, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2655
3120
  const processRuleGroup = (rg, outermost) => {
2656
3121
  var _rg$id;
2657
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? prismaFallback : void 0;
3122
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? prismaFallback : void 0;
2658
3123
  const combinator = rg.combinator.toUpperCase();
2659
3124
  let hasChildRules = false;
2660
3125
  const expressions = rg.rules.map((rule) => {
@@ -2693,7 +3158,7 @@ const defaultRuleGroupProcessorSequelize = (ruleGroup, options) => {
2693
3158
  if (!Op) return void 0;
2694
3159
  const processRuleGroup = (rg, _outermost) => {
2695
3160
  var _rg$id;
2696
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return;
3161
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return;
2697
3162
  const combinator = rg.combinator.toUpperCase();
2698
3163
  let hasChildRules = false;
2699
3164
  const expressions = rg.rules.map((rule) => {
@@ -2732,7 +3197,7 @@ const defaultRuleGroupProcessorSPARQL = (ruleGroup, options) => {
2732
3197
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2733
3198
  const processRuleGroup = (rg, outermost) => {
2734
3199
  var _rg$id;
2735
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
3200
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermost ? fallbackExpression : "";
2736
3201
  const processedRules = [];
2737
3202
  let precedingCombinator = "";
2738
3203
  let firstRule = true;
@@ -2788,7 +3253,7 @@ const defaultRuleGroupProcessorSQL = (ruleGroup, options) => {
2788
3253
  const { fields, fallbackExpression, getParseNumberBoolean, placeholderFieldName, placeholderOperatorName, placeholderValueName, ruleProcessor, validateRule, validationMap } = options;
2789
3254
  const processRuleGroup = (rg, outermostOrLonelyInGroup) => {
2790
3255
  var _rg$id;
2791
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
3256
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return outermostOrLonelyInGroup ? fallbackExpression : "";
2792
3257
  const processedRules = [];
2793
3258
  let precedingCombinator = "";
2794
3259
  let firstRule = true;
@@ -2858,7 +3323,7 @@ const defaultRuleGroupProcessorTanStackDB = (ruleGroup, options) => (refs) => {
2858
3323
  if (refKeys.length === 0) return fallback;
2859
3324
  const processRuleGroup = (rg) => {
2860
3325
  var _rg$id;
2861
- if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return;
3326
+ if (!isRuleOrGroupValid(rg, validationMap[(_rg$id = rg.id) !== null && _rg$id !== void 0 ? _rg$id : /* v8 ignore start -- @preserve */ ""])) return;
2862
3327
  const processedRules = rg.rules.map((rule) => {
2863
3328
  if (isRuleGroup(rule)) return processRuleGroup(rule);
2864
3329
  const [validationResult, fieldValidator] = validateRule(rule);
@@ -3258,7 +3723,7 @@ const defaultRuleProcessorCypher = (rule, opts = {}) => {
3258
3723
  * @group Export
3259
3724
  */
3260
3725
  const defaultRuleProcessorDrizzle = (rule, _options) => {
3261
- const opts = _options !== null && _options !== void 0 ? _options : /* v8 ignore start -- @preserve */ {};
3726
+ const opts = _options !== null && _options !== void 0 ? _options : /* v8 ignore start -- @preserve */ {};
3262
3727
  // v8 ignore next
3263
3728
  const { parseNumbers, preserveValueOrder, context = {} } = opts;
3264
3729
  const { columns, drizzleOperators, useRawFields } = context;
@@ -3277,10 +3742,16 @@ const defaultRuleProcessorDrizzle = (rule, _options) => {
3277
3742
  const matchEval = processMatchMode(rule);
3278
3743
  if (matchEval === false) return;
3279
3744
  else if (matchEval) {
3745
+ var _opts$subqueryDepth;
3280
3746
  if (opts.preset !== "postgresql") return void 0;
3281
3747
  const { mode, threshold } = matchEval;
3282
- const arrayElementAlias = "elem_alias";
3283
- const nestedArrayFilter = defaultRuleGroupProcessorDrizzle(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: arrayElementAlias }) }), _objectSpread2(_objectSpread2({}, opts), {}, { context: _objectSpread2(_objectSpread2({}, opts.context), {}, { useRawFields: true }) }));
3748
+ const subqueryDepth = (_opts$subqueryDepth = opts.subqueryDepth) !== null && _opts$subqueryDepth !== void 0 ? _opts$subqueryDepth : 0;
3749
+ const arrayElementAlias = getSubqueryElementAlias(subqueryDepth);
3750
+ const sqlQuery = transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: arrayElementAlias }) });
3751
+ const nestedArrayFilter = defaultRuleGroupProcessorDrizzle(sqlQuery, _objectSpread2(_objectSpread2({}, opts), {}, {
3752
+ context: _objectSpread2(_objectSpread2({}, opts.context), {}, { useRawFields: true }),
3753
+ subqueryDepth: subqueryDepth + 1
3754
+ }));
3284
3755
  switch (mode) {
3285
3756
  case "all": return sql`(select count(*) from unnest(${column}) as ${sql.raw(arrayElementAlias)} where ${nestedArrayFilter({}, drizzleOperators)}) = array_length(${column}, 1)`;
3286
3757
  case "none": return sql`not exists (select 1 from unnest(${column}) as ${sql.raw(arrayElementAlias)} where ${nestedArrayFilter({}, drizzleOperators)})`;
@@ -3808,7 +4279,7 @@ const defaultValueProcessorNL = (rule, opts = {}) => {
3808
4279
  const { escapeQuotes, fields, parseNumbers, quoteFieldNamesWith, quoteValuesWith, fieldIdentifierSeparator, translations } = opts;
3809
4280
  const valueIsField = rule.valueSource === "field";
3810
4281
  const operatorLowerCase = lc(rule.operator);
3811
- const quoteChar = quoteValuesWith || "'";
4282
+ const quoteChar = quoteValuesWith || /* v8 ignore start -- @preserve */ "'";
3812
4283
  const quoteValue = (v) => `${quoteChar}${v}${quoteChar}`;
3813
4284
  const escapeValue = (v) => escapeStringValueQuotes(v, quoteChar, escapeQuotes);
3814
4285
  const wrapAndEscape = (v) => quoteValue(escapeValue(v));
@@ -3816,7 +4287,7 @@ const defaultValueProcessorNL = (rule, opts = {}) => {
3816
4287
  quoteFieldNamesWith,
3817
4288
  fieldIdentifierSeparator
3818
4289
  });
3819
- const t = translations !== null && translations !== void 0 ? translations : /* v8 ignore start -- @preserve */ {};
4290
+ const t = translations !== null && translations !== void 0 ? translations : /* v8 ignore start -- @preserve */ {};
3820
4291
  const orTL = (_t$or = t.or) !== null && _t$or !== void 0 ? _t$or : "or";
3821
4292
  const trueTL = (_t$true = t.true) !== null && _t$true !== void 0 ? _t$true : "true";
3822
4293
  const falseTL = (_t$false = t.false) !== null && _t$false !== void 0 ? _t$false : "false";
@@ -3905,7 +4376,7 @@ const defaultOperatorProcessorNL = (rule, opts = {}) => {
3905
4376
  name: field,
3906
4377
  value: field,
3907
4378
  label: field
3908
- } })) !== null && _getOperators !== void 0 ? _getOperators : /* v8 ignore start -- @preserve */ []), normalizedOperator)) !== null && _getOption !== void 0 ? _getOption : {
4379
+ } })) !== null && _getOperators !== void 0 ? _getOperators : /* v8 ignore start -- @preserve */ []), normalizedOperator)) !== null && _getOption !== void 0 ? _getOption : {
3909
4380
  name: normalizedOperator,
3910
4381
  value: normalizedOperator,
3911
4382
  label: normalizedOperator
@@ -3922,7 +4393,7 @@ const defaultRuleProcessorNL = (rule, opts) => {
3922
4393
  var _fieldData$label, _opts$translations, _translations$afterSu, _translations$afterVe, _translations$afterOb;
3923
4394
  const { field, operator } = rule;
3924
4395
  // v8 ignore next
3925
- const { fieldData, quoteFieldNamesWith = ["", ""], fieldIdentifierSeparator = "", quoteValuesWith = `'`, operatorProcessor = defaultOperatorProcessorNL, valueProcessor = defaultValueProcessorNL, concatOperator = "||", wordOrder = "SVO" } = opts !== null && opts !== void 0 ? opts : /* v8 ignore start -- @preserve */ {};
4396
+ const { fieldData, quoteFieldNamesWith = ["", ""], fieldIdentifierSeparator = "", quoteValuesWith = `'`, operatorProcessor = defaultOperatorProcessorNL, valueProcessor = defaultValueProcessorNL, concatOperator = "||", wordOrder = "SVO" } = opts !== null && opts !== void 0 ? opts : /* v8 ignore start -- @preserve */ {};
3926
4397
  const processedField = getQuotedFieldName((_fieldData$label = fieldData === null || fieldData === void 0 ? void 0 : fieldData.label) !== null && _fieldData$label !== void 0 ? _fieldData$label : field, {
3927
4398
  quoteFieldNamesWith,
3928
4399
  fieldIdentifierSeparator
@@ -3992,10 +4463,12 @@ const defaultRuleProcessorSQL = (rule, opts = {}) => {
3992
4463
  const matchEval = processMatchMode(rule);
3993
4464
  if (matchEval === false) return;
3994
4465
  else if (matchEval) {
4466
+ var _opts$subqueryDepth;
3995
4467
  if ((opts === null || opts === void 0 ? void 0 : opts.preset) !== "postgresql") return "";
3996
4468
  const { mode, threshold } = matchEval;
3997
- const arrayElementAlias = "elem_alias";
3998
- const nestedArrayFilter = defaultRuleGroupProcessorSQL(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: arrayElementAlias }) }), opts);
4469
+ const subqueryDepth = (_opts$subqueryDepth = opts.subqueryDepth) !== null && _opts$subqueryDepth !== void 0 ? _opts$subqueryDepth : 0;
4470
+ const arrayElementAlias = getSubqueryElementAlias(subqueryDepth);
4471
+ const nestedArrayFilter = defaultRuleGroupProcessorSQL(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: arrayElementAlias }) }), _objectSpread2(_objectSpread2({}, opts), {}, { subqueryDepth: subqueryDepth + 1 }));
3999
4472
  switch (mode) {
4000
4473
  case "all": return `(select count(*) from unnest(${ruleField}) as ${wrapFieldName(arrayElementAlias)} where ${nestedArrayFilter}) = array_length(${ruleField}, 1)`;
4001
4474
  case "none": return `not exists (select 1 from unnest(${ruleField}) as ${wrapFieldName(arrayElementAlias)} where ${nestedArrayFilter})`;
@@ -4050,10 +4523,15 @@ const defaultRuleProcessorParameterized = (rule, opts, meta) => {
4050
4523
  /* v8 ignore start -- @preserve */
4051
4524
  if (matchEval === false) return;
4052
4525
  else if (matchEval) {
4526
+ var _opts$subqueryDepth;
4053
4527
  if ((opts === null || opts === void 0 ? void 0 : opts.preset) !== "postgresql") return finalize("");
4054
4528
  const { mode, threshold } = matchEval;
4055
- const arrayElementAlias = "elem_alias";
4056
- const { sql: nestedSQL, params: nestedParams } = defaultRuleGroupProcessorParameterized(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: arrayElementAlias }) }), _objectSpread2(_objectSpread2({}, opts), {}, { fields: [] }));
4529
+ const subqueryDepth = (_opts$subqueryDepth = opts.subqueryDepth) !== null && _opts$subqueryDepth !== void 0 ? _opts$subqueryDepth : 0;
4530
+ const arrayElementAlias = getSubqueryElementAlias(subqueryDepth);
4531
+ const { sql: nestedSQL, params: nestedParams } = defaultRuleGroupProcessorParameterized(transformQuery(rule.value, { ruleProcessor: (r) => _objectSpread2(_objectSpread2({}, r), {}, { field: arrayElementAlias }) }), _objectSpread2(_objectSpread2({}, opts), {}, {
4532
+ fields: [],
4533
+ subqueryDepth: subqueryDepth + 1
4534
+ }));
4057
4535
  if (Array.isArray(nestedParams)) params.push(...nestedParams);
4058
4536
  else Object.assign(paramsNamed, nestedParams);
4059
4537
  switch (mode) {
@@ -4124,7 +4602,7 @@ const defaultRuleProcessorParameterized = (rule, opts, meta) => {
4124
4602
  }
4125
4603
  let paramValue = rule.value;
4126
4604
  if (typeof rule.value === "string") if (shouldRenderAsNumber(rule.value, parseNumbers)) paramValue = parseNumber(rule.value, { parseNumbers });
4127
- else paramValue = /^'.*'$/g.test(value) ? value.replaceAll(/(^'|'$)/g, "") : /* v8 ignore next -- @preserve */ value;
4605
+ else paramValue = /^'.*'$/g.test(value) ? value.replaceAll(/(^'|'$)/g, "") : /* v8 ignore next -- @preserve */ value;
4128
4606
  let paramName = "";
4129
4607
  if (parameterized) params.push(paramValue);
4130
4608
  else {
@@ -4342,7 +4820,7 @@ const defaultRuleProcessorSPARQL = (rule, opts = {}) => {
4342
4820
  * @group Export
4343
4821
  */
4344
4822
  const defaultRuleProcessorTanStackDB = (rule, _options) => {
4345
- const { parseNumbers, preserveValueOrder, context = {} } = _options !== null && _options !== void 0 ? _options : /* v8 ignore start -- @preserve */ {};
4823
+ const { parseNumbers, preserveValueOrder, context = {} } = _options !== null && _options !== void 0 ? _options : /* v8 ignore start -- @preserve */ {};
4346
4824
  const ops = context.tanStackDbOperators;
4347
4825
  const refs = context._tanstackDbRefs;
4348
4826
  const primaryRef = context._tanstackDbPrimaryRef;
@@ -4603,7 +5081,7 @@ function formatQuery(ruleGroup, optionParam = {}) {
4603
5081
  // v8 ignore else
4604
5082
  if (typeof f.validator === "function") {
4605
5083
  var _f$value;
4606
- validatorMap[(_f$value = f.value) !== null && _f$value !== void 0 ? _f$value : /* v8 ignore start -- @preserve */ f.name] = f.validator;
5084
+ validatorMap[(_f$value = f.value) !== null && _f$value !== void 0 ? _f$value : /* v8 ignore start -- @preserve */ f.name] = f.validator;
4607
5085
  }
4608
5086
  const validateRule = (rule) => {
4609
5087
  let validationResult;
@@ -4774,12 +5252,20 @@ const getParentPath = (path) => path.slice(0, -1);
4774
5252
  /**
4775
5253
  * Determines if two paths (each `Path`) are equivalent.
4776
5254
  */
4777
- const pathsAreEqual = (path1, path2) => path1.length === path2.length && path1.every((val, idx) => val === path2[idx]);
5255
+ const pathsAreEqual = (path1, path2) => {
5256
+ if (path1.length !== path2.length) return false;
5257
+ for (let i = 0; i < path1.length; i++) if (path1[i] !== path2[i]) return false;
5258
+ return true;
5259
+ };
4778
5260
  /**
4779
5261
  * Determines if the first path is an ancestor of the second path. The first path must
4780
5262
  * be shorter and exactly match the second path up through the length of the first path.
4781
5263
  */
4782
- const isAncestor = (maybeAncestor, path) => maybeAncestor.length < path.length && new RegExp(`^${maybeAncestor.join("-")}`).test(path.join("-"));
5264
+ const isAncestor = (maybeAncestor, path) => {
5265
+ if (maybeAncestor.length >= path.length) return false;
5266
+ for (let i = 0; i < maybeAncestor.length; i++) if (maybeAncestor[i] !== path[i]) return false;
5267
+ return true;
5268
+ };
4783
5269
  /**
4784
5270
  * Finds the deepest/longest path that two paths have in common.
4785
5271
  */
@@ -4812,11 +5298,38 @@ const pathIsDisabled = (path, query) => {
4812
5298
  }
4813
5299
  return disabled;
4814
5300
  };
5301
+ /**
5302
+ * Determines if the rule or group at the specified path is disabled by `disabledPaths`—the array
5303
+ * form of the `QueryBuilder` `disabled` prop, which disables nodes by position rather than by a
5304
+ * `disabled` property on the node itself. A path is disabled if it appears in `disabledPaths` or
5305
+ * descends from a path that does.
5306
+ *
5307
+ * @group Paths
5308
+ */
5309
+ const pathIsDisabledByPaths = (path, disabledPaths = []) => disabledPaths.some((p) => pathsAreEqual(p, path) || isAncestor(p, path));
5310
+ /**
5311
+ * Builds the {@link PathInfo} for each child of a group at `path`. A child is disabled if its
5312
+ * parent is disabled or if its own path appears in `disabledPaths`.
5313
+ *
5314
+ * @group Paths
5315
+ */
5316
+ const derivePathInfo = (path, childCount, { disabled = false, disabledPaths = [] } = {}) => {
5317
+ const paths = [];
5318
+ for (let i = 0; i < childCount; i++) {
5319
+ const thisPath = [...path, i];
5320
+ paths[i] = {
5321
+ path: thisPath,
5322
+ disabled: disabled || disabledPaths.some((p) => pathsAreEqual(thisPath, p))
5323
+ };
5324
+ }
5325
+ return paths;
5326
+ };
4815
5327
  //#endregion
4816
5328
  //#region src/utils/generateAccessibleDescription.ts
4817
5329
  const generateAccessibleDescription = (params) => pathsAreEqual([], params.path) ? `Query builder` : `Rule group at path ${params.path.join("-")}`;
4818
5330
  //#endregion
4819
5331
  //#region src/utils/generateID.ts
5332
+ /* v8 ignore file -- this is fine */
4820
5333
  const cryptoModule = globalThis.crypto;
4821
5334
  const uuidV4regex = /^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i;
4822
5335
  /**
@@ -4866,7 +5379,7 @@ const dummyFD$1 = {
4866
5379
  */
4867
5380
  const getMatchModesUtil = (fieldData, getMatchModes) => {
4868
5381
  var _fd$matchModes, _matchModes$map;
4869
- const fd = fieldData ? toFullOption(fieldData) : /* v8 ignore next -- @preserve */ dummyFD$1;
5382
+ const fd = fieldData ? toFullOption(fieldData) : /* v8 ignore next -- @preserve */ dummyFD$1;
4870
5383
  let matchModes = (_fd$matchModes = fd.matchModes) !== null && _fd$matchModes !== void 0 ? _fd$matchModes : false;
4871
5384
  if (!matchModes && getMatchModes) matchModes = getMatchModes(fd.value, { fieldData: fd });
4872
5385
  if (matchModes === true) return defaultMatchModes;
@@ -4887,7 +5400,7 @@ const getFirstOptionsFrom = (opts, r, listsAsArrays) => {
4887
5400
  const firstOption = getFirstOption(opts);
4888
5401
  if (r.operator === "between" || r.operator === "notBetween") {
4889
5402
  const valueAsArray = [firstOption, firstOption];
4890
- return listsAsArrays ? valueAsArray : joinWith(valueAsArray.map((v) => v !== null && v !== void 0 ? v : /* v8 ignore start -- @preserve */ ""), ",");
5403
+ return listsAsArrays ? valueAsArray : joinWith(valueAsArray.map((v) => v !== null && v !== void 0 ? v : /* v8 ignore start -- @preserve */ ""), ",");
4891
5404
  }
4892
5405
  return firstOption;
4893
5406
  };
@@ -5029,6 +5542,9 @@ const mergeClassnames = (...args) => ({
5029
5542
  removeRule: joinClassnamesByName("removeRule", args),
5030
5543
  notToggle: joinClassnamesByName("notToggle", args),
5031
5544
  shiftActions: joinClassnamesByName("shiftActions", args),
5545
+ undoRedoActions: joinClassnamesByName("undoRedoActions", args),
5546
+ undoAction: joinClassnamesByName("undoAction", args),
5547
+ redoAction: joinClassnamesByName("redoAction", args),
5032
5548
  dragHandle: joinClassnamesByName("dragHandle", args),
5033
5549
  lockRule: joinClassnamesByName("lockRule", args),
5034
5550
  lockGroup: joinClassnamesByName("lockGroup", args),
@@ -5058,6 +5574,66 @@ const mergeClassnames = (...args) => ({
5058
5574
  valueDateTimeRelative: joinClassnamesByName("valueDateTimeRelative", args)
5059
5575
  });
5060
5576
  //#endregion
5577
+ //#region src/utils/optionResolvers.ts
5578
+ /**
5579
+ * Resolves the operator list for a field, applying the same precedence as the `QueryBuilder`
5580
+ * component: the field's own `operators`, then the `getOperators` callback, then the
5581
+ * query-level operator list.
5582
+ *
5583
+ * @group Option Lists
5584
+ */
5585
+ const resolveOperatorList = ({ field, fieldData, getOperators, operators, placeholder, baseOption, autoSelectOption }) => {
5586
+ var _ref, _fieldData$operators;
5587
+ return prepareOptionList({
5588
+ optionList: (_ref = (_fieldData$operators = fieldData === null || fieldData === void 0 ? void 0 : fieldData.operators) !== null && _fieldData$operators !== void 0 ? _fieldData$operators : getOperators === null || getOperators === void 0 ? void 0 : getOperators(field, { fieldData })) !== null && _ref !== void 0 ? _ref : operators,
5589
+ placeholder,
5590
+ baseOption,
5591
+ labelMap: defaultOperatorLabelMap,
5592
+ autoSelectOption
5593
+ }).optionList;
5594
+ };
5595
+ /**
5596
+ * Resolves the default operator for a field, applying the same precedence as the `QueryBuilder`
5597
+ * component: the field's own `defaultOperator`, then the `getDefaultOperator` option (a string or
5598
+ * a function), then the first available operator.
5599
+ *
5600
+ * @group Option Lists
5601
+ */
5602
+ const resolveDefaultOperator = ({ field, fieldData, getDefaultOperator, getOperators }) => {
5603
+ var _getFirstOption;
5604
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.defaultOperator) return fieldData.defaultOperator;
5605
+ if (getDefaultOperator) return typeof getDefaultOperator === "function" ? getDefaultOperator(field, { fieldData }) : getDefaultOperator;
5606
+ return (_getFirstOption = getFirstOption(getOperators(field, { fieldData }))) !== null && _getFirstOption !== void 0 ? _getFirstOption : "";
5607
+ };
5608
+ /**
5609
+ * Resolves the value editor type for a field/operator pair, applying the same precedence as the
5610
+ * `QueryBuilder` component: the field's own `valueEditorType` (a string or a function of the
5611
+ * operator), then the `getValueEditorType` callback, then `"text"`.
5612
+ *
5613
+ * @group Option Lists
5614
+ */
5615
+ const resolveValueEditorType = ({ field, operator, fieldData, getValueEditorType }) => {
5616
+ var _getValueEditorType;
5617
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.valueEditorType) return typeof fieldData.valueEditorType === "function" ? fieldData.valueEditorType(operator) : fieldData.valueEditorType;
5618
+ return (_getValueEditorType = getValueEditorType === null || getValueEditorType === void 0 ? void 0 : getValueEditorType(field, operator, { fieldData })) !== null && _getValueEditorType !== void 0 ? _getValueEditorType : "text";
5619
+ };
5620
+ /**
5621
+ * Resolves the value option list for a field/operator pair, applying the same precedence as the
5622
+ * `QueryBuilder` component: the field's own `values`, then the `getValues` callback, then an
5623
+ * empty list.
5624
+ *
5625
+ * @group Option Lists
5626
+ */
5627
+ const resolveValueList = ({ field, operator, fieldData, getValues, placeholder, baseOption, autoSelectOption }) => {
5628
+ var _ref2, _fieldData$values;
5629
+ return prepareOptionList({
5630
+ optionList: (_ref2 = (_fieldData$values = fieldData === null || fieldData === void 0 ? void 0 : fieldData.values) !== null && _fieldData$values !== void 0 ? _fieldData$values : getValues === null || getValues === void 0 ? void 0 : getValues(field, operator, { fieldData })) !== null && _ref2 !== void 0 ? _ref2 : [],
5631
+ placeholder,
5632
+ baseOption,
5633
+ autoSelectOption
5634
+ }).optionList;
5635
+ };
5636
+ //#endregion
5061
5637
  //#region src/utils/preferProp.ts
5062
5638
  const preferPropDefaultTrue = (prop, context) => prop === false ? false : prop ? true : !(context === false);
5063
5639
  const preferPropDefaultFalse = (prop, context) => prop ? true : prop === false ? false : !!context;
@@ -5114,6 +5690,22 @@ const prepareRuleGroup = (queryObject, { idGenerator = generateID } = {}) => {
5114
5690
  * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.
5115
5691
  */
5116
5692
  const prepareRuleOrGroup = (rg, { idGenerator = generateID } = {}) => isRuleGroup(rg) ? prepareRuleGroup(rg, { idGenerator }) : prepareRule(rg, { idGenerator });
5693
+ /**
5694
+ * Resolves the query a query builder should render from the available sources, in precedence
5695
+ * order: the controlled `query`, then whatever is already in the store, then the uncontrolled
5696
+ * `defaultQuery`, then a freshly created empty group.
5697
+ *
5698
+ * The result is prepared with {@link prepareRuleGroup} unless it already has an `id`, which is
5699
+ * taken to mean it has been prepared before—most often because the caller is passing back the
5700
+ * object it received from `onQueryChange`.
5701
+ *
5702
+ * @group Query Tools
5703
+ */
5704
+ const resolveCandidateQuery = (sources, options) => {
5705
+ var _ref, _ref2, _sources$query;
5706
+ const candidateQuery = (_ref = (_ref2 = (_sources$query = sources.query) !== null && _sources$query !== void 0 ? _sources$query : sources.storeQuery) !== null && _ref2 !== void 0 ? _ref2 : sources.defaultQuery) !== null && _ref !== void 0 ? _ref : sources.fallbackQuery;
5707
+ return candidateQuery.id ? candidateQuery : prepareRuleGroup(candidateQuery, options);
5708
+ };
5117
5709
  //#endregion
5118
5710
  //#region src/utils/regenerateIDs.ts
5119
5711
  /**
@@ -5134,6 +5726,28 @@ const regenerateIDs = (subject, { idGenerator = generateID } = {}) => {
5134
5726
  //#endregion
5135
5727
  //#region src/utils/queryTools.ts
5136
5728
  /**
5729
+ * Whether a mutation targeting `pathOrID` is blocked by the given guards, and why.
5730
+ * Returns `null` when the mutation may proceed.
5731
+ *
5732
+ * Exported so that callers which run their own logic before mutating—such as a UI layer that
5733
+ * invokes a confirmation callback—can apply the same rules without duplicating them.
5734
+ *
5735
+ * @group Query Tools
5736
+ */
5737
+ const getGuardAbortReason = (query, pathOrID, guards = {}, { asParent = false } = {}) => {
5738
+ if (guards.queryDisabled) return asParent ? "parent-disabled" : "target-disabled";
5739
+ if (!guards.respectDisabled || pathOrID === void 0) return null;
5740
+ const path = Array.isArray(pathOrID) ? pathOrID : getPathOfID(pathOrID, query);
5741
+ if (path && (pathIsDisabled(path, query) || pathIsDisabledByPaths(path, guards.disabledPaths))) return asParent ? "parent-disabled" : "target-disabled";
5742
+ return null;
5743
+ };
5744
+ /**
5745
+ * Whether adding a group beneath `parentPath` would exceed `maxLevels`.
5746
+ *
5747
+ * @group Query Tools
5748
+ */
5749
+ const exceedsMaxLevels = (parentPath, { maxLevels = Infinity } = {}) => !!parentPath && parentPath.length >= maxLevels;
5750
+ /**
5137
5751
  * Adds a rule or group to a query without mutating the original query.
5138
5752
  *
5139
5753
  * @returns A new query with the rule or group added.
@@ -5149,9 +5763,42 @@ const add = (query, ruleOrGroup, parentPathOrID, options = {}) => produce(query,
5149
5763
  * @group Query Tools
5150
5764
  */
5151
5765
  const addInPlace = (query, ruleOrGroup, parentPathOrID, options = {}) => {
5152
- const { combinators = defaultCombinators, combinatorPreceding, idGenerator = generateID } = options;
5766
+ const { combinators = defaultCombinators, combinatorPreceding, idGenerator = generateID, onAbort } = options;
5153
5767
  const parent = Array.isArray(parentPathOrID) ? findPath(parentPathOrID, query) : findID(parentPathOrID, query);
5154
- if (!parent || !isRuleGroup(parent)) return query;
5768
+ if (!parent) {
5769
+ onAbort === null || onAbort === void 0 || onAbort({
5770
+ reason: "parent-not-found",
5771
+ operation: "add",
5772
+ pathOrID: parentPathOrID
5773
+ });
5774
+ return query;
5775
+ }
5776
+ if (!isRuleGroup(parent)) {
5777
+ onAbort === null || onAbort === void 0 || onAbort({
5778
+ reason: "parent-not-a-group",
5779
+ operation: "add",
5780
+ pathOrID: parentPathOrID
5781
+ });
5782
+ return query;
5783
+ }
5784
+ const parentPath = Array.isArray(parentPathOrID) ? parentPathOrID : getPathOfID(parentPathOrID, query);
5785
+ const addGuardReason = getGuardAbortReason(query, parentPath, options, { asParent: true });
5786
+ if (addGuardReason) {
5787
+ onAbort === null || onAbort === void 0 || onAbort({
5788
+ reason: addGuardReason,
5789
+ operation: "add",
5790
+ pathOrID: parentPathOrID
5791
+ });
5792
+ return query;
5793
+ }
5794
+ if (isRuleGroup(ruleOrGroup) && exceedsMaxLevels(parentPath, options)) {
5795
+ onAbort === null || onAbort === void 0 || onAbort({
5796
+ reason: "max-levels-exceeded",
5797
+ operation: "add",
5798
+ pathOrID: parentPathOrID
5799
+ });
5800
+ return query;
5801
+ }
5155
5802
  if (isRuleGroupTypeIC(parent) && parent.rules.length > 0) {
5156
5803
  const prevCombinator = parent.rules.at(-2);
5157
5804
  parent.rules.push(combinatorPreceding !== null && combinatorPreceding !== void 0 ? combinatorPreceding : typeof prevCombinator === "string" ? prevCombinator : getFirstOption(combinators));
@@ -5172,7 +5819,7 @@ const updatePropRank = {
5172
5819
  value: 4
5173
5820
  };
5174
5821
  /** Stable-sorts `[prop, value]` entries by {@link updatePropRank}. */
5175
- const orderUpdateEntries = (entries) => entries.sort((x, y) => {
5822
+ const orderUpdateEntries = (entries) => entries.toSorted((x, y) => {
5176
5823
  var _updatePropRank$x$, _updatePropRank$y$;
5177
5824
  return ((_updatePropRank$x$ = updatePropRank[x[0]]) !== null && _updatePropRank$x$ !== void 0 ? _updatePropRank$x$ : 3) - ((_updatePropRank$y$ = updatePropRank[y[0]]) !== null && _updatePropRank$y$ !== void 0 ? _updatePropRank$y$ : 3);
5178
5825
  });
@@ -5243,19 +5890,69 @@ const updateInPlace = ((query, a, b, c, d) => applyUpdatesInPlace(query, a, b, c
5243
5890
  * Updates a single property of a rule or group within a query in place.
5244
5891
  */
5245
5892
  const updateInPlaceSingle = (query, prop, value, pathOrID, options = {}) => {
5246
- const { resetOnFieldChange: _resetOnFieldChange = true, resetOnOperatorChange = false, getRuleDefaultOperator = () => "=", getValueSources = () => ["value"], getRuleDefaultValue = () => "", getMatchModes = () => [] } = options;
5893
+ const { resetOnFieldChange: _resetOnFieldChange = true, resetOnOperatorChange = false, getRuleDefaultOperator = () => "=", getValueSources = () => ["value"], getRuleDefaultValue = () => "", getMatchModes = () => [], onAbort } = options;
5247
5894
  let resetOnFieldChange = _resetOnFieldChange;
5248
5895
  const path = Array.isArray(pathOrID) ? pathOrID : getPathOfID(pathOrID, query);
5249
- if (!path) return query;
5896
+ if (!path) {
5897
+ onAbort === null || onAbort === void 0 || onAbort({
5898
+ reason: "target-not-found",
5899
+ operation: "update",
5900
+ pathOrID
5901
+ });
5902
+ return query;
5903
+ }
5904
+ const updateGuards = prop === "disabled" ? { queryDisabled: options.queryDisabled } : options;
5905
+ const updateGuardReason = getGuardAbortReason(query, path, updateGuards);
5906
+ if (updateGuardReason) {
5907
+ onAbort === null || onAbort === void 0 || onAbort({
5908
+ reason: updateGuardReason,
5909
+ operation: "update",
5910
+ pathOrID
5911
+ });
5912
+ return query;
5913
+ }
5250
5914
  if (prop === "combinator" && !isRuleGroupType(query)) {
5251
- const parentRules = findPath(getParentPath(path), query).rules;
5252
- if (path.at(-1) % 2 === 1) parentRules[path.at(-1)] = value;
5915
+ const parent = findPath(getParentPath(path), query);
5916
+ if (!parent || !isRuleGroup(parent)) {
5917
+ onAbort === null || onAbort === void 0 || onAbort({
5918
+ reason: "target-not-found",
5919
+ operation: "update",
5920
+ pathOrID
5921
+ });
5922
+ return query;
5923
+ }
5924
+ const parentRules = parent.rules;
5925
+ if (path.at(-1) % 2 === 1) if (parentRules[path.at(-1)] === value) onAbort === null || onAbort === void 0 || onAbort({
5926
+ reason: "no-change",
5927
+ operation: "update",
5928
+ pathOrID
5929
+ });
5930
+ else parentRules[path.at(-1)] = value;
5931
+ else onAbort === null || onAbort === void 0 || onAbort({
5932
+ reason: "not-a-combinator-slot",
5933
+ operation: "update",
5934
+ pathOrID
5935
+ });
5253
5936
  return query;
5254
5937
  }
5255
5938
  const ruleOrGroup = findPath(path, query);
5256
- if (!ruleOrGroup) return query;
5939
+ if (!ruleOrGroup) {
5940
+ onAbort === null || onAbort === void 0 || onAbort({
5941
+ reason: "target-not-found",
5942
+ operation: "update",
5943
+ pathOrID
5944
+ });
5945
+ return query;
5946
+ }
5257
5947
  const isGroup = isRuleGroup(ruleOrGroup);
5258
- if (ruleOrGroup[prop] === value) return query;
5948
+ if (ruleOrGroup[prop] === value) {
5949
+ onAbort === null || onAbort === void 0 || onAbort({
5950
+ reason: "no-change",
5951
+ operation: "update",
5952
+ pathOrID
5953
+ });
5954
+ return query;
5955
+ }
5259
5956
  if (prop !== "valueSource") ruleOrGroup[prop] = value;
5260
5957
  if (isGroup) return query;
5261
5958
  let resetValueSource = false;
@@ -5302,7 +5999,7 @@ const updateInPlaceSingle = (query, prop, value, pathOrID, options = {}) => {
5302
5999
  *
5303
6000
  * @group Query Tools
5304
6001
  */
5305
- const remove = (query, pathOrID) => produce(query, (q) => removeInPlace(q, pathOrID));
6002
+ const remove = (query, pathOrID, options = {}) => produce(query, (q) => removeInPlace(q, pathOrID, options));
5306
6003
  /**
5307
6004
  * Removes a rule or group from a query in place.
5308
6005
  *
@@ -5310,20 +6007,53 @@ const remove = (query, pathOrID) => produce(query, (q) => removeInPlace(q, pathO
5310
6007
  *
5311
6008
  * @group Query Tools
5312
6009
  */
5313
- const removeInPlace = (query, pathOrID) => {
6010
+ const removeInPlace = (query, pathOrID, options = {}) => {
6011
+ const { onAbort } = options;
5314
6012
  const path = Array.isArray(pathOrID) ? pathOrID : getPathOfID(pathOrID, query);
5315
- if (!path || path.length === 0 || !isRuleGroupType(query) && !findPath(path, query)) return query;
5316
- const index = path.at(-1);
5317
- const parent = findPath(getParentPath(path), query);
5318
- if (parent && isRuleGroup(parent)) if (!isRuleGroupType(parent) && parent.rules.length > 1) {
5319
- const idxStartDelete = index === 0 ? 0 : index - 1;
5320
- parent.rules.splice(idxStartDelete, 2);
5321
- } else parent.rules.splice(index, 1);
5322
- return query;
5323
- };
5324
- const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
5325
- if (Array.isArray(newPathOrShiftDirection)) return newPathOrShiftDirection;
5326
- const ic = isRuleGroupTypeIC(query);
6013
+ if (!path) {
6014
+ onAbort === null || onAbort === void 0 || onAbort({
6015
+ reason: "target-not-found",
6016
+ operation: "remove",
6017
+ pathOrID
6018
+ });
6019
+ return query;
6020
+ }
6021
+ if (path.length === 0) {
6022
+ onAbort === null || onAbort === void 0 || onAbort({
6023
+ reason: "root-not-allowed",
6024
+ operation: "remove",
6025
+ pathOrID
6026
+ });
6027
+ return query;
6028
+ }
6029
+ const removeGuardReason = getGuardAbortReason(query, path, options);
6030
+ if (removeGuardReason) {
6031
+ onAbort === null || onAbort === void 0 || onAbort({
6032
+ reason: removeGuardReason,
6033
+ operation: "remove",
6034
+ pathOrID
6035
+ });
6036
+ return query;
6037
+ }
6038
+ if (!findPath(path, query)) {
6039
+ onAbort === null || onAbort === void 0 || onAbort({
6040
+ reason: "target-not-found",
6041
+ operation: "remove",
6042
+ pathOrID
6043
+ });
6044
+ return query;
6045
+ }
6046
+ const index = path.at(-1);
6047
+ const parent = findPath(getParentPath(path), query);
6048
+ if (!isRuleGroupType(parent) && parent.rules.length > 1) {
6049
+ const idxStartDelete = index === 0 ? 0 : index - 1;
6050
+ parent.rules.splice(idxStartDelete, 2);
6051
+ } else parent.rules.splice(index, 1);
6052
+ return query;
6053
+ };
6054
+ const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
6055
+ if (Array.isArray(newPathOrShiftDirection)) return newPathOrShiftDirection;
6056
+ const ic = isRuleGroupTypeIC(query);
5327
6057
  if (newPathOrShiftDirection === "up") if (pathsAreEqual(currentPath, [0])) return currentPath;
5328
6058
  else if (currentPath.at(-1) === 0) {
5329
6059
  const parentPath = getParentPath(currentPath);
@@ -5340,7 +6070,8 @@ const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
5340
6070
  return [...getParentPath(parentPath), parentPath.at(-1) + 1];
5341
6071
  } else {
5342
6072
  const evaluationPath = [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 2 : 1)];
5343
- if (isRuleGroup(findPath(evaluationPath, query))) return [...evaluationPath, 0];
6073
+ const entityToEvaluate = findPath(evaluationPath, query);
6074
+ if (isRuleGroup(entityToEvaluate)) return [...evaluationPath, 0];
5344
6075
  else return [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 3 : 2)];
5345
6076
  }
5346
6077
  return currentPath;
@@ -5363,13 +6094,67 @@ const move = (query, oldPathOrID, newPath, options = {}) => produce(query, (q) =
5363
6094
  * @group Query Tools
5364
6095
  */
5365
6096
  const moveInPlace = (query, oldPathOrID, newPath, options = {}) => {
5366
- const { clone = false, combinators = defaultCombinators, idGenerator = generateID } = options;
6097
+ const { clone = false, combinators = defaultCombinators, idGenerator = generateID, onAbort } = options;
5367
6098
  const oldPath = Array.isArray(oldPathOrID) ? oldPathOrID : getPathOfID(oldPathOrID, query);
5368
- if (!oldPath) return query;
5369
- const nextPath = getNextPath(query, oldPath, newPath);
5370
- if (oldPath.length === 0 || pathsAreEqual(oldPath, nextPath) || !findPath(getParentPath(nextPath), query)) return query;
6099
+ if (!oldPath) {
6100
+ onAbort === null || onAbort === void 0 || onAbort({
6101
+ reason: "target-not-found",
6102
+ operation: "move",
6103
+ pathOrID: oldPathOrID
6104
+ });
6105
+ return query;
6106
+ }
5371
6107
  const ruleOrGroupOriginal = findPath(oldPath, query);
5372
- if (!ruleOrGroupOriginal) return query;
6108
+ if (!ruleOrGroupOriginal) {
6109
+ onAbort === null || onAbort === void 0 || onAbort({
6110
+ reason: "target-not-found",
6111
+ operation: "move",
6112
+ pathOrID: oldPathOrID
6113
+ });
6114
+ return query;
6115
+ }
6116
+ const nextPath = getNextPath(query, oldPath, newPath);
6117
+ if (oldPath.length === 0) {
6118
+ onAbort === null || onAbort === void 0 || onAbort({
6119
+ reason: "root-not-allowed",
6120
+ operation: "move",
6121
+ pathOrID: oldPathOrID
6122
+ });
6123
+ return query;
6124
+ }
6125
+ const moveGuardReason = getGuardAbortReason(query, oldPath, options);
6126
+ if (moveGuardReason) {
6127
+ onAbort === null || onAbort === void 0 || onAbort({
6128
+ reason: moveGuardReason,
6129
+ operation: "move",
6130
+ pathOrID: oldPathOrID
6131
+ });
6132
+ return query;
6133
+ }
6134
+ if (pathsAreEqual(oldPath, nextPath)) {
6135
+ onAbort === null || onAbort === void 0 || onAbort({
6136
+ reason: "same-location",
6137
+ operation: "move",
6138
+ pathOrID: oldPathOrID
6139
+ });
6140
+ return query;
6141
+ }
6142
+ if (!findPath(getParentPath(nextPath), query)) {
6143
+ onAbort === null || onAbort === void 0 || onAbort({
6144
+ reason: "destination-not-found",
6145
+ operation: "move",
6146
+ pathOrID: newPath
6147
+ });
6148
+ return query;
6149
+ }
6150
+ if (!clone && isAncestor(oldPath, nextPath)) {
6151
+ onAbort === null || onAbort === void 0 || onAbort({
6152
+ reason: "destination-not-found",
6153
+ operation: "move",
6154
+ pathOrID: newPath
6155
+ });
6156
+ return query;
6157
+ }
5373
6158
  const ruleOrGroup = clone ? regenerateIDs(isDraft(ruleOrGroupOriginal) ? current(ruleOrGroupOriginal) : ruleOrGroupOriginal, { idGenerator }) : ruleOrGroupOriginal;
5374
6159
  const independentCombinators = isRuleGroupTypeIC(query);
5375
6160
  const parentOfRuleToRemove = findPath(getParentPath(oldPath), query);
@@ -5382,15 +6167,18 @@ const moveInPlace = (query, oldPathOrID, newPath, options = {}) => {
5382
6167
  parentOfRuleToRemove.rules.splice(idxStartDelete, deleteLength);
5383
6168
  }
5384
6169
  const newNewPath = [...nextPath];
6170
+ if (independentCombinators && newNewPath.at(-1) % 2 === 1) newNewPath[newNewPath.length - 1] += 1;
5385
6171
  const commonAncestorPath = getCommonAncestorPath(oldPath, nextPath);
5386
- if (!clone && oldPath.length === commonAncestorPath.length + 1 && nextPath[commonAncestorPath.length] > oldPath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
5387
- const parentToInsertInto = findPath(getParentPath(newNewPath), query);
6172
+ if (!clone && oldPath.length === commonAncestorPath.length + 1 && newNewPath[commonAncestorPath.length] > oldPath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
6173
+ const newNewParentPath = getParentPath(newNewPath);
6174
+ const parentToInsertInto = findPath(newNewParentPath, query);
5388
6175
  const newIndex = newNewPath.at(-1);
6176
+ const spliceIndex = independentCombinators && newIndex > 0 ? newIndex - 1 : newIndex;
5389
6177
  /**
5390
6178
  * This function 1) glosses over the need for type assertions to splice directly
5391
6179
  * into `parentToInsertInto.rules`, and 2) shortens the actual insertion code.
5392
6180
  */
5393
- const insertRuleOrGroup = (...args) => parentToInsertInto.rules.splice(newIndex, 0, ...args);
6181
+ const insertRuleOrGroup = (...args) => parentToInsertInto.rules.splice(spliceIndex, 0, ...args);
5394
6182
  if (parentToInsertInto.rules.length === 0 || !independentCombinators) insertRuleOrGroup(ruleOrGroup);
5395
6183
  else if (newIndex === 0) if (ruleToRemoveIndex === 0 && oldNextCombinator) insertRuleOrGroup(ruleOrGroup, oldNextCombinator);
5396
6184
  else {
@@ -5400,7 +6188,7 @@ const moveInPlace = (query, oldPathOrID, newPath, options = {}) => {
5400
6188
  else if (oldPrevCombinator) insertRuleOrGroup(oldPrevCombinator, ruleOrGroup);
5401
6189
  else {
5402
6190
  var _ref5, _parentToInsertInto$r2;
5403
- insertRuleOrGroup((_ref5 = (_parentToInsertInto$r2 = parentToInsertInto.rules[newIndex - 2]) !== null && _parentToInsertInto$r2 !== void 0 ? _parentToInsertInto$r2 : oldNextCombinator) !== null && _ref5 !== void 0 ? _ref5 : getFirstOption(combinators), ruleOrGroup);
6191
+ insertRuleOrGroup((_ref5 = (_parentToInsertInto$r2 = parentToInsertInto.rules[spliceIndex - 2]) !== null && _parentToInsertInto$r2 !== void 0 ? _parentToInsertInto$r2 : oldNextCombinator) !== null && _ref5 !== void 0 ? _ref5 : getFirstOption(combinators), ruleOrGroup);
5404
6192
  }
5405
6193
  return query;
5406
6194
  };
@@ -5420,9 +6208,42 @@ const insert = (query, ruleOrGroup, path, options = {}) => produce(query, (q) =>
5420
6208
  * @group Query Tools
5421
6209
  */
5422
6210
  const insertInPlace = (query, ruleOrGroup, path, options = {}) => {
5423
- const { combinators = defaultCombinators, combinatorPreceding, combinatorSucceeding, idGenerator = generateID, replace = false } = options;
6211
+ const { combinators = defaultCombinators, combinatorPreceding, combinatorSucceeding, idGenerator = generateID, replace = false, onAbort } = options;
5424
6212
  const parentToInsertInto = findPath(getParentPath(path), query);
5425
- if (!parentToInsertInto || !isRuleGroup(parentToInsertInto)) return query;
6213
+ if (!parentToInsertInto) {
6214
+ onAbort === null || onAbort === void 0 || onAbort({
6215
+ reason: "parent-not-found",
6216
+ operation: "insert",
6217
+ pathOrID: path
6218
+ });
6219
+ return query;
6220
+ }
6221
+ if (!isRuleGroup(parentToInsertInto)) {
6222
+ onAbort === null || onAbort === void 0 || onAbort({
6223
+ reason: "parent-not-a-group",
6224
+ operation: "insert",
6225
+ pathOrID: path
6226
+ });
6227
+ return query;
6228
+ }
6229
+ const parentPath = getParentPath(path);
6230
+ const insertGuardReason = getGuardAbortReason(query, parentPath, options, { asParent: true });
6231
+ if (insertGuardReason) {
6232
+ onAbort === null || onAbort === void 0 || onAbort({
6233
+ reason: insertGuardReason,
6234
+ operation: "insert",
6235
+ pathOrID: path
6236
+ });
6237
+ return query;
6238
+ }
6239
+ if (isRuleGroup(ruleOrGroup) && exceedsMaxLevels(parentPath, options)) {
6240
+ onAbort === null || onAbort === void 0 || onAbort({
6241
+ reason: "max-levels-exceeded",
6242
+ operation: "insert",
6243
+ pathOrID: path
6244
+ });
6245
+ return query;
6246
+ }
5426
6247
  const rorg = regenerateIDs(ruleOrGroup, { idGenerator });
5427
6248
  const independentCombinators = isRuleGroupTypeIC(query);
5428
6249
  const newIndex = path.at(-1);
@@ -5470,15 +6291,85 @@ const group = (query, sourcePathOrID, targetPathOrID, options = {}) => produce(q
5470
6291
  * @group Query Tools
5471
6292
  */
5472
6293
  const groupInPlace = (query, sourcePathOrID, targetPathOrID, options = {}) => {
5473
- const { clone = false, combinators = defaultCombinators, idGenerator = generateID } = options;
6294
+ const { clone = false, combinators = defaultCombinators, idGenerator = generateID, onAbort } = options;
5474
6295
  const sourcePath = Array.isArray(sourcePathOrID) ? sourcePathOrID : getPathOfID(sourcePathOrID, query);
5475
6296
  const targetPath = Array.isArray(targetPathOrID) ? targetPathOrID : getPathOfID(targetPathOrID, query);
5476
- if (!sourcePath || !targetPath) return query;
6297
+ if (!sourcePath) {
6298
+ onAbort === null || onAbort === void 0 || onAbort({
6299
+ reason: "target-not-found",
6300
+ operation: "group",
6301
+ pathOrID: sourcePathOrID
6302
+ });
6303
+ return query;
6304
+ }
6305
+ if (!targetPath) {
6306
+ onAbort === null || onAbort === void 0 || onAbort({
6307
+ reason: "target-not-found",
6308
+ operation: "group",
6309
+ pathOrID: targetPathOrID
6310
+ });
6311
+ return query;
6312
+ }
5477
6313
  const nextPath = getNextPath(query, sourcePath, targetPath);
5478
- if (sourcePath.length === 0 || pathsAreEqual(sourcePath, nextPath) || !findPath(getParentPath(nextPath), query)) return query;
6314
+ if (sourcePath.length === 0) {
6315
+ onAbort === null || onAbort === void 0 || onAbort({
6316
+ reason: "root-not-allowed",
6317
+ operation: "group",
6318
+ pathOrID: sourcePathOrID
6319
+ });
6320
+ return query;
6321
+ }
6322
+ const groupGuardReason = getGuardAbortReason(query, sourcePath, options);
6323
+ if (groupGuardReason) {
6324
+ onAbort === null || onAbort === void 0 || onAbort({
6325
+ reason: groupGuardReason,
6326
+ operation: "group",
6327
+ pathOrID: sourcePathOrID
6328
+ });
6329
+ return query;
6330
+ }
6331
+ if (pathsAreEqual(sourcePath, nextPath)) {
6332
+ onAbort === null || onAbort === void 0 || onAbort({
6333
+ reason: "same-location",
6334
+ operation: "group",
6335
+ pathOrID: sourcePathOrID
6336
+ });
6337
+ return query;
6338
+ }
6339
+ if (!findPath(getParentPath(nextPath), query)) {
6340
+ onAbort === null || onAbort === void 0 || onAbort({
6341
+ reason: "destination-not-found",
6342
+ operation: "group",
6343
+ pathOrID: targetPathOrID
6344
+ });
6345
+ return query;
6346
+ }
6347
+ if (!clone && isAncestor(sourcePath, nextPath)) {
6348
+ onAbort === null || onAbort === void 0 || onAbort({
6349
+ reason: "destination-not-found",
6350
+ operation: "group",
6351
+ pathOrID: targetPathOrID
6352
+ });
6353
+ return query;
6354
+ }
5479
6355
  const sourceRuleOrGroupOriginal = findPath(sourcePath, query);
5480
6356
  const targetRuleOrGroup = findPath(targetPath, query);
5481
- if (!sourceRuleOrGroupOriginal || !targetRuleOrGroup) return query;
6357
+ if (!sourceRuleOrGroupOriginal) {
6358
+ onAbort === null || onAbort === void 0 || onAbort({
6359
+ reason: "target-not-found",
6360
+ operation: "group",
6361
+ pathOrID: sourcePathOrID
6362
+ });
6363
+ return query;
6364
+ }
6365
+ if (!targetRuleOrGroup) {
6366
+ onAbort === null || onAbort === void 0 || onAbort({
6367
+ reason: "target-not-found",
6368
+ operation: "group",
6369
+ pathOrID: targetPathOrID
6370
+ });
6371
+ return query;
6372
+ }
5482
6373
  const sourceRuleOrGroup = clone ? regenerateIDs(isDraft(sourceRuleOrGroupOriginal) ? current(sourceRuleOrGroupOriginal) : sourceRuleOrGroupOriginal, { idGenerator }) : sourceRuleOrGroupOriginal;
5483
6374
  const independentCombinators = isRuleGroupTypeIC(query);
5484
6375
  const parentOfRuleToRemove = findPath(getParentPath(sourcePath), query);
@@ -5491,7 +6382,8 @@ const groupInPlace = (query, sourcePathOrID, targetPathOrID, options = {}) => {
5491
6382
  const newNewPath = [...nextPath];
5492
6383
  const commonAncestorPath = getCommonAncestorPath(sourcePath, nextPath);
5493
6384
  if (!clone && sourcePath.length === commonAncestorPath.length + 1 && nextPath[commonAncestorPath.length] > sourcePath[commonAncestorPath.length]) newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;
5494
- const parentOfTargetPath = findPath(getParentPath(newNewPath), query);
6385
+ const newNewParentPath = getParentPath(newNewPath);
6386
+ const parentOfTargetPath = findPath(newNewParentPath, query);
5495
6387
  const targetPathIndex = newNewPath.at(-1);
5496
6388
  parentOfTargetPath.rules.splice(targetPathIndex, 1, prepareRuleOrGroup(independentCombinators ? { rules: [
5497
6389
  targetRuleOrGroup,
@@ -5504,6 +6396,1301 @@ const groupInPlace = (query, sourcePathOrID, targetPathOrID, options = {}) => {
5504
6396
  return query;
5505
6397
  };
5506
6398
  //#endregion
5507
- export { LogType, TestID, add, addInPlace, betweenOperators, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, convertFromIC, convertQuery, convertToIC, cypherCombinatorMap, defaultCELValueProcessor, defaultCombinatorLabelMap, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultExportOperatorMap, defaultJoinChar, defaultMatchModes, defaultMongoDBValueProcessor, defaultNLTranslations, defaultOperatorLabelMap, defaultOperatorNegationMap, defaultOperatorProcessorNL, defaultOperatorProcessorSQL, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderLabel, defaultPlaceholderName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultPlaceholderValueGroupLabel, defaultPlaceholderValueLabel, defaultPlaceholderValueName, defaultRuleGroupProcessorCEL, defaultRuleGroupProcessorCypher, defaultRuleGroupProcessorDiagnostics, defaultRuleGroupProcessorDrizzle, defaultRuleGroupProcessorElasticSearch, defaultRuleGroupProcessorGremlin, defaultRuleGroupProcessorJSONata, defaultRuleGroupProcessorJsonLogic, defaultRuleGroupProcessorLDAP, defaultRuleGroupProcessorMongoDB, defaultRuleGroupProcessorMongoDBQuery, defaultRuleGroupProcessorNL, defaultRuleGroupProcessorParameterized, defaultRuleGroupProcessorPrisma, defaultRuleGroupProcessorSPARQL, defaultRuleGroupProcessorSQL, defaultRuleGroupProcessorSequelize, defaultRuleGroupProcessorSpEL, defaultRuleGroupProcessorTanStackDB, defaultRuleProcessorCEL, defaultRuleProcessorCypher, defaultRuleProcessorDrizzle, defaultRuleProcessorElasticSearch, defaultRuleProcessorGremlin, defaultRuleProcessorJSONata, defaultRuleProcessorJsonLogic, defaultRuleProcessorLDAP, defaultRuleProcessorMongoDB, defaultRuleProcessorMongoDBQuery, defaultRuleProcessorNL, defaultRuleProcessorParameterized, defaultRuleProcessorPrisma, defaultRuleProcessorSPARQL, defaultRuleProcessorSQL, defaultRuleProcessorSequelize, defaultRuleProcessorSpEL, defaultRuleProcessorTanStackDB, defaultSpELValueProcessor, defaultTranslations, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorNL, defaultValueProcessorSpELByRule, filterFieldsByComparator, findID, findPath, formatQuery, formatQueryOptionPresets, generateAccessibleDescription, generateID, getCommonAncestorPath, getFirstOption, getLikeWildcards, getMatchModesUtil, getNLTranslataion, getOption, getParentPath, getParseNumberMethod, getPathOfID, getQuoteFieldNamesWithArray, getQuotedFieldName, getRuleDefaultValue, getSQLConcat, getValidationClassNames, getValueSourcesUtil, group, groupInPlace, groupInvalidReasons, inOperators, insert, insertInPlace, isAncestor, isFlexibleOptionArray, isFlexibleOptionGroupArray, isFullOptionArray, isFullOptionGroupArray, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isRuleType, isUnsafeKey, isValidValue, isValidationResult, isValueProcessorLegacy, joinWith, jsonLogicAdditionalOperators, lc, mapSQLOperator, mergeAnyTranslation, mergeAnyTranslations, mergeClassnames, mongoDbFallback, mongoOperators, move, moveInPlace, normalizeConstituentWordOrder, nullFreeArray, nullOperators, nullOrUndefinedOrEmpty, numericRegex, numerifyValues, objectEntries, objectKeys, parseNumber, pathIsDisabled, pathsAreEqual, preferAnyProp, preferFlagProps, preferProp, prepareOptionList, prepareRule, prepareRuleGroup, prepareRuleOrGroup, prismaFallback, prismaOperators, processMatchMode, queryBuilderFlagDefaults, regenerateID, regenerateIDs, relationalOperators, remove, removeInPlace, rootPath, shouldRenderAsNumber, sparqlVar, splitBy, sqlDialectPresets, standardClassnames, stripParamPrefix, substringOperators, toArray, toFlatOptionArray, toFullOption, toFullOptionList, toFullOptionMap, transformQuery, trimIfString, uniqByIdentifier, uniqByName, uniqOptGroups, uniqOptList, update, updateInPlace, uuidV4regex, withParamPrefix, wrapLikeFragment };
6399
+ //#region src/utils/queryActions.ts
6400
+ /**
6401
+ * Builds the query builder's six mutation handlers as pure functions of the current query.
6402
+ *
6403
+ * This is the framework-agnostic core of the action handlers in `useQueryBuilderSchema`. It owns
6404
+ * the policy that surrounds the query tools—disabled gating, the confirmation callback protocol,
6405
+ * `maxLevels`, and debug logging—so an implementation only has to supply its own storage: read
6406
+ * the current query, call the action, and apply a non-`undefined` result.
6407
+ *
6408
+ * @group Query Tools
6409
+ */
6410
+ const createQueryActions = (config = {}) => {
6411
+ const { qbId, combinators, idGenerator, maxLevels = Infinity, queryDisabled, respectDisabled = true, disabledPaths, resetOnFieldChange, resetOnOperatorChange, getRuleDefaultOperator, getValueSources, getRuleDefaultValue, getMatchModes, onAddRule, onAddGroup, onRemove, onMoveRule, onMoveGroup, onGroupRule, onGroupGroup, onLog } = config;
6412
+ const log = (payload) => onLog === null || onLog === void 0 ? void 0 : onLog(_objectSpread2({ qbId }, payload));
6413
+ const guards = {
6414
+ respectDisabled,
6415
+ queryDisabled,
6416
+ disabledPaths
6417
+ };
6418
+ /** Whether the mutation is blocked, using the same rules the query tools apply internally. */
6419
+ const blocked = (query, path, asParent = false) => !!getGuardAbortReason(query, path, guards, { asParent });
6420
+ return {
6421
+ addRule: (query, rule, parentPath, context) => {
6422
+ if (blocked(query, parentPath, true)) {
6423
+ log({
6424
+ type: LogType.parentPathDisabled,
6425
+ rule,
6426
+ parentPath,
6427
+ query
6428
+ });
6429
+ return;
6430
+ }
6431
+ const nextRule = onAddRule ? onAddRule(rule, parentPath, query, context) : true;
6432
+ if (!nextRule) {
6433
+ log({
6434
+ type: LogType.onAddRuleFalse,
6435
+ rule,
6436
+ parentPath,
6437
+ query
6438
+ });
6439
+ return;
6440
+ }
6441
+ const newRule = nextRule === true ? rule : nextRule;
6442
+ const newQuery = add(query, newRule, parentPath, {
6443
+ combinators,
6444
+ combinatorPreceding: newRule.combinatorPreceding,
6445
+ idGenerator
6446
+ });
6447
+ log({
6448
+ type: LogType.add,
6449
+ query,
6450
+ newQuery,
6451
+ newRule,
6452
+ parentPath
6453
+ });
6454
+ return newQuery;
6455
+ },
6456
+ addGroup: (query, ruleGroup, parentPath, context) => {
6457
+ var _combinatorPreceding;
6458
+ if (parentPath.length >= maxLevels) return void 0;
6459
+ if (blocked(query, parentPath, true)) {
6460
+ log({
6461
+ type: LogType.parentPathDisabled,
6462
+ ruleGroup,
6463
+ parentPath,
6464
+ query
6465
+ });
6466
+ return;
6467
+ }
6468
+ const nextGroup = onAddGroup ? onAddGroup(ruleGroup, parentPath, query, context) : true;
6469
+ if (!nextGroup) {
6470
+ log({
6471
+ type: LogType.onAddGroupFalse,
6472
+ ruleGroup,
6473
+ parentPath,
6474
+ query
6475
+ });
6476
+ return;
6477
+ }
6478
+ const newGroup = nextGroup === true ? ruleGroup : nextGroup;
6479
+ const newQuery = add(query, newGroup, parentPath, {
6480
+ combinators,
6481
+ combinatorPreceding: (_combinatorPreceding = newGroup.combinatorPreceding) !== null && _combinatorPreceding !== void 0 ? _combinatorPreceding : void 0,
6482
+ idGenerator
6483
+ });
6484
+ log({
6485
+ type: LogType.add,
6486
+ query,
6487
+ newQuery,
6488
+ newGroup,
6489
+ parentPath
6490
+ });
6491
+ return newQuery;
6492
+ },
6493
+ propChange: (query, prop, value, path) => {
6494
+ if (getGuardAbortReason(query, path, prop === "disabled" ? { queryDisabled } : guards)) {
6495
+ log({
6496
+ type: LogType.pathDisabled,
6497
+ path,
6498
+ prop,
6499
+ value,
6500
+ query
6501
+ });
6502
+ return;
6503
+ }
6504
+ const newQuery = update(query, prop, value, path, {
6505
+ resetOnFieldChange,
6506
+ resetOnOperatorChange,
6507
+ getRuleDefaultOperator,
6508
+ getValueSources,
6509
+ getRuleDefaultValue,
6510
+ getMatchModes
6511
+ });
6512
+ log({
6513
+ type: LogType.update,
6514
+ query,
6515
+ newQuery,
6516
+ prop,
6517
+ value,
6518
+ path
6519
+ });
6520
+ return newQuery;
6521
+ },
6522
+ removeRuleOrGroup: (query, path, context) => {
6523
+ if (blocked(query, path)) {
6524
+ log({
6525
+ type: LogType.pathDisabled,
6526
+ path,
6527
+ query
6528
+ });
6529
+ return;
6530
+ }
6531
+ const ruleOrGroup = findPath(path, query);
6532
+ /* v8 ignore next -- @preserve */
6533
+ if (!ruleOrGroup) return void 0;
6534
+ if (onRemove && !onRemove(ruleOrGroup, path, query, context)) {
6535
+ log({
6536
+ type: LogType.onRemoveFalse,
6537
+ ruleOrGroup,
6538
+ path,
6539
+ query
6540
+ });
6541
+ return;
6542
+ }
6543
+ const newQuery = remove(query, path);
6544
+ log({
6545
+ type: LogType.remove,
6546
+ query,
6547
+ newQuery,
6548
+ path,
6549
+ ruleOrGroup
6550
+ });
6551
+ return newQuery;
6552
+ },
6553
+ moveRule: (query, oldPath, newPath, clone, context) => {
6554
+ if (blocked(query, oldPath)) {
6555
+ log({
6556
+ type: LogType.pathDisabled,
6557
+ oldPath,
6558
+ newPath,
6559
+ query
6560
+ });
6561
+ return;
6562
+ }
6563
+ const ruleOrGroup = findPath(oldPath, query);
6564
+ if (!ruleOrGroup) return void 0;
6565
+ const nextQuery = move(query, oldPath, newPath, {
6566
+ clone,
6567
+ combinators,
6568
+ idGenerator
6569
+ });
6570
+ const isGroup = isRuleGroup(ruleOrGroup);
6571
+ const callback = isGroup ? onMoveGroup : onMoveRule;
6572
+ const callbackResult = callback ? callback(ruleOrGroup, oldPath, newPath, query, nextQuery, {
6573
+ clone,
6574
+ combinators
6575
+ }, context) : true;
6576
+ if (!callbackResult) {
6577
+ log({
6578
+ type: isGroup ? LogType.onMoveGroupFalse : LogType.onMoveRuleFalse,
6579
+ ruleOrGroup,
6580
+ oldPath,
6581
+ newPath,
6582
+ clone,
6583
+ query,
6584
+ nextQuery
6585
+ });
6586
+ return;
6587
+ }
6588
+ const newQuery = isRuleGroup(callbackResult) ? callbackResult : nextQuery;
6589
+ log({
6590
+ type: LogType.move,
6591
+ query,
6592
+ newQuery,
6593
+ oldPath,
6594
+ newPath,
6595
+ clone
6596
+ });
6597
+ return newQuery;
6598
+ },
6599
+ groupRule: (query, sourcePath, targetPath, clone, context) => {
6600
+ if (blocked(query, sourcePath)) {
6601
+ log({
6602
+ type: LogType.pathDisabled,
6603
+ sourcePath,
6604
+ targetPath,
6605
+ query
6606
+ });
6607
+ return;
6608
+ }
6609
+ const ruleOrGroup = findPath(sourcePath, query);
6610
+ if (!ruleOrGroup) return void 0;
6611
+ const nextQuery = group(query, sourcePath, targetPath, {
6612
+ clone,
6613
+ combinators,
6614
+ idGenerator
6615
+ });
6616
+ const isGroup = isRuleGroup(ruleOrGroup);
6617
+ const callback = isGroup ? onGroupGroup : onGroupRule;
6618
+ const callbackResult = callback ? callback(ruleOrGroup, sourcePath, targetPath, query, nextQuery, {
6619
+ clone,
6620
+ combinators
6621
+ }, context) : true;
6622
+ if (!callbackResult) {
6623
+ log({
6624
+ type: isGroup ? LogType.onGroupGroupFalse : LogType.onGroupRuleFalse,
6625
+ ruleOrGroup,
6626
+ sourcePath,
6627
+ targetPath,
6628
+ clone,
6629
+ query,
6630
+ nextQuery
6631
+ });
6632
+ return;
6633
+ }
6634
+ const newQuery = isRuleGroup(callbackResult) ? callbackResult : nextQuery;
6635
+ log({
6636
+ type: LogType.group,
6637
+ query,
6638
+ newQuery,
6639
+ sourcePath,
6640
+ targetPath,
6641
+ clone
6642
+ });
6643
+ return newQuery;
6644
+ }
6645
+ };
6646
+ };
6647
+ //#endregion
6648
+ //#region src/utils/ruleFactory.ts
6649
+ /**
6650
+ * Creates a rule from the given configuration, applying the same precedence as the
6651
+ * `QueryBuilder` component. The `value` is computed in a second pass, once `field`, `operator`,
6652
+ * and `valueSource` are known, since the default value depends on all three.
6653
+ *
6654
+ * @group Query Tools
6655
+ */
6656
+ const createRule = ({ fields, getDefaultField, getRuleDefaultOperator, getValueSources, getMatchModes, getRuleDefaultValue, idGenerator = generateID }) => {
6657
+ var _getFirstOption, _getFirstOption2;
6658
+ let field = (_getFirstOption = getFirstOption(fields)) !== null && _getFirstOption !== void 0 ? _getFirstOption : "";
6659
+ if (getDefaultField) if (typeof getDefaultField === "function") {
6660
+ const defaultField = getDefaultField(fields);
6661
+ if (defaultField) field = defaultField;
6662
+ } else field = getDefaultField;
6663
+ const fieldData = getOption(fields, field);
6664
+ const operator = getRuleDefaultOperator(field);
6665
+ const valueSource = (_getFirstOption2 = getFirstOption(getValueSources(field, operator, { fieldData }))) !== null && _getFirstOption2 !== void 0 ? _getFirstOption2 : "value";
6666
+ const matchMode = getFirstOption(getMatchModes(field, { fieldData }));
6667
+ const newRule = _objectSpread2({
6668
+ id: idGenerator(),
6669
+ field,
6670
+ operator,
6671
+ valueSource,
6672
+ value: ""
6673
+ }, matchMode ? { match: {
6674
+ mode: matchMode,
6675
+ threshold: 1
6676
+ } } : null);
6677
+ return _objectSpread2(_objectSpread2({}, newRule), {}, { value: getRuleDefaultValue(newRule) });
6678
+ };
6679
+ /**
6680
+ * Creates a group from the given configuration. Pass `true` for `independentCombinators` to omit
6681
+ * the `combinator` property.
6682
+ *
6683
+ * The group's own `id` is generated _before_ any contained rule's, matching the order the
6684
+ * `QueryBuilder` component has always used. This is observable when `idGenerator` is
6685
+ * deterministic, as it often is in tests.
6686
+ *
6687
+ * @group Query Tools
6688
+ */
6689
+ const createRuleGroup = ({ combinators, addRuleToNewGroups, createRule: createRuleMain, idGenerator = generateID }, independentCombinators) => {
6690
+ var _getFirstOption3;
6691
+ const id = idGenerator();
6692
+ const rules = addRuleToNewGroups ? [createRuleMain()] : [];
6693
+ if (independentCombinators) return {
6694
+ id,
6695
+ rules,
6696
+ not: false
6697
+ };
6698
+ return {
6699
+ id,
6700
+ rules,
6701
+ combinator: (_getFirstOption3 = getFirstOption(combinators)) !== null && _getFirstOption3 !== void 0 ? _getFirstOption3 : "",
6702
+ not: false
6703
+ };
6704
+ };
6705
+ //#endregion
6706
+ //#region src/utils/signature.ts
6707
+ /**
6708
+ * Signature returned when a change alters the _shape_ of the query—rules or groups added,
6709
+ * removed, moved, or reordered—rather than the properties of a single node. Structural changes
6710
+ * never coalesce with each other, so each one produces its own history entry.
6711
+ */
6712
+ const structuralSignature = "~structural";
6713
+ /**
6714
+ * Signature returned when two queries differ by reference only, with no observable difference
6715
+ * in their properties.
6716
+ */
6717
+ const unchangedSignature = "";
6718
+ /**
6719
+ * Returns the list of property names that differ between two nodes, ignoring `rules` (which is
6720
+ * compared structurally by the caller).
6721
+ */
6722
+ const changedProps = (prev, next) => {
6723
+ const keys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(next)]);
6724
+ keys.delete("rules");
6725
+ const changed = [];
6726
+ for (const key of keys) if (!Object.is(prev[key], next[key])) changed.push(key);
6727
+ return changed.toSorted();
6728
+ };
6729
+ const signatureOfNode = (prev, next, parentId, index) => {
6730
+ var _next$id3;
6731
+ if (prev === next) return "";
6732
+ if (typeof prev === "string" || typeof next === "string") return typeof prev === typeof next ? `${parentId}:combinator[${index}]` : structuralSignature;
6733
+ const prevIsGroup = isRuleGroup(prev);
6734
+ const nextIsGroup = isRuleGroup(next);
6735
+ if (prevIsGroup !== nextIsGroup) return structuralSignature;
6736
+ if (!prevIsGroup || !nextIsGroup) {
6737
+ var _next$id;
6738
+ const props = changedProps(prev, next);
6739
+ return props.length === 0 ? "" : `${(_next$id = next.id) !== null && _next$id !== void 0 ? _next$id : ""}:${props.join(",")}`;
6740
+ }
6741
+ if (prev.rules.length !== next.rules.length) return structuralSignature;
6742
+ const ownProps = changedProps(prev, next);
6743
+ let changedIndex = -1;
6744
+ for (const [i, prevRule] of prev.rules.entries()) if (prevRule !== next.rules[i]) {
6745
+ if (changedIndex !== -1) return structuralSignature;
6746
+ changedIndex = i;
6747
+ }
6748
+ if (changedIndex === -1) {
6749
+ var _next$id2;
6750
+ return ownProps.length === 0 ? "" : `${(_next$id2 = next.id) !== null && _next$id2 !== void 0 ? _next$id2 : ""}:${ownProps.join(",")}`;
6751
+ }
6752
+ if (ownProps.length > 0) return structuralSignature;
6753
+ return signatureOfNode(prev.rules[changedIndex], next.rules[changedIndex], (_next$id3 = next.id) !== null && _next$id3 !== void 0 ? _next$id3 : "", changedIndex);
6754
+ };
6755
+ /**
6756
+ * Describes _what changed_ between two versions of a query as a short string, so that
6757
+ * consecutive edits to the same property of the same rule (e.g. typing in a value editor) can
6758
+ * be recognized and coalesced into a single history entry.
6759
+ *
6760
+ * Returns {@link structuralSignature} for changes to the shape of the query, {@link unchangedSignature} when the
6761
+ * two queries differ by reference only, and `"<id>:<props>"` otherwise.
6762
+ *
6763
+ * The walk prunes on reference equality, so it costs O(depth) rather than O(size) for the
6764
+ * single-node edits that make up the overwhelming majority of changes.
6765
+ *
6766
+ * Note that this relies on the structural sharing that Immer—and therefore every query
6767
+ * produced by RQB's own update functions—guarantees: nodes that did not change keep their
6768
+ * identity. A query that has been wholly rebuilt (deep-cloned, round-tripped through JSON,
6769
+ * re-parsed from a string) shares no identity with its predecessor, so it is reported as
6770
+ * {@link structuralSignature} and will not coalesce. That is a graceful degradation—every change simply
6771
+ * gets its own history entry—but controlled components that clone the query on every change
6772
+ * will not benefit from coalescing.
6773
+ */
6774
+ const signatureOf = (prev, next) => signatureOfNode(prev, next, "", -1);
6775
+ //#endregion
6776
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/checkPrivateRedeclaration.js
6777
+ function _checkPrivateRedeclaration(e, t) {
6778
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
6779
+ }
6780
+ //#endregion
6781
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateMethodInitSpec.js
6782
+ function _classPrivateMethodInitSpec(e, a) {
6783
+ _checkPrivateRedeclaration(e, a), a.add(e);
6784
+ }
6785
+ //#endregion
6786
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldInitSpec.js
6787
+ function _classPrivateFieldInitSpec(e, t, a) {
6788
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
6789
+ }
6790
+ //#endregion
6791
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/assertClassBrand.js
6792
+ function _assertClassBrand(e, t, n) {
6793
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
6794
+ throw new TypeError("Private element is not present on this object");
6795
+ }
6796
+ //#endregion
6797
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldGet2.js
6798
+ function _classPrivateFieldGet2(s, a) {
6799
+ return s.get(_assertClassBrand(s, a));
6800
+ }
6801
+ //#endregion
6802
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldSet2.js
6803
+ function _classPrivateFieldSet2(s, a, r) {
6804
+ return s.set(_assertClassBrand(s, a), r), r;
6805
+ }
6806
+ //#endregion
6807
+ //#region src/utils/QueryManager.ts
6808
+ const _excluded = ["strict", "onInvalidTarget"];
6809
+ const _excluded2 = ["strict", "onInvalidTarget"];
6810
+ const _excluded3 = ["strict", "onInvalidTarget"];
6811
+ const _excluded4 = ["strict", "onInvalidTarget"];
6812
+ const _excluded5 = ["strict", "onInvalidTarget"];
6813
+ const _excluded6 = ["strict", "onInvalidTarget"];
6814
+ let _Symbol$iterator;
6815
+ /**
6816
+ * Abort reasons that {@link QueryManager}'s `strict` mode treats as errors. The remaining
6817
+ * reasons—`"same-location"` and `"no-change"`—describe valid operations that had nothing to do,
6818
+ * so they are reported to `onInvalidTarget` but never throw.
6819
+ *
6820
+ * @group Query Tools
6821
+ */
6822
+ const strictAbortReasons = [
6823
+ "target-not-found",
6824
+ "parent-not-found",
6825
+ "parent-not-a-group",
6826
+ "destination-not-found",
6827
+ "root-not-allowed",
6828
+ "not-a-combinator-slot",
6829
+ "target-disabled",
6830
+ "parent-disabled",
6831
+ "max-levels-exceeded"
6832
+ ];
6833
+ const strictAbortReasonSet = new Set(strictAbortReasons);
6834
+ /**
6835
+ * Thrown by {@link QueryManager} methods in `strict` mode when an operation cannot be carried
6836
+ * out because its target could not be used.
6837
+ *
6838
+ * @group Query Tools
6839
+ */
6840
+ var QueryManagerError = class QueryManagerError extends Error {
6841
+ constructor(info) {
6842
+ super(`QueryManager: "${info.operation}" aborted (${info.reason})${info.pathOrID === void 0 ? "" : ` for target ${JSON.stringify(info.pathOrID)}`}.`);
6843
+ _defineProperty(this, "code", void 0);
6844
+ _defineProperty(this, "info", void 0);
6845
+ this.name = "QueryManagerError";
6846
+ this.code = info.reason;
6847
+ this.info = info;
6848
+ Object.setPrototypeOf(this, QueryManagerError.prototype);
6849
+ }
6850
+ };
6851
+ var _query = /* @__PURE__ */ new WeakMap();
6852
+ var _options = /* @__PURE__ */ new WeakMap();
6853
+ var _fields = /* @__PURE__ */ new WeakMap();
6854
+ var _fieldMap = /* @__PURE__ */ new WeakMap();
6855
+ var _operators = /* @__PURE__ */ new WeakMap();
6856
+ var _combinators = /* @__PURE__ */ new WeakMap();
6857
+ var _idGenerator = /* @__PURE__ */ new WeakMap();
6858
+ var _validator = /* @__PURE__ */ new WeakMap();
6859
+ var _strict = /* @__PURE__ */ new WeakMap();
6860
+ var _respectDisabled = /* @__PURE__ */ new WeakMap();
6861
+ var _onInvalidTarget = /* @__PURE__ */ new WeakMap();
6862
+ var _listeners = /* @__PURE__ */ new WeakMap();
6863
+ var _historyEnabled = /* @__PURE__ */ new WeakMap();
6864
+ var _maxHistory = /* @__PURE__ */ new WeakMap();
6865
+ var _coalesceMs = /* @__PURE__ */ new WeakMap();
6866
+ var _now = /* @__PURE__ */ new WeakMap();
6867
+ var _past = /* @__PURE__ */ new WeakMap();
6868
+ var _future = /* @__PURE__ */ new WeakMap();
6869
+ var _lastSig = /* @__PURE__ */ new WeakMap();
6870
+ var _lastAt = /* @__PURE__ */ new WeakMap();
6871
+ var _batchDepth = /* @__PURE__ */ new WeakMap();
6872
+ var _batchSnapshot = /* @__PURE__ */ new WeakMap();
6873
+ var _historyBypassed = /* @__PURE__ */ new WeakMap();
6874
+ var _cacheFor = /* @__PURE__ */ new WeakMap();
6875
+ var _idPathIndex = /* @__PURE__ */ new WeakMap();
6876
+ var _validation = /* @__PURE__ */ new WeakMap();
6877
+ var _QueryManager_brand = /* @__PURE__ */ new WeakSet();
6878
+ _Symbol$iterator = Symbol.iterator;
6879
+ /**
6880
+ * Stateful wrapper around the {@link add}/{@link remove}/{@link update}/{@link move}/
6881
+ * {@link insert}/{@link group} query tools, plus rule/group factories, {@link defaultValidator
6882
+ * validation}, and {@link formatQuery formatting}.
6883
+ *
6884
+ * The query is held internally, so each method takes the same arguments as its `queryTools`
6885
+ * counterpart minus the leading `query` parameter, and returns the manager itself for chaining.
6886
+ * Mutations use the non-`InPlace` tools, so a query previously handed out by
6887
+ * {@link QueryManager.getQuery} is never modified.
6888
+ *
6889
+ * ```ts
6890
+ * const q = new QueryManager(undefined, { fields });
6891
+ * q.add(q.createRule()).add({ field: 'firstName', operator: '=', value: 'Steve' });
6892
+ * q.format('sql');
6893
+ * ```
6894
+ *
6895
+ * Like the underlying query tools, methods are a no-op when the target path or `id` can't be
6896
+ * resolved (including attempts to remove the root group). By default nothing is thrown; pass
6897
+ * `strict: true` to raise a {@link QueryManagerError} instead, or `onInvalidTarget` to observe
6898
+ * aborted operations without changing control flow.
6899
+ *
6900
+ * @group Query Tools
6901
+ */
6902
+ var QueryManager = class QueryManager {
6903
+ constructor(query, options = {}) {
6904
+ var _options$idGenerator, _options$validator, _options$strict, _options$respectDisab, _options$history, _historyOptions$maxHi, _historyOptions$coale, _options$now, _options$operators, _options$combinators;
6905
+ _classPrivateMethodInitSpec(this, _QueryManager_brand);
6906
+ _classPrivateFieldInitSpec(this, _query, void 0);
6907
+ _classPrivateFieldInitSpec(this, _options, void 0);
6908
+ _classPrivateFieldInitSpec(this, _fields, void 0);
6909
+ _classPrivateFieldInitSpec(this, _fieldMap, void 0);
6910
+ _classPrivateFieldInitSpec(this, _operators, void 0);
6911
+ _classPrivateFieldInitSpec(this, _combinators, void 0);
6912
+ _classPrivateFieldInitSpec(this, _idGenerator, void 0);
6913
+ _classPrivateFieldInitSpec(this, _validator, void 0);
6914
+ _classPrivateFieldInitSpec(this, _strict, void 0);
6915
+ _classPrivateFieldInitSpec(this, _respectDisabled, void 0);
6916
+ _classPrivateFieldInitSpec(this, _onInvalidTarget, void 0);
6917
+ _classPrivateFieldInitSpec(this, _listeners, /* @__PURE__ */ new Set());
6918
+ _classPrivateFieldInitSpec(this, _historyEnabled, void 0);
6919
+ _classPrivateFieldInitSpec(this, _maxHistory, void 0);
6920
+ _classPrivateFieldInitSpec(this, _coalesceMs, void 0);
6921
+ _classPrivateFieldInitSpec(this, _now, void 0);
6922
+ _classPrivateFieldInitSpec(this, _past, []);
6923
+ _classPrivateFieldInitSpec(this, _future, []);
6924
+ _classPrivateFieldInitSpec(this, _lastSig, void 0);
6925
+ _classPrivateFieldInitSpec(this, _lastAt, 0);
6926
+ _classPrivateFieldInitSpec(this, _batchDepth, 0);
6927
+ _classPrivateFieldInitSpec(this, _batchSnapshot, void 0);
6928
+ _classPrivateFieldInitSpec(this, _historyBypassed, false);
6929
+ _classPrivateFieldInitSpec(this, _cacheFor, void 0);
6930
+ _classPrivateFieldInitSpec(this, _idPathIndex, void 0);
6931
+ _classPrivateFieldInitSpec(this, _validation, void 0);
6932
+ _defineProperty(
6933
+ this,
6934
+ /**
6935
+ * The current query. The returned object is frozen and structurally shared, so it is safe to
6936
+ * retain and compare by reference to detect changes.
6937
+ *
6938
+ * Like {@link QueryManager.subscribe}, this method is bound to the instance, so it can be
6939
+ * passed as a bare reference (e.g. as the `getSnapshot` argument to `useSyncExternalStore`).
6940
+ */
6941
+ "getQuery",
6942
+ () => _classPrivateFieldGet2(_query, this)
6943
+ );
6944
+ _defineProperty(
6945
+ this,
6946
+ /**
6947
+ * Registers a listener called after every change to the query, and returns a function that
6948
+ * unregisters it. Mutations that resolve to a no-op do not notify, and a
6949
+ * {@link QueryManager.batch batch} notifies once no matter how many changes it contains.
6950
+ *
6951
+ * Together with {@link QueryManager.getQuery}, this satisfies React's `useSyncExternalStore`
6952
+ * contract. Both methods are bound to the instance, so they are stable references across
6953
+ * renders and can be passed directly:
6954
+ *
6955
+ * ```ts
6956
+ * const query = useSyncExternalStore(q.subscribe, q.getQuery);
6957
+ * ```
6958
+ *
6959
+ * In React, prefer the `useQueryManager` hook from `react-querybuilder`, which wraps this.
6960
+ */
6961
+ "subscribe",
6962
+ (listener) => {
6963
+ _classPrivateFieldGet2(_listeners, this).add(listener);
6964
+ return () => {
6965
+ _classPrivateFieldGet2(_listeners, this).delete(listener);
6966
+ };
6967
+ }
6968
+ );
6969
+ _classPrivateFieldSet2(_options, this, options);
6970
+ _classPrivateFieldSet2(_idGenerator, this, (_options$idGenerator = options.idGenerator) !== null && _options$idGenerator !== void 0 ? _options$idGenerator : generateID);
6971
+ _classPrivateFieldSet2(_validator, this, (_options$validator = options.validator) !== null && _options$validator !== void 0 ? _options$validator : defaultValidator);
6972
+ _classPrivateFieldSet2(_strict, this, (_options$strict = options.strict) !== null && _options$strict !== void 0 ? _options$strict : false);
6973
+ _classPrivateFieldSet2(_respectDisabled, this, (_options$respectDisab = options.respectDisabled) !== null && _options$respectDisab !== void 0 ? _options$respectDisab : true);
6974
+ _classPrivateFieldSet2(_onInvalidTarget, this, options.onInvalidTarget);
6975
+ const history = (_options$history = options.history) !== null && _options$history !== void 0 ? _options$history : false;
6976
+ const historyOptions = typeof history === "object" ? history : {};
6977
+ _classPrivateFieldSet2(_historyEnabled, this, history !== false);
6978
+ _classPrivateFieldSet2(_maxHistory, this, (_historyOptions$maxHi = historyOptions.maxHistory) !== null && _historyOptions$maxHi !== void 0 ? _historyOptions$maxHi : 50);
6979
+ _classPrivateFieldSet2(_coalesceMs, this, (_historyOptions$coale = historyOptions.coalesceMs) !== null && _historyOptions$coale !== void 0 ? _historyOptions$coale : 500);
6980
+ _classPrivateFieldSet2(_now, this, (_options$now = options.now) !== null && _options$now !== void 0 ? _options$now : Date.now);
6981
+ const { optionList: fields, optionsMap: fieldMap } = prepareOptionList({
6982
+ optionList: options.fields,
6983
+ baseOption: options.baseField,
6984
+ autoSelectOption: options.autoSelectField
6985
+ });
6986
+ _classPrivateFieldSet2(_fields, this, freeze(fields, true));
6987
+ _classPrivateFieldSet2(_fieldMap, this, freeze(fieldMap, true));
6988
+ _classPrivateFieldSet2(_operators, this, prepareOptionList({
6989
+ optionList: (_options$operators = options.operators) !== null && _options$operators !== void 0 ? _options$operators : defaultOperators,
6990
+ baseOption: options.baseOperator,
6991
+ labelMap: defaultOperatorLabelMap,
6992
+ autoSelectOption: options.autoSelectOperator
6993
+ }).optionList);
6994
+ _classPrivateFieldSet2(_combinators, this, freeze(prepareOptionList({
6995
+ optionList: (_options$combinators = options.combinators) !== null && _options$combinators !== void 0 ? _options$combinators : defaultCombinators,
6996
+ baseOption: options.baseCombinator
6997
+ }).optionList, true));
6998
+ _classPrivateFieldSet2(_query, this, freeze(query ? prepareRuleGroup(query, { idGenerator: _classPrivateFieldGet2(_idGenerator, this) }) : this.createRuleGroup(), true));
6999
+ }
7000
+ /** Replaces the current query, ensuring every rule and group has an `id`. */
7001
+ setQuery(query) {
7002
+ _assertClassBrand(_QueryManager_brand, this, _commit).call(this, freeze(prepareRuleGroup(query, { idGenerator: _classPrivateFieldGet2(_idGenerator, this) }), true));
7003
+ return this;
7004
+ }
7005
+ /**
7006
+ * Creates a rule using the configured fields, operators, and defaults. The rule is not added
7007
+ * to the query—pass it to {@link QueryManager.add} or {@link QueryManager.insert}.
7008
+ */
7009
+ createRule() {
7010
+ return createRule({
7011
+ fields: _classPrivateFieldGet2(_fields, this),
7012
+ getDefaultField: _classPrivateFieldGet2(_options, this).getDefaultField,
7013
+ getRuleDefaultOperator: (f) => _assertClassBrand(_QueryManager_brand, this, _defaultOperator).call(this, f),
7014
+ getValueSources: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valueSourcesFor).call(this, f, o),
7015
+ getMatchModes: (f) => _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, f),
7016
+ getRuleDefaultValue: (r) => _assertClassBrand(_QueryManager_brand, this, _defaultValue).call(this, r),
7017
+ idGenerator: _classPrivateFieldGet2(_idGenerator, this)
7018
+ });
7019
+ }
7020
+ /**
7021
+ * Creates a group. Pass `true` for a group with independent combinators. The group is not
7022
+ * added to the query—pass it to {@link QueryManager.add} or {@link QueryManager.insert}.
7023
+ */
7024
+ createRuleGroup(independentCombinators) {
7025
+ return createRuleGroup({
7026
+ combinators: _classPrivateFieldGet2(_combinators, this),
7027
+ addRuleToNewGroups: _classPrivateFieldGet2(_options, this).addRuleToNewGroups,
7028
+ createRule: () => this.createRule(),
7029
+ idGenerator: _classPrivateFieldGet2(_idGenerator, this)
7030
+ }, independentCombinators);
7031
+ }
7032
+ /**
7033
+ * Adds a rule or group to the end of the group at `parentPathOrID`, which defaults to the
7034
+ * root group.
7035
+ */
7036
+ add(ruleOrGroup, parentPathOrID = [], options = {}) {
7037
+ const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded);
7038
+ _assertClassBrand(_QueryManager_brand, this, _commit).call(this, add(_classPrivateFieldGet2(_query, this), ruleOrGroup, parentPathOrID, _objectSpread2(_objectSpread2(_objectSpread2({}, _assertClassBrand(_QueryManager_brand, this, _toolOptions).call(this)), toolOptions), {}, { onAbort: _assertClassBrand(_QueryManager_brand, this, _onAbort).call(this, {
7039
+ strict,
7040
+ onInvalidTarget
7041
+ }) })));
7042
+ return this;
7043
+ }
7044
+ /** Removes the rule or group at the given path or `id`. The root group cannot be removed. */
7045
+ remove(pathOrID, options = {}) {
7046
+ const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded2);
7047
+ _assertClassBrand(_QueryManager_brand, this, _commit).call(this, remove(_classPrivateFieldGet2(_query, this), pathOrID, _objectSpread2(_objectSpread2(_objectSpread2({}, _assertClassBrand(_QueryManager_brand, this, _guardOptions).call(this)), toolOptions), {}, { onAbort: _assertClassBrand(_QueryManager_brand, this, _onAbort).call(this, {
7048
+ strict,
7049
+ onInvalidTarget
7050
+ }) })));
7051
+ return this;
7052
+ }
7053
+ update(a, b, c, d) {
7054
+ var _args$optionsIndex;
7055
+ const optionsIndex = typeof a === "string" || Array.isArray(a) ? 3 : 2;
7056
+ const args = [
7057
+ a,
7058
+ b,
7059
+ c,
7060
+ d
7061
+ ];
7062
+ const _ref = (_args$optionsIndex = args[optionsIndex]) !== null && _args$optionsIndex !== void 0 ? _args$optionsIndex : {}, { strict, onInvalidTarget } = _ref, toolOptions = _objectWithoutProperties(_ref, _excluded3);
7063
+ args[optionsIndex] = _objectSpread2(_objectSpread2(_objectSpread2({}, _assertClassBrand(_QueryManager_brand, this, _updateOptions).call(this)), toolOptions), {}, { onAbort: _assertClassBrand(_QueryManager_brand, this, _onAbort).call(this, {
7064
+ strict,
7065
+ onInvalidTarget
7066
+ }) });
7067
+ _assertClassBrand(_QueryManager_brand, this, _commit).call(this, update(_classPrivateFieldGet2(_query, this), ...args.slice(0, optionsIndex + 1)));
7068
+ return this;
7069
+ }
7070
+ /** Moves the rule or group at `oldPathOrID` to `newPath`, or shifts it `'up'`/`'down'`. */
7071
+ move(oldPathOrID, newPath, options = {}) {
7072
+ const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded4);
7073
+ _assertClassBrand(_QueryManager_brand, this, _commit).call(this, move(_classPrivateFieldGet2(_query, this), oldPathOrID, newPath, _objectSpread2(_objectSpread2(_objectSpread2({}, _assertClassBrand(_QueryManager_brand, this, _toolOptions).call(this)), toolOptions), {}, { onAbort: _assertClassBrand(_QueryManager_brand, this, _onAbort).call(this, {
7074
+ strict,
7075
+ onInvalidTarget
7076
+ }) })));
7077
+ return this;
7078
+ }
7079
+ /**
7080
+ * Inserts a rule or group at the given path. Unlike the other methods, this accepts a path
7081
+ * only—inserting _at_ an `id` would be ambiguous.
7082
+ */
7083
+ insert(ruleOrGroup, path, options = {}) {
7084
+ const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded5);
7085
+ _assertClassBrand(_QueryManager_brand, this, _commit).call(this, insert(_classPrivateFieldGet2(_query, this), ruleOrGroup, path, _objectSpread2(_objectSpread2(_objectSpread2({}, _assertClassBrand(_QueryManager_brand, this, _toolOptions).call(this)), toolOptions), {}, { onAbort: _assertClassBrand(_QueryManager_brand, this, _onAbort).call(this, {
7086
+ strict,
7087
+ onInvalidTarget
7088
+ }) })));
7089
+ return this;
7090
+ }
7091
+ /**
7092
+ * Creates a new group at `targetPathOrID` containing the rules/groups currently at
7093
+ * `targetPathOrID` and `sourcePathOrID`.
7094
+ */
7095
+ group(sourcePathOrID, targetPathOrID, options = {}) {
7096
+ const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded6);
7097
+ _assertClassBrand(_QueryManager_brand, this, _commit).call(this, group(_classPrivateFieldGet2(_query, this), sourcePathOrID, targetPathOrID, _objectSpread2(_objectSpread2(_objectSpread2({}, _assertClassBrand(_QueryManager_brand, this, _toolOptions).call(this)), toolOptions), {}, { onAbort: _assertClassBrand(_QueryManager_brand, this, _onAbort).call(this, {
7098
+ strict,
7099
+ onInvalidTarget
7100
+ }) })));
7101
+ return this;
7102
+ }
7103
+ /**
7104
+ * Creates an independent manager with the same configuration and the current query.
7105
+ *
7106
+ * Subscribers and history are _not_ carried over: the clone starts with no listeners and an
7107
+ * empty undo stack. Because every mutation produces a new query object, the two managers
7108
+ * share the initial query safely and diverge from the first change.
7109
+ *
7110
+ * Pass `{ regenerateIDs: true }` to give every rule and group in the clone a new `id`, which
7111
+ * is useful when both queries will be used together (e.g. inserted into the same tree).
7112
+ */
7113
+ clone(options) {
7114
+ const query = (options === null || options === void 0 ? void 0 : options.regenerateIDs) ? regenerateIDs(_classPrivateFieldGet2(_query, this), { idGenerator: _classPrivateFieldGet2(_idGenerator, this) }) : _classPrivateFieldGet2(_query, this);
7115
+ return new QueryManager(query, _classPrivateFieldGet2(_options, this));
7116
+ }
7117
+ /**
7118
+ * Runs `fn`, deferring history recording and subscriber notification until it returns. The
7119
+ * whole batch becomes a single undo step and triggers a single notification, or neither if
7120
+ * the query ends up unchanged.
7121
+ *
7122
+ * Batches may be nested; only the outermost one commits. If `fn` throws, the query and its
7123
+ * history are restored to their pre-batch state and the error propagates, so a batch either
7124
+ * applies completely or not at all.
7125
+ *
7126
+ * {@link QueryManager.undo}, {@link QueryManager.redo}, and {@link QueryManager.clearHistory}
7127
+ * may be called inside a batch; their notifications are deferred like everything else. Because
7128
+ * they manage the history stacks themselves, a batch containing one of them records no entry of
7129
+ * its own, leaving the stacks exactly as those methods left them.
7130
+ */
7131
+ batch(fn) {
7132
+ var _this$batchDepth;
7133
+ _classPrivateFieldSet2(_batchDepth, this, (_this$batchDepth = _classPrivateFieldGet2(_batchDepth, this), _this$batchDepth++, _this$batchDepth));
7134
+ if (_classPrivateFieldGet2(_batchDepth, this) === 1) _classPrivateFieldSet2(_batchSnapshot, this, {
7135
+ query: _classPrivateFieldGet2(_query, this),
7136
+ past: [..._classPrivateFieldGet2(_past, this)],
7137
+ future: [..._classPrivateFieldGet2(_future, this)],
7138
+ lastSig: _classPrivateFieldGet2(_lastSig, this),
7139
+ lastAt: _classPrivateFieldGet2(_lastAt, this)
7140
+ });
7141
+ try {
7142
+ fn();
7143
+ } catch (error) {
7144
+ if (_classPrivateFieldGet2(_batchDepth, this) === 1) {
7145
+ const snapshot = _classPrivateFieldGet2(_batchSnapshot, this);
7146
+ _classPrivateFieldSet2(_query, this, snapshot.query);
7147
+ _classPrivateFieldSet2(_past, this, snapshot.past);
7148
+ _classPrivateFieldSet2(_future, this, snapshot.future);
7149
+ _classPrivateFieldSet2(_lastSig, this, snapshot.lastSig);
7150
+ _classPrivateFieldSet2(_lastAt, this, snapshot.lastAt);
7151
+ }
7152
+ throw error;
7153
+ } finally {
7154
+ var _this$batchDepth3;
7155
+ _classPrivateFieldSet2(_batchDepth, this, (_this$batchDepth3 = _classPrivateFieldGet2(_batchDepth, this), _this$batchDepth3--, _this$batchDepth3));
7156
+ if (_classPrivateFieldGet2(_batchDepth, this) === 0) {
7157
+ const { query: base } = _classPrivateFieldGet2(_batchSnapshot, this);
7158
+ _classPrivateFieldSet2(_batchSnapshot, this, void 0);
7159
+ if (base !== _classPrivateFieldGet2(_query, this)) {
7160
+ if (!_classPrivateFieldGet2(_historyBypassed, this)) _assertClassBrand(_QueryManager_brand, this, _record).call(this, base, _classPrivateFieldGet2(_query, this));
7161
+ _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
7162
+ }
7163
+ _classPrivateFieldSet2(_historyBypassed, this, false);
7164
+ }
7165
+ }
7166
+ return this;
7167
+ }
7168
+ /** Whether there is a previous query to restore. Always `false` unless `history` is enabled. */
7169
+ canUndo() {
7170
+ return _classPrivateFieldGet2(_past, this).length > 0;
7171
+ }
7172
+ /** Whether there is an undone query to restore. Always `false` unless `history` is enabled. */
7173
+ canRedo() {
7174
+ return _classPrivateFieldGet2(_future, this).length > 0;
7175
+ }
7176
+ /** Restores the previous query. No-op when {@link QueryManager.canUndo} is `false`. */
7177
+ undo() {
7178
+ if (_classPrivateFieldGet2(_past, this).length === 0) return this;
7179
+ _classPrivateFieldGet2(_future, this).unshift(_classPrivateFieldGet2(_query, this));
7180
+ _classPrivateFieldSet2(_query, this, _classPrivateFieldGet2(_past, this).pop());
7181
+ _classPrivateFieldSet2(_lastSig, this, void 0);
7182
+ _assertClassBrand(_QueryManager_brand, this, _markHistoryBypassed).call(this);
7183
+ if (_classPrivateFieldGet2(_batchDepth, this) === 0) _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
7184
+ return this;
7185
+ }
7186
+ /** Restores the most recently undone query. No-op when {@link QueryManager.canRedo} is `false`. */
7187
+ redo() {
7188
+ if (_classPrivateFieldGet2(_future, this).length === 0) return this;
7189
+ _classPrivateFieldGet2(_past, this).push(_classPrivateFieldGet2(_query, this));
7190
+ _classPrivateFieldSet2(_query, this, _classPrivateFieldGet2(_future, this).shift());
7191
+ _classPrivateFieldSet2(_lastSig, this, void 0);
7192
+ _assertClassBrand(_QueryManager_brand, this, _markHistoryBypassed).call(this);
7193
+ if (_classPrivateFieldGet2(_batchDepth, this) === 0) _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
7194
+ return this;
7195
+ }
7196
+ /** Discards all undo/redo history without changing the current query. */
7197
+ clearHistory() {
7198
+ _assertClassBrand(_QueryManager_brand, this, _markHistoryBypassed).call(this);
7199
+ _classPrivateFieldSet2(_past, this, []);
7200
+ _classPrivateFieldSet2(_future, this, []);
7201
+ _classPrivateFieldSet2(_lastSig, this, void 0);
7202
+ return this;
7203
+ }
7204
+ /**
7205
+ * The recorded history: `past` oldest first, `future` newest first. Both are copies, so
7206
+ * mutating them does not affect the manager.
7207
+ */
7208
+ getHistory() {
7209
+ return {
7210
+ past: [..._classPrivateFieldGet2(_past, this)],
7211
+ future: [..._classPrivateFieldGet2(_future, this)]
7212
+ };
7213
+ }
7214
+ /**
7215
+ * Validates the current query with the configured validator.
7216
+ *
7217
+ * The result is cached until the query changes, so a custom `validator` with side effects (or
7218
+ * one that depends on anything other than the query) may run fewer times than expected.
7219
+ */
7220
+ validate() {
7221
+ var _classPrivateFieldGet4;
7222
+ _assertClassBrand(_QueryManager_brand, this, _ensureCache).call(this);
7223
+ (_classPrivateFieldGet4 = _classPrivateFieldGet2(_validation, this)) !== null && _classPrivateFieldGet4 !== void 0 || _classPrivateFieldSet2(_validation, this, _classPrivateFieldGet2(_validator, this).call(this, _classPrivateFieldGet2(_query, this)));
7224
+ return _classPrivateFieldGet2(_validation, this);
7225
+ }
7226
+ format(options) {
7227
+ return formatQuery(_classPrivateFieldGet2(_query, this), options);
7228
+ }
7229
+ /**
7230
+ * Yields every rule and group in the query, depth-first in pre-order, starting with the root
7231
+ * group itself. Combinator strings in independent-combinator groups are skipped.
7232
+ *
7233
+ * ```ts
7234
+ * for (const { node, path, parent } of qm.walk({ rulesOnly: true })) {
7235
+ * console.log(path, node.field);
7236
+ * }
7237
+ * ```
7238
+ *
7239
+ * Traversal operates on the query as it was when iteration began, so mutating the manager
7240
+ * mid-iteration does not affect a walk already in progress. Because generators are lazy, that
7241
+ * happens on the first iteration step rather than when `walk` is called.
7242
+ *
7243
+ * @yields Every rule and group in the query, subject to `options`.
7244
+ */
7245
+ *walk(options = {}) {
7246
+ const { from, rulesOnly, groupsOnly } = options;
7247
+ let start = _classPrivateFieldGet2(_query, this);
7248
+ let startPath = [];
7249
+ let startParent = null;
7250
+ if (from !== void 0) {
7251
+ const path = _assertClassBrand(_QueryManager_brand, this, _toPath).call(this, from);
7252
+ const node = path && findPath(path, _classPrivateFieldGet2(_query, this));
7253
+ if (!path || !node) return;
7254
+ start = node;
7255
+ startPath = path;
7256
+ startParent = path.length === 0 ? null : findPath(getParentPath(path), _classPrivateFieldGet2(_query, this));
7257
+ }
7258
+ for (const entry of _assertClassBrand(_QueryManager_brand, this, _walkFrom).call(this, start, startPath, startParent)) {
7259
+ if (rulesOnly && isRuleGroup(entry.node)) continue;
7260
+ if (groupsOnly && !isRuleGroup(entry.node)) continue;
7261
+ yield entry;
7262
+ }
7263
+ }
7264
+ /** Yields every rule in the query. Shorthand for `walk({ ...options, rulesOnly: true })`. */
7265
+ rules(options = {}) {
7266
+ return this.walk(_objectSpread2(_objectSpread2({}, options), {}, { rulesOnly: true }));
7267
+ }
7268
+ /**
7269
+ * Yields every group in the query, including the root group. Shorthand for
7270
+ * `walk({ ...options, groupsOnly: true })`.
7271
+ */
7272
+ groups(options = {}) {
7273
+ return this.walk(_objectSpread2(_objectSpread2({}, options), {}, { groupsOnly: true }));
7274
+ }
7275
+ /** Returns the first node matching `predicate`, or `null` if there is none. */
7276
+ find(predicate, options = {}) {
7277
+ for (const entry of this.walk(options)) if (predicate(entry)) return entry;
7278
+ return null;
7279
+ }
7280
+ /** Returns every node matching `predicate`. */
7281
+ filter(predicate, options = {}) {
7282
+ const results = [];
7283
+ for (const entry of this.walk(options)) if (predicate(entry)) results.push(entry);
7284
+ return results;
7285
+ }
7286
+ /** Equivalent to {@link QueryManager.walk} with no options, enabling `for...of` and spread. */
7287
+ [_Symbol$iterator]() {
7288
+ return this.walk();
7289
+ }
7290
+ /**
7291
+ * Returns the rule or group at the given path, or `null` if the path can't be resolved.
7292
+ *
7293
+ * Unlike the standalone {@link findPath}, which can return `undefined` for an out-of-range
7294
+ * index, unresolvable paths are always normalized to `null` here.
7295
+ */
7296
+ findPath(path) {
7297
+ var _findPath;
7298
+ return (_findPath = findPath(path, _classPrivateFieldGet2(_query, this))) !== null && _findPath !== void 0 ? _findPath : null;
7299
+ }
7300
+ /**
7301
+ * Returns the rule or group with the given `id`, or `null` if there is none. Backed by an
7302
+ * index built once per query, so repeated lookups are constant time.
7303
+ */
7304
+ findID(id) {
7305
+ const path = _assertClassBrand(_QueryManager_brand, this, _index).call(this).get(id);
7306
+ return path === void 0 ? null : findPath(path, _classPrivateFieldGet2(_query, this));
7307
+ }
7308
+ /**
7309
+ * Returns the {@link Path} of the rule or group with the given `id`, or `null` if there is
7310
+ * none. Backed by an index built once per query, so repeated lookups are constant time.
7311
+ */
7312
+ getPathOfID(id) {
7313
+ var _this$index$get2;
7314
+ return (_this$index$get2 = _assertClassBrand(_QueryManager_brand, this, _index).call(this).get(id)) !== null && _this$index$get2 !== void 0 ? _this$index$get2 : null;
7315
+ }
7316
+ /**
7317
+ * Determines whether the rule or group at the given path is disabled, either itself or by an
7318
+ * ancestor group.
7319
+ */
7320
+ pathIsDisabled(path) {
7321
+ return pathIsDisabled(path, _classPrivateFieldGet2(_query, this));
7322
+ }
7323
+ /** Returns the rule or group at the given path or `id`, or `null` if it can't be resolved. */
7324
+ getNode(pathOrID) {
7325
+ var _findPath2;
7326
+ const path = _assertClassBrand(_QueryManager_brand, this, _toPath).call(this, pathOrID);
7327
+ return path === null ? null : (_findPath2 = findPath(path, _classPrivateFieldGet2(_query, this))) !== null && _findPath2 !== void 0 ? _findPath2 : null;
7328
+ }
7329
+ /**
7330
+ * Returns the rule at the given path or `id`, or `null` if it can't be resolved _or_ resolves
7331
+ * to a group.
7332
+ */
7333
+ getRule(pathOrID) {
7334
+ const node = this.getNode(pathOrID);
7335
+ return node && !isRuleGroup(node) ? node : null;
7336
+ }
7337
+ /**
7338
+ * Returns the group at the given path or `id`, or `null` if it can't be resolved _or_
7339
+ * resolves to a rule.
7340
+ */
7341
+ getGroup(pathOrID) {
7342
+ const node = this.getNode(pathOrID);
7343
+ return node && isRuleGroup(node) ? node : null;
7344
+ }
7345
+ /**
7346
+ * Returns the group containing the rule or group at the given path or `id`. Returns `null`
7347
+ * for the root group, which has no parent, and when the target can't be resolved.
7348
+ */
7349
+ getParent(pathOrID) {
7350
+ const path = _assertClassBrand(_QueryManager_brand, this, _toPath).call(this, pathOrID);
7351
+ if (path === null || path.length === 0) return null;
7352
+ if (!findPath(path, _classPrivateFieldGet2(_query, this))) return null;
7353
+ return findPath(getParentPath(path), _classPrivateFieldGet2(_query, this));
7354
+ }
7355
+ /**
7356
+ * The normalized field list, as the `QueryBuilder` component would render it. Needed to
7357
+ * populate a field selector.
7358
+ */
7359
+ getFields() {
7360
+ return _classPrivateFieldGet2(_fields, this);
7361
+ }
7362
+ /**
7363
+ * The normalized combinator list, as the `QueryBuilder` component would render it. Needed to
7364
+ * populate a combinator selector.
7365
+ */
7366
+ getCombinators() {
7367
+ return _classPrivateFieldGet2(_combinators, this);
7368
+ }
7369
+ /**
7370
+ * The field configuration for a field name. When the field isn't configured, returns the same
7371
+ * minimal fallback (`{ name, value, label }`, all set to the field name) that
7372
+ * {@link QueryManager.getRuleContext} reports as `fieldData`, so both access paths agree.
7373
+ */
7374
+ getFieldData(field) {
7375
+ return getFieldData(field, _classPrivateFieldGet2(_fieldMap, this));
7376
+ }
7377
+ /** The operator list for a field, mirroring `QueryBuilder`'s precedence. */
7378
+ getOperators(field) {
7379
+ return _assertClassBrand(_QueryManager_brand, this, _operatorsFor).call(this, field);
7380
+ }
7381
+ /** The value sources available for a field/operator pair. */
7382
+ getValueSources(field, operator) {
7383
+ return _assertClassBrand(_QueryManager_brand, this, _valueSourcesFor).call(this, field, operator);
7384
+ }
7385
+ /** The match modes available for a field. */
7386
+ getMatchModes(field) {
7387
+ return _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, field);
7388
+ }
7389
+ /** The value option list for a field/operator pair. */
7390
+ getValues(field, operator) {
7391
+ return _assertClassBrand(_QueryManager_brand, this, _valuesFor).call(this, field, operator);
7392
+ }
7393
+ /** The value editor type for a field/operator pair. */
7394
+ getValueEditorType(field, operator) {
7395
+ return _assertClassBrand(_QueryManager_brand, this, _valueEditorTypeFor).call(this, field, operator);
7396
+ }
7397
+ /**
7398
+ * Resolves everything about a rule that depends on the field/operator configuration—field data,
7399
+ * operators, value editor type, value list, value sources, match modes, and validation result.
7400
+ * Returns `null` when the target can't be resolved or isn't a rule.
7401
+ *
7402
+ * This is the same derivation the `useRule` hook performs, so a non-React implementation can
7403
+ * render a rule without reimplementing the configuration precedence rules.
7404
+ */
7405
+ getRuleContext(pathOrID) {
7406
+ const rule = this.getRule(pathOrID);
7407
+ if (!rule) return null;
7408
+ const validation = this.validate();
7409
+ return deriveRuleContext(rule, {
7410
+ fields: _classPrivateFieldGet2(_fields, this),
7411
+ fieldMap: _classPrivateFieldGet2(_fieldMap, this),
7412
+ getInputType: (f, o, misc) => {
7413
+ var _this$options$getInpu, _classPrivateFieldGet5, _classPrivateFieldGet6;
7414
+ return (_this$options$getInpu = (_classPrivateFieldGet5 = (_classPrivateFieldGet6 = _classPrivateFieldGet2(_options, this)).getInputType) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.call(_classPrivateFieldGet6, f, o, misc)) !== null && _this$options$getInpu !== void 0 ? _this$options$getInpu : null;
7415
+ },
7416
+ getMatchModes: (f) => _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, f),
7417
+ getOperators: (f) => _assertClassBrand(_QueryManager_brand, this, _operatorsFor).call(this, f),
7418
+ getParameters: (f, o, misc) => _assertClassBrand(_QueryManager_brand, this, _parametersFor).call(this, f, o, misc),
7419
+ getValueEditorType: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valueEditorTypeFor).call(this, f, o),
7420
+ getValues: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valuesFor).call(this, f, o),
7421
+ getValueSources: (f, o) => this.getValueSources(f, o),
7422
+ getSubQueryBuilderProps: (f, misc) => {
7423
+ var _this$options$getSubQ, _classPrivateFieldGet7, _classPrivateFieldGet8;
7424
+ return (_this$options$getSubQ = (_classPrivateFieldGet7 = (_classPrivateFieldGet8 = _classPrivateFieldGet2(_options, this)).getSubQueryBuilderProps) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.call(_classPrivateFieldGet8, f, misc)) !== null && _this$options$getSubQ !== void 0 ? _this$options$getSubQ : {};
7425
+ }
7426
+ }, {
7427
+ validationMap: typeof validation === "boolean" ? {} : validation,
7428
+ id: rule.id
7429
+ });
7430
+ }
7431
+ /**
7432
+ * Resolves everything about a rule group that depends on the combinator configuration, plus its
7433
+ * validation result. Returns `null` when the target can't be resolved or isn't a group.
7434
+ *
7435
+ * This is the same derivation the `useRuleGroup` hook performs.
7436
+ */
7437
+ getRuleGroupContext(pathOrID = []) {
7438
+ const ruleGroup = this.getGroup(pathOrID);
7439
+ if (!ruleGroup) return null;
7440
+ const validation = this.validate();
7441
+ return deriveRuleGroupContext(ruleGroup, _classPrivateFieldGet2(_combinators, this), {
7442
+ validationMap: typeof validation === "boolean" ? {} : validation,
7443
+ id: ruleGroup.id
7444
+ });
7445
+ }
7446
+ /** Whether the current query uses independent combinators. */
7447
+ isIC() {
7448
+ return isRuleGroupTypeIC(_classPrivateFieldGet2(_query, this));
7449
+ }
7450
+ /**
7451
+ * Returns the signature describing how the current query differs from `other`, as used by
7452
+ * this manager's history coalescing.
7453
+ */
7454
+ signatureOf(other) {
7455
+ return signatureOf(_classPrivateFieldGet2(_query, this), other);
7456
+ }
7457
+ /** Generates a {@link DiagnosticsResult}. Shorthand for `format('diagnostics')`. */
7458
+ diagnostics() {
7459
+ return formatQuery(_classPrivateFieldGet2(_query, this), "diagnostics");
7460
+ }
7461
+ /**
7462
+ * Returns the current query, so `JSON.stringify(queryManager)` produces the same output as
7463
+ * `JSON.stringify(queryManager.getQuery())`.
7464
+ */
7465
+ toJSON() {
7466
+ return _classPrivateFieldGet2(_query, this);
7467
+ }
7468
+ /**
7469
+ * Returns a new manager with the same configuration and the current query converted to use
7470
+ * independent combinators. Idempotent, and never modifies this manager. As with
7471
+ * {@link QueryManager.clone}, subscribers and history are not carried over.
7472
+ */
7473
+ toIC() {
7474
+ return new QueryManager(convertToIC(_classPrivateFieldGet2(_query, this)), _classPrivateFieldGet2(_options, this));
7475
+ }
7476
+ /**
7477
+ * Returns a new manager with the same configuration and the current query converted to use a
7478
+ * single combinator per group. Idempotent, and never modifies this manager. As with
7479
+ * {@link QueryManager.clone}, subscribers and history are not carried over.
7480
+ */
7481
+ fromIC() {
7482
+ return new QueryManager(convertFromIC(_classPrivateFieldGet2(_query, this)), _classPrivateFieldGet2(_options, this));
7483
+ }
7484
+ /**
7485
+ * Runs {@link transformQuery} against the current query and returns its result.
7486
+ *
7487
+ * Unlike {@link QueryManager.toIC}/{@link QueryManager.fromIC}, this returns the raw
7488
+ * transformed value rather than a new manager, since `transformQuery` can produce arbitrary
7489
+ * shapes that are no longer valid queries. This manager is never modified.
7490
+ */
7491
+ transform(options) {
7492
+ return transformQuery(_classPrivateFieldGet2(_query, this), options);
7493
+ }
7494
+ };
7495
+ /** Resolves the field configuration for a field name. */
7496
+ function _fieldData(field) {
7497
+ var _this$fieldMap$field;
7498
+ return (_this$fieldMap$field = _classPrivateFieldGet2(_fieldMap, this)[field]) !== null && _this$fieldMap$field !== void 0 ? _this$fieldMap$field : {};
7499
+ }
7500
+ /** Resolves the operator list for a field, mirroring `QueryBuilder`'s precedence. */
7501
+ function _operatorsFor(field) {
7502
+ return resolveOperatorList({
7503
+ field,
7504
+ fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7505
+ getOperators: _classPrivateFieldGet2(_options, this).getOperators,
7506
+ operators: _classPrivateFieldGet2(_operators, this),
7507
+ baseOption: _classPrivateFieldGet2(_options, this).baseOperator,
7508
+ autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectOperator
7509
+ });
7510
+ }
7511
+ /** Resolves the default operator for a field, mirroring `QueryBuilder`'s precedence. */
7512
+ function _defaultOperator(field) {
7513
+ return resolveDefaultOperator({
7514
+ field,
7515
+ fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7516
+ getDefaultOperator: _classPrivateFieldGet2(_options, this).getDefaultOperator,
7517
+ getOperators: (f) => _assertClassBrand(_QueryManager_brand, this, _operatorsFor).call(this, f)
7518
+ });
7519
+ }
7520
+ function _valueSourcesFor(field, operator) {
7521
+ return getValueSourcesUtil(_assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field), operator, _classPrivateFieldGet2(_options, this).getValueSources);
7522
+ }
7523
+ function _matchModesFor(field) {
7524
+ return getMatchModesUtil(_assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field), _classPrivateFieldGet2(_options, this).getMatchModes);
7525
+ }
7526
+ function _valuesFor(field, operator) {
7527
+ return resolveValueList({
7528
+ field,
7529
+ operator,
7530
+ fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7531
+ getValues: _classPrivateFieldGet2(_options, this).getValues,
7532
+ autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectValue
7533
+ });
7534
+ }
7535
+ function _valueEditorTypeFor(field, operator) {
7536
+ return resolveValueEditorType({
7537
+ field,
7538
+ operator,
7539
+ fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7540
+ getValueEditorType: _classPrivateFieldGet2(_options, this).getValueEditorType
7541
+ });
7542
+ }
7543
+ /** Computes the default `value` for a rule, mirroring `QueryBuilder`'s precedence. */
7544
+ function _defaultValue(rule) {
7545
+ const { getDefaultValue, getParameters, listsAsArrays } = _classPrivateFieldGet2(_options, this);
7546
+ return getRuleDefaultValue(rule, {
7547
+ fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, rule.field),
7548
+ fields: _classPrivateFieldGet2(_fields, this),
7549
+ listsAsArrays,
7550
+ getValueEditorType: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valueEditorTypeFor).call(this, f, o),
7551
+ getValues: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valuesFor).call(this, f, o),
7552
+ getDefaultValue: getDefaultValue && ((r, misc) => getDefaultValue(r, misc)),
7553
+ getParameters: getParameters && ((f, o, misc) => _assertClassBrand(_QueryManager_brand, this, _parametersFor).call(this, f, o, misc))
7554
+ });
7555
+ }
7556
+ /**
7557
+ * Resolves the parameter list for a field/operator pair, normalized the same way as every
7558
+ * other option list. Shared by {@link QueryManager.#defaultValue} and
7559
+ * {@link QueryManager.getRuleContext} so both see the same shape.
7560
+ */
7561
+ function _parametersFor(field, operator, misc) {
7562
+ var _this$options$getPara, _classPrivateFieldGet2$1, _classPrivateFieldGet3;
7563
+ return prepareOptionList({
7564
+ optionList: (_this$options$getPara = (_classPrivateFieldGet2$1 = (_classPrivateFieldGet3 = _classPrivateFieldGet2(_options, this)).getParameters) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.call(_classPrivateFieldGet3, field, operator, misc)) !== null && _this$options$getPara !== void 0 ? _this$options$getPara : [],
7565
+ autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectValue
7566
+ }).optionList;
7567
+ }
7568
+ /** Defaults shared by every mutating method, overridable per call. */
7569
+ function _guardOptions() {
7570
+ const { maxLevels } = _classPrivateFieldGet2(_options, this);
7571
+ return {
7572
+ maxLevels: (maxLevels !== null && maxLevels !== void 0 ? maxLevels : 0) > 0 ? Number(maxLevels) : Infinity,
7573
+ respectDisabled: _classPrivateFieldGet2(_respectDisabled, this),
7574
+ disabledPaths: _classPrivateFieldGet2(_options, this).disabledPaths,
7575
+ queryDisabled: _classPrivateFieldGet2(_options, this).queryDisabled
7576
+ };
7577
+ }
7578
+ function _toolOptions() {
7579
+ return _objectSpread2({
7580
+ combinators: _classPrivateFieldGet2(_combinators, this),
7581
+ idGenerator: _classPrivateFieldGet2(_idGenerator, this)
7582
+ }, _assertClassBrand(_QueryManager_brand, this, _guardOptions).call(this));
7583
+ }
7584
+ /**
7585
+ * Builds the `onAbort` handler passed to the query tools, applying the per-call overrides on
7586
+ * top of the manager's own options.
7587
+ */
7588
+ function _onAbort({ strict, onInvalidTarget }) {
7589
+ const strictMain = strict !== null && strict !== void 0 ? strict : _classPrivateFieldGet2(_strict, this);
7590
+ const handler = onInvalidTarget !== null && onInvalidTarget !== void 0 ? onInvalidTarget : _classPrivateFieldGet2(_onInvalidTarget, this);
7591
+ return (info) => {
7592
+ handler === null || handler === void 0 || handler(info);
7593
+ if (strictMain && strictAbortReasonSet.has(info.reason)) throw new QueryManagerError(info);
7594
+ };
7595
+ }
7596
+ /** Defaults for {@link update}, so resets mirror `QueryBuilder`'s behavior. */
7597
+ function _updateOptions() {
7598
+ return _objectSpread2({
7599
+ getRuleDefaultOperator: (f) => _assertClassBrand(_QueryManager_brand, this, _defaultOperator).call(this, f),
7600
+ getRuleDefaultValue: (r) => _assertClassBrand(_QueryManager_brand, this, _defaultValue).call(this, r),
7601
+ getValueSources: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valueSourcesFor).call(this, f, o),
7602
+ getMatchModes: (f) => _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, f),
7603
+ resetOnFieldChange: _classPrivateFieldGet2(_options, this).resetOnFieldChange,
7604
+ resetOnOperatorChange: _classPrivateFieldGet2(_options, this).resetOnOperatorChange
7605
+ }, _assertClassBrand(_QueryManager_brand, this, _guardOptions).call(this));
7606
+ }
7607
+ /**
7608
+ * Applies a new query, recording history and notifying subscribers as appropriate. Every
7609
+ * mutation funnels through here. A tool that could not resolve its target returns the same
7610
+ * query object, which is treated as a no-op.
7611
+ */
7612
+ function _commit(next) {
7613
+ const prev = _classPrivateFieldGet2(_query, this);
7614
+ if (prev === next) return;
7615
+ _classPrivateFieldSet2(_query, this, next);
7616
+ if (_classPrivateFieldGet2(_batchDepth, this) > 0) return;
7617
+ _assertClassBrand(_QueryManager_brand, this, _record).call(this, prev, next);
7618
+ _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
7619
+ }
7620
+ /**
7621
+ * Records a change, either as a new history entry or by absorbing it into the current one.
7622
+ * Mirrors the recording semantics of the `react-querybuilder/history` entry point.
7623
+ */
7624
+ function _record(prev, next) {
7625
+ if (!_classPrivateFieldGet2(_historyEnabled, this)) return;
7626
+ const sig = signatureOf(prev, next);
7627
+ if (sig === "") return;
7628
+ const now = _classPrivateFieldGet2(_now, this).call(this);
7629
+ if (!(sig !== "~structural" && sig === _classPrivateFieldGet2(_lastSig, this) && now - _classPrivateFieldGet2(_lastAt, this) < _classPrivateFieldGet2(_coalesceMs, this))) {
7630
+ _classPrivateFieldGet2(_past, this).push(prev);
7631
+ if (_classPrivateFieldGet2(_past, this).length > _classPrivateFieldGet2(_maxHistory, this)) _classPrivateFieldGet2(_past, this).shift();
7632
+ _classPrivateFieldSet2(_future, this, []);
7633
+ }
7634
+ _classPrivateFieldSet2(_lastSig, this, sig);
7635
+ _classPrivateFieldSet2(_lastAt, this, now);
7636
+ }
7637
+ function _notify() {
7638
+ for (const listener of _classPrivateFieldGet2(_listeners, this)) listener();
7639
+ }
7640
+ /**
7641
+ * Records that a history-stack method ran inside the current batch. Those methods manage
7642
+ * `#past`/`#future` themselves, so the batch must not also record an entry on completion —
7643
+ * doing so would push a duplicate onto `#past` and clear the redo stack that `undo` just
7644
+ * populated.
7645
+ */
7646
+ function _markHistoryBypassed() {
7647
+ if (_classPrivateFieldGet2(_batchDepth, this) > 0) _classPrivateFieldSet2(_historyBypassed, this, true);
7648
+ }
7649
+ /**
7650
+ * Discards every cached derivation when the query has been replaced since they were computed.
7651
+ * Called at the top of each cached reader.
7652
+ */
7653
+ function _ensureCache() {
7654
+ if (_classPrivateFieldGet2(_cacheFor, this) === _classPrivateFieldGet2(_query, this)) return;
7655
+ _classPrivateFieldSet2(_cacheFor, this, _classPrivateFieldGet2(_query, this));
7656
+ _classPrivateFieldSet2(_idPathIndex, this, void 0);
7657
+ _classPrivateFieldSet2(_validation, this, void 0);
7658
+ }
7659
+ /**
7660
+ * The single traversal implementation. Combinator strings in independent-combinator groups
7661
+ * are skipped.
7662
+ *
7663
+ * @yields The subtree rooted at `node`, depth-first in pre-order, starting with `node` itself.
7664
+ */
7665
+ function* _walkFrom(node, path, parent) {
7666
+ yield {
7667
+ node,
7668
+ path,
7669
+ parent
7670
+ };
7671
+ if (!isRuleGroup(node)) return;
7672
+ const startGroup = node;
7673
+ for (const [index, child] of startGroup.rules.entries()) {
7674
+ if (typeof child === "string") continue;
7675
+ yield* _assertClassBrand(_QueryManager_brand, this, _walkFrom).call(this, child, [...path, index], startGroup);
7676
+ }
7677
+ }
7678
+ /** Builds (once per query) the `id` to {@link Path} index backing `findID`/`getPathOfID`. */
7679
+ function _index() {
7680
+ _assertClassBrand(_QueryManager_brand, this, _ensureCache).call(this);
7681
+ if (!_classPrivateFieldGet2(_idPathIndex, this)) {
7682
+ const index = /* @__PURE__ */ new Map();
7683
+ for (const { node, path } of _assertClassBrand(_QueryManager_brand, this, _walkFrom).call(this, _classPrivateFieldGet2(_query, this), [], null)) if (node.id !== void 0 && !index.has(node.id)) index.set(node.id, path);
7684
+ _classPrivateFieldSet2(_idPathIndex, this, index);
7685
+ }
7686
+ return _classPrivateFieldGet2(_idPathIndex, this);
7687
+ }
7688
+ /** Resolves a path or `id` to a path, or `null` when the `id` isn't present. */
7689
+ function _toPath(pathOrID) {
7690
+ var _this$index$get;
7691
+ return typeof pathOrID === "string" ? (_this$index$get = _assertClassBrand(_QueryManager_brand, this, _index).call(this).get(pathOrID)) !== null && _this$index$get !== void 0 ? _this$index$get : null : pathOrID;
7692
+ }
7693
+ //#endregion
7694
+ export { LogType, QueryManager, QueryManagerError, TestID, add, addInPlace, betweenOperators, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, coerceBigIntValue, coerceInputType, convertFromIC, convertQuery, convertToIC, createQueryActions, createRule, createRuleGroup, cypherCombinatorMap, defaultCELValueProcessor, defaultCoalesceMs, defaultCombinatorLabelMap, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultExportOperatorMap, defaultJoinChar, defaultMatchModes, defaultMaxHistory, defaultMongoDBValueProcessor, defaultNLTranslations, defaultOperatorLabelMap, defaultOperatorNegationMap, defaultOperatorProcessorNL, defaultOperatorProcessorSQL, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderLabel, defaultPlaceholderName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultPlaceholderValueGroupLabel, defaultPlaceholderValueLabel, defaultPlaceholderValueName, defaultRuleGroupProcessorCEL, defaultRuleGroupProcessorCypher, defaultRuleGroupProcessorDiagnostics, defaultRuleGroupProcessorDrizzle, defaultRuleGroupProcessorElasticSearch, defaultRuleGroupProcessorGremlin, defaultRuleGroupProcessorJSONata, defaultRuleGroupProcessorJsonLogic, defaultRuleGroupProcessorLDAP, defaultRuleGroupProcessorMongoDB, defaultRuleGroupProcessorMongoDBQuery, defaultRuleGroupProcessorNL, defaultRuleGroupProcessorParameterized, defaultRuleGroupProcessorPrisma, defaultRuleGroupProcessorSPARQL, defaultRuleGroupProcessorSQL, defaultRuleGroupProcessorSequelize, defaultRuleGroupProcessorSpEL, defaultRuleGroupProcessorTanStackDB, defaultRuleProcessorCEL, defaultRuleProcessorCypher, defaultRuleProcessorDrizzle, defaultRuleProcessorElasticSearch, defaultRuleProcessorGremlin, defaultRuleProcessorJSONata, defaultRuleProcessorJsonLogic, defaultRuleProcessorLDAP, defaultRuleProcessorMongoDB, defaultRuleProcessorMongoDBQuery, defaultRuleProcessorNL, defaultRuleProcessorParameterized, defaultRuleProcessorPrisma, defaultRuleProcessorSPARQL, defaultRuleProcessorSQL, defaultRuleProcessorSequelize, defaultRuleProcessorSpEL, defaultRuleProcessorTanStackDB, defaultSpELValueProcessor, defaultTranslations, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorNL, defaultValueProcessorSpELByRule, derivePathInfo, deriveRuleClassName, deriveRuleClassNames, deriveRuleContext, deriveRuleGroupClassNames, deriveRuleGroupContext, deriveRuleGroupOuterClassName, deriveRuleOuterClassName, exceedsMaxLevels, filterFieldsByComparator, findID, findPath, formatQuery, formatQueryOptionPresets, generateAccessibleDescription, generateID, getCommonAncestorPath, getFieldData, getFirstOption, getGuardAbortReason, getLikeWildcards, getMatchModesUtil, getMultiValueUpdate, getNLTranslataion, getOption, getParametersAsList, getParentPath, getParseNumberMethod, getPathOfID, getQuoteFieldNamesWithArray, getQuotedFieldName, getRuleDefaultValue, getRuleGroupCombinator, getRuleInputType, getRuleValidationResult, getRuleValueEditorType, getRuleValueSourceOptions, getRuleValues, getSQLConcat, getSubqueryElementAlias, getValidationClassNames, getValueEditorReset, getValueSelectorUpdate, getValueSourcesUtil, group, groupInPlace, groupInvalidReasons, hideValueControlsForOperator, inOperators, insert, insertInPlace, isAncestor, isBetweenOperator, isFlexibleOptionArray, isFlexibleOptionGroupArray, isFullOptionArray, isFullOptionGroupArray, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isRuleType, isUnsafeKey, isValidValue, isValidationResult, isValueProcessorLegacy, joinWith, jsonLogicAdditionalOperators, lc, mapSQLOperator, mergeAnyTranslation, mergeAnyTranslations, mergeClassnames, mongoDbFallback, mongoOperators, move, moveInPlace, normalizeConstituentWordOrder, normalizeValueSelectorValue, nullFreeArray, nullOperators, nullOrUndefinedOrEmpty, numericRegex, numerifyValues, objectEntries, objectKeys, parseNumber, pathIsDisabled, pathIsDisabledByPaths, pathsAreEqual, preferAnyProp, preferFlagProps, preferProp, prepareOptionList, prepareRule, prepareRuleGroup, prepareRuleOrGroup, prismaFallback, prismaOperators, processMatchMode, queryBuilderFlagDefaults, regenerateID, regenerateIDs, relationalOperators, remove, removeInPlace, resolveCandidateQuery, resolveDefaultOperator, resolveOperatorList, resolveValueEditorType, resolveValueList, rootPath, shouldRenderAsNumber, signatureOf, sparqlVar, splitBy, sqlDialectPresets, standardClassnames, strictAbortReasons, stripParamPrefix, structuralSignature, subqueryElementAliasBase, substringOperators, toArray, toFlatOptionArray, toFullOption, toFullOptionList, toFullOptionMap, transformQuery, trimIfString, unchangedSignature, uniqByIdentifier, uniqByName, uniqOptGroups, uniqOptList, update, updateInPlace, uuidV4regex, withParamPrefix, wrapLikeFragment };
5508
7695
 
5509
7696
  //# sourceMappingURL=react-querybuilder_core.legacy-esm.js.map