@react-querybuilder/core 8.22.5 → 8.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/derivations/package.json +4 -0
  2. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +2078 -1665
  3. package/dist/cjs/react-querybuilder_core.cjs.development.js +1293 -422
  4. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  5. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +2078 -1665
  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/{convertQuery-Cw76XFIn.js → convertQuery-BLT0GIhM.js} +17 -8
  9. package/dist/{convertQuery-Cw76XFIn.js.map → convertQuery-BLT0GIhM.js.map} +1 -1
  10. package/dist/{convertQuery-D_4J7E-Z.mjs → convertQuery-DaXv3h7S.mjs} +6 -3
  11. package/dist/{convertQuery-D_4J7E-Z.mjs.map → convertQuery-DaXv3h7S.mjs.map} +1 -1
  12. package/dist/derivations.d.mts +2902 -0
  13. package/dist/derivations.d.ts +2902 -0
  14. package/dist/derivations.js +2845 -0
  15. package/dist/derivations.js.map +1 -0
  16. package/dist/derivations.mjs +2678 -0
  17. package/dist/derivations.mjs.map +1 -0
  18. package/dist/formatQuery.d.mts +2 -895
  19. package/dist/formatQuery.d.ts +2 -895
  20. package/dist/formatQuery.js +120 -140
  21. package/dist/formatQuery.js.map +1 -1
  22. package/dist/formatQuery.mjs +8 -28
  23. package/dist/formatQuery.mjs.map +1 -1
  24. package/dist/{import-DVWI7Fdh.d.mts → import-BdKPtLzo.d.mts} +2 -2
  25. package/dist/{import-6ExjhifL.d.ts → import-BfZTwhp2.d.ts} +2 -2
  26. package/dist/{index-CX9mehdL.d.mts → index-DOIE2pwx.d.mts} +274 -3
  27. package/dist/{index-CX9mehdL.d.ts → index-DOIE2pwx.d.ts} +274 -3
  28. package/dist/index-OF2Q1gTp.d.mts +895 -0
  29. package/dist/index-XueTy_XQ.d.ts +895 -0
  30. package/dist/isRuleOrGroupValid-CIMZNkt4.mjs +27 -0
  31. package/dist/isRuleOrGroupValid-CIMZNkt4.mjs.map +1 -0
  32. package/dist/isRuleOrGroupValid-CtUf4_4x.js +38 -0
  33. package/dist/isRuleOrGroupValid-CtUf4_4x.js.map +1 -0
  34. package/dist/{isRuleGroup-CqLThsbu.mjs → objectUtils-DDZ-KhV5.mjs} +25 -2
  35. package/dist/objectUtils-DDZ-KhV5.mjs.map +1 -0
  36. package/dist/{isRuleGroup-0JNiQgLg.js → objectUtils-DfnEmDSV.js} +48 -1
  37. package/dist/objectUtils-DfnEmDSV.js.map +1 -0
  38. package/dist/parseCEL.d.mts +2 -2
  39. package/dist/parseCEL.d.ts +2 -2
  40. package/dist/parseCEL.js +19 -16
  41. package/dist/parseCEL.js.map +1 -1
  42. package/dist/parseCEL.mjs +12 -9
  43. package/dist/parseCEL.mjs.map +1 -1
  44. package/dist/parseCypher.d.mts +1 -1
  45. package/dist/parseCypher.d.ts +1 -1
  46. package/dist/parseGremlin.d.mts +1 -1
  47. package/dist/parseGremlin.d.ts +1 -1
  48. package/dist/parseJSONata.d.mts +2 -2
  49. package/dist/parseJSONata.d.ts +2 -2
  50. package/dist/parseJSONata.js +17 -14
  51. package/dist/parseJSONata.js.map +1 -1
  52. package/dist/parseJSONata.mjs +11 -8
  53. package/dist/parseJSONata.mjs.map +1 -1
  54. package/dist/parseJsonLogic.d.mts +2 -2
  55. package/dist/parseJsonLogic.d.ts +2 -2
  56. package/dist/parseJsonLogic.js +38 -38
  57. package/dist/parseJsonLogic.js.map +1 -1
  58. package/dist/parseJsonLogic.mjs +5 -5
  59. package/dist/parseMongoDB.d.mts +2 -2
  60. package/dist/parseMongoDB.d.ts +2 -2
  61. package/dist/parseMongoDB.js +50 -47
  62. package/dist/parseMongoDB.js.map +1 -1
  63. package/dist/parseMongoDB.mjs +35 -32
  64. package/dist/parseMongoDB.mjs.map +1 -1
  65. package/dist/parseSPARQL.d.mts +1 -1
  66. package/dist/parseSPARQL.d.ts +1 -1
  67. package/dist/parseSQL.d.mts +2 -2
  68. package/dist/parseSQL.d.ts +2 -2
  69. package/dist/parseSQL.js +27 -23
  70. package/dist/parseSQL.js.map +1 -1
  71. package/dist/parseSQL.mjs +21 -17
  72. package/dist/parseSQL.mjs.map +1 -1
  73. package/dist/parseSpEL.d.mts +2 -2
  74. package/dist/parseSpEL.d.ts +2 -2
  75. package/dist/parseSpEL.js +17 -14
  76. package/dist/parseSpEL.js.map +1 -1
  77. package/dist/parseSpEL.mjs +13 -10
  78. package/dist/parseSpEL.mjs.map +1 -1
  79. package/dist/parserUtils-BKPstAaO.mjs +30 -0
  80. package/dist/parserUtils-BKPstAaO.mjs.map +1 -0
  81. package/dist/parserUtils-DbBXyAht.js +41 -0
  82. package/dist/parserUtils-DbBXyAht.js.map +1 -0
  83. package/dist/{prepareQueryObjects-BnGL91Tt.js → prepareQueryObjects-Dj9cTl9D.js} +90 -63
  84. package/dist/prepareQueryObjects-Dj9cTl9D.js.map +1 -0
  85. package/dist/{prepareQueryObjects-ChINDIap.mjs → prepareQueryObjects-Dmyf3Wi_.mjs} +56 -59
  86. package/dist/prepareQueryObjects-Dmyf3Wi_.mjs.map +1 -0
  87. package/dist/react-querybuilder_core.d.mts +2078 -1665
  88. package/dist/react-querybuilder_core.legacy-esm.d.ts +2078 -1665
  89. package/dist/react-querybuilder_core.legacy-esm.js +1445 -635
  90. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  91. package/dist/react-querybuilder_core.mjs +1288 -424
  92. package/dist/react-querybuilder_core.mjs.map +1 -1
  93. package/dist/react-querybuilder_core.production.d.mts +2078 -1665
  94. package/dist/react-querybuilder_core.production.mjs +1 -1
  95. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  96. package/dist/transformQuery-B7d9AWUf.d.mts +116 -0
  97. package/dist/transformQuery-BXDiUBGB.d.ts +116 -0
  98. package/dist/transformQuery.d.mts +2 -116
  99. package/dist/transformQuery.d.ts +2 -116
  100. package/dist/transformQuery.js +3 -4
  101. package/dist/transformQuery.js.map +1 -1
  102. package/dist/transformQuery.mjs +1 -2
  103. package/dist/transformQuery.mjs.map +1 -1
  104. package/dist/utils-CP5Jqy1P.mjs +1294 -0
  105. package/dist/utils-CP5Jqy1P.mjs.map +1 -0
  106. package/dist/utils-e-7KHkjV.js +1779 -0
  107. package/dist/utils-e-7KHkjV.js.map +1 -0
  108. package/package.json +33 -22
  109. package/dist/isRuleGroup-0JNiQgLg.js.map +0 -1
  110. package/dist/isRuleGroup-CqLThsbu.mjs.map +0 -1
  111. package/dist/objectUtils-Cr02aGxb.js +0 -27
  112. package/dist/objectUtils-Cr02aGxb.js.map +0 -1
  113. package/dist/objectUtils-DBlmJgBf.mjs +0 -16
  114. package/dist/objectUtils-DBlmJgBf.mjs.map +0 -1
  115. package/dist/prepareQueryObjects-BnGL91Tt.js.map +0 -1
  116. package/dist/prepareQueryObjects-ChINDIap.mjs.map +0 -1
  117. package/dist/utils-4k-j5FBa.mjs +0 -537
  118. package/dist/utils-4k-j5FBa.mjs.map +0 -1
  119. package/dist/utils-C79dxwZb.js +0 -752
  120. package/dist/utils-C79dxwZb.js.map +0 -1
@@ -1,5 +1,646 @@
1
1
  import { numericQuantity, numericRegex as numericRegex$1 } from "numeric-quantity";
2
- import { current, freeze, isDraft, produce } from "immer";
2
+ import { Immer, current, freeze, isDraft, produce, setAutoFreeze as setAutoFreeze$1 } from "immer";
3
+ //#region src/controlPropKeys.ts
4
+ /**
5
+ * Runtime data describing the set of query builder controls and the props each one receives.
6
+ *
7
+ * These live in `@react-querybuilder/core` (not `react-querybuilder`) so that non-React ports
8
+ * can consume them without a React dependency.
9
+ *
10
+ * Nothing here can drift from the React implementation unnoticed:
11
+ * `react-querybuilder`'s `types/controlPropKeys.test.ts` gates {@link controlKeys} against
12
+ * `defaultControlElements` and `ControlElementsProp`, and every entry of
13
+ * {@link controlPropKeys} against the corresponding props interface—both at runtime and at
14
+ * compile time, in both directions.
15
+ */
16
+ /**
17
+ * The name of every query builder control, alphabetized.
18
+ *
19
+ * @group Props
20
+ */
21
+ const controlKeys = [
22
+ "actionElement",
23
+ "addGroupAction",
24
+ "addRuleAction",
25
+ "cloneGroupAction",
26
+ "cloneRuleAction",
27
+ "combinatorSelector",
28
+ "dragHandle",
29
+ "fieldSelector",
30
+ "inlineCombinator",
31
+ "lockGroupAction",
32
+ "lockRuleAction",
33
+ "matchModeEditor",
34
+ "muteGroupAction",
35
+ "muteRuleAction",
36
+ "notToggle",
37
+ "operatorSelector",
38
+ "removeGroupAction",
39
+ "removeRuleAction",
40
+ "rule",
41
+ "ruleGroup",
42
+ "ruleGroupBodyElements",
43
+ "ruleGroupHeaderElements",
44
+ "shiftActions",
45
+ "undoRedoActions",
46
+ "valueEditor",
47
+ "valueSelector",
48
+ "valueSourceSelector"
49
+ ];
50
+ /**
51
+ * The full set of prop names each default control receives. Ports can use this to declare
52
+ * every prop explicitly instead of relying on fall-through/attribute inheritance.
53
+ *
54
+ * Each array is the complete, alphabetized key set of the control's props interface in
55
+ * `react-querybuilder`. The lists are written out in full rather than composed from shared
56
+ * bases because `--isolatedDeclarations` cannot infer array types built with spreads. A
57
+ * compile-time gate in `react-querybuilder` (`types/controlPropKeys.test.ts`) fails the build
58
+ * if any list drifts from its interface in either direction.
59
+ *
60
+ * @group Props
61
+ */
62
+ const controlPropKeys = {
63
+ actionElement: [
64
+ "className",
65
+ "context",
66
+ "disabled",
67
+ "disabledTranslation",
68
+ "handleOnClick",
69
+ "label",
70
+ "level",
71
+ "path",
72
+ "ruleOrGroup",
73
+ "rules",
74
+ "schema",
75
+ "testID",
76
+ "title",
77
+ "validation"
78
+ ],
79
+ addGroupAction: [
80
+ "className",
81
+ "context",
82
+ "disabled",
83
+ "disabledTranslation",
84
+ "handleOnClick",
85
+ "label",
86
+ "level",
87
+ "path",
88
+ "ruleOrGroup",
89
+ "rules",
90
+ "schema",
91
+ "testID",
92
+ "title",
93
+ "validation"
94
+ ],
95
+ addRuleAction: [
96
+ "className",
97
+ "context",
98
+ "disabled",
99
+ "disabledTranslation",
100
+ "handleOnClick",
101
+ "label",
102
+ "level",
103
+ "path",
104
+ "ruleOrGroup",
105
+ "rules",
106
+ "schema",
107
+ "testID",
108
+ "title",
109
+ "validation"
110
+ ],
111
+ cloneGroupAction: [
112
+ "className",
113
+ "context",
114
+ "disabled",
115
+ "disabledTranslation",
116
+ "handleOnClick",
117
+ "label",
118
+ "level",
119
+ "path",
120
+ "ruleOrGroup",
121
+ "rules",
122
+ "schema",
123
+ "testID",
124
+ "title",
125
+ "validation"
126
+ ],
127
+ cloneRuleAction: [
128
+ "className",
129
+ "context",
130
+ "disabled",
131
+ "disabledTranslation",
132
+ "handleOnClick",
133
+ "label",
134
+ "level",
135
+ "path",
136
+ "ruleOrGroup",
137
+ "rules",
138
+ "schema",
139
+ "testID",
140
+ "title",
141
+ "validation"
142
+ ],
143
+ combinatorSelector: [
144
+ "className",
145
+ "context",
146
+ "disabled",
147
+ "handleOnChange",
148
+ "level",
149
+ "options",
150
+ "path",
151
+ "ruleGroup",
152
+ "rules",
153
+ "schema",
154
+ "testID",
155
+ "title",
156
+ "validation",
157
+ "value"
158
+ ],
159
+ dragHandle: [
160
+ "className",
161
+ "context",
162
+ "disabled",
163
+ "dragHandleAttributes",
164
+ "label",
165
+ "level",
166
+ "path",
167
+ "ruleOrGroup",
168
+ "schema",
169
+ "testID",
170
+ "title",
171
+ "validation"
172
+ ],
173
+ fieldSelector: [
174
+ "className",
175
+ "context",
176
+ "disabled",
177
+ "handleOnChange",
178
+ "level",
179
+ "operator",
180
+ "options",
181
+ "path",
182
+ "rule",
183
+ "schema",
184
+ "testID",
185
+ "title",
186
+ "validation",
187
+ "value"
188
+ ],
189
+ inlineCombinator: [
190
+ "className",
191
+ "component",
192
+ "context",
193
+ "disabled",
194
+ "handleOnChange",
195
+ "level",
196
+ "options",
197
+ "path",
198
+ "ruleGroup",
199
+ "rules",
200
+ "schema",
201
+ "testID",
202
+ "title",
203
+ "validation",
204
+ "value"
205
+ ],
206
+ lockGroupAction: [
207
+ "className",
208
+ "context",
209
+ "disabled",
210
+ "disabledTranslation",
211
+ "handleOnClick",
212
+ "label",
213
+ "level",
214
+ "path",
215
+ "ruleOrGroup",
216
+ "rules",
217
+ "schema",
218
+ "testID",
219
+ "title",
220
+ "validation"
221
+ ],
222
+ lockRuleAction: [
223
+ "className",
224
+ "context",
225
+ "disabled",
226
+ "disabledTranslation",
227
+ "handleOnClick",
228
+ "label",
229
+ "level",
230
+ "path",
231
+ "ruleOrGroup",
232
+ "rules",
233
+ "schema",
234
+ "testID",
235
+ "title",
236
+ "validation"
237
+ ],
238
+ matchModeEditor: [
239
+ "className",
240
+ "classNames",
241
+ "context",
242
+ "disabled",
243
+ "field",
244
+ "fieldData",
245
+ "handleOnChange",
246
+ "level",
247
+ "match",
248
+ "numericEditorComponent",
249
+ "options",
250
+ "path",
251
+ "rule",
252
+ "schema",
253
+ "selectorComponent",
254
+ "testID",
255
+ "thresholdPlaceholder",
256
+ "title",
257
+ "validation",
258
+ "value"
259
+ ],
260
+ muteGroupAction: [
261
+ "className",
262
+ "context",
263
+ "disabled",
264
+ "disabledTranslation",
265
+ "handleOnClick",
266
+ "label",
267
+ "level",
268
+ "path",
269
+ "ruleOrGroup",
270
+ "rules",
271
+ "schema",
272
+ "testID",
273
+ "title",
274
+ "validation"
275
+ ],
276
+ muteRuleAction: [
277
+ "className",
278
+ "context",
279
+ "disabled",
280
+ "disabledTranslation",
281
+ "handleOnClick",
282
+ "label",
283
+ "level",
284
+ "path",
285
+ "ruleOrGroup",
286
+ "rules",
287
+ "schema",
288
+ "testID",
289
+ "title",
290
+ "validation"
291
+ ],
292
+ notToggle: [
293
+ "checked",
294
+ "className",
295
+ "context",
296
+ "disabled",
297
+ "handleOnChange",
298
+ "label",
299
+ "level",
300
+ "path",
301
+ "ruleGroup",
302
+ "schema",
303
+ "testID",
304
+ "title",
305
+ "validation"
306
+ ],
307
+ operatorSelector: [
308
+ "className",
309
+ "context",
310
+ "disabled",
311
+ "field",
312
+ "fieldData",
313
+ "handleOnChange",
314
+ "level",
315
+ "options",
316
+ "path",
317
+ "rule",
318
+ "schema",
319
+ "testID",
320
+ "title",
321
+ "validation",
322
+ "value"
323
+ ],
324
+ removeGroupAction: [
325
+ "className",
326
+ "context",
327
+ "disabled",
328
+ "disabledTranslation",
329
+ "handleOnClick",
330
+ "label",
331
+ "level",
332
+ "path",
333
+ "ruleOrGroup",
334
+ "rules",
335
+ "schema",
336
+ "testID",
337
+ "title",
338
+ "validation"
339
+ ],
340
+ removeRuleAction: [
341
+ "className",
342
+ "context",
343
+ "disabled",
344
+ "disabledTranslation",
345
+ "handleOnClick",
346
+ "label",
347
+ "level",
348
+ "path",
349
+ "ruleOrGroup",
350
+ "rules",
351
+ "schema",
352
+ "testID",
353
+ "title",
354
+ "validation"
355
+ ],
356
+ rule: [
357
+ "actions",
358
+ "context",
359
+ "disabled",
360
+ "dndRef",
361
+ "dragHandleAttributes",
362
+ "dragMonitorId",
363
+ "dragRef",
364
+ "dropEffect",
365
+ "dropMonitorId",
366
+ "dropNotAllowed",
367
+ "field",
368
+ "groupItems",
369
+ "id",
370
+ "isDragging",
371
+ "isOver",
372
+ "operator",
373
+ "parentDisabled",
374
+ "parentMuted",
375
+ "path",
376
+ "rule",
377
+ "schema",
378
+ "shiftDownDisabled",
379
+ "shiftUpDisabled",
380
+ "translations",
381
+ "value",
382
+ "valueSource"
383
+ ],
384
+ ruleGroup: [
385
+ "actions",
386
+ "combinator",
387
+ "context",
388
+ "disabled",
389
+ "dragHandleAttributes",
390
+ "dragMonitorId",
391
+ "dragRef",
392
+ "dropEffect",
393
+ "dropMonitorId",
394
+ "dropNotAllowed",
395
+ "dropRef",
396
+ "groupItems",
397
+ "id",
398
+ "isDragging",
399
+ "isOver",
400
+ "not",
401
+ "parentDisabled",
402
+ "parentMuted",
403
+ "path",
404
+ "previewRef",
405
+ "ruleGroup",
406
+ "rules",
407
+ "schema",
408
+ "shiftDownDisabled",
409
+ "shiftUpDisabled",
410
+ "translations"
411
+ ],
412
+ ruleGroupBodyElements: [
413
+ "accessibleDescription",
414
+ "actions",
415
+ "addGroup",
416
+ "addRule",
417
+ "classNames",
418
+ "cloneGroup",
419
+ "combinator",
420
+ "context",
421
+ "disabled",
422
+ "dragHandleAttributes",
423
+ "dragMonitorId",
424
+ "dragRef",
425
+ "dropEffect",
426
+ "dropMonitorId",
427
+ "dropNotAllowed",
428
+ "dropRef",
429
+ "groupItems",
430
+ "id",
431
+ "isDragging",
432
+ "isOver",
433
+ "muted",
434
+ "not",
435
+ "onCombinatorChange",
436
+ "onGroupAdd",
437
+ "onIndependentCombinatorChange",
438
+ "onNotToggleChange",
439
+ "outerClassName",
440
+ "parentDisabled",
441
+ "parentMuted",
442
+ "path",
443
+ "pathsMemo",
444
+ "previewRef",
445
+ "removeGroup",
446
+ "ruleGroup",
447
+ "rules",
448
+ "schema",
449
+ "shiftDownDisabled",
450
+ "shiftGroupDown",
451
+ "shiftGroupUp",
452
+ "shiftUpDisabled",
453
+ "toggleLockGroup",
454
+ "toggleMuteGroup",
455
+ "translations",
456
+ "validationClassName",
457
+ "validationResult"
458
+ ],
459
+ ruleGroupHeaderElements: [
460
+ "accessibleDescription",
461
+ "actions",
462
+ "addGroup",
463
+ "addRule",
464
+ "classNames",
465
+ "cloneGroup",
466
+ "combinator",
467
+ "context",
468
+ "disabled",
469
+ "dragHandleAttributes",
470
+ "dragMonitorId",
471
+ "dragRef",
472
+ "dropEffect",
473
+ "dropMonitorId",
474
+ "dropNotAllowed",
475
+ "dropRef",
476
+ "groupItems",
477
+ "id",
478
+ "isDragging",
479
+ "isOver",
480
+ "muted",
481
+ "not",
482
+ "onCombinatorChange",
483
+ "onGroupAdd",
484
+ "onIndependentCombinatorChange",
485
+ "onNotToggleChange",
486
+ "outerClassName",
487
+ "parentDisabled",
488
+ "parentMuted",
489
+ "path",
490
+ "pathsMemo",
491
+ "previewRef",
492
+ "removeGroup",
493
+ "ruleGroup",
494
+ "rules",
495
+ "schema",
496
+ "shiftDownDisabled",
497
+ "shiftGroupDown",
498
+ "shiftGroupUp",
499
+ "shiftUpDisabled",
500
+ "toggleLockGroup",
501
+ "toggleMuteGroup",
502
+ "translations",
503
+ "validationClassName",
504
+ "validationResult"
505
+ ],
506
+ shiftActions: [
507
+ "className",
508
+ "context",
509
+ "disabled",
510
+ "labels",
511
+ "level",
512
+ "path",
513
+ "ruleOrGroup",
514
+ "schema",
515
+ "shiftDown",
516
+ "shiftDownDisabled",
517
+ "shiftUp",
518
+ "shiftUpDisabled",
519
+ "testID",
520
+ "title",
521
+ "titles",
522
+ "validation"
523
+ ],
524
+ undoRedoActions: [
525
+ "className",
526
+ "classNames",
527
+ "context",
528
+ "disabled",
529
+ "labels",
530
+ "level",
531
+ "path",
532
+ "ruleOrGroup",
533
+ "schema",
534
+ "testID",
535
+ "title",
536
+ "titles",
537
+ "validation"
538
+ ],
539
+ valueEditor: [
540
+ "className",
541
+ "context",
542
+ "disabled",
543
+ "field",
544
+ "fieldData",
545
+ "handleOnChange",
546
+ "inputType",
547
+ "level",
548
+ "listsAsArrays",
549
+ "operator",
550
+ "parseNumbers",
551
+ "path",
552
+ "rule",
553
+ "schema",
554
+ "selectorComponent",
555
+ "separator",
556
+ "skipHook",
557
+ "testID",
558
+ "title",
559
+ "type",
560
+ "validation",
561
+ "value",
562
+ "valueSource",
563
+ "values"
564
+ ],
565
+ valueSelector: [
566
+ "className",
567
+ "context",
568
+ "disabled",
569
+ "handleOnChange",
570
+ "level",
571
+ "listsAsArrays",
572
+ "multiple",
573
+ "options",
574
+ "path",
575
+ "schema",
576
+ "testID",
577
+ "title",
578
+ "validation",
579
+ "value"
580
+ ],
581
+ valueSourceSelector: [
582
+ "className",
583
+ "context",
584
+ "disabled",
585
+ "field",
586
+ "fieldData",
587
+ "handleOnChange",
588
+ "level",
589
+ "options",
590
+ "path",
591
+ "rule",
592
+ "schema",
593
+ "testID",
594
+ "title",
595
+ "validation",
596
+ "value"
597
+ ]
598
+ };
599
+ /**
600
+ * Which bulk override, if any, applies to each control: `"action"` for controls that a supplied
601
+ * `actionElement` replaces, `"selector"` for controls that a supplied `valueSelector` replaces,
602
+ * and `null` for controls that neither replaces.
603
+ *
604
+ * `actionElement` and `valueSelector` are themselves `null`—they are the _source_ of a bulk
605
+ * override, not a target of one.
606
+ *
607
+ * Replaces name-suffix sniffing (`key.endsWith('Action')`), which would silently misclassify a
608
+ * future control named e.g. `pathSelector`, and which disagrees between implementations about
609
+ * whether `shiftActions`/`undoRedoActions` (plural) match. They do not: neither receives the
610
+ * `actionElement` bulk override.
611
+ *
612
+ * @group Props
613
+ */
614
+ const controlKind = {
615
+ actionElement: null,
616
+ addGroupAction: "action",
617
+ addRuleAction: "action",
618
+ cloneGroupAction: "action",
619
+ cloneRuleAction: "action",
620
+ combinatorSelector: "selector",
621
+ dragHandle: null,
622
+ fieldSelector: "selector",
623
+ inlineCombinator: null,
624
+ lockGroupAction: "action",
625
+ lockRuleAction: "action",
626
+ matchModeEditor: null,
627
+ muteGroupAction: "action",
628
+ muteRuleAction: "action",
629
+ notToggle: null,
630
+ operatorSelector: "selector",
631
+ removeGroupAction: "action",
632
+ removeRuleAction: "action",
633
+ rule: null,
634
+ ruleGroup: null,
635
+ ruleGroupBodyElements: null,
636
+ ruleGroupHeaderElements: null,
637
+ shiftActions: null,
638
+ undoRedoActions: null,
639
+ valueEditor: null,
640
+ valueSelector: null,
641
+ valueSourceSelector: "selector"
642
+ };
643
+ //#endregion
3
644
  //#region src/defaults.ts
