@bigbinary/neeto-rules-frontend 2.6.2 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -171,7 +171,8 @@ var BUILDER_PANEL_TYPES = {
171
171
  DELAY: "builder-delay",
172
172
  LEAD_TIME: "builder-lead-time",
173
173
  NAME: "builder-name",
174
- SCOPE: "builder-scope"
174
+ SCOPE: "builder-scope",
175
+ SCOPE_PHONE_FIELD: "builder-scope-phone-field"
175
176
  };
176
177
  var BUILDER_ANCHORS = {
177
178
  TRIGGER_ADD: "trigger-add",
@@ -188,9 +189,10 @@ var BUILDER_ANCHORS = {
188
189
  ACTION_RECIPIENT: "action-recipient",
189
190
  RULE_DELAY: "rule-delay",
190
191
  META_NAME: "meta-name",
191
- SCOPE: "scope"
192
+ SCOPE: "scope",
193
+ SCOPE_PHONE_FIELD: "scope-phone-field"
192
194
  };
193
- var TOKEN_TO_PANEL_TYPE = (_TOKEN_TO_PANEL_TYPE = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.TRIGGER_ADD, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_REPLACE, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_ACTOR, BUILDER_PANEL_TYPES.ACTOR), BUILDER_ANCHORS.COND_FIELD, BUILDER_PANEL_TYPES.CONDITION_FIELD), BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_PANEL_TYPES.OPERATOR), BUILDER_ANCHORS.COND_CONNECTOR, BUILDER_PANEL_TYPES.CONNECTOR), BUILDER_ANCHORS.COND_VALUES, BUILDER_PANEL_TYPES.CONDITION_VALUE), BUILDER_ANCHORS.ACTION_ADD, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_PANEL_TYPES.ACTION_CONFIG), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_PANEL_TYPES.RECIPIENT), BUILDER_ANCHORS.RULE_DELAY, BUILDER_PANEL_TYPES.DELAY), BUILDER_ANCHORS.TRIGGER_LEAD_TIME, BUILDER_PANEL_TYPES.LEAD_TIME), BUILDER_ANCHORS.META_NAME, BUILDER_PANEL_TYPES.NAME), BUILDER_ANCHORS.SCOPE, BUILDER_PANEL_TYPES.SCOPE));
195
+ var TOKEN_TO_PANEL_TYPE = (_TOKEN_TO_PANEL_TYPE = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.TRIGGER_ADD, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_REPLACE, BUILDER_PANEL_TYPES.TRIGGER), BUILDER_ANCHORS.TRIGGER_ACTOR, BUILDER_PANEL_TYPES.ACTOR), BUILDER_ANCHORS.COND_FIELD, BUILDER_PANEL_TYPES.CONDITION_FIELD), BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_PANEL_TYPES.OPERATOR), BUILDER_ANCHORS.COND_CONNECTOR, BUILDER_PANEL_TYPES.CONNECTOR), BUILDER_ANCHORS.COND_VALUES, BUILDER_PANEL_TYPES.CONDITION_VALUE), BUILDER_ANCHORS.ACTION_ADD, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_PANEL_TYPES.ACTION_CHANNEL), BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_PANEL_TYPES.ACTION_CONFIG), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TOKEN_TO_PANEL_TYPE, BUILDER_ANCHORS.ACTION_RECIPIENT, BUILDER_PANEL_TYPES.RECIPIENT), BUILDER_ANCHORS.RULE_DELAY, BUILDER_PANEL_TYPES.DELAY), BUILDER_ANCHORS.TRIGGER_LEAD_TIME, BUILDER_PANEL_TYPES.LEAD_TIME), BUILDER_ANCHORS.META_NAME, BUILDER_PANEL_TYPES.NAME), BUILDER_ANCHORS.SCOPE, BUILDER_PANEL_TYPES.SCOPE), BUILDER_ANCHORS.SCOPE_PHONE_FIELD, BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD));
194
196
  var LARGE_PANEL_TYPES = [BUILDER_PANEL_TYPES.ACTION_CONFIG, BUILDER_PANEL_TYPES.SCOPE, BUILDER_PANEL_TYPES.NAME];
195
197
  var CONDITION_ANCHORS = [BUILDER_ANCHORS.COND_FIELD, BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_ANCHORS.COND_VALUES, BUILDER_ANCHORS.COND_CONNECTOR];
196
198
  var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT];
@@ -294,6 +296,9 @@ var isMultiValueVerb = function isMultiValueVerb(verb) {
294
296
  var sentencify = function sentencify(label) {
295
297
  return label ? label.charAt(0).toLowerCase() + label.slice(1) : label;
296
298
  };
299
+ var copyFor = function copyFor(value, args) {
300
+ return typeof value === "function" ? value(args) : value;
301
+ };
297
302
  var matchesTrigger = function matchesTrigger(name) {
298
303
  return function (option) {
299
304
  return option.eventValue === name || option.value === name || option.id === name;
@@ -457,24 +462,77 @@ var hasAction = function hasAction(rule) {
457
462
  var isRuleComplete = function isRuleComplete(rule) {
458
463
  return hasTrigger(rule) && hasAction(rule);
459
464
  };
460
- var invalidScopeIndexes = function invalidScopeIndexes(_ref12) {
465
+ var scopeOptionFor = function scopeOptionFor(_ref12) {
466
+ var _item$value, _schema$scope;
467
+ var schema = _ref12.schema,
468
+ item = _ref12.item;
469
+ var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
470
+ return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
471
+ var _candidate$value2;
472
+ return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
473
+ });
474
+ };
475
+ var scopePhoneFields = function scopePhoneFields(_ref13) {
476
+ var _ref14, _item$phoneFields, _scopeOptionFor;
477
+ var schema = _ref13.schema,
478
+ item = _ref13.item;
479
+ return (_ref14 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
480
+ schema: schema,
481
+ item: item
482
+ })) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref14 !== void 0 ? _ref14 : null;
483
+ };
484
+ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref15) {
485
+ var schema = _ref15.schema,
486
+ item = _ref15.item;
487
+ if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
488
+ var phoneFields = scopePhoneFields({
489
+ schema: schema,
490
+ item: item
491
+ });
492
+ return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
493
+ };
494
+ var invalidScopeIndexes = function invalidScopeIndexes(_ref16) {
461
495
  var _scope$requiresPhone;
462
- var rule = _ref12.rule,
463
- schema = _ref12.schema;
496
+ var rule = _ref16.rule,
497
+ schema = _ref16.schema;
464
498
  var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
465
499
  if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone = scope.requiresPhone) !== null && _scope$requiresPhone !== void 0 && _scope$requiresPhone.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
466
500
  return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
467
- var _item$value, _item$hasPhoneField;
468
- var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
469
- var option = (scope.options || []).find(function (candidate) {
470
- var _candidate$value2;
471
- return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
501
+ var _ref17, _item$hasPhoneField;
502
+ var option = scopeOptionFor({
503
+ schema: schema,
504
+ item: item
505
+ });
506
+ var phoneFields = scopePhoneFields({
507
+ schema: schema,
508
+ item: item
472
509
  });
473
- var hasPhoneField = (_item$hasPhoneField = item === null || item === void 0 ? void 0 : item.hasPhoneField) !== null && _item$hasPhoneField !== void 0 ? _item$hasPhoneField : option === null || option === void 0 ? void 0 : option.hasPhoneField;
510
+ var hasPhoneField = (_ref17 = (_item$hasPhoneField = item === null || item === void 0 ? void 0 : item.hasPhoneField) !== null && _item$hasPhoneField !== void 0 ? _item$hasPhoneField : option === null || option === void 0 ? void 0 : option.hasPhoneField) !== null && _ref17 !== void 0 ? _ref17 : phoneFields ? phoneFields.length > 0 : undefined;
474
511
  if (hasPhoneField === false) indexes.push(index);
475
512
  return indexes;
476
513
  }, []);
