@bigbinary/neeto-rules-frontend 2.6.3 → 2.7.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.
@@ -11,7 +11,7 @@ import Header from '@bigbinary/neeto-molecules/Header';
11
11
  import Spinner from '@bigbinary/neetoui/Spinner';
12
12
  import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
13
13
  import { useTranslation } from 'react-i18next';
14
- import { E as EditorAction, n as Panel, q as ErrorCallout, r as SmsFields, s as PhoneNumberField, k as formatData, u as usePollRuleName, T as TouchErrors, m as ScrollToErrorField, o as getValidationSchema, p as DEFAULT_INITIAL_VALUE, l as buildPayload } from './index-B0FTuUOt.js';
14
+ import { E as EditorAction, o as Panel, r as ErrorCallout, s as SmsFields, t as PhoneNumberField, l as formatData, u as usePollRuleName, T as TouchErrors, n as ScrollToErrorField, p as getValidationSchema, q as DEFAULT_INITIAL_VALUE, m as buildPayload } from './index-qw90tLi9.js';
15
15
  import { u as useCustomDataStore } from './useCustomDataStore-BtKYtLVc.js';
16
16
  import { u as useUtilityStore } from './useUtilityStore-CCUYS1mS.js';
17
17
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
@@ -28,9 +28,12 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
28
28
  import Search from '@bigbinary/neeto-icons/Search';
29
29
  import Input from '@bigbinary/neetoui/Input';
30
30
  import Typography from '@bigbinary/neetoui/Typography';
31
+ import { dayjs } from '@bigbinary/neeto-commons-frontend/utils';
31
32
  import Checkbox from '@bigbinary/neetoui/Checkbox';
33
+ import DatePicker from '@bigbinary/neetoui/DatePicker';
32
34
  import Radio from '@bigbinary/neetoui/Radio';
33
35
  import Textarea from '@bigbinary/neetoui/Textarea';
36
+ import { D as DATE_FORMAT } from './utils-DeqHhpwQ.js';
34
37
  import Input$1 from '@bigbinary/neetoui/formik/Input';
35
38
  import Select from '@bigbinary/neetoui/formik/Select';
36
39
  import Select$1 from '@bigbinary/neetoui/Select';
@@ -56,10 +59,6 @@ import '@monaco-editor/react';
56
59
  import '@bigbinary/neeto-icons/Help';
57
60
  import '@bigbinary/neeto-molecules/DynamicVariables';
58
61
  import '@bigbinary/neetoui/Label';
59
- import '@bigbinary/neeto-commons-frontend/utils';
60
- import '@bigbinary/neetoui/DatePicker';
61
- import './utils-CfCq6Ltz.js';
62
- import '@bigbinary/neeto-commons-frontend/initializers';
63
62
  import '@bigbinary/neetoui/formik/MultiEmailInput';
64
63
  import '@bigbinary/neeto-editor/FormikEditor';
65
64
  import '@bigbinary/neeto-icons/Refresh';
@@ -71,6 +70,7 @@ import '@bigbinary/neeto-molecules/PhoneNumber';
71
70
  import '@bigbinary/neetoui/Tag';
72
71
  import 'react-select';
73
72
  import './constants-C_bfl8XZ.js';
73
+ import '@bigbinary/neeto-commons-frontend/initializers';
74
74
  import '@bigbinary/neetoui/TimePicker';
75
75
  import '@bigbinary/neeto-editor/utils';
76
76
  import 'zustand';
@@ -169,7 +169,8 @@ var BUILDER_PANEL_TYPES = {
169
169
  DELAY: "builder-delay",
170
170
  LEAD_TIME: "builder-lead-time",
171
171
  NAME: "builder-name",
172
- SCOPE: "builder-scope"
172
+ SCOPE: "builder-scope",
173
+ SCOPE_PHONE_FIELD: "builder-scope-phone-field"
173
174
  };
174
175
  var BUILDER_ANCHORS = {
175
176
  TRIGGER_ADD: "trigger-add",
@@ -186,9 +187,10 @@ var BUILDER_ANCHORS = {
186
187
  ACTION_RECIPIENT: "action-recipient",
187
188
  RULE_DELAY: "rule-delay",
188
189
  META_NAME: "meta-name",
189
- SCOPE: "scope"
190
+ SCOPE: "scope",
191
+ SCOPE_PHONE_FIELD: "scope-phone-field"
190
192
  };
191
- 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));
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(_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));
192
194
  var LARGE_PANEL_TYPES = [BUILDER_PANEL_TYPES.ACTION_CONFIG, BUILDER_PANEL_TYPES.SCOPE, BUILDER_PANEL_TYPES.NAME];
193
195
  var CONDITION_ANCHORS = [BUILDER_ANCHORS.COND_FIELD, BUILDER_ANCHORS.COND_OP_TOGGLE, BUILDER_ANCHORS.COND_VALUES, BUILDER_ANCHORS.COND_CONNECTOR];
194
196
  var ACTION_ANCHORS = [BUILDER_ANCHORS.ACTION_CHANNEL, BUILDER_ANCHORS.ACTION_CONFIG, BUILDER_ANCHORS.ACTION_RECIPIENT];