4
645
  /**
5
646
  * @group Defaults
@@ -648,6 +1289,31 @@ const defaultMaxHistory = 50;
648
1289
  */
649
1290
  const defaultCoalesceMs = 500;
650
1291
  //#endregion
1292
+ //#region src/utils/abortReasons.ts
1293
+ /**
1294
+ * Abort reasons that {@link QueryManager}'s `strict` mode treats as errors. The remaining
1295
+ * reasons—`"same-location"` and `"no-change"`—describe valid operations that had nothing to do,
1296
+ * so they are reported to `onInvalidTarget` but never throw.
1297
+ *
1298
+ * Declared apart from `QueryManager` so the `@react-querybuilder/core/derivations` entry point can
1299
+ * export it without putting the manager in its module graph.
1300
+ *
1301
+ * @group Query Tools
1302
+ */
1303
+ const strictAbortReasons = [
1304
+ "target-not-found",
1305
+ "parent-not-found",
1306
+ "parent-not-a-group",
1307
+ "destination-not-found",
1308
+ "root-not-allowed",
1309
+ "not-a-combinator-slot",
1310
+ "target-disabled",
1311
+ "parent-disabled",
1312
+ "max-levels-exceeded"
1313
+ ];
1314
+ /** @internal */
1315
+ const strictAbortReasonSet = new Set(strictAbortReasons);
1316
+ //#endregion
651
1317
  //#region src/utils/arrayUtils.ts
652
1318
  /**
653
1319
  * Splits a string by a given character (see {@link defaultJoinChar}). Escaped characters
@@ -750,7 +1416,100 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
750
1416
  */
751
1417
  const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
752
1418
  //#endregion
753
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
1419
+ //#region src/utils/signature.ts
1420
+ /**
1421
+ * Signature returned when a change alters the _shape_ of the query—rules or groups added,
1422
+ * removed, moved, or reordered—rather than the properties of a single node. Structural changes
1423
+ * never coalesce with each other, so each one produces its own history entry.
1424
+ */
1425
+ const structuralSignature = "~structural";
1426
+ /**
1427
+ * Signature returned when two queries differ by reference only, with no observable difference
1428
+ * in their properties.
1429
+ */
1430
+ const unchangedSignature = "";
1431
+ /**
1432
+ * Returns the list of property names that differ between two nodes, ignoring `rules` (which is
1433
+ * compared structurally by the caller).
1434
+ */
1435
+ const changedProps = (prev, next) => {
1436
+ const keys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(next)]);
1437
+ keys.delete("rules");
1438
+ const changed = [];
1439
+ for (const key of keys) if (!Object.is(prev[key], next[key])) changed.push(key);
1440
+ return changed.toSorted();
1441
+ };
1442
+ const signatureOfNode = (prev, next, parentId, index) => {
1443
+ var _next$id3;
1444
+ if (prev === next) return "";
1445
+ if (typeof prev === "string" || typeof next === "string") return typeof prev === typeof next ? `${parentId}:combinator[${index}]` : structuralSignature;
1446
+ const prevIsGroup = isRuleGroup(prev);
1447
+ const nextIsGroup = isRuleGroup(next);
1448
+ if (prevIsGroup !== nextIsGroup) return structuralSignature;
1449
+ if (!prevIsGroup || !nextIsGroup) {
1450
+ var _next$id;
1451
+ const props = changedProps(prev, next);
1452
+ return props.length === 0 ? "" : `${(_next$id = next.id) !== null && _next$id !== void 0 ? _next$id : ""}:${props.join(",")}`;
1453
+ }
1454
+ if (prev.rules.length !== next.rules.length) return structuralSignature;
1455
+ const ownProps = changedProps(prev, next);
1456
+ let changedIndex = -1;
1457
+ for (const [i, prevRule] of prev.rules.entries()) if (prevRule !== next.rules[i]) {
1458
+ if (changedIndex !== -1) return structuralSignature;
1459
+ changedIndex = i;
1460
+ }
1461
+ if (changedIndex === -1) {
1462
+ var _next$id2;
1463
+ return ownProps.length === 0 ? "" : `${(_next$id2 = next.id) !== null && _next$id2 !== void 0 ? _next$id2 : ""}:${ownProps.join(",")}`;
1464
+ }
1465
+ if (ownProps.length > 0) return structuralSignature;
1466
+ return signatureOfNode(prev.rules[changedIndex], next.rules[changedIndex], (_next$id3 = next.id) !== null && _next$id3 !== void 0 ? _next$id3 : "", changedIndex);
1467
+ };
1468
+ /**
1469
+ * Describes _what changed_ between two versions of a query as a short string, so that
1470
+ * consecutive edits to the same property of the same rule (e.g. typing in a value editor) can
1471
+ * be recognized and coalesced into a single history entry.
1472
+ *
1473
+ * Returns {@link structuralSignature} for changes to the shape of the query, {@link unchangedSignature} when the
1474
+ * two queries differ by reference only, and `"<id>:<props>"` otherwise.
1475
+ *
1476
+ * The walk prunes on reference equality, so it costs O(depth) rather than O(size) for the
1477
+ * single-node edits that make up the overwhelming majority of changes.
1478
+ *
1479
+ * Note that this relies on the structural sharing that Immer—and therefore every query
1480
+ * produced by RQB's own update functions—guarantees: nodes that did not change keep their
1481
+ * identity. A query that has been wholly rebuilt (deep-cloned, round-tripped through JSON,
1482
+ * re-parsed from a string) shares no identity with its predecessor, so it is reported as
1483
+ * {@link structuralSignature} and will not coalesce. That is a graceful degradation—every change simply
1484
+ * gets its own history entry—but controlled components that clone the query on every change
1485
+ * will not benefit from coalescing.
1486
+ */
1487
+ const signatureOf = (prev, next) => signatureOfNode(prev, next, "", -1);
1488
+ //#endregion
1489
+ //#region src/utils/coalesce.ts
1490
+ /**
1491
+ * Determines whether a change should be absorbed into the current history entry instead of
1492
+ * pushing a new one. This is the exact rule {@link QueryManager} applies when recording history,
1493
+ * exposed so non-React implementations can manage their own history stacks without
1494
+ * reimplementing (and drifting from) the semantics.
1495
+ *
1496
+ * A change coalesces only when all three hold:
1497
+ * - the change is not structural (rules/groups added, removed, moved, or reordered)
1498
+ * - its signature matches the previously recorded signature
1499
+ * - it occurred within `coalesceMs` of the previous recording
1500
+ *
1501
+ * Note that {@link unchangedSignature} is not handled here. A change with no observable
1502
+ * difference is never recorded at all, which is a separate decision made before this check.
1503
+ *
1504
+ * @param prevSig Signature of the previously recorded change, or `undefined` if there is none.
1505
+ * @param nextSig Signature of the change being recorded, from {@link signatureOf}.
1506
+ * @param prevAt Timestamp of the previous recording.
1507
+ * @param now Timestamp of the change being recorded.
1508
+ * @param coalesceMs Coalescing window in milliseconds.
1509
+ */
1510
+ const shouldCoalesce = (prevSig, nextSig, prevAt, now, coalesceMs = 500) => nextSig !== "~structural" && nextSig === prevSig && now >= prevAt && now - prevAt < coalesceMs;
1511
+ //#endregion
1512
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/typeof.js
754
1513
  function _typeof(o) {
755
1514
  "@babel/helpers - typeof";
756
1515
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -760,7 +1519,7 @@ function _typeof(o) {
760
1519
  }, _typeof(o);
761
1520
  }
762
1521
  //#endregion
763
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
1522
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPrimitive.js
764
1523
  function toPrimitive(t, r) {
765
1524
  if ("object" != _typeof(t) || !t) return t;
766
1525
  var e = t[Symbol.toPrimitive];
@@ -772,13 +1531,13 @@ function toPrimitive(t, r) {
772
1531
  return ("string" === r ? String : Number)(t);
773
1532
  }
774
1533
  //#endregion
775
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
1534
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPropertyKey.js
776
1535
  function toPropertyKey(t) {
777
1536
  var i = toPrimitive(t, "string");
778
1537
  return "symbol" == _typeof(i) ? i : i + "";
779
1538
  }
780
1539
  //#endregion
781
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
1540
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/defineProperty.js
782
1541
  function _defineProperty(e, r, t) {
783
1542
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
784
1543
  value: t,
@@ -788,7 +1547,7 @@ function _defineProperty(e, r, t) {
788
1547
  }) : e[r] = t, e;
789
1548
  }
790
1549
  //#endregion
