@inploi/plugin-chatbot 3.15.0 → 3.16.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.
- package/cdn/index.js +11 -11
- package/dist/{chatbot-body-0131fc86.js → chatbot-body-1f7580cd.js} +735 -171
- package/dist/{chatbot-body-daedf7bd.cjs → chatbot-body-5774cb2a.cjs} +735 -171
- package/dist/chatbot.d.ts +1 -3
- package/dist/chatbot.state.d.ts +127 -0
- package/dist/chatbot.utils.d.ts +9 -7
- package/dist/conditions.d.ts +3 -0
- package/dist/conditions.test.d.ts +1 -0
- package/dist/{index-b1d81d1c.js → index-063bd7e8.js} +1 -1
- package/dist/{index-51b0335a.cjs → index-a8a873bc.cjs} +1 -1
- package/dist/interpreter.d.ts +8 -7
- package/dist/plugin-chatbot.cjs +1 -1
- package/dist/plugin-chatbot.js +1 -1
- package/package.json +7 -6
|
@@ -1,5 +1,603 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as getHeadOrThrow, i as invariant, A as AbortedError, N, a as getFlowSubmissionsPayload, _, k as kbToReadableSize, h, b as _$1, p, F, o as o$1, c as clsx, y, s as store, d as a$2, e as debounce$1, f as k, j as parse, l as picklist, m as isSubmissionOfType, C as Cn, n as parseAsync, V as ValiError, q as object, t as transform, r as maxLength, u as minLength, v as record, w as boolean, x as string, z as email, B as url, D as regex, E as cva, G as ERROR_MESSAGES } from "./index-063bd7e8.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, number, quote, subString) {
|
|
392
|
+
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || 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 isString$1 = (value) => typeof value === "string";
|
|
463
|
+
const isIfBlockConditionMet = (ifBlock, submissions) => {
|
|
464
|
+
const [firstSegment, ...rest] = ifBlock.data.compareKey.split(".");
|
|
465
|
+
if (!firstSegment)
|
|
466
|
+
return false;
|
|
467
|
+
const answer = submissions == null ? void 0 : submissions[firstSegment];
|
|
468
|
+
if (!answer)
|
|
469
|
+
return false;
|
|
470
|
+
switch (answer.type) {
|
|
471
|
+
case "address": {
|
|
472
|
+
const value = get$2(answer.value, rest.join("."));
|
|
473
|
+
switch (ifBlock.data.compare) {
|
|
474
|
+
case "equals":
|
|
475
|
+
return value === ifBlock.data.compareValue;
|
|
476
|
+
case "contains":
|
|
477
|
+
if (!value)
|
|
478
|
+
return false;
|
|
479
|
+
return value.includes(ifBlock.data.compareValue);
|
|
480
|
+
case "notEquals":
|
|
481
|
+
return value !== ifBlock.data.compareValue;
|
|
482
|
+
case "notContains":
|
|
483
|
+
if (!value)
|
|
484
|
+
return true;
|
|
485
|
+
return !value.includes(ifBlock.data.compareValue);
|
|
486
|
+
}
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
case "integration": {
|
|
490
|
+
if (typeof answer.value !== "object")
|
|
491
|
+
return false;
|
|
492
|
+
if (Array.isArray(answer.value))
|
|
493
|
+
return false;
|
|
494
|
+
const value = get$2(answer.value, rest.join("."));
|
|
495
|
+
const newIfBlock = {
|
|
496
|
+
...ifBlock,
|
|
497
|
+
data: {
|
|
498
|
+
...ifBlock.data,
|
|
499
|
+
compareKey: "_temp"
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
switch (typeof value) {
|
|
503
|
+
case "boolean":
|
|
504
|
+
return isIfBlockConditionMet(newIfBlock, {
|
|
505
|
+
["_temp"]: {
|
|
506
|
+
value,
|
|
507
|
+
type: "boolean"
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
case "string":
|
|
511
|
+
return isIfBlockConditionMet(newIfBlock, {
|
|
512
|
+
["_temp"]: {
|
|
513
|
+
value,
|
|
514
|
+
type: "string"
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
case "number":
|
|
518
|
+
return isIfBlockConditionMet(newIfBlock, {
|
|
519
|
+
["_temp"]: {
|
|
520
|
+
value,
|
|
521
|
+
type: "number"
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
case "object":
|
|
525
|
+
if (Array.isArray(value) && value.every(isString$1)) {
|
|
526
|
+
return isIfBlockConditionMet(newIfBlock, {
|
|
527
|
+
["_temp"]: {
|
|
528
|
+
value,
|
|
529
|
+
type: "enum"
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
case "boolean": {
|
|
538
|
+
const compareBoolean = ifBlock.data.compareValue === "true";
|
|
539
|
+
switch (ifBlock.data.compare) {
|
|
540
|
+
case "equals":
|
|
541
|
+
return answer.value === compareBoolean;
|
|
542
|
+
case "notEquals":
|
|
543
|
+
return answer.value !== compareBoolean;
|
|
544
|
+
}
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
case "string":
|
|
548
|
+
switch (ifBlock.data.compare) {
|
|
549
|
+
case "equals":
|
|
550
|
+
return answer.value === ifBlock.data.compareValue;
|
|
551
|
+
case "contains":
|
|
552
|
+
if (!answer.value)
|
|
553
|
+
return false;
|
|
554
|
+
return answer.value.includes(ifBlock.data.compareValue);
|
|
555
|
+
case "notEquals":
|
|
556
|
+
return answer.value !== ifBlock.data.compareValue;
|
|
557
|
+
case "notContains":
|
|
558
|
+
if (!answer.value)
|
|
559
|
+
return true;
|
|
560
|
+
return !answer.value.includes(ifBlock.data.compareValue);
|
|
561
|
+
}
|
|
562
|
+
break;
|
|
563
|
+
case "number": {
|
|
564
|
+
try {
|
|
565
|
+
const compareNumber = Number(ifBlock.data.compareValue);
|
|
566
|
+
switch (ifBlock.data.compare) {
|
|
567
|
+
case "equals":
|
|
568
|
+
return answer.value === compareNumber;
|
|
569
|
+
case "notEquals":
|
|
570
|
+
return answer.value !== compareNumber;
|
|
571
|
+
case "greaterThan":
|
|
572
|
+
return answer.value > compareNumber;
|
|
573
|
+
case "greaterThanOrEqualTo":
|
|
574
|
+
return answer.value >= compareNumber;
|
|
575
|
+
case "lessThan":
|
|
576
|
+
return answer.value < compareNumber;
|
|
577
|
+
case "lessThanOrEqualTo":
|
|
578
|
+
return answer.value <= compareNumber;
|
|
579
|
+
}
|
|
580
|
+
} catch {
|
|
581
|
+
console.error(`Failed to parse number in if-block ${ifBlock.id}`, answer.value);
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
case "enum":
|
|
587
|
+
switch (ifBlock.data.compare) {
|
|
588
|
+
case "equals":
|
|
589
|
+
return answer.value.length === 1 && answer.value[0] === ifBlock.data.compareValue;
|
|
590
|
+
case "notEquals":
|
|
591
|
+
return answer.value.length === 1 && answer.value[0] !== ifBlock.data.compareValue;
|
|
592
|
+
case "contains":
|
|
593
|
+
return answer.value.includes(ifBlock.data.compareValue);
|
|
594
|
+
case "notContains":
|
|
595
|
+
return !answer.value.includes(ifBlock.data.compareValue);
|
|
596
|
+
}
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
return false;
|
|
600
|
+
};
|
|
3
601
|
const followNodes = ({
|
|
4
602
|
node,
|
|
5
603
|
nodes,
|
|
@@ -72,7 +670,8 @@ const createFlowInterpreter = ({
|
|
|
72
670
|
userInput: async (input) => chatService.input({
|
|
73
671
|
input,
|
|
74
672
|
signal: controller.signal
|
|
75
|
-
})
|
|
673
|
+
}),
|
|
674
|
+
addToSubmissions: chatService.addToSubmissions
|
|
76
675
|
},
|
|
77
676
|
next: (nodeId) => {
|
|
78
677
|
const nextNode = nodeId ? flow.find((node2) => node2.id === nodeId) : fallthroughBranch({
|
|
@@ -222,6 +821,11 @@ async function interpretSubmitNode({
|
|
|
222
821
|
submissions: getFlowSubmissionsPayload(submissions || {})
|
|
223
822
|
})
|
|
224
823
|
}).catch((e) => e);
|
|
824
|
+
if (node.data.key)
|
|
825
|
+
chat.addToSubmissions(node.data.key, {
|
|
826
|
+
type: "integration",
|
|
827
|
+
value: response
|
|
828
|
+
});
|
|
225
829
|
await N(response).with({
|
|
226
830
|
ats_data: {
|
|
227
831
|
redirect_url: _.string
|
|
@@ -279,8 +883,7 @@ async function interpretIfBlockNode({
|
|
|
279
883
|
next,
|
|
280
884
|
node
|
|
281
885
|
}) {
|
|
282
|
-
|
|
283
|
-
next(nextId);
|
|
886
|
+
next(isIfBlockConditionMet(node, submissions) ? node.branchId : node.nextId);
|
|
284
887
|
}
|
|
285
888
|
async function interpretTextNode({
|
|
286
889
|
chat,
|
|
@@ -330,7 +933,7 @@ async function interpretQuestionTextNode({
|
|
|
330
933
|
maxChars: node.data.maxChars
|
|
331
934
|
}
|
|
332
935
|
});
|
|
333
|
-
if (reply
|
|
936
|
+
if (reply === null) {
|
|
334
937
|
await chat.sendMessage({
|
|
335
938
|
type: "system",
|
|
336
939
|
variant: "info",
|
|
@@ -365,7 +968,7 @@ async function interpretQuestionNumberNode({
|
|
|
365
968
|
format: "text"
|
|
366
969
|
}
|
|
367
970
|
});
|
|
368
|
-
if (reply
|
|
971
|
+
if (reply === null) {
|
|
369
972
|
await chat.sendMessage({
|
|
370
973
|
type: "system",
|
|
371
974
|
variant: "info",
|
|
@@ -422,7 +1025,7 @@ async function interpretQuestionBooleanNode({
|
|
|
422
1025
|
type: "text",
|
|
423
1026
|
text: interpolateString(node.data.question, submissions)
|
|
424
1027
|
});
|
|
425
|
-
const
|
|
1028
|
+
const reply = await chat.userInput({
|
|
426
1029
|
key: node.data.key,
|
|
427
1030
|
type: "boolean",
|
|
428
1031
|
config: {
|
|
@@ -433,7 +1036,6 @@ async function interpretQuestionBooleanNode({
|
|
|
433
1036
|
}
|
|
434
1037
|
}
|
|
435
1038
|
});
|
|
436
|
-
const reply = input.value;
|
|
437
1039
|
if (reply === null) {
|
|
438
1040
|
await chat.sendMessage({
|
|
439
1041
|
type: "system",
|
|
@@ -444,10 +1046,7 @@ async function interpretQuestionBooleanNode({
|
|
|
444
1046
|
await chat.sendMessage({
|
|
445
1047
|
author: "user",
|
|
446
1048
|
type: "text",
|
|
447
|
-
text:
|
|
448
|
-
true: node.data.trueLabel,
|
|
449
|
-
false: node.data.falseLabel
|
|
450
|
-
}[reply]
|
|
1049
|
+
text: reply.value === true ? node.data.trueLabel : node.data.falseLabel
|
|
451
1050
|
});
|
|
452
1051
|
}
|
|
453
1052
|
next(node.nextId);
|
|
@@ -471,7 +1070,7 @@ async function interpretQuestionAddressNode({
|
|
|
471
1070
|
placeholder: node.data.placeholder
|
|
472
1071
|
}
|
|
473
1072
|
});
|
|
474
|
-
if (response
|
|
1073
|
+
if (response === null) {
|
|
475
1074
|
await chat.sendMessage({
|
|
476
1075
|
type: "system",
|
|
477
1076
|
variant: "info",
|
|
@@ -509,7 +1108,7 @@ async function interpretQuestionFileNode({
|
|
|
509
1108
|
allowMultiple: node.data.multiple === true
|
|
510
1109
|
}
|
|
511
1110
|
});
|
|
512
|
-
if (files
|
|
1111
|
+
if (files === null) {
|
|
513
1112
|
await chat.sendMessage({
|
|
514
1113
|
type: "system",
|
|
515
1114
|
variant: "info",
|
|
@@ -539,91 +1138,34 @@ async function interpretEndFlowNode({
|
|
|
539
1138
|
});
|
|
540
1139
|
end();
|
|
541
1140
|
}
|
|
542
|
-
const possibleContainsValue = _.union(_.string, _.array(_.string), null);
|
|
543
|
-
const isIfBlockConditionMet = (ifBlock, submissions) => {
|
|
544
|
-
const answer = submissions == null ? void 0 : submissions[ifBlock.data.compareKey];
|
|
545
|
-
if (!answer)
|
|
546
|
-
return false;
|
|
547
|
-
return N({
|
|
548
|
-
...ifBlock.data,
|
|
549
|
-
answer
|
|
550
|
-
}).with({
|
|
551
|
-
compare: "equals"
|
|
552
|
-
}, ({
|
|
553
|
-
compareValue
|
|
554
|
-
}) => {
|
|
555
|
-
if (typeof answer.value === "string" || typeof answer.value === "boolean")
|
|
556
|
-
return compareValue === answer.value.toString();
|
|
557
|
-
return false;
|
|
558
|
-
}).with({
|
|
559
|
-
compare: "notEquals"
|
|
560
|
-
}, ({
|
|
561
|
-
compareValue
|
|
562
|
-
}) => {
|
|
563
|
-
if (typeof answer.value === "string" || typeof answer.value === "boolean")
|
|
564
|
-
return compareValue !== answer.value.toString();
|
|
565
|
-
return false;
|
|
566
|
-
}).with({
|
|
567
|
-
compare: "contains",
|
|
568
|
-
answer: {
|
|
569
|
-
value: possibleContainsValue
|
|
570
|
-
}
|
|
571
|
-
}, ({
|
|
572
|
-
compareValue,
|
|
573
|
-
answer: answer2
|
|
574
|
-
}) => answer2.value !== null && answer2.value.includes(compareValue)).with({
|
|
575
|
-
compare: "notContains",
|
|
576
|
-
answer: {
|
|
577
|
-
value: possibleContainsValue
|
|
578
|
-
}
|
|
579
|
-
}, ({
|
|
580
|
-
compareValue,
|
|
581
|
-
answer: answer2
|
|
582
|
-
}) => answer2.value === null || !answer2.value.includes(compareValue)).with({
|
|
583
|
-
answer: {
|
|
584
|
-
type: "file"
|
|
585
|
-
}
|
|
586
|
-
}, () => false).with({
|
|
587
|
-
answer: {
|
|
588
|
-
type: "address",
|
|
589
|
-
value: _.any
|
|
590
|
-
}
|
|
591
|
-
}, () => {
|
|
592
|
-
return false;
|
|
593
|
-
}).with({
|
|
594
|
-
compare: "greaterThan"
|
|
595
|
-
}, () => false).with({
|
|
596
|
-
compare: "lessThan"
|
|
597
|
-
}, () => false).with({
|
|
598
|
-
compare: "greaterThanOrEqualTo"
|
|
599
|
-
}, () => false).with({
|
|
600
|
-
compare: "lessThanOrEqualTo"
|
|
601
|
-
}, () => false).exhaustive();
|
|
602
|
-
};
|
|
603
1141
|
const interpolateString = (str, context) => {
|
|
604
1142
|
const regex2 = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g;
|
|
605
|
-
return str.replace(regex2, (
|
|
1143
|
+
return str.replace(regex2, (_2, key, defaultValue = "") => {
|
|
606
1144
|
key = key.trim();
|
|
607
1145
|
const submission = context == null ? void 0 : context[key];
|
|
608
1146
|
if (!submission)
|
|
609
1147
|
return defaultValue;
|
|
610
1148
|
switch (submission.type) {
|
|
611
1149
|
case "boolean":
|
|
612
|
-
return submission.value ===
|
|
1150
|
+
return submission.value === true ? "true" : "false";
|
|
613
1151
|
case "file":
|
|
614
|
-
if (!submission.value)
|
|
615
|
-
return "no files";
|
|
616
1152
|
return submission.value.map((file) => `${file.name} (${kbToReadableSize(file.sizeKb)})`).join(", ");
|
|
617
|
-
case "
|
|
1153
|
+
case "enum":
|
|
618
1154
|
return submission.value.join(", ");
|
|
1155
|
+
case "address":
|
|
1156
|
+
return Object.values(submission.value).filter((line) => line && line.trim().length > 0).join(", ");
|
|
1157
|
+
case "number":
|
|
1158
|
+
case "string":
|
|
1159
|
+
if (!submission.value)
|
|
1160
|
+
return defaultValue;
|
|
1161
|
+
return submission.value.toString();
|
|
1162
|
+
case "integration":
|
|
1163
|
+
return JSON.stringify(submission.value);
|
|
619
1164
|
default:
|
|
620
|
-
return
|
|
1165
|
+
return defaultValue;
|
|
621
1166
|
}
|
|
622
1167
|
});
|
|
623
1168
|
};
|
|
624
|
-
function getDefaultExportFromCjs(x) {
|
|
625
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
626
|
-
}
|
|
627
1169
|
function debounce(func, wait, immediate) {
|
|
628
1170
|
var timeout, args, context, timestamp, result;
|
|
629
1171
|
if (null == wait)
|
|
@@ -882,39 +1424,15 @@ const useChatService = () => {
|
|
|
882
1424
|
}
|
|
883
1425
|
};
|
|
884
1426
|
}, [chatRef]);
|
|
885
|
-
const chatService = F(() =>
|
|
886
|
-
|
|
887
|
-
message,
|
|
888
|
-
signal: signal2,
|
|
889
|
-
groupId
|
|
890
|
-
}) => {
|
|
891
|
-
await N(message).with({
|
|
892
|
-
author: "bot",
|
|
893
|
-
type: "text"
|
|
894
|
-
}, async (message2) => {
|
|
895
|
-
if (signal2 == null ? void 0 : signal2.aborted)
|
|
896
|
-
throw new AbortedError();
|
|
897
|
-
chatStore.isBotTyping$.value = true;
|
|
898
|
-
const typingTime = Math.min(Math.max(20, message2.text.length), 100) * TYPING_SPEED_MS_PER_CHARACTER;
|
|
899
|
-
await new Promise((resolve) => {
|
|
900
|
-
return setTimeout(resolve, typingTime, {
|
|
901
|
-
signal: signal2
|
|
902
|
-
});
|
|
903
|
-
});
|
|
904
|
-
chatStore.isBotTyping$.value = false;
|
|
905
|
-
}).otherwise(async () => void 0);
|
|
906
|
-
if (signal2 == null ? void 0 : signal2.aborted)
|
|
907
|
-
throw new AbortedError();
|
|
908
|
-
store.addMessage(message, groupId);
|
|
909
|
-
},
|
|
910
|
-
input: async ({
|
|
1427
|
+
const chatService = F(() => {
|
|
1428
|
+
const inputFn = ({
|
|
911
1429
|
input,
|
|
912
1430
|
signal: signal2
|
|
913
1431
|
}) => {
|
|
914
1432
|
if (signal2 == null ? void 0 : signal2.aborted)
|
|
915
1433
|
throw new AbortedError();
|
|
916
1434
|
store.setInput(input);
|
|
917
|
-
return
|
|
1435
|
+
return new Promise((resolve) => {
|
|
918
1436
|
const submitFunction = (submission) => {
|
|
919
1437
|
if (signal2 == null ? void 0 : signal2.aborted)
|
|
920
1438
|
throw new AbortedError();
|
|
@@ -926,8 +1444,36 @@ const useChatService = () => {
|
|
|
926
1444
|
};
|
|
927
1445
|
chatStore.onSubmitSuccessFn$.value = submitFunction;
|
|
928
1446
|
});
|
|
929
|
-
}
|
|
930
|
-
|
|
1447
|
+
};
|
|
1448
|
+
return {
|
|
1449
|
+
addToSubmissions: (key, value) => store.setSubmission(key, value),
|
|
1450
|
+
send: async ({
|
|
1451
|
+
message,
|
|
1452
|
+
signal: signal2,
|
|
1453
|
+
groupId
|
|
1454
|
+
}) => {
|
|
1455
|
+
await N(message).with({
|
|
1456
|
+
author: "bot",
|
|
1457
|
+
type: "text"
|
|
1458
|
+
}, async (message2) => {
|
|
1459
|
+
if (signal2 == null ? void 0 : signal2.aborted)
|
|
1460
|
+
throw new AbortedError();
|
|
1461
|
+
chatStore.isBotTyping$.value = true;
|
|
1462
|
+
const typingTime = Math.min(Math.max(20, message2.text.length), 100) * TYPING_SPEED_MS_PER_CHARACTER;
|
|
1463
|
+
await new Promise((resolve) => {
|
|
1464
|
+
return setTimeout(resolve, typingTime, {
|
|
1465
|
+
signal: signal2
|
|
1466
|
+
});
|
|
1467
|
+
});
|
|
1468
|
+
chatStore.isBotTyping$.value = false;
|
|
1469
|
+
}).otherwise(async () => void 0);
|
|
1470
|
+
if (signal2 == null ? void 0 : signal2.aborted)
|
|
1471
|
+
throw new AbortedError();
|
|
1472
|
+
store.addMessage(message, groupId);
|
|
1473
|
+
},
|
|
1474
|
+
input: inputFn
|
|
1475
|
+
};
|
|
1476
|
+
}, []);
|
|
931
1477
|
return {
|
|
932
1478
|
chatRef,
|
|
933
1479
|
chatService
|
|
@@ -1260,7 +1806,10 @@ const ChatInputAddressDetails = ({
|
|
|
1260
1806
|
onSubmit: (e) => {
|
|
1261
1807
|
const formData = new FormData(e.currentTarget);
|
|
1262
1808
|
const fields = Object.fromEntries(formData.entries());
|
|
1263
|
-
onSubmitSuccess(
|
|
1809
|
+
onSubmitSuccess({
|
|
1810
|
+
type: "address",
|
|
1811
|
+
value: fields
|
|
1812
|
+
});
|
|
1264
1813
|
},
|
|
1265
1814
|
children: [o$1("div", {
|
|
1266
1815
|
class: "bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",
|
|
@@ -1367,7 +1916,10 @@ const ChatInputBoolean = ({
|
|
|
1367
1916
|
throw new Error("invalid form");
|
|
1368
1917
|
});
|
|
1369
1918
|
const answer = parse(AnswerSchema, value);
|
|
1370
|
-
onSubmitSuccess(
|
|
1919
|
+
onSubmitSuccess({
|
|
1920
|
+
type: "boolean",
|
|
1921
|
+
value: answer === "true"
|
|
1922
|
+
});
|
|
1371
1923
|
},
|
|
1372
1924
|
children: [o$1("div", {
|
|
1373
1925
|
class: "flex items-center gap-2 p-2.5",
|
|
@@ -1502,7 +2054,7 @@ const ChatInputFile = ({
|
|
|
1502
2054
|
}) => {
|
|
1503
2055
|
var _a;
|
|
1504
2056
|
const submission = (_a = store.current$.value.flow) == null ? void 0 : _a.data.submissions[input.key];
|
|
1505
|
-
const [files, setFiles] = h(isFileSubmission(submission)
|
|
2057
|
+
const [files, setFiles] = h(isFileSubmission(submission) ? submission.value : []);
|
|
1506
2058
|
const [error, setError] = h();
|
|
1507
2059
|
const hiddenFileCount = files.length - FILENAMES_TO_SHOW_QTY;
|
|
1508
2060
|
const totalSize = addFileSizesKb(files);
|
|
@@ -1538,7 +2090,10 @@ const ChatInputFile = ({
|
|
|
1538
2090
|
type: "invalid",
|
|
1539
2091
|
message: "Only one file is allowed"
|
|
1540
2092
|
});
|
|
1541
|
-
return onSubmitSuccess(
|
|
2093
|
+
return onSubmitSuccess({
|
|
2094
|
+
type: "file",
|
|
2095
|
+
value: files
|
|
2096
|
+
});
|
|
1542
2097
|
},
|
|
1543
2098
|
children: [o$1("div", {
|
|
1544
2099
|
class: "flex items-center gap-2",
|
|
@@ -1663,14 +2218,14 @@ var isPlainObject = (tempObject) => {
|
|
|
1663
2218
|
var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
|
|
1664
2219
|
function cloneObject(data) {
|
|
1665
2220
|
let copy;
|
|
1666
|
-
const
|
|
2221
|
+
const isArray2 = Array.isArray(data);
|
|
1667
2222
|
if (data instanceof Date) {
|
|
1668
2223
|
copy = new Date(data);
|
|
1669
2224
|
} else if (data instanceof Set) {
|
|
1670
2225
|
copy = new Set(data);
|
|
1671
|
-
} else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (
|
|
1672
|
-
copy =
|
|
1673
|
-
if (!
|
|
2226
|
+
} else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray2 || isObject(data))) {
|
|
2227
|
+
copy = isArray2 ? [] : {};
|
|
2228
|
+
if (!isArray2 && !isPlainObject(data)) {
|
|
1674
2229
|
copy = data;
|
|
1675
2230
|
} else {
|
|
1676
2231
|
for (const key in data) {
|
|
@@ -3121,7 +3676,7 @@ const submitIfSingleChecked = (form) => {
|
|
|
3121
3676
|
bubbles: true
|
|
3122
3677
|
}));
|
|
3123
3678
|
};
|
|
3124
|
-
const isMultipleChoiceSubmission = isSubmissionOfType("
|
|
3679
|
+
const isMultipleChoiceSubmission = isSubmissionOfType("enum");
|
|
3125
3680
|
const getResolver$1 = (config) => {
|
|
3126
3681
|
const length = {
|
|
3127
3682
|
min: config.minSelected ?? 0,
|
|
@@ -3161,7 +3716,10 @@ const ChatInputMultipleChoice = ({
|
|
|
3161
3716
|
},
|
|
3162
3717
|
onSubmit: handleSubmit((submission2) => {
|
|
3163
3718
|
const checked = submission2.checked;
|
|
3164
|
-
onSubmitSuccess(
|
|
3719
|
+
onSubmitSuccess({
|
|
3720
|
+
type: "enum",
|
|
3721
|
+
value: checked
|
|
3722
|
+
});
|
|
3165
3723
|
}),
|
|
3166
3724
|
children: [o$1("div", {
|
|
3167
3725
|
class: "flex items-center gap-1",
|
|
@@ -3203,7 +3761,10 @@ const ChatInputMultipleChoice = ({
|
|
|
3203
3761
|
class: "flex flex-col items-center gap-2",
|
|
3204
3762
|
children: [!isSingleChoice && o$1(SendButton, {}), input.config.minSelected === 0 && o$1(SkipButton, {
|
|
3205
3763
|
type: "button",
|
|
3206
|
-
onClick: () => onSubmitSuccess(
|
|
3764
|
+
onClick: () => onSubmitSuccess({
|
|
3765
|
+
type: "enum",
|
|
3766
|
+
value: []
|
|
3767
|
+
})
|
|
3207
3768
|
})]
|
|
3208
3769
|
})]
|
|
3209
3770
|
}), o$1("div", {
|
|
@@ -3276,7 +3837,7 @@ const inputFormatToProps = {
|
|
|
3276
3837
|
formNoValidate: true
|
|
3277
3838
|
}
|
|
3278
3839
|
};
|
|
3279
|
-
const isTextSubmission = isSubmissionOfType("
|
|
3840
|
+
const isTextSubmission = isSubmissionOfType("string");
|
|
3280
3841
|
const getResolver = (config) => {
|
|
3281
3842
|
const maxLengthError = `Please enter no more than ${config.maxChars} characters`;
|
|
3282
3843
|
return i(object({
|
|
@@ -3320,42 +3881,43 @@ const ChatInputText = ({
|
|
|
3320
3881
|
ref.current.select();
|
|
3321
3882
|
}
|
|
3322
3883
|
}, []);
|
|
3323
|
-
return o$1(
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3884
|
+
return o$1("form", {
|
|
3885
|
+
noValidate: true,
|
|
3886
|
+
class: "flex flex-col gap-1 p-2.5",
|
|
3887
|
+
onSubmit: handleSubmit((submission2) => {
|
|
3888
|
+
onSubmitSuccess({
|
|
3889
|
+
type: "string",
|
|
3890
|
+
value: submission2.text
|
|
3891
|
+
});
|
|
3892
|
+
}),
|
|
3893
|
+
children: [o$1("div", {
|
|
3894
|
+
class: "flex items-center gap-2",
|
|
3330
3895
|
children: [o$1("div", {
|
|
3331
|
-
class: "
|
|
3332
|
-
children: [o$1("
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
error: errors2.text
|
|
3357
|
-
})]
|
|
3358
|
-
})
|
|
3896
|
+
class: "relative min-w-0 flex-grow",
|
|
3897
|
+
children: [o$1("input", {
|
|
3898
|
+
id: "chat-input",
|
|
3899
|
+
...props,
|
|
3900
|
+
...inputFormatToProps[input.config.format],
|
|
3901
|
+
autocomplete: "off",
|
|
3902
|
+
autoCapitalize: "off",
|
|
3903
|
+
autoCorrect: "off",
|
|
3904
|
+
autoFocus: true,
|
|
3905
|
+
ref: (element) => {
|
|
3906
|
+
if (element) {
|
|
3907
|
+
ref.current = element;
|
|
3908
|
+
}
|
|
3909
|
+
setRef(element);
|
|
3910
|
+
},
|
|
3911
|
+
class: "outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest w-full rounded-full px-3 py-1 text-base outline outline-2 transition-all",
|
|
3912
|
+
placeholder: input.config.placeholder
|
|
3913
|
+
}), input.config.optional && o$1(SkipButton, {
|
|
3914
|
+
class: "absolute right-0 top-0",
|
|
3915
|
+
onClick: () => onSubmitSuccess(null)
|
|
3916
|
+
})]
|
|
3917
|
+
}), o$1(SendButton, {})]
|
|
3918
|
+
}), o$1(InputError, {
|
|
3919
|
+
error: errors2.text
|
|
3920
|
+
})]
|
|
3359
3921
|
});
|
|
3360
3922
|
};
|
|
3361
3923
|
const ChatInput = () => {
|
|
@@ -3377,10 +3939,6 @@ const ChatInput = () => {
|
|
|
3377
3939
|
wrapper.removeEventListener("transitionend", chatStore.scrollToEnd.smooth);
|
|
3378
3940
|
};
|
|
3379
3941
|
}, []);
|
|
3380
|
-
const handleSubmitSuccess = (type) => (value) => chatStore.onSubmitSuccessFn$.value({
|
|
3381
|
-
type,
|
|
3382
|
-
value
|
|
3383
|
-
});
|
|
3384
3942
|
return o$1("div", {
|
|
3385
3943
|
ref: inputWrapperRef,
|
|
3386
3944
|
class: "ease-expo-out absolute bottom-0 w-full overflow-hidden rounded-b-3xl backdrop-blur-xl transition-all duration-700 will-change-[height]",
|
|
@@ -3411,44 +3969,50 @@ const ChatInput = () => {
|
|
|
3411
3969
|
type: "text"
|
|
3412
3970
|
}
|
|
3413
3971
|
}, (props) => o$1(ChatInputText, {
|
|
3414
|
-
onSubmitSuccess:
|
|
3972
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3415
3973
|
...props
|
|
3416
3974
|
})).with({
|
|
3417
3975
|
input: {
|
|
3418
3976
|
type: "multiple-choice"
|
|
3419
3977
|
}
|
|
3420
3978
|
}, (props) => o$1(ChatInputMultipleChoice, {
|
|
3421
|
-
onSubmitSuccess:
|
|
3979
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3422
3980
|
...props
|
|
3423
3981
|
})).with({
|
|
3424
3982
|
input: {
|
|
3425
3983
|
type: "boolean"
|
|
3426
3984
|
}
|
|
3427
3985
|
}, (props) => o$1(ChatInputBoolean, {
|
|
3428
|
-
onSubmitSuccess:
|
|
3986
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3429
3987
|
...props
|
|
3430
3988
|
})).with({
|
|
3431
3989
|
input: {
|
|
3432
3990
|
type: "file"
|
|
3433
3991
|
}
|
|
3434
3992
|
}, (props) => o$1(ChatInputFile, {
|
|
3435
|
-
onSubmitSuccess:
|
|
3993
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3436
3994
|
...props
|
|
3437
3995
|
})).with({
|
|
3438
3996
|
input: {
|
|
3439
3997
|
type: "submit"
|
|
3440
3998
|
}
|
|
3441
3999
|
}, (props) => o$1(ChatInputSubmit, {
|
|
3442
|
-
onSubmitSuccess:
|
|
4000
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3443
4001
|
...props
|
|
3444
4002
|
})).with({
|
|
3445
4003
|
input: {
|
|
3446
4004
|
type: "address"
|
|
3447
4005
|
}
|
|
3448
4006
|
}, (props) => o$1(ChatInputAddress, {
|
|
3449
|
-
onSubmitSuccess:
|
|
4007
|
+
onSubmitSuccess: chatStore.onSubmitSuccessFn$.value,
|
|
3450
4008
|
...props
|
|
3451
|
-
})).
|
|
4009
|
+
})).with({
|
|
4010
|
+
input: {
|
|
4011
|
+
type: "number"
|
|
4012
|
+
}
|
|
4013
|
+
}, () => {
|
|
4014
|
+
throw new Error("Not implemented");
|
|
4015
|
+
}).exhaustive()
|
|
3452
4016
|
})
|
|
3453
4017
|
});
|
|
3454
4018
|
};
|