@@ -292,6 +294,9 @@ var isMultiValueVerb = function isMultiValueVerb(verb) {
292
294
  var sentencify = function sentencify(label) {
293
295
  return label ? label.charAt(0).toLowerCase() + label.slice(1) : label;
294
296
  };
297
+ var copyFor = function copyFor(value, args) {
298
+ return typeof value === "function" ? value(args) : value;
299
+ };
295
300
  var matchesTrigger = function matchesTrigger(name) {
296
301
  return function (option) {
297
302
  return option.eventValue === name || option.value === name || option.id === name;
@@ -455,24 +460,77 @@ var hasAction = function hasAction(rule) {
455
460
  var isRuleComplete = function isRuleComplete(rule) {
456
461
  return hasTrigger(rule) && hasAction(rule);
457
462
  };
458
- var invalidScopeIndexes = function invalidScopeIndexes(_ref12) {
463
+ var scopeOptionFor = function scopeOptionFor(_ref12) {
464
+ var _item$value, _schema$scope;
465
+ var schema = _ref12.schema,
466
+ item = _ref12.item;
467
+ var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
468
+ return ((schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.options) || []).find(function (candidate) {
469
+ var _candidate$value2;
470
+ return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
471
+ });
472
+ };
473
+ var scopePhoneFields = function scopePhoneFields(_ref13) {
474
+ var _ref14, _item$phoneFields, _scopeOptionFor;
475
+ var schema = _ref13.schema,
476
+ item = _ref13.item;
477
+ return (_ref14 = (_item$phoneFields = item === null || item === void 0 ? void 0 : item.phoneFields) !== null && _item$phoneFields !== void 0 ? _item$phoneFields : (_scopeOptionFor = scopeOptionFor({
478
+ schema: schema,
479
+ item: item
480
+ })) === null || _scopeOptionFor === void 0 ? void 0 : _scopeOptionFor.phoneFields) !== null && _ref14 !== void 0 ? _ref14 : null;
481
+ };
482
+ var effectiveScopePhoneField = function effectiveScopePhoneField(_ref15) {
483
+ var schema = _ref15.schema,
484
+ item = _ref15.item;
485
+ if (item !== null && item !== void 0 && item.phoneField) return item.phoneField;
486
+ var phoneFields = scopePhoneFields({
487
+ schema: schema,
488
+ item: item
489
+ });
490
+ return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].value : undefined;
491
+ };
492
+ var invalidScopeIndexes = function invalidScopeIndexes(_ref16) {
459
493
  var _scope$requiresPhone;
460
- var rule = _ref12.rule,
461
- schema = _ref12.schema;
494
+ var rule = _ref16.rule,
495
+ schema = _ref16.schema;
462
496
  var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
463
497
  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 [];
464
498
  return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
465
- var _item$value, _item$hasPhoneField;
466
- var value = (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
467
- var option = (scope.options || []).find(function (candidate) {
468
- var _candidate$value2;
469
- return ((_candidate$value2 = candidate.value) !== null && _candidate$value2 !== void 0 ? _candidate$value2 : candidate.id) === value;
499
+ var _ref17, _item$hasPhoneField;
500
+ var option = scopeOptionFor({
501
+ schema: schema,
502
+ item: item
470
503
  });
471
- 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;
504
+ var phoneFields = scopePhoneFields({
505
+ schema: schema,
506
+ item: item
507
+ });
508
+ 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;
472
509
  if (hasPhoneField === false) indexes.push(index);
473
510
  return indexes;
474
511
  }, []);
475
512
  };
513
+ var invalidScopePhoneFieldIndexes = function invalidScopePhoneFieldIndexes(_ref18) {
514
+ var _scope$requiresPhone2;
515
+ var rule = _ref18.rule,
516
+ schema = _ref18.schema;
517
+ var scope = schema === null || schema === void 0 ? void 0 : schema.scope;
518
+ 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 [];
519
+ return ((rule === null || rule === void 0 ? void 0 : rule.scope) || []).reduce(function (indexes, item, index) {
520
+ var phoneFields = scopePhoneFields({
521
+ schema: schema,
522
+ item: item
523
+ });
524
+ var hasChoice = ((phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) || 0) > 1;
525
+ if (hasChoice && !effectiveScopePhoneField({
526
+ schema: schema,
527
+ item: item
528
+ })) {
529
+ indexes.push(index);
530
+ }
531
+ return indexes;
532
+ }, []);
533
+ };
476
534
  var minutesToParts = function minutesToParts(minutes) {
477
535
  var total = Number(minutes) || 0;
478
536
  if (total && total % UNIT_MINUTES.days === 0) {
@@ -492,9 +550,9 @@ var minutesToParts = function minutesToParts(minutes) {
492
550
  unit: "minutes"
493
551
  };
494
552
  };
495
- var partsToMinutes = function partsToMinutes(_ref13) {
496
- var value = _ref13.value,
497
- unit = _ref13.unit;
553
+ var partsToMinutes = function partsToMinutes(_ref19) {
554
+ var value = _ref19.value,
555
+ unit = _ref19.unit;
498
556
  return (
499
557
  // eslint-disable-next-line security/detect-object-injection
500
558
  (Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
@@ -527,17 +585,17 @@ var modeFromJoinType = function modeFromJoinType(joinType) {
527
585
  };
528
586
 
529
587
  // eslint-disable-next-line security/detect-object-injection
530
- var valueAt = function valueAt(_ref14) {
588
+ var valueAt = function valueAt(_ref20) {
531
589
  var _values$key;
532
- var values = _ref14.values,
533
- key = _ref14.key;
590
+ var values = _ref20.values,
591
+ key = _ref20.key;
534
592
  return values === null || values === void 0 || (_values$key = values[key]) === null || _values$key === void 0 ? void 0 : _values$key.value;
535
593
  };
536
594
  var asArray = function asArray(maybeArray) {
537
595
  return Array.isArray(maybeArray) ? maybeArray : [];
538
596
  };
539
597
  var fieldKeysFromSchema = function fieldKeysFromSchema() {
540
- var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope;
598
+ var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope2;
541
599
  var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
542
600
  return {
543
601
  triggers: ((_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.fieldKey) || "events",
@@ -546,18 +604,18 @@ var fieldKeysFromSchema = function fieldKeysFromSchema() {
546
604
  actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
547
605
  delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
548
606
  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,
549
- scope: ((_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.fieldKey) || "meetingIds",
607
+ scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
550
608
  status: "status",
551
609
  name: "name"
552
610
  };
553
611
  };
554
612
  var valuesToRuleModel = function valuesToRuleModel() {
555
613
  var _valueAt, _conditions$;
556
- var _ref15 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
557
- _ref15$values = _ref15.values,
558
- values = _ref15$values === void 0 ? {} : _ref15$values,
559
- _ref15$schema = _ref15.schema,
560
- schema = _ref15$schema === void 0 ? {} : _ref15$schema;
614
+ var _ref21 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
615
+ _ref21$values = _ref21.values,
616
+ values = _ref21$values === void 0 ? {} : _ref21$values,
617
+ _ref21$schema = _ref21.schema,
618
+ schema = _ref21$schema === void 0 ? {} : _ref21$schema;
561
619
  var keys = fieldKeysFromSchema(schema);
562
620
  var conditions = asArray(valueAt({
563
621
  values: values,
@@ -601,42 +659,42 @@ var valuesToRuleModel = function valuesToRuleModel() {
601
659
  }))
602
660
  };
603
661
  };
604
- var setTriggers = function setTriggers(_ref16) {
605
- var schema = _ref16.schema,
606
- triggers = _ref16.triggers;
662
+ var setTriggers = function setTriggers(_ref22) {
663
+ var schema = _ref22.schema,
664
+ triggers = _ref22.triggers;
607
665
  return {
608
666
  path: "".concat(fieldKeysFromSchema(schema).triggers, ".value"),
609
667
  value: triggers
610
668
  };
611
669
  };
612
- var setPerformer = function setPerformer(_ref17) {
613
- var schema = _ref17.schema,
614
- performer = _ref17.performer;
670
+ var setPerformer = function setPerformer(_ref23) {
671
+ var schema = _ref23.schema,
672
+ performer = _ref23.performer;
615
673
  return {
616
674
  path: "".concat(fieldKeysFromSchema(schema).performer, ".value"),
617
675
  value: performer
618
676
  };
619
677
  };
620
- var setActions = function setActions(_ref18) {
621
- var schema = _ref18.schema,
622
- actions = _ref18.actions;
678
+ var setActions = function setActions(_ref24) {
679
+ var schema = _ref24.schema,
680
+ actions = _ref24.actions;
623
681
  return {
624
682
  path: "".concat(fieldKeysFromSchema(schema).actions, ".value"),
625
683
  value: actions
626
684
  };
627
685
  };
628
- var setConditions = function setConditions(_ref19) {
629
- var schema = _ref19.schema,
630
- conditions = _ref19.conditions;
686
+ var setConditions = function setConditions(_ref25) {
687
+ var schema = _ref25.schema,
688
+ conditions = _ref25.conditions;
631
689
  return {
632
690
  path: "".concat(fieldKeysFromSchema(schema).conditions, ".value"),
633
691
  value: conditions
634
692
  };
635
693
  };
636
- var setConditionMode = function setConditionMode(_ref20) {
637
- var schema = _ref20.schema,
638
- conditions = _ref20.conditions,
639
- joinType = _ref20.joinType;
694
+ var setConditionMode = function setConditionMode(_ref26) {
695
+ var schema = _ref26.schema,
696
+ conditions = _ref26.conditions,
697
+ joinType = _ref26.joinType;
640
698
  return setConditions({
641
699
  schema: schema,
642
700
  conditions: conditions.map(function (condition) {
@@ -644,34 +702,34 @@ var setConditionMode = function setConditionMode(_ref20) {
644
702
  })
645
703
  });
646
704
  };
647
- var setDelay = function setDelay(_ref21) {
648
- var schema = _ref21.schema,
649
- delay = _ref21.delay;
705
+ var setDelay = function setDelay(_ref27) {
706
+ var schema = _ref27.schema,
707
+ delay = _ref27.delay;
650
708
  return {
651
709
  path: "".concat(fieldKeysFromSchema(schema).delay, ".value"),
652
710
  value: delay !== null && delay !== void 0 ? delay : {}
653
711
  };
654
712
  };
655
- var setActive = function setActive(_ref22) {
656
- var schema = _ref22.schema,
657
- active = _ref22.active;
713
+ var setActive = function setActive(_ref28) {
714
+ var schema = _ref28.schema,
715
+ active = _ref28.active;
658
716
  return {
659
717
  path: "".concat(fieldKeysFromSchema(schema).status, ".value"),
660
718
  value: active ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED
661
719
  };
662
720
  };
663
- var setScope = function setScope(_ref23) {
664
- var schema = _ref23.schema,
665
- scope = _ref23.scope;
721
+ var setScope = function setScope(_ref29) {
722
+ var schema = _ref29.schema,
723
+ scope = _ref29.scope;
666
724
  return {
667
725
  path: "".concat(fieldKeysFromSchema(schema).scope, ".value"),
668
726
  value: scope
669
727
  };
670
728
  };
671
- var removeArrayItem = function removeArrayItem(_ref24) {
672
- var values = _ref24.values,
673
- fieldKey = _ref24.fieldKey,
674
- index = _ref24.index;
729
+ var removeArrayItem = function removeArrayItem(_ref30) {
730
+ var values = _ref30.values,
731
+ fieldKey = _ref30.fieldKey,
732
+ index = _ref30.index;
675
733
  var list = asArray(valueAt({
676
734
  values: values,
677
735
  key: fieldKey
@@ -1031,7 +1089,7 @@ var itemLabel = function itemLabel(item) {
1031
1089
  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 : "");
1032
1090
  };
1033
1091
  var ScopeBlock = function ScopeBlock(_ref) {
1034
- var _schema$scope;
1092
+ var _schema$scope, _schema$scope2, _schema$scope2$requir;
1035
1093
  var rule = _ref.rule,
1036
1094
  schema = _ref.schema,
1037
1095
  handleToken = _ref.onToken,
@@ -1048,6 +1106,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1048
1106
  t = _useTranslation.t;
1049
1107
  var scope = rule.scope || [];
1050
1108
  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");
1109
+ 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 || []));
1051
1110
  if (isEmpty(scope)) {
1052
1111
  return /*#__PURE__*/jsx("div", {
1053
1112
  className: "mb-row",
@@ -1077,6 +1136,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1077
1136
  isActive: isActive,
1078
1137
  isInvalid: isInvalid,
1079
1138
  item: item,
1139
+ requiresPhone: requiresPhone,
1080
1140
  schema: schema,
1081
1141
  isLast: index === scope.length - 1,
1082
1142
  key: ((_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item) || index,
@@ -1086,7 +1146,7 @@ var ScopeBlock = function ScopeBlock(_ref) {
1086
1146
  });
1087
1147
  };
1088
1148
  var ScopeRow = function ScopeRow(_ref2) {
1089
- var _schema$scope2;
1149
+ var _schema$scope3, _schema$scope4, _schema$scope5;
1090
1150
  var schema = _ref2.schema,
1091
1151
  item = _ref2.item,
1092
1152
  index = _ref2.index,
@@ -1094,13 +1154,30 @@ var ScopeRow = function ScopeRow(_ref2) {
1094
1154
  handleRemoveScope = _ref2.onRemoveScope,
1095
1155
  isActive = _ref2.isActive,
1096
1156
  isInvalid = _ref2.isInvalid,
1097
- isLast = _ref2.isLast;
1157
+ isLast = _ref2.isLast,
1158
+ requiresPhone = _ref2.requiresPhone;
1098
1159
  var _useTranslation2 = useTranslation(),
1099
1160
  t = _useTranslation2.t;
1100
1161
  var _useClearingHover = useClearingHover(),
1101
1162
  clearing = _useClearingHover.clearing,
1102
1163
  clearingHoverProps = _useClearingHover.clearingHoverProps;
1103
- 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");
1164
+ 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");
1165
+ var meeting = itemLabel(item);
1166
+ var phoneFields = requiresPhone ? scopePhoneFields({
1167
+ item: item,
1168
+ schema: schema
1169
+ }) : null;
1170
+ var hasPhoneFieldChoice = ((phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) || 0) > 1;
1171
+ var singlePhoneFieldLabel = (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? phoneFields[0].label : null;
1172
+ var selectedPhoneField = phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.find(function (field) {
1173
+ return field.value === (item === null || item === void 0 ? void 0 : item.phoneField);
1174
+ });
1175
+ var usingLabel = copyFor(schema === null || schema === void 0 || (_schema$scope4 = schema.scope) === null || _schema$scope4 === void 0 ? void 0 : _schema$scope4.usingLabel, {
1176
+ meeting: meeting
1177
+ }) || t("neetoRules.builder.scope.using");
1178
+ var phoneFieldPlaceholder = copyFor(schema === null || schema === void 0 || (_schema$scope5 = schema.scope) === null || _schema$scope5 === void 0 ? void 0 : _schema$scope5.phoneFieldPlaceholder, {
1179
+ meeting: meeting
1180
+ }) || t("neetoRules.builder.selectPhoneField");
1104
1181
  return /*#__PURE__*/jsxs("div", {
1105
1182
  className: classNames("mb-row", {
1106
1183
  clearing: clearing
@@ -1125,7 +1202,33 @@ var ScopeRow = function ScopeRow(_ref2) {
1125
1202
  type: BUILDER_ANCHORS.SCOPE
1126
1203
  });
1127
1204
  },
1128
- children: itemLabel(item)
1205
+ children: meeting
1206
+ }), singlePhoneFieldLabel && /*#__PURE__*/jsxs("span", {
1207
+ className: "mb-fixed",
1208
+ children: [usingLabel, " ", singlePhoneFieldLabel]
1209
+ }), hasPhoneFieldChoice && /*#__PURE__*/jsxs(Fragment, {
1210
+ children: [/*#__PURE__*/jsx("span", {
1211
+ className: "mb-fixed",
1212
+ children: usingLabel
1213
+ }), /*#__PURE__*/jsx(Token, {
1214
+ dataTestid: "scope-phone-field-".concat(index),
1215
+ active: isActive({
1216
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1217
+ index: index
1218
+ }),
1219
+ invalid: isInvalid({
1220
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1221
+ index: index
1222
+ }),
1223
+ state: selectedPhoneField ? TOKEN_STATE.FILLED : TOKEN_STATE.MUTED,
1224
+ onClick: handleToken && function () {
1225
+ return handleToken({
1226
+ type: BUILDER_ANCHORS.SCOPE_PHONE_FIELD,
1227
+ index: index
1228
+ });
1229
+ },
1230
+ children: (selectedPhoneField === null || selectedPhoneField === void 0 ? void 0 : selectedPhoneField.label) || phoneFieldPlaceholder
1231
+ })]
1129
1232
  })]
1130
1233
  }), /*#__PURE__*/jsxs("div", {
1131
1234
  className: "mb-row-actions",
@@ -1786,47 +1889,58 @@ var actionAt = function actionAt(_ref3) {
1786
1889
  index = _ref3.index;
1787
1890
  return rule.actions[index] || {};
1788
1891
  };
1789
- var findField = function findField(_ref4) {
1892
+
1893
+ // eslint-disable-next-line security/detect-object-injection
1894
+ var scopeItemAt = function scopeItemAt(_ref4) {
1895
+ var _rule$scope;
1896
+ var rule = _ref4.rule,
1897
+ index = _ref4.index;
1898
+ return ((_rule$scope = rule.scope) === null || _rule$scope === void 0 ? void 0 : _rule$scope[index]) || {};
1899
+ };
1900
+ var scopeItemLabel = function scopeItemLabel(item) {
1901
+ 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 : "");
1902
+ };
1903
+ var findField = function findField(_ref5) {
1790
1904
  var _schema$conditions;
1791
- var schema = _ref4.schema,
1792
- value = _ref4.value;
1905
+ var schema = _ref5.schema,
1906
+ value = _ref5.value;
1793
1907
  return (((_schema$conditions = schema.conditions) === null || _schema$conditions === void 0 ? void 0 : _schema$conditions.fields) || []).find(function (field) {
1794
1908
  return optionValue(field) === value;
1795
1909
  });
1796
1910
  };
1797
- var findActionOption = function findActionOption(_ref5) {
1911
+ var findActionOption = function findActionOption(_ref6) {
1798
1912
  var _schema$actions;
1799
- var schema = _ref5.schema,
1800
- name = _ref5.name;
1913
+ var schema = _ref6.schema,
1914
+ name = _ref6.name;
1801
1915
  return (((_schema$actions = schema.actions) === null || _schema$actions === void 0 ? void 0 : _schema$actions.options) || []).find(function (option) {
1802
1916
  return optionValue(option) === name;
1803
1917
  });
1804
1918
  };
1805
- var channelOf = function channelOf(_ref6) {
1919
+ var channelOf = function channelOf(_ref7) {
1806
1920
  var _schema$actions2, _schema$actions2$acti;
1807
- var schema = _ref6.schema,
1808
- action = _ref6.action;
1921
+ var schema = _ref7.schema,
1922
+ action = _ref7.action;
1809
1923
  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);
1810
1924
  };
1811
- var recipientOf = function recipientOf(_ref7) {
1925
+ var recipientOf = function recipientOf(_ref8) {
1812
1926
  var _action$recipient, _schema$actions3, _schema$actions3$acti;
1813
- var schema = _ref7.schema,
1814
- action = _ref7.action;
1927
+ var schema = _ref8.schema,
1928
+ action = _ref8.action;
1815
1929
  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;
1816
1930
  };
1817
- var channelMetaOf = function channelMetaOf(_ref8) {
1931
+ var channelMetaOf = function channelMetaOf(_ref9) {
1818
1932
  var _schema$actions4;
1819
- var schema = _ref8.schema,
1820
- action = _ref8.action;
1933
+ var schema = _ref9.schema,
1934
+ action = _ref9.action;
1821
1935
  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({
1822
1936
  schema: schema,
1823
1937
  action: action
1824
1938
  })]) || {};
1825
1939
  };
1826
- var actionHasConfig = function actionHasConfig(_ref9) {
1940
+ var actionHasConfig = function actionHasConfig(_ref0) {
1827
1941
  var _schema$actions5, _schema$actions6;
1828
- var schema = _ref9.schema,
1829
- action = _ref9.action;
1942
+ var schema = _ref0.schema,
1943
+ action = _ref0.action;
1830
1944
  var meta = channelMetaOf({
1831
1945
  schema: schema,
1832
1946
  action: action
@@ -1840,10 +1954,10 @@ var actionHasConfig = function actionHasConfig(_ref9) {
1840
1954
  if ((_schema$actions5 = schema.actions) !== null && _schema$actions5 !== void 0 && _schema$actions5.hasConfig) return schema.actions.hasConfig(action);
1841
1955
  return !!((_schema$actions6 = schema.actions) !== null && _schema$actions6 !== void 0 && _schema$actions6.renderConfig);
1842
1956
  };
1843
- var recipientsFor = function recipientsFor(_ref0) {
1957
+ var recipientsFor = function recipientsFor(_ref1) {
1844
1958
  var _schema$actions7, _schema$actions8;
1845
- var schema = _ref0.schema,
1846
- action = _ref0.action;
1959
+ var schema = _ref1.schema,
1960
+ action = _ref1.action;
1847
1961
  var channel = channelOf({
1848
1962
  schema: schema,
1849
1963
  action: action
@@ -1858,11 +1972,11 @@ var recipientsFor = function recipientsFor(_ref0) {
1858
1972
  if (option !== null && option !== void 0 && option.recipients) return option.recipients;
1859
1973
  return ((_schema$actions8 = schema.actions) === null || _schema$actions8 === void 0 ? void 0 : _schema$actions8.recipients) || [];
1860
1974
  };
1861
- var nextTriggers = function nextTriggers(_ref1) {
1975
+ var nextTriggers = function nextTriggers(_ref10) {
1862
1976
  var _schema$triggers;
1863
- var schema = _ref1.schema,
1864
- rule = _ref1.rule,
1865
- value = _ref1.value;
1977
+ var schema = _ref10.schema,
1978
+ rule = _ref10.rule,
1979
+ value = _ref10.value;
1866
1980
  if ((_schema$triggers = schema.triggers) !== null && _schema$triggers !== void 0 && _schema$triggers.multi) {
1867
1981
  var names = pluck("name", rule.triggers);
1868
1982
  return names.includes(value) ? removeBy({
@@ -1875,12 +1989,12 @@ var nextTriggers = function nextTriggers(_ref1) {
1875
1989
  name: value
1876
1990
  }];
1877
1991
  };
1878
- var nextConditionAt = function nextConditionAt(_ref10) {
1992
+ var nextConditionAt = function nextConditionAt(_ref11) {
1879
1993
  var _field$allowMatching;
1880
- var schema = _ref10.schema,
1881
- rule = _ref10.rule,
1882
- index = _ref10.index,
1883
- value = _ref10.value;
1994
+ var schema = _ref11.schema,
1995
+ rule = _ref11.rule,
1996
+ index = _ref11.index,
1997
+ value = _ref11.value;
1884
1998
  var field = findField({
1885
1999
  schema: schema,
1886
2000
  value: value
@@ -1899,12 +2013,12 @@ var nextConditionAt = function nextConditionAt(_ref10) {
1899
2013
  metadata: {}
1900
2014
  });
1901
2015
  };
1902
- var nextActionAt = function nextActionAt(_ref11) {
2016
+ var nextActionAt = function nextActionAt(_ref12) {
1903
2017
  var _schema$actions9;
1904
- var schema = _ref11.schema,
1905
- rule = _ref11.rule,
1906
- index = _ref11.index,
1907
- value = _ref11.value;
2018
+ var schema = _ref12.schema,
2019
+ rule = _ref12.rule,
2020
+ index = _ref12.index,
2021
+ value = _ref12.value;
1908
2022
  if (!((_schema$actions9 = schema.actions) !== null && _schema$actions9 !== void 0 && _schema$actions9.resolveName)) {
1909
2023
  var option = findActionOption({
1910
2024
  schema: schema,
@@ -1962,12 +2076,33 @@ var nextActionAt = function nextActionAt(_ref11) {
1962
2076
  metadata: channelChanged ? {} : prev.metadata
1963
2077
  });
1964
2078
  };
1965
- var nextActionRecipientAt = function nextActionRecipientAt(_ref12) {
2079
+ var appendScopeItem = function appendScopeItem(_ref13) {
2080
+ var _sc$requiresPhone;
2081
+ var schema = _ref13.schema,
2082
+ rule = _ref13.rule,
2083
+ value = _ref13.value;
2084
+ var sc = schema.scope || {};
2085
+ var option = (sc.options || []).find(function (candidate) {
2086
+ return optionValue(candidate) === value;
2087
+ }) || {
2088
+ value: value
2089
+ };
2090
+ var requiresPhone = ((_sc$requiresPhone = sc.requiresPhone) === null || _sc$requiresPhone === void 0 ? void 0 : _sc$requiresPhone.call(sc, rule.actions)) || false;
2091
+ if (!requiresPhone) return option;
2092
+ var phoneFields = scopePhoneFields({
2093
+ schema: schema,
2094
+ item: option
2095
+ });
2096
+ return (phoneFields === null || phoneFields === void 0 ? void 0 : phoneFields.length) === 1 ? _objectSpread$4(_objectSpread$4({}, option), {}, {
2097
+ phoneField: phoneFields[0].value
2098
+ }) : option;
2099
+ };
2100
+ var nextActionRecipientAt = function nextActionRecipientAt(_ref14) {
1966
2101
  var _schema$actions1;
1967
- var schema = _ref12.schema,
1968
- rule = _ref12.rule,
1969
- index = _ref12.index,
1970
- value = _ref12.value;
2102
+ var schema = _ref14.schema,
2103
+ rule = _ref14.rule,
2104
+ index = _ref14.index,
2105
+ value = _ref14.value;
1971
2106
  var prev = actionAt({
1972
2107
  rule: rule,
1973
2108
  index: index
@@ -1984,12 +2119,12 @@ var nextActionRecipientAt = function nextActionRecipientAt(_ref12) {
1984
2119
  }) : value
1985
2120
  });
1986
2121
  };
1987
- var descriptorFor = function descriptorFor(_ref13) {
2122
+ var descriptorFor = function descriptorFor(_ref15) {
1988
2123
  var _schema$actor2, _schema$conditions2;
1989
- var anchor = _ref13.anchor,
1990
- schema = _ref13.schema,
1991
- rule = _ref13.rule,
1992
- index = _ref13.index;
2124
+ var anchor = _ref15.anchor,
2125
+ schema = _ref15.schema,
2126
+ rule = _ref15.rule,
2127
+ index = _ref15.index;
1993
2128
  switch (anchor) {
1994
2129
  case BUILDER_ANCHORS.TRIGGER_ADD:
1995
2130
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2179,13 +2314,13 @@ var descriptorFor = function descriptorFor(_ref13) {
2179
2314
  }
2180
2315
  case BUILDER_ANCHORS.SCOPE:
2181
2316
  {
2182
- var _sc$requiresPhone;
2317
+ var _sc$requiresPhone2;
2183
2318
  var sc = schema.scope || {};
2184
2319
  var selected = (rule.scope || []).map(function (item) {
2185
2320
  var _item$value;
2186
2321
  return (_item$value = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value !== void 0 ? _item$value : item;
2187
2322
  });
2188
- var requiresPhone = ((_sc$requiresPhone = sc.requiresPhone) === null || _sc$requiresPhone === void 0 ? void 0 : _sc$requiresPhone.call(sc, rule.actions)) || false;
2323
+ var requiresPhone = ((_sc$requiresPhone2 = sc.requiresPhone) === null || _sc$requiresPhone2 === void 0 ? void 0 : _sc$requiresPhone2.call(sc, rule.actions)) || false;
2189
2324
  return {
2190
2325
  title: selected.length ? sc.paneChangeTitle || t("neetoRules.builder.panes.scopeChangeTitle") : sc.paneTitle || t("neetoRules.builder.panes.scopeTitle"),
2191
2326
  subtitle: sc.paneSubtitle || t("neetoRules.builder.panes.scopeSubtitle"),
@@ -2205,6 +2340,36 @@ var descriptorFor = function descriptorFor(_ref13) {
2205
2340
  selectedValues: selected
2206
2341
  };
2207
2342
  }
2343
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2344
+ {
2345
+ var _sc = schema.scope || {};
2346
+ var item = scopeItemAt({
2347
+ rule: rule,
2348
+ index: index
2349
+ });
2350
+ var meeting = scopeItemLabel(item);
2351
+ var options = scopePhoneFields({
2352
+ schema: schema,
2353
+ item: item
2354
+ }) || [];
2355
+ return {
2356
+ title: copyFor(_sc.phoneFieldPaneTitle, {
2357
+ meeting: meeting
2358
+ }) || t("neetoRules.builder.panes.phoneFieldTitle"),
2359
+ subtitle: copyFor(_sc.phoneFieldPaneSubtitle, {
2360
+ meeting: meeting
2361
+ }) || t("neetoRules.builder.panes.phoneFieldSubtitle", {
2362
+ meeting: meeting
2363
+ }),
2364
+ options: options.map(function (option) {
2365
+ return {
2366
+ label: option.label,
2367
+ value: optionValue(option)
2368
+ };
2369
+ }),
2370
+ selectedValues: [item.phoneField]
2371
+ };
2372
+ }
2208
2373
  default:
2209
2374
  return {
2210
2375
  title: "",
@@ -2214,13 +2379,13 @@ var descriptorFor = function descriptorFor(_ref13) {
2214
2379
  };
2215
2380
  }
2216
2381
  };
2217
- var commitFor = function commitFor(_ref14) {
2218
- var anchor = _ref14.anchor,
2219
- schema = _ref14.schema,
2220
- rule = _ref14.rule,
2221
- index = _ref14.index,
2222
- value = _ref14.value,
2223
- helpers = _ref14.helpers;
2382
+ var commitFor = function commitFor(_ref16) {
2383
+ var anchor = _ref16.anchor,
2384
+ schema = _ref16.schema,
2385
+ rule = _ref16.rule,
2386
+ index = _ref16.index,
2387
+ value = _ref16.value,
2388
+ helpers = _ref16.helpers;
2224
2389
  var setTriggers = helpers.setTriggers,
2225
2390
  setPerformer = helpers.setPerformer,
2226
2391
  setConditionMode = helpers.setConditionMode,
@@ -2293,8 +2458,7 @@ var commitFor = function commitFor(_ref14) {
2293
2458
  }
2294
2459
  case BUILDER_ANCHORS.SCOPE:
2295
2460
  {
2296
- var sc = schema.scope || {};
2297
- var key = sc.fieldKey || "scope";
2461
+ var key = fieldKeys.scope;
2298
2462
  var current = rule.scope || [];
2299
2463
  var has = current.some(function (item) {
2300
2464
  var _item$value2;
@@ -2303,24 +2467,30 @@ var commitFor = function commitFor(_ref14) {
2303
2467
  var next = has ? current.filter(function (item) {
2304
2468
  var _item$value3;
2305
2469
  return ((_item$value3 = item === null || item === void 0 ? void 0 : item.value) !== null && _item$value3 !== void 0 ? _item$value3 : item) !== value;
2306
- }) : [].concat(_toConsumableArray(current), [(sc.options || []).find(function (option) {
2307
- return optionValue(option) === value;
2308
- }) || {
2470
+ }) : [].concat(_toConsumableArray(current), [appendScopeItem({
2471
+ schema: schema,
2472
+ rule: rule,
2309
2473
  value: value
2310
- }]);
2474
+ })]);
2311
2475
  setFieldValue("".concat(key, ".value"), next);
2312
2476
  return "stay";
2313
2477
  }
2478
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2479
+ {
2480
+ var _key = fieldKeys.scope;
2481
+ setFieldValue("".concat(_key, ".value.").concat(index, ".phoneField"), value);
2482
+ return "stay";
2483
+ }
2314
2484
  default:
2315
2485
  return "close";
2316
2486
  }
2317
2487
  };
2318
- var continueTargetFor = function continueTargetFor(_ref15) {
2488
+ var continueTargetFor = function continueTargetFor(_ref17) {
2319
2489
  var _schema$actor3;
2320
- var anchor = _ref15.anchor,
2321
- schema = _ref15.schema,
2322
- rule = _ref15.rule,
2323
- index = _ref15.index;
2490
+ var anchor = _ref17.anchor,
2491
+ schema = _ref17.schema,
2492
+ rule = _ref17.rule,
2493
+ index = _ref17.index;
2324
2494
  switch (anchor) {
2325
2495
  case BUILDER_ANCHORS.TRIGGER_ADD:
2326
2496
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2393,21 +2563,21 @@ var continueTargetFor = function continueTargetFor(_ref15) {
2393
2563
  return null;
2394
2564
  }
2395
2565
  };
2396
- var replaceAt = function replaceAt(_ref16) {
2397
- var list = _ref16.list,
2398
- index = _ref16.index,
2399
- item = _ref16.item;
2566
+ var replaceAt = function replaceAt(_ref18) {
2567
+ var list = _ref18.list,
2568
+ index = _ref18.index,
2569
+ item = _ref18.item;
2400
2570
  var next = _toConsumableArray(list);
2401
2571
  // eslint-disable-next-line security/detect-object-injection
2402
2572
  next[index] = item;
2403
2573
  return next;
2404
2574
  };
2405
- var applyPreview = function applyPreview(_ref17) {
2406
- var rule = _ref17.rule,
2407
- schema = _ref17.schema,
2408
- anchor = _ref17.anchor,
2409
- index = _ref17.index,
2410
- value = _ref17.value;
2575
+ var applyPreview = function applyPreview(_ref19) {
2576
+ var rule = _ref19.rule,
2577
+ schema = _ref19.schema,
2578
+ anchor = _ref19.anchor,
2579
+ index = _ref19.index,
2580
+ value = _ref19.value;
2411
2581
  switch (anchor) {
2412
2582
  case BUILDER_ANCHORS.TRIGGER_ADD:
2413
2583
  case BUILDER_ANCHORS.TRIGGER_REPLACE:
@@ -2483,6 +2653,19 @@ var applyPreview = function applyPreview(_ref17) {
2483
2653
  })
2484
2654
  })
2485
2655
  });
2656
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2657
+ return _objectSpread$4(_objectSpread$4({}, rule), {}, {
2658
+ scope: replaceAt({
2659
+ list: rule.scope,
2660
+ index: index,
2661
+ item: _objectSpread$4(_objectSpread$4({}, scopeItemAt({
2662
+ rule: rule,
2663
+ index: index
2664
+ })), {}, {
2665
+ phoneField: value
2666
+ })
2667
+ })
2668
+ });
2486
2669
  default:
2487
2670
  return rule;
2488
2671
  }
@@ -2548,6 +2731,9 @@ var Canvas = function Canvas(_ref) {
2548
2731
  if (isEmpty(flatErrors) && isRuleComplete(rule) && isEmpty(invalidScopeIndexes({
2549
2732
  rule: rule,
2550
2733
  schema: schema
2734
+ })) && isEmpty(invalidScopePhoneFieldIndexes({
2735
+ rule: rule,
2736
+ schema: schema
2551
2737
  }))) {
2552
2738
  return undefined;
2553
2739
  }
@@ -2640,6 +2826,11 @@ var Canvas = function Canvas(_ref) {
2640
2826
  rule: rule,
2641
2827
  schema: schema
2642
2828
  }).includes(index);
2829
+ case BUILDER_ANCHORS.SCOPE_PHONE_FIELD:
2830
+ return invalidScopePhoneFieldIndexes({
2831
+ rule: rule,
2832
+ schema: schema
2833
+ }).includes(index);
2643
2834
  case BUILDER_ANCHORS.META_NAME:
2644
2835
  return hasErrorAt({
2645
2836
  prefix: "".concat(fieldKeys.name, ".value")
@@ -2692,7 +2883,11 @@ var Canvas = function Canvas(_ref) {
2692
2883
  var isScopeComplete = !(schema !== null && schema !== void 0 && (_schema$scope2 = schema.scope) !== null && _schema$scope2 !== void 0 && _schema$scope2.enabled) || isNotEmpty(rule.scope || []);
2693
2884
  var isComplete = isRuleComplete(rule) && isScopeComplete;
2694
2885
  var handleRemoveScope = function handleRemoveScope(index) {
2695
- return setScope((rule.scope || []).filter(function (_, i) {
2886
+ closePaneIfTargeting({
2887
+ anchors: [BUILDER_ANCHORS.SCOPE_PHONE_FIELD],
2888
+ index: index
2889
+ });
2890
+ setScope((rule.scope || []).filter(function (_, i) {
2696
2891
  return i !== index;
2697
2892
  }));
2698
2893
  };
@@ -2841,6 +3036,25 @@ var Canvas = function Canvas(_ref) {
2841
3036
  });
2842
3037
  };
2843
3038
 
3039
+ var ACTION_CONFIG_TYPES = {
3040
+ emailChannel: "emailChannel",
3041
+ multiSelect: "multiSelect",
3042
+ dropdown: "dropdown",
3043
+ note: "note",
3044
+ textarea: "textarea",
3045
+ number: "number",
3046
+ text: "text",
3047
+ regex: "regex",
3048
+ decimal: "decimal",
3049
+ date: "date"
3050
+ };
3051
+ var CONDITION_VALUE_TYPES = {
3052
+ multiSelect: "multi-select",
3053
+ multiSelectCreate: "multi-select-create",
3054
+ number: "number",
3055
+ email: "email"
3056
+ };
3057
+
2844
3058
  var restoreTokens = function restoreTokens(text) {
2845
3059
  return text ? text.replace(/\[\[/g, "{{").replace(/\]\]/g, "}}") : text;
2846
3060
  };
@@ -2890,7 +3104,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2890
3104
  className: "mb-pane-empty",
2891
3105
  children: t("neetoRules.builder.noMatches")
2892
3106
  });
2893
- if (type === "emailChannel") {
3107
+ if (type === ACTION_CONFIG_TYPES.emailChannel) {
2894
3108
  var _getIn, _action$metadata;
2895
3109
  var subjectPath = "".concat(name, ".subject");
2896
3110
  var bodyPath = "".concat(name, ".body");
@@ -2919,7 +3133,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2919
3133
  }), hintBlock]
2920
3134
  });
2921
3135
  }
2922
- if (type === "multiSelect") {
3136
+ if (type === ACTION_CONFIG_TYPES.multiSelect) {
2923
3137
  if (isEmpty(options)) return noOptionsMessage();
2924
3138
  var current = getIn(values, valuePath) || [];
2925
3139
  var filtered = filterOptions(options);
@@ -2944,7 +3158,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2944
3158
  })]
2945
3159
  });
2946
3160
  }
2947
- if (type === "dropdown") {
3161
+ if (type === ACTION_CONFIG_TYPES.dropdown) {
2948
3162
  if (isEmpty(options)) return noOptionsMessage();
2949
3163
  var _current = getIn(values, valuePath);
2950
3164
  var _filtered = filterOptions(options);
@@ -2970,7 +3184,7 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2970
3184
  })
2971
3185
  });
2972
3186
  }
2973
- if (type === "note") {
3187
+ if (type === ACTION_CONFIG_TYPES.note) {
2974
3188
  var _action$metadata2;
2975
3189
  return /*#__PURE__*/jsxs("div", {
2976
3190
  className: "flex flex-col gap-2",
@@ -2984,9 +3198,9 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
2984
3198
  }), hintBlock]
2985
3199
  });
2986
3200
  }
2987
- if (type === "textarea" || type === "number") {
3201
+ if (type === ACTION_CONFIG_TYPES.textarea || type === ACTION_CONFIG_TYPES.number) {
2988
3202
  var _getIn2, _getIn3;
2989
- return type === "number" ? /*#__PURE__*/jsx(Input, {
3203
+ return type === ACTION_CONFIG_TYPES.number ? /*#__PURE__*/jsx(Input, {
2990
3204
  required: true,
2991
3205
  error: fieldError(valuePath),
2992
3206
  label: t("neetoRules.builder.config.value"),
@@ -3014,6 +3228,46 @@ var ActionConfigFields = function ActionConfigFields(_ref) {
3014
3228
  }
3015
3229
  });
3016
3230
  }
3231
+ if (type === ACTION_CONFIG_TYPES.text || type === ACTION_CONFIG_TYPES.regex || type === ACTION_CONFIG_TYPES.decimal) {
3232
+ var _getIn4;
3233
+ return /*#__PURE__*/jsxs("div", {
3234
+ className: "flex flex-col gap-2",
3235
+ children: [/*#__PURE__*/jsx(Input, {
3236
+ required: true,
3237
+ error: fieldError(valuePath),
3238
+ label: t("neetoRules.builder.config.value"),
3239
+ placeholder: option === null || option === void 0 ? void 0 : option.valuePlaceholder,
3240
+ size: "large",
3241
+ value: (_getIn4 = getIn(values, valuePath)) !== null && _getIn4 !== void 0 ? _getIn4 : "",
3242
+ onBlur: function onBlur() {
3243
+ return setFieldTouched(valuePath, true);
3244
+ },
3245
+ onChange: function onChange(event) {
3246
+ return setFieldValue(valuePath, event.target.value);
3247
+ }
3248
+ }), hintBlock]
3249
+ });
3250
+ }
3251
+ if (type === ACTION_CONFIG_TYPES.date) {
3252
+ return /*#__PURE__*/jsxs("div", {
3253
+ className: "flex flex-col gap-2",
3254
+ children: [/*#__PURE__*/jsx(DatePicker, {
3255
+ required: true,
3256
+ error: fieldError(valuePath),
3257
+ label: t("neetoRules.builder.config.value"),
3258
+ type: "date",
3259
+ value: getIn(values, valuePath) || "",
3260
+ onBlur: function onBlur() {
3261
+ return setFieldTouched(valuePath, true);
3262
+ },
3263
+ onChange: function onChange(date) {
3264
+ return setFieldValue(valuePath,
3265
+ // eslint-disable-next-line @bigbinary/neeto/use-standard-date-time-formats
3266
+ date ? dayjs(date).format(DATE_FORMAT) : "");
3267
+ }
3268
+ }), hintBlock]
3269
+ });
3270
+ }
3017
3271
  return /*#__PURE__*/jsx(Typography, {
3018
3272
  style: "body2",
3019
3273
  children: t("neetoRules.builder.noConfig")
@@ -3993,7 +4247,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
3993
4247
  className: "mb-pane-empty",
3994
4248
  children: t("neetoRules.builder.noMatches")
3995
4249
  });
3996
- if (type === "multi-select" && isNotEmpty(enumOptions)) {
4250
+ if (type === CONDITION_VALUE_TYPES.multiSelect && isNotEmpty(enumOptions)) {
3997
4251
  var current = getIn(values, valuesPath) || [];
3998
4252
  var filtered = filterOptions(enumOptions);
3999
4253
  if (term && isEmpty(filtered)) return noMatches;
@@ -4017,7 +4271,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
4017
4271
  })]
4018
4272
  });
4019
4273
  }
4020
- if (type === "multi-select") {
4274
+ if (type === CONDITION_VALUE_TYPES.multiSelect) {
4021
4275
  return /*#__PURE__*/jsx(Typography, {
4022
4276
  className: "neeto-ui-text-gray-500",
4023
4277
  style: "body2",
@@ -4026,7 +4280,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
4026
4280
  }) : t("neetoRules.builder.config.noOptions")
4027
4281
  });
4028
4282
  }
4029
- if (type === "multi-select-create") {
4283
+ if (type === CONDITION_VALUE_TYPES.multiSelectCreate) {
4030
4284
  var _current = getIn(values, valuesPath) || [];
4031
4285
  return /*#__PURE__*/jsx(Select$1, {
4032
4286
  autoFocus: true,
@@ -4068,7 +4322,7 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
4068
4322
  })
4069
4323
  });
4070
4324
  }
4071
- if (valueType === "number") {
4325
+ if (valueType === CONDITION_VALUE_TYPES.number) {
4072
4326
  var _getIn;
4073
4327
  return /*#__PURE__*/jsx(Input, {
4074
4328
  autoFocus: true,
@@ -4092,8 +4346,8 @@ var ConditionValueFields = function ConditionValueFields(_ref) {
4092
4346
  label: t("neetoRules.common.value"),
4093
4347
  name: valuePath,
4094
4348
  size: "large",
4095
- type: valueType === "email" ? "email" : "text",
4096
- placeholder: (field === null || field === void 0 ? void 0 : field.placeholder) || (valueType === "email" ? t("neetoRules.builder.config.exampleEmail") : undefined)
4349
+ type: valueType === CONDITION_VALUE_TYPES.email ? "email" : "text",
4350
+ placeholder: (field === null || field === void 0 ? void 0 : field.placeholder) || (valueType === CONDITION_VALUE_TYPES.email ? t("neetoRules.builder.config.exampleEmail") : undefined)
4097
4351
  });
4098
4352
  };
4099
4353
 
@@ -4196,12 +4450,14 @@ var BUILDER_PANEL_TYPE_CONFIG_MAP = (_BUILDER_PANEL_TYPE_C = {}, _defineProperty
4196
4450
  component: ConfigPane
4197
4451
  }), BUILDER_PANEL_TYPES.DELAY, {
4198
4452
  component: DelayPane
4199
- }), _defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.LEAD_TIME, {
4453
+ }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_BUILDER_PANEL_TYPE_C, BUILDER_PANEL_TYPES.LEAD_TIME, {
4200
4454
  component: LeadTimePane
4201
4455
  }), BUILDER_PANEL_TYPES.NAME, {
4202
4456
  component: NamePane
4203
4457
  }), BUILDER_PANEL_TYPES.SCOPE, {
4204
4458
  component: OptionsPane
4459
+ }), BUILDER_PANEL_TYPES.SCOPE_PHONE_FIELD, {
4460
+ component: OptionsPane
4205
4461
  }));
4206
4462
 
4207
4463
  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; }
@@ -4280,6 +4536,9 @@ var Form = function Form(_ref) {
4280
4536
  if (!isRuleComplete(rule) || invalidScopeIndexes({
4281
4537
  rule: rule,
4282
4538
  schema: schema
4539
+ }).length || invalidScopePhoneFieldIndexes({
4540
+ rule: rule,
4541
+ schema: schema
4283
4542
  }).length) {
4284
4543
  formikBag.setSubmitting(false);
4285
4544
  return;