791
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectSpread2.js
1550
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/objectSpread2.js
792
1551
  function ownKeys(e, r) {
793
1552
  var t = Object.keys(e);
794
1553
  if (Object.getOwnPropertySymbols) {
@@ -811,7 +1570,7 @@ function _objectSpread2(e) {
811
1570
  return e;
812
1571
  }
813
1572
  //#endregion
814
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectWithoutPropertiesLoose.js
1573
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/objectWithoutPropertiesLoose.js
815
1574
  function _objectWithoutPropertiesLoose(r, e) {
816
1575
  if (null == r) return {};
817
1576
  var t = {};
@@ -822,7 +1581,7 @@ function _objectWithoutPropertiesLoose(r, e) {
822
1581
  return t;
823
1582
  }
824
1583
  //#endregion
825
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/objectWithoutProperties.js
1584
+ //#region \0@oxc-project+runtime@0.144.0/helpers/esm/objectWithoutProperties.js
826
1585
  function _objectWithoutProperties(e, t) {
827
1586
  if (null == e) return {};
828
1587
  var o, r, i = _objectWithoutPropertiesLoose(e, t);
@@ -1351,6 +2110,20 @@ const uniqOptList = (originalArray) => {
1351
2110
  if (isFlexibleOptionGroupArray(originalArray)) return uniqOptGroups(originalArray);
1352
2111
  return uniqByIdentifier(originalArray.map((o) => toFullOption(o)));
1353
2112
  };
2113
+ /**
2114
+ * Normalizes any accepted option list shape—array, option groups, or a record—into a
2115
+ * `FullOptionList`, applying `baseOption` properties and (when `autoSelectOption` is `false`)
2116
+ * a leading placeholder option. Also returns the flattened lookup map and the option that
2117
+ * should be selected by default.
2118
+ *
2119
+ * Note: `labelMap` overrides only apply to array/option group input (where string options are
2120
+ * expanded); record input derives labels from the record values themselves.
2121
+ *
2122
+ * This is the same normalization `<QueryBuilder />` applies to `fields`, `operators`,
2123
+ * `combinators`, and value lists, so a non-React implementation resolves options identically.
2124
+ *
2125
+ * @group Option Lists
2126
+ */
1354
2127
  const prepareOptionList = (props) => {
1355
2128
  // v8 ignore next
1356
2129
  const { optionList: optionListPropOriginal, baseOption = {}, labelMap = {}, placeholder: { placeholderName = "~", placeholderLabel = defaultPlaceholderLabel, placeholderGroupLabel = defaultPlaceholderLabel } = {}, autoSelectOption = true } = props;
@@ -4628,8 +5401,10 @@ const defaultRuleProcessorParameterized = (rule, opts, meta) => {
4628
5401
  return finalize(`${qPre}${rule.field}${qPost} ${sqlOperator} ${paramPrefix}${firstParamName} and ${paramPrefix}${secondParamName}`);
4629
5402
  }
4630
5403
  let paramValue = rule.value;
4631
- if (typeof rule.value === "string") if (shouldRenderAsNumber(rule.value, parseNumbers)) paramValue = parseNumber(rule.value, { parseNumbers });
4632
- else paramValue = /^'.*'$/g.test(value) ? value.replaceAll(/(^'|'$)/g, "") : /* v8 ignore next -- @preserve */ value;
5404
+ if (typeof rule.value === "string") {
5405
+ if (shouldRenderAsNumber(rule.value, parseNumbers)) paramValue = parseNumber(rule.value, { parseNumbers });
5406
+ else paramValue = /^'.*'$/g.test(value) ? value.replaceAll(/(^'|'$)/g, "") : /* v8 ignore next -- @preserve */ value;
5407
+ }
4633
5408
  let paramName = "";
4634
5409
  if (parameterized) params.push(paramValue);
4635
5410
  else {
@@ -5353,6 +6128,12 @@ const derivePathInfo = (path, childCount, { disabled = false, disabledPaths = []
5353
6128
  };
5354
6129
  //#endregion
5355
6130
  //#region src/utils/generateAccessibleDescription.ts
6131
+ /**
6132
+ * The default `accessibleDescriptionGenerator`. Produces the `aria-label` for a rule group:
6133
+ * `"Query builder"` for the root group, `"Rule group at path 0-1"` for any other.
6134
+ *
6135
+ * @group Accessibility
6136
+ */
5356
6137
  const generateAccessibleDescription = (params) => pathsAreEqual([], params.path) ? `Query builder` : `Rule group at path ${params.path.join("-")}`;
5357
6138
  //#endregion
5358
6139
  //#region src/utils/generateID.ts
@@ -5391,6 +6172,29 @@ if (cryptoModule) {
5391
6172
  }
5392
6173
  }
5393
6174
  //#endregion
6175
+ //#region src/utils/immerInstances.ts
6176
+ /**
6177
+ * Globally enables or disables immer's auto-freeze, i.e. the deep freeze applied to every query
6178
+ * returned by {@link add}, {@link update}, {@link remove}, {@link move}, {@link insert}, and
6179
+ * {@link group}.
6180
+ *
6181
+ * Re-exported from immer so that consumers mixing these tools with their own `produce` calls can
6182
+ * switch both at once. Prefer the per-call `freeze` option, or the {@link QueryManager} option of
6183
+ * the same name, when the change should not be process-wide. A per-call `freeze: false` wins
6184
+ * regardless of this setting; a per-call `freeze: true` does not re-enable freezing once this has
6185
+ * turned it off, since it selects immer's default instance.
6186
+ *
6187
+ * @group Query Tools
6188
+ */
6189
+ const setAutoFreeze = setAutoFreeze$1;
6190
+ const unfrozenImmer = new Immer({ autoFreeze: false });
6191
+ /**
6192
+ * The `produce` implementation matching the requested freeze behavior.
6193
+ *
6194
+ * @internal
6195
+ */
6196
+ const producerFor = (freeze = true) => freeze ? produce : unfrozenImmer.produce;
6197
+ //#endregion
5394
6198
  //#region src/utils/getMatchModesUtil.ts
5395
6199
  const dummyFD$1 = {
5396
6200
  name: "name",
@@ -5661,6 +6465,46 @@ const resolveValueList = ({ field, operator, fieldData, getValues, placeholder,
5661
6465
  }).optionList;
5662
6466
  };
5663
6467
  //#endregion
6468
+ //#region src/utils/optionsEqual.ts
6469
+ const isPlainObject = (x) => {
6470
+ const proto = Object.getPrototypeOf(x);
6471
+ return proto === null || proto === Object.prototype;
6472
+ };
6473
+ /**
6474
+ * Structural equality for {@link QueryManagerOptions} values. Arrays and plain objects are
6475
+ * compared by value; everything else — functions, class instances, `Map`s, `Date`s — by
6476
+ * identity.
6477
+ *
6478
+ * That split is what makes an options object rebuilt on every render compare equal as long as
6479
+ * its _data_ did not change, which is the entire point: a caller that passes object literals
6480
+ * (`fields={[...]}`, `translations={{...}}`) hands a fresh identity to every reconfigure, so an
6481
+ * identity-only comparison would report a change every time.
6482
+ *
6483
+ * Comparing functions by identity is deliberate rather than a limitation. Two functions cannot
6484
+ * be proven equivalent, so a caller that rebuilds `getDefaultValue` per render must either
6485
+ * memoize it or accept the reconfigure.
6486
+ */
6487
+ const valuesEqual = (a, b) => {
6488
+ if (Object.is(a, b)) return true;
6489
+ if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((v, i) => valuesEqual(v, b[i]));
6490
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
6491
+ if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b) || !isPlainObject(a)) return false;
6492
+ const aKeys = Object.keys(a);
6493
+ return aKeys.length === Object.keys(b).length && aKeys.every((k) => valuesEqual(a[k], b[k]));
6494
+ };
6495
+ /**
6496
+ * Whether two {@link QueryManagerOptions} objects describe the same configuration, per
6497
+ * {@link valuesEqual}: data by value, functions by identity.
6498
+ *
6499
+ * {@link QueryManager.reconfigure} uses this to gate itself, so most callers never need it
6500
+ * directly. It is exported for framework adapters that decide whether to _call_ `reconfigure`
6501
+ * at all — skipping the call avoids building the merged options object in the first place.
6502
+ *
6503
+ * Nested option objects (`history`, `translations`, …) are descended into rather than compared
6504
+ * by identity, so `{ history: { maxHistory: 10 } }` rebuilt per render compares equal.
6505
+ */
6506
+ const optionsEqual = (a, b) => valuesEqual(a, b);
6507
+ //#endregion
5664
6508
  //#region src/utils/preferProp.ts
5665
6509
  const preferPropDefaultTrue = (prop, context) => prop === false ? false : prop ? true : !(context === false);
5666
6510
  const preferPropDefaultFalse = (prop, context) => prop ? true : prop === false ? false : !!context;
@@ -5781,7 +6625,7 @@ const exceedsMaxLevels = (parentPath, { maxLevels = Infinity } = {}) => !!parent
5781
6625
  *
5782
6626
  * @group Query Tools
5783
6627
  */
5784
- const add = (query, ruleOrGroup, parentPathOrID, options = {}) => produce(query, (q) => addInPlace(q, ruleOrGroup, parentPathOrID, options));
6628
+ const add = (query, ruleOrGroup, parentPathOrID, options = {}) => producerFor(options.freeze)(query, (q) => addInPlace(q, ruleOrGroup, parentPathOrID, options));
5785
6629
  /**
5786
6630
  * Adds a rule or group to a query in place.
5787
6631
  *
@@ -5881,6 +6725,14 @@ const normalizeUpdateArgs = (a, b, c, d) => {
5881
6725
  };
5882
6726
  };
5883
6727
  /**
6728
+ * The options argument of an {@link update} call, whose position depends on the argument form.
6729
+ * Cheaper than {@link normalizeUpdateArgs} when only the options are needed.
6730
+ */
6731
+ const updateOptionsOf = (a, b, c, d) => {
6732
+ var _ref4;
6733
+ return (_ref4 = typeof a === "string" || Array.isArray(a) ? d : c) !== null && _ref4 !== void 0 ? _ref4 : {};
6734
+ };
6735
+ /**
5884
6736
  * Applies one or more property updates to a query in place. Shared by
5885
6737
  * {@link update} and {@link updateInPlace}.
5886
6738
  */
@@ -5901,7 +6753,7 @@ const applyUpdatesInPlace = (query, a, b, c, d) => {
5901
6753
  *
5902
6754
  * @group Query Tools
5903
6755
  */
5904
- const update = ((query, a, b, c, d) => produce(query, (q) => {
6756
+ const update = ((query, a, b, c, d) => producerFor(updateOptionsOf(a, b, c, d).freeze)(query, (q) => {
5905
6757
  applyUpdatesInPlace(q, a, b, c, d);
5906
6758
  }));
5907
6759
  /**
@@ -5949,13 +6801,14 @@ const updateInPlaceSingle = (query, prop, value, pathOrID, options = {}) => {
5949
6801
  return query;
5950
6802
  }
5951
6803
  const parentRules = parent.rules;
5952
- if (path.at(-1) % 2 === 1) if (parentRules[path.at(-1)] === value) onAbort === null || onAbort === void 0 || onAbort({
5953
- reason: "no-change",
5954
- operation: "update",
5955
- pathOrID
5956
- });
5957
- else parentRules[path.at(-1)] = value;
5958
- else onAbort === null || onAbort === void 0 || onAbort({
6804
+ if (path.at(-1) % 2 === 1) {
6805
+ if (parentRules[path.at(-1)] === value) onAbort === null || onAbort === void 0 || onAbort({
6806
+ reason: "no-change",
6807
+ operation: "update",
6808
+ pathOrID
6809
+ });
6810
+ else parentRules[path.at(-1)] = value;
6811
+ } else onAbort === null || onAbort === void 0 || onAbort({
5959
6812
  reason: "not-a-combinator-slot",
5960
6813
  operation: "update",
5961
6814
  pathOrID
@@ -6026,7 +6879,7 @@ const updateInPlaceSingle = (query, prop, value, pathOrID, options = {}) => {
6026
6879
  *
6027
6880
  * @group Query Tools
6028
6881
  */
6029
- const remove = (query, pathOrID, options = {}) => produce(query, (q) => removeInPlace(q, pathOrID, options));
6882
+ const remove = (query, pathOrID, options = {}) => producerFor(options.freeze)(query, (q) => removeInPlace(q, pathOrID, options));
6030
6883
  /**
6031
6884
  * Removes a rule or group from a query in place.
6032
6885
  *
@@ -6081,25 +6934,28 @@ const removeInPlace = (query, pathOrID, options = {}) => {
6081
6934
  const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
6082
6935
  if (Array.isArray(newPathOrShiftDirection)) return newPathOrShiftDirection;
6083
6936
  const ic = isRuleGroupTypeIC(query);
6084
- if (newPathOrShiftDirection === "up") if (pathsAreEqual(currentPath, [0])) return currentPath;
6085
- else if (currentPath.at(-1) === 0) {
6086
- const parentPath = getParentPath(currentPath);
6087
- return [...getParentPath(parentPath), Math.max(0, parentPath.at(-1) - (ic ? 1 : 0))];
6088
- } else {
6089
- const evaluationPath = [...getParentPath(currentPath), Math.max(0, currentPath.at(-1) - (ic ? 2 : 1))];
6090
- const entityAtTarget = findPath(evaluationPath, query);
6091
- if (isRuleGroup(entityAtTarget)) return [...evaluationPath, entityAtTarget.rules.length];
6092
- else return [...getParentPath(currentPath), Math.max(0, currentPath.at(-1) - (ic ? 3 : 1))];
6093
- }
6094
- else if (newPathOrShiftDirection === "down") if (pathsAreEqual([query.rules.length - 1], currentPath)) return currentPath;
6095
- else if (currentPath.at(-1) === findPath(getParentPath(currentPath), query).rules.length - 1) {
6096
- const parentPath = getParentPath(currentPath);
6097
- return [...getParentPath(parentPath), parentPath.at(-1) + 1];
6098
- } else {
6099
- const evaluationPath = [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 2 : 1)];
6100
- const entityToEvaluate = findPath(evaluationPath, query);
6101
- if (isRuleGroup(entityToEvaluate)) return [...evaluationPath, 0];
6102
- else return [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 3 : 2)];
6937
+ if (newPathOrShiftDirection === "up") {
6938
+ if (pathsAreEqual(currentPath, [0])) return currentPath;
6939
+ else if (currentPath.at(-1) === 0) {
6940
+ const parentPath = getParentPath(currentPath);
6941
+ return [...getParentPath(parentPath), Math.max(0, parentPath.at(-1) - (ic ? 1 : 0))];
6942
+ } else {
6943
+ const evaluationPath = [...getParentPath(currentPath), Math.max(0, currentPath.at(-1) - (ic ? 2 : 1))];
6944
+ const entityAtTarget = findPath(evaluationPath, query);
6945
+ if (isRuleGroup(entityAtTarget)) return [...evaluationPath, entityAtTarget.rules.length];
6946
+ else return [...getParentPath(currentPath), Math.max(0, currentPath.at(-1) - (ic ? 3 : 1))];
6947
+ }
6948
+ } else if (newPathOrShiftDirection === "down") {
6949
+ if (pathsAreEqual([query.rules.length - 1], currentPath)) return currentPath;
6950
+ else if (currentPath.at(-1) === findPath(getParentPath(currentPath), query).rules.length - 1) {
6951
+ const parentPath = getParentPath(currentPath);
6952
+ return [...getParentPath(parentPath), parentPath.at(-1) + 1];
6953
+ } else {
6954
+ const evaluationPath = [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 2 : 1)];
6955
+ const entityToEvaluate = findPath(evaluationPath, query);
6956
+ if (isRuleGroup(entityToEvaluate)) return [...evaluationPath, 0];
6957
+ else return [...getParentPath(currentPath), currentPath.at(-1) + (ic ? 3 : 2)];
6958
+ }
6103
6959
  }
6104
6960
  return currentPath;
6105
6961
  };
@@ -6111,7 +6967,7 @@ const getNextPath = (query, currentPath, newPathOrShiftDirection) => {
6111
6967
  *
6112
6968
  * @group Query Tools
6113
6969
  */
6114
- const move = (query, oldPathOrID, newPath, options = {}) => produce(query, (q) => moveInPlace(q, oldPathOrID, newPath, options));
6970
+ const move = (query, oldPathOrID, newPath, options = {}) => producerFor(options.freeze)(query, (q) => moveInPlace(q, oldPathOrID, newPath, options));
6115
6971
  /**
6116
6972
  * Moves a rule or group from one path to another in place.
6117
6973
  * In the options parameter, pass `{ clone: true }` to copy instead of move.
@@ -6207,15 +7063,16 @@ const moveInPlace = (query, oldPathOrID, newPath, options = {}) => {
6207
7063
  */
6208
7064
  const insertRuleOrGroup = (...args) => parentToInsertInto.rules.splice(spliceIndex, 0, ...args);
6209
7065
  if (parentToInsertInto.rules.length === 0 || !independentCombinators) insertRuleOrGroup(ruleOrGroup);
6210
- else if (newIndex === 0) if (ruleToRemoveIndex === 0 && oldNextCombinator) insertRuleOrGroup(ruleOrGroup, oldNextCombinator);
6211
- else {
6212
- var _ref4, _parentToInsertInto$r;
6213
- insertRuleOrGroup(ruleOrGroup, (_ref4 = (_parentToInsertInto$r = parentToInsertInto.rules[1]) !== null && _parentToInsertInto$r !== void 0 ? _parentToInsertInto$r : oldPrevCombinator) !== null && _ref4 !== void 0 ? _ref4 : getFirstOption(combinators));
6214
- }
6215
- else if (oldPrevCombinator) insertRuleOrGroup(oldPrevCombinator, ruleOrGroup);
7066
+ else if (newIndex === 0) {
7067
+ if (ruleToRemoveIndex === 0 && oldNextCombinator) insertRuleOrGroup(ruleOrGroup, oldNextCombinator);
7068
+ else {
7069
+ var _ref5, _parentToInsertInto$r;
7070
+ insertRuleOrGroup(ruleOrGroup, (_ref5 = (_parentToInsertInto$r = parentToInsertInto.rules[1]) !== null && _parentToInsertInto$r !== void 0 ? _parentToInsertInto$r : oldPrevCombinator) !== null && _ref5 !== void 0 ? _ref5 : getFirstOption(combinators));
7071
+ }
7072
+ } else if (oldPrevCombinator) insertRuleOrGroup(oldPrevCombinator, ruleOrGroup);
6216
7073
  else {
6217
- var _ref5, _parentToInsertInto$r2;
6218
- insertRuleOrGroup((_ref5 = (_parentToInsertInto$r2 = parentToInsertInto.rules[spliceIndex - 2]) !== null && _parentToInsertInto$r2 !== void 0 ? _parentToInsertInto$r2 : oldNextCombinator) !== null && _ref5 !== void 0 ? _ref5 : getFirstOption(combinators), ruleOrGroup);
7074
+ var _ref6, _parentToInsertInto$r2;
7075
+ insertRuleOrGroup((_ref6 = (_parentToInsertInto$r2 = parentToInsertInto.rules[spliceIndex - 2]) !== null && _parentToInsertInto$r2 !== void 0 ? _parentToInsertInto$r2 : oldNextCombinator) !== null && _ref6 !== void 0 ? _ref6 : getFirstOption(combinators), ruleOrGroup);
6219
7076
  }
6220
7077
  return query;
6221
7078
  };
@@ -6226,7 +7083,7 @@ const moveInPlace = (query, oldPathOrID, newPath, options = {}) => {
6226
7083
  *
6227
7084
  * @group Query Tools
6228
7085
  */
6229
- const insert = (query, ruleOrGroup, path, options = {}) => produce(query, (q) => insertInPlace(q, ruleOrGroup, path, options));
7086
+ const insert = (query, ruleOrGroup, path, options = {}) => producerFor(options.freeze)(query, (q) => insertInPlace(q, ruleOrGroup, path, options));
6230
7087
  /**
6231
7088
  * Inserts a rule or group into a query in place.
6232
7089
  *
@@ -6285,15 +7142,15 @@ const insertInPlace = (query, ruleOrGroup, path, options = {}) => {
6285
7142
  var _rorg$path;
6286
7143
  if (((_rorg$path = rorg.path) === null || _rorg$path === void 0 ? void 0 : _rorg$path.at(-1)) === 0 && combinatorSucceeding) insertRuleOrGroup(newIndex, rorg, combinatorSucceeding);
6287
7144
  else {
6288
- var _ref6, _parentToInsertInto$r3;
6289
- insertRuleOrGroup(newIndex, rorg, (_ref6 = (_parentToInsertInto$r3 = parentToInsertInto.rules[1]) !== null && _parentToInsertInto$r3 !== void 0 ? _parentToInsertInto$r3 : combinatorPreceding) !== null && _ref6 !== void 0 ? _ref6 : getFirstOption(combinators));
7145
+ var _ref7, _parentToInsertInto$r3;
7146
+ insertRuleOrGroup(newIndex, rorg, (_ref7 = (_parentToInsertInto$r3 = parentToInsertInto.rules[1]) !== null && _parentToInsertInto$r3 !== void 0 ? _parentToInsertInto$r3 : combinatorPreceding) !== null && _ref7 !== void 0 ? _ref7 : getFirstOption(combinators));
6290
7147
  }
6291
7148
  } else {
6292
7149
  const normalizedNewIndex = newIndex % 2 === 0 ? newIndex - 1 : newIndex;
6293
7150
  if (combinatorPreceding) insertRuleOrGroup(normalizedNewIndex, combinatorPreceding, rorg);
6294
7151
  else {
6295
- var _ref7, _parentToInsertInto$r4;
6296
- insertRuleOrGroup(normalizedNewIndex, (_ref7 = (_parentToInsertInto$r4 = parentToInsertInto.rules[normalizedNewIndex - 2]) !== null && _parentToInsertInto$r4 !== void 0 ? _parentToInsertInto$r4 : combinatorSucceeding) !== null && _ref7 !== void 0 ? _ref7 : getFirstOption(combinators), rorg);
7152
+ var _ref8, _parentToInsertInto$r4;
7153
+ insertRuleOrGroup(normalizedNewIndex, (_ref8 = (_parentToInsertInto$r4 = parentToInsertInto.rules[normalizedNewIndex - 2]) !== null && _parentToInsertInto$r4 !== void 0 ? _parentToInsertInto$r4 : combinatorSucceeding) !== null && _ref8 !== void 0 ? _ref8 : getFirstOption(combinators), rorg);
6297
7154
  }
6298
7155
  }
6299
7156
  return query;
@@ -6307,7 +7164,7 @@ const insertInPlace = (query, ruleOrGroup, path, options = {}) => {
6307
7164
  *
6308
7165
  * @group Query Tools
6309
7166
  */
6310
- const group = (query, sourcePathOrID, targetPathOrID, options = {}) => produce(query, (q) => groupInPlace(q, sourcePathOrID, targetPathOrID, options));
7167
+ const group = (query, sourcePathOrID, targetPathOrID, options = {}) => producerFor(options.freeze)(query, (q) => groupInPlace(q, sourcePathOrID, targetPathOrID, options));
6311
7168
  /**
6312
7169
  * Creates a new group at a target path with its `rules` array containing the current
6313
7170
  * objects at the target path and the source path in place.
@@ -6435,7 +7292,7 @@ const groupInPlace = (query, sourcePathOrID, targetPathOrID, options = {}) => {
6435
7292
  * @group Query Tools
6436
7293
  */
6437
7294
  const createQueryActions = (config = {}) => {
6438
- 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;
7295
+ const { qbId, combinators, idGenerator, maxLevels = Infinity, queryDisabled, respectDisabled = true, disabledPaths, resetOnFieldChange, resetOnOperatorChange, getRuleDefaultOperator, getValueSources, getRuleDefaultValue, getMatchModes, freeze, onAddRule, onAddGroup, onRemove, onMoveRule, onMoveGroup, onGroupRule, onGroupGroup, onLog } = config;
6439
7296
  const log = (payload) => onLog === null || onLog === void 0 ? void 0 : onLog(_objectSpread2({ qbId }, payload));
6440
7297
  const guards = {
6441
7298
  respectDisabled,
@@ -6469,7 +7326,8 @@ const createQueryActions = (config = {}) => {
6469
7326
  const newQuery = add(query, newRule, parentPath, {
6470
7327
  combinators,
6471
7328
  combinatorPreceding: newRule.combinatorPreceding,
6472
- idGenerator
7329
+ idGenerator,
7330
+ freeze
6473
7331
  });
6474
7332
  log({
6475
7333
  type: LogType.add,
@@ -6506,7 +7364,8 @@ const createQueryActions = (config = {}) => {
6506
7364
  const newQuery = add(query, newGroup, parentPath, {
6507
7365
  combinators,
6508
7366
  combinatorPreceding: (_combinatorPreceding = newGroup.combinatorPreceding) !== null && _combinatorPreceding !== void 0 ? _combinatorPreceding : void 0,
6509
- idGenerator
7367
+ idGenerator,
7368
+ freeze
6510
7369
  });
6511
7370
  log({
6512
7371
  type: LogType.add,
@@ -6534,7 +7393,8 @@ const createQueryActions = (config = {}) => {
6534
7393
  getRuleDefaultOperator,
6535
7394
  getValueSources,
6536
7395
  getRuleDefaultValue,
6537
- getMatchModes
7396
+ getMatchModes,
7397
+ freeze
6538
7398
  });
6539
7399
  log({
6540
7400
  type: LogType.update,
@@ -6567,7 +7427,7 @@ const createQueryActions = (config = {}) => {
6567
7427
  });
6568
7428
  return;
6569
7429
  }
6570
- const newQuery = remove(query, path);
7430
+ const newQuery = remove(query, path, { freeze });
6571
7431
  log({
6572
7432
  type: LogType.remove,
6573
7433
  query,
@@ -6592,7 +7452,8 @@ const createQueryActions = (config = {}) => {
6592
7452
  const nextQuery = move(query, oldPath, newPath, {
6593
7453
  clone,
6594
7454
  combinators,
6595
- idGenerator
7455
+ idGenerator,
7456
+ freeze
6596
7457
  });
6597
7458
  const isGroup = isRuleGroup(ruleOrGroup);
6598
7459
  const callback = isGroup ? onMoveGroup : onMoveRule;
@@ -6638,7 +7499,8 @@ const createQueryActions = (config = {}) => {
6638
7499
  const nextQuery = group(query, sourcePath, targetPath, {
6639
7500
  clone,
6640
7501
  combinators,
6641
- idGenerator
7502
+ idGenerator,
7503
+ freeze
6642
7504
  });
6643
7505
  const isGroup = isRuleGroup(ruleOrGroup);
6644
7506
  const callback = isGroup ? onGroupGroup : onGroupRule;
@@ -6683,10 +7545,12 @@ const createQueryActions = (config = {}) => {
6683
7545
  const createRule = ({ fields, getDefaultField, getRuleDefaultOperator, getValueSources, getMatchModes, getRuleDefaultValue, idGenerator = generateID }) => {
6684
7546
  var _getFirstOption, _getFirstOption2;
6685
7547
  let field = (_getFirstOption = getFirstOption(fields)) !== null && _getFirstOption !== void 0 ? _getFirstOption : "";
6686
- if (getDefaultField) if (typeof getDefaultField === "function") {
6687
- const defaultField = getDefaultField(fields);
6688
- if (defaultField) field = defaultField;
6689
- } else field = getDefaultField;
7548
+ if (getDefaultField) {
7549
+ if (typeof getDefaultField === "function") {
7550
+ const defaultField = getDefaultField(fields);
7551
+ if (defaultField) field = defaultField;
7552
+ } else field = getDefaultField;
7553
+ }
6690
7554
  const fieldData = getOption(fields, field);
6691
7555
  const operator = getRuleDefaultOperator(field);
6692
7556
  const valueSource = (_getFirstOption2 = getFirstOption(getValueSources(field, operator, { fieldData }))) !== null && _getFirstOption2 !== void 0 ? _getFirstOption2 : "value";
@@ -6730,107 +7594,6 @@ const createRuleGroup = ({ combinators, addRuleToNewGroups, createRule: createRu
6730
7594
  };
6731
7595
  };
6732
7596
  //#endregion
6733
- //#region src/utils/signature.ts
6734
- /**
6735
- * Signature returned when a change alters the _shape_ of the query—rules or groups added,
6736
- * removed, moved, or reordered—rather than the properties of a single node. Structural changes
6737
- * never coalesce with each other, so each one produces its own history entry.
6738
- */
6739
- const structuralSignature = "~structural";
6740
- /**
6741
- * Signature returned when two queries differ by reference only, with no observable difference
6742
- * in their properties.
6743
- */
6744
- const unchangedSignature = "";
6745
- /**
6746
- * Returns the list of property names that differ between two nodes, ignoring `rules` (which is
6747
- * compared structurally by the caller).
6748
- */
6749
- const changedProps = (prev, next) => {
6750
- const keys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(next)]);
6751
- keys.delete("rules");
6752
- const changed = [];
6753
- for (const key of keys) if (!Object.is(prev[key], next[key])) changed.push(key);
6754
- return changed.toSorted();
6755
- };
6756
- const signatureOfNode = (prev, next, parentId, index) => {
6757
- var _next$id3;
6758
- if (prev === next) return "";
6759
- if (typeof prev === "string" || typeof next === "string") return typeof prev === typeof next ? `${parentId}:combinator[${index}]` : structuralSignature;
6760
- const prevIsGroup = isRuleGroup(prev);
6761
- const nextIsGroup = isRuleGroup(next);
6762
- if (prevIsGroup !== nextIsGroup) return structuralSignature;
6763
- if (!prevIsGroup || !nextIsGroup) {
6764
- var _next$id;
6765
- const props = changedProps(prev, next);
6766
- return props.length === 0 ? "" : `${(_next$id = next.id) !== null && _next$id !== void 0 ? _next$id : ""}:${props.join(",")}`;
6767
- }
6768
- if (prev.rules.length !== next.rules.length) return structuralSignature;
6769
- const ownProps = changedProps(prev, next);
6770
- let changedIndex = -1;
6771
- for (const [i, prevRule] of prev.rules.entries()) if (prevRule !== next.rules[i]) {
6772
- if (changedIndex !== -1) return structuralSignature;
6773
- changedIndex = i;
6774
- }
6775
- if (changedIndex === -1) {
6776
- var _next$id2;
6777
- return ownProps.length === 0 ? "" : `${(_next$id2 = next.id) !== null && _next$id2 !== void 0 ? _next$id2 : ""}:${ownProps.join(",")}`;
6778
- }
6779
- if (ownProps.length > 0) return structuralSignature;
6780
- return signatureOfNode(prev.rules[changedIndex], next.rules[changedIndex], (_next$id3 = next.id) !== null && _next$id3 !== void 0 ? _next$id3 : "", changedIndex);
6781
- };
6782
- /**
6783
- * Describes _what changed_ between two versions of a query as a short string, so that
6784
- * consecutive edits to the same property of the same rule (e.g. typing in a value editor) can
6785
- * be recognized and coalesced into a single history entry.
6786
- *
6787
- * Returns {@link structuralSignature} for changes to the shape of the query, {@link unchangedSignature} when the
6788
- * two queries differ by reference only, and `"<id>:<props>"` otherwise.
6789
- *
6790
- * The walk prunes on reference equality, so it costs O(depth) rather than O(size) for the
6791
- * single-node edits that make up the overwhelming majority of changes.
6792
- *
6793
- * Note that this relies on the structural sharing that Immer—and therefore every query
6794
- * produced by RQB's own update functions—guarantees: nodes that did not change keep their
6795
- * identity. A query that has been wholly rebuilt (deep-cloned, round-tripped through JSON,
6796
- * re-parsed from a string) shares no identity with its predecessor, so it is reported as
6797
- * {@link structuralSignature} and will not coalesce. That is a graceful degradation—every change simply
6798
- * gets its own history entry—but controlled components that clone the query on every change
6799
- * will not benefit from coalescing.
6800
- */
6801
- const signatureOf = (prev, next) => signatureOfNode(prev, next, "", -1);
6802
- //#endregion
6803
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/checkPrivateRedeclaration.js
6804
- function _checkPrivateRedeclaration(e, t) {
6805
- if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
6806
- }
6807
- //#endregion
6808
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateMethodInitSpec.js
6809
- function _classPrivateMethodInitSpec(e, a) {
6810
- _checkPrivateRedeclaration(e, a), a.add(e);
6811
- }
6812
- //#endregion
6813
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldInitSpec.js
6814
- function _classPrivateFieldInitSpec(e, t, a) {
6815
- _checkPrivateRedeclaration(e, t), t.set(e, a);
6816
- }
6817
- //#endregion
6818
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/assertClassBrand.js
6819
- function _assertClassBrand(e, t, n) {
6820
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
6821
- throw new TypeError("Private element is not present on this object");
6822
- }
6823
- //#endregion
6824
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldGet2.js
6825
- function _classPrivateFieldGet2(s, a) {
6826
- return s.get(_assertClassBrand(s, a));
6827
- }
6828
- //#endregion
6829
- //#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldSet2.js
6830
- function _classPrivateFieldSet2(s, a, r) {
6831
- return s.set(_assertClassBrand(s, a), r), r;
6832
- }
6833
- //#endregion
6834
7597
  //#region src/utils/QueryManager.ts
6835
7598
  const _excluded = ["strict", "onInvalidTarget"];
6836
7599
  const _excluded2 = ["strict", "onInvalidTarget"];
@@ -6840,25 +7603,6 @@ const _excluded5 = ["strict", "onInvalidTarget"];
6840
7603
  const _excluded6 = ["strict", "onInvalidTarget"];
6841
7604
  let _Symbol$iterator;
6842
7605
  /**
6843
- * Abort reasons that {@link QueryManager}'s `strict` mode treats as errors. The remaining
6844
- * reasons—`"same-location"` and `"no-change"`—describe valid operations that had nothing to do,
6845
- * so they are reported to `onInvalidTarget` but never throw.
6846
- *
6847
- * @group Query Tools
6848
- */
6849
- const strictAbortReasons = [
6850
- "target-not-found",
6851
- "parent-not-found",
6852
- "parent-not-a-group",
6853
- "destination-not-found",
6854
- "root-not-allowed",
6855
- "not-a-combinator-slot",
6856
- "target-disabled",
6857
- "parent-disabled",
6858
- "max-levels-exceeded"
6859
- ];
6860
- const strictAbortReasonSet = new Set(strictAbortReasons);
6861
- /**
6862
7606
  * Thrown by {@link QueryManager} methods in `strict` mode when an operation cannot be carried
6863
7607
  * out because its target could not be used.
6864
7608
  *
@@ -6875,34 +7619,57 @@ var QueryManagerError = class QueryManagerError extends Error {
6875
7619
  Object.setPrototypeOf(this, QueryManagerError.prototype);
6876
7620
  }
6877
7621
  };
6878
- var _query = /* @__PURE__ */ new WeakMap();
6879
- var _options = /* @__PURE__ */ new WeakMap();
6880
- var _fields = /* @__PURE__ */ new WeakMap();
6881
- var _fieldMap = /* @__PURE__ */ new WeakMap();
6882
- var _operators = /* @__PURE__ */ new WeakMap();
6883
- var _combinators = /* @__PURE__ */ new WeakMap();
6884
- var _idGenerator = /* @__PURE__ */ new WeakMap();
6885
- var _validator = /* @__PURE__ */ new WeakMap();
6886
- var _strict = /* @__PURE__ */ new WeakMap();
6887
- var _respectDisabled = /* @__PURE__ */ new WeakMap();
6888
- var _onInvalidTarget = /* @__PURE__ */ new WeakMap();
6889
- var _listeners = /* @__PURE__ */ new WeakMap();
6890
- var _historyEnabled = /* @__PURE__ */ new WeakMap();
6891
- var _maxHistory = /* @__PURE__ */ new WeakMap();
6892
- var _coalesceMs = /* @__PURE__ */ new WeakMap();
6893
- var _now = /* @__PURE__ */ new WeakMap();
6894
- var _configVersion = /* @__PURE__ */ new WeakMap();
6895
- var _past = /* @__PURE__ */ new WeakMap();
6896
- var _future = /* @__PURE__ */ new WeakMap();
6897
- var _lastSig = /* @__PURE__ */ new WeakMap();
6898
- var _lastAt = /* @__PURE__ */ new WeakMap();
6899
- var _batchDepth = /* @__PURE__ */ new WeakMap();
6900
- var _batchSnapshot = /* @__PURE__ */ new WeakMap();
6901
- var _historyBypassed = /* @__PURE__ */ new WeakMap();
6902
- var _cacheFor = /* @__PURE__ */ new WeakMap();
6903
- var _idPathIndex = /* @__PURE__ */ new WeakMap();
6904
- var _validation = /* @__PURE__ */ new WeakMap();
6905
- var _QueryManager_brand = /* @__PURE__ */ new WeakSet();
7622
+ /**
7623
+ * Key of the single own property holding every {@link QueryManager} instance's state.
7624
+ *
7625
+ * `#private` fields are unreachable from a `Proxy`: inside a method invoked through one, `this`
7626
+ * _is_ the proxy, and the private brand lives on the target, so every access throws
7627
+ * `TypeError: Cannot read private member`. Frameworks wrap objects in proxies routinely — Vue's
7628
+ * `reactive()`, and by extension Vue Test Utils' handling of mount props, do it implicitly — so
7629
+ * consumers hit that failure by accident rather than by choice.
7630
+ *
7631
+ * A `WeakMap` keyed by instance does not fix it either, for the same reason: `weakMap.get(this)`
7632
+ * misses the entry stored under the target. An ordinary own property is the only mechanism that
7633
+ * reads correctly through a proxy, because the `get` trap forwards to the target.
7634
+ *
7635
+ * The symbol is module-private and never exported. Reaching into the state bag (via
7636
+ * `Object.getOwnPropertySymbols`, say) is not a supported access path and its contents may change
7637
+ * in any release.
7638
+ */
7639
+ const kState = Symbol("QueryManager.state");
7640
+ const queryChange = freeze({
7641
+ query: true,
7642
+ config: false
7643
+ });
7644
+ const configChange = freeze({
7645
+ query: false,
7646
+ config: true
7647
+ });
7648
+ const queryAndConfigChange = freeze({
7649
+ query: true,
7650
+ config: true
7651
+ });
7652
+ /**
7653
+ * Builds the state bag. The option-derived members are left unset for `applyOptions` to fill in,
7654
+ * hence the assertion.
7655
+ */
7656
+ const createManagerState = () => {
7657
+ const state = {
7658
+ listeners: /* @__PURE__ */ new Set(),
7659
+ configVersion: 0,
7660
+ past: [],
7661
+ future: [],
7662
+ lastAt: 0,
7663
+ batchDepth: 0,
7664
+ historyBypassed: false,
7665
+ pendingConfigNotify: false
7666
+ };
7667
+ Object.defineProperty(state, "__v_skip", {
7668
+ value: true,
7669
+ enumerable: false
7670
+ });
7671
+ return state;
7672
+ };
6906
7673
  _Symbol$iterator = Symbol.iterator;
6907
7674
  /**
6908
7675
  * Stateful wrapper around the {@link add}/{@link remove}/{@link update}/{@link move}/
@@ -6912,7 +7679,8 @@ _Symbol$iterator = Symbol.iterator;
6912
7679
  * The query is held internally, so each method takes the same arguments as its `queryTools`
6913
7680
  * counterpart minus the leading `query` parameter, and returns the manager itself for chaining.
6914
7681
  * Mutations use the non-`InPlace` tools, so a query previously handed out by
6915
- * {@link QueryManager.getQuery} is never modified.
7682
+ * {@link QueryManager.getQuery} is never modified. Under `freeze: false` that remains true, but
7683
+ * as a convention rather than a runtime-enforced guarantee.
6916
7684
  *
6917
7685
  * ```ts
6918
7686
  * const q = new QueryManager(undefined, { fields });
@@ -6928,46 +7696,31 @@ _Symbol$iterator = Symbol.iterator;
6928
7696
  * @group Query Tools
6929
7697
  */
6930
7698
  var QueryManager = class QueryManager {
7699
+ /**
7700
+ * All instance state, rather than `#private` fields. See `kState` for why.
7701
+ *
7702
+ * The property itself is symbol-keyed and installed by the constructor; this accessor exists
7703
+ * because `isolatedDeclarations` cannot emit a computed property name keyed by a symbol the
7704
+ * module does not export, and exporting it would put it in the public API surface. A
7705
+ * prototype accessor is proxy-safe for the same reason the own property is: `this` is the
7706
+ * proxy, and the `get` trap forwards to the target.
7707
+ */
7708
+ get state() {
7709
+ return this[kState];
7710
+ }
6931
7711
  constructor(query, options = {}) {
6932
- _classPrivateMethodInitSpec(this, _QueryManager_brand);
6933
- _classPrivateFieldInitSpec(this, _query, void 0);
6934
- _classPrivateFieldInitSpec(this, _options, void 0);
6935
- _classPrivateFieldInitSpec(this, _fields, void 0);
6936
- _classPrivateFieldInitSpec(this, _fieldMap, void 0);
6937
- _classPrivateFieldInitSpec(this, _operators, void 0);
6938
- _classPrivateFieldInitSpec(this, _combinators, void 0);
6939
- _classPrivateFieldInitSpec(this, _idGenerator, void 0);
6940
- _classPrivateFieldInitSpec(this, _validator, void 0);
6941
- _classPrivateFieldInitSpec(this, _strict, void 0);
6942
- _classPrivateFieldInitSpec(this, _respectDisabled, void 0);
6943
- _classPrivateFieldInitSpec(this, _onInvalidTarget, void 0);
6944
- _classPrivateFieldInitSpec(this, _listeners, /* @__PURE__ */ new Set());
6945
- _classPrivateFieldInitSpec(this, _historyEnabled, void 0);
6946
- _classPrivateFieldInitSpec(this, _maxHistory, void 0);
6947
- _classPrivateFieldInitSpec(this, _coalesceMs, void 0);
6948
- _classPrivateFieldInitSpec(this, _now, void 0);
6949
- _classPrivateFieldInitSpec(this, _configVersion, 0);
6950
- _classPrivateFieldInitSpec(this, _past, []);
6951
- _classPrivateFieldInitSpec(this, _future, []);
6952
- _classPrivateFieldInitSpec(this, _lastSig, void 0);
6953
- _classPrivateFieldInitSpec(this, _lastAt, 0);
6954
- _classPrivateFieldInitSpec(this, _batchDepth, 0);
6955
- _classPrivateFieldInitSpec(this, _batchSnapshot, void 0);
6956
- _classPrivateFieldInitSpec(this, _historyBypassed, false);
6957
- _classPrivateFieldInitSpec(this, _cacheFor, void 0);
6958
- _classPrivateFieldInitSpec(this, _idPathIndex, void 0);
6959
- _classPrivateFieldInitSpec(this, _validation, void 0);
6960
7712
  _defineProperty(
6961
7713
  this,
6962
7714
  /**
6963
- * The current query. The returned object is frozen and structurally shared, so it is safe to
6964
- * retain and compare by reference to detect changes.
7715
+ * The current query. The returned object is structurally shared, so it is safe to retain and
7716
+ * compare by reference to detect changes. It is also frozen unless the `freeze` option is
7717
+ * `false`.
6965
7718
  *
6966
7719
  * Like {@link QueryManager.subscribe}, this method is bound to the instance, so it can be
6967
7720
  * passed as a bare reference (e.g. as the `getSnapshot` argument to `useSyncExternalStore`).
6968
7721
  */
6969
7722
  "getQuery",
6970
- () => _classPrivateFieldGet2(_query, this)
7723
+ () => this.state.query
6971
7724
  );
6972
7725
  _defineProperty(
6973
7726
  this,
@@ -6981,7 +7734,7 @@ var QueryManager = class QueryManager {
6981
7734
  * already does this.
6982
7735
  */
6983
7736
  "getConfigVersion",
6984
- () => _classPrivateFieldGet2(_configVersion, this)
7737
+ () => this.state.configVersion
6985
7738
  );
6986
7739
  _defineProperty(
6987
7740
  this,
@@ -6999,21 +7752,282 @@ var QueryManager = class QueryManager {
6999
7752
  * ```
7000
7753
  *
7001
7754
  * In React, prefer the `useQueryManager` hook from `react-querybuilder`, which wraps this.
7755
+ *
7756
+ * The listener receives a {@link SubscriptionChange} describing what changed. It is optional:
7757
+ * a zero-argument listener — including `useSyncExternalStore`'s `onStoreChange` — is still a
7758
+ * valid listener and behaves as it always has.
7002
7759
  */
7003
7760
  "subscribe",
7004
7761
  (listener) => {
7005
- _classPrivateFieldGet2(_listeners, this).add(listener);
7762
+ this.state.listeners.add(listener);
7006
7763
  return () => {
7007
- _classPrivateFieldGet2(_listeners, this).delete(listener);
7764
+ this.state.listeners.delete(listener);
7008
7765
  };
7009
7766
  }
7010
7767
  );
7011
- _assertClassBrand(_QueryManager_brand, this, _applyOptions).call(this, options);
7012
- _classPrivateFieldSet2(_query, this, freeze(query ? prepareRuleGroup(query, { idGenerator: _classPrivateFieldGet2(_idGenerator, this) }) : this.createRuleGroup(), true));
7768
+ Object.defineProperty(this, kState, {
7769
+ value: createManagerState(),
7770
+ enumerable: false,
7771
+ writable: false,
7772
+ configurable: false
7773
+ });
7774
+ this.applyOptions(options);
7775
+ this.state.query = this.freeze(query ? prepareRuleGroup(query, { idGenerator: this.state.idGenerator }) : this.createRuleGroup());
7776
+ }
7777
+ /**
7778
+ * Deep-freezes `x` unless the `freeze` option is `false`. Every value the manager hands out
7779
+ * directly goes through here; the shallow copies returned by {@link QueryManager.getOptions}
7780
+ * and passed to `applyOptions` are frozen unconditionally instead.
7781
+ */
7782
+ freeze(x) {
7783
+ return this.state.freezeEnabled ? freeze(x, true) : x;
7784
+ }
7785
+ /**
7786
+ * Assigns `options` and every field derived from it. Shared by the constructor and
7787
+ * {@link QueryManager.reconfigure}, so the two can never drift apart. Does not touch the
7788
+ * query, the history stacks, the caches, or the subscriber list.
7789
+ */
7790
+ applyOptions(options) {
7791
+ var _options$freeze, _options$idGenerator, _options$validator, _options$strict, _options$respectDisab, _options$history, _historyOptions$maxHi, _historyOptions$coale, _options$now, _options$translations, _options$operators, _options$translations2, _options$combinators;
7792
+ this.state.options = options;
7793
+ this.state.freezeEnabled = (_options$freeze = options.freeze) !== null && _options$freeze !== void 0 ? _options$freeze : true;
7794
+ this.state.idGenerator = (_options$idGenerator = options.idGenerator) !== null && _options$idGenerator !== void 0 ? _options$idGenerator : generateID;
7795
+ this.state.validator = (_options$validator = options.validator) !== null && _options$validator !== void 0 ? _options$validator : defaultValidator;
7796
+ this.state.strict = (_options$strict = options.strict) !== null && _options$strict !== void 0 ? _options$strict : false;
7797
+ this.state.respectDisabled = (_options$respectDisab = options.respectDisabled) !== null && _options$respectDisab !== void 0 ? _options$respectDisab : true;
7798
+ this.state.onInvalidTarget = options.onInvalidTarget;
7799
+ const history = (_options$history = options.history) !== null && _options$history !== void 0 ? _options$history : false;
7800
+ const historyOptions = typeof history === "object" ? history : {};
7801
+ this.state.historyEnabled = history !== false;
7802
+ this.state.maxHistory = (_historyOptions$maxHi = historyOptions.maxHistory) !== null && _historyOptions$maxHi !== void 0 ? _historyOptions$maxHi : 50;
7803
+ this.state.coalesceMs = (_historyOptions$coale = historyOptions.coalesceMs) !== null && _historyOptions$coale !== void 0 ? _historyOptions$coale : 500;
7804
+ this.state.now = (_options$now = options.now) !== null && _options$now !== void 0 ? _options$now : Date.now;
7805
+ const { optionList: fields, optionsMap: fieldMap } = prepareOptionList({
7806
+ optionList: options.fields,
7807
+ baseOption: options.baseField,
7808
+ autoSelectOption: options.autoSelectField,
7809
+ placeholder: (_options$translations = options.translations) === null || _options$translations === void 0 ? void 0 : _options$translations.fields
7810
+ });
7811
+ this.state.fields = this.freeze(fields);
7812
+ this.state.fieldMap = this.freeze(fieldMap);
7813
+ this.state.operators = prepareOptionList({
7814
+ optionList: (_options$operators = options.operators) !== null && _options$operators !== void 0 ? _options$operators : defaultOperators,
7815
+ baseOption: options.baseOperator,
7816
+ labelMap: defaultOperatorLabelMap,
7817
+ autoSelectOption: options.autoSelectOperator,
7818
+ placeholder: (_options$translations2 = options.translations) === null || _options$translations2 === void 0 ? void 0 : _options$translations2.operators
7819
+ }).optionList;
7820
+ this.state.combinators = this.freeze(prepareOptionList({
7821
+ optionList: (_options$combinators = options.combinators) !== null && _options$combinators !== void 0 ? _options$combinators : defaultCombinators,
7822
+ baseOption: options.baseCombinator
7823
+ }).optionList);
7824
+ }
7825
+ /** Resolves the field configuration for a field name. */
7826
+ fieldData(field) {
7827
+ var _field;
7828
+ return (_field = this.state.fieldMap[field]) !== null && _field !== void 0 ? _field : {};
7829
+ }
7830
+ /** Resolves the operator list for a field, mirroring `QueryBuilder`'s precedence. */
7831
+ operatorsFor(field) {
7832
+ var _this$state$options$t;
7833
+ return resolveOperatorList({
7834
+ field,
7835
+ fieldData: this.fieldData(field),
7836
+ getOperators: this.state.options.getOperators,
7837
+ operators: this.state.operators,
7838
+ baseOption: this.state.options.baseOperator,
7839
+ autoSelectOption: this.state.options.autoSelectOperator,
7840
+ placeholder: (_this$state$options$t = this.state.options.translations) === null || _this$state$options$t === void 0 ? void 0 : _this$state$options$t.operators
7841
+ });
7842
+ }
7843
+ /** Resolves the default operator for a field, mirroring `QueryBuilder`'s precedence. */
7844
+ defaultOperator(field) {
7845
+ return resolveDefaultOperator({
7846
+ field,
7847
+ fieldData: this.fieldData(field),
7848
+ getDefaultOperator: this.state.options.getDefaultOperator,
7849
+ getOperators: (f) => this.operatorsFor(f)
7850
+ });
7851
+ }
7852
+ valueSourcesFor(field, operator) {
7853
+ return getValueSourcesUtil(this.fieldData(field), operator, this.state.options.getValueSources);
7854
+ }
7855
+ matchModesFor(field) {
7856
+ return getMatchModesUtil(this.fieldData(field), this.state.options.getMatchModes);
7857
+ }
7858
+ valuesFor(field, operator) {
7859
+ var _this$state$options$t2;
7860
+ return resolveValueList({
7861
+ field,
7862
+ operator,
7863
+ fieldData: this.fieldData(field),
7864
+ getValues: this.state.options.getValues,
7865
+ autoSelectOption: this.state.options.autoSelectValue,
7866
+ placeholder: (_this$state$options$t2 = this.state.options.translations) === null || _this$state$options$t2 === void 0 ? void 0 : _this$state$options$t2.values
7867
+ });
7868
+ }
7869
+ valueEditorTypeFor(field, operator) {
7870
+ return resolveValueEditorType({
7871
+ field,
7872
+ operator,
7873
+ fieldData: this.fieldData(field),
7874
+ getValueEditorType: this.state.options.getValueEditorType
7875
+ });
7876
+ }
7877
+ /** Computes the default `value` for a rule, mirroring `QueryBuilder`'s precedence. */
7878
+ defaultValue(rule) {
7879
+ const { getDefaultValue, getParameters, listsAsArrays } = this.state.options;
7880
+ return getRuleDefaultValue(rule, {
7881
+ fieldData: this.fieldData(rule.field),
7882
+ fields: this.state.fields,
7883
+ listsAsArrays,
7884
+ getValueEditorType: (f, o) => this.valueEditorTypeFor(f, o),
7885
+ getValues: (f, o) => this.valuesFor(f, o),
7886
+ getDefaultValue: getDefaultValue && ((r, misc) => getDefaultValue(r, misc)),
7887
+ getParameters: getParameters && ((f, o, misc) => this.parametersFor(f, o, misc))
7888
+ });
7889
+ }
7890
+ /**
7891
+ * Resolves the parameter list for a field/operator pair, normalized the same way as every
7892
+ * other option list. Shared by `defaultValue` and {@link QueryManager.getRuleContext} so both
7893
+ * see the same shape.
7894
+ */
7895
+ parametersFor(field, operator, misc) {
7896
+ var _this$state$options$g, _this$state$options$g2, _this$state$options;
7897
+ return prepareOptionList({
7898
+ optionList: (_this$state$options$g = (_this$state$options$g2 = (_this$state$options = this.state.options).getParameters) === null || _this$state$options$g2 === void 0 ? void 0 : _this$state$options$g2.call(_this$state$options, field, operator, misc)) !== null && _this$state$options$g !== void 0 ? _this$state$options$g : [],
7899
+ autoSelectOption: this.state.options.autoSelectValue
7900
+ }).optionList;
7901
+ }
7902
+ /** Defaults shared by every mutating method, overridable per call. */
7903
+ guardOptions() {
7904
+ const { maxLevels } = this.state.options;
7905
+ return {
7906
+ freeze: this.state.freezeEnabled,
7907
+ maxLevels: (maxLevels !== null && maxLevels !== void 0 ? maxLevels : 0) > 0 ? Number(maxLevels) : Infinity,
7908
+ respectDisabled: this.state.respectDisabled,
7909
+ disabledPaths: this.state.options.disabledPaths,
7910
+ queryDisabled: this.state.options.queryDisabled
7911
+ };
7912
+ }
7913
+ toolOptions() {
7914
+ return _objectSpread2({
7915
+ combinators: this.state.combinators,
7916
+ idGenerator: this.state.idGenerator
7917
+ }, this.guardOptions());
7918
+ }
7919
+ /**
7920
+ * Builds the `onAbort` handler passed to the query tools, applying the per-call overrides on
7921
+ * top of the manager's own options.
7922
+ */
7923
+ onAbort({ strict, onInvalidTarget }) {
7924
+ const strictMain = strict !== null && strict !== void 0 ? strict : this.state.strict;
7925
+ const handler = onInvalidTarget !== null && onInvalidTarget !== void 0 ? onInvalidTarget : this.state.onInvalidTarget;
7926
+ return (info) => {
7927
+ handler === null || handler === void 0 || handler(info);
7928
+ if (strictMain && strictAbortReasonSet.has(info.reason)) throw new QueryManagerError(info);
7929
+ };
7930
+ }
7931
+ /** Defaults for {@link update}, so resets mirror `QueryBuilder`'s behavior. */
7932
+ updateOptions() {
7933
+ return _objectSpread2({
7934
+ getRuleDefaultOperator: (f) => this.defaultOperator(f),
7935
+ getRuleDefaultValue: (r) => this.defaultValue(r),
7936
+ getValueSources: (f, o) => this.valueSourcesFor(f, o),
7937
+ getMatchModes: (f) => this.matchModesFor(f),
7938
+ resetOnFieldChange: this.state.options.resetOnFieldChange,
7939
+ resetOnOperatorChange: this.state.options.resetOnOperatorChange
7940
+ }, this.guardOptions());
7941
+ }
7942
+ /**
7943
+ * Applies a new query, recording history and notifying subscribers as appropriate. Every
7944
+ * mutation funnels through here. A tool that could not resolve its target returns the same
7945
+ * query object, which is treated as a no-op.
7946
+ */
7947
+ commit(next) {
7948
+ const prev = this.state.query;
7949
+ if (prev === next) return;
7950
+ this.state.query = next;
7951
+ if (this.state.batchDepth > 0) return;
7952
+ this.record(prev, next);
7953
+ this.notify(queryChange);
7954
+ }
7955
+ /**
7956
+ * Records a change, either as a new history entry or by absorbing it into the current one.
7957
+ * Mirrors the recording semantics of the `react-querybuilder/history` entry point.
7958
+ */
7959
+ record(prev, next) {
7960
+ if (!this.state.historyEnabled) return;
7961
+ const sig = signatureOf(prev, next);
7962
+ if (sig === "") return;
7963
+ const now = this.state.now();
7964
+ if (!shouldCoalesce(this.state.lastSig, sig, this.state.lastAt, now, this.state.coalesceMs)) {
7965
+ this.state.past.push(prev);
7966
+ if (this.state.past.length > this.state.maxHistory) this.state.past.shift();
7967
+ this.state.future = [];
7968
+ }
7969
+ this.state.lastSig = sig;
7970
+ this.state.lastAt = now;
7971
+ }
7972
+ notify(change) {
7973
+ for (const listener of this.state.listeners) listener(change);
7974
+ }
7975
+ /**
7976
+ * Records that a history-stack method ran inside the current batch. Those methods manage
7977
+ * `past`/`future` themselves, so the batch must not also record an entry on completion —
7978
+ * doing so would push a duplicate onto `past` and clear the redo stack that `undo` just
7979
+ * populated.
7980
+ */
7981
+ markHistoryBypassed() {
7982
+ if (this.state.batchDepth > 0) this.state.historyBypassed = true;
7983
+ }
7984
+ /**
7985
+ * Discards every cached derivation when the query has been replaced since they were computed.
7986
+ * Called at the top of each cached reader.
7987
+ */
7988
+ ensureCache() {
7989
+ if (this.state.cacheFor === this.state.query) return;
7990
+ this.state.cacheFor = this.state.query;
7991
+ this.state.idPathIndex = void 0;
7992
+ this.state.validation = void 0;
7993
+ }
7994
+ /**
7995
+ * The single traversal implementation. Combinator strings in independent-combinator groups
7996
+ * are skipped.
7997
+ *
7998
+ * @yields The subtree rooted at `node`, depth-first in pre-order, starting with `node` itself.
7999
+ */
8000
+ *walkFrom(node, path, parent) {
8001
+ yield {
8002
+ node,
8003
+ path,
8004
+ parent
8005
+ };
8006
+ if (!isRuleGroup(node)) return;
8007
+ const startGroup = node;
8008
+ for (const [index, child] of startGroup.rules.entries()) {
8009
+ if (typeof child === "string") continue;
8010
+ yield* this.walkFrom(child, [...path, index], startGroup);
8011
+ }
8012
+ }
8013
+ /** Builds (once per query) the `id` to {@link Path} index backing `findID`/`getPathOfID`. */
8014
+ index() {
8015
+ this.ensureCache();
8016
+ if (!this.state.idPathIndex) {
8017
+ const index = /* @__PURE__ */ new Map();
8018
+ for (const { node, path } of this.walkFrom(this.state.query, [], null)) if (node.id !== void 0 && !index.has(node.id)) index.set(node.id, path);
8019
+ this.state.idPathIndex = index;
8020
+ }
8021
+ return this.state.idPathIndex;
8022
+ }
8023
+ /** Resolves a path or `id` to a path, or `null` when the `id` isn't present. */
8024
+ toPath(pathOrID) {
8025
+ var _this$index$get;
8026
+ return typeof pathOrID === "string" ? (_this$index$get = this.index().get(pathOrID)) !== null && _this$index$get !== void 0 ? _this$index$get : null : pathOrID;
7013
8027
  }
7014
8028
  /** Replaces the current query, ensuring every rule and group has an `id`. */
7015
8029
  setQuery(query) {
7016
- _assertClassBrand(_QueryManager_brand, this, _commit).call(this, freeze(prepareRuleGroup(query, { idGenerator: _classPrivateFieldGet2(_idGenerator, this) }), true));
8030
+ this.commit(this.freeze(prepareRuleGroup(query, { idGenerator: this.state.idGenerator })));
7017
8031
  return this;
7018
8032
  }
7019
8033
  /**
@@ -7022,13 +8036,13 @@ var QueryManager = class QueryManager {
7022
8036
  */
7023
8037
  createRule() {
7024
8038
  return createRule({
7025
- fields: _classPrivateFieldGet2(_fields, this),
7026
- getDefaultField: _classPrivateFieldGet2(_options, this).getDefaultField,
7027
- getRuleDefaultOperator: (f) => _assertClassBrand(_QueryManager_brand, this, _defaultOperator).call(this, f),
7028
- getValueSources: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valueSourcesFor).call(this, f, o),
7029
- getMatchModes: (f) => _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, f),
7030
- getRuleDefaultValue: (r) => _assertClassBrand(_QueryManager_brand, this, _defaultValue).call(this, r),
7031
- idGenerator: _classPrivateFieldGet2(_idGenerator, this)
8039
+ fields: this.state.fields,
8040
+ getDefaultField: this.state.options.getDefaultField,
8041
+ getRuleDefaultOperator: (f) => this.defaultOperator(f),
8042
+ getValueSources: (f, o) => this.valueSourcesFor(f, o),
8043
+ getMatchModes: (f) => this.matchModesFor(f),
8044
+ getRuleDefaultValue: (r) => this.defaultValue(r),
8045
+ idGenerator: this.state.idGenerator
7032
8046
  });
7033
8047
  }
7034
8048
  /**
@@ -7037,10 +8051,10 @@ var QueryManager = class QueryManager {
7037
8051
  */
7038
8052
  createRuleGroup(independentCombinators) {
7039
8053
  return createRuleGroup({
7040
- combinators: _classPrivateFieldGet2(_combinators, this),
7041
- addRuleToNewGroups: _classPrivateFieldGet2(_options, this).addRuleToNewGroups,
8054
+ combinators: this.state.combinators,
8055
+ addRuleToNewGroups: this.state.options.addRuleToNewGroups,
7042
8056
  createRule: () => this.createRule(),
7043
- idGenerator: _classPrivateFieldGet2(_idGenerator, this)
8057
+ idGenerator: this.state.idGenerator
7044
8058
  }, independentCombinators);
7045
8059
  }
7046
8060
  /**
@@ -7049,7 +8063,7 @@ var QueryManager = class QueryManager {
7049
8063
  */
7050
8064
  add(ruleOrGroup, parentPathOrID = [], options = {}) {
7051
8065
  const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded);
7052
- _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, {
8066
+ this.commit(add(this.state.query, ruleOrGroup, parentPathOrID, _objectSpread2(_objectSpread2(_objectSpread2({}, this.toolOptions()), toolOptions), {}, { onAbort: this.onAbort({
7053
8067
  strict,
7054
8068
  onInvalidTarget
7055
8069
  }) })));
@@ -7058,7 +8072,7 @@ var QueryManager = class QueryManager {
7058
8072
  /** Removes the rule or group at the given path or `id`. The root group cannot be removed. */
7059
8073
  remove(pathOrID, options = {}) {
7060
8074
  const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded2);
7061
- _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, {
8075
+ this.commit(remove(this.state.query, pathOrID, _objectSpread2(_objectSpread2(_objectSpread2({}, this.guardOptions()), toolOptions), {}, { onAbort: this.onAbort({
7062
8076
  strict,
7063
8077
  onInvalidTarget
7064
8078
  }) })));
@@ -7074,17 +8088,17 @@ var QueryManager = class QueryManager {
7074
8088
  d
7075
8089
  ];
7076
8090
  const _ref = (_args$optionsIndex = args[optionsIndex]) !== null && _args$optionsIndex !== void 0 ? _args$optionsIndex : {}, { strict, onInvalidTarget } = _ref, toolOptions = _objectWithoutProperties(_ref, _excluded3);
7077
- args[optionsIndex] = _objectSpread2(_objectSpread2(_objectSpread2({}, _assertClassBrand(_QueryManager_brand, this, _updateOptions).call(this)), toolOptions), {}, { onAbort: _assertClassBrand(_QueryManager_brand, this, _onAbort).call(this, {
8091
+ args[optionsIndex] = _objectSpread2(_objectSpread2(_objectSpread2({}, this.updateOptions()), toolOptions), {}, { onAbort: this.onAbort({
7078
8092
  strict,
7079
8093
  onInvalidTarget
7080
8094
  }) });
7081
- _assertClassBrand(_QueryManager_brand, this, _commit).call(this, update(_classPrivateFieldGet2(_query, this), ...args.slice(0, optionsIndex + 1)));
8095
+ this.commit(update(this.state.query, ...args.slice(0, optionsIndex + 1)));
7082
8096
  return this;
7083
8097
  }
7084
8098
  /** Moves the rule or group at `oldPathOrID` to `newPath`, or shifts it `'up'`/`'down'`. */
7085
8099
  move(oldPathOrID, newPath, options = {}) {
7086
8100
  const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded4);
7087
- _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, {
8101
+ this.commit(move(this.state.query, oldPathOrID, newPath, _objectSpread2(_objectSpread2(_objectSpread2({}, this.toolOptions()), toolOptions), {}, { onAbort: this.onAbort({
7088
8102
  strict,
7089
8103
  onInvalidTarget
7090
8104
  }) })));
@@ -7096,7 +8110,7 @@ var QueryManager = class QueryManager {
7096
8110
  */
7097
8111
  insert(ruleOrGroup, path, options = {}) {
7098
8112
  const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded5);
7099
- _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, {
8113
+ this.commit(insert(this.state.query, ruleOrGroup, path, _objectSpread2(_objectSpread2(_objectSpread2({}, this.toolOptions()), toolOptions), {}, { onAbort: this.onAbort({
7100
8114
  strict,
7101
8115
  onInvalidTarget
7102
8116
  }) })));
@@ -7108,7 +8122,7 @@ var QueryManager = class QueryManager {
7108
8122
  */
7109
8123
  group(sourcePathOrID, targetPathOrID, options = {}) {
7110
8124
  const { strict, onInvalidTarget } = options, toolOptions = _objectWithoutProperties(options, _excluded6);
7111
- _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, {
8125
+ this.commit(group(this.state.query, sourcePathOrID, targetPathOrID, _objectSpread2(_objectSpread2(_objectSpread2({}, this.toolOptions()), toolOptions), {}, { onAbort: this.onAbort({
7112
8126
  strict,
7113
8127
  onInvalidTarget
7114
8128
  }) })));
@@ -7120,7 +8134,7 @@ var QueryManager = class QueryManager {
7120
8134
  * defaults filled in for options that were never provided.
7121
8135
  */
7122
8136
  getOptions() {
7123
- return freeze(_objectSpread2({}, _classPrivateFieldGet2(_options, this)));
8137
+ return freeze(_objectSpread2({}, this.state.options));
7124
8138
  }
7125
8139
  /**
7126
8140
  * Updates the manager's configuration in place, keeping the current query, the undo/redo
@@ -7143,20 +8157,51 @@ var QueryManager = class QueryManager {
7143
8157
  * re-normalize.
7144
8158
  *
7145
8159
  * History options are honored immediately: lowering `maxHistory` trims the undo stack, and
7146
- * turning history off clears both stacks. Subscribers are notified once, and
7147
- * {@link QueryManager.getConfigVersion} is incremented, even inside a
7148
- * {@link QueryManager.batch batch} — configuration is not part of a batch's rollback.
8160
+ * turning history off clears both stacks.
8161
+ *
8162
+ * A call that resolves to the configuration already in effect is a **no-op**: nothing is
8163
+ * re-derived, {@link QueryManager.getConfigVersion} does not change, and subscribers are not
8164
+ * notified. Equality is structural for data and by identity for functions
8165
+ * ({@link optionsEqual}), so a caller that rebuilds its options object on every render — which
8166
+ * every framework adapter does — does not force a reconfigure as long as the data is the same.
8167
+ * Rebuilding a callback per render _does_ count as a change; memoize it to avoid that.
8168
+ *
8169
+ * Otherwise subscribers are notified once and `getConfigVersion` is incremented. Inside a
8170
+ * {@link QueryManager.batch batch} the options are still applied immediately — configuration
8171
+ * is not part of a batch's rollback — but the notification is deferred and merged into the
8172
+ * batch's single notification.
7149
8173
  */
7150
8174
  reconfigure(options, config) {
7151
- var _this$configVersion;
7152
- _assertClassBrand(_QueryManager_brand, this, _applyOptions).call(this, freeze((config === null || config === void 0 ? void 0 : config.replace) ? _objectSpread2({}, options) : _objectSpread2(_objectSpread2({}, _classPrivateFieldGet2(_options, this)), options)));
7153
- _classPrivateFieldSet2(_validation, this, void 0);
7154
- _assertClassBrand(_QueryManager_brand, this, _reconcileHistoryConfig).call(this);
7155
- _classPrivateFieldSet2(_configVersion, this, (_this$configVersion = _classPrivateFieldGet2(_configVersion, this), ++_this$configVersion));
7156
- _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
8175
+ const merged = (config === null || config === void 0 ? void 0 : config.replace) ? _objectSpread2({}, options) : _objectSpread2(_objectSpread2({}, this.state.options), options);
8176
+ if (optionsEqual(this.state.options, merged)) return this;
8177
+ this.applyOptions(freeze(merged));
8178
+ this.state.validation = void 0;
8179
+ this.reconcileHistoryConfig();
8180
+ ++this.state.configVersion;
8181
+ if (this.state.batchDepth > 0) this.state.pendingConfigNotify = true;
8182
+ else this.notify(configChange);
7157
8183
  return this;
7158
8184
  }
7159
8185
  /**
8186
+ * Brings the history stacks in line with the current history configuration. Unlike
8187
+ * {@link QueryManager.clearHistory}, this does _not_ set `historyBypassed`: it reflects a
8188
+ * configuration change rather than a deliberate history repositioning, so a later mutation in
8189
+ * the same batch must still be recorded normally.
8190
+ *
8191
+ * Called by {@link QueryManager.reconfigure} and again after a failed
8192
+ * {@link QueryManager.batch batch} restores its snapshot, since that snapshot predates the
8193
+ * configuration change (configuration is not part of a batch's rollback).
8194
+ */
8195
+ reconcileHistoryConfig() {
8196
+ if (this.state.historyEnabled) {
8197
+ if (this.state.past.length > this.state.maxHistory) this.state.past.splice(0, this.state.past.length - this.state.maxHistory);
8198
+ } else {
8199
+ this.state.past = [];
8200
+ this.state.future = [];
8201
+ this.state.lastSig = void 0;
8202
+ }
8203
+ }
8204
+ /**
7160
8205
  * Creates an independent manager with the same configuration and the current query.
7161
8206
  *
7162
8207
  * Subscribers and history are _not_ carried over: the clone starts with no listeners and an
@@ -7167,8 +8212,8 @@ var QueryManager = class QueryManager {
7167
8212
  * is useful when both queries will be used together (e.g. inserted into the same tree).
7168
8213
  */
7169
8214
  clone(options) {
7170
- const query = (options === null || options === void 0 ? void 0 : options.regenerateIDs) ? regenerateIDs(_classPrivateFieldGet2(_query, this), { idGenerator: _classPrivateFieldGet2(_idGenerator, this) }) : _classPrivateFieldGet2(_query, this);
7171
- return new QueryManager(query, _classPrivateFieldGet2(_options, this));
8215
+ const query = (options === null || options === void 0 ? void 0 : options.regenerateIDs) ? regenerateIDs(this.state.query, { idGenerator: this.state.idGenerator }) : this.state.query;
8216
+ return new QueryManager(query, this.state.options);
7172
8217
  }
7173
8218
  /**
7174
8219
  * Runs `fn`, deferring history recording and subscriber notification until it returns. The
@@ -7185,77 +8230,78 @@ var QueryManager = class QueryManager {
7185
8230
  * its own, leaving the stacks exactly as those methods left them.
7186
8231
  */
7187
8232
  batch(fn) {
7188
- var _this$batchDepth;
7189
- _classPrivateFieldSet2(_batchDepth, this, (_this$batchDepth = _classPrivateFieldGet2(_batchDepth, this), _this$batchDepth++, _this$batchDepth));
7190
- if (_classPrivateFieldGet2(_batchDepth, this) === 1) _classPrivateFieldSet2(_batchSnapshot, this, {
7191
- query: _classPrivateFieldGet2(_query, this),
7192
- past: [..._classPrivateFieldGet2(_past, this)],
7193
- future: [..._classPrivateFieldGet2(_future, this)],
7194
- lastSig: _classPrivateFieldGet2(_lastSig, this),
7195
- lastAt: _classPrivateFieldGet2(_lastAt, this)
7196
- });
8233
+ this.state.batchDepth++;
8234
+ if (this.state.batchDepth === 1) this.state.batchSnapshot = {
8235
+ query: this.state.query,
8236
+ past: [...this.state.past],
8237
+ future: [...this.state.future],
8238
+ lastSig: this.state.lastSig,
8239
+ lastAt: this.state.lastAt
8240
+ };
7197
8241
  try {
7198
8242
  fn();
7199
8243
  } catch (error) {
7200
- if (_classPrivateFieldGet2(_batchDepth, this) === 1) {
7201
- const snapshot = _classPrivateFieldGet2(_batchSnapshot, this);
7202
- _classPrivateFieldSet2(_query, this, snapshot.query);
7203
- _classPrivateFieldSet2(_past, this, snapshot.past);
7204
- _classPrivateFieldSet2(_future, this, snapshot.future);
7205
- _classPrivateFieldSet2(_lastSig, this, snapshot.lastSig);
7206
- _classPrivateFieldSet2(_lastAt, this, snapshot.lastAt);
7207
- _assertClassBrand(_QueryManager_brand, this, _reconcileHistoryConfig).call(this);
8244
+ if (this.state.batchDepth === 1) {
8245
+ const snapshot = this.state.batchSnapshot;
8246
+ this.state.query = snapshot.query;
8247
+ this.state.past = snapshot.past;
8248
+ this.state.future = snapshot.future;
8249
+ this.state.lastSig = snapshot.lastSig;
8250
+ this.state.lastAt = snapshot.lastAt;
8251
+ this.reconcileHistoryConfig();
7208
8252
  }
7209
8253
  throw error;
7210
8254
  } finally {
7211
- var _this$batchDepth3;
7212
- _classPrivateFieldSet2(_batchDepth, this, (_this$batchDepth3 = _classPrivateFieldGet2(_batchDepth, this), _this$batchDepth3--, _this$batchDepth3));
7213
- if (_classPrivateFieldGet2(_batchDepth, this) === 0) {
7214
- const { query: base } = _classPrivateFieldGet2(_batchSnapshot, this);
7215
- _classPrivateFieldSet2(_batchSnapshot, this, void 0);
7216
- if (base !== _classPrivateFieldGet2(_query, this)) {
7217
- if (!_classPrivateFieldGet2(_historyBypassed, this)) _assertClassBrand(_QueryManager_brand, this, _record).call(this, base, _classPrivateFieldGet2(_query, this));
7218
- _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
8255
+ this.state.batchDepth--;
8256
+ if (this.state.batchDepth === 0) {
8257
+ const { query: base } = this.state.batchSnapshot;
8258
+ this.state.batchSnapshot = void 0;
8259
+ const queryChanged = base !== this.state.query;
8260
+ const configChanged = this.state.pendingConfigNotify;
8261
+ this.state.pendingConfigNotify = false;
8262
+ if (queryChanged) {
8263
+ if (!this.state.historyBypassed) this.record(base, this.state.query);
7219
8264
  }
7220
- _classPrivateFieldSet2(_historyBypassed, this, false);
8265
+ if (queryChanged || configChanged) this.notify(queryChanged ? configChanged ? queryAndConfigChange : queryChange : configChange);
8266
+ this.state.historyBypassed = false;
7221
8267
  }
7222
8268
  }
7223
8269
  return this;
7224
8270
  }
7225
8271
  /** Whether there is a previous query to restore. Always `false` unless `history` is enabled. */
7226
8272
  canUndo() {
7227
- return _classPrivateFieldGet2(_past, this).length > 0;
8273
+ return this.state.past.length > 0;
7228
8274
  }
7229
8275
  /** Whether there is an undone query to restore. Always `false` unless `history` is enabled. */
7230
8276
  canRedo() {
7231
- return _classPrivateFieldGet2(_future, this).length > 0;
8277
+ return this.state.future.length > 0;
7232
8278
  }
7233
8279
  /** Restores the previous query. No-op when {@link QueryManager.canUndo} is `false`. */
7234
8280
  undo() {
7235
- if (_classPrivateFieldGet2(_past, this).length === 0) return this;
7236
- _classPrivateFieldGet2(_future, this).unshift(_classPrivateFieldGet2(_query, this));
7237
- _classPrivateFieldSet2(_query, this, _classPrivateFieldGet2(_past, this).pop());
7238
- _classPrivateFieldSet2(_lastSig, this, void 0);
7239
- _assertClassBrand(_QueryManager_brand, this, _markHistoryBypassed).call(this);
7240
- if (_classPrivateFieldGet2(_batchDepth, this) === 0) _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
8281
+ if (this.state.past.length === 0) return this;
8282
+ this.state.future.unshift(this.state.query);
8283
+ this.state.query = this.state.past.pop();
8284
+ this.state.lastSig = void 0;
8285
+ this.markHistoryBypassed();
8286
+ if (this.state.batchDepth === 0) this.notify(queryChange);
7241
8287
  return this;
7242
8288
  }
7243
8289
  /** Restores the most recently undone query. No-op when {@link QueryManager.canRedo} is `false`. */
7244
8290
  redo() {
7245
- if (_classPrivateFieldGet2(_future, this).length === 0) return this;
7246
- _classPrivateFieldGet2(_past, this).push(_classPrivateFieldGet2(_query, this));
7247
- _classPrivateFieldSet2(_query, this, _classPrivateFieldGet2(_future, this).shift());
7248
- _classPrivateFieldSet2(_lastSig, this, void 0);
7249
- _assertClassBrand(_QueryManager_brand, this, _markHistoryBypassed).call(this);
7250
- if (_classPrivateFieldGet2(_batchDepth, this) === 0) _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
8291
+ if (this.state.future.length === 0) return this;
8292
+ this.state.past.push(this.state.query);
8293
+ this.state.query = this.state.future.shift();
8294
+ this.state.lastSig = void 0;
8295
+ this.markHistoryBypassed();
8296
+ if (this.state.batchDepth === 0) this.notify(queryChange);
7251
8297
  return this;
7252
8298
  }
7253
8299
  /** Discards all undo/redo history without changing the current query. */
7254
8300
  clearHistory() {
7255
- _assertClassBrand(_QueryManager_brand, this, _markHistoryBypassed).call(this);
7256
- _classPrivateFieldSet2(_past, this, []);
7257
- _classPrivateFieldSet2(_future, this, []);
7258
- _classPrivateFieldSet2(_lastSig, this, void 0);
8301
+ this.markHistoryBypassed();
8302
+ this.state.past = [];
8303
+ this.state.future = [];
8304
+ this.state.lastSig = void 0;
7259
8305
  return this;
7260
8306
  }
7261
8307
  /**
@@ -7264,8 +8310,8 @@ var QueryManager = class QueryManager {
7264
8310
  */
7265
8311
  getHistory() {
7266
8312
  return {
7267
- past: [..._classPrivateFieldGet2(_past, this)],
7268
- future: [..._classPrivateFieldGet2(_future, this)]
8313
+ past: [...this.state.past],
8314
+ future: [...this.state.future]
7269
8315
  };
7270
8316
  }
7271
8317
  /**
@@ -7275,13 +8321,13 @@ var QueryManager = class QueryManager {
7275
8321
  * one that depends on anything other than the query) may run fewer times than expected.
7276
8322
  */
7277
8323
  validate() {
7278
- var _classPrivateFieldGet6;
7279
- _assertClassBrand(_QueryManager_brand, this, _ensureCache).call(this);
7280
- (_classPrivateFieldGet6 = _classPrivateFieldGet2(_validation, this)) !== null && _classPrivateFieldGet6 !== void 0 || _classPrivateFieldSet2(_validation, this, _classPrivateFieldGet2(_validator, this).call(this, _classPrivateFieldGet2(_query, this)));
7281
- return _classPrivateFieldGet2(_validation, this);
8324
+ var _this$state, _this$state$validatio;
8325
+ this.ensureCache();
8326
+ (_this$state$validatio = (_this$state = this.state).validation) !== null && _this$state$validatio !== void 0 || (_this$state.validation = this.state.validator(this.state.query));
8327
+ return this.state.validation;
7282
8328
  }
7283
8329
  format(options) {
7284
- return formatQuery(_classPrivateFieldGet2(_query, this), options);
8330
+ return formatQuery(this.state.query, options);
7285
8331
  }
7286
8332
  /**
7287
8333
  * Yields every rule and group in the query, depth-first in pre-order, starting with the root
@@ -7301,18 +8347,18 @@ var QueryManager = class QueryManager {
7301
8347
  */
7302
8348
  *walk(options = {}) {
7303
8349
  const { from, rulesOnly, groupsOnly } = options;
7304
- let start = _classPrivateFieldGet2(_query, this);
8350
+ let start = this.state.query;
7305
8351
  let startPath = [];
7306
8352
  let startParent = null;
7307
8353
  if (from !== void 0) {
7308
- const path = _assertClassBrand(_QueryManager_brand, this, _toPath).call(this, from);
7309
- const node = path && findPath(path, _classPrivateFieldGet2(_query, this));
8354
+ const path = this.toPath(from);
8355
+ const node = path && findPath(path, this.state.query);
7310
8356
  if (!path || !node) return;
7311
8357
  start = node;
7312
8358
  startPath = path;
7313
- startParent = path.length === 0 ? null : findPath(getParentPath(path), _classPrivateFieldGet2(_query, this));
8359
+ startParent = path.length === 0 ? null : findPath(getParentPath(path), this.state.query);
7314
8360
  }
7315
- for (const entry of _assertClassBrand(_QueryManager_brand, this, _walkFrom).call(this, start, startPath, startParent)) {
8361
+ for (const entry of this.walkFrom(start, startPath, startParent)) {
7316
8362
  if (rulesOnly && isRuleGroup(entry.node)) continue;
7317
8363
  if (groupsOnly && !isRuleGroup(entry.node)) continue;
7318
8364
  yield entry;
@@ -7352,15 +8398,15 @@ var QueryManager = class QueryManager {
7352
8398
  */
7353
8399
  findPath(path) {
7354
8400
  var _findPath;
7355
- return (_findPath = findPath(path, _classPrivateFieldGet2(_query, this))) !== null && _findPath !== void 0 ? _findPath : null;
8401
+ return (_findPath = findPath(path, this.state.query)) !== null && _findPath !== void 0 ? _findPath : null;
7356
8402
  }
7357
8403
  /**
7358
8404
  * Returns the rule or group with the given `id`, or `null` if there is none. Backed by an
7359
8405
  * index built once per query, so repeated lookups are constant time.
7360
8406
  */
7361
8407
  findID(id) {
7362
- const path = _assertClassBrand(_QueryManager_brand, this, _index).call(this).get(id);
7363
- return path === void 0 ? null : findPath(path, _classPrivateFieldGet2(_query, this));
8408
+ const path = this.index().get(id);
8409
+ return path === void 0 ? null : findPath(path, this.state.query);
7364
8410
  }
7365
8411
  /**
7366
8412
  * Returns the {@link Path} of the rule or group with the given `id`, or `null` if there is
@@ -7368,20 +8414,20 @@ var QueryManager = class QueryManager {
7368
8414
  */
7369
8415
  getPathOfID(id) {
7370
8416
  var _this$index$get2;
7371
- return (_this$index$get2 = _assertClassBrand(_QueryManager_brand, this, _index).call(this).get(id)) !== null && _this$index$get2 !== void 0 ? _this$index$get2 : null;
8417
+ return (_this$index$get2 = this.index().get(id)) !== null && _this$index$get2 !== void 0 ? _this$index$get2 : null;
7372
8418
  }
7373
8419
  /**
7374
8420
  * Determines whether the rule or group at the given path is disabled, either itself or by an
7375
8421
  * ancestor group.
7376
8422
  */
7377
8423
  pathIsDisabled(path) {
7378
- return pathIsDisabled(path, _classPrivateFieldGet2(_query, this));
8424
+ return pathIsDisabled(path, this.state.query);
7379
8425
  }
7380
8426
  /** Returns the rule or group at the given path or `id`, or `null` if it can't be resolved. */
7381
8427
  getNode(pathOrID) {
7382
8428
  var _findPath2;
7383
- const path = _assertClassBrand(_QueryManager_brand, this, _toPath).call(this, pathOrID);
7384
- return path === null ? null : (_findPath2 = findPath(path, _classPrivateFieldGet2(_query, this))) !== null && _findPath2 !== void 0 ? _findPath2 : null;
8429
+ const path = this.toPath(pathOrID);
8430
+ return path === null ? null : (_findPath2 = findPath(path, this.state.query)) !== null && _findPath2 !== void 0 ? _findPath2 : null;
7385
8431
  }
7386
8432
  /**
7387
8433
  * Returns the rule at the given path or `id`, or `null` if it can't be resolved _or_ resolves
@@ -7404,24 +8450,24 @@ var QueryManager = class QueryManager {
7404
8450
  * for the root group, which has no parent, and when the target can't be resolved.
7405
8451
  */
7406
8452
  getParent(pathOrID) {
7407
- const path = _assertClassBrand(_QueryManager_brand, this, _toPath).call(this, pathOrID);
8453
+ const path = this.toPath(pathOrID);
7408
8454
  if (path === null || path.length === 0) return null;
7409
- if (!findPath(path, _classPrivateFieldGet2(_query, this))) return null;
7410
- return findPath(getParentPath(path), _classPrivateFieldGet2(_query, this));
8455
+ if (!findPath(path, this.state.query)) return null;
8456
+ return findPath(getParentPath(path), this.state.query);
7411
8457
  }
7412
8458
  /**
7413
8459
  * The normalized field list, as the `QueryBuilder` component would render it. Needed to
7414
8460
  * populate a field selector.
7415
8461
  */
7416
8462
  getFields() {
7417
- return _classPrivateFieldGet2(_fields, this);
8463
+ return this.state.fields;
7418
8464
  }
7419
8465
  /**
7420
8466
  * The normalized combinator list, as the `QueryBuilder` component would render it. Needed to
7421
8467
  * populate a combinator selector.
7422
8468
  */
7423
8469
  getCombinators() {
7424
- return _classPrivateFieldGet2(_combinators, this);
8470
+ return this.state.combinators;
7425
8471
  }
7426
8472
  /**
7427
8473
  * The field configuration for a field name. When the field isn't configured, returns the same
@@ -7429,27 +8475,51 @@ var QueryManager = class QueryManager {
7429
8475
  * {@link QueryManager.getRuleContext} reports as `fieldData`, so both access paths agree.
7430
8476
  */
7431
8477
  getFieldData(field) {
7432
- return getFieldData(field, _classPrivateFieldGet2(_fieldMap, this));
8478
+ return getFieldData(field, this.state.fieldMap);
7433
8479
  }
7434
8480
  /** The operator list for a field, mirroring `QueryBuilder`'s precedence. */
7435
8481
  getOperators(field) {
7436
- return _assertClassBrand(_QueryManager_brand, this, _operatorsFor).call(this, field);
8482
+ return this.operatorsFor(field);
7437
8483
  }
7438
8484
  /** The value sources available for a field/operator pair. */
7439
8485
  getValueSources(field, operator) {
7440
- return _assertClassBrand(_QueryManager_brand, this, _valueSourcesFor).call(this, field, operator);
8486
+ return this.valueSourcesFor(field, operator);
7441
8487
  }
7442
8488
  /** The match modes available for a field. */
7443
8489
  getMatchModes(field) {
7444
- return _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, field);
8490
+ return this.matchModesFor(field);
7445
8491
  }
7446
8492
  /** The value option list for a field/operator pair. */
7447
8493
  getValues(field, operator) {
7448
- return _assertClassBrand(_QueryManager_brand, this, _valuesFor).call(this, field, operator);
8494
+ return this.valuesFor(field, operator);
7449
8495
  }
7450
8496
  /** The value editor type for a field/operator pair. */
7451
8497
  getValueEditorType(field, operator) {
7452
- return _assertClassBrand(_QueryManager_brand, this, _valueEditorTypeFor).call(this, field, operator);
8498
+ return this.valueEditorTypeFor(field, operator);
8499
+ }
8500
+ /**
8501
+ * The default `operator` for a field, identical to the operator
8502
+ * {@link QueryManager.createRule} would assign to a new rule on that field.
8503
+ */
8504
+ getRuleDefaultOperator(field) {
8505
+ return this.defaultOperator(field);
8506
+ }
8507
+ /**
8508
+ * The default `value` for a rule, identical to the value {@link QueryManager.createRule} and
8509
+ * {@link QueryManager.update} would assign after a field or operator change.
8510
+ */
8511
+ getRuleDefaultValue(rule) {
8512
+ return this.defaultValue(rule);
8513
+ }
8514
+ /**
8515
+ * The flattened field record backing {@link QueryManager.getFieldData}, keyed by field name
8516
+ * with option groups flattened away.
8517
+ *
8518
+ * Treat the result as read-only. It may or may not be frozen depending on configuration, so
8519
+ * do not rely on frozen-ness to prevent mutation.
8520
+ */
8521
+ getFieldMap() {
8522
+ return this.state.fieldMap;
7453
8523
  }
7454
8524
  /**
7455
8525
  * Resolves everything about a rule that depends on the field/operator configuration—field data,
@@ -7464,21 +8534,21 @@ var QueryManager = class QueryManager {
7464
8534
  if (!rule) return null;
7465
8535
  const validation = this.validate();
7466
8536
  return deriveRuleContext(rule, {
7467
- fields: _classPrivateFieldGet2(_fields, this),
7468
- fieldMap: _classPrivateFieldGet2(_fieldMap, this),
8537
+ fields: this.state.fields,
8538
+ fieldMap: this.state.fieldMap,
7469
8539
  getInputType: (f, o, misc) => {
7470
- var _this$options$getInpu, _classPrivateFieldGet7, _classPrivateFieldGet8;
7471
- return (_this$options$getInpu = (_classPrivateFieldGet7 = (_classPrivateFieldGet8 = _classPrivateFieldGet2(_options, this)).getInputType) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.call(_classPrivateFieldGet8, f, o, misc)) !== null && _this$options$getInpu !== void 0 ? _this$options$getInpu : null;
8540
+ var _this$state$options$g3, _this$state$options$g4, _this$state$options2;
8541
+ return (_this$state$options$g3 = (_this$state$options$g4 = (_this$state$options2 = this.state.options).getInputType) === null || _this$state$options$g4 === void 0 ? void 0 : _this$state$options$g4.call(_this$state$options2, f, o, misc)) !== null && _this$state$options$g3 !== void 0 ? _this$state$options$g3 : null;
7472
8542
  },
7473
- getMatchModes: (f) => _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, f),
7474
- getOperators: (f) => _assertClassBrand(_QueryManager_brand, this, _operatorsFor).call(this, f),
7475
- getParameters: (f, o, misc) => _assertClassBrand(_QueryManager_brand, this, _parametersFor).call(this, f, o, misc),
7476
- getValueEditorType: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valueEditorTypeFor).call(this, f, o),
7477
- getValues: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valuesFor).call(this, f, o),
8543
+ getMatchModes: (f) => this.matchModesFor(f),
8544
+ getOperators: (f) => this.operatorsFor(f),
8545
+ getParameters: (f, o, misc) => this.parametersFor(f, o, misc),
8546
+ getValueEditorType: (f, o) => this.valueEditorTypeFor(f, o),
8547
+ getValues: (f, o) => this.valuesFor(f, o),
7478
8548
  getValueSources: (f, o) => this.getValueSources(f, o),
7479
8549
  getSubQueryBuilderProps: (f, misc) => {
7480
- var _this$options$getSubQ, _classPrivateFieldGet9, _classPrivateFieldGet10;
7481
- return (_this$options$getSubQ = (_classPrivateFieldGet9 = (_classPrivateFieldGet10 = _classPrivateFieldGet2(_options, this)).getSubQueryBuilderProps) === null || _classPrivateFieldGet9 === void 0 ? void 0 : _classPrivateFieldGet9.call(_classPrivateFieldGet10, f, misc)) !== null && _this$options$getSubQ !== void 0 ? _this$options$getSubQ : {};
8550
+ var _this$state$options$g5, _this$state$options$g6, _this$state$options3;
8551
+ return (_this$state$options$g5 = (_this$state$options$g6 = (_this$state$options3 = this.state.options).getSubQueryBuilderProps) === null || _this$state$options$g6 === void 0 ? void 0 : _this$state$options$g6.call(_this$state$options3, f, misc)) !== null && _this$state$options$g5 !== void 0 ? _this$state$options$g5 : {};
7482
8552
  }
7483
8553
  }, {
7484
8554
  validationMap: typeof validation === "boolean" ? {} : validation,
@@ -7495,32 +8565,32 @@ var QueryManager = class QueryManager {
7495
8565
  const ruleGroup = this.getGroup(pathOrID);
7496
8566
  if (!ruleGroup) return null;
7497
8567
  const validation = this.validate();
7498
- return deriveRuleGroupContext(ruleGroup, _classPrivateFieldGet2(_combinators, this), {
8568
+ return deriveRuleGroupContext(ruleGroup, this.state.combinators, {
7499
8569
  validationMap: typeof validation === "boolean" ? {} : validation,
7500
8570
  id: ruleGroup.id
7501
8571
  });
7502
8572
  }
7503
8573
  /** Whether the current query uses independent combinators. */
7504
8574
  isIC() {
7505
- return isRuleGroupTypeIC(_classPrivateFieldGet2(_query, this));
8575
+ return isRuleGroupTypeIC(this.state.query);
7506
8576
  }
7507
8577
  /**
7508
8578
  * Returns the signature describing how the current query differs from `other`, as used by
7509
8579
  * this manager's history coalescing.
7510
8580
  */
7511
8581
  signatureOf(other) {
7512
- return signatureOf(_classPrivateFieldGet2(_query, this), other);
8582
+ return signatureOf(this.state.query, other);
7513
8583
  }
7514
8584
  /** Generates a {@link DiagnosticsResult}. Shorthand for `format('diagnostics')`. */
7515
8585
  diagnostics() {
7516
- return formatQuery(_classPrivateFieldGet2(_query, this), "diagnostics");
8586
+ return formatQuery(this.state.query, "diagnostics");
7517
8587
  }
7518
8588
  /**
7519
8589
  * Returns the current query, so `JSON.stringify(queryManager)` produces the same output as
7520
8590
  * `JSON.stringify(queryManager.getQuery())`.
7521
8591
  */
7522
8592
  toJSON() {
7523
- return _classPrivateFieldGet2(_query, this);
8593
+ return this.state.query;
7524
8594
  }
7525
8595
  /**
7526
8596
  * Returns a new manager with the same configuration and the current query converted to use
@@ -7528,7 +8598,7 @@ var QueryManager = class QueryManager {
7528
8598
  * {@link QueryManager.clone}, subscribers and history are not carried over.
7529
8599
  */
7530
8600
  toIC() {
7531
- return new QueryManager(convertToIC(_classPrivateFieldGet2(_query, this)), _classPrivateFieldGet2(_options, this));
8601
+ return new QueryManager(convertToIC(this.state.query), this.state.options);
7532
8602
  }
7533
8603
  /**
7534
8604
  * Returns a new manager with the same configuration and the current query converted to use a
@@ -7536,7 +8606,7 @@ var QueryManager = class QueryManager {
7536
8606
  * {@link QueryManager.clone}, subscribers and history are not carried over.
7537
8607
  */
7538
8608
  fromIC() {
7539
- return new QueryManager(convertFromIC(_classPrivateFieldGet2(_query, this)), _classPrivateFieldGet2(_options, this));
8609
+ return new QueryManager(convertFromIC(this.state.query), this.state.options);
7540
8610
  }
7541
8611
  /**
7542
8612
  * Runs {@link transformQuery} against the current query and returns its result.
@@ -7546,270 +8616,10 @@ var QueryManager = class QueryManager {
7546
8616
  * shapes that are no longer valid queries. This manager is never modified.
7547
8617
  */
7548
8618
  transform(options) {
7549
- return transformQuery(_classPrivateFieldGet2(_query, this), options);
7550
- }
7551
- };
7552
- /**
7553
- * Assigns `#options` and every field derived from it. Shared by the constructor and
7554
- * {@link QueryManager.reconfigure}, so the two can never drift apart. Does not touch the
7555
- * query, the history stacks, the caches, or the subscriber list.
7556
- */
7557
- function _applyOptions(options) {
7558
- var _options$idGenerator, _options$validator, _options$strict, _options$respectDisab, _options$history, _historyOptions$maxHi, _historyOptions$coale, _options$now, _options$translations, _options$operators, _options$translations2, _options$combinators;
7559
- _classPrivateFieldSet2(_options, this, options);
7560
- _classPrivateFieldSet2(_idGenerator, this, (_options$idGenerator = options.idGenerator) !== null && _options$idGenerator !== void 0 ? _options$idGenerator : generateID);
7561
- _classPrivateFieldSet2(_validator, this, (_options$validator = options.validator) !== null && _options$validator !== void 0 ? _options$validator : defaultValidator);
7562
- _classPrivateFieldSet2(_strict, this, (_options$strict = options.strict) !== null && _options$strict !== void 0 ? _options$strict : false);
7563
- _classPrivateFieldSet2(_respectDisabled, this, (_options$respectDisab = options.respectDisabled) !== null && _options$respectDisab !== void 0 ? _options$respectDisab : true);
7564
- _classPrivateFieldSet2(_onInvalidTarget, this, options.onInvalidTarget);
7565
- const history = (_options$history = options.history) !== null && _options$history !== void 0 ? _options$history : false;
7566
- const historyOptions = typeof history === "object" ? history : {};
7567
- _classPrivateFieldSet2(_historyEnabled, this, history !== false);
7568
- _classPrivateFieldSet2(_maxHistory, this, (_historyOptions$maxHi = historyOptions.maxHistory) !== null && _historyOptions$maxHi !== void 0 ? _historyOptions$maxHi : 50);
7569
- _classPrivateFieldSet2(_coalesceMs, this, (_historyOptions$coale = historyOptions.coalesceMs) !== null && _historyOptions$coale !== void 0 ? _historyOptions$coale : 500);
7570
- _classPrivateFieldSet2(_now, this, (_options$now = options.now) !== null && _options$now !== void 0 ? _options$now : Date.now);
7571
- const { optionList: fields, optionsMap: fieldMap } = prepareOptionList({
7572
- optionList: options.fields,
7573
- baseOption: options.baseField,
7574
- autoSelectOption: options.autoSelectField,
7575
- placeholder: (_options$translations = options.translations) === null || _options$translations === void 0 ? void 0 : _options$translations.fields
7576
- });
7577
- _classPrivateFieldSet2(_fields, this, freeze(fields, true));
7578
- _classPrivateFieldSet2(_fieldMap, this, freeze(fieldMap, true));
7579
- _classPrivateFieldSet2(_operators, this, prepareOptionList({
7580
- optionList: (_options$operators = options.operators) !== null && _options$operators !== void 0 ? _options$operators : defaultOperators,
7581
- baseOption: options.baseOperator,
7582
- labelMap: defaultOperatorLabelMap,
7583
- autoSelectOption: options.autoSelectOperator,
7584
- placeholder: (_options$translations2 = options.translations) === null || _options$translations2 === void 0 ? void 0 : _options$translations2.operators
7585
- }).optionList);
7586
- _classPrivateFieldSet2(_combinators, this, freeze(prepareOptionList({
7587
- optionList: (_options$combinators = options.combinators) !== null && _options$combinators !== void 0 ? _options$combinators : defaultCombinators,
7588
- baseOption: options.baseCombinator
7589
- }).optionList, true));
7590
- }
7591
- /** Resolves the field configuration for a field name. */
7592
- function _fieldData(field) {
7593
- var _this$fieldMap$field;
7594
- return (_this$fieldMap$field = _classPrivateFieldGet2(_fieldMap, this)[field]) !== null && _this$fieldMap$field !== void 0 ? _this$fieldMap$field : {};
7595
- }
7596
- /** Resolves the operator list for a field, mirroring `QueryBuilder`'s precedence. */
7597
- function _operatorsFor(field) {
7598
- var _classPrivateFieldGet2$1;
7599
- return resolveOperatorList({
7600
- field,
7601
- fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7602
- getOperators: _classPrivateFieldGet2(_options, this).getOperators,
7603
- operators: _classPrivateFieldGet2(_operators, this),
7604
- baseOption: _classPrivateFieldGet2(_options, this).baseOperator,
7605
- autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectOperator,
7606
- placeholder: (_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_options, this).translations) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.operators
7607
- });
7608
- }
7609
- /** Resolves the default operator for a field, mirroring `QueryBuilder`'s precedence. */
7610
- function _defaultOperator(field) {
7611
- return resolveDefaultOperator({
7612
- field,
7613
- fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7614
- getDefaultOperator: _classPrivateFieldGet2(_options, this).getDefaultOperator,
7615
- getOperators: (f) => _assertClassBrand(_QueryManager_brand, this, _operatorsFor).call(this, f)
7616
- });
7617
- }
7618
- function _valueSourcesFor(field, operator) {
7619
- return getValueSourcesUtil(_assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field), operator, _classPrivateFieldGet2(_options, this).getValueSources);
7620
- }
7621
- function _matchModesFor(field) {
7622
- return getMatchModesUtil(_assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field), _classPrivateFieldGet2(_options, this).getMatchModes);
7623
- }
7624
- function _valuesFor(field, operator) {
7625
- var _classPrivateFieldGet3;
7626
- return resolveValueList({
7627
- field,
7628
- operator,
7629
- fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7630
- getValues: _classPrivateFieldGet2(_options, this).getValues,
7631
- autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectValue,
7632
- placeholder: (_classPrivateFieldGet3 = _classPrivateFieldGet2(_options, this).translations) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.values
7633
- });
7634
- }
7635
- function _valueEditorTypeFor(field, operator) {
7636
- return resolveValueEditorType({
7637
- field,
7638
- operator,
7639
- fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7640
- getValueEditorType: _classPrivateFieldGet2(_options, this).getValueEditorType
7641
- });
7642
- }
7643
- /** Computes the default `value` for a rule, mirroring `QueryBuilder`'s precedence. */
7644
- function _defaultValue(rule) {
7645
- const { getDefaultValue, getParameters, listsAsArrays } = _classPrivateFieldGet2(_options, this);
7646
- return getRuleDefaultValue(rule, {
7647
- fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, rule.field),
7648
- fields: _classPrivateFieldGet2(_fields, this),
7649
- listsAsArrays,
7650
- getValueEditorType: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valueEditorTypeFor).call(this, f, o),
7651
- getValues: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valuesFor).call(this, f, o),
7652
- getDefaultValue: getDefaultValue && ((r, misc) => getDefaultValue(r, misc)),
7653
- getParameters: getParameters && ((f, o, misc) => _assertClassBrand(_QueryManager_brand, this, _parametersFor).call(this, f, o, misc))
7654
- });
7655
- }
7656
- /**
7657
- * Resolves the parameter list for a field/operator pair, normalized the same way as every
7658
- * other option list. Shared by {@link QueryManager.#defaultValue} and
7659
- * {@link QueryManager.getRuleContext} so both see the same shape.
7660
- */
7661
- function _parametersFor(field, operator, misc) {
7662
- var _this$options$getPara, _classPrivateFieldGet4, _classPrivateFieldGet5;
7663
- return prepareOptionList({
7664
- optionList: (_this$options$getPara = (_classPrivateFieldGet4 = (_classPrivateFieldGet5 = _classPrivateFieldGet2(_options, this)).getParameters) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.call(_classPrivateFieldGet5, field, operator, misc)) !== null && _this$options$getPara !== void 0 ? _this$options$getPara : [],
7665
- autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectValue
7666
- }).optionList;
7667
- }
7668
- /** Defaults shared by every mutating method, overridable per call. */
7669
- function _guardOptions() {
7670
- const { maxLevels } = _classPrivateFieldGet2(_options, this);
7671
- return {
7672
- maxLevels: (maxLevels !== null && maxLevels !== void 0 ? maxLevels : 0) > 0 ? Number(maxLevels) : Infinity,
7673
- respectDisabled: _classPrivateFieldGet2(_respectDisabled, this),
7674
- disabledPaths: _classPrivateFieldGet2(_options, this).disabledPaths,
7675
- queryDisabled: _classPrivateFieldGet2(_options, this).queryDisabled
7676
- };
7677
- }
7678
- function _toolOptions() {
7679
- return _objectSpread2({
7680
- combinators: _classPrivateFieldGet2(_combinators, this),
7681
- idGenerator: _classPrivateFieldGet2(_idGenerator, this)
7682
- }, _assertClassBrand(_QueryManager_brand, this, _guardOptions).call(this));
7683
- }
7684
- /**
7685
- * Builds the `onAbort` handler passed to the query tools, applying the per-call overrides on
7686
- * top of the manager's own options.
7687
- */
7688
- function _onAbort({ strict, onInvalidTarget }) {
7689
- const strictMain = strict !== null && strict !== void 0 ? strict : _classPrivateFieldGet2(_strict, this);
7690
- const handler = onInvalidTarget !== null && onInvalidTarget !== void 0 ? onInvalidTarget : _classPrivateFieldGet2(_onInvalidTarget, this);
7691
- return (info) => {
7692
- handler === null || handler === void 0 || handler(info);
7693
- if (strictMain && strictAbortReasonSet.has(info.reason)) throw new QueryManagerError(info);
7694
- };
7695
- }
7696
- /** Defaults for {@link update}, so resets mirror `QueryBuilder`'s behavior. */
7697
- function _updateOptions() {
7698
- return _objectSpread2({
7699
- getRuleDefaultOperator: (f) => _assertClassBrand(_QueryManager_brand, this, _defaultOperator).call(this, f),
7700
- getRuleDefaultValue: (r) => _assertClassBrand(_QueryManager_brand, this, _defaultValue).call(this, r),
7701
- getValueSources: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valueSourcesFor).call(this, f, o),
7702
- getMatchModes: (f) => _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, f),
7703
- resetOnFieldChange: _classPrivateFieldGet2(_options, this).resetOnFieldChange,
7704
- resetOnOperatorChange: _classPrivateFieldGet2(_options, this).resetOnOperatorChange
7705
- }, _assertClassBrand(_QueryManager_brand, this, _guardOptions).call(this));
7706
- }
7707
- /**
7708
- * Applies a new query, recording history and notifying subscribers as appropriate. Every
7709
- * mutation funnels through here. A tool that could not resolve its target returns the same
7710
- * query object, which is treated as a no-op.
7711
- */
7712
- function _commit(next) {
7713
- const prev = _classPrivateFieldGet2(_query, this);
7714
- if (prev === next) return;
7715
- _classPrivateFieldSet2(_query, this, next);
7716
- if (_classPrivateFieldGet2(_batchDepth, this) > 0) return;
7717
- _assertClassBrand(_QueryManager_brand, this, _record).call(this, prev, next);
7718
- _assertClassBrand(_QueryManager_brand, this, _notify).call(this);
7719
- }
7720
- /**
7721
- * Records a change, either as a new history entry or by absorbing it into the current one.
7722
- * Mirrors the recording semantics of the `react-querybuilder/history` entry point.
7723
- */
7724
- function _record(prev, next) {
7725
- if (!_classPrivateFieldGet2(_historyEnabled, this)) return;
7726
- const sig = signatureOf(prev, next);
7727
- if (sig === "") return;
7728
- const now = _classPrivateFieldGet2(_now, this).call(this);
7729
- if (!(sig !== "~structural" && sig === _classPrivateFieldGet2(_lastSig, this) && now - _classPrivateFieldGet2(_lastAt, this) < _classPrivateFieldGet2(_coalesceMs, this))) {
7730
- _classPrivateFieldGet2(_past, this).push(prev);
7731
- if (_classPrivateFieldGet2(_past, this).length > _classPrivateFieldGet2(_maxHistory, this)) _classPrivateFieldGet2(_past, this).shift();
7732
- _classPrivateFieldSet2(_future, this, []);
7733
- }
7734
- _classPrivateFieldSet2(_lastSig, this, sig);
7735
- _classPrivateFieldSet2(_lastAt, this, now);
7736
- }
7737
- function _notify() {
7738
- for (const listener of _classPrivateFieldGet2(_listeners, this)) listener();
7739
- }
7740
- /**
7741
- * Records that a history-stack method ran inside the current batch. Those methods manage
7742
- * `#past`/`#future` themselves, so the batch must not also record an entry on completion —
7743
- * doing so would push a duplicate onto `#past` and clear the redo stack that `undo` just
7744
- * populated.
7745
- */
7746
- function _markHistoryBypassed() {
7747
- if (_classPrivateFieldGet2(_batchDepth, this) > 0) _classPrivateFieldSet2(_historyBypassed, this, true);
7748
- }
7749
- /**
7750
- * Discards every cached derivation when the query has been replaced since they were computed.
7751
- * Called at the top of each cached reader.
7752
- */
7753
- function _ensureCache() {
7754
- if (_classPrivateFieldGet2(_cacheFor, this) === _classPrivateFieldGet2(_query, this)) return;
7755
- _classPrivateFieldSet2(_cacheFor, this, _classPrivateFieldGet2(_query, this));
7756
- _classPrivateFieldSet2(_idPathIndex, this, void 0);
7757
- _classPrivateFieldSet2(_validation, this, void 0);
7758
- }
7759
- /**
7760
- * The single traversal implementation. Combinator strings in independent-combinator groups
7761
- * are skipped.
7762
- *
7763
- * @yields The subtree rooted at `node`, depth-first in pre-order, starting with `node` itself.
7764
- */
7765
- function* _walkFrom(node, path, parent) {
7766
- yield {
7767
- node,
7768
- path,
7769
- parent
7770
- };
7771
- if (!isRuleGroup(node)) return;
7772
- const startGroup = node;
7773
- for (const [index, child] of startGroup.rules.entries()) {
7774
- if (typeof child === "string") continue;
7775
- yield* _assertClassBrand(_QueryManager_brand, this, _walkFrom).call(this, child, [...path, index], startGroup);
7776
- }
7777
- }
7778
- /** Builds (once per query) the `id` to {@link Path} index backing `findID`/`getPathOfID`. */
7779
- function _index() {
7780
- _assertClassBrand(_QueryManager_brand, this, _ensureCache).call(this);
7781
- if (!_classPrivateFieldGet2(_idPathIndex, this)) {
7782
- const index = /* @__PURE__ */ new Map();
7783
- 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);
7784
- _classPrivateFieldSet2(_idPathIndex, this, index);
7785
- }
7786
- return _classPrivateFieldGet2(_idPathIndex, this);
7787
- }
7788
- /** Resolves a path or `id` to a path, or `null` when the `id` isn't present. */
7789
- function _toPath(pathOrID) {
7790
- var _this$index$get;
7791
- 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;
7792
- }
7793
- /**
7794
- * Brings the history stacks in line with the current history configuration. Unlike
7795
- * {@link QueryManager.clearHistory}, this does _not_ set `#historyBypassed`: it reflects a
7796
- * configuration change rather than a deliberate history repositioning, so a later mutation in
7797
- * the same batch must still be recorded normally.
7798
- *
7799
- * Called by {@link QueryManager.reconfigure} and again after a failed
7800
- * {@link QueryManager.batch batch} restores its snapshot, since that snapshot predates the
7801
- * configuration change (configuration is not part of a batch's rollback).
7802
- */
7803
- function _reconcileHistoryConfig() {
7804
- if (_classPrivateFieldGet2(_historyEnabled, this)) {
7805
- if (_classPrivateFieldGet2(_past, this).length > _classPrivateFieldGet2(_maxHistory, this)) _classPrivateFieldGet2(_past, this).splice(0, _classPrivateFieldGet2(_past, this).length - _classPrivateFieldGet2(_maxHistory, this));
7806
- } else {
7807
- _classPrivateFieldSet2(_past, this, []);
7808
- _classPrivateFieldSet2(_future, this, []);
7809
- _classPrivateFieldSet2(_lastSig, this, void 0);
8619
+ return transformQuery(this.state.query, options);
7810
8620
  }
7811
- }
8621
+ };
7812
8622
  //#endregion
7813
- 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, deriveQueryBuilderClassNames, 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 };
8623
+ export { LogType, QueryManager, QueryManagerError, TestID, add, addInPlace, betweenOperators, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, coerceBigIntValue, coerceInputType, controlKeys, controlKind, controlPropKeys, 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, deriveQueryBuilderClassNames, 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, optionsEqual, 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, setAutoFreeze, shouldCoalesce, 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, valuesEqual, withParamPrefix, wrapLikeFragment };
7814
8624
 
7815
8625
  //# sourceMappingURL=react-querybuilder_core.legacy-esm.js.map