477
514
  };
515
+ var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref18) {
516
+ var _scope$requiresPhone2;
517
+ var rule = _ref18.rule,
518
+ schema = _ref18.schema;
519
+ var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
520
+ if (!(scope !== null && scope !== void 0 && scope.enabled) || !((_scope$requiresPhone2 = scope.requiresPhone) !== null && _scope$requiresPhone2 !== void 0 && _scope$requiresPhone2.call(scope, (rule === null || rule === void 0 ? void 0 : rule.actions) || []))) return [];
521
+ return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
522
+ var phoneFields = scopePhoneFields({
523
+ schema: schema,
524
+ item: item
525
+ });
526
+ var hasChoice = ((phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) || 0) > 1;
527
+ if (hasChoice && !effectiveScopePhoneField({
528
+ schema: schema,
529
+ item: item
530
+ })) {
531
+ indexes.push(index);
532
+ }
533
+ return indexes;
534
+ }, []);
535
+ };
478
536
  var minutesToParts = function minutesToParts(minutes) {
479
537
  var total = Number(minutes) || 0;
480
538
  if (total && total % UNIT_MINUTES.days === 0) {
@@ -494,9 +552,9 @@ var minutesToParts = function minutesToParts(minutes) {
494
552
  unit: "minutes"
495
553
  };
496
554
  };
497
- var partsToMinutes = function partsToMinutes(_ref13) {
498
- var value = _ref13.value,
499
- unit = _ref13.unit;
555
+ var partsToMinutes = function partsToMinutes(_ref19) {
556
+ var value = _ref19.value,
557
+ unit = _ref19.unit;
500
558
  return (
501
559
  // eslint-disable-next-line security/detect-object-injection
502
560
  (Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
@@ -529,17 +587,17 @@ var modeFromJoinType = function modeFromJoinType(joinType) {
529
587
  };
530
588
 
531
589
  // eslint-disable-next-line security/detect-object-injection
532
- var valueAt = function valueAt(_ref14) {
590
+ var valueAt = function valueAt(_ref20) {
533
591
  var _values$key;
534
- var values = _ref14.values,
535
- key = _ref14.key;
592
+ var values = _ref20.values,
593
+ key = _ref20.key;
536
594
  return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
537
595
  };
538
596
  var asArray = function asArray(maybeArray) {
539
597
  return Array.isArray(maybeArray) ? maybeArray : [];
540
598
  };
541
599
  var fieldKeysFromSchema = function fieldKeysFromSchema() {
542
- var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope;
600
+ var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope2;
543
601
  var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
544
602
  return {
545
603
  triggers: ((_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.fieldKey) || "events",
@@ -548,18 +606,18 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
548
606
  actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
549
607
  delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
550
608
  leadTime: (_schema$triggers3 = schema.triggers) === null || _schema$triggers3 === void 0 || (_schema$triggers3 = _schema$triggers3.leadTime) === null || _schema$triggers3 === void 0 ? void 0 : _schema$triggers3.fieldKey,
551
- scope: ((_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.fieldKey) || "meetingIds",
609
+ scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
552
610
  status: "status",
553
611
  name: "name"
554
612
  };
555
613
  };
556
614
  var valuesToRuleModel = function valuesToRuleModel() {
557
615
  var _valueAt, _conditions$;
558
- var _ref15 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
559
- _ref15$values = _ref15.values,
560
- values = _ref15$values === void 0 ? {} : _ref15$values,
561
- _ref15$schema = _ref15.schema,
562
- schema = _ref15$schema === void 0 ? {} : _ref15$schema;
616
+ var _ref21 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
617
+ _ref21$values = _ref21.values,
618
+ values = _ref21$values === void 0 ? {} : _ref21$values,
619
+ _ref21$schema = _ref21.schema,
620
+ schema = _ref21$schema === void 0 ? {} : _ref21$schema;
563
621
  var keys = fieldKeysFromSchema(schema);
564
622
  var conditions = asArray(valueAt({
565
623
  values: values,
@@ -603,42 +661,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
603
661
  }))
604
662
  };
605
663
  };
606
- var setTriggers = function setTriggers(_ref16) {
607
- var schema = _ref16.schema,
608
- triggers = _ref16.triggers;
664
+ var setTriggers = function setTriggers(_ref22) {
665
+ var schema = _ref22.schema,
666
+ triggers = _ref22.triggers;
609
667
  return {
610
668
  path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
611
669
  value: triggers
612
670
  };
613
671
  };
614
- var setPerformer = function setPerformer(_ref17) {
615
- var schema = _ref17.schema,
616
- performer = _ref17.performer;
672
+ var setPerformer = function setPerformer(_ref23) {
673
+ var schema = _ref23.schema,
674
+ performer = _ref23.performer;
617
675
  return {
618
676
  path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
619
677
  value: performer
620
678
  };
621
679
  };
622
- var setActions = function setActions(_ref18) {
623
- var schema = _ref18.schema,
624
- actions = _ref18.actions;
680
+ var setActions = function setActions(_ref24) {
681
+ var schema = _ref24.schema,
682
+ actions = _ref24.actions;
625
683
  return {
626
684
  path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
627
685
  value: actions
628
686
  };
629
687
  };
630
- var setConditions = function setConditions(_ref19) {
631
- var schema = _ref19.schema,
632
- conditions = _ref19.conditions;
688
+ var setConditions = function setConditions(_ref25) {
689
+ var schema = _ref25.schema,
690
+ conditions = _ref25.conditions;
633
691
  return {
634
692
  path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
635
693
  value: conditions
636
694
  };
637
695
  };
638
- var setConditionMode = function setConditionMode(_ref20) {
639
- var schema = _ref20.schema,
640
- conditions = _ref20.conditions,
641
- joinType = _ref20.joinType;
696
+ var setConditionMode = function setConditionMode(_ref26) {
697
+ var schema = _ref26.schema,
698
+ conditions = _ref26.conditions,
699
+ joinType = _ref26.joinType;
642
700
  return setConditions({
643
701
  schema: schema,
644
702
  conditions: conditions.map(function (condition) {
@@ -646,34 +704,34 @@ var setConditionMode = function setConditionMode(_ref20) {
646
704
  })
647
705
  });
648
706
  };
649
- var setDelay = function setDelay(_ref21) {
650
- var schema = _ref21.schema,
651
- delay = _ref21.delay;
707
+ var setDelay = function setDelay(_ref27) {
708
+ var schema = _ref27.schema,
709
+ delay = _ref27.delay;
652
710
  return {
653
711
  path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
654
712
  value: delay !== null && delay !== void 0 ? delay : {}
655
713
  };
656
714
  };
657
- var setActive = function setActive(_ref22) {
658
- var schema = _ref22.schema,
659
- active = _ref22.active;
715
+ var setActive = function setActive(_ref28) {
716
+ var schema = _ref28.schema,
717
+ active = _ref28.active;
660
718
  return {
661
719
  path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
662
720
  value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
663
721
  };
664
722
  };
665
- var setScope = function setScope(_ref23) {
666
- var schema = _ref23.schema,
667
- scope = _ref23.scope;
723
+ var setScope = function setScope(_ref29) {
724
+ var schema = _ref29.schema,
725
+ scope = _ref29.scope;
668
726
  return {
669
727
  path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
670
728
  value: scope
671
729
  };
672
730
  };
673
- var removeArrayItem = function removeArrayItem(_ref24) {
674
- var values = _ref24.values,
675
- fieldKey = _ref24.fieldKey,
676
- index = _ref24.index;
731
+ var removeArrayItem = function removeArrayItem(_ref30) {
732
+ var values = _ref30.values,
733
+ fieldKey = _ref30.fieldKey,
734
+ index = _ref30.index;
677
735
  var list = asArray(valueAt({
678
736
  values: values,
679
737
  key: fieldKey
@@ -1033,7 +1091,7 @@ var itemLabel = function itemLabel(item) {
1033
1091
  return (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.value) || String(item !== null && item !== void 0 ? item : "");
1034
1092
  };
1035
1093
  var ScopeBlock = function ScopeBlock(_ref) {
1036
- var _schema$scope;
1094
+ var _schema$scope, _schema$scope2, _schema$scope2$requir;
1037
1095
  var rule = _ref.rule,
1038
1096
  schema = _ref.schema,
1039
1097
  handleToken = _ref.onToken,
@@ -1050,6 +1108,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1050
1108
  t = _useTranslation.t;
1051
1109
  var scope = rule.scope || [];
1052
1110
  var placeholder = (schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.placeholder) || t("neetoRules.builder.scope.placeholder");
1111
+ var requiresPhone = !!(schema !== null && schema !== void 0 && (_schema$scope2 = schema.scope) !== null && _schema$scope2 !== void 0 && (_schema$scope2$requir = _schema$scope2.requiresPhone) !== null && _schema$scope2$requir !== void 0 && _schema$scope2$requir.call(_schema$scope2, rule.actions || []));
1053
1112
  if (ramda.isEmpty(scope)) {
1054
1113
  return /*#__PURE__*/jsxRuntime.jsx("div", {
1055
1114
  className: "mb-row",
@@ -1079,6 +1138,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1079
1138
  isActive: isActive,
1080
1139
  isInvalid: isInvalid,
1081
1140
  item: item,
1141
+ requiresPhone: requiresPhone,
1082
1142
  schema: schema,
1083
1143
  isLast: index === scope.length - 1,
1084
1144
  key: ((_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item) || index,
@@ -1088,7 +1148,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1088
1148
  });
1089
1149
  };
1090
1150
  var ScopeRow = function ScopeRow(_ref2) {
1091
- var _schema$scope2;
1151
+ var _schema$scope3, _schema$scope4, _schema$scope5;
1092
1152
  var schema = _ref2.schema,
1093
1153
  item = _ref2.item,
1094
1154
  index = _ref2.index,
@@ -1096,13 +1156,30 @@ var ScopeRow = function ScopeRow(_ref2) {
1096
1156
  handleRemoveScope = _ref2.onRemoveScope,
1097
1157
  isActive = _ref2.isActive,
1098
1158
  isInvalid = _ref2.isInvalid,
1099
- isLast = _ref2.isLast;
1159
+ isLast = _ref2.isLast,
1160
+ requiresPhone = _ref2.requiresPhone;
1100
1161
  var _useTranslation2 = reactI18next.useTranslation(),
1101
1162
  t = _useTranslation2.t;
1102
1163
  var _useClearingHover = useClearingHover(),
1103
1164
  clearing = _useClearingHover.clearing,
1104
1165
  clearingHoverProps = _useClearingHover.clearingHoverProps;
1105
- var lead = (schema === null || schema === void 0 || (_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.lead) || t("neetoRules.builder.scope.lead");
1166
+ var lead = (schema === null || schema === void 0 || (_schema$scope3 = schema.scope) === null || _schema$scope3 === void 0 ? void 0 : _schema$scope3.lead) || t("neetoRules.builder.scope.lead");
1167
+ var meeting = itemLabel(item);
1168
+ var phoneFields = requiresPhone ? scopePhoneFields({
1169
+ item: item,
1170
+ schema: schema
1171
+ }) : null;
1172
+ var hasPhoneFieldChoice = ((phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) || 0) > 1;
1173
+ var singlePhoneFieldLabel = (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].label : null;
1174
+ var selectedPhoneField = phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.find(function (field) {
1175
+ return field.value === (item === null || item === void 0 ? void 0 : item.phoneField);
1176
+ });
1177
+ var usingLabel = copyFor(schema === null || schema === void 0 || (_schema$scope4 = schema.scope) === null || _schema$scope4 === void 0 ? void 0 : _schema$scope4.usingLabel, {
1178
+ meeting: meeting
1179
+ }) || t("neetoRules.builder.scope.using");
1180
+ var phoneFieldPlaceholder = copyFor(schema === null || schema === void 0 || (_schema$scope5 = schema.scope) === null || _schema$scope5 === void 0 ? void 0 : _schema$scope5.phoneFieldPlaceholder, {
1181
+ meeting: meeting
1182
+ }) || t("neetoRules.builder.selectPhoneField");
1106
1183
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1107
1184
  className: classNames("mb-row", {
1108
1185
  clearing: clearing
@@ -1127,7 +1204,33 @@ var ScopeRow = function ScopeRow(_ref2) {
1127
1204
  type: BUILDER_ANCHORS.SCOPE
1128
1205
  });
1129
1206
  },
1130
- children: itemLabel(item)
1207
+ children: meeting
1208
+ }), singlePhoneFieldLabel && /*#__PURE__*/jsxRuntime.jsxs("span", {
1209
+ className: "mb-fixed",
1210
+ children: [usingLabel, " ", singlePhoneFieldLabel]
1211
+ }), hasPhoneFieldChoice && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1212
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
1213
+ className: "mb-fixed",
1214
+ children: usingLabel
1215
+ }), /*#__PURE__*/jsxRuntime.jsx(Token, {
1216
+ dataTestid: "scope-phone-field-".concat(index),
1217
+ active: isActive({
1218
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1219
+ index: index
1220
+ }),
1221
+ invalid: isInvalid({
1222
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1223
+ index: index
1224
+ }),
1225
+ state: selectedPhoneField ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
1226
+ onClick: handleToken && function () {
1227
+ return handleToken({
1228
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1229
+ index: index
1230
+ });
1231
+ },
1232
+ children: (selectedPhoneField === null || selectedPhoneField === void 0 ? void 0 : selectedPhoneField.label) || phoneFieldPlaceholder
1233
+ })]
1131
1234
  })]
1132
1235
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1133
1236
  className: "mb-row-actions",
@@ -1788,41 +1891,58 @@ var actionAt = function actionAt(_ref3) {
1788
1891
  index = _ref3.index;
1789
1892
  return rule.actions[index] || {};
1790
1893
  };
1791
- var findField = function findField(_ref4) {
1894
+
1895
+ // eslint-disable-next-line security/detect-object-injection
1896
+ var scopeItemAt = function scopeItemAt(_ref4) {
1897
+ var _rule$scope;
1898
+ var rule = _ref4.rule,
1899
+ index = _ref4.index;
1900
+ return ((_rule$scope = rule.scope) === null || _rule$scope === void 0 ? void 0 : _rule$scope[index]) || {};
1901
+ };
1902
+ var scopeItemLabel = function scopeItemLabel(item) {
1903
+ return (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name) || (item === null || item === void 0 ? void 0 : item.value) || String(item !== null && item !== void 0 ? item : "");
1904
+ };
1905
+ var findField = function findField(_ref5) {
1792
1906
  var _schema$conditions;
1793
- var schema = _ref4.schema,
1794
- value = _ref4.value;
1907
+ var schema = _ref5.schema,
1908
+ value = _ref5.value;
1795
1909
  return (((_schema$conditions = schema.conditions) === null || _schema$conditions === void 0 ? void 0 : _schema$conditions.fields) || []).find(function (field) {
1796
1910
  return optionValue(field) === value;
1797
1911
  });
1798
1912
  };
1799
- var findActionOption = function findActionOption(_ref5) {
1913
+ var findActionOption = function findActionOption(_ref6) {
1800
1914
  var _schema$actions;
1801
- var schema = _ref5.schema,
1802
- name = _ref5.name;
1915
+ var schema = _ref6.schema,
1916
+ name = _ref6.name;
1803
1917
  return (((_schema$actions = schema.actions) === null || _schema$actions === void 0 ? void 0 : _schema$actions.options) || []).find(function (option) {
1804
1918
  return optionValue(option) === name;
1805
1919
  });
1806
1920
  };
1807
- var channelOf = function channelOf(_ref6) {
1921
+ var channelOf = function channelOf(_ref7) {
1808
1922
  var _schema$actions2, _schema$actions2$acti;
1809
- var schema = _ref6.schema,
1810
- action = _ref6.action;
1811
- return (action === null || action === void 0 ? void 0 : action.channel) || ((_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$acti = _schema$actions2.actionForName) === null || _schema$actions2$acti === void 0 || (_schema$actions2$acti = _schema$actions2$acti.call(_schema$actions2, action === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions2$acti === void 0 ? void 0 : _schema$actions2$acti.channel);
1812
- };
1813
- var channelMetaOf = function channelMetaOf(_ref7) {
1814
- var _schema$actions3;
1815
1923
  var schema = _ref7.schema,
1816
1924
  action = _ref7.action;
1817
- return ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3 = _schema$actions3.channelMeta) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3[channelOf({
1925
+ return (action === null || action === void 0 ? void 0 : action.channel) || ((_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$acti = _schema$actions2.actionForName) === null || _schema$actions2$acti === void 0 || (_schema$actions2$acti = _schema$actions2$acti.call(_schema$actions2, action === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions2$acti === void 0 ? void 0 : _schema$actions2$acti.channel);
1926
+ };
1927
+ var recipientOf = function recipientOf(_ref8) {
1928
+ var _action$recipient, _schema$actions3, _schema$actions3$acti;
1929
+ var schema = _ref8.schema,
1930
+ action = _ref8.action;
1931
+ return (_action$recipient = action === null || action === void 0 ? void 0 : action.recipient) !== null && _action$recipient !== void 0 ? _action$recipient : (_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3$acti = _schema$actions3.actionForName) === null || _schema$actions3$acti === void 0 || (_schema$actions3$acti = _schema$actions3$acti.call(_schema$actions3, action === null || action === void 0 ? void 0 : action.name)) === null || _schema$actions3$acti === void 0 ? void 0 : _schema$actions3$acti.recipient;
1932
+ };
1933
+ var channelMetaOf = function channelMetaOf(_ref9) {
1934
+ var _schema$actions4;
1935
+ var schema = _ref9.schema,
1936
+ action = _ref9.action;
1937
+ return ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4 = _schema$actions4.channelMeta) === null || _schema$actions4 === void 0 ? void 0 : _schema$actions4[channelOf({
1818
1938
  schema: schema,
1819
1939
  action: action
1820
1940
  })]) || {};
1821
1941
  };
1822
- var actionHasConfig = function actionHasConfig(_ref8) {
1823
- var _schema$actions4, _schema$actions5;
1824
- var schema = _ref8.schema,
1825
- action = _ref8.action;
1942
+ var actionHasConfig = function actionHasConfig(_ref0) {
1943
+ var _schema$actions5, _schema$actions6;
1944
+ var schema = _ref0.schema,
1945
+ action = _ref0.action;
1826
1946
  var meta = channelMetaOf({
1827
1947
  schema: schema,
1828
1948
  action: action
@@ -1833,18 +1953,18 @@ var actionHasConfig = function actionHasConfig(_ref8) {
1833
1953
  name: action === null || action === void 0 ? void 0 : action.name
1834
1954
  });
1835
1955
  if (option !== null && option !== void 0 && option.component || option !== null && option !== void 0 && option.renderConfig) return true;
1836
- if ((_schema$actions4 = schema.actions) !== null && _schema$actions4 !== void 0 && _schema$actions4.hasConfig) return schema.actions.hasConfig(action);
1837
- return !!((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.renderConfig);
1956
+ if ((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.hasConfig) return schema.actions.hasConfig(action);
1957
+ return !!((_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.renderConfig);
1838
1958
  };
1839
- var recipientsFor = function recipientsFor(_ref9) {
1840
- var _schema$actions6, _schema$actions7;
1841
- var schema = _ref9.schema,
1842
- action = _ref9.action;
1959
+ var recipientsFor = function recipientsFor(_ref1) {
1960
+ var _schema$actions7, _schema$actions8;
1961
+ var schema = _ref1.schema,
1962
+ action = _ref1.action;
1843
1963
  var channel = channelOf({
1844
1964
  schema: schema,
1845
1965
  action: action
1846
1966
  });
1847
- if (channel && (_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.recipientsFor) {
1967
+ if (channel && (_schema$actions7 = schema.actions) !== null && _schema$actions7 !== void 0 && _schema$actions7.recipientsFor) {
1848
1968
  return schema.actions.recipientsFor(channel);
1849
1969
  }
1850
1970
  var option = findActionOption({
@@ -1852,13 +1972,13 @@ var recipientsFor = function recipientsFor(_ref9) {
1852
1972
  name: channel
1853
1973
  });
1854
1974
  if (option !== null && option !== void 0 && option.recipients) return option.recipients;
1855
- return ((_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 ? void 0 : _schema$actions7.recipients) || [];
1975
+ return ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8.recipients) || [];
1856
1976
  };
1857
- var nextTriggers = function nextTriggers(_ref0) {
1977
+ var nextTriggers = function nextTriggers(_ref10) {
1858
1978
  var _schema$triggers;
1859
- var schema = _ref0.schema,
1860
- rule = _ref0.rule,
1861
- value = _ref0.value;
1979
+ var schema = _ref10.schema,
1980
+ rule = _ref10.rule,
1981
+ value = _ref10.value;
1862
1982
  if ((_schema$triggers = schema.triggers) !== null && _schema$triggers !== void 0 && _schema$triggers.multi) {
1863
1983
  var names = ramda.pluck("name", rule.triggers);
1864
1984
  return names.includes(value) ? neetoCist.removeBy({
@@ -1871,12 +1991,12 @@ var nextTriggers = function nextTriggers(_ref0) {
1871
1991
  name: value
1872
1992
  }];
1873
1993
  };
1874
- var nextConditionAt = function nextConditionAt(_ref1) {
1994
+ var nextConditionAt = function nextConditionAt(_ref11) {
1875
1995
  var _field$allowMatching;
1876
- var schema = _ref1.schema,
1877
- rule = _ref1.rule,
1878
- index = _ref1.index,
1879
- value = _ref1.value;
1996
+ var schema = _ref11.schema,
1997
+ rule = _ref11.rule,
1998
+ index = _ref11.index,
1999
+ value = _ref11.value;
1880
2000
  var field = findField({
1881
2001
  schema: schema,
1882
2002
  value: value
@@ -1895,13 +2015,13 @@ var nextConditionAt = function nextConditionAt(_ref1) {
1895
2015
  metadata: {}
1896
2016
  });
1897
2017
  };
1898
- var nextActionAt = function nextActionAt(_ref10) {
1899
- var _schema$actions8;
1900
- var schema = _ref10.schema,
1901
- rule = _ref10.rule,
1902
- index = _ref10.index,
1903
- value = _ref10.value;
1904
- if (!((_schema$actions8 = schema.actions) !== null && _schema$actions8 !== void 0 && _schema$actions8.resolveName)) {
2018
+ var nextActionAt = function nextActionAt(_ref12) {
2019
+ var _schema$actions9;
2020
+ var schema = _ref12.schema,
2021
+ rule = _ref12.rule,
2022
+ index = _ref12.index,
2023
+ value = _ref12.value;
2024
+ if (!((_schema$actions9 = schema.actions) !== null && _schema$actions9 !== void 0 && _schema$actions9.resolveName)) {
1905
2025
  var option = findActionOption({
1906
2026
  schema: schema,
1907
2027
  name: value
@@ -1939,10 +2059,10 @@ var nextActionAt = function nextActionAt(_ref10) {
1939
2059
  var channelChanged = prevChannel !== value;
1940
2060
  var recipient = channelChanged ? undefined : prev.recipient;
1941
2061
  if (channelChanged) {
1942
- var _schema$actions9;
2062
+ var _schema$actions0;
1943
2063
  var channelRecipients =
1944
2064
  // eslint-disable-next-line security/detect-object-injection
1945
- ((_schema$actions9 = schema.actions) === null || _schema$actions9 === void 0 || (_schema$actions9 = _schema$actions9.recipientsByChannel) === null || _schema$actions9 === void 0 ? void 0 : _schema$actions9[value]) || [];
2065
+ ((_schema$actions0 = schema.actions) === null || _schema$actions0 === void 0 || (_schema$actions0 = _schema$actions0.recipientsByChannel) === null || _schema$actions0 === void 0 ? void 0 : _schema$actions0[value]) || [];
1946
2066
  if (channelRecipients.length === 1) {
1947
2067
  var _channelRecipients = _slicedToArray(channelRecipients, 1);
1948
2068
  recipient = _channelRecipients[0];
@@ -1958,12 +2078,33 @@ var nextActionAt = function nextActionAt(_ref10) {
1958
2078
  metadata: channelChanged ? {} : prev.metadata
1959
2079
  });
1960
2080
  };
1961
- var nextActionRecipientAt = function nextActionRecipientAt(_ref11) {
1962
- var _schema$actions0;
1963
- var schema = _ref11.schema,
1964
- rule = _ref11.rule,
1965
- index = _ref11.index,
1966
- value = _ref11.value;
2081
+ var appendScopeItem = function appendScopeItem(_ref13) {
2082
+ var _sc$requiresPhone;
2083
+ var schema = _ref13.schema,
2084
+ rule = _ref13.rule,
2085
+ value = _ref13.value;
2086
+ var sc = schema.scope || {};
2087
+ var option = (sc.options || []).find(function (candidate) {
2088
+ return optionValue(candidate) === value;
2089
+ }) || {
2090
+ value: value
2091
+ };
2092
+ var requiresPhone = ((_sc$requiresPhone = sc.requiresPhone) === null || _sc$requiresPhone === void 0 ? void 0 : _sc$requiresPhone.call(sc, rule.actions)) || false;
2093
+ if (!requiresPhone) return option;
2094
+ var phoneFields = scopePhoneFields({
2095
+ schema: schema,
2096
+ item: option
2097
+ });
2098
+ return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? _objectSpread$4(_objectSpread$4({}, option), {}, {
2099
+ phoneField: phoneFields[0].value
2100
+ }) : option;
2101
+ };
2102
+ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
2103
+ var _schema$actions1;
2104
+ var schema = _ref14.schema,
2105
+ rule = _ref14.rule,
2106
+ index = _ref14.index,
2107
+ value = _ref14.value;
1967
2108
  var prev = actionAt({
1968
2109
  rule: rule,
1969
2110
  index: index
@@ -1974,18 +2115,18 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref11) {
1974
2115
  });
1975
2116
  return _objectSpread$4(_objectSpread$4({}, prev), {}, {
1976
2117
  recipient: value,
1977
- name: (_schema$actions0 = schema.actions) !== null && _schema$actions0 !== void 0 && _schema$actions0.resolveName ? schema.actions.resolveName({
2118
+ name: (_schema$actions1 = schema.actions) !== null && _schema$actions1 !== void 0 && _schema$actions1.resolveName ? schema.actions.resolveName({
1978
2119
  channel: channel,
1979
2120
  recipient: value
1980
2121
  }) : value
1981
2122
  });
1982
2123
  };
1983
- var descriptorFor = function descriptorFor(_ref12) {
2124
+ var descriptorFor = function descriptorFor(_ref15) {
1984
2125
  var _schema$actor2, _schema$conditions2;
1985
- var anchor = _ref12.anchor,
1986
- schema = _ref12.schema,
1987
- rule = _ref12.rule,
1988
- index = _ref12.index;
2126
+ var anchor = _ref15.anchor,
2127
+ schema = _ref15.schema,
2128
+ rule = _ref15.rule,
2129
+ index = _ref15.index;
1989
2130
  switch (anchor) {
1990
2131
  case BUILDER_ANCHORS.TRIGGER_ADD:
1991
2132
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2095,22 +2236,22 @@ var descriptorFor = function descriptorFor(_ref12) {
2095
2236
  case BUILDER_ANCHORS.ACTION_ADD:
2096
2237
  case BUILDER_ANCHORS.ACTION_CHANNEL:
2097
2238
  {
2098
- var _schema$actions10, _schema$actions11, _channelOf;
2239
+ var _schema$actions11, _schema$actions12, _channelOf;
2099
2240
  var isSwap = anchor === BUILDER_ANCHORS.ACTION_CHANNEL;
2100
2241
  var channelMetaFor = function channelMetaFor(value) {
2101
- var _schema$actions1;
2242
+ var _schema$actions10;
2102
2243
  return (
2103
2244
  // eslint-disable-next-line security/detect-object-injection
2104
- ((_schema$actions1 = schema.actions) === null || _schema$actions1 === void 0 || (_schema$actions1 = _schema$actions1.channelMeta) === null || _schema$actions1 === void 0 ? void 0 : _schema$actions1[value]) || {}
2245
+ ((_schema$actions10 = schema.actions) === null || _schema$actions10 === void 0 || (_schema$actions10 = _schema$actions10.channelMeta) === null || _schema$actions10 === void 0 ? void 0 : _schema$actions10[value]) || {}
2105
2246
  );
2106
2247
  };
2107
2248
  var rank = function rank(value) {
2108
2249
  var idx = SWAP_CHANNEL_ORDER.indexOf(value);
2109
2250
  return idx === -1 ? SWAP_CHANNEL_ORDER.length : idx;
2110
2251
  };
2111
- var sourceOptions = isSwap ? _toConsumableArray(((_schema$actions10 = schema.actions) === null || _schema$actions10 === void 0 ? void 0 : _schema$actions10.options) || []).sort(function (optionA, optionB) {
2252
+ var sourceOptions = isSwap ? _toConsumableArray(((_schema$actions11 = schema.actions) === null || _schema$actions11 === void 0 ? void 0 : _schema$actions11.options) || []).sort(function (optionA, optionB) {
2112
2253
  return rank(optionValue(optionA)) - rank(optionValue(optionB));
2113
- }) : ((_schema$actions11 = schema.actions) === null || _schema$actions11 === void 0 ? void 0 : _schema$actions11.options) || [];
2254
+ }) : ((_schema$actions12 = schema.actions) === null || _schema$actions12 === void 0 ? void 0 : _schema$actions12.options) || [];
2114
2255
  return {
2115
2256
  title: isSwap ? i18next.t("neetoRules.builder.panes.actionSwapTitle") : i18next.t("neetoRules.builder.panes.actionAddTitle"),
2116
2257
  subtitle: isSwap ? i18next.t("neetoRules.builder.panes.actionSwapSubtitle") : i18next.t("neetoRules.builder.panes.actionAddSubtitle"),
@@ -2140,7 +2281,7 @@ var descriptorFor = function descriptorFor(_ref12) {
2140
2281
  }
2141
2282
  case BUILDER_ANCHORS.ACTION_RECIPIENT:
2142
2283
  {
2143
- var _schema$actions12;
2284
+ var _schema$actions13;
2144
2285
  var action = actionAt({
2145
2286
  rule: rule,
2146
2287
  index: index
@@ -2150,7 +2291,7 @@ var descriptorFor = function descriptorFor(_ref12) {
2150
2291
  action: action
2151
2292
  });
2152
2293
  // eslint-disable-next-line security/detect-object-injection
2153
- var meta = ((_schema$actions12 = schema.actions) === null || _schema$actions12 === void 0 || (_schema$actions12 = _schema$actions12.channelMeta) === null || _schema$actions12 === void 0 ? void 0 : _schema$actions12[channel]) || {};
2294
+ var meta = ((_schema$actions13 = schema.actions) === null || _schema$actions13 === void 0 || (_schema$actions13 = _schema$actions13.channelMeta) === null || _schema$actions13 === void 0 ? void 0 : _schema$actions13[channel]) || {};
2154
2295
  var option = findActionOption({
2155
2296
  schema: schema,
2156
2297
  name: channel
@@ -2167,18 +2308,21 @@ var descriptorFor = function descriptorFor(_ref12) {
2167
2308
  value: optionValue(recipient)
2168
2309
  };
2169
2310
  }),
2170
- selectedValues: [action.recipient]
2311
+ selectedValues: [recipientOf({
2312
+ schema: schema,
2313
+ action: action
2314
+ })]
2171
2315
  };
2172
2316
  }
2173
2317
  case BUILDER_ANCHORS.SCOPE:
2174
2318
  {
2175
- var _sc$requiresPhone;
2319
+ var _sc$requiresPhone2;
2176
2320
  var sc = schema.scope || {};
2177
2321
  var selected = (rule.scope || []).map(function (item) {
2178
2322
  var _item$value;
2179
2323
  return (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
2180
2324
  });
2181
- var requiresPhone = ((_sc$requiresPhone = sc.requiresPhone) === null || _sc$requiresPhone === void 0 ? void 0 : _sc$requiresPhone.call(sc, rule.actions)) || false;
2325
+ var requiresPhone = ((_sc$requiresPhone2 = sc.requiresPhone) === null || _sc$requiresPhone2 === void 0 ? void 0 : _sc$requiresPhone2.call(sc, rule.actions)) || false;
2182
2326
  return {
2183
2327
  title: selected.length ? sc.paneChangeTitle || i18next.t("neetoRules.builder.panes.scopeChangeTitle") : sc.paneTitle || i18next.t("neetoRules.builder.panes.scopeTitle"),
2184
2328
  subtitle: sc.paneSubtitle || i18next.t("neetoRules.builder.panes.scopeSubtitle"),
@@ -2198,6 +2342,36 @@ var descriptorFor = function descriptorFor(_ref12) {
2198
2342
  selectedValues: selected
2199
2343
  };
2200
2344
  }
2345
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2346
+ {
2347
+ var _sc = schema.scope || {};
2348
+ var item = scopeItemAt({
2349
+ rule: rule,
2350
+ index: index
2351
+ });
2352
+ var meeting = scopeItemLabel(item);
2353
+ var options = scopePhoneFields({
2354
+ schema: schema,
2355
+ item: item
2356
+ }) || [];
2357
+ return {
2358
+ title: copyFor(_sc.phoneFieldPaneTitle, {
2359
+ meeting: meeting
2360
+ }) || i18next.t("neetoRules.builder.panes.phoneFieldTitle"),
2361
+ subtitle: copyFor(_sc.phoneFieldPaneSubtitle, {
2362
+ meeting: meeting
2363
+ }) || i18next.t("neetoRules.builder.panes.phoneFieldSubtitle", {
2364
+ meeting: meeting
2365
+ }),
2366
+ options: options.map(function (option) {
2367
+ return {
2368
+ label: option.label,
2369
+ value: optionValue(option)
2370
+ };
2371
+ }),
2372
+ selectedValues: [item.phoneField]
2373
+ };
2374
+ }
2201
2375
  default:
2202
2376
  return {
2203
2377
  title: "",
@@ -2207,13 +2381,13 @@ var descriptorFor = function descriptorFor(_ref12) {
2207
2381
  };
2208
2382
  }
2209
2383
  };
2210
- var commitFor = function commitFor(_ref13) {
2211
- var anchor = _ref13.anchor,
2212
- schema = _ref13.schema,
2213
- rule = _ref13.rule,
2214
- index = _ref13.index,
2215
- value = _ref13.value,
2216
- helpers = _ref13.helpers;
2384
+ var commitFor = function commitFor(_ref16) {
2385
+ var anchor = _ref16.anchor,
2386
+ schema = _ref16.schema,
2387
+ rule = _ref16.rule,
2388
+ index = _ref16.index,
2389
+ value = _ref16.value,
2390
+ helpers = _ref16.helpers;
2217
2391
  var setTriggers = helpers.setTriggers,
2218
2392
  setPerformer = helpers.setPerformer,
2219
2393
  setConditionMode = helpers.setConditionMode,
@@ -2286,8 +2460,7 @@ var commitFor = function commitFor(_ref13) {
2286
2460
  }
2287
2461
  case BUILDER_ANCHORS.SCOPE:
2288
2462
  {
2289
- var sc = schema.scope || {};
2290
- var key = sc.fieldKey || "scope";
2463
+ var key = fieldKeys.scope;
2291
2464
  var current = rule.scope || [];
2292
2465
  var has = current.some(function (item) {
2293
2466
  var _item$value2;
@@ -2296,24 +2469,30 @@ var commitFor = function commitFor(_ref13) {
2296
2469
  var next = has ? current.filter(function (item) {
2297
2470
  var _item$value3;
2298
2471
  return ((_item$value3 = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value3 !== void 0 ? _item$value3 : item) !== value;
2299
- }) : [].concat(_toConsumableArray(current), [(sc.options || []).find(function (option) {
2300
- return optionValue(option) === value;
2301
- }) || {
2472
+ }) : [].concat(_toConsumableArray(current), [appendScopeItem({
2473
+ schema: schema,
2474
+ rule: rule,
2302
2475
  value: value
2303
- }]);
2476
+ })]);
2304
2477
  setFieldValue("".concat(key, ".value"), next);
2305
2478
  return "stay";
2306
2479
  }
2480
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2481
+ {
2482
+ var _key = fieldKeys.scope;
2483
+ setFieldValue("".concat(_key, ".value.").concat(index, ".phoneField"), value);
2484
+ return "stay";
2485
+ }
2307
2486
  default:
2308
2487
  return "close";
2309
2488
  }
2310
2489
  };
2311
- var continueTargetFor = function continueTargetFor(_ref14) {
2490
+ var continueTargetFor = function continueTargetFor(_ref17) {
2312
2491
  var _schema$actor3;
2313
- var anchor = _ref14.anchor,
2314
- schema = _ref14.schema,
2315
- rule = _ref14.rule,
2316
- index = _ref14.index;
2492
+ var anchor = _ref17.anchor,
2493
+ schema = _ref17.schema,
2494
+ rule = _ref17.rule,
2495
+ index = _ref17.index;
2317
2496
  switch (anchor) {
2318
2497
  case BUILDER_ANCHORS.TRIGGER_ADD:
2319
2498
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2386,21 +2565,21 @@ var continueTargetFor = function continueTargetFor(_ref14) {
2386
2565
  return null;
2387
2566
  }
2388
2567
  };
2389
- var replaceAt = function replaceAt(_ref15) {
2390
- var list = _ref15.list,
2391
- index = _ref15.index,
2392
- item = _ref15.item;
2568
+ var replaceAt = function replaceAt(_ref18) {
2569
+ var list = _ref18.list,
2570
+ index = _ref18.index,
2571
+ item = _ref18.item;
2393
2572
  var next = _toConsumableArray(list);
2394
2573
  // eslint-disable-next-line security/detect-object-injection
2395
2574
  next[index] = item;
2396
2575
  return next;
2397
2576
  };
2398
- var applyPreview = function applyPreview(_ref16) {
2399
- var rule = _ref16.rule,
2400
- schema = _ref16.schema,
2401
- anchor = _ref16.anchor,
2402
- index = _ref16.index,
2403
- value = _ref16.value;
2577
+ var applyPreview = function applyPreview(_ref19) {
2578
+ var rule = _ref19.rule,
2579
+ schema = _ref19.schema,
2580
+ anchor = _ref19.anchor,
2581
+ index = _ref19.index,
2582
+ value = _ref19.value;
2404
2583
  switch (anchor) {
2405
2584
  case BUILDER_ANCHORS.TRIGGER_ADD:
2406
2585
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2476,6 +2655,19 @@ var applyPreview = function applyPreview(_ref16) {
2476
2655
  })
2477
2656
  })
2478
2657
  });
2658
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2659
+ return _objectSpread$4(_objectSpread$4({}, rule), {}, {
2660
+ scope: replaceAt({
2661
+ list: rule.scope,
2662
+ index: index,
2663
+ item: _objectSpread$4(_objectSpread$4({}, scopeItemAt({
2664
+ rule: rule,
2665
+ index: index
2666
+ })), {}, {
2667
+ phoneField: value
2668
+ })
2669
+ })
2670
+ });
2479
2671
  default:
2480
2672
  return rule;
2481
2673
  }
@@ -2541,6 +2733,9 @@ var Canvas = function Canvas(_ref) {
2541
2733
  if (ramda.isEmpty(flatErrors) && isRuleComplete(rule) && ramda.isEmpty(invalidScopeIndexes({
2542
2734
  rule: rule,
2543
2735
  schema: schema
2736
+ })) && ramda.isEmpty(invalidScopePhoneFieldIndexes({
2737
+ rule: rule,
2738
+ schema: schema
2544
2739
  }))) {
2545
2740
  return undefined;
2546
2741
  }
@@ -2633,6 +2828,11 @@ var Canvas = function Canvas(_ref) {
2633
2828
  rule: rule,
2634
2829
  schema: schema
2635
2830
  }).includes(index);
2831
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2832
+ return invalidScopePhoneFieldIndexes({
2833
+ rule: rule,
2834
+ schema: schema
2835
+ }).includes(index);
2636
2836
  case BUILDER_ANCHORS.META_NAME:
2637
2837
  return hasErrorAt({
2638
2838
  prefix: "".concat(fieldKeys.name, ".value")
@@ -2685,7 +2885,11 @@ var Canvas = function Canvas(_ref) {
2685
2885
  var isScopeComplete = !(schema !== null && schema !== void 0 && (_schema$scope2 = schema.scope) !== null && _schema$scope2 !== void 0 && _schema$scope2.enabled) || neetoCist.isNotEmpty(rule.scope || []);
2686
2886
  var isComplete = isRuleComplete(rule) && isScopeComplete;
2687
2887
  var handleRemoveScope = function handleRemoveScope(index) {
2688
- return setScope((rule.scope || []).filter(function (_, i) {
2888
+ closePaneIfTargeting({
2889
+ anchors: [BUILDER_ANCHORS.SCOPE_PHONE_FIELD],
2890
+ index: index
2891
+ });
2892
+ setScope((rule.scope || []).filter(function (_, i) {
2689
2893
  return i !== index;
2690
2894
  }));
2691
2895
  };
@@ -3848,7 +4052,7 @@ var RecipientField = function RecipientField(_ref) {
3848
4052
  };
3849
4053
 
3850
4054
  var RecipientPane = function RecipientPane(_ref) {
3851
- var _schema$actions, _schema$actions$actio, _schema$actions2, _schema$actions2$rend, _schema$actions3, _schema$actions3$opti, _schema$actions4, _schema$actions4$opti, _schema$actions5, _schema$actions6, _schema$actions$rende, _schema$actions7, _schema$actions7$rend, _action$metadata, _schema$actions8;
4055
+ var _schema$actions, _schema$actions$actio, _action$recipient, _schema$actions2, _schema$actions2$acti, _schema$actions3, _schema$actions3$rend, _schema$actions4, _schema$actions4$opti, _schema$actions5, _schema$actions5$opti, _schema$actions6, _schema$actions7, _schema$actions$rende, _schema$actions8, _schema$actions8$rend, _action$metadata, _schema$actions9;
3852
4056
  var schema = _ref.schema,
3853
4057
  index$1 = _ref.index;
3854
4058
  var _useTranslation = reactI18next.useTranslation(),
@@ -3862,13 +4066,14 @@ var RecipientPane = function RecipientPane(_ref) {
3862
4066
  // eslint-disable-next-line security/detect-object-injection
3863
4067
  var action = rule.actions[index$1] || {};
3864
4068
  var channel = action.channel || ((_schema$actions = schema.actions) === null || _schema$actions === void 0 || (_schema$actions$actio = _schema$actions.actionForName) === null || _schema$actions$actio === void 0 || (_schema$actions$actio = _schema$actions$actio.call(_schema$actions, action.name)) === null || _schema$actions$actio === void 0 ? void 0 : _schema$actions$actio.channel);
4069
+ var recipient = (_action$recipient = action.recipient) !== null && _action$recipient !== void 0 ? _action$recipient : (_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$acti = _schema$actions2.actionForName) === null || _schema$actions2$acti === void 0 || (_schema$actions2$acti = _schema$actions2$acti.call(_schema$actions2, action.name)) === null || _schema$actions2$acti === void 0 ? void 0 : _schema$actions2$acti.recipient;
3865
4070
  var name = "".concat(fieldKeys.actions, ".value.").concat(index$1, ".metadata");
3866
- var editor = (_schema$actions2 = schema.actions) === null || _schema$actions2 === void 0 || (_schema$actions2$rend = _schema$actions2.renderRecipientEditor) === null || _schema$actions2$rend === void 0 ? void 0 : _schema$actions2$rend.call(_schema$actions2, {
4071
+ var editor = (_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3$rend = _schema$actions3.renderRecipientEditor) === null || _schema$actions3$rend === void 0 ? void 0 : _schema$actions3$rend.call(_schema$actions3, {
3867
4072
  channel: channel,
3868
4073
  name: name,
3869
4074
  action: action
3870
4075
  });
3871
- var flatOption = ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 || (_schema$actions3$opti = _schema$actions3.optionForName) === null || _schema$actions3$opti === void 0 ? void 0 : _schema$actions3$opti.call(_schema$actions3, action.name)) || ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4$opti = _schema$actions4.optionForChannel) === null || _schema$actions4$opti === void 0 ? void 0 : _schema$actions4$opti.call(_schema$actions4, channel));
4076
+ var flatOption = ((_schema$actions4 = schema.actions) === null || _schema$actions4 === void 0 || (_schema$actions4$opti = _schema$actions4.optionForName) === null || _schema$actions4$opti === void 0 ? void 0 : _schema$actions4$opti.call(_schema$actions4, action.name)) || ((_schema$actions5 = schema.actions) === null || _schema$actions5 === void 0 || (_schema$actions5$opti = _schema$actions5.optionForChannel) === null || _schema$actions5$opti === void 0 ? void 0 : _schema$actions5$opti.call(_schema$actions5, channel));
3872
4077
  var isSmsToNumbers = (flatOption === null || flatOption === void 0 ? void 0 : flatOption.type) === SMS_TO_NUMBERS;
3873
4078
  var recipientFieldPath = isSmsToNumbers ? "".concat(name, ".phoneNumbers") : "".concat(name, ".emails");
3874
4079
  usePaneValidation(recipientFieldPath);
@@ -3882,11 +4087,11 @@ var RecipientPane = function RecipientPane(_ref) {
3882
4087
  }, 0);
3883
4088
  // eslint-disable-next-line react-hooks/exhaustive-deps
3884
4089
  }, [!editor]);
3885
- var recipientConfig = (((_schema$actions5 = schema.actions) === null || _schema$actions5 === void 0 ? void 0 : _schema$actions5.options) || []).flatMap(function (option) {
4090
+ var recipientConfig = (((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.options) || []).flatMap(function (option) {
3886
4091
  return option.recipients || [];
3887
- }).concat(((_schema$actions6 = schema.actions) === null || _schema$actions6 === void 0 ? void 0 : _schema$actions6.recipients) || []).find(function (item) {
4092
+ }).concat(((_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 ? void 0 : _schema$actions7.recipients) || []).find(function (item) {
3888
4093
  var _item$value;
3889
- return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === action.recipient;
4094
+ return ((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id) === recipient;
3890
4095
  });
3891
4096
  var builtInRecipientField = recipientConfig !== null && recipientConfig !== void 0 && recipientConfig.field ? /*#__PURE__*/jsxRuntime.jsx(RecipientField, {
3892
4097
  name: name,
@@ -3894,9 +4099,9 @@ var RecipientPane = function RecipientPane(_ref) {
3894
4099
  field: recipientConfig.field,
3895
4100
  placeholder: recipientConfig.placeholder
3896
4101
  }) : null;
3897
- var recipientField = (_schema$actions$rende = (_schema$actions7 = schema.actions) === null || _schema$actions7 === void 0 || (_schema$actions7$rend = _schema$actions7.renderRecipientField) === null || _schema$actions7$rend === void 0 ? void 0 : _schema$actions7$rend.call(_schema$actions7, {
4102
+ var recipientField = (_schema$actions$rende = (_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 || (_schema$actions8$rend = _schema$actions8.renderRecipientField) === null || _schema$actions8$rend === void 0 ? void 0 : _schema$actions8$rend.call(_schema$actions8, {
3898
4103
  channel: channel,
3899
- recipient: action.recipient,
4104
+ recipient: recipient,
3900
4105
  name: name,
3901
4106
  action: action
3902
4107
  })) !== null && _schema$actions$rende !== void 0 ? _schema$actions$rende : builtInRecipientField;
@@ -3931,7 +4136,7 @@ var RecipientPane = function RecipientPane(_ref) {
3931
4136
  }
3932
4137
 
3933
4138
  // eslint-disable-next-line security/detect-object-injection
3934
- var meta = ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 || (_schema$actions8 = _schema$actions8.channelMeta) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8[channel]) || {};
4139
+ var meta = ((_schema$actions9 = schema.actions) === null || _schema$actions9 === void 0 || (_schema$actions9 = _schema$actions9.channelMeta) === null || _schema$actions9 === void 0 ? void 0 : _schema$actions9[channel]) || {};
3935
4140
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3936
4141
  children: [/*#__PURE__*/jsxRuntime.jsx(index.Panel.Header, {
3937
4142
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -4188,12 +4393,14 @@ var BUILDER_PANEL_TYPE_CONFIG_MAP = (_BUILDER_PANEL_TYPE_C = {}, _defineProperty
4188
4393
  component: ConfigPane
4189
4394
  }), BUILDER_PANEL_TYPES.DELAY, {
4190
4395
  component: DelayPane
4191
- }), _defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.LEAD_TIME, {
4396
+ }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.LEAD_TIME, {
4192
4397
  component: LeadTimePane
4193
4398
  }), BUILDER_PANEL_TYPES.NAME, {
4194
4399
  component: NamePane
4195
4400
  }), BUILDER_PANEL_TYPES.SCOPE, {
4196
4401
  component: OptionsPane
4402
+ }), BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD, {
4403
+ component: OptionsPane
4197
4404
  }));
4198
4405
 
4199
4406
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -4272,6 +4479,9 @@ var Form = function Form(_ref) {
4272
4479
  if (!isRuleComplete(rule) || invalidScopeIndexes({
4273
4480
  rule: rule,
4274
4481
  schema: schema
4482
+ }).length || invalidScopePhoneFieldIndexes({
4483
+ rule: rule,
4484
+ schema: schema
4275
4485
  }).length) {
4276
4486
  formikBag.setSubmitting(false);
4277
4487
  return;