@inploi/plugin-chatbot 3.19.0 → 3.20.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.
@@ -1,474 +1,23 @@
1
- import { i as isString$1, g as getHeadOrThrow, a as invariant, A as AbortedError, N, k as kbToReadableSize, b as getFlowSubmissionsPayload, _, h, c as _$1, p, F, o as o$1, d as clsx, y, s as store, e as a$2, f as debounce$1, j as k, l as parse, m as picklist, n as isSubmissionOfType, C as Cn, q as parseAsync, V as ValiError, r as object, t as transform, u as maxLength, v as minLength, w as record, x as boolean, z as number, B as minValue, D as maxValue, E as custom, G as string, H as email, I as url, J as regex, K as cva, L as ERROR_MESSAGES } from "./index-18edb2f5.js";
1
+ import { g as get$1, i as isString$1, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, N, c as getFlowSubmissionsPayload, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as debounce$1, m as k, n as parse, q as picklist, r as isSubmissionOfType, C as Cn, t as parseAsync, V as ValiError, u as object, v as transform, w as maxLength, x as minLength, z as record, B as boolean, D as number, E as minValue, G as maxValue, H as custom, I as string, J as email, K as url, L as regex, M as cva, O as ERROR_MESSAGES } from "./index-41fa1f9a.js";
2
2
  import "@inploi/sdk";
