@uipath/apollo-wind 2.93.0 → 2.94.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 (132) hide show
  1. package/dist/components/forms/field-renderer.cjs +1 -1
  2. package/dist/components/forms/field-renderer.js +1 -1
  3. package/dist/components/forms/field-rules-strings.cjs +40 -0
  4. package/dist/components/forms/field-rules-strings.d.ts +17 -0
  5. package/dist/components/forms/field-rules-strings.js +6 -0
  6. package/dist/components/forms/field-rules.cjs +526 -0
  7. package/dist/components/forms/field-rules.d.ts +97 -0
  8. package/dist/components/forms/field-rules.js +468 -0
  9. package/dist/components/forms/form-designer.cjs +208 -592
  10. package/dist/components/forms/form-designer.js +210 -594
  11. package/dist/components/forms/form-schema.d.ts +5 -0
  12. package/dist/components/forms/index.cjs +43 -3
  13. package/dist/components/forms/index.d.ts +4 -0
  14. package/dist/components/forms/index.js +5 -1
  15. package/dist/components/forms/metadata-form.cjs +1 -1
  16. package/dist/components/forms/metadata-form.js +1 -1
  17. package/dist/components/forms/rules-engine-dialect.cjs +644 -0
  18. package/dist/components/forms/rules-engine-dialect.d.ts +90 -0
  19. package/dist/components/forms/rules-engine-dialect.js +537 -0
  20. package/dist/components/forms/rules-engine.cjs +99 -10
  21. package/dist/components/forms/rules-engine.d.ts +5 -0
  22. package/dist/components/forms/rules-engine.js +99 -10
  23. package/dist/components/forms/use-field-rules.cjs +122 -0
  24. package/dist/components/forms/use-field-rules.d.ts +31 -0
  25. package/dist/components/forms/use-field-rules.js +88 -0
  26. package/dist/components/ui/command.cjs +1 -1
  27. package/dist/components/ui/command.js +1 -1
  28. package/dist/components/ui/conditions-editor/condition-row.cjs +458 -0
  29. package/dist/components/ui/conditions-editor/condition-row.d.ts +23 -0
  30. package/dist/components/ui/conditions-editor/condition-row.js +421 -0
  31. package/dist/components/ui/conditions-editor/conditions-editor.cjs +363 -0
  32. package/dist/components/ui/conditions-editor/conditions-editor.d.ts +67 -0
  33. package/dist/components/ui/conditions-editor/conditions-editor.js +329 -0
  34. package/dist/components/ui/conditions-editor/context.cjs +45 -0
  35. package/dist/components/ui/conditions-editor/context.d.ts +54 -0
  36. package/dist/components/ui/conditions-editor/context.js +8 -0
  37. package/dist/components/ui/conditions-editor/index.cjs +55 -0
  38. package/dist/components/ui/conditions-editor/index.d.ts +6 -0
  39. package/dist/components/ui/conditions-editor/index.js +6 -0
  40. package/dist/components/ui/conditions-editor/model.cjs +126 -0
  41. package/dist/components/ui/conditions-editor/model.d.ts +39 -0
  42. package/dist/components/ui/conditions-editor/model.js +71 -0
  43. package/dist/components/ui/conditions-editor/status.cjs +198 -0
  44. package/dist/components/ui/conditions-editor/status.d.ts +44 -0
  45. package/dist/components/ui/conditions-editor/status.js +131 -0
  46. package/dist/components/ui/conditions-editor/strings.cjs +86 -0
  47. package/dist/components/ui/conditions-editor/strings.d.ts +62 -0
  48. package/dist/components/ui/conditions-editor/strings.js +52 -0
  49. package/dist/components/ui/conditions-editor/vocabulary.cjs +163 -0
  50. package/dist/components/ui/conditions-editor/vocabulary.d.ts +51 -0
  51. package/dist/components/ui/conditions-editor/vocabulary.js +129 -0
  52. package/dist/components/ui/context-menu.cjs +1 -1
  53. package/dist/components/ui/context-menu.js +1 -1
  54. package/dist/components/ui/dropdown-menu.cjs +1 -1
  55. package/dist/components/ui/dropdown-menu.js +1 -1
  56. package/dist/components/ui/field-actions/index.cjs +9 -2
  57. package/dist/components/ui/field-actions/index.d.ts +1 -0
  58. package/dist/components/ui/field-actions/index.js +2 -1
  59. package/dist/components/ui/field-actions/insert-variable-action.cjs +3 -1
  60. package/dist/components/ui/field-actions/insert-variable-action.d.ts +4 -1
  61. package/dist/components/ui/field-actions/insert-variable-action.js +3 -1
  62. package/dist/components/ui/field-actions/rules-action.cjs +244 -0
  63. package/dist/components/ui/field-actions/rules-action.d.ts +42 -0
  64. package/dist/components/ui/field-actions/rules-action.js +207 -0
  65. package/dist/components/ui/index.cjs +285 -246
  66. package/dist/components/ui/index.d.ts +3 -0
  67. package/dist/components/ui/index.js +3 -0
  68. package/dist/components/ui/quick-form-field/components/field-header.cjs +137 -167
  69. package/dist/components/ui/quick-form-field/components/field-header.d.ts +1 -1
  70. package/dist/components/ui/quick-form-field/components/field-header.js +138 -168
  71. package/dist/components/ui/quick-form-field/components/header-actions.cjs +187 -0
  72. package/dist/components/ui/quick-form-field/components/header-actions.d.ts +59 -0
  73. package/dist/components/ui/quick-form-field/components/header-actions.js +138 -0
  74. package/dist/components/ui/quick-form-field/components/header-context.cjs +59 -0
  75. package/dist/components/ui/quick-form-field/components/header-context.d.ts +33 -0
  76. package/dist/components/ui/quick-form-field/components/header-context.js +16 -0
  77. package/dist/components/ui/quick-form-field/index.cjs +18 -4
  78. package/dist/components/ui/quick-form-field/index.d.ts +2 -0
  79. package/dist/components/ui/quick-form-field/index.js +3 -1
  80. package/dist/components/ui/quick-form-field/quick-form-field.cjs +1 -1
  81. package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -6
  82. package/dist/components/ui/quick-form-field/quick-form-field.js +1 -1
  83. package/dist/components/ui/quick-form-field/types.d.ts +42 -11
  84. package/dist/components/ui/row-groups/add-row-button.cjs +54 -0
  85. package/dist/components/ui/row-groups/add-row-button.d.ts +10 -0
  86. package/dist/components/ui/row-groups/add-row-button.js +20 -0
  87. package/dist/components/ui/row-groups/after-press.cjs +73 -0
  88. package/dist/components/ui/row-groups/after-press.d.ts +7 -0
  89. package/dist/components/ui/row-groups/after-press.js +36 -0
  90. package/dist/components/ui/row-groups/collapsible-row-group.cjs +83 -0
  91. package/dist/components/ui/row-groups/collapsible-row-group.d.ts +13 -0
  92. package/dist/components/ui/row-groups/collapsible-row-group.js +49 -0
  93. package/dist/components/ui/row-groups/empty-rows.cjs +42 -0
  94. package/dist/components/ui/row-groups/empty-rows.d.ts +7 -0
  95. package/dist/components/ui/row-groups/empty-rows.js +8 -0
  96. package/dist/components/ui/row-groups/group-mode-toggle.cjs +80 -0
  97. package/dist/components/ui/row-groups/group-mode-toggle.d.ts +26 -0
  98. package/dist/components/ui/row-groups/group-mode-toggle.js +40 -0
  99. package/dist/components/ui/row-groups/index.cjs +62 -0
  100. package/dist/components/ui/row-groups/index.d.ts +6 -0
  101. package/dist/components/ui/row-groups/index.js +7 -0
  102. package/dist/components/ui/row-groups/row-delete-button.cjs +54 -0
  103. package/dist/components/ui/row-groups/row-delete-button.d.ts +18 -0
  104. package/dist/components/ui/row-groups/row-delete-button.js +20 -0
  105. package/dist/components/ui/row-groups/use-row-focus.cjs +82 -0
  106. package/dist/components/ui/row-groups/use-row-focus.d.ts +17 -0
  107. package/dist/components/ui/row-groups/use-row-focus.js +48 -0
  108. package/dist/components/ui/rules-editor/context.cjs +45 -0
  109. package/dist/components/ui/rules-editor/context.d.ts +52 -0
  110. package/dist/components/ui/rules-editor/context.js +8 -0
  111. package/dist/components/ui/rules-editor/index.cjs +56 -0
  112. package/dist/components/ui/rules-editor/index.d.ts +4 -0
  113. package/dist/components/ui/rules-editor/index.js +4 -0
  114. package/dist/components/ui/rules-editor/model.cjs +205 -0
  115. package/dist/components/ui/rules-editor/model.d.ts +128 -0
  116. package/dist/components/ui/rules-editor/model.js +144 -0
  117. package/dist/components/ui/rules-editor/rule-card.cjs +470 -0
  118. package/dist/components/ui/rules-editor/rule-card.d.ts +14 -0
  119. package/dist/components/ui/rules-editor/rule-card.js +436 -0
  120. package/dist/components/ui/rules-editor/rules-editor.cjs +160 -0
  121. package/dist/components/ui/rules-editor/rules-editor.d.ts +66 -0
  122. package/dist/components/ui/rules-editor/rules-editor.js +126 -0
  123. package/dist/components/ui/rules-editor/strings.cjs +68 -0
  124. package/dist/components/ui/rules-editor/strings.d.ts +56 -0
  125. package/dist/components/ui/rules-editor/strings.js +34 -0
  126. package/dist/components/ui/select.cjs +1 -1
  127. package/dist/components/ui/select.js +1 -1
  128. package/dist/index.cjs +129 -8
  129. package/dist/index.d.ts +17 -4
  130. package/dist/index.js +10 -3
  131. package/dist/styles.css +97 -24
  132. package/package.json +2 -2