3
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
4
- function getDefaultExportFromCjs(x) {
5
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
6
- }
7
- var isArray$3 = Array.isArray;
8
- var isArray_1 = isArray$3;
9
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
10
- var _freeGlobal = freeGlobal$1;
11
- var freeGlobal = _freeGlobal;
12
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
13
- var root$3 = freeGlobal || freeSelf || Function("return this")();
14
- var _root = root$3;
15
- var root$2 = _root;
16
- var Symbol$4 = root$2.Symbol;
17
- var _Symbol = Symbol$4;
18
- var Symbol$3 = _Symbol;
19
- var objectProto$4 = Object.prototype;
20
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
21
- var nativeObjectToString$1 = objectProto$4.toString;
22
- var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
23
- function getRawTag$1(value) {
24
- var isOwn = hasOwnProperty$3.call(value, symToStringTag$1), tag = value[symToStringTag$1];
25
- try {
26
- value[symToStringTag$1] = void 0;
27
- var unmasked = true;
28
- } catch (e) {
29
- }
30
- var result = nativeObjectToString$1.call(value);
31
- if (unmasked) {
32
- if (isOwn) {
33
- value[symToStringTag$1] = tag;
34
- } else {
35
- delete value[symToStringTag$1];
36
- }
37
- }
38
- return result;
39
- }
40
- var _getRawTag = getRawTag$1;
41
- var objectProto$3 = Object.prototype;
42
- var nativeObjectToString = objectProto$3.toString;
43
- function objectToString$1(value) {
44
- return nativeObjectToString.call(value);
45
- }
46
- var _objectToString = objectToString$1;
47
- var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
48
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
49
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
50
- function baseGetTag$2(value) {
51
- if (value == null) {
52
- return value === void 0 ? undefinedTag : nullTag;
53
- }
54
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
55
- }
56
- var _baseGetTag = baseGetTag$2;
57
- function isObjectLike$1(value) {
58
- return value != null && typeof value == "object";
59
- }
60
- var isObjectLike_1 = isObjectLike$1;
61
- var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
62
- var symbolTag = "[object Symbol]";
63
- function isSymbol$3(value) {
64
- return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
65
- }
66
- var isSymbol_1 = isSymbol$3;
67
- var isArray$2 = isArray_1, isSymbol$2 = isSymbol_1;
68
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
69
- function isKey$2(value, object2) {
70
- if (isArray$2(value)) {
71
- return false;
72
- }
73
- var type = typeof value;
74
- if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$2(value)) {
75
- return true;
76
- }
77
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object2 != null && value in Object(object2);
78
- }
79
- var _isKey = isKey$2;
80
- function isObject$3(value) {
81
- var type = typeof value;
82
- return value != null && (type == "object" || type == "function");
83
- }
84
- var isObject_1 = isObject$3;
85
- var baseGetTag = _baseGetTag, isObject$2 = isObject_1;
86
- var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
87
- function isFunction$2(value) {
88
- if (!isObject$2(value)) {
89
- return false;
90
- }
91
- var tag = baseGetTag(value);
92
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
93
- }
94
- var isFunction_1 = isFunction$2;
95
- var root$1 = _root;
96
- var coreJsData$1 = root$1["__core-js_shared__"];
97
- var _coreJsData = coreJsData$1;
98
- var coreJsData = _coreJsData;
99
- var maskSrcKey = function() {
100
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
101
- return uid ? "Symbol(src)_1." + uid : "";
102
- }();
103
- function isMasked$1(func) {
104
- return !!maskSrcKey && maskSrcKey in func;
105
- }
106
- var _isMasked = isMasked$1;
107
- var funcProto$1 = Function.prototype;
108
- var funcToString$1 = funcProto$1.toString;
109
- function toSource$1(func) {
110
- if (func != null) {
111
- try {
112
- return funcToString$1.call(func);
113
- } catch (e) {
114
- }
115
- try {
116
- return func + "";
117
- } catch (e) {
118
- }
119
- }
120
- return "";
121
- }
122
- var _toSource = toSource$1;
123
- var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$1 = isObject_1, toSource = _toSource;
124
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
125
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
126
- var funcProto = Function.prototype, objectProto$2 = Object.prototype;
127
- var funcToString = funcProto.toString;
128
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
129
- var reIsNative = RegExp(
130
- "^" + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
131
- );
132
- function baseIsNative$1(value) {
133
- if (!isObject$1(value) || isMasked(value)) {
134
- return false;
135
- }
136
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
137
- return pattern.test(toSource(value));
138
- }
139
- var _baseIsNative = baseIsNative$1;
140
- function getValue$1(object2, key) {
141
- return object2 == null ? void 0 : object2[key];
142
- }
143
- var _getValue = getValue$1;
144
- var baseIsNative = _baseIsNative, getValue = _getValue;
145
- function getNative$2(object2, key) {
146
- var value = getValue(object2, key);
147
- return baseIsNative(value) ? value : void 0;
148
- }
149
- var _getNative = getNative$2;
150
- var getNative$1 = _getNative;
151
- var nativeCreate$4 = getNative$1(Object, "create");
152
- var _nativeCreate = nativeCreate$4;
153
- var nativeCreate$3 = _nativeCreate;
154
- function hashClear$1() {
155
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
156
- this.size = 0;
157
- }
158
- var _hashClear = hashClear$1;
159
- function hashDelete$1(key) {
160
- var result = this.has(key) && delete this.__data__[key];
161
- this.size -= result ? 1 : 0;
162
- return result;
163
- }
164
- var _hashDelete = hashDelete$1;
165
- var nativeCreate$2 = _nativeCreate;
166
- var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
167
- var objectProto$1 = Object.prototype;
168
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
169
- function hashGet$1(key) {
170
- var data = this.__data__;
171
- if (nativeCreate$2) {
172
- var result = data[key];
173
- return result === HASH_UNDEFINED$1 ? void 0 : result;
174
- }
175
- return hasOwnProperty$1.call(data, key) ? data[key] : void 0;
176
- }
177
- var _hashGet = hashGet$1;
178
- var nativeCreate$1 = _nativeCreate;
179
- var objectProto = Object.prototype;
180
- var hasOwnProperty = objectProto.hasOwnProperty;
181
- function hashHas$1(key) {
182
- var data = this.__data__;
183
- return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty.call(data, key);
184
- }
185
- var _hashHas = hashHas$1;
186
- var nativeCreate = _nativeCreate;
187
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
188
- function hashSet$1(key, value) {
189
- var data = this.__data__;
190
- this.size += this.has(key) ? 0 : 1;
191
- data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
192
- return this;
193
- }
194
- var _hashSet = hashSet$1;
195
- var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
196
- function Hash$1(entries) {
197
- var index = -1, length = entries == null ? 0 : entries.length;
198
- this.clear();
199
- while (++index < length) {
200
- var entry = entries[index];
201
- this.set(entry[0], entry[1]);
202
- }
203
- }
204
- Hash$1.prototype.clear = hashClear;
205
- Hash$1.prototype["delete"] = hashDelete;
206
- Hash$1.prototype.get = hashGet;
207
- Hash$1.prototype.has = hashHas;
208
- Hash$1.prototype.set = hashSet;
209
- var _Hash = Hash$1;
210
- function listCacheClear$1() {
211
- this.__data__ = [];
212
- this.size = 0;
213
- }
214
- var _listCacheClear = listCacheClear$1;
215
- function eq$1(value, other) {
216
- return value === other || value !== value && other !== other;
217
- }
218
- var eq_1 = eq$1;
219
- var eq = eq_1;
220
- function assocIndexOf$4(array, key) {
221
- var length = array.length;
222
- while (length--) {
223
- if (eq(array[length][0], key)) {
224
- return length;
225
- }
226
- }
227
- return -1;
228
- }
229
- var _assocIndexOf = assocIndexOf$4;
230
- var assocIndexOf$3 = _assocIndexOf;
231
- var arrayProto = Array.prototype;
232
- var splice = arrayProto.splice;
233
- function listCacheDelete$1(key) {
234
- var data = this.__data__, index = assocIndexOf$3(data, key);
235
- if (index < 0) {
236
- return false;
237
- }
238
- var lastIndex = data.length - 1;
239
- if (index == lastIndex) {
240
- data.pop();
241
- } else {
242
- splice.call(data, index, 1);
243
- }
244
- --this.size;
245
- return true;
246
- }
247
- var _listCacheDelete = listCacheDelete$1;
248
- var assocIndexOf$2 = _assocIndexOf;
249
- function listCacheGet$1(key) {
250
- var data = this.__data__, index = assocIndexOf$2(data, key);
251
- return index < 0 ? void 0 : data[index][1];
252
- }
253
- var _listCacheGet = listCacheGet$1;
254
- var assocIndexOf$1 = _assocIndexOf;
255
- function listCacheHas$1(key) {
256
- return assocIndexOf$1(this.__data__, key) > -1;
257
- }
258
- var _listCacheHas = listCacheHas$1;
259
- var assocIndexOf = _assocIndexOf;
260
- function listCacheSet$1(key, value) {
261
- var data = this.__data__, index = assocIndexOf(data, key);
262
- if (index < 0) {
263
- ++this.size;
264
- data.push([key, value]);
265
- } else {
266
- data[index][1] = value;
267
- }
268
- return this;
269
- }
270
- var _listCacheSet = listCacheSet$1;
271
- var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
272
- function ListCache$1(entries) {
273
- var index = -1, length = entries == null ? 0 : entries.length;
274
- this.clear();
275
- while (++index < length) {
276
- var entry = entries[index];
277
- this.set(entry[0], entry[1]);
278
- }
279
- }
280
- ListCache$1.prototype.clear = listCacheClear;
281
- ListCache$1.prototype["delete"] = listCacheDelete;
282
- ListCache$1.prototype.get = listCacheGet;
283
- ListCache$1.prototype.has = listCacheHas;
284
- ListCache$1.prototype.set = listCacheSet;
285
- var _ListCache = ListCache$1;
286
- var getNative = _getNative, root = _root;
287
- var Map$1 = getNative(root, "Map");
288
- var _Map = Map$1;
289
- var Hash = _Hash, ListCache = _ListCache, Map = _Map;
290
- function mapCacheClear$1() {
291
- this.size = 0;
292
- this.__data__ = {
293
- "hash": new Hash(),
294
- "map": new (Map || ListCache)(),
295
- "string": new Hash()
296
- };
297
- }
298
- var _mapCacheClear = mapCacheClear$1;
299
- function isKeyable$1(value) {
300
- var type = typeof value;
301
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
302
- }
303
- var _isKeyable = isKeyable$1;
304
- var isKeyable = _isKeyable;
305
- function getMapData$4(map, key) {
306
- var data = map.__data__;
307
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
308
- }
309
- var _getMapData = getMapData$4;
310
- var getMapData$3 = _getMapData;
311
- function mapCacheDelete$1(key) {
312
- var result = getMapData$3(this, key)["delete"](key);
313
- this.size -= result ? 1 : 0;
314
- return result;
315
- }
316
- var _mapCacheDelete = mapCacheDelete$1;
317
- var getMapData$2 = _getMapData;
318
- function mapCacheGet$1(key) {
319
- return getMapData$2(this, key).get(key);
320
- }
321
- var _mapCacheGet = mapCacheGet$1;
322
- var getMapData$1 = _getMapData;
323
- function mapCacheHas$1(key) {
324
- return getMapData$1(this, key).has(key);
325
- }
326
- var _mapCacheHas = mapCacheHas$1;
327
- var getMapData = _getMapData;
328
- function mapCacheSet$1(key, value) {
329
- var data = getMapData(this, key), size = data.size;
330
- data.set(key, value);
331
- this.size += data.size == size ? 0 : 1;
332
- return this;
333
- }
334
- var _mapCacheSet = mapCacheSet$1;
335
- var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
336
- function MapCache$1(entries) {
337
- var index = -1, length = entries == null ? 0 : entries.length;
338
- this.clear();
339
- while (++index < length) {
340
- var entry = entries[index];
341
- this.set(entry[0], entry[1]);
342
- }
343
- }
344
- MapCache$1.prototype.clear = mapCacheClear;
345
- MapCache$1.prototype["delete"] = mapCacheDelete;
346
- MapCache$1.prototype.get = mapCacheGet;
347
- MapCache$1.prototype.has = mapCacheHas;
348
- MapCache$1.prototype.set = mapCacheSet;
349
- var _MapCache = MapCache$1;
350
- var MapCache = _MapCache;
351
- var FUNC_ERROR_TEXT = "Expected a function";
352
- function memoize$1(func, resolver) {
353
- if (typeof func != "function" || resolver != null && typeof resolver != "function") {
354
- throw new TypeError(FUNC_ERROR_TEXT);
355
- }
356
- var memoized = function() {
357
- var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
358
- if (cache.has(key)) {
359
- return cache.get(key);
360
- }
361
- var result = func.apply(this, args);
362
- memoized.cache = cache.set(key, result) || cache;
363
- return result;
364
- };
365
- memoized.cache = new (memoize$1.Cache || MapCache)();
366
- return memoized;
367
- }
368
- memoize$1.Cache = MapCache;
369
- var memoize_1 = memoize$1;
370
- var memoize = memoize_1;
371
- var MAX_MEMOIZE_SIZE = 500;
372
- function memoizeCapped$1(func) {
373
- var result = memoize(func, function(key) {
374
- if (cache.size === MAX_MEMOIZE_SIZE) {
375
- cache.clear();
376
- }
377
- return key;
378
- });
379
- var cache = result.cache;
380
- return result;
381
- }
382
- var _memoizeCapped = memoizeCapped$1;
383
- var memoizeCapped = _memoizeCapped;
384
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
385
- var reEscapeChar = /\\(\\)?/g;
386
- var stringToPath$2 = memoizeCapped(function(string2) {
387
- var result = [];
388
- if (string2.charCodeAt(0) === 46) {
389
- result.push("");
390
- }
391
- string2.replace(rePropName, function(match, number2, quote, subString) {
392
- result.push(quote ? subString.replace(reEscapeChar, "$1") : number2 || match);
393
- });
394
- return result;
395
- });
396
- var _stringToPath = stringToPath$2;
397
- function arrayMap$1(array, iteratee) {
398
- var index = -1, length = array == null ? 0 : array.length, result = Array(length);
399
- while (++index < length) {
400
- result[index] = iteratee(array[index], index, array);
401
- }
402
- return result;
403
- }
404
- var _arrayMap = arrayMap$1;
405
- var Symbol$1 = _Symbol, arrayMap = _arrayMap, isArray$1 = isArray_1, isSymbol$1 = isSymbol_1;
406
- var INFINITY$1 = 1 / 0;
407
- var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
408
- function baseToString$1(value) {
409
- if (typeof value == "string") {
410
- return value;
411
- }
412
- if (isArray$1(value)) {
413
- return arrayMap(value, baseToString$1) + "";
414
- }
415
- if (isSymbol$1(value)) {
416
- return symbolToString ? symbolToString.call(value) : "";
417
- }
418
- var result = value + "";
419
- return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
420
- }
421
- var _baseToString = baseToString$1;
422
- var baseToString = _baseToString;
423
- function toString$1(value) {
424
- return value == null ? "" : baseToString(value);
425
- }
426
- var toString_1 = toString$1;
427
- var isArray = isArray_1, isKey$1 = _isKey, stringToPath$1 = _stringToPath, toString = toString_1;
428
- function castPath$1(value, object2) {
429
- if (isArray(value)) {
430
- return value;
431
- }
432
- return isKey$1(value, object2) ? [value] : stringToPath$1(toString(value));
433
- }
434
- var _castPath = castPath$1;
435
- var isSymbol = isSymbol_1;
436
- var INFINITY = 1 / 0;
437
- function toKey$1(value) {
438
- if (typeof value == "string" || isSymbol(value)) {
439
- return value;
440
- }
441
- var result = value + "";
442
- return result == "0" && 1 / value == -INFINITY ? "-0" : result;
443
- }
444
- var _toKey = toKey$1;
445
- var castPath = _castPath, toKey = _toKey;
446
- function baseGet$2(object2, path) {
447
- path = castPath(path, object2);
448
- var index = 0, length = path.length;
449
- while (object2 != null && index < length) {
450
- object2 = object2[toKey(path[index++])];
451
- }
452
- return index && index == length ? object2 : void 0;
453
- }
454
- var _baseGet = baseGet$2;
455
- var baseGet$1 = _baseGet;
456
- function get$1(object2, path, defaultValue) {
457
- var result = object2 == null ? void 0 : baseGet$1(object2, path);
458
- return result === void 0 ? defaultValue : result;
459
- }
460
- var get_1 = get$1;
461
- const get$2 = /* @__PURE__ */ getDefaultExportFromCjs(get_1);
462
- const isIfBlockConditionMet = (ifBlock, submissions) => {
463
- const [firstSegment, ...rest] = ifBlock.data.compareKey.split(".");
3
+ const isIfBlockConditionMet = (ifBlock, {
4
+ context,
5
+ submissions
6
+ }) => {
7
+ const [firstSegment, ...path] = ifBlock.data.compareKey.split(".");
464
8
  if (!firstSegment)
465
9
  return false;
466
- const answer = submissions == null ? void 0 : submissions[firstSegment];
10
+ const answer = getSubmissionValueToCheck({
11
+ context,
12
+ key: firstSegment,
13
+ path,
14
+ submissions
15
+ });
467
16
  if (!answer)
468
17
  return false;
469
18
  switch (answer.type) {
470
19
  case "address": {
471
- const value = get$2(answer.value, rest.join("."));
20
+ const value = get$1(answer.value, path.join("."));
472
21
  switch (ifBlock.data.compare) {
473
22
  case "equals":
474
23
  return value === ifBlock.data.compareValue;
@@ -490,7 +39,7 @@ const isIfBlockConditionMet = (ifBlock, submissions) => {
490
39
  return false;
491
40
  if (Array.isArray(answer.value))
492
41
  return false;
493
- const value = get$2(answer.value, rest.join("."));
42
+ const value = get$1(answer.value, path.join("."));
494
43
  const newIfBlock = {
495
44
  ...ifBlock,
496
45
  data: {
@@ -501,32 +50,44 @@ const isIfBlockConditionMet = (ifBlock, submissions) => {
501
50
  switch (typeof value) {
502
51
  case "boolean":
503
52
  return isIfBlockConditionMet(newIfBlock, {
504
- ["_temp"]: {
505
- value,
506
- type: "boolean"
507
- }
53
+ submissions: {
54
+ ["_temp"]: {
55
+ value,
56
+ type: "boolean"
57
+ }
58
+ },
59
+ context
508
60
  });
509
61
  case "string":
510
62
  return isIfBlockConditionMet(newIfBlock, {
511
- ["_temp"]: {
512
- value,
513
- type: "string"
514
- }
63
+ submissions: {
64
+ ["_temp"]: {
65
+ value,
66
+ type: "string"
67
+ }
68
+ },
69
+ context
515
70
  });
516
71
  case "number":
517
72
  return isIfBlockConditionMet(newIfBlock, {
518
- ["_temp"]: {
519
- value,
520
- type: "number"
521
- }
73
+ submissions: {
74
+ ["_temp"]: {
75
+ value,
76
+ type: "number"
77
+ }
78
+ },
79
+ context
522
80
  });
523
81
  case "object":
524
82
  if (Array.isArray(value) && value.every(isString$1)) {
525
83
  return isIfBlockConditionMet(newIfBlock, {
526
- ["_temp"]: {
527
- value,
528
- type: "enum"
529
- }
84
+ submissions: {
85
+ ["_temp"]: {
86
+ value,
87
+ type: "enum"
88
+ }
89
+ },
90
+ context
530
91
  });
531
92
  }
532
93
  return false;
@@ -597,6 +158,59 @@ const isIfBlockConditionMet = (ifBlock, submissions) => {
597
158
  }
598
159
  return false;
599
160
  };
161
+ const HANDLEBARS_REGEXP = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
162
+ const interpolateWithData = (str, {
163
+ context,
164
+ submissions
165
+ }) => {
166
+ return str.replace(HANDLEBARS_REGEXP, (_2, key, defaultValue = "") => {
167
+ const [firstSegment, ...path] = key.trim().split(".");
168
+ const entity = getSubmissionValueToCheck({
169
+ key: firstSegment,
170
+ path,
171
+ submissions,
172
+ context
173
+ });
174
+ if (!entity)
175
+ return defaultValue;
176
+ switch (entity.type) {
177
+ case "boolean":
178
+ return entity.value === true ? "true" : "false";
179
+ case "file":
180
+ return entity.value.map((file) => `${file.name} (${kbToReadableSize(file.sizeKb)})`).join(", ");
181
+ case "enum":
182
+ return entity.value.join(", ");
183
+ case "address":
184
+ return Object.values(entity.value).filter((line) => line && line.trim().length > 0).join(", ");
185
+ case "number":
186
+ case "string":
187
+ if (!entity.value)
188
+ return defaultValue;
189
+ return entity.value.toString();
190
+ case "integration": {
191
+ if (typeof entity.value !== "object")
192
+ break;
193
+ if (Array.isArray(entity.value))
194
+ break;
195
+ const value = get$1(entity.value, path.join("."));
196
+ switch (typeof value) {
197
+ case "boolean":
198
+ return value === true ? "true" : "false";
199
+ case "string":
200
+ return value;
201
+ case "number":
202
+ return value.toString();
203
+ case "object":
204
+ if (Array.isArray(value) && value.every(isString$1)) {
205
+ return value.join(", ");
206
+ }
207
+ }
208
+ break;
209
+ }
210
+ }
211
+ return defaultValue;
212
+ });
213
+ };
600
214
  const followNodes = ({
601
215
  node,
602
216
  nodes,
@@ -884,32 +498,44 @@ async function interpretLinkNode({
884
498
  chat,
885
499
  next,
886
500
  node,
887
- submissions
501
+ submissions,
502
+ context
888
503
  }) {
889
504
  await chat.sendMessage({
890
505
  type: "link",
891
506
  href: node.data.href,
892
- text: interpolateString(node.data.cta, submissions)
507
+ text: interpolateWithData(node.data.cta, {
508
+ submissions,
509
+ context
510
+ })
893
511
  });
894
512
  next(node.nextId);
895
513
  }
896
514
  async function interpretIfBlockNode({
897
515
  submissions,
898
516
  next,
899
- node
517
+ node,
518
+ context
900
519
  }) {
901
- next(isIfBlockConditionMet(node, submissions) ? node.branchId : node.nextId);
520
+ next(isIfBlockConditionMet(node, {
521
+ submissions,
522
+ context
523
+ }) ? node.branchId : node.nextId);
902
524
  }
903
525
  async function interpretTextNode({
904
526
  chat,
905
527
  next,
906
528
  node,
907
- submissions
529
+ submissions,
530
+ context
908
531
  }) {
909
532
  await chat.sendMessage({
910
533
  author: "bot",
911
534
  type: "text",
912
- text: interpolateString(node.data.text, submissions)
535
+ text: interpolateWithData(node.data.text, {
536
+ submissions,
537
+ context
538
+ })
913
539
  });
914
540
  next(node.nextId);
915
541
  }
@@ -931,12 +557,16 @@ async function interpretQuestionTextNode({
931
557
  chat,
932
558
  next,
933
559
  node,
934
- submissions
560
+ submissions,
561
+ context
935
562
  }) {
936
563
  await chat.sendMessage({
937
564
  author: "bot",
938
565
  type: "text",
939
- text: interpolateString(node.data.question, submissions)
566
+ text: interpolateWithData(node.data.question, {
567
+ submissions,
568
+ context
569
+ })
940
570
  });
941
571
  const reply = await chat.userInput({
942
572
  key: node.data.key,
@@ -967,12 +597,16 @@ async function interpretQuestionNumberNode({
967
597
  chat,
968
598
  next,
969
599
  node,
970
- submissions
600
+ submissions,
601
+ context
971
602
  }) {
972
603
  await chat.sendMessage({
973
604
  author: "bot",
974
605
  type: "text",
975
- text: interpolateString(node.data.question, submissions)
606
+ text: interpolateWithData(node.data.question, {
607
+ submissions,
608
+ context
609
+ })
976
610
  });
977
611
  const reply = await chat.userInput({
978
612
  key: node.data.key,
@@ -1004,12 +638,16 @@ async function interpretQuestionEnumNode({
1004
638
  chat,
1005
639
  next,
1006
640
  node,
1007
- submissions
641
+ submissions,
642
+ context
1008
643
  }) {
1009
644
  await chat.sendMessage({
1010
645
  author: "bot",
1011
646
  type: "text",
1012
- text: interpolateString(node.data.question, submissions)
647
+ text: interpolateWithData(node.data.question, {
648
+ submissions,
649
+ context
650
+ })
1013
651
  });
1014
652
  const reply = await chat.userInput({
1015
653
  key: node.data.key,
@@ -1035,12 +673,16 @@ async function interpretQuestionBooleanNode({
1035
673
  chat,
1036
674
  next,
1037
675
  node,
1038
- submissions
676
+ submissions,
677
+ context
1039
678
  }) {
1040
679
  await chat.sendMessage({
1041
680
  author: "bot",
1042
681
  type: "text",
1043
- text: interpolateString(node.data.question, submissions)
682
+ text: interpolateWithData(node.data.question, {
683
+ submissions,
684
+ context
685
+ })
1044
686
  });
1045
687
  const reply = await chat.userInput({
1046
688
  key: node.data.key,
@@ -1107,12 +749,16 @@ async function interpretQuestionFileNode({
1107
749
  node,
1108
750
  chat,
1109
751
  next,
1110
- submissions
752
+ submissions,
753
+ context
1111
754
  }) {
1112
755
  await chat.sendMessage({
1113
756
  author: "bot",
1114
757
  type: "text",
1115
- text: interpolateString(node.data.question, submissions)
758
+ text: interpolateWithData(node.data.question, {
759
+ submissions,
760
+ context
761
+ })
1116
762
  });
1117
763
  const files = await chat.userInput({
1118
764
  key: node.data.key,
@@ -1155,50 +801,38 @@ async function interpretEndFlowNode({
1155
801
  });
1156
802
  end();
1157
803
  }
1158
- const interpolateString = (str, context) => {
1159
- const regex2 = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
1160
- return str.replace(regex2, (_2, key, defaultValue = "") => {
1161
- const [firstSegment, ...rest] = key.trim().split(".");
1162
- const submission = context == null ? void 0 : context[firstSegment];
1163
- if (!submission)
1164
- return defaultValue;
1165
- switch (submission.type) {
1166
- case "boolean":
1167
- return submission.value === true ? "true" : "false";
1168
- case "file":
1169
- return submission.value.map((file) => `${file.name} (${kbToReadableSize(file.sizeKb)})`).join(", ");
1170
- case "enum":
1171
- return submission.value.join(", ");
1172
- case "address":
1173
- return Object.values(submission.value).filter((line) => line && line.trim().length > 0).join(", ");
1174
- case "number":
804
+ const getSubmissionValueToCheck = ({
805
+ key,
806
+ path,
807
+ submissions,
808
+ context
809
+ }) => {
810
+ if (key === "$context") {
811
+ if (!path)
812
+ return void 0;
813
+ const contextData = get$1(context, path.join("."));
814
+ switch (typeof contextData) {
1175
815
  case "string":
1176
- if (!submission.value)
1177
- return defaultValue;
1178
- return submission.value.toString();
1179
- case "integration": {
1180
- if (typeof submission.value !== "object")
1181
- break;
1182
- if (Array.isArray(submission.value))
1183
- break;
1184
- const value = get$2(submission.value, rest.join("."));
1185
- switch (typeof value) {
1186
- case "boolean":
1187
- return value === true ? "true" : "false";
1188
- case "string":
1189
- return value;
1190
- case "number":
1191
- return value.toString();
1192
- case "object":
1193
- if (Array.isArray(value) && value.every(isString$1)) {
1194
- return value.join(", ");
1195
- }
1196
- }
1197
- break;
1198
- }
816
+ return {
817
+ type: "string",
818
+ value: contextData
819
+ };
820
+ case "number":
821
+ return {
822
+ type: "number",
823
+ value: contextData
824
+ };
825
+ case "boolean":
826
+ return {
827
+ type: "boolean",
828
+ value: contextData
829
+ };
830
+ default:
831
+ console.warn(`Unexpected type for $context.${path.join(".")}`, contextData);
832
+ return void 0;
1199
833
  }
1200
- return defaultValue;
1201
- });
834
+ }
835
+ return submissions == null ? void 0 : submissions[key];
1202
836
  };
1203
837
  function debounce(func, wait, immediate) {
1204
838
  var timeout, args, context, timestamp, result;
@@ -2252,14 +1886,14 @@ var isPlainObject = (tempObject) => {
2252
1886
  var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
2253
1887
  function cloneObject(data) {
2254
1888
  let copy;
2255
- const isArray2 = Array.isArray(data);
1889
+ const isArray = Array.isArray(data);
2256
1890
  if (data instanceof Date) {
2257
1891
  copy = new Date(data);
2258
1892
  } else if (data instanceof Set) {
2259
1893
  copy = new Set(data);
2260
- } else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray2 || isObject(data))) {
2261
- copy = isArray2 ? [] : {};
2262
- if (!isArray2 && !isPlainObject(data)) {
1894
+ } else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray || isObject(data))) {
1895
+ copy = isArray ? [] : {};
1896
+ if (!isArray && !isPlainObject(data)) {
2263
1897
  copy = data;
2264
1898
  } else {
2265
1899
  for (const key in data) {