@@ -75,7 +75,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
75
75
  const fields = new Set();
76
76
  field.rules.forEach((rule)=>{
77
77
  rule.conditions?.forEach((condition)=>{
78
- if ('when' in condition && condition.when) fields.add(condition.when);
78
+ for (const name of external_rules_engine_cjs_namespaceObject.RulesEngine.conditionFields(condition))fields.add(name);
79
79
  });
80
80
  });
81
81
  return Array.from(fields);
@@ -47,7 +47,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
47
47
  const fields = new Set();
48
48
  field.rules.forEach((rule)=>{
49
49
  rule.conditions?.forEach((condition)=>{
50
- if ('when' in condition && condition.when) fields.add(condition.when);
50
+ for (const name of RulesEngine.conditionFields(condition))fields.add(name);
51
51
  });
52
52
  });
53
53
  return Array.from(fields);
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ DEFAULT_FIELD_RULES_STRINGS: ()=>DEFAULT_FIELD_RULES_STRINGS
28
+ });
29
+ const DEFAULT_FIELD_RULES_STRINGS = {
30
+ errorUnnamedField: "Expressions can't name this field, so this comparison can't run.",
31
+ repairComparedWithText: (field, value, expected)=>`${field} is compared with the text "${value}", not ${'boolean' === expected ? 'yes or no' : 'a number'}`,
32
+ repairEmptyCondition: 'an empty condition, shown as false, keeps it from ever applying'
33
+ };
34
+ exports.DEFAULT_FIELD_RULES_STRINGS = __webpack_exports__.DEFAULT_FIELD_RULES_STRINGS;
35
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
36
+ "DEFAULT_FIELD_RULES_STRINGS"
37
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
38
+ Object.defineProperty(exports, '__esModule', {
39
+ value: true
40
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copy the RulesEngine adapter writes: why a row cannot be stored, and why a stored rule needs
3
+ * repair. Pass a partial set as `strings` to `createRulesEngineVocabulary` and in
4
+ * `FieldRulesOptions` to translate it.
5
+ */
6
+ export interface FieldRulesStrings {
7
+ /** On a comparison only an expression can store, on a field key no expression can name. */
8
+ errorUnnamedField: string;
9
+ /**
10
+ * Repair reasons follow RulesEditor's "This rule cannot be evaluated: ". This one is for a fixed
11
+ * value stored as text on a field that holds a number or a yes/no.
12
+ */
13
+ repairComparedWithText: (field: string, value: string, expected: 'number' | 'boolean') => string;
14
+ /** A placeholder row, shown as `false`, in a rule that needs every condition. */
15
+ repairEmptyCondition: string;
16
+ }
17
+ export declare const DEFAULT_FIELD_RULES_STRINGS: FieldRulesStrings;
@@ -0,0 +1,6 @@
1
+ const DEFAULT_FIELD_RULES_STRINGS = {
2
+ errorUnnamedField: "Expressions can't name this field, so this comparison can't run.",
3
+ repairComparedWithText: (field, value, expected)=>`${field} is compared with the text "${value}", not ${'boolean' === expected ? 'yes or no' : 'a number'}`,
4
+ repairEmptyCondition: 'an empty condition, shown as false, keeps it from ever applying'
5
+ };
6
+ export { DEFAULT_FIELD_RULES_STRINGS };
@@ -0,0 +1,526 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ renameFieldInRules: ()=>renameFieldInRules,
28
+ flagOutcome: ()=>flagOutcome,
29
+ writeStoredRules: ()=>writeStoredRules,
30
+ toFieldRules: ()=>toFieldRules,
31
+ alwaysApplying: ()=>alwaysApplying,
32
+ settleAlways: ()=>settleAlways,
33
+ fromFieldRules: ()=>fromFieldRules,
34
+ readStoredRules: ()=>readStoredRules,
35
+ rulesReferencing: ()=>rulesReferencing
36
+ });
37
+ const index_cjs_namespaceObject = require("../ui/conditions-editor/index.cjs");
38
+ const status_cjs_namespaceObject = require("../ui/conditions-editor/status.cjs");
39
+ const rules_editor_index_cjs_namespaceObject = require("../ui/rules-editor/index.cjs");
40
+ const external_field_rules_strings_cjs_namespaceObject = require("./field-rules-strings.cjs");
41
+ const external_rules_engine_dialect_cjs_namespaceObject = require("./rules-engine-dialect.cjs");
42
+ const originals = new WeakMap();
43
+ const unknownFieldConditions = new WeakMap();
44
+ function vocabularyOf(options) {
45
+ return {
46
+ fields: options.fields,
47
+ operators: options.operators ?? defaultOperators(options.strings),
48
+ valueModes: external_rules_engine_dialect_cjs_namespaceObject.rulesEngineVocabulary.valueModes
49
+ };
50
+ }
51
+ const SPECIAL = /[.*+?^${}()|[\]\\]/g;
52
+ const escapePattern = (text)=>text.replace(SPECIAL, '\\$&');
53
+ const unescapePattern = (text)=>text.replace(/\\([.*+?^${}()|[\]\\])/g, '$1');
54
+ function literalText(pattern) {
55
+ const text = unescapePattern(pattern);
56
+ return escapePattern(text) === pattern ? text : void 0;
57
+ }
58
+ function definedKeys(condition) {
59
+ return Object.keys(condition).filter((key)=>'when' !== key && void 0 !== condition[key]);
60
+ }
61
+ function readCondition(stored, vocabulary, id) {
62
+ const keys = definedKeys(stored);
63
+ if (0 === keys.length) return (0, index_cjs_namespaceObject.createCondition)({
64
+ id,
65
+ field: stored.when || void 0
66
+ });
67
+ if (void 0 !== stored.custom) {
68
+ const node = (0, external_rules_engine_dialect_cjs_namespaceObject.parseExpression)(stored.custom);
69
+ return node && (0, external_rules_engine_dialect_cjs_namespaceObject.canRun)(stored.custom, vocabulary.fields) ? (0, external_rules_engine_dialect_cjs_namespaceObject.parseCondition)(node, vocabulary, id) : void 0;
70
+ }
71
+ if (keys.length > 1) return;
72
+ const field = stored.when;
73
+ let row;
74
+ if (void 0 !== stored.is) row = '' === stored.is ? {
75
+ field,
76
+ operator: 'isEmpty'
77
+ } : {
78
+ field,
79
+ operator: 'equals',
80
+ value: (0, external_rules_engine_dialect_cjs_namespaceObject.valueText)(stored.is)
81
+ };
82
+ else if (void 0 !== stored.isNot) row = '' === stored.isNot ? {
83
+ field,
84
+ operator: 'isNotEmpty'
85
+ } : {
86
+ field,
87
+ operator: 'notEquals',
88
+ value: (0, external_rules_engine_dialect_cjs_namespaceObject.valueText)(stored.isNot)
89
+ };
90
+ else if (void 0 !== stored.in) row = {
91
+ field,
92
+ operator: 'isOneOf',
93
+ values: stored.in.map(external_rules_engine_dialect_cjs_namespaceObject.valueText)
94
+ };
95
+ else if (void 0 !== stored.notIn) row = {
96
+ field,
97
+ operator: 'isNotOneOf',
98
+ values: stored.notIn.map(external_rules_engine_dialect_cjs_namespaceObject.valueText)
99
+ };
100
+ else if (void 0 !== stored.empty) row = {
101
+ field,
102
+ operator: stored.empty ? 'isEmpty' : 'isNotEmpty'
103
+ };
104
+ else {
105
+ const pattern = stored.matches ?? '';
106
+ const text = literalText(pattern);
107
+ const start = pattern.startsWith('^') ? literalText(pattern.slice(1)) : void 0;
108
+ row = void 0 !== text ? {
109
+ field,
110
+ operator: 'contains',
111
+ value: text
112
+ } : void 0 !== start ? {
113
+ field,
114
+ operator: 'startsWith',
115
+ value: start
116
+ } : {
117
+ field,
118
+ operator: 'matches',
119
+ value: pattern
120
+ };
121
+ }
122
+ const condition = (0, index_cjs_namespaceObject.createCondition)({
123
+ id,
124
+ ...row
125
+ });
126
+ if (!(0, external_rules_engine_dialect_cjs_namespaceObject.offered)(condition, vocabulary)) return;
127
+ const known = vocabulary.fields.some((option)=>option.value === field);
128
+ return !known || (0, status_cjs_namespaceObject.isComplete)(condition, vocabulary) ? condition : void 0;
129
+ }
130
+ function readStoredCondition(stored, vocabulary, id) {
131
+ const condition = readCondition(stored, vocabulary, id);
132
+ const field = condition?.field;
133
+ if (condition && field && !vocabulary.fields.some((option)=>option.value === field)) unknownFieldConditions.set(condition, stored);
134
+ return condition;
135
+ }
136
+ function storedExpression(stored) {
137
+ if (0 === definedKeys(stored).length) return null;
138
+ if (void 0 !== stored.custom) return stored.custom;
139
+ if (!(0, external_rules_engine_dialect_cjs_namespaceObject.canName)(stored.when)) return;
140
+ const name = stored.when;
141
+ const list = (values, symbol, joiner, none)=>0 === values.length ? none : values.map((value)=>`${name} ${symbol} ${(0, external_rules_engine_dialect_cjs_namespaceObject.printLiteral)(value)}`).join(joiner);
142
+ if (void 0 !== stored.is) return `${name} === ${(0, external_rules_engine_dialect_cjs_namespaceObject.printLiteral)(stored.is)}`;
143
+ if (void 0 !== stored.isNot) return `${name} !== ${(0, external_rules_engine_dialect_cjs_namespaceObject.printLiteral)(stored.isNot)}`;
144
+ if (void 0 !== stored.in) return list(stored.in, '===', ' || ', 'false');
145
+ if (void 0 !== stored.notIn) return list(stored.notIn, '!==', ' && ', 'true');
146
+ }
147
+ function repairReason(stored, row, fields, strings) {
148
+ const field = fields.find((option)=>option.value === row.field);
149
+ if (!field) return;
150
+ const values = [
151
+ stored.is,
152
+ stored.isNot,
153
+ ...stored.in ?? [],
154
+ ...stored.notIn ?? []
155
+ ];
156
+ const mistyped = values.find((value)=>void 0 !== value && '' !== value && (0, external_rules_engine_dialect_cjs_namespaceObject.typedValue)(field, (0, external_rules_engine_dialect_cjs_namespaceObject.valueText)(value)) !== value);
157
+ if (void 0 === mistyped) return;
158
+ const expected = 'boolean' == typeof (0, external_rules_engine_dialect_cjs_namespaceObject.typedValue)(field, (0, external_rules_engine_dialect_cjs_namespaceObject.valueText)(mistyped)) ? 'boolean' : 'number';
159
+ return strings.repairComparedWithText(field.label, (0, external_rules_engine_dialect_cjs_namespaceObject.valueText)(mistyped), expected);
160
+ }
161
+ function defaultOperators(strings) {
162
+ return strings ? (0, external_rules_engine_dialect_cjs_namespaceObject.createRulesEngineVocabulary)({
163
+ strings
164
+ }).operators : external_rules_engine_dialect_cjs_namespaceObject.RULES_ENGINE_OPERATORS;
165
+ }
166
+ function storedRuleExpression(stored, placeholder) {
167
+ const texts = stored.conditions.map(storedExpression);
168
+ if (texts.includes(void 0)) return;
169
+ const parts = texts.flatMap((text)=>null != text ? [
170
+ text
171
+ ] : void 0 === placeholder ? [] : [
172
+ placeholder
173
+ ]);
174
+ const joiner = 'OR' === stored.operator ? ' || ' : ' && ';
175
+ return 1 === parts.length ? parts[0] : parts.map((part)=>`(${part})`).join(joiner);
176
+ }
177
+ function storedFieldKeys(stored) {
178
+ const keys = stored.conditions.flatMap((condition)=>[
179
+ ...condition.when ? [
180
+ condition.when
181
+ ] : [],
182
+ ...void 0 === condition.custom ? [] : (0, external_rules_engine_dialect_cjs_namespaceObject.fieldKeysOf)(condition.custom)
183
+ ]);
184
+ return Array.from(new Set(keys));
185
+ }
186
+ function matchOutcome(effects, outcomes) {
187
+ let best;
188
+ let claims = -1;
189
+ for (const outcome of outcomes){
190
+ const entries = Object.entries(outcome.effects);
191
+ const matches = entries.every(([key, value])=>effects[key] === value);
192
+ if (matches && entries.length > claims) {
193
+ best = outcome;
194
+ claims = entries.length;
195
+ }
196
+ }
197
+ return best;
198
+ }
199
+ function readRule(stored, index, options) {
200
+ const strings = {
201
+ ...external_field_rules_strings_cjs_namespaceObject.DEFAULT_FIELD_RULES_STRINGS,
202
+ ...options.strings
203
+ };
204
+ const vocabulary = vocabularyOf(options);
205
+ const id = stored.id || `rule-${index}`;
206
+ const effects = stored.effects ?? {};
207
+ const outcome = matchOutcome(effects, options.outcomes);
208
+ const claimed = Object.keys(outcome?.effects ?? {});
209
+ const otherEffects = Object.fromEntries(Object.entries(effects).filter(([key])=>!claimed.includes(key)));
210
+ const base = {
211
+ id,
212
+ outcome: outcome?.value ?? '',
213
+ ...Object.keys(otherEffects).length > 0 ? {
214
+ otherEffects
215
+ } : {}
216
+ };
217
+ const preserved = ()=>({
218
+ ...base,
219
+ mode: 'preserved',
220
+ preservedSource: JSON.stringify({
221
+ operator: stored.operator ?? 'AND',
222
+ conditions: stored.conditions
223
+ }, null, 2),
224
+ fieldKeys: storedFieldKeys(stored),
225
+ saved: {
226
+ conditions: stored.conditions,
227
+ operator: stored.operator
228
+ }
229
+ });
230
+ const readRows = (conditions)=>conditions.map((condition, position)=>readStoredCondition(condition, vocabulary, `${id}-condition-${position}`));
231
+ const allRows = (found)=>found.every((row)=>void 0 !== row);
232
+ const upgrades = stored.conditions.map((condition)=>options.upgradeCondition?.(condition));
233
+ const rewritten = stored.conditions.map((condition, i)=>upgrades[i]?.condition ?? condition);
234
+ const upgradedRows = upgrades.some(Boolean) ? readRows(rewritten) : void 0;
235
+ const upgraded = upgradedRows && allRows(upgradedRows) ? upgradedRows : void 0;
236
+ const conditions = upgraded ? rewritten : stored.conditions;
237
+ const rows = upgraded ?? readRows(stored.conditions);
238
+ let rule;
239
+ if (allRows(rows)) {
240
+ rule = {
241
+ ...base,
242
+ mode: 'conditions',
243
+ conditions: (0, index_cjs_namespaceObject.createConditionGroup)('OR' === stored.operator ? 'any' : 'all', rows, `${id}-conditions`)
244
+ };
245
+ const placeholders = stored.conditions.filter((c)=>0 === definedKeys(c).length).length;
246
+ const blocked = 'OR' !== stored.operator && placeholders > 0 && placeholders < stored.conditions.length;
247
+ const reason = upgraded ? upgrades.find((upgrade)=>void 0 !== upgrade)?.reason : blocked ? strings.repairEmptyCondition : conditions.map((condition, position)=>definedKeys(condition).length > 0 ? repairReason(condition, rows[position], options.fields, strings) : void 0).find((found)=>void 0 !== found);
248
+ if (reason) {
249
+ const expression = storedRuleExpression(stored, 'false');
250
+ const shown = void 0 === expression ? preserved() : {
251
+ ...base,
252
+ mode: 'expression',
253
+ expression,
254
+ saved: {
255
+ expression,
256
+ conditions: stored.conditions,
257
+ operator: stored.operator
258
+ }
259
+ };
260
+ rule = (0, external_rules_engine_dialect_cjs_namespaceObject.markRepairNeeded)(shown, rule.conditions, reason);
261
+ }
262
+ } else {
263
+ const expression = storedRuleExpression(stored);
264
+ const saved = {
265
+ conditions: stored.conditions,
266
+ operator: stored.operator
267
+ };
268
+ rule = void 0 === expression ? preserved() : {
269
+ ...base,
270
+ mode: 'expression',
271
+ expression,
272
+ saved: {
273
+ ...saved,
274
+ expression
275
+ }
276
+ };
277
+ }
278
+ originals.set(rule, stored);
279
+ return rule;
280
+ }
281
+ function fromFieldRules(rules, options) {
282
+ return rules.map((rule, index)=>readRule(rule, index, options));
283
+ }
284
+ function writeCondition(c, vocabulary) {
285
+ const stored = unknownFieldConditions.get(c);
286
+ if (stored) return stored;
287
+ if (!(0, status_cjs_namespaceObject.isComplete)(c, vocabulary)) return;
288
+ const resolved = (0, status_cjs_namespaceObject.resolveCondition)(c, vocabulary);
289
+ const when = c.field ?? '';
290
+ const id = resolved.operator?.value;
291
+ const typed = (text)=>(0, external_rules_engine_dialect_cjs_namespaceObject.typedValue)(resolved.field, text);
292
+ if ('isEmpty' === id || 'isNotEmpty' === id) {
293
+ const empty = 'isEmpty' === id;
294
+ if (resolved.field?.type === 'other') return {
295
+ when,
296
+ empty
297
+ };
298
+ if (!(0, external_rules_engine_dialect_cjs_namespaceObject.canName)(when)) return empty ? {
299
+ when,
300
+ is: ''
301
+ } : {
302
+ when,
303
+ isNot: ''
304
+ };
305
+ return {
306
+ when,
307
+ custom: empty ? (0, external_rules_engine_dialect_cjs_namespaceObject.emptyCheck)(when) : (0, external_rules_engine_dialect_cjs_namespaceObject.notEmptyCheck)(when)
308
+ };
309
+ }
310
+ if ('literal' === resolved.mode) {
311
+ const value = c.value ?? '';
312
+ switch(id){
313
+ case 'equals':
314
+ return {
315
+ when,
316
+ is: typed(value)
317
+ };
318
+ case 'notEquals':
319
+ return {
320
+ when,
321
+ isNot: typed(value)
322
+ };
323
+ case 'isOneOf':
324
+ return {
325
+ when,
326
+ in: (c.values ?? []).map(typed)
327
+ };
328
+ case 'isNotOneOf':
329
+ return {
330
+ when,
331
+ notIn: (c.values ?? []).map(typed)
332
+ };
333
+ case 'contains':
334
+ return {
335
+ when,
336
+ matches: escapePattern(value)
337
+ };
338
+ case 'startsWith':
339
+ return {
340
+ when,
341
+ matches: `^${escapePattern(value)}`
342
+ };
343
+ case 'matches':
344
+ return {
345
+ when,
346
+ matches: value
347
+ };
348
+ }
349
+ }
350
+ const text = (0, external_rules_engine_dialect_cjs_namespaceObject.conditionExpression)(c, vocabulary);
351
+ return void 0 === text ? void 0 : {
352
+ when,
353
+ custom: text
354
+ };
355
+ }
356
+ function writeGroup(group, vocabulary) {
357
+ const written = [];
358
+ for (const child of group.children){
359
+ const condition = 'condition' === child.kind ? writeCondition(child, vocabulary) : void 0;
360
+ if (condition) written.push(condition);
361
+ }
362
+ return written;
363
+ }
364
+ function writeRule(rule, options) {
365
+ const original = originals.get(rule);
366
+ if (original) return original;
367
+ const stored = rule;
368
+ const vocabulary = vocabularyOf(options);
369
+ const outcome = options.outcomes.find((option)=>option.value === rule.outcome);
370
+ const effects = {
371
+ ...stored.otherEffects,
372
+ ...outcome?.effects
373
+ };
374
+ const { saved } = stored;
375
+ if ('preserved' === rule.mode) return saved && {
376
+ id: rule.id,
377
+ conditions: saved.conditions,
378
+ operator: saved.operator,
379
+ effects
380
+ };
381
+ if ('expression' === rule.mode) {
382
+ if (saved && rule.expression === saved.expression) return {
383
+ id: rule.id,
384
+ conditions: saved.conditions,
385
+ operator: saved.operator,
386
+ effects
387
+ };
388
+ const expression = rule.expression.trim();
389
+ if (!expression) return;
390
+ const when = (0, external_rules_engine_dialect_cjs_namespaceObject.fieldKeysOf)(expression)[0] ?? '';
391
+ return {
392
+ id: rule.id,
393
+ conditions: [
394
+ {
395
+ when,
396
+ custom: expression
397
+ }
398
+ ],
399
+ operator: 'AND',
400
+ effects
401
+ };
402
+ }
403
+ const written = writeGroup(rule.conditions, vocabulary);
404
+ if (rule.conditions.children.length > 0 && 0 === written.length) return;
405
+ return {
406
+ id: rule.id,
407
+ conditions: written,
408
+ operator: 'any' === rule.conditions.mode ? 'OR' : 'AND',
409
+ effects
410
+ };
411
+ }
412
+ function toFieldRules(rules, options) {
413
+ return rules.flatMap((rule)=>writeRule(rule, options) ?? []);
414
+ }
415
+ const REQUIRED_RULE_ID = 'required-flag';
416
+ function readStoredRules(stored, options) {
417
+ const rules = fromFieldRules(stored.rules ?? [], options);
418
+ const outcome = flagOutcome(options);
419
+ if (!outcome || !stored.required || rules.some((rule)=>isRequiredRule(rule, outcome))) return rules;
420
+ const conditions = (0, index_cjs_namespaceObject.createConditionGroup)('all', [], `${REQUIRED_RULE_ID}-conditions`);
421
+ return [
422
+ (0, rules_editor_index_cjs_namespaceObject.createRule)({
423
+ id: REQUIRED_RULE_ID,
424
+ outcome,
425
+ conditions
426
+ }),
427
+ ...rules
428
+ ];
429
+ }
430
+ function writeStoredRules(rules, options) {
431
+ const outcome = flagOutcome(options);
432
+ const index = outcome ? rules.findIndex((rule)=>isRequiredRule(rule, outcome)) : -1;
433
+ const overrides = rules.slice(0, Math.max(index, 0)).some((rule)=>(effectsOf(rule, options).required ?? true) !== true);
434
+ if (index < 0 || rules[index].otherEffects || overrides) return {
435
+ rules: toFieldRules(rules, options),
436
+ required: false
437
+ };
438
+ return {
439
+ rules: toFieldRules(rules.filter((_, position)=>position !== index), options),
440
+ required: true
441
+ };
442
+ }
443
+ function isRequiredRule(rule, outcome) {
444
+ return rule.outcome === outcome && (0, rules_editor_index_cjs_namespaceObject.isUnconditionalRule)(rule);
445
+ }
446
+ function flagOutcome(options) {
447
+ const value = options.requiredOutcome;
448
+ const effects = options.outcomes.find((option)=>option.value === value)?.effects ?? {};
449
+ const keys = Object.keys(effects);
450
+ return 1 === keys.length && true === effects.required ? value : void 0;
451
+ }
452
+ function effectsOf(rule, options) {
453
+ const outcome = options.outcomes.find((option)=>option.value === rule.outcome);
454
+ return {
455
+ ...rule.otherEffects,
456
+ ...outcome?.effects
457
+ };
458
+ }
459
+ function alwaysApplying(rules) {
460
+ return new Set(rules.filter(rules_editor_index_cjs_namespaceObject.isUnconditionalRule).map((rule)=>rule.id));
461
+ }
462
+ function settleAlways(rules, options, always) {
463
+ const vocabulary = vocabularyOf(options);
464
+ return rules.map((rule)=>'conditions' === rule.mode && rule.conditions.children.length > 0 && always.has(rule.id) && 0 === writeGroup(rule.conditions, vocabulary).length ? {
465
+ ...rule,
466
+ conditions: {
467
+ ...rule.conditions,
468
+ children: []
469
+ }
470
+ } : rule);
471
+ }
472
+ const namesField = (name, key)=>name === key || name.startsWith(`${key}.`);
473
+ function renameFieldInRules(rules, from, to) {
474
+ if (from === to || !from || !to) return [
475
+ ...rules
476
+ ];
477
+ return rules.map((rule)=>{
478
+ let changed = false;
479
+ const conditions = rule.conditions.map((condition)=>{
480
+ const when = namesField(condition.when, from) ? `${to}${condition.when.slice(from.length)}` : condition.when;
481
+ const custom = void 0 === condition.custom ? void 0 : (0, external_rules_engine_dialect_cjs_namespaceObject.renameInExpression)(condition.custom, from, to);
482
+ if (when === condition.when && custom === condition.custom) return condition;
483
+ changed = true;
484
+ return {
485
+ ...condition,
486
+ when,
487
+ ...void 0 === custom ? {} : {
488
+ custom
489
+ }
490
+ };
491
+ });
492
+ return changed ? {
493
+ ...rule,
494
+ conditions
495
+ } : rule;
496
+ });
497
+ }
498
+ function rulesReferencing(rules, key) {
499
+ if (!key) return [];
500
+ return rules.flatMap((rule, index)=>rule.conditions.some((condition)=>namesField(condition.when, key) || void 0 !== condition.custom && (0, external_rules_engine_dialect_cjs_namespaceObject.fieldKeysOf)(condition.custom).some((name)=>namesField(name, key))) ? [
501
+ rule.id || `rule-${index}`
502
+ ] : []);
503
+ }
504
+ exports.alwaysApplying = __webpack_exports__.alwaysApplying;
505
+ exports.flagOutcome = __webpack_exports__.flagOutcome;
506
+ exports.fromFieldRules = __webpack_exports__.fromFieldRules;
507
+ exports.readStoredRules = __webpack_exports__.readStoredRules;
508
+ exports.renameFieldInRules = __webpack_exports__.renameFieldInRules;
509
+ exports.rulesReferencing = __webpack_exports__.rulesReferencing;
510
+ exports.settleAlways = __webpack_exports__.settleAlways;
511
+ exports.toFieldRules = __webpack_exports__.toFieldRules;
512
+ exports.writeStoredRules = __webpack_exports__.writeStoredRules;
513
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
514
+ "alwaysApplying",
515
+ "flagOutcome",
516
+ "fromFieldRules",
517
+ "readStoredRules",
518
+ "renameFieldInRules",
519
+ "rulesReferencing",
520
+ "settleAlways",
521
+ "toFieldRules",
522
+ "writeStoredRules"
523
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
524
+ Object.defineProperty(exports, '__esModule', {
525
+ value: true
526
+ });