@seamly/web-ui 19.0.0 → 19.1.3
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/build/dist/lib/index.debug.js +150 -62
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +40 -8
- package/build/dist/lib/index.js +493 -413
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +581 -432
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +1875 -1791
- package/build/dist/lib/style-guide.min.js +1 -1
- package/package.json +1 -1
- package/src/javascripts/api/errors/seamly-base-error.js +17 -0
- package/src/javascripts/api/errors/seamly-configuration-error.js +4 -6
- package/src/javascripts/api/errors/seamly-general-error.js +4 -6
- package/src/javascripts/api/errors/seamly-offline-error.js +4 -6
- package/src/javascripts/api/errors/seamly-session-expired-error.js +4 -6
- package/src/javascripts/api/errors/seamly-unauthorized-error.js +4 -6
- package/src/javascripts/api/errors/seamly-unavailable-error.js +17 -0
- package/src/javascripts/api/index.js +10 -11
- package/src/javascripts/api/producer.js +5 -1
- package/src/javascripts/domains/app/actions.js +27 -17
- package/src/javascripts/domains/app/index.js +2 -1
- package/src/javascripts/domains/config/reducer.js +1 -0
- package/src/javascripts/domains/config/selectors.js +1 -1
- package/src/javascripts/domains/errors/index.js +33 -0
- package/src/javascripts/domains/i18n/reducer.js +6 -0
- package/src/javascripts/domains/interrupt/middleware.js +2 -0
- package/src/javascripts/domains/interrupt/reducer.js +10 -9
- package/src/javascripts/domains/store/index.js +6 -1
- package/src/javascripts/domains/store/state-reducer.js +10 -6
- package/src/javascripts/domains/visibility/actions.js +73 -0
- package/src/javascripts/domains/visibility/constants.js +8 -0
- package/src/javascripts/domains/visibility/hooks.js +24 -0
- package/src/javascripts/domains/visibility/index.js +8 -0
- package/src/javascripts/domains/visibility/reducer.js +19 -0
- package/src/javascripts/domains/visibility/selectors.js +9 -0
- package/src/javascripts/domains/visibility/utils.js +42 -0
- package/src/javascripts/index.js +3 -12
- package/src/javascripts/lib/engine/index.js +1 -0
- package/src/javascripts/lib/redux-helpers/index.js +1 -5
- package/src/javascripts/style-guide/components/app.js +1 -1
- package/src/javascripts/style-guide/components/static-core.js +13 -0
- package/src/javascripts/style-guide/states.js +48 -21
- package/src/javascripts/ui/components/conversation/conversation.js +2 -2
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +1 -8
- package/src/javascripts/ui/components/conversation/event/text.js +19 -13
- package/src/javascripts/ui/components/core/seamly-core.js +3 -0
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +3 -3
- package/src/javascripts/ui/components/core/seamly-initializer.js +2 -6
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +2 -3
- package/src/javascripts/ui/components/core/seamly-new-notifications.js +2 -2
- package/src/javascripts/ui/components/core/seamly-read-state.js +2 -2
- package/src/javascripts/ui/components/entry/toggle-button.js +2 -2
- package/src/javascripts/ui/components/layout/agent-info.js +2 -2
- package/src/javascripts/ui/components/layout/app-frame.js +2 -3
- package/src/javascripts/ui/components/layout/chat-frame.js +2 -2
- package/src/javascripts/ui/components/layout/modal-wrapper.js +3 -6
- package/src/javascripts/ui/components/layout/view.js +3 -6
- package/src/javascripts/ui/hooks/seamly-hooks.js +0 -2
- package/src/javascripts/ui/hooks/use-seamly-chat.js +3 -5
- package/src/javascripts/ui/hooks/use-seamly-commands.js +7 -29
- package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +2 -2
- package/src/javascripts/ui/utils/general-utils.js +0 -9
- package/src/javascripts/ui/utils/seamly-utils.js +0 -66
- package/src/.DS_Store +0 -0
- package/src/javascripts/ui/hooks/use-seamly-stored-visibility.js +0 -31
- package/src/javascripts/ui/hooks/use-seamly-visibility.js +0 -98
|
@@ -48,6 +48,27 @@ const web_ui_namespaceObject = require("@seamly/web-ui");
|
|
|
48
48
|
const external_preact_namespaceObject = require("preact");
|
|
49
49
|
;// CONCATENATED MODULE: external "preact/hooks"
|
|
50
50
|
const hooks_namespaceObject = require("preact/hooks");
|
|
51
|
+
;// CONCATENATED MODULE: ./node_modules/redux-thunk/es/index.js
|
|
52
|
+
function createThunkMiddleware(extraArgument) {
|
|
53
|
+
return function (_ref) {
|
|
54
|
+
var dispatch = _ref.dispatch,
|
|
55
|
+
getState = _ref.getState;
|
|
56
|
+
return function (next) {
|
|
57
|
+
return function (action) {
|
|
58
|
+
if (typeof action === 'function') {
|
|
59
|
+
return action(dispatch, getState, extraArgument);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return next(action);
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var thunk = createThunkMiddleware();
|
|
69
|
+
thunk.withExtraArgument = createThunkMiddleware;
|
|
70
|
+
|
|
71
|
+
/* harmony default export */ const es = (thunk);
|
|
51
72
|
;// CONCATENATED MODULE: ./src/javascripts/lib/id.js
|
|
52
73
|
function id_randomId() {
|
|
53
74
|
return '_' + (Number(String(Math.random()).slice(2)) + Date.now() + Math.round(performance.now())).toString(36);
|
|
@@ -145,7 +166,6 @@ const general_utils_millisecondsToSeconds = milliseconds => {
|
|
|
145
166
|
const microsecondsToMilliseconds = microseconds => {
|
|
146
167
|
return Math.ceil(microseconds / 1000);
|
|
147
168
|
};
|
|
148
|
-
const general_utils_sanitizeText = text => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g, '/');
|
|
149
169
|
const general_utils_getTimeFromSeconds = seconds => {
|
|
150
170
|
const minutes = Math.floor(seconds / 60);
|
|
151
171
|
const secondsPartial = seconds - minutes * 60;
|
|
@@ -270,12 +290,6 @@ const entryTypes = {
|
|
|
270
290
|
text: 'text',
|
|
271
291
|
upload: 'upload'
|
|
272
292
|
};
|
|
273
|
-
const seamly_utils_visibilityStates = {
|
|
274
|
-
hidden: 'hidden',
|
|
275
|
-
minimized: 'minimized',
|
|
276
|
-
open: 'open',
|
|
277
|
-
initialize: null
|
|
278
|
-
};
|
|
279
293
|
const readStates = {
|
|
280
294
|
received: 'received',
|
|
281
295
|
read: 'read'
|
|
@@ -322,7 +336,6 @@ const seamly_utils_seamlyActions = {
|
|
|
322
336
|
SET_PARTICIPANT: 'SET_PARTICIPANT',
|
|
323
337
|
SET_HEADER_TITLE: 'SET_HEADER_TITLE',
|
|
324
338
|
SET_HEADER_SUB_TITLE: 'SET_HEADER_SUB_TITLE',
|
|
325
|
-
SET_VISIBILITY: 'SET_VISIBILITY',
|
|
326
339
|
RESET_HISTORY_LOADED_FLAG: 'RESET_HISTORY_LOADED_FLAG',
|
|
327
340
|
SET_ACTIVE_SERVICE: 'SET_ACTIVE_SERVICE',
|
|
328
341
|
INIT_IDLE_DETACH_COUNTDOWN: 'INIT_IDLE_DETACH_COUNTDOWN',
|
|
@@ -350,8 +363,6 @@ const seamly_utils_seamlyActions = {
|
|
|
350
363
|
SET_UPLOAD_ERROR: 'SET_UPLOAD_ERROR',
|
|
351
364
|
CLEAR_UPLOAD: 'CLEAR_UPLOAD',
|
|
352
365
|
CLEAR_ALL_UPLOADS: 'CLEAR_ALL_UPLOADS',
|
|
353
|
-
RESET_UPLOAD_STATE: 'RESET_UPLOAD_STATE',
|
|
354
|
-
RESET_ENTRY_STATE: 'RESET_ENTRY_STATE',
|
|
355
366
|
SET_SEAMLY_CONTAINER_ELEMENT: 'SET_SEAMLY_CONTAINER_ELEMENT'
|
|
356
367
|
};
|
|
357
368
|
const cardTypes = {
|
|
@@ -370,7 +381,6 @@ const {
|
|
|
370
381
|
SET_PARTICIPANT,
|
|
371
382
|
SET_HEADER_TITLE,
|
|
372
383
|
SET_HEADER_SUB_TITLE,
|
|
373
|
-
SET_VISIBILITY,
|
|
374
384
|
RESET_HISTORY_LOADED_FLAG,
|
|
375
385
|
SET_ACTIVE_SERVICE,
|
|
376
386
|
INIT_IDLE_DETACH_COUNTDOWN,
|
|
@@ -398,8 +408,6 @@ const {
|
|
|
398
408
|
SET_UPLOAD_ERROR,
|
|
399
409
|
CLEAR_UPLOAD,
|
|
400
410
|
CLEAR_ALL_UPLOADS,
|
|
401
|
-
RESET_UPLOAD_STATE,
|
|
402
|
-
RESET_ENTRY_STATE,
|
|
403
411
|
SET_SEAMLY_CONTAINER_ELEMENT
|
|
404
412
|
} = seamly_utils_seamlyActions;
|
|
405
413
|
const isUnreadMessage = ({
|
|
@@ -778,11 +786,6 @@ const seamlyStateReducer = (state, action) => {
|
|
|
778
786
|
resumeConversationPrompt: false
|
|
779
787
|
});
|
|
780
788
|
|
|
781
|
-
case SET_VISIBILITY:
|
|
782
|
-
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
783
|
-
visible: action.visible
|
|
784
|
-
});
|
|
785
|
-
|
|
786
789
|
case SET_PARTICIPANT:
|
|
787
790
|
case CLEAR_PARTICIPANTS:
|
|
788
791
|
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
@@ -990,26 +993,6 @@ const seamlyStateReducer = (state, action) => {
|
|
|
990
993
|
currentUploads: []
|
|
991
994
|
});
|
|
992
995
|
|
|
993
|
-
case RESET_UPLOAD_STATE:
|
|
994
|
-
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
995
|
-
showFileUpload: false,
|
|
996
|
-
currentUploads: []
|
|
997
|
-
});
|
|
998
|
-
|
|
999
|
-
case RESET_ENTRY_STATE:
|
|
1000
|
-
{
|
|
1001
|
-
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
1002
|
-
entryMeta: {
|
|
1003
|
-
default: payloadTypes.text,
|
|
1004
|
-
active: payloadTypes.text,
|
|
1005
|
-
userSelected: null,
|
|
1006
|
-
blockAutoEntrySwitch: false,
|
|
1007
|
-
options: {},
|
|
1008
|
-
optionsOverride: {}
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
996
|
case SET_SEAMLY_CONTAINER_ELEMENT:
|
|
1014
997
|
{
|
|
1015
998
|
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
@@ -1021,81 +1004,6 @@ const seamlyStateReducer = (state, action) => {
|
|
|
1021
1004
|
return state;
|
|
1022
1005
|
}
|
|
1023
1006
|
};
|
|
1024
|
-
const seamly_utils_calculateVisibility = ({
|
|
1025
|
-
hasResponded,
|
|
1026
|
-
previousVisibility,
|
|
1027
|
-
requestedVisibility,
|
|
1028
|
-
config
|
|
1029
|
-
}) => {
|
|
1030
|
-
const {
|
|
1031
|
-
defaults,
|
|
1032
|
-
layoutMode,
|
|
1033
|
-
hideOnNoUserResponse
|
|
1034
|
-
} = config;
|
|
1035
|
-
const {
|
|
1036
|
-
visible: defaultVisibility
|
|
1037
|
-
} = defaults || {}; // Requesting open should override the responded check.
|
|
1038
|
-
|
|
1039
|
-
if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== seamly_utils_visibilityStates.open) {
|
|
1040
|
-
return hasResponded ? requestedVisibility || previousVisibility || seamly_utils_visibilityStates.open : seamly_utils_visibilityStates.hidden;
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
const baseVisibility = layoutMode === 'inline' ? seamly_utils_visibilityStates.open : seamly_utils_visibilityStates.minimized;
|
|
1044
|
-
return requestedVisibility || previousVisibility || defaultVisibility || baseVisibility;
|
|
1045
|
-
};
|
|
1046
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/store/state-reducer.js
|
|
1047
|
-
// Legacy state reducer. Do not add new features here but extract/create new reducers as needed
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
const initialState = {
|
|
1051
|
-
events: [],
|
|
1052
|
-
initialState: {},
|
|
1053
|
-
unreadEvents: 0,
|
|
1054
|
-
isLoading: false,
|
|
1055
|
-
idleDetachCountdown: {
|
|
1056
|
-
hasCountdown: false,
|
|
1057
|
-
isActive: false
|
|
1058
|
-
},
|
|
1059
|
-
resumeConversationPrompt: false,
|
|
1060
|
-
visible: seamly_utils_visibilityStates.hidden,
|
|
1061
|
-
serviceInfo: {
|
|
1062
|
-
activeServiceSessionId: ''
|
|
1063
|
-
},
|
|
1064
|
-
participantInfo: {
|
|
1065
|
-
participants: {},
|
|
1066
|
-
currentAgent: ''
|
|
1067
|
-
},
|
|
1068
|
-
headerTitles: {
|
|
1069
|
-
title: null,
|
|
1070
|
-
subTitle: ''
|
|
1071
|
-
},
|
|
1072
|
-
historyLoaded: false,
|
|
1073
|
-
skiplinkTargetId: id_randomId(),
|
|
1074
|
-
optionsButtonId: id_randomId(),
|
|
1075
|
-
cobrowsingContainerId: id_randomId(),
|
|
1076
|
-
headerCollapseButtonId: id_randomId(),
|
|
1077
|
-
serviceData: {},
|
|
1078
|
-
options: {
|
|
1079
|
-
features: {},
|
|
1080
|
-
panelActive: false,
|
|
1081
|
-
optionActive: '',
|
|
1082
|
-
userSelectedOptions: {}
|
|
1083
|
-
},
|
|
1084
|
-
showFileUpload: false,
|
|
1085
|
-
currentUploads: [],
|
|
1086
|
-
entryMeta: {
|
|
1087
|
-
default: entryTypes.text,
|
|
1088
|
-
active: entryTypes.text,
|
|
1089
|
-
userSelected: null,
|
|
1090
|
-
blockAutoEntrySwitch: false,
|
|
1091
|
-
options: {},
|
|
1092
|
-
optionsOverride: {}
|
|
1093
|
-
},
|
|
1094
|
-
seamlyContainerElement: null
|
|
1095
|
-
};
|
|
1096
|
-
function stateReducer(state = initialState, action) {
|
|
1097
|
-
return seamlyStateReducer(state, action);
|
|
1098
|
-
}
|
|
1099
1007
|
;// CONCATENATED MODULE: ./src/javascripts/lib/redux-helpers/index.js
|
|
1100
1008
|
function redux_helpers_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1101
1009
|
|
|
@@ -1207,12 +1115,7 @@ function createThunk(type, payloadCreator) {
|
|
|
1207
1115
|
});
|
|
1208
1116
|
}
|
|
1209
1117
|
function createReducer(domain, handlers = {}, defaultState) {
|
|
1210
|
-
const reducer = (state, action) => {
|
|
1211
|
-
if (state === undefined) {
|
|
1212
|
-
// eslint-disable-next-line no-param-reassign
|
|
1213
|
-
state = defaultState;
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1118
|
+
const reducer = (state = defaultState, action) => {
|
|
1216
1119
|
const typeReducer = handlers === null || handlers === void 0 ? void 0 : handlers[action === null || action === void 0 ? void 0 : action.type];
|
|
1217
1120
|
return typeReducer ? typeReducer(state, action) : state;
|
|
1218
1121
|
};
|
|
@@ -1230,63 +1133,22 @@ function createDomain(domain) {
|
|
|
1230
1133
|
selectState: state => state[domain]
|
|
1231
1134
|
};
|
|
1232
1135
|
}
|
|
1233
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/
|
|
1136
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/config/utils.js
|
|
1234
1137
|
|
|
1235
1138
|
const {
|
|
1236
|
-
|
|
1139
|
+
createAction: utils_createAction,
|
|
1140
|
+
createThunk: utils_createThunk,
|
|
1237
1141
|
createReducer: utils_createReducer,
|
|
1238
1142
|
selectState
|
|
1239
|
-
} = createDomain('
|
|
1240
|
-
|
|
1241
|
-
return Object.entries(schema).reduce((errors, [key, validations]) => {
|
|
1242
|
-
if (validations && !Array.isArray(validations)) {
|
|
1243
|
-
// eslint-disable-next-line no-param-reassign
|
|
1244
|
-
validations = [validations];
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
for (let i = 0; i < ((_validations = validations) === null || _validations === void 0 ? void 0 : _validations.length) ?? 0; i++) {
|
|
1248
|
-
var _validations;
|
|
1249
|
-
|
|
1250
|
-
if (!validations[i].fn(values[key], validations[i].compareValue)) {
|
|
1251
|
-
errors[key] = validations[i].errorText;
|
|
1252
|
-
break;
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
return errors;
|
|
1257
|
-
}, {});
|
|
1258
|
-
}
|
|
1259
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/actions.js
|
|
1143
|
+
} = createDomain('config');
|
|
1144
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/config/actions.js
|
|
1260
1145
|
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
formId
|
|
1268
|
-
})
|
|
1269
|
-
});
|
|
1270
|
-
const [registerControl, deregisterControl, updateControlValue, updateControlTouched] = utils_createActions('control', {
|
|
1271
|
-
register: (formId, name) => ({
|
|
1272
|
-
formId,
|
|
1273
|
-
name
|
|
1274
|
-
}),
|
|
1275
|
-
deregister: (formId, name) => ({
|
|
1276
|
-
formId,
|
|
1277
|
-
name
|
|
1278
|
-
}),
|
|
1279
|
-
updateValue: (formId, name, value) => ({
|
|
1280
|
-
formId,
|
|
1281
|
-
name,
|
|
1282
|
-
value
|
|
1283
|
-
}),
|
|
1284
|
-
updateTouched: (formId, name, touched) => ({
|
|
1285
|
-
formId,
|
|
1286
|
-
name,
|
|
1287
|
-
touched
|
|
1288
|
-
})
|
|
1289
|
-
});
|
|
1146
|
+
const initialize = utils_createAction('initialize', config => ({
|
|
1147
|
+
config
|
|
1148
|
+
}));
|
|
1149
|
+
const update = utils_createAction('update', config => ({
|
|
1150
|
+
config
|
|
1151
|
+
}));
|
|
1290
1152
|
;// CONCATENATED MODULE: ./node_modules/reselect/es/index.js
|
|
1291
1153
|
function defaultEqualityCheck(a, b) {
|
|
1292
1154
|
return a === b;
|
|
@@ -1408,45 +1270,39 @@ function createStructuredSelector(selectors) {
|
|
|
1408
1270
|
}, {});
|
|
1409
1271
|
});
|
|
1410
1272
|
}
|
|
1411
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/
|
|
1412
|
-
const
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1273
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/constants.js
|
|
1274
|
+
const StoreKey = 'visibility';
|
|
1275
|
+
const constants_visibilityStates = {
|
|
1276
|
+
hidden: 'hidden',
|
|
1277
|
+
minimized: 'minimized',
|
|
1278
|
+
open: 'open',
|
|
1279
|
+
initialize: null
|
|
1280
|
+
};
|
|
1281
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/config/selectors.js
|
|
1282
|
+
function selectors_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1416
1283
|
|
|
1417
|
-
|
|
1418
|
-
return false;
|
|
1419
|
-
}
|
|
1284
|
+
function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selectors_ownKeys(Object(source), true).forEach(function (key) { selectors_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { selectors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1420
1285
|
|
|
1421
|
-
|
|
1422
|
-
};
|
|
1423
|
-
const getPropSelector = (propName, orDefault) => (_, props) => props[propName] || orDefault;
|
|
1424
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/selectors.js
|
|
1286
|
+
function selectors_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1425
1287
|
|
|
1426
1288
|
|
|
1427
1289
|
|
|
1428
|
-
const getState = selectState;
|
|
1429
|
-
const selectors_getFormById = createSelector(getState, getPropSelector('formId'), (forms, formId) => forms[formId]);
|
|
1430
|
-
const getFormControlsByFormId = createSelector(selectors_getFormById, form => (form === null || form === void 0 ? void 0 : form.controls) || {});
|
|
1431
|
-
const selectors_getFormValuesByFormId = createSelector(getFormControlsByFormId, controls => {
|
|
1432
|
-
const valuesObj = {};
|
|
1433
|
-
Object.entries(controls).forEach(([key, {
|
|
1434
|
-
value
|
|
1435
|
-
}]) => {
|
|
1436
|
-
valuesObj[key] = value;
|
|
1437
|
-
});
|
|
1438
|
-
return valuesObj;
|
|
1439
|
-
});
|
|
1440
|
-
const selectors_getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
1441
|
-
var _controls$name;
|
|
1442
1290
|
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1291
|
+
const selectConfig = createSelector(selectState, config => {
|
|
1292
|
+
let newConfig = selectors_objectSpread({
|
|
1293
|
+
visible: (config === null || config === void 0 ? void 0 : config.layoutMode) === 'inline' ? constants_visibilityStates.open : constants_visibilityStates.minimized,
|
|
1294
|
+
appContainerClassNames: config.appContainerClassNames || []
|
|
1295
|
+
}, config);
|
|
1447
1296
|
|
|
1448
|
-
|
|
1297
|
+
if (typeof newConfig.appContainerClassNames === 'function') {
|
|
1298
|
+
newConfig = selectors_objectSpread(selectors_objectSpread({}, newConfig), {}, {
|
|
1299
|
+
appContainerClassNames: newConfig.appContainerClassNames(newConfig)
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
return newConfig;
|
|
1449
1304
|
});
|
|
1305
|
+
|
|
1450
1306
|
;// CONCATENATED MODULE: ./src/javascripts/domains/redux/context.js
|
|
1451
1307
|
|
|
1452
1308
|
const context_StoreContext = (0,external_preact_namespaceObject.createContext)(undefined);
|
|
@@ -1545,1024 +1401,839 @@ const hooks_useSelectorWithProps = function useSelectorWithProps(selector, props
|
|
|
1545
1401
|
|
|
1546
1402
|
|
|
1547
1403
|
|
|
1548
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/
|
|
1404
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/config/hooks.js
|
|
1549
1405
|
|
|
1550
|
-
const context_FormContext = (0,external_preact_namespaceObject.createContext)({});
|
|
1551
|
-
/* harmony default export */ const forms_context = ((/* unused pure expression or super */ null && (context_FormContext)));
|
|
1552
|
-
const {
|
|
1553
|
-
Provider: forms_context_Provider,
|
|
1554
|
-
Consumer: context_Consumer
|
|
1555
|
-
} = context_FormContext;
|
|
1556
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/hooks.js
|
|
1557
1406
|
|
|
1407
|
+
function hooks_useConfig() {
|
|
1408
|
+
return useSelector(Selectors.selectConfig);
|
|
1409
|
+
}
|
|
1410
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/config/middleware.js
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
function createMiddleware() {
|
|
1414
|
+
return ({
|
|
1415
|
+
dispatch
|
|
1416
|
+
}) => next => action => {
|
|
1417
|
+
var _action$config, _action$config$defaul;
|
|
1558
1418
|
|
|
1419
|
+
const result = next(action);
|
|
1559
1420
|
|
|
1421
|
+
switch (action.type) {
|
|
1422
|
+
case String(Actions.initialize):
|
|
1423
|
+
case String(Actions.update):
|
|
1424
|
+
if (action !== null && action !== void 0 && (_action$config = action.config) !== null && _action$config !== void 0 && (_action$config$defaul = _action$config.defaults) !== null && _action$config$defaul !== void 0 && _action$config$defaul.agentName) {
|
|
1425
|
+
var _action$config2, _action$config2$defau;
|
|
1560
1426
|
|
|
1427
|
+
dispatch({
|
|
1428
|
+
type: seamlyActions.SET_HEADER_SUB_TITLE,
|
|
1429
|
+
title: action === null || action === void 0 ? void 0 : (_action$config2 = action.config) === null || _action$config2 === void 0 ? void 0 : (_action$config2$defau = _action$config2.defaults) === null || _action$config2$defau === void 0 ? void 0 : _action$config2$defau.agentName
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1561
1432
|
|
|
1433
|
+
}
|
|
1562
1434
|
|
|
1563
|
-
|
|
1564
|
-
return useContext(FormContext);
|
|
1565
|
-
}
|
|
1566
|
-
function hooks_useForm() {
|
|
1567
|
-
const {
|
|
1568
|
-
handleSubmit
|
|
1569
|
-
} = hooks_useFormContext();
|
|
1570
|
-
return {
|
|
1571
|
-
handleSubmit
|
|
1435
|
+
return result;
|
|
1572
1436
|
};
|
|
1573
1437
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
};
|
|
1580
|
-
}
|
|
1581
|
-
function hooks_useFormControl(name) {
|
|
1582
|
-
const dispatch = useStoreDispatch();
|
|
1583
|
-
const {
|
|
1584
|
-
formId,
|
|
1585
|
-
updateControlValue,
|
|
1586
|
-
updateControlTouched,
|
|
1587
|
-
errors
|
|
1588
|
-
} = hooks_useFormContext();
|
|
1589
|
-
const form = useSelectorWithProps(getFormById, {
|
|
1590
|
-
formId
|
|
1591
|
-
}, [formId]);
|
|
1592
|
-
const isRegistered = !!form;
|
|
1593
|
-
const isRegisteredRef = useRef();
|
|
1594
|
-
isRegisteredRef.current = isRegistered;
|
|
1595
|
-
const value = useSelectorWithProps(getControlValueByName, {
|
|
1596
|
-
formId,
|
|
1597
|
-
name
|
|
1598
|
-
}, [formId, name]);
|
|
1599
|
-
const touched = useSelectorWithProps(getControlTouchedByName, {
|
|
1600
|
-
formId,
|
|
1601
|
-
name
|
|
1602
|
-
}, [formId, name]);
|
|
1603
|
-
const error = errors === null || errors === void 0 ? void 0 : errors[name];
|
|
1604
|
-
const isValid = !error;
|
|
1605
|
-
useEffect(() => {
|
|
1606
|
-
// Make sure the form is registered
|
|
1607
|
-
// Since child useEffect runs before FormProvider useEffect
|
|
1608
|
-
if (isRegisteredRef.current) {
|
|
1609
|
-
dispatch(Actions.registerControl(formId, name));
|
|
1610
|
-
}
|
|
1611
|
-
}, [isRegistered, formId, name, dispatch]);
|
|
1612
|
-
useLayoutEffect(() => {
|
|
1613
|
-
return () => {
|
|
1614
|
-
dispatch(Actions.deregisterControl(formId, name));
|
|
1615
|
-
};
|
|
1616
|
-
}, [isRegistered, formId, name, dispatch]); // preact uses onInput instead of onChange
|
|
1617
|
-
|
|
1618
|
-
const onInput = useCallback(e => updateControlValue(name, e.target.value), [name, updateControlValue]);
|
|
1619
|
-
const onBlur = useCallback(() => {
|
|
1620
|
-
updateControlTouched(name, true);
|
|
1621
|
-
}, [updateControlTouched, name]);
|
|
1622
|
-
const field = useMemo(() => ({
|
|
1623
|
-
name,
|
|
1624
|
-
onInput,
|
|
1625
|
-
onBlur,
|
|
1626
|
-
value
|
|
1627
|
-
}), [name, onInput, onBlur, value]);
|
|
1628
|
-
const meta = useMemo(() => ({
|
|
1629
|
-
isValid,
|
|
1630
|
-
error,
|
|
1631
|
-
touched
|
|
1632
|
-
}), [isValid, error, touched]);
|
|
1633
|
-
return [field, meta];
|
|
1634
|
-
}
|
|
1635
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/provider.js
|
|
1636
|
-
const _excluded = (/* unused pure expression or super */ null && (["children", "formId", "persistData", "onSubmit", "validationSchema"]));
|
|
1438
|
+
;// CONCATENATED MODULE: ./src/javascripts/config.js
|
|
1439
|
+
const CSS_NAME = 'cvco';
|
|
1440
|
+
const apiVersion = '2';
|
|
1441
|
+
const config_userParticipantId = 'seamly-client-participant'; // How long to debounce distinct changes in unread messages for before
|
|
1442
|
+
// broadcasting to the screen reader. This is done to avoid verbosity.
|
|
1637
1443
|
|
|
1638
|
-
|
|
1444
|
+
const unreadScreenReaderWait = 2000;
|
|
1445
|
+
const newMessageScreenReaderWait = 1000;
|
|
1446
|
+
const config_screenReaderDebounceDelaySeconds = 10;
|
|
1447
|
+
const activitySendDelay = 15000;
|
|
1448
|
+
const maxCharacterWarningLimit = 50;
|
|
1449
|
+
const maxCharacterSrDebounceDelay = 300;
|
|
1450
|
+
const config_defaultTransitionTimeMs = 300; // How long to wait before we decide the user isn't typing
|
|
1639
1451
|
|
|
1640
|
-
|
|
1452
|
+
const config_typingTimeout = 2000;
|
|
1453
|
+
const defaultConfig = {
|
|
1454
|
+
namespace: 'default',
|
|
1455
|
+
layoutMode: 'window',
|
|
1456
|
+
// "window", "inline" ("sidebar"), "modal"
|
|
1457
|
+
messages: {
|
|
1458
|
+
agent: {
|
|
1459
|
+
showAvatar: false,
|
|
1460
|
+
// true, "inline"
|
|
1461
|
+
showName: false
|
|
1462
|
+
},
|
|
1463
|
+
user: {
|
|
1464
|
+
showAvatar: false,
|
|
1465
|
+
// true, "inline"
|
|
1466
|
+
showName: false
|
|
1467
|
+
},
|
|
1468
|
+
timeIndicator: {
|
|
1469
|
+
enabled: false,
|
|
1470
|
+
threshold: 3600000 // Default threshold is an hour in milliseconds
|
|
1641
1471
|
|
|
1642
|
-
|
|
1472
|
+
}
|
|
1473
|
+
},
|
|
1474
|
+
appContainerClassNames: config => [`app--layout-${config.layoutMode}`, `namespace--${config.namespace}`]
|
|
1475
|
+
};
|
|
1476
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/config/reducer.js
|
|
1477
|
+
const _excluded = ["messages"];
|
|
1643
1478
|
|
|
1644
1479
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
1645
1480
|
|
|
1646
1481
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1647
1482
|
|
|
1483
|
+
function reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1648
1484
|
|
|
1485
|
+
function reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { reducer_ownKeys(Object(source), true).forEach(function (key) { reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1649
1486
|
|
|
1487
|
+
function reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1650
1488
|
|
|
1651
1489
|
|
|
1652
1490
|
|
|
1653
1491
|
|
|
1654
1492
|
|
|
1655
|
-
function provider_FormProvider(_ref) {
|
|
1656
|
-
let {
|
|
1657
|
-
children,
|
|
1658
|
-
formId,
|
|
1659
|
-
persistData,
|
|
1660
|
-
onSubmit,
|
|
1661
|
-
validationSchema
|
|
1662
|
-
} = _ref,
|
|
1663
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
1664
|
-
|
|
1665
|
-
const dispatch = useStoreDispatch();
|
|
1666
|
-
const values = useSelectorWithProps(getFormValuesByFormId, {
|
|
1667
|
-
formId
|
|
1668
|
-
}, [formId]);
|
|
1669
|
-
const [isSubmitted, setIsSubmitted] = useState(false);
|
|
1670
|
-
const [externalErrors, setExternalErrors] = useState({});
|
|
1671
|
-
const {
|
|
1672
|
-
isValid: validationIsValid,
|
|
1673
|
-
errors: validationErrors
|
|
1674
|
-
} = useValidations(values, validationSchema);
|
|
1675
|
-
const errors = useMemo(() => provider_objectSpread(provider_objectSpread({}, validationErrors), externalErrors), [validationErrors, externalErrors]); // register
|
|
1676
1493
|
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1494
|
+
const initialState = reducer_objectSpread(reducer_objectSpread({}, defaultConfig), {}, {
|
|
1495
|
+
hideOnNoUserResponse: false,
|
|
1496
|
+
showDisclaimer: false,
|
|
1497
|
+
showFaq: false,
|
|
1498
|
+
customComponents: {},
|
|
1499
|
+
defaults: {}
|
|
1500
|
+
});
|
|
1681
1501
|
|
|
1682
|
-
|
|
1683
|
-
return () => {
|
|
1684
|
-
// deregister form from redux store
|
|
1685
|
-
dispatch(Actions.deregisterForm(formId));
|
|
1686
|
-
};
|
|
1687
|
-
}, [formId, persistData, dispatch]);
|
|
1688
|
-
const updateControlValue = useCallback((name, value) => {
|
|
1689
|
-
dispatch(Actions.updateControlValue(formId, name, value));
|
|
1690
|
-
}, [formId, dispatch]);
|
|
1691
|
-
const updateControlTouched = useCallback((name, touched) => {
|
|
1692
|
-
dispatch(Actions.updateControlTouched(formId, name, touched));
|
|
1693
|
-
}, [dispatch, formId]); // Function to manually set an error
|
|
1502
|
+
const configKeys = ['hideOnNoUserResponse', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback'];
|
|
1694
1503
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
},
|
|
1702
|
-
|
|
1703
|
-
e.preventDefault();
|
|
1704
|
-
setIsSubmitted(true);
|
|
1504
|
+
const updateState = (state, {
|
|
1505
|
+
config
|
|
1506
|
+
}) => {
|
|
1507
|
+
const _pick = pick(config, configKeys),
|
|
1508
|
+
{
|
|
1509
|
+
messages
|
|
1510
|
+
} = _pick,
|
|
1511
|
+
partialConfig = _objectWithoutProperties(_pick, _excluded);
|
|
1705
1512
|
|
|
1706
|
-
|
|
1707
|
-
onSubmit(values, {
|
|
1708
|
-
updateControlValue,
|
|
1709
|
-
setError
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
}, [validationIsValid, onSubmit, values, updateControlValue, setError]);
|
|
1713
|
-
const contextValue = useMemo(() => ({
|
|
1714
|
-
formId,
|
|
1715
|
-
values,
|
|
1716
|
-
errors,
|
|
1717
|
-
isValid: Object.keys(errors).length === 0,
|
|
1718
|
-
isSubmitted,
|
|
1719
|
-
handleSubmit,
|
|
1720
|
-
validationSchema,
|
|
1721
|
-
updateControlValue,
|
|
1722
|
-
updateControlTouched
|
|
1723
|
-
}), [formId, values, errors, isSubmitted, handleSubmit, validationSchema, updateControlValue, updateControlTouched]);
|
|
1513
|
+
let newState = state;
|
|
1724
1514
|
|
|
1725
|
-
if (
|
|
1726
|
-
|
|
1727
|
-
return null;
|
|
1515
|
+
if (Object.keys(partialConfig).length > 0) {
|
|
1516
|
+
newState = reducer_objectSpread(reducer_objectSpread({}, newState), partialConfig);
|
|
1728
1517
|
}
|
|
1729
1518
|
|
|
1730
|
-
if (
|
|
1731
|
-
|
|
1732
|
-
|
|
1519
|
+
if (messages) {
|
|
1520
|
+
newState = reducer_objectSpread(reducer_objectSpread({}, newState), {}, {
|
|
1521
|
+
messages: reducer_objectSpread(reducer_objectSpread({}, newState.messages), messages)
|
|
1522
|
+
});
|
|
1733
1523
|
}
|
|
1734
1524
|
|
|
1735
|
-
return
|
|
1736
|
-
|
|
1737
|
-
children: children
|
|
1738
|
-
}));
|
|
1739
|
-
}
|
|
1740
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/reducer.js
|
|
1741
|
-
function reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1742
|
-
|
|
1743
|
-
function reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { reducer_ownKeys(Object(source), true).forEach(function (key) { reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1525
|
+
return newState;
|
|
1526
|
+
};
|
|
1744
1527
|
|
|
1745
|
-
|
|
1528
|
+
/* harmony default export */ const reducer = (utils_createReducer({
|
|
1529
|
+
[initialize]: (state, action) => {
|
|
1530
|
+
return updateState(state, action);
|
|
1531
|
+
},
|
|
1532
|
+
[update]: (state, action) => {
|
|
1533
|
+
return updateState(state, action);
|
|
1534
|
+
}
|
|
1535
|
+
}, initialState));
|
|
1536
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/config/index.js
|
|
1746
1537
|
|
|
1747
1538
|
|
|
1748
1539
|
|
|
1749
|
-
const reducer_initialState = {};
|
|
1750
|
-
const initialFormState = {
|
|
1751
|
-
controls: {}
|
|
1752
|
-
};
|
|
1753
|
-
const initialControlState = {
|
|
1754
|
-
value: '',
|
|
1755
|
-
touched: false
|
|
1756
|
-
};
|
|
1757
1540
|
|
|
1758
|
-
function updateFormControl(state, formId, name, controlState) {
|
|
1759
|
-
var _state$formId;
|
|
1760
1541
|
|
|
1761
|
-
const currentControlState = ((_state$formId = state[formId]) === null || _state$formId === void 0 ? void 0 : _state$formId.controls[name]) || initialControlState;
|
|
1762
|
-
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
|
|
1763
|
-
[formId]: reducer_objectSpread(reducer_objectSpread({}, state[formId]), {}, {
|
|
1764
|
-
controls: reducer_objectSpread(reducer_objectSpread({}, state[formId].controls), {}, {
|
|
1765
|
-
[name]: reducer_objectSpread(reducer_objectSpread({}, currentControlState), controlState)
|
|
1766
|
-
})
|
|
1767
|
-
})
|
|
1768
|
-
});
|
|
1769
|
-
}
|
|
1770
1542
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
persistData
|
|
1776
|
-
}) => {
|
|
1777
|
-
const formState = persistData ? state[formId] ?? reducer_objectSpread(reducer_objectSpread({}, initialFormState), {}, {
|
|
1778
|
-
persistData
|
|
1779
|
-
}) : reducer_objectSpread(reducer_objectSpread({}, initialFormState), {}, {
|
|
1780
|
-
persistData
|
|
1781
|
-
});
|
|
1782
|
-
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
|
|
1783
|
-
[formId]: formState
|
|
1784
|
-
});
|
|
1785
|
-
},
|
|
1786
|
-
[deregisterForm]: (state, {
|
|
1787
|
-
formId
|
|
1788
|
-
}) => {
|
|
1789
|
-
var _newState$formId;
|
|
1543
|
+
;// CONCATENATED MODULE: ./src/javascripts/lib/mutex.js
|
|
1544
|
+
function createMutex() {
|
|
1545
|
+
let isRunning = false;
|
|
1546
|
+
const tasks = [];
|
|
1790
1547
|
|
|
1791
|
-
|
|
1548
|
+
const next = async () => {
|
|
1549
|
+
if (!isRunning) {
|
|
1550
|
+
while (tasks.length) {
|
|
1551
|
+
const task = tasks.shift();
|
|
1552
|
+
isRunning = true; // eslint-disable-next-line no-await-in-loop
|
|
1792
1553
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1554
|
+
await task().catch(() => {});
|
|
1555
|
+
isRunning = false;
|
|
1556
|
+
}
|
|
1795
1557
|
}
|
|
1558
|
+
};
|
|
1796
1559
|
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
[deregisterControl]: (state, {
|
|
1807
|
-
formId,
|
|
1808
|
-
name
|
|
1809
|
-
}) => {
|
|
1810
|
-
const form = state[formId];
|
|
1811
|
-
|
|
1812
|
-
if (!form) {
|
|
1813
|
-
return state;
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
if (form.persistData) {
|
|
1817
|
-
return state;
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
const controls = reducer_objectSpread({}, form.controls);
|
|
1821
|
-
|
|
1822
|
-
delete controls[name];
|
|
1823
|
-
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
|
|
1824
|
-
[formId]: reducer_objectSpread(reducer_objectSpread({}, form), {}, {
|
|
1825
|
-
controls
|
|
1826
|
-
})
|
|
1827
|
-
});
|
|
1828
|
-
},
|
|
1829
|
-
[updateControlValue]: (state, {
|
|
1830
|
-
formId,
|
|
1831
|
-
name,
|
|
1832
|
-
value
|
|
1833
|
-
}) => {
|
|
1834
|
-
return updateFormControl(state, formId, name, {
|
|
1835
|
-
value
|
|
1836
|
-
});
|
|
1837
|
-
},
|
|
1838
|
-
[updateControlTouched]: (state, {
|
|
1839
|
-
formId,
|
|
1840
|
-
name,
|
|
1841
|
-
touched
|
|
1842
|
-
}) => {
|
|
1843
|
-
return updateFormControl(state, formId, name, {
|
|
1844
|
-
touched
|
|
1560
|
+
const runExclusively = async task => {
|
|
1561
|
+
const prms = new Promise((resolve, reject) => {
|
|
1562
|
+
tasks.push(async () => {
|
|
1563
|
+
try {
|
|
1564
|
+
resolve(await task());
|
|
1565
|
+
} catch (e) {
|
|
1566
|
+
reject(e);
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1845
1569
|
});
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1570
|
+
next();
|
|
1571
|
+
return prms;
|
|
1572
|
+
};
|
|
1854
1573
|
|
|
1855
|
-
|
|
1574
|
+
return {
|
|
1575
|
+
next,
|
|
1576
|
+
runExclusively
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/utils.js
|
|
1856
1580
|
|
|
1857
1581
|
const {
|
|
1858
|
-
|
|
1859
|
-
|
|
1582
|
+
createAction: i18n_utils_createAction,
|
|
1583
|
+
createThunk: i18n_utils_createThunk,
|
|
1584
|
+
createReducer: i18n_utils_createReducer,
|
|
1860
1585
|
selectState: utils_selectState
|
|
1861
|
-
} = createDomain('
|
|
1862
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/
|
|
1863
|
-
|
|
1864
|
-
const [enable, disable] = translations_utils_createActions('translate', {
|
|
1865
|
-
enable: locale => ({
|
|
1866
|
-
locale
|
|
1867
|
-
}),
|
|
1868
|
-
disable: () => ({})
|
|
1869
|
-
});
|
|
1870
|
-
const [enableEvent, disableEvent] = translations_utils_createActions('event', {
|
|
1871
|
-
enable: payloadId => ({
|
|
1872
|
-
payloadId
|
|
1873
|
-
}),
|
|
1874
|
-
disable: payloadId => ({
|
|
1875
|
-
payloadId
|
|
1876
|
-
})
|
|
1877
|
-
});
|
|
1878
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/selectors.js
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
const selectors_getState = utils_selectState;
|
|
1883
|
-
const getOriginalPayloadIds = createSelector(selectors_getState, state => state.originalPayloadIds);
|
|
1884
|
-
const getIsPayloadTranslated = createSelector(getOriginalPayloadIds, getPropSelector('payloadId'), (payloadIds, payloadId) => !payloadIds.includes(payloadId));
|
|
1885
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/components/core/seamly-api-context.js
|
|
1886
|
-
|
|
1887
|
-
const seamly_api_context_SeamlyApiContext = (0,external_preact_namespaceObject.createContext)(null);
|
|
1888
|
-
const seamly_api_context_SeamlyEventBusContext = (0,external_preact_namespaceObject.createContext)('');
|
|
1889
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/seamly-api-hooks.js
|
|
1586
|
+
} = createDomain('i18n');
|
|
1587
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/selectors.js
|
|
1890
1588
|
|
|
1891
1589
|
|
|
1892
|
-
const
|
|
1893
|
-
const
|
|
1894
|
-
|
|
1895
|
-
return api.store || {};
|
|
1896
|
-
};
|
|
1897
|
-
const useSeamlyConversationUrl = () => {
|
|
1898
|
-
const {
|
|
1899
|
-
get
|
|
1900
|
-
} = seamly_api_hooks_useSeamlyObjectStore();
|
|
1590
|
+
const selectTranslations = createSelector(utils_selectState, state => state.translations);
|
|
1591
|
+
const selectInitialLocale = createSelector(utils_selectState, state => state.initialLocale);
|
|
1592
|
+
const selectLocale = createSelector(utils_selectState, state => state.locale);
|
|
1901
1593
|
|
|
1902
|
-
|
|
1903
|
-
return get('conversationUrl');
|
|
1904
|
-
}
|
|
1594
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/actions.js
|
|
1905
1595
|
|
|
1906
|
-
return null;
|
|
1907
|
-
};
|
|
1908
|
-
const seamly_api_hooks_useSeamlyHasConversation = () => {
|
|
1909
|
-
const url = useSeamlyConversationUrl();
|
|
1910
|
-
return !!url;
|
|
1911
|
-
};
|
|
1912
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/config/utils.js
|
|
1913
1596
|
|
|
1914
|
-
const {
|
|
1915
|
-
createAction: utils_createAction,
|
|
1916
|
-
createThunk: utils_createThunk,
|
|
1917
|
-
createReducer: config_utils_createReducer,
|
|
1918
|
-
selectState: config_utils_selectState
|
|
1919
|
-
} = createDomain('config');
|
|
1920
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/config/actions.js
|
|
1921
1597
|
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1924
|
-
}));
|
|
1925
|
-
const update = utils_createAction('update', config => ({
|
|
1926
|
-
config
|
|
1598
|
+
const setInitialLocale = i18n_utils_createAction('setInitialLocale', locale => ({
|
|
1599
|
+
locale
|
|
1927
1600
|
}));
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1601
|
+
const mutex = createMutex();
|
|
1602
|
+
const setLocale = i18n_utils_createThunk('setLocale', async (locale, {
|
|
1603
|
+
getState,
|
|
1604
|
+
extra: {
|
|
1605
|
+
api
|
|
1606
|
+
}
|
|
1607
|
+
}) => {
|
|
1608
|
+
return mutex.runExclusively(() => {
|
|
1609
|
+
if (locale === selectLocale(getState())) {
|
|
1610
|
+
return undefined;
|
|
1611
|
+
}
|
|
1934
1612
|
|
|
1613
|
+
return api.getTranslations(locale);
|
|
1614
|
+
});
|
|
1615
|
+
});
|
|
1616
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
1617
|
+
function _arrayWithHoles(arr) {
|
|
1618
|
+
if (Array.isArray(arr)) return arr;
|
|
1619
|
+
}
|
|
1620
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
1621
|
+
function _iterableToArrayLimit(arr, i) {
|
|
1622
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1935
1623
|
|
|
1624
|
+
if (_i == null) return;
|
|
1625
|
+
var _arr = [];
|
|
1626
|
+
var _n = true;
|
|
1627
|
+
var _d = false;
|
|
1936
1628
|
|
|
1629
|
+
var _s, _e;
|
|
1937
1630
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
appContainerClassNames: config.appContainerClassNames || []
|
|
1942
|
-
}, config);
|
|
1631
|
+
try {
|
|
1632
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
1633
|
+
_arr.push(_s.value);
|
|
1943
1634
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1635
|
+
if (i && _arr.length === i) break;
|
|
1636
|
+
}
|
|
1637
|
+
} catch (err) {
|
|
1638
|
+
_d = true;
|
|
1639
|
+
_e = err;
|
|
1640
|
+
} finally {
|
|
1641
|
+
try {
|
|
1642
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1643
|
+
} finally {
|
|
1644
|
+
if (_d) throw _e;
|
|
1645
|
+
}
|
|
1948
1646
|
}
|
|
1949
1647
|
|
|
1950
|
-
return
|
|
1951
|
-
});
|
|
1952
|
-
|
|
1953
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/config/hooks.js
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
function hooks_useConfig() {
|
|
1957
|
-
return useSelector(Selectors.selectConfig);
|
|
1648
|
+
return _arr;
|
|
1958
1649
|
}
|
|
1959
|
-
;// CONCATENATED MODULE: ./
|
|
1650
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
1651
|
+
function _arrayLikeToArray(arr, len) {
|
|
1652
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1960
1653
|
|
|
1654
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1655
|
+
arr2[i] = arr[i];
|
|
1656
|
+
}
|
|
1961
1657
|
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
}) => next => action => {
|
|
1966
|
-
var _action$config, _action$config$defaul;
|
|
1658
|
+
return arr2;
|
|
1659
|
+
}
|
|
1660
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
1967
1661
|
|
|
1968
|
-
|
|
1662
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
1663
|
+
if (!o) return;
|
|
1664
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1665
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1666
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1667
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1668
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1669
|
+
}
|
|
1670
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
|
1671
|
+
function _nonIterableRest() {
|
|
1672
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1673
|
+
}
|
|
1674
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
|
1969
1675
|
|
|
1970
|
-
switch (action.type) {
|
|
1971
|
-
case String(Actions.initialize):
|
|
1972
|
-
case String(Actions.update):
|
|
1973
|
-
if (action !== null && action !== void 0 && (_action$config = action.config) !== null && _action$config !== void 0 && (_action$config$defaul = _action$config.defaults) !== null && _action$config$defaul !== void 0 && _action$config$defaul.agentName) {
|
|
1974
|
-
var _action$config2, _action$config2$defau;
|
|
1975
1676
|
|
|
1976
|
-
dispatch({
|
|
1977
|
-
type: seamlyActions.SET_HEADER_SUB_TITLE,
|
|
1978
|
-
title: action === null || action === void 0 ? void 0 : (_action$config2 = action.config) === null || _action$config2 === void 0 ? void 0 : (_action$config2$defau = _action$config2.defaults) === null || _action$config2$defau === void 0 ? void 0 : _action$config2$defau.agentName
|
|
1979
|
-
});
|
|
1980
|
-
}
|
|
1981
1677
|
|
|
1982
|
-
}
|
|
1983
1678
|
|
|
1984
|
-
|
|
1985
|
-
|
|
1679
|
+
function _slicedToArray(arr, i) {
|
|
1680
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1681
|
+
}
|
|
1682
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
|
1683
|
+
function _classCallCheck(instance, Constructor) {
|
|
1684
|
+
if (!(instance instanceof Constructor)) {
|
|
1685
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/createClass.js
|
|
1689
|
+
function _defineProperties(target, props) {
|
|
1690
|
+
for (var i = 0; i < props.length; i++) {
|
|
1691
|
+
var descriptor = props[i];
|
|
1692
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1693
|
+
descriptor.configurable = true;
|
|
1694
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1695
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1696
|
+
}
|
|
1986
1697
|
}
|
|
1987
|
-
;// CONCATENATED MODULE: ./src/javascripts/config.js
|
|
1988
|
-
const CSS_NAME = 'cvco';
|
|
1989
|
-
const apiVersion = '2';
|
|
1990
|
-
const config_userParticipantId = 'seamly-client-participant'; // How long to debounce distinct changes in unread messages for before
|
|
1991
|
-
// broadcasting to the screen reader. This is done to avoid verbosity.
|
|
1992
|
-
|
|
1993
|
-
const unreadScreenReaderWait = 2000;
|
|
1994
|
-
const newMessageScreenReaderWait = 1000;
|
|
1995
|
-
const config_screenReaderDebounceDelaySeconds = 10;
|
|
1996
|
-
const activitySendDelay = 15000;
|
|
1997
|
-
const maxCharacterWarningLimit = 50;
|
|
1998
|
-
const maxCharacterSrDebounceDelay = 300;
|
|
1999
|
-
const config_defaultTransitionTimeMs = 300; // How long to wait before we decide the user isn't typing
|
|
2000
|
-
|
|
2001
|
-
const config_typingTimeout = 2000;
|
|
2002
|
-
const defaultConfig = {
|
|
2003
|
-
namespace: 'default',
|
|
2004
|
-
layoutMode: 'window',
|
|
2005
|
-
// "window", "inline" ("sidebar"), "modal"
|
|
2006
|
-
messages: {
|
|
2007
|
-
agent: {
|
|
2008
|
-
showAvatar: false,
|
|
2009
|
-
// true, "inline"
|
|
2010
|
-
showName: false
|
|
2011
|
-
},
|
|
2012
|
-
user: {
|
|
2013
|
-
showAvatar: false,
|
|
2014
|
-
// true, "inline"
|
|
2015
|
-
showName: false
|
|
2016
|
-
},
|
|
2017
|
-
timeIndicator: {
|
|
2018
|
-
enabled: false,
|
|
2019
|
-
threshold: 3600000 // Default threshold is an hour in milliseconds
|
|
2020
1698
|
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
1699
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
1700
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
1701
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
1702
|
+
return Constructor;
|
|
1703
|
+
}
|
|
1704
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
1705
|
+
function defineProperty_defineProperty(obj, key, value) {
|
|
1706
|
+
if (key in obj) {
|
|
1707
|
+
Object.defineProperty(obj, key, {
|
|
1708
|
+
value: value,
|
|
1709
|
+
enumerable: true,
|
|
1710
|
+
configurable: true,
|
|
1711
|
+
writable: true
|
|
1712
|
+
});
|
|
1713
|
+
} else {
|
|
1714
|
+
obj[key] = value;
|
|
1715
|
+
}
|
|
2027
1716
|
|
|
2028
|
-
|
|
1717
|
+
return obj;
|
|
1718
|
+
}
|
|
1719
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/array-utils/array-utils.es.js
|
|
1720
|
+
/*
|
|
1721
|
+
* Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/)
|
|
1722
|
+
*
|
|
1723
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1724
|
+
* you may not use this file except in compliance with the License.
|
|
1725
|
+
* You may obtain a copy of the License at
|
|
1726
|
+
*
|
|
1727
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1728
|
+
*
|
|
1729
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1730
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1731
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1732
|
+
* See the License for the specific language governing permissions and
|
|
1733
|
+
* limitations under the License.
|
|
1734
|
+
*/
|
|
2029
1735
|
|
|
2030
|
-
|
|
1736
|
+
/**
|
|
1737
|
+
* Flattens an array of arrays of infinite depth into a single-dimension array.
|
|
1738
|
+
*
|
|
1739
|
+
* > This is now natively in JavaScript as the `flat` method on an Array
|
|
1740
|
+
* > instance. [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat).
|
|
1741
|
+
* > If you can't use `flat`, then this method will do the job 🙂
|
|
1742
|
+
*
|
|
1743
|
+
* @param {Array} array
|
|
1744
|
+
* @return {Array} Flattened array.
|
|
1745
|
+
*/
|
|
1746
|
+
function flatten(array) {
|
|
1747
|
+
return array.reduce(function (accumulator, value) {
|
|
1748
|
+
return accumulator.concat(Array.isArray(value) ? flatten(value) : value);
|
|
1749
|
+
}, []);
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Creates an array of numbers from the starting value (inclusive) to the end
|
|
1753
|
+
* (exclusive), with an optional step (the gap between values).
|
|
1754
|
+
*
|
|
1755
|
+
* @param {Number} start
|
|
1756
|
+
* The value to start at, the first item in the returned array.
|
|
1757
|
+
* @param {Number} end
|
|
1758
|
+
* The value to end with, the last item in the returned array.
|
|
1759
|
+
* @param {Number} [step=1]
|
|
1760
|
+
* The increment/gap between values, defaults to 1.
|
|
1761
|
+
* @return {Array} An array encompassing the given range.
|
|
1762
|
+
*/
|
|
2031
1763
|
|
|
2032
|
-
function
|
|
1764
|
+
function range(start, end) {
|
|
1765
|
+
var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1766
|
+
return Array.apply(0, Array(Math.ceil((end - start) / step))).map(function (empty, index) {
|
|
1767
|
+
return index * step + start;
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Remove and return the first item from `array` that matches the predicate
|
|
1772
|
+
* function.
|
|
1773
|
+
*
|
|
1774
|
+
* @param {Array} array
|
|
1775
|
+
* @param {Function} predicate
|
|
1776
|
+
* Invoked with the array item.
|
|
1777
|
+
* @return {Object} The matching item, or `null` if no match was found.
|
|
1778
|
+
*/
|
|
2033
1779
|
|
|
2034
|
-
function
|
|
1780
|
+
function remove(array, predicate) {
|
|
1781
|
+
return array.find(function (item, index) {
|
|
1782
|
+
if (predicate(item)) {
|
|
1783
|
+
array.splice(index, 1);
|
|
1784
|
+
return item;
|
|
1785
|
+
}
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
2035
1788
|
|
|
2036
|
-
|
|
1789
|
+
//# sourceMappingURL=array-utils.es.js.map
|
|
1790
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/function-utils/function-utils.es.js
|
|
1791
|
+
/**
|
|
1792
|
+
* A higher-order function to apply [memoization](https://en.wikipedia.org/wiki/Memoization).
|
|
1793
|
+
*
|
|
1794
|
+
* If memoizing a recursive function, then memoize and define the function at
|
|
1795
|
+
* the same time so you can make a call to the memoized function, eg:
|
|
1796
|
+
*
|
|
1797
|
+
* ```javascript
|
|
1798
|
+
* const myFunction = memoize(() => myFunction());
|
|
1799
|
+
* ```
|
|
1800
|
+
*
|
|
1801
|
+
* @param {Function} func
|
|
1802
|
+
* @return {Function}
|
|
1803
|
+
*/
|
|
1804
|
+
function memoize(func) {
|
|
1805
|
+
var cache = {};
|
|
1806
|
+
return function () {
|
|
1807
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1808
|
+
args[_key] = arguments[_key];
|
|
1809
|
+
}
|
|
2037
1810
|
|
|
1811
|
+
var key = args.length ? args.map(function (arg) {
|
|
1812
|
+
return arg === null ? 'null' : arg === undefined ? 'undefined' : typeof arg === 'function' ? arg.toString() : arg instanceof Date ? arg.toISOString() : JSON.stringify(arg);
|
|
1813
|
+
}).join('|') : '_(no-args)_';
|
|
2038
1814
|
|
|
1815
|
+
if (Object.prototype.hasOwnProperty.call(cache, key)) {
|
|
1816
|
+
return cache[key];
|
|
1817
|
+
}
|
|
2039
1818
|
|
|
1819
|
+
var result = func.apply(void 0, args);
|
|
1820
|
+
cache[key] = result;
|
|
1821
|
+
return result;
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
2040
1824
|
|
|
1825
|
+
//# sourceMappingURL=function-utils.es.js.map
|
|
1826
|
+
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/lib/icu-message-formatter.es.js
|
|
2041
1827
|
|
|
2042
1828
|
|
|
2043
|
-
const config_reducer_initialState = config_reducer_objectSpread(config_reducer_objectSpread({}, defaultConfig), {}, {
|
|
2044
|
-
hideOnNoUserResponse: false,
|
|
2045
|
-
showDisclaimer: false,
|
|
2046
|
-
showFaq: false,
|
|
2047
|
-
customComponents: {},
|
|
2048
|
-
defaults: {}
|
|
2049
|
-
});
|
|
2050
1829
|
|
|
2051
|
-
const configKeys = ['hideOnNoUserResponse', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback'];
|
|
2052
1830
|
|
|
2053
|
-
const updateState = (state, {
|
|
2054
|
-
config
|
|
2055
|
-
}) => {
|
|
2056
|
-
const _pick = pick(config, configKeys),
|
|
2057
|
-
{
|
|
2058
|
-
messages
|
|
2059
|
-
} = _pick,
|
|
2060
|
-
partialConfig = reducer_objectWithoutProperties(_pick, reducer_excluded);
|
|
2061
1831
|
|
|
2062
|
-
let newState = state;
|
|
2063
1832
|
|
|
2064
|
-
if (Object.keys(partialConfig).length > 0) {
|
|
2065
|
-
newState = config_reducer_objectSpread(config_reducer_objectSpread({}, newState), partialConfig);
|
|
2066
|
-
}
|
|
2067
1833
|
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
1834
|
+
/*
|
|
1835
|
+
* Copyright 2019, Emanuel Rabina (http://www.ultraq.net.nz/)
|
|
1836
|
+
*
|
|
1837
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1838
|
+
* you may not use this file except in compliance with the License.
|
|
1839
|
+
* You may obtain a copy of the License at
|
|
1840
|
+
*
|
|
1841
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1842
|
+
*
|
|
1843
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1844
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1845
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1846
|
+
* See the License for the specific language governing permissions and
|
|
1847
|
+
* limitations under the License.
|
|
1848
|
+
*/
|
|
2073
1849
|
|
|
2074
|
-
|
|
2075
|
-
|
|
1850
|
+
/**
|
|
1851
|
+
* Most branch-based type handlers are based around "cases".
|
|
1852
|
+
* For example, `select` and `plural` compare compare a value
|
|
1853
|
+
* to "case keys" to choose a subtranslation.
|
|
1854
|
+
*
|
|
1855
|
+
* This util splits "matches" portions provided to the aforementioned
|
|
1856
|
+
* handlers into case strings, and extracts any prepended arguments
|
|
1857
|
+
* (for example, `plural` supports an `offset:n` argument used for
|
|
1858
|
+
* populating the magic `#` variable).
|
|
1859
|
+
*
|
|
1860
|
+
* @param {String} string
|
|
1861
|
+
* @return {Object} The `cases` key points to a map of all cases.
|
|
1862
|
+
* The `arguments` key points to a list of prepended arguments.
|
|
1863
|
+
*/
|
|
1864
|
+
function parseCases(string) {
|
|
1865
|
+
var isWhitespace = function isWhitespace(ch) {
|
|
1866
|
+
return /\s/.test(ch);
|
|
1867
|
+
};
|
|
2076
1868
|
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
}
|
|
2084
|
-
}, config_reducer_initialState));
|
|
2085
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/config/index.js
|
|
1869
|
+
var args = [];
|
|
1870
|
+
var cases = {};
|
|
1871
|
+
var currTermStart = 0;
|
|
1872
|
+
var latestTerm = null;
|
|
1873
|
+
var inTerm = false;
|
|
1874
|
+
var i = 0;
|
|
2086
1875
|
|
|
1876
|
+
while (i < string.length) {
|
|
1877
|
+
// Term ended
|
|
1878
|
+
if (inTerm && (isWhitespace(string[i]) || string[i] === '{')) {
|
|
1879
|
+
inTerm = false;
|
|
1880
|
+
latestTerm = string.slice(currTermStart, i); // We want to process the opening char again so the case will be properly registered.
|
|
2087
1881
|
|
|
1882
|
+
if (string[i] === '{') {
|
|
1883
|
+
i--;
|
|
1884
|
+
}
|
|
1885
|
+
} // New term
|
|
1886
|
+
else if (!inTerm && !isWhitespace(string[i])) {
|
|
1887
|
+
var caseBody = string[i] === '{'; // If there's a previous term, we can either handle a whole
|
|
1888
|
+
// case, or add that as an argument.
|
|
2088
1889
|
|
|
1890
|
+
if (latestTerm && caseBody) {
|
|
1891
|
+
var branchEndIndex = findClosingBracket(string, i);
|
|
2089
1892
|
|
|
1893
|
+
if (branchEndIndex === -1) {
|
|
1894
|
+
throw new Error("Unbalanced curly braces in string: \"".concat(string, "\""));
|
|
1895
|
+
}
|
|
2090
1896
|
|
|
1897
|
+
cases[latestTerm] = string.slice(i + 1, branchEndIndex); // Don't include the braces
|
|
2091
1898
|
|
|
2092
|
-
|
|
2093
|
-
function seamly_state_hooks_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1899
|
+
i = branchEndIndex; // Will be moved up where needed at end of loop.
|
|
2094
1900
|
|
|
2095
|
-
|
|
1901
|
+
latestTerm = null;
|
|
1902
|
+
} else {
|
|
1903
|
+
if (latestTerm) {
|
|
1904
|
+
args.push(latestTerm);
|
|
1905
|
+
latestTerm = null;
|
|
1906
|
+
}
|
|
2096
1907
|
|
|
2097
|
-
|
|
1908
|
+
inTerm = true;
|
|
1909
|
+
currTermStart = i;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
2098
1912
|
|
|
1913
|
+
i++;
|
|
1914
|
+
}
|
|
2099
1915
|
|
|
1916
|
+
if (inTerm) {
|
|
1917
|
+
latestTerm = string.slice(currTermStart);
|
|
1918
|
+
}
|
|
2100
1919
|
|
|
1920
|
+
if (latestTerm) {
|
|
1921
|
+
args.push(latestTerm);
|
|
1922
|
+
}
|
|
2101
1923
|
|
|
1924
|
+
return {
|
|
1925
|
+
args: args,
|
|
1926
|
+
cases: cases
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Finds the index of the matching closing curly bracket, including through
|
|
1931
|
+
* strings that could have nested brackets.
|
|
1932
|
+
*
|
|
1933
|
+
* @param {String} string
|
|
1934
|
+
* @param {Number} fromIndex
|
|
1935
|
+
* @return {Number} The index of the matching closing bracket, or -1 if no
|
|
1936
|
+
* closing bracket could be found.
|
|
1937
|
+
*/
|
|
2102
1938
|
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
const selectEvents = createSelector(seamly_state_hooks_selectState, selectConfig, ({
|
|
2106
|
-
events
|
|
2107
|
-
}, config) => {
|
|
2108
|
-
var _config$messages;
|
|
1939
|
+
function findClosingBracket(string, fromIndex) {
|
|
1940
|
+
var depth = 0;
|
|
2109
1941
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
threshold
|
|
2113
|
-
} = (config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) ?? {};
|
|
1942
|
+
for (var i = fromIndex + 1; i < string.length; i++) {
|
|
1943
|
+
var char = string.charAt(i);
|
|
2114
1944
|
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
1945
|
+
if (char === '}') {
|
|
1946
|
+
if (depth === 0) {
|
|
1947
|
+
return i;
|
|
1948
|
+
}
|
|
2118
1949
|
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
// always add timeIndicator to first message
|
|
2123
|
-
if (idx === 0) {
|
|
2124
|
-
mappedEvents.push(seamly_state_hooks_objectSpread(seamly_state_hooks_objectSpread({}, event), {}, {
|
|
2125
|
-
timeIndicator: event.payload.occurredAt
|
|
2126
|
-
})); // else check if diff is greater than threshold
|
|
2127
|
-
} else {
|
|
2128
|
-
const timeIndicator = previousEvent && microsecondsToMilliseconds(event.payload.occurredAt - previousEvent.payload.occurredAt) >= threshold ? event.payload.occurredAt : undefined;
|
|
2129
|
-
mappedEvents.push(seamly_state_hooks_objectSpread(seamly_state_hooks_objectSpread({}, event), {}, {
|
|
2130
|
-
timeIndicator
|
|
2131
|
-
}));
|
|
1950
|
+
depth--;
|
|
1951
|
+
} else if (char === '{') {
|
|
1952
|
+
depth++;
|
|
2132
1953
|
}
|
|
1954
|
+
}
|
|
2133
1955
|
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
const selectLastMessageEventId = createSelector(selectEvents, events => {
|
|
2146
|
-
var _filteredEvents;
|
|
2147
|
-
|
|
2148
|
-
const filteredEvents = events.filter(event => event.type === 'message');
|
|
2149
|
-
return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
|
|
2150
|
-
});
|
|
2151
|
-
const useLastMessageEventId = () => useSelector(selectLastMessageEventId);
|
|
2152
|
-
const useSeamlyIsHistoryLoaded = () => seamly_state_hooks_useSeamlyStateContext().historyLoaded;
|
|
2153
|
-
const useSeamlyCurrentAgent = () => {
|
|
2154
|
-
const {
|
|
2155
|
-
participants,
|
|
2156
|
-
currentAgent
|
|
2157
|
-
} = seamly_state_hooks_useSeamlyStateContext().participantInfo;
|
|
2158
|
-
return currentAgent ? participants[currentAgent] : null;
|
|
2159
|
-
};
|
|
2160
|
-
const useSeamlyServiceData = key => seamly_state_hooks_useSeamlyStateContext().serviceData[key];
|
|
2161
|
-
const useEntryTextLimit = () => {
|
|
2162
|
-
const {
|
|
2163
|
-
entryMeta: {
|
|
2164
|
-
options: {
|
|
2165
|
-
text
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
} = seamly_state_hooks_useSeamlyStateContext();
|
|
2169
|
-
const {
|
|
2170
|
-
limit
|
|
2171
|
-
} = text || {};
|
|
2172
|
-
return {
|
|
2173
|
-
hasLimit: limit != null,
|
|
2174
|
-
limit: limit != null ? limit : null
|
|
2175
|
-
};
|
|
2176
|
-
};
|
|
2177
|
-
const useSeamlyLayoutMode = () => {
|
|
2178
|
-
const {
|
|
2179
|
-
layoutMode
|
|
2180
|
-
} = useConfig();
|
|
2181
|
-
return {
|
|
2182
|
-
isInline: layoutMode === 'inline',
|
|
2183
|
-
isModal: layoutMode === 'modal',
|
|
2184
|
-
isWindow: layoutMode === 'window',
|
|
2185
|
-
isResolving: !layoutMode
|
|
2186
|
-
};
|
|
2187
|
-
};
|
|
2188
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-dispatch.js
|
|
1956
|
+
return -1;
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Split a `{key, type, format}` block into those 3 parts, taking into account
|
|
1960
|
+
* nested message syntax that can exist in the `format` part.
|
|
1961
|
+
*
|
|
1962
|
+
* @param {String} block
|
|
1963
|
+
* @return {Array}
|
|
1964
|
+
* An array with `key`, `type`, and `format` items in that order, if present
|
|
1965
|
+
* in the formatted argument block.
|
|
1966
|
+
*/
|
|
2189
1967
|
|
|
2190
|
-
|
|
2191
|
-
|
|
1968
|
+
function splitFormattedArgument(block) {
|
|
1969
|
+
return split(block.slice(1, -1), ',', 3);
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Like `String.prototype.split()` but where the limit parameter causes the
|
|
1973
|
+
* remainder of the string to be grouped together in a final entry.
|
|
1974
|
+
*
|
|
1975
|
+
* @private
|
|
1976
|
+
* @param {String} string
|
|
1977
|
+
* @param {String} separator
|
|
1978
|
+
* @param {Number} limit
|
|
1979
|
+
* @param {Array} [accumulator=[]]
|
|
1980
|
+
* @return {Array}
|
|
1981
|
+
*/
|
|
2192
1982
|
|
|
1983
|
+
function split(string, separator, limit) {
|
|
1984
|
+
var accumulator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
2193
1985
|
|
|
1986
|
+
if (!string) {
|
|
1987
|
+
return accumulator;
|
|
1988
|
+
}
|
|
2194
1989
|
|
|
1990
|
+
if (limit === 1) {
|
|
1991
|
+
accumulator.push(string);
|
|
1992
|
+
return accumulator;
|
|
1993
|
+
}
|
|
2195
1994
|
|
|
1995
|
+
var indexOfDelimiter = string.indexOf(separator);
|
|
2196
1996
|
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
1997
|
+
if (indexOfDelimiter === -1) {
|
|
1998
|
+
accumulator.push(string);
|
|
1999
|
+
return accumulator;
|
|
2000
|
+
}
|
|
2200
2001
|
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
});
|
|
2207
|
-
});
|
|
2208
|
-
};
|
|
2002
|
+
var head = string.substring(0, indexOfDelimiter).trim();
|
|
2003
|
+
var tail = string.substring(indexOfDelimiter + separator.length + 1).trim();
|
|
2004
|
+
accumulator.push(head);
|
|
2005
|
+
return split(tail, separator, limit - 1, accumulator);
|
|
2006
|
+
}
|
|
2209
2007
|
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
const setSeamlyContainerElement = useCallback(element => {
|
|
2216
|
-
dispatch({
|
|
2217
|
-
type: focus_helper_hooks_SET_SEAMLY_CONTAINER_ELEMENT,
|
|
2218
|
-
element
|
|
2219
|
-
});
|
|
2220
|
-
}, [dispatch]);
|
|
2221
|
-
return [seamlyContainerElement, setSeamlyContainerElement];
|
|
2222
|
-
};
|
|
2223
|
-
const focus_helper_hooks_useElementFocusingById = elementId => useCallback(() => {
|
|
2224
|
-
focusWithRaf(elementId);
|
|
2225
|
-
}, [elementId]);
|
|
2226
|
-
const focus_helper_hooks_useSkiplinkTargetFocusing = () => {
|
|
2227
|
-
const skiplinkTargetId = useSkiplink();
|
|
2228
|
-
return focus_helper_hooks_useElementFocusingById(skiplinkTargetId);
|
|
2229
|
-
};
|
|
2230
|
-
const useFocusIfSeamlyContainedFocus = () => {
|
|
2231
|
-
const containerElementRef = useRef(null);
|
|
2232
|
-
const [seamlyContainerElement] = useSeamlyContainerElement();
|
|
2233
|
-
containerElementRef.current = seamlyContainerElement;
|
|
2234
|
-
return useCallback(elementToFocus => {
|
|
2235
|
-
const focusFn = () => {
|
|
2236
|
-
focusWithRaf(elementToFocus);
|
|
2237
|
-
};
|
|
2008
|
+
/**
|
|
2009
|
+
* The main class for formatting messages.
|
|
2010
|
+
*
|
|
2011
|
+
* @author Emanuel Rabina
|
|
2012
|
+
*/
|
|
2238
2013
|
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2014
|
+
var MessageFormatter = /*#__PURE__*/function () {
|
|
2015
|
+
/**
|
|
2016
|
+
* Creates a new formatter that can work using any of the custom type handlers
|
|
2017
|
+
* you register.
|
|
2018
|
+
*
|
|
2019
|
+
* @param {String} locale
|
|
2020
|
+
* @param {Object} [typeHandlers={}]
|
|
2021
|
+
* Optional object where the keys are the names of the types to register,
|
|
2022
|
+
* their values being the functions that will return a nicely formatted
|
|
2023
|
+
* string for the data and locale they are given.
|
|
2024
|
+
*/
|
|
2025
|
+
function MessageFormatter(locale) {
|
|
2026
|
+
var _this = this;
|
|
2243
2027
|
|
|
2028
|
+
var typeHandlers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2244
2029
|
|
|
2030
|
+
_classCallCheck(this, MessageFormatter);
|
|
2245
2031
|
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
const {
|
|
2251
|
-
fromClient
|
|
2252
|
-
} = event.payload;
|
|
2253
|
-
const classNames = ['message'];
|
|
2032
|
+
defineProperty_defineProperty(this, "format", memoize(function (message) {
|
|
2033
|
+
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2034
|
+
return flatten(_this.process(message, values)).join('');
|
|
2035
|
+
}));
|
|
2254
2036
|
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
} else if (!fromClient) {
|
|
2258
|
-
classNames.push('message--source-agent');
|
|
2259
|
-
} else {
|
|
2260
|
-
classNames.push('message--source-user');
|
|
2037
|
+
this.locale = locale;
|
|
2038
|
+
this.typeHandlers = typeHandlers;
|
|
2261
2039
|
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Formats an ICU message syntax string using `values` for placeholder data
|
|
2042
|
+
* and any currently-registered type handlers.
|
|
2043
|
+
*
|
|
2044
|
+
* @param {String} message
|
|
2045
|
+
* @param {Object} [values={}]
|
|
2046
|
+
* @return {String}
|
|
2047
|
+
*/
|
|
2262
2048
|
|
|
2263
|
-
return classNames;
|
|
2264
|
-
};
|
|
2265
|
-
const useCobrowsingContainer = () => {
|
|
2266
|
-
const {
|
|
2267
|
-
cobrowsingContainerId: id
|
|
2268
|
-
} = useSeamlyStateContext();
|
|
2269
|
-
const focusContainer = useElementFocusingById(id);
|
|
2270
|
-
return {
|
|
2271
|
-
id,
|
|
2272
|
-
focusContainer
|
|
2273
|
-
};
|
|
2274
|
-
};
|
|
2275
|
-
;// CONCATENATED MODULE: ./src/javascripts/lib/mutex.js
|
|
2276
|
-
function createMutex() {
|
|
2277
|
-
let isRunning = false;
|
|
2278
|
-
const tasks = [];
|
|
2279
2049
|
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2050
|
+
_createClass(MessageFormatter, [{
|
|
2051
|
+
key: "process",
|
|
2052
|
+
value:
|
|
2053
|
+
/**
|
|
2054
|
+
* Process an ICU message syntax string using `values` for placeholder data
|
|
2055
|
+
* and any currently-registered type handlers. The result of this method is
|
|
2056
|
+
* an array of the component parts after they have been processed in turn by
|
|
2057
|
+
* their own type handlers. This raw output is useful for other renderers,
|
|
2058
|
+
* eg: React where components can be used instead of being forced to return
|
|
2059
|
+
* raw strings.
|
|
2060
|
+
*
|
|
2061
|
+
* This method is used by {@link MessageFormatter#format} where it acts as a
|
|
2062
|
+
* string renderer.
|
|
2063
|
+
*
|
|
2064
|
+
* @param {String} message
|
|
2065
|
+
* @param {Object} [values={}]
|
|
2066
|
+
* @return {Array}
|
|
2067
|
+
*/
|
|
2068
|
+
function process(message) {
|
|
2069
|
+
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2285
2070
|
|
|
2286
|
-
|
|
2287
|
-
|
|
2071
|
+
if (!message) {
|
|
2072
|
+
return [];
|
|
2288
2073
|
}
|
|
2289
|
-
}
|
|
2290
|
-
};
|
|
2291
2074
|
|
|
2292
|
-
|
|
2293
|
-
const prms = new Promise((resolve, reject) => {
|
|
2294
|
-
tasks.push(async () => {
|
|
2295
|
-
try {
|
|
2296
|
-
resolve(await task());
|
|
2297
|
-
} catch (e) {
|
|
2298
|
-
reject(e);
|
|
2299
|
-
}
|
|
2300
|
-
});
|
|
2301
|
-
});
|
|
2302
|
-
next();
|
|
2303
|
-
return prms;
|
|
2304
|
-
};
|
|
2075
|
+
var blockStartIndex = message.indexOf('{');
|
|
2305
2076
|
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
runExclusively
|
|
2309
|
-
};
|
|
2310
|
-
}
|
|
2311
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/utils.js
|
|
2077
|
+
if (blockStartIndex !== -1) {
|
|
2078
|
+
var blockEndIndex = findClosingBracket(message, blockStartIndex);
|
|
2312
2079
|
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
createThunk: i18n_utils_createThunk,
|
|
2316
|
-
createReducer: i18n_utils_createReducer,
|
|
2317
|
-
selectState: i18n_utils_selectState
|
|
2318
|
-
} = createDomain('i18n');
|
|
2319
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/selectors.js
|
|
2080
|
+
if (blockEndIndex !== -1) {
|
|
2081
|
+
var block = message.substring(blockStartIndex, blockEndIndex + 1);
|
|
2320
2082
|
|
|
2083
|
+
if (block) {
|
|
2084
|
+
var result = [];
|
|
2085
|
+
var head = message.substring(0, blockStartIndex);
|
|
2321
2086
|
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2087
|
+
if (head) {
|
|
2088
|
+
result.push(head);
|
|
2089
|
+
}
|
|
2325
2090
|
|
|
2326
|
-
|
|
2091
|
+
var _splitFormattedArgume = splitFormattedArgument(block),
|
|
2092
|
+
_splitFormattedArgume2 = _slicedToArray(_splitFormattedArgume, 3),
|
|
2093
|
+
key = _splitFormattedArgume2[0],
|
|
2094
|
+
type = _splitFormattedArgume2[1],
|
|
2095
|
+
format = _splitFormattedArgume2[2];
|
|
2327
2096
|
|
|
2097
|
+
var body = values[key];
|
|
2328
2098
|
|
|
2099
|
+
if (body === null || body === undefined) {
|
|
2100
|
+
body = '';
|
|
2101
|
+
}
|
|
2329
2102
|
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2103
|
+
var typeHandler = type && this.typeHandlers[type];
|
|
2104
|
+
result.push(typeHandler ? typeHandler(body, format, this.locale, values, this.process.bind(this)) : body);
|
|
2105
|
+
var tail = message.substring(blockEndIndex + 1);
|
|
2106
|
+
|
|
2107
|
+
if (tail) {
|
|
2108
|
+
result.push(this.process(tail, values));
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
return result;
|
|
2112
|
+
}
|
|
2113
|
+
} else {
|
|
2114
|
+
throw new Error("Unbalanced curly braces in string: \"".concat(message, "\""));
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
return [message];
|
|
2343
2119
|
}
|
|
2120
|
+
}]);
|
|
2344
2121
|
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
});
|
|
2348
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
2349
|
-
function _arrayWithHoles(arr) {
|
|
2350
|
-
if (Array.isArray(arr)) return arr;
|
|
2351
|
-
}
|
|
2352
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
2353
|
-
function _iterableToArrayLimit(arr, i) {
|
|
2354
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2122
|
+
return MessageFormatter;
|
|
2123
|
+
}();
|
|
2355
2124
|
|
|
2356
|
-
|
|
2357
|
-
var _arr = [];
|
|
2358
|
-
var _n = true;
|
|
2359
|
-
var _d = false;
|
|
2125
|
+
function icu_message_formatter_es_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2360
2126
|
|
|
2361
|
-
|
|
2127
|
+
function icu_message_formatter_es_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { icu_message_formatter_es_ownKeys(Object(source), true).forEach(function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { icu_message_formatter_es_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2128
|
+
var pluralFormatter;
|
|
2129
|
+
var keyCounter = 0; // All the special keywords that can be used in `plural` blocks for the various branches
|
|
2362
2130
|
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2131
|
+
var ONE = 'one';
|
|
2132
|
+
var OTHER$1 = 'other';
|
|
2133
|
+
/**
|
|
2134
|
+
* @private
|
|
2135
|
+
* @param {String} caseBody
|
|
2136
|
+
* @param {Number} value
|
|
2137
|
+
* @return {Object} {caseBody: string, numberValues: object}
|
|
2138
|
+
*/
|
|
2366
2139
|
|
|
2367
|
-
|
|
2140
|
+
function replaceNumberSign(caseBody, value) {
|
|
2141
|
+
var i = 0;
|
|
2142
|
+
var output = '';
|
|
2143
|
+
var numBraces = 0;
|
|
2144
|
+
var numberValues = {};
|
|
2145
|
+
|
|
2146
|
+
while (i < caseBody.length) {
|
|
2147
|
+
if (caseBody[i] === '#' && !numBraces) {
|
|
2148
|
+
var keyParam = "__hashToken".concat(keyCounter++);
|
|
2149
|
+
output += "{".concat(keyParam, ", number}");
|
|
2150
|
+
numberValues[keyParam] = value;
|
|
2151
|
+
} else {
|
|
2152
|
+
output += caseBody[i];
|
|
2368
2153
|
}
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
2375
|
-
} finally {
|
|
2376
|
-
if (_d) throw _e;
|
|
2154
|
+
|
|
2155
|
+
if (caseBody[i] === '{') {
|
|
2156
|
+
numBraces++;
|
|
2157
|
+
} else if (caseBody[i] === '}') {
|
|
2158
|
+
numBraces--;
|
|
2377
2159
|
}
|
|
2160
|
+
|
|
2161
|
+
i++;
|
|
2378
2162
|
}
|
|
2379
2163
|
|
|
2380
|
-
return
|
|
2164
|
+
return {
|
|
2165
|
+
caseBody: output,
|
|
2166
|
+
numberValues: numberValues
|
|
2167
|
+
};
|
|
2381
2168
|
}
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2169
|
+
/**
|
|
2170
|
+
* Handler for `plural` statements within ICU message syntax strings. Returns
|
|
2171
|
+
* a formatted string for the branch that closely matches the current value.
|
|
2172
|
+
*
|
|
2173
|
+
* See https://formatjs.io/docs/core-concepts/icu-syntax#plural-format for more
|
|
2174
|
+
* details on how the `plural` statement works.
|
|
2175
|
+
*
|
|
2176
|
+
* @param {String} value
|
|
2177
|
+
* @param {String} matches
|
|
2178
|
+
* @param {String} locale
|
|
2179
|
+
* @param {String} values
|
|
2180
|
+
* @param {Function} format
|
|
2181
|
+
* @return {String}
|
|
2182
|
+
*/
|
|
2385
2183
|
|
|
2386
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
2387
|
-
arr2[i] = arr[i];
|
|
2388
|
-
}
|
|
2389
2184
|
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2185
|
+
function pluralTypeHandler(value) {
|
|
2186
|
+
var matches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2187
|
+
var locale = arguments.length > 2 ? arguments[2] : undefined;
|
|
2188
|
+
var values = arguments.length > 3 ? arguments[3] : undefined;
|
|
2189
|
+
var format = arguments.length > 4 ? arguments[4] : undefined;
|
|
2393
2190
|
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2398
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2399
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
2400
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
2401
|
-
}
|
|
2402
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
|
2403
|
-
function _nonIterableRest() {
|
|
2404
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2405
|
-
}
|
|
2406
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
|
2191
|
+
var _parseCases = parseCases(matches),
|
|
2192
|
+
args = _parseCases.args,
|
|
2193
|
+
cases = _parseCases.cases;
|
|
2407
2194
|
|
|
2195
|
+
var intValue = parseInt(value);
|
|
2196
|
+
args.forEach(function (arg) {
|
|
2197
|
+
if (arg.startsWith('offset:')) {
|
|
2198
|
+
intValue -= parseInt(arg.slice('offset:'.length));
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
var keywordPossibilities = [];
|
|
2408
2202
|
|
|
2203
|
+
if ('PluralRules' in Intl) {
|
|
2204
|
+
// Effectively memoize because instantiation of `Int.*` objects is expensive.
|
|
2205
|
+
if (pluralFormatter === undefined || pluralFormatter.resolvedOptions().locale !== locale) {
|
|
2206
|
+
pluralFormatter = new Intl.PluralRules(locale);
|
|
2207
|
+
}
|
|
2409
2208
|
|
|
2209
|
+
var pluralKeyword = pluralFormatter.select(intValue); // Other is always added last with least priority, so we don't want to add it here.
|
|
2410
2210
|
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
}
|
|
2414
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
|
2415
|
-
function _classCallCheck(instance, Constructor) {
|
|
2416
|
-
if (!(instance instanceof Constructor)) {
|
|
2417
|
-
throw new TypeError("Cannot call a class as a function");
|
|
2211
|
+
if (pluralKeyword !== OTHER$1) {
|
|
2212
|
+
keywordPossibilities.push(pluralKeyword);
|
|
2213
|
+
}
|
|
2418
2214
|
}
|
|
2419
|
-
}
|
|
2420
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/createClass.js
|
|
2421
|
-
function _defineProperties(target, props) {
|
|
2422
|
-
for (var i = 0; i < props.length; i++) {
|
|
2423
|
-
var descriptor = props[i];
|
|
2424
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
2425
|
-
descriptor.configurable = true;
|
|
2426
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
2427
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
2215
|
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
2434
|
-
return Constructor;
|
|
2435
|
-
}
|
|
2436
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
2437
|
-
function defineProperty_defineProperty(obj, key, value) {
|
|
2438
|
-
if (key in obj) {
|
|
2439
|
-
Object.defineProperty(obj, key, {
|
|
2440
|
-
value: value,
|
|
2441
|
-
enumerable: true,
|
|
2442
|
-
configurable: true,
|
|
2443
|
-
writable: true
|
|
2444
|
-
});
|
|
2445
|
-
} else {
|
|
2446
|
-
obj[key] = value;
|
|
2216
|
+
if (intValue === 1) {
|
|
2217
|
+
keywordPossibilities.push(ONE);
|
|
2447
2218
|
}
|
|
2448
2219
|
|
|
2449
|
-
|
|
2450
|
-
}
|
|
2451
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/array-utils/array-utils.es.js
|
|
2452
|
-
/*
|
|
2453
|
-
* Copyright 2017, Emanuel Rabina (http://www.ultraq.net.nz/)
|
|
2454
|
-
*
|
|
2455
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2456
|
-
* you may not use this file except in compliance with the License.
|
|
2457
|
-
* You may obtain a copy of the License at
|
|
2458
|
-
*
|
|
2459
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2460
|
-
*
|
|
2461
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2462
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2463
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2464
|
-
* See the License for the specific language governing permissions and
|
|
2465
|
-
* limitations under the License.
|
|
2466
|
-
*/
|
|
2467
|
-
|
|
2468
|
-
/**
|
|
2469
|
-
* Flattens an array of arrays of infinite depth into a single-dimension array.
|
|
2470
|
-
*
|
|
2471
|
-
* > This is now natively in JavaScript as the `flat` method on an Array
|
|
2472
|
-
* > instance. [Check MDN for which browsers have access to this feature](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat).
|
|
2473
|
-
* > If you can't use `flat`, then this method will do the job 🙂
|
|
2474
|
-
*
|
|
2475
|
-
* @param {Array} array
|
|
2476
|
-
* @return {Array} Flattened array.
|
|
2477
|
-
*/
|
|
2478
|
-
function flatten(array) {
|
|
2479
|
-
return array.reduce(function (accumulator, value) {
|
|
2480
|
-
return accumulator.concat(Array.isArray(value) ? flatten(value) : value);
|
|
2481
|
-
}, []);
|
|
2482
|
-
}
|
|
2483
|
-
/**
|
|
2484
|
-
* Creates an array of numbers from the starting value (inclusive) to the end
|
|
2485
|
-
* (exclusive), with an optional step (the gap between values).
|
|
2486
|
-
*
|
|
2487
|
-
* @param {Number} start
|
|
2488
|
-
* The value to start at, the first item in the returned array.
|
|
2489
|
-
* @param {Number} end
|
|
2490
|
-
* The value to end with, the last item in the returned array.
|
|
2491
|
-
* @param {Number} [step=1]
|
|
2492
|
-
* The increment/gap between values, defaults to 1.
|
|
2493
|
-
* @return {Array} An array encompassing the given range.
|
|
2494
|
-
*/
|
|
2495
|
-
|
|
2496
|
-
function range(start, end) {
|
|
2497
|
-
var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
2498
|
-
return Array.apply(0, Array(Math.ceil((end - start) / step))).map(function (empty, index) {
|
|
2499
|
-
return index * step + start;
|
|
2500
|
-
});
|
|
2501
|
-
}
|
|
2502
|
-
/**
|
|
2503
|
-
* Remove and return the first item from `array` that matches the predicate
|
|
2504
|
-
* function.
|
|
2505
|
-
*
|
|
2506
|
-
* @param {Array} array
|
|
2507
|
-
* @param {Function} predicate
|
|
2508
|
-
* Invoked with the array item.
|
|
2509
|
-
* @return {Object} The matching item, or `null` if no match was found.
|
|
2510
|
-
*/
|
|
2511
|
-
|
|
2512
|
-
function remove(array, predicate) {
|
|
2513
|
-
return array.find(function (item, index) {
|
|
2514
|
-
if (predicate(item)) {
|
|
2515
|
-
array.splice(index, 1);
|
|
2516
|
-
return item;
|
|
2517
|
-
}
|
|
2518
|
-
});
|
|
2519
|
-
}
|
|
2220
|
+
keywordPossibilities.push("=".concat(intValue), OTHER$1);
|
|
2520
2221
|
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
/**
|
|
2524
|
-
* A higher-order function to apply [memoization](https://en.wikipedia.org/wiki/Memoization).
|
|
2525
|
-
*
|
|
2526
|
-
* If memoizing a recursive function, then memoize and define the function at
|
|
2527
|
-
* the same time so you can make a call to the memoized function, eg:
|
|
2528
|
-
*
|
|
2529
|
-
* ```javascript
|
|
2530
|
-
* const myFunction = memoize(() => myFunction());
|
|
2531
|
-
* ```
|
|
2532
|
-
*
|
|
2533
|
-
* @param {Function} func
|
|
2534
|
-
* @return {Function}
|
|
2535
|
-
*/
|
|
2536
|
-
function memoize(func) {
|
|
2537
|
-
var cache = {};
|
|
2538
|
-
return function () {
|
|
2539
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2540
|
-
args[_key] = arguments[_key];
|
|
2541
|
-
}
|
|
2222
|
+
for (var i = 0; i < keywordPossibilities.length; i++) {
|
|
2223
|
+
var keyword = keywordPossibilities[i];
|
|
2542
2224
|
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2225
|
+
if (keyword in cases) {
|
|
2226
|
+
var _replaceNumberSign = replaceNumberSign(cases[keyword], intValue),
|
|
2227
|
+
caseBody = _replaceNumberSign.caseBody,
|
|
2228
|
+
numberValues = _replaceNumberSign.numberValues;
|
|
2546
2229
|
|
|
2547
|
-
|
|
2548
|
-
return cache[key];
|
|
2230
|
+
return format(caseBody, icu_message_formatter_es_objectSpread(icu_message_formatter_es_objectSpread({}, values), numberValues));
|
|
2549
2231
|
}
|
|
2232
|
+
}
|
|
2550
2233
|
|
|
2551
|
-
|
|
2552
|
-
cache[key] = result;
|
|
2553
|
-
return result;
|
|
2554
|
-
};
|
|
2234
|
+
return value;
|
|
2555
2235
|
}
|
|
2556
2236
|
|
|
2557
|
-
//# sourceMappingURL=function-utils.es.js.map
|
|
2558
|
-
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/lib/icu-message-formatter.es.js
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
2237
|
/*
|
|
2567
2238
|
* Copyright 2019, Emanuel Rabina (http://www.ultraq.net.nz/)
|
|
2568
2239
|
*
|
|
@@ -2578,540 +2249,1138 @@ function memoize(func) {
|
|
|
2578
2249
|
* See the License for the specific language governing permissions and
|
|
2579
2250
|
* limitations under the License.
|
|
2580
2251
|
*/
|
|
2581
|
-
|
|
2252
|
+
var OTHER = 'other';
|
|
2582
2253
|
/**
|
|
2583
|
-
*
|
|
2584
|
-
*
|
|
2585
|
-
* to "case keys" to choose a subtranslation.
|
|
2254
|
+
* Handler for `select` statements within ICU message syntax strings. Returns
|
|
2255
|
+
* a formatted string for the branch that closely matches the current value.
|
|
2586
2256
|
*
|
|
2587
|
-
*
|
|
2588
|
-
*
|
|
2589
|
-
* (for example, `plural` supports an `offset:n` argument used for
|
|
2590
|
-
* populating the magic `#` variable).
|
|
2257
|
+
* See https://formatjs.io/docs/core-concepts/icu-syntax#select-format for more
|
|
2258
|
+
* details on how the `select` statement works.
|
|
2591
2259
|
*
|
|
2592
|
-
* @param {String}
|
|
2593
|
-
* @
|
|
2594
|
-
*
|
|
2260
|
+
* @param {String} value
|
|
2261
|
+
* @param {String} matches
|
|
2262
|
+
* @param {String} locale
|
|
2263
|
+
* @param {String} values
|
|
2264
|
+
* @param {Function} format
|
|
2265
|
+
* @return {String}
|
|
2595
2266
|
*/
|
|
2596
|
-
function parseCases(string) {
|
|
2597
|
-
var isWhitespace = function isWhitespace(ch) {
|
|
2598
|
-
return /\s/.test(ch);
|
|
2599
|
-
};
|
|
2600
2267
|
|
|
2601
|
-
|
|
2602
|
-
var
|
|
2603
|
-
var
|
|
2604
|
-
var
|
|
2605
|
-
var inTerm = false;
|
|
2606
|
-
var i = 0;
|
|
2268
|
+
function selectTypeHandler(value) {
|
|
2269
|
+
var matches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2270
|
+
var values = arguments.length > 3 ? arguments[3] : undefined;
|
|
2271
|
+
var format = arguments.length > 4 ? arguments[4] : undefined;
|
|
2607
2272
|
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
if (inTerm && (isWhitespace(string[i]) || string[i] === '{')) {
|
|
2611
|
-
inTerm = false;
|
|
2612
|
-
latestTerm = string.slice(currTermStart, i); // We want to process the opening char again so the case will be properly registered.
|
|
2273
|
+
var _parseCases = parseCases(matches),
|
|
2274
|
+
cases = _parseCases.cases;
|
|
2613
2275
|
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
var caseBody = string[i] === '{'; // If there's a previous term, we can either handle a whole
|
|
2620
|
-
// case, or add that as an argument.
|
|
2276
|
+
if (value in cases) {
|
|
2277
|
+
return format(cases[value], values);
|
|
2278
|
+
} else if (OTHER in cases) {
|
|
2279
|
+
return format(cases[OTHER], values);
|
|
2280
|
+
}
|
|
2621
2281
|
|
|
2622
|
-
|
|
2623
|
-
|
|
2282
|
+
return value;
|
|
2283
|
+
}
|
|
2624
2284
|
|
|
2625
|
-
if (branchEndIndex === -1) {
|
|
2626
|
-
throw new Error("Unbalanced curly braces in string: \"".concat(string, "\""));
|
|
2627
|
-
}
|
|
2628
2285
|
|
|
2629
|
-
|
|
2286
|
+
//# sourceMappingURL=icu-message-formatter.es.js.map
|
|
2630
2287
|
|
|
2631
|
-
|
|
2288
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/hooks.js
|
|
2632
2289
|
|
|
2633
|
-
latestTerm = null;
|
|
2634
|
-
} else {
|
|
2635
|
-
if (latestTerm) {
|
|
2636
|
-
args.push(latestTerm);
|
|
2637
|
-
latestTerm = null;
|
|
2638
|
-
}
|
|
2639
2290
|
|
|
2640
|
-
inTerm = true;
|
|
2641
|
-
currTermStart = i;
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
2291
|
|
|
2645
|
-
|
|
2646
|
-
|
|
2292
|
+
// The passed in locale (en-GB) is only used to call Intl.PluralRules.select() in
|
|
2293
|
+
// pluralTypeHandler. Since we only use exact plural matches (=0, =1 etc) we can
|
|
2294
|
+
// safely use en-GB all the time.
|
|
2647
2295
|
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2296
|
+
const formatter = new MessageFormatter('en-GB', {
|
|
2297
|
+
plural: pluralTypeHandler,
|
|
2298
|
+
select: selectTypeHandler
|
|
2299
|
+
});
|
|
2300
|
+
function hooks_useI18n() {
|
|
2301
|
+
const translations = useSelector(Selectors.selectTranslations);
|
|
2302
|
+
const locale = useSelector(Selectors.selectLocale);
|
|
2303
|
+
const initialLocale = useSelector(Selectors.selectInitialLocale);
|
|
2304
|
+
const t = useCallback((key, values = {}) => {
|
|
2305
|
+
const translation = translations[key];
|
|
2651
2306
|
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2307
|
+
if (!translation) {
|
|
2308
|
+
return null;
|
|
2309
|
+
}
|
|
2655
2310
|
|
|
2311
|
+
return formatter.format(translation, values);
|
|
2312
|
+
}, [translations]);
|
|
2656
2313
|
return {
|
|
2657
|
-
|
|
2658
|
-
|
|
2314
|
+
t,
|
|
2315
|
+
locale,
|
|
2316
|
+
initialLocale
|
|
2659
2317
|
};
|
|
2660
2318
|
}
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
* strings that could have nested brackets.
|
|
2664
|
-
*
|
|
2665
|
-
* @param {String} string
|
|
2666
|
-
* @param {Number} fromIndex
|
|
2667
|
-
* @return {Number} The index of the matching closing bracket, or -1 if no
|
|
2668
|
-
* closing bracket could be found.
|
|
2669
|
-
*/
|
|
2319
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/reducer.js
|
|
2320
|
+
function i18n_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2670
2321
|
|
|
2671
|
-
function
|
|
2672
|
-
var depth = 0;
|
|
2322
|
+
function i18n_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { i18n_reducer_ownKeys(Object(source), true).forEach(function (key) { i18n_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { i18n_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2673
2323
|
|
|
2674
|
-
|
|
2675
|
-
var char = string.charAt(i);
|
|
2324
|
+
function i18n_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2676
2325
|
|
|
2677
|
-
if (char === '}') {
|
|
2678
|
-
if (depth === 0) {
|
|
2679
|
-
return i;
|
|
2680
|
-
}
|
|
2681
2326
|
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2327
|
+
|
|
2328
|
+
const defaultState = {
|
|
2329
|
+
translations: {
|
|
2330
|
+
'errors.configError.message': 'We are sorry this happened, please retry at a later time.',
|
|
2331
|
+
'errors.configError.srText': 'A chat configuration error occurred. Our apologies, please retry at a later time.',
|
|
2332
|
+
'errors.configError.title': 'Chat configuration error.',
|
|
2333
|
+
'errors.general.buttonText': 'Restart chat',
|
|
2334
|
+
'errors.general.message': 'Do you want to start a new chat session?',
|
|
2335
|
+
'errors.general.srText': 'Something went wrong with the chat session. You can restart the chat.',
|
|
2336
|
+
'errors.general.title': 'Something went wrong',
|
|
2337
|
+
'errors.seamlyOffline.message': 'There might be a problem with your or our network connection. The chat session should resume as soon the connection is available again.',
|
|
2338
|
+
'errors.seamlyOffline.srText': 'The chat has connection issues. There might be a problem with your or our network connection. The chat session should resume as soon as the connection is available again.',
|
|
2339
|
+
'errors.seamlyOffline.title': 'Connection issues',
|
|
2340
|
+
'errors.seamlyUnavailable.buttonText': 'Try again',
|
|
2341
|
+
'errors.seamlyUnavailable.message': 'The server could not be reached. Try again in a little while.',
|
|
2342
|
+
'errors.seamlyUnavailable.srText': 'The chat server could not be reached. Try again in a little while.',
|
|
2343
|
+
'errors.seamlyUnavailable.title': 'Server unavailable'
|
|
2344
|
+
},
|
|
2345
|
+
isLoading: false,
|
|
2346
|
+
initialLocale: undefined
|
|
2347
|
+
};
|
|
2348
|
+
/* harmony default export */ const i18n_reducer = (i18n_utils_createReducer({
|
|
2349
|
+
[setInitialLocale]: (state, {
|
|
2350
|
+
locale
|
|
2351
|
+
}) => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
2352
|
+
initialLocale: locale
|
|
2353
|
+
}),
|
|
2354
|
+
[setLocale.pending]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
2355
|
+
isLoading: true
|
|
2356
|
+
}),
|
|
2357
|
+
[setLocale.fulfilled]: (state, {
|
|
2358
|
+
payload: translations,
|
|
2359
|
+
meta: {
|
|
2360
|
+
arg: locale
|
|
2361
|
+
}
|
|
2362
|
+
}) => {
|
|
2363
|
+
if (!translations) {
|
|
2364
|
+
return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
2365
|
+
isLoading: false
|
|
2366
|
+
});
|
|
2685
2367
|
}
|
|
2686
|
-
}
|
|
2687
2368
|
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2369
|
+
return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
2370
|
+
isLoading: false,
|
|
2371
|
+
locale,
|
|
2372
|
+
translations: Object.keys(translations).sort().reduce((accum, key) => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, accum), {}, {
|
|
2373
|
+
[key]: translations[key]
|
|
2374
|
+
}), {})
|
|
2375
|
+
});
|
|
2376
|
+
},
|
|
2377
|
+
[setLocale.rejected]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
2378
|
+
isLoading: false
|
|
2379
|
+
})
|
|
2380
|
+
}, defaultState));
|
|
2381
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/index.js
|
|
2699
2382
|
|
|
2700
|
-
function splitFormattedArgument(block) {
|
|
2701
|
-
return split(block.slice(1, -1), ',', 3);
|
|
2702
|
-
}
|
|
2703
|
-
/**
|
|
2704
|
-
* Like `String.prototype.split()` but where the limit parameter causes the
|
|
2705
|
-
* remainder of the string to be grouped together in a final entry.
|
|
2706
|
-
*
|
|
2707
|
-
* @private
|
|
2708
|
-
* @param {String} string
|
|
2709
|
-
* @param {String} separator
|
|
2710
|
-
* @param {Number} limit
|
|
2711
|
-
* @param {Array} [accumulator=[]]
|
|
2712
|
-
* @return {Array}
|
|
2713
|
-
*/
|
|
2714
2383
|
|
|
2715
|
-
function split(string, separator, limit) {
|
|
2716
|
-
var accumulator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
2717
2384
|
|
|
2718
|
-
if (!string) {
|
|
2719
|
-
return accumulator;
|
|
2720
|
-
}
|
|
2721
2385
|
|
|
2722
|
-
if (limit === 1) {
|
|
2723
|
-
accumulator.push(string);
|
|
2724
|
-
return accumulator;
|
|
2725
|
-
}
|
|
2726
2386
|
|
|
2727
|
-
|
|
2387
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/app/utils.js
|
|
2728
2388
|
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2389
|
+
const {
|
|
2390
|
+
createAction: app_utils_createAction,
|
|
2391
|
+
createThunk: app_utils_createThunk,
|
|
2392
|
+
createReducer: app_utils_createReducer,
|
|
2393
|
+
selectState: app_utils_selectState
|
|
2394
|
+
} = createDomain('app');
|
|
2395
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/app/selectors.js
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
const selectUserHasResponded = createSelector(app_utils_selectState, state => state.userHasResponded);
|
|
2399
|
+
|
|
2400
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/utils.js
|
|
2401
|
+
|
|
2402
|
+
|
|
2403
|
+
const {
|
|
2404
|
+
createAction: visibility_utils_createAction,
|
|
2405
|
+
createActions: utils_createActions,
|
|
2406
|
+
createThunk: visibility_utils_createThunk,
|
|
2407
|
+
createReducer: visibility_utils_createReducer,
|
|
2408
|
+
selectState: visibility_utils_selectState
|
|
2409
|
+
} = createDomain('visibility');
|
|
2410
|
+
const calculateVisibility = ({
|
|
2411
|
+
hasResponded,
|
|
2412
|
+
previousVisibility,
|
|
2413
|
+
requestedVisibility,
|
|
2414
|
+
config
|
|
2415
|
+
}) => {
|
|
2416
|
+
const {
|
|
2417
|
+
defaults,
|
|
2418
|
+
layoutMode,
|
|
2419
|
+
hideOnNoUserResponse
|
|
2420
|
+
} = config;
|
|
2421
|
+
const {
|
|
2422
|
+
visible: defaultVisibility
|
|
2423
|
+
} = defaults || {}; // Requesting open should override the responded check.
|
|
2424
|
+
|
|
2425
|
+
if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== constants_visibilityStates.open) {
|
|
2426
|
+
return hasResponded ? requestedVisibility || previousVisibility || constants_visibilityStates.open : constants_visibilityStates.hidden;
|
|
2732
2427
|
}
|
|
2733
2428
|
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
}
|
|
2429
|
+
const baseVisibility = layoutMode === 'inline' ? constants_visibilityStates.open : constants_visibilityStates.minimized;
|
|
2430
|
+
return requestedVisibility || previousVisibility || defaultVisibility || baseVisibility;
|
|
2431
|
+
};
|
|
2432
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/selectors.js
|
|
2739
2433
|
|
|
2740
|
-
/**
|
|
2741
|
-
* The main class for formatting messages.
|
|
2742
|
-
*
|
|
2743
|
-
* @author Emanuel Rabina
|
|
2744
|
-
*/
|
|
2745
2434
|
|
|
2746
|
-
|
|
2747
|
-
/**
|
|
2748
|
-
* Creates a new formatter that can work using any of the custom type handlers
|
|
2749
|
-
* you register.
|
|
2750
|
-
*
|
|
2751
|
-
* @param {String} locale
|
|
2752
|
-
* @param {Object} [typeHandlers={}]
|
|
2753
|
-
* Optional object where the keys are the names of the types to register,
|
|
2754
|
-
* their values being the functions that will return a nicely formatted
|
|
2755
|
-
* string for the data and locale they are given.
|
|
2756
|
-
*/
|
|
2757
|
-
function MessageFormatter(locale) {
|
|
2758
|
-
var _this = this;
|
|
2435
|
+
const selectVisibility = createSelector(visibility_utils_selectState, state => state.visibility);
|
|
2759
2436
|
|
|
2760
|
-
|
|
2437
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/seamly-state-hooks.js
|
|
2438
|
+
function seamly_state_hooks_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2761
2439
|
|
|
2762
|
-
|
|
2440
|
+
function seamly_state_hooks_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { seamly_state_hooks_ownKeys(Object(source), true).forEach(function (key) { seamly_state_hooks_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { seamly_state_hooks_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2763
2441
|
|
|
2764
|
-
|
|
2765
|
-
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2766
|
-
return flatten(_this.process(message, values)).join('');
|
|
2767
|
-
}));
|
|
2442
|
+
function seamly_state_hooks_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2768
2443
|
|
|
2769
|
-
|
|
2770
|
-
|
|
2444
|
+
|
|
2445
|
+
|
|
2446
|
+
|
|
2447
|
+
|
|
2448
|
+
const seamly_state_hooks_selectState = state => state.state;
|
|
2449
|
+
const seamly_state_hooks_useSeamlyStateContext = () => useSelector(seamly_state_hooks_selectState);
|
|
2450
|
+
const selectEvents = createSelector(seamly_state_hooks_selectState, selectConfig, ({
|
|
2451
|
+
events
|
|
2452
|
+
}, config) => {
|
|
2453
|
+
var _config$messages;
|
|
2454
|
+
|
|
2455
|
+
const {
|
|
2456
|
+
enabled,
|
|
2457
|
+
threshold
|
|
2458
|
+
} = (config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) ?? {};
|
|
2459
|
+
|
|
2460
|
+
if (!enabled) {
|
|
2461
|
+
return events;
|
|
2771
2462
|
}
|
|
2772
|
-
/**
|
|
2773
|
-
* Formats an ICU message syntax string using `values` for placeholder data
|
|
2774
|
-
* and any currently-registered type handlers.
|
|
2775
|
-
*
|
|
2776
|
-
* @param {String} message
|
|
2777
|
-
* @param {Object} [values={}]
|
|
2778
|
-
* @return {String}
|
|
2779
|
-
*/
|
|
2780
2463
|
|
|
2464
|
+
const mappedEvents = [];
|
|
2465
|
+
let previousEvent = null;
|
|
2466
|
+
events.forEach((event, idx) => {
|
|
2467
|
+
// always add timeIndicator to first message
|
|
2468
|
+
if (idx === 0) {
|
|
2469
|
+
mappedEvents.push(seamly_state_hooks_objectSpread(seamly_state_hooks_objectSpread({}, event), {}, {
|
|
2470
|
+
timeIndicator: event.payload.occurredAt
|
|
2471
|
+
})); // else check if diff is greater than threshold
|
|
2472
|
+
} else {
|
|
2473
|
+
const timeIndicator = previousEvent && microsecondsToMilliseconds(event.payload.occurredAt - previousEvent.payload.occurredAt) >= threshold ? event.payload.occurredAt : undefined;
|
|
2474
|
+
mappedEvents.push(seamly_state_hooks_objectSpread(seamly_state_hooks_objectSpread({}, event), {}, {
|
|
2475
|
+
timeIndicator
|
|
2476
|
+
}));
|
|
2477
|
+
}
|
|
2781
2478
|
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
*
|
|
2796
|
-
* @param {String} message
|
|
2797
|
-
* @param {Object} [values={}]
|
|
2798
|
-
* @return {Array}
|
|
2799
|
-
*/
|
|
2800
|
-
function process(message) {
|
|
2801
|
-
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2479
|
+
previousEvent = event;
|
|
2480
|
+
});
|
|
2481
|
+
return mappedEvents;
|
|
2482
|
+
});
|
|
2483
|
+
const seamly_state_hooks_useEvents = () => useSelector(selectEvents, []);
|
|
2484
|
+
const useSeamlyIsLoading = () => seamly_state_hooks_useSeamlyStateContext().isLoading;
|
|
2485
|
+
const useSeamlyHeaderData = () => seamly_state_hooks_useSeamlyStateContext().headerTitles;
|
|
2486
|
+
const seamly_state_hooks_useSeamlyUnreadCount = () => seamly_state_hooks_useSeamlyStateContext().unreadEvents;
|
|
2487
|
+
const seamly_state_hooks_useSkiplink = () => seamly_state_hooks_useSeamlyStateContext().skiplinkTargetId;
|
|
2488
|
+
const useSeamlyParticipant = participantId => seamly_state_hooks_useSeamlyStateContext().participantInfo.participants[participantId];
|
|
2489
|
+
const useSeamlyServiceInfo = () => seamly_state_hooks_useSeamlyStateContext().serviceInfo;
|
|
2490
|
+
const selectLastMessageEventId = createSelector(selectEvents, events => {
|
|
2491
|
+
var _filteredEvents;
|
|
2802
2492
|
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2493
|
+
const filteredEvents = events.filter(event => event.type === 'message');
|
|
2494
|
+
return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
|
|
2495
|
+
});
|
|
2496
|
+
const useLastMessageEventId = () => useSelector(selectLastMessageEventId);
|
|
2497
|
+
const useSeamlyIsHistoryLoaded = () => seamly_state_hooks_useSeamlyStateContext().historyLoaded;
|
|
2498
|
+
const useSeamlyCurrentAgent = () => {
|
|
2499
|
+
const {
|
|
2500
|
+
participants,
|
|
2501
|
+
currentAgent
|
|
2502
|
+
} = seamly_state_hooks_useSeamlyStateContext().participantInfo;
|
|
2503
|
+
return currentAgent ? participants[currentAgent] : null;
|
|
2504
|
+
};
|
|
2505
|
+
const useSeamlyServiceData = key => seamly_state_hooks_useSeamlyStateContext().serviceData[key];
|
|
2506
|
+
const useEntryTextLimit = () => {
|
|
2507
|
+
const {
|
|
2508
|
+
entryMeta: {
|
|
2509
|
+
options: {
|
|
2510
|
+
text
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
} = seamly_state_hooks_useSeamlyStateContext();
|
|
2514
|
+
const {
|
|
2515
|
+
limit
|
|
2516
|
+
} = text || {};
|
|
2517
|
+
return {
|
|
2518
|
+
hasLimit: limit != null,
|
|
2519
|
+
limit: limit != null ? limit : null
|
|
2520
|
+
};
|
|
2521
|
+
};
|
|
2522
|
+
const useSeamlyLayoutMode = () => {
|
|
2523
|
+
const {
|
|
2524
|
+
layoutMode
|
|
2525
|
+
} = useConfig();
|
|
2526
|
+
return {
|
|
2527
|
+
isInline: layoutMode === 'inline',
|
|
2528
|
+
isModal: layoutMode === 'modal',
|
|
2529
|
+
isWindow: layoutMode === 'window',
|
|
2530
|
+
isResolving: !layoutMode
|
|
2531
|
+
};
|
|
2532
|
+
};
|
|
2533
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/actions.js
|
|
2534
|
+
function actions_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2535
|
+
|
|
2536
|
+
function actions_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { actions_ownKeys(Object(source), true).forEach(function (key) { actions_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { actions_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2537
|
+
|
|
2538
|
+
function actions_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
|
|
2543
|
+
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
const setFromStorage = visibility_utils_createAction('setFromStorage', visibility => ({
|
|
2547
|
+
visibility
|
|
2548
|
+
}));
|
|
2549
|
+
const validVisibilityStates = [constants_visibilityStates.open, constants_visibilityStates.minimized, constants_visibilityStates.hidden];
|
|
2550
|
+
const setVisibility = visibility_utils_createThunk('set', (requestedVisibility, {
|
|
2551
|
+
getState,
|
|
2552
|
+
extra: {
|
|
2553
|
+
api,
|
|
2554
|
+
eventBus
|
|
2555
|
+
}
|
|
2556
|
+
}) => {
|
|
2557
|
+
const state = getState();
|
|
2558
|
+
const previousVisibility = selectVisibility(state);
|
|
2559
|
+
const hasResponded = selectUserHasResponded(state);
|
|
2560
|
+
const hasConversation = api.hasConversation();
|
|
2561
|
+
const config = selectConfig(state);
|
|
2562
|
+
const {
|
|
2563
|
+
visibilityCallback = calculateVisibility,
|
|
2564
|
+
layoutMode
|
|
2565
|
+
} = config;
|
|
2566
|
+
const {
|
|
2567
|
+
unreadEvents: unreadMessageCount
|
|
2568
|
+
} = seamly_state_hooks_selectState(state);
|
|
2569
|
+
const calculatedVisibility = visibilityCallback({
|
|
2570
|
+
hasConversation,
|
|
2571
|
+
hasResponded,
|
|
2572
|
+
previousVisibility,
|
|
2573
|
+
requestedVisibility,
|
|
2574
|
+
config
|
|
2575
|
+
});
|
|
2576
|
+
|
|
2577
|
+
if (!validVisibilityStates.includes(calculatedVisibility)) {
|
|
2578
|
+
console.error('The visibilityCallback function should return "open", "minimized" or "hidden".');
|
|
2579
|
+
return undefined;
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
if (previousVisibility === calculatedVisibility) {
|
|
2583
|
+
return undefined;
|
|
2584
|
+
} // Store the user-requested visibility in order to reinitialize after refresh
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
api.store.set(StoreKey, actions_objectSpread(actions_objectSpread({}, api.store.get(StoreKey) || {}), {}, {
|
|
2588
|
+
[layoutMode]: requestedVisibility
|
|
2589
|
+
}));
|
|
2590
|
+
|
|
2591
|
+
if (requestedVisibility) {
|
|
2592
|
+
eventBus.emit('ui.visible', requestedVisibility, {
|
|
2593
|
+
visibility: requestedVisibility,
|
|
2594
|
+
hasConversation,
|
|
2595
|
+
hasResponded,
|
|
2596
|
+
unreadMessageCount
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
return calculatedVisibility;
|
|
2601
|
+
});
|
|
2602
|
+
const actions_initialize = visibility_utils_createThunk('initialize', async (locale, {
|
|
2603
|
+
dispatch,
|
|
2604
|
+
getState,
|
|
2605
|
+
extra: {
|
|
2606
|
+
api
|
|
2607
|
+
}
|
|
2608
|
+
}) => {
|
|
2609
|
+
var _api$store$get;
|
|
2610
|
+
|
|
2611
|
+
// initialize stored visibility
|
|
2612
|
+
const {
|
|
2613
|
+
layoutMode
|
|
2614
|
+
} = selectConfig(getState());
|
|
2615
|
+
const storedVisibility = (_api$store$get = api.store.get(StoreKey)) === null || _api$store$get === void 0 ? void 0 : _api$store$get[layoutMode];
|
|
2616
|
+
|
|
2617
|
+
if (storedVisibility) {
|
|
2618
|
+
dispatch(setFromStorage(storedVisibility));
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
dispatch(setVisibility(constants_visibilityStates.initialize));
|
|
2622
|
+
});
|
|
2623
|
+
;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-unavailable-error.js
|
|
2624
|
+
/**
|
|
2625
|
+
* This error is used to alert the user that there's a problem with the connection
|
|
2626
|
+
* when initialising the application because of a connection issue on either the server
|
|
2627
|
+
* or the client side.
|
|
2628
|
+
*/
|
|
2629
|
+
class SeamlyUnavailableError extends Error {
|
|
2630
|
+
constructor(params) {
|
|
2631
|
+
super(params);
|
|
2632
|
+
|
|
2633
|
+
if (Error.captureStackTrace) {
|
|
2634
|
+
Error.captureStackTrace(this, SeamlyUnavailableError);
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
this.name = 'SeamlyUnavailableError';
|
|
2638
|
+
this.langKey = 'errors.seamlyUnavailable';
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
}
|
|
2642
|
+
;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-base-error.js
|
|
2643
|
+
class SeamlyBaseError extends Error {
|
|
2644
|
+
constructor(originalError, ...params) {
|
|
2645
|
+
super(...params);
|
|
2646
|
+
|
|
2647
|
+
if (Error.captureStackTrace) {
|
|
2648
|
+
Error.captureStackTrace(this, Object.getPrototypeOf(this));
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
this.originalError = originalError;
|
|
2652
|
+
|
|
2653
|
+
if (originalError !== null && originalError !== void 0 && originalError.payload) {
|
|
2654
|
+
this.originalEvent = originalError;
|
|
2655
|
+
this.originalError = originalError.payload.error;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
if (originalError !== null && originalError !== void 0 && originalError.error) {
|
|
2659
|
+
this.originalError = originalError.error;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
}
|
|
2664
|
+
;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-session-expired-error.js
|
|
2665
|
+
|
|
2666
|
+
class SeamlySessionExpiredError extends SeamlyBaseError {
|
|
2667
|
+
constructor(originalError, ...params) {
|
|
2668
|
+
super(originalError, ...params);
|
|
2669
|
+
this.name = 'SeamlySessionExpiredError';
|
|
2670
|
+
this.action = 'reset';
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
}
|
|
2674
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/app/actions.js
|
|
2675
|
+
|
|
2676
|
+
|
|
2677
|
+
|
|
2678
|
+
|
|
2679
|
+
|
|
2680
|
+
|
|
2681
|
+
|
|
2682
|
+
const setHasResponded = app_utils_createAction('setHasResponded', hasResponded => ({
|
|
2683
|
+
hasResponded
|
|
2684
|
+
}));
|
|
2685
|
+
const app_actions_initialize = app_utils_createThunk('initialize', async (config, {
|
|
2686
|
+
dispatch,
|
|
2687
|
+
extra: {
|
|
2688
|
+
api
|
|
2689
|
+
}
|
|
2690
|
+
}) => {
|
|
2691
|
+
var _config$context;
|
|
2692
|
+
|
|
2693
|
+
dispatch(initialize(config));
|
|
2694
|
+
let locale = config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale;
|
|
2695
|
+
|
|
2696
|
+
try {
|
|
2697
|
+
const {
|
|
2698
|
+
features,
|
|
2699
|
+
defaultLocale
|
|
2700
|
+
} = await api.getConfig();
|
|
2701
|
+
dispatch({
|
|
2702
|
+
type: seamly_utils_seamlyActions.SET_FEATURES,
|
|
2703
|
+
features
|
|
2704
|
+
});
|
|
2705
|
+
locale = locale || defaultLocale;
|
|
2706
|
+
dispatch(setInitialLocale(locale));
|
|
2707
|
+
} catch (e) {
|
|
2708
|
+
throw new SeamlyUnavailableError();
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
try {
|
|
2712
|
+
if (api.hasConversation()) {
|
|
2713
|
+
var _initialState$transla;
|
|
2714
|
+
|
|
2715
|
+
const initialState = await api.getConversationIntitialState();
|
|
2716
|
+
dispatch({
|
|
2717
|
+
type: seamly_utils_seamlyActions.SET_INITIAL_STATE,
|
|
2718
|
+
initialState
|
|
2719
|
+
});
|
|
2720
|
+
locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
|
|
2721
|
+
|
|
2722
|
+
if ('userResponded' in initialState) {
|
|
2723
|
+
dispatch(setHasResponded(initialState.userResponded));
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
} catch (e) {
|
|
2727
|
+
if (e instanceof SeamlySessionExpiredError) {
|
|
2728
|
+
throw e;
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
throw new SeamlyUnavailableError();
|
|
2732
|
+
} finally {
|
|
2733
|
+
await dispatch(setLocale(locale));
|
|
2734
|
+
dispatch(actions_initialize());
|
|
2735
|
+
}
|
|
2736
|
+
});
|
|
2737
|
+
const actions_reset = app_utils_createAction('reset', () => {});
|
|
2738
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/app/hooks.js
|
|
2739
|
+
|
|
2740
|
+
|
|
2741
|
+
function hooks_useUserHasResponded() {
|
|
2742
|
+
return useSelector(Selectors.selectUserHasResponded);
|
|
2743
|
+
}
|
|
2744
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/app/reducer.js
|
|
2745
|
+
function app_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2746
|
+
|
|
2747
|
+
function app_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { app_reducer_ownKeys(Object(source), true).forEach(function (key) { app_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { app_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2748
|
+
|
|
2749
|
+
function app_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2750
|
+
|
|
2751
|
+
|
|
2752
|
+
|
|
2753
|
+
const reducer_initialState = {
|
|
2754
|
+
userHasResponded: false
|
|
2755
|
+
};
|
|
2756
|
+
/* harmony default export */ const app_reducer = (app_utils_createReducer({
|
|
2757
|
+
[setHasResponded]: (state, {
|
|
2758
|
+
hasResponded
|
|
2759
|
+
}) => app_reducer_objectSpread(app_reducer_objectSpread({}, state), {}, {
|
|
2760
|
+
userHasResponded: hasResponded
|
|
2761
|
+
})
|
|
2762
|
+
}, reducer_initialState));
|
|
2763
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/app/index.js
|
|
2764
|
+
|
|
2765
|
+
|
|
2766
|
+
|
|
2767
|
+
|
|
2768
|
+
|
|
2769
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/store/state-reducer.js
|
|
2770
|
+
function state_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2771
|
+
|
|
2772
|
+
function state_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { state_reducer_ownKeys(Object(source), true).forEach(function (key) { state_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { state_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2773
|
+
|
|
2774
|
+
function state_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2775
|
+
|
|
2776
|
+
// Legacy state reducer. Do not add new features here but extract/create new reducers as needed
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
|
|
2780
|
+
const state_reducer_initialState = {
|
|
2781
|
+
events: [],
|
|
2782
|
+
initialState: {},
|
|
2783
|
+
unreadEvents: 0,
|
|
2784
|
+
isLoading: false,
|
|
2785
|
+
idleDetachCountdown: {
|
|
2786
|
+
hasCountdown: false,
|
|
2787
|
+
isActive: false
|
|
2788
|
+
},
|
|
2789
|
+
resumeConversationPrompt: false,
|
|
2790
|
+
serviceInfo: {
|
|
2791
|
+
activeServiceSessionId: ''
|
|
2792
|
+
},
|
|
2793
|
+
participantInfo: {
|
|
2794
|
+
participants: {},
|
|
2795
|
+
currentAgent: ''
|
|
2796
|
+
},
|
|
2797
|
+
headerTitles: {
|
|
2798
|
+
title: null,
|
|
2799
|
+
subTitle: ''
|
|
2800
|
+
},
|
|
2801
|
+
historyLoaded: false,
|
|
2802
|
+
skiplinkTargetId: id_randomId(),
|
|
2803
|
+
optionsButtonId: id_randomId(),
|
|
2804
|
+
cobrowsingContainerId: id_randomId(),
|
|
2805
|
+
headerCollapseButtonId: id_randomId(),
|
|
2806
|
+
serviceData: {},
|
|
2807
|
+
options: {
|
|
2808
|
+
features: {},
|
|
2809
|
+
panelActive: false,
|
|
2810
|
+
optionActive: '',
|
|
2811
|
+
userSelectedOptions: {}
|
|
2812
|
+
},
|
|
2813
|
+
showFileUpload: false,
|
|
2814
|
+
currentUploads: [],
|
|
2815
|
+
entryMeta: {
|
|
2816
|
+
default: entryTypes.text,
|
|
2817
|
+
active: entryTypes.text,
|
|
2818
|
+
userSelected: null,
|
|
2819
|
+
blockAutoEntrySwitch: false,
|
|
2820
|
+
options: {},
|
|
2821
|
+
optionsOverride: {}
|
|
2822
|
+
},
|
|
2823
|
+
seamlyContainerElement: null
|
|
2824
|
+
};
|
|
2825
|
+
function stateReducer(state = state_reducer_initialState, action) {
|
|
2826
|
+
if (action.type === String(actions_reset)) {
|
|
2827
|
+
const {
|
|
2828
|
+
visible
|
|
2829
|
+
} = state;
|
|
2830
|
+
return state_reducer_objectSpread(state_reducer_objectSpread({}, state_reducer_initialState), {}, {
|
|
2831
|
+
visible
|
|
2832
|
+
});
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
return seamlyStateReducer(state, action);
|
|
2836
|
+
}
|
|
2837
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/utils.js
|
|
2838
|
+
|
|
2839
|
+
const {
|
|
2840
|
+
createActions: forms_utils_createActions,
|
|
2841
|
+
createReducer: forms_utils_createReducer,
|
|
2842
|
+
selectState: forms_utils_selectState
|
|
2843
|
+
} = createDomain('forms');
|
|
2844
|
+
function utils_validate(values, schema = {}) {
|
|
2845
|
+
return Object.entries(schema).reduce((errors, [key, validations]) => {
|
|
2846
|
+
if (validations && !Array.isArray(validations)) {
|
|
2847
|
+
// eslint-disable-next-line no-param-reassign
|
|
2848
|
+
validations = [validations];
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
for (let i = 0; i < ((_validations = validations) === null || _validations === void 0 ? void 0 : _validations.length) ?? 0; i++) {
|
|
2852
|
+
var _validations;
|
|
2853
|
+
|
|
2854
|
+
if (!validations[i].fn(values[key], validations[i].compareValue)) {
|
|
2855
|
+
errors[key] = validations[i].errorText;
|
|
2856
|
+
break;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
return errors;
|
|
2861
|
+
}, {});
|
|
2862
|
+
}
|
|
2863
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/actions.js
|
|
2864
|
+
|
|
2865
|
+
const [registerForm, deregisterForm] = forms_utils_createActions('form', {
|
|
2866
|
+
register: (formId, persistData) => ({
|
|
2867
|
+
formId,
|
|
2868
|
+
persistData
|
|
2869
|
+
}),
|
|
2870
|
+
deregister: formId => ({
|
|
2871
|
+
formId
|
|
2872
|
+
})
|
|
2873
|
+
});
|
|
2874
|
+
const [registerControl, deregisterControl, updateControlValue, updateControlTouched] = forms_utils_createActions('control', {
|
|
2875
|
+
register: (formId, name) => ({
|
|
2876
|
+
formId,
|
|
2877
|
+
name
|
|
2878
|
+
}),
|
|
2879
|
+
deregister: (formId, name) => ({
|
|
2880
|
+
formId,
|
|
2881
|
+
name
|
|
2882
|
+
}),
|
|
2883
|
+
updateValue: (formId, name, value) => ({
|
|
2884
|
+
formId,
|
|
2885
|
+
name,
|
|
2886
|
+
value
|
|
2887
|
+
}),
|
|
2888
|
+
updateTouched: (formId, name, touched) => ({
|
|
2889
|
+
formId,
|
|
2890
|
+
name,
|
|
2891
|
+
touched
|
|
2892
|
+
})
|
|
2893
|
+
});
|
|
2894
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/redux/utils.js
|
|
2895
|
+
const arrayContentEquals = (a, b) => {
|
|
2896
|
+
if (a === b) {
|
|
2897
|
+
return true;
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) {
|
|
2901
|
+
return false;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
return a.every((value, idx) => b[idx] === value);
|
|
2905
|
+
};
|
|
2906
|
+
const getPropSelector = (propName, orDefault) => (_, props) => props[propName] || orDefault;
|
|
2907
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/selectors.js
|
|
2908
|
+
|
|
2909
|
+
|
|
2910
|
+
|
|
2911
|
+
const getState = forms_utils_selectState;
|
|
2912
|
+
const selectors_getFormById = createSelector(getState, getPropSelector('formId'), (forms, formId) => forms[formId]);
|
|
2913
|
+
const getFormControlsByFormId = createSelector(selectors_getFormById, form => (form === null || form === void 0 ? void 0 : form.controls) || {});
|
|
2914
|
+
const selectors_getFormValuesByFormId = createSelector(getFormControlsByFormId, controls => {
|
|
2915
|
+
const valuesObj = {};
|
|
2916
|
+
Object.entries(controls).forEach(([key, {
|
|
2917
|
+
value
|
|
2918
|
+
}]) => {
|
|
2919
|
+
valuesObj[key] = value;
|
|
2920
|
+
});
|
|
2921
|
+
return valuesObj;
|
|
2922
|
+
});
|
|
2923
|
+
const selectors_getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
2924
|
+
var _controls$name;
|
|
2925
|
+
|
|
2926
|
+
return (_controls$name = controls[name]) === null || _controls$name === void 0 ? void 0 : _controls$name.value;
|
|
2927
|
+
});
|
|
2928
|
+
const selectors_getControlTouchedByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
2929
|
+
var _controls$name2;
|
|
2930
|
+
|
|
2931
|
+
return (_controls$name2 = controls[name]) === null || _controls$name2 === void 0 ? void 0 : _controls$name2.touched;
|
|
2932
|
+
});
|
|
2933
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/context.js
|
|
2934
|
+
|
|
2935
|
+
const context_FormContext = (0,external_preact_namespaceObject.createContext)({});
|
|
2936
|
+
/* harmony default export */ const forms_context = ((/* unused pure expression or super */ null && (context_FormContext)));
|
|
2937
|
+
const {
|
|
2938
|
+
Provider: forms_context_Provider,
|
|
2939
|
+
Consumer: context_Consumer
|
|
2940
|
+
} = context_FormContext;
|
|
2941
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/hooks.js
|
|
2942
|
+
|
|
2943
|
+
|
|
2944
|
+
|
|
2945
|
+
|
|
2946
|
+
|
|
2947
|
+
|
|
2948
|
+
function hooks_useFormContext() {
|
|
2949
|
+
return useContext(FormContext);
|
|
2950
|
+
}
|
|
2951
|
+
function hooks_useForm() {
|
|
2952
|
+
const {
|
|
2953
|
+
handleSubmit
|
|
2954
|
+
} = hooks_useFormContext();
|
|
2955
|
+
return {
|
|
2956
|
+
handleSubmit
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
function hooks_useValidations(values, validationSchema) {
|
|
2960
|
+
const errors = useMemo(() => validate(values, validationSchema), [values, validationSchema]);
|
|
2961
|
+
return {
|
|
2962
|
+
isValid: Object.keys(errors).length === 0,
|
|
2963
|
+
errors
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
function hooks_useFormControl(name) {
|
|
2967
|
+
const dispatch = useStoreDispatch();
|
|
2968
|
+
const {
|
|
2969
|
+
formId,
|
|
2970
|
+
updateControlValue,
|
|
2971
|
+
updateControlTouched,
|
|
2972
|
+
errors
|
|
2973
|
+
} = hooks_useFormContext();
|
|
2974
|
+
const form = useSelectorWithProps(getFormById, {
|
|
2975
|
+
formId
|
|
2976
|
+
}, [formId]);
|
|
2977
|
+
const isRegistered = !!form;
|
|
2978
|
+
const isRegisteredRef = useRef();
|
|
2979
|
+
isRegisteredRef.current = isRegistered;
|
|
2980
|
+
const value = useSelectorWithProps(getControlValueByName, {
|
|
2981
|
+
formId,
|
|
2982
|
+
name
|
|
2983
|
+
}, [formId, name]);
|
|
2984
|
+
const touched = useSelectorWithProps(getControlTouchedByName, {
|
|
2985
|
+
formId,
|
|
2986
|
+
name
|
|
2987
|
+
}, [formId, name]);
|
|
2988
|
+
const error = errors === null || errors === void 0 ? void 0 : errors[name];
|
|
2989
|
+
const isValid = !error;
|
|
2990
|
+
useEffect(() => {
|
|
2991
|
+
// Make sure the form is registered
|
|
2992
|
+
// Since child useEffect runs before FormProvider useEffect
|
|
2993
|
+
if (isRegisteredRef.current) {
|
|
2994
|
+
dispatch(Actions.registerControl(formId, name));
|
|
2995
|
+
}
|
|
2996
|
+
}, [isRegistered, formId, name, dispatch]);
|
|
2997
|
+
useLayoutEffect(() => {
|
|
2998
|
+
return () => {
|
|
2999
|
+
dispatch(Actions.deregisterControl(formId, name));
|
|
3000
|
+
};
|
|
3001
|
+
}, [isRegistered, formId, name, dispatch]); // preact uses onInput instead of onChange
|
|
3002
|
+
|
|
3003
|
+
const onInput = useCallback(e => updateControlValue(name, e.target.value), [name, updateControlValue]);
|
|
3004
|
+
const onBlur = useCallback(() => {
|
|
3005
|
+
updateControlTouched(name, true);
|
|
3006
|
+
}, [updateControlTouched, name]);
|
|
3007
|
+
const field = useMemo(() => ({
|
|
3008
|
+
name,
|
|
3009
|
+
onInput,
|
|
3010
|
+
onBlur,
|
|
3011
|
+
value
|
|
3012
|
+
}), [name, onInput, onBlur, value]);
|
|
3013
|
+
const meta = useMemo(() => ({
|
|
3014
|
+
isValid,
|
|
3015
|
+
error,
|
|
3016
|
+
touched
|
|
3017
|
+
}), [isValid, error, touched]);
|
|
3018
|
+
return [field, meta];
|
|
3019
|
+
}
|
|
3020
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/provider.js
|
|
3021
|
+
const provider_excluded = (/* unused pure expression or super */ null && (["children", "formId", "persistData", "onSubmit", "validationSchema"]));
|
|
2806
3022
|
|
|
2807
|
-
|
|
3023
|
+
function provider_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2808
3024
|
|
|
2809
|
-
|
|
2810
|
-
var blockEndIndex = findClosingBracket(message, blockStartIndex);
|
|
3025
|
+
function provider_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { provider_ownKeys(Object(source), true).forEach(function (key) { provider_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { provider_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2811
3026
|
|
|
2812
|
-
|
|
2813
|
-
var block = message.substring(blockStartIndex, blockEndIndex + 1);
|
|
3027
|
+
function provider_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2814
3028
|
|
|
2815
|
-
|
|
2816
|
-
var result = [];
|
|
2817
|
-
var head = message.substring(0, blockStartIndex);
|
|
3029
|
+
function provider_objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = provider_objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
2818
3030
|
|
|
2819
|
-
|
|
2820
|
-
result.push(head);
|
|
2821
|
-
}
|
|
3031
|
+
function provider_objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
2822
3032
|
|
|
2823
|
-
var _splitFormattedArgume = splitFormattedArgument(block),
|
|
2824
|
-
_splitFormattedArgume2 = _slicedToArray(_splitFormattedArgume, 3),
|
|
2825
|
-
key = _splitFormattedArgume2[0],
|
|
2826
|
-
type = _splitFormattedArgume2[1],
|
|
2827
|
-
format = _splitFormattedArgume2[2];
|
|
2828
3033
|
|
|
2829
|
-
var body = values[key];
|
|
2830
3034
|
|
|
2831
|
-
if (body === null || body === undefined) {
|
|
2832
|
-
body = '';
|
|
2833
|
-
}
|
|
2834
3035
|
|
|
2835
|
-
var typeHandler = type && this.typeHandlers[type];
|
|
2836
|
-
result.push(typeHandler ? typeHandler(body, format, this.locale, values, this.process.bind(this)) : body);
|
|
2837
|
-
var tail = message.substring(blockEndIndex + 1);
|
|
2838
3036
|
|
|
2839
|
-
if (tail) {
|
|
2840
|
-
result.push(this.process(tail, values));
|
|
2841
|
-
}
|
|
2842
3037
|
|
|
2843
|
-
return result;
|
|
2844
|
-
}
|
|
2845
|
-
} else {
|
|
2846
|
-
throw new Error("Unbalanced curly braces in string: \"".concat(message, "\""));
|
|
2847
|
-
}
|
|
2848
|
-
}
|
|
2849
3038
|
|
|
2850
|
-
return [message];
|
|
2851
|
-
}
|
|
2852
|
-
}]);
|
|
2853
3039
|
|
|
2854
|
-
|
|
2855
|
-
|
|
3040
|
+
function provider_FormProvider(_ref) {
|
|
3041
|
+
let {
|
|
3042
|
+
children,
|
|
3043
|
+
formId,
|
|
3044
|
+
persistData,
|
|
3045
|
+
onSubmit,
|
|
3046
|
+
validationSchema
|
|
3047
|
+
} = _ref,
|
|
3048
|
+
props = provider_objectWithoutProperties(_ref, provider_excluded);
|
|
2856
3049
|
|
|
2857
|
-
|
|
3050
|
+
const dispatch = useStoreDispatch();
|
|
3051
|
+
const values = useSelectorWithProps(getFormValuesByFormId, {
|
|
3052
|
+
formId
|
|
3053
|
+
}, [formId]);
|
|
3054
|
+
const [isSubmitted, setIsSubmitted] = useState(false);
|
|
3055
|
+
const [externalErrors, setExternalErrors] = useState({});
|
|
3056
|
+
const {
|
|
3057
|
+
isValid: validationIsValid,
|
|
3058
|
+
errors: validationErrors
|
|
3059
|
+
} = useValidations(values, validationSchema);
|
|
3060
|
+
const errors = useMemo(() => provider_objectSpread(provider_objectSpread({}, validationErrors), externalErrors), [validationErrors, externalErrors]); // register
|
|
2858
3061
|
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
3062
|
+
useLayoutEffect(() => {
|
|
3063
|
+
// register form in redux store
|
|
3064
|
+
dispatch(Actions.registerForm(formId, persistData));
|
|
3065
|
+
}, [formId, persistData, dispatch]); // deregister
|
|
2862
3066
|
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
3067
|
+
useEffect(() => {
|
|
3068
|
+
return () => {
|
|
3069
|
+
// deregister form from redux store
|
|
3070
|
+
dispatch(Actions.deregisterForm(formId));
|
|
3071
|
+
};
|
|
3072
|
+
}, [formId, persistData, dispatch]);
|
|
3073
|
+
const updateControlValue = useCallback((name, value) => {
|
|
3074
|
+
dispatch(Actions.updateControlValue(formId, name, value));
|
|
3075
|
+
}, [formId, dispatch]);
|
|
3076
|
+
const updateControlTouched = useCallback((name, touched) => {
|
|
3077
|
+
dispatch(Actions.updateControlTouched(formId, name, touched));
|
|
3078
|
+
}, [dispatch, formId]); // Function to manually set an error
|
|
2871
3079
|
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
3080
|
+
const setError = useCallback((name, error) => {
|
|
3081
|
+
setExternalErrors(val => {
|
|
3082
|
+
return provider_objectSpread(provider_objectSpread({}, val), {}, {
|
|
3083
|
+
[name]: error
|
|
3084
|
+
});
|
|
3085
|
+
});
|
|
3086
|
+
}, [setExternalErrors]);
|
|
3087
|
+
const handleSubmit = useCallback(e => {
|
|
3088
|
+
e.preventDefault();
|
|
3089
|
+
setIsSubmitted(true);
|
|
2877
3090
|
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
} else {
|
|
2884
|
-
output += caseBody[i];
|
|
3091
|
+
if (validationIsValid) {
|
|
3092
|
+
onSubmit(values, {
|
|
3093
|
+
updateControlValue,
|
|
3094
|
+
setError
|
|
3095
|
+
});
|
|
2885
3096
|
}
|
|
3097
|
+
}, [validationIsValid, onSubmit, values, updateControlValue, setError]);
|
|
3098
|
+
const contextValue = useMemo(() => ({
|
|
3099
|
+
formId,
|
|
3100
|
+
values,
|
|
3101
|
+
errors,
|
|
3102
|
+
isValid: Object.keys(errors).length === 0,
|
|
3103
|
+
isSubmitted,
|
|
3104
|
+
handleSubmit,
|
|
3105
|
+
validationSchema,
|
|
3106
|
+
updateControlValue,
|
|
3107
|
+
updateControlTouched
|
|
3108
|
+
}), [formId, values, errors, isSubmitted, handleSubmit, validationSchema, updateControlValue, updateControlTouched]);
|
|
2886
3109
|
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
}
|
|
3110
|
+
if (!formId) {
|
|
3111
|
+
console.error('"formId" is required.');
|
|
3112
|
+
return null;
|
|
3113
|
+
}
|
|
2892
3114
|
|
|
2893
|
-
|
|
3115
|
+
if (!onSubmit) {
|
|
3116
|
+
console.error('"onSubmit" is required.');
|
|
3117
|
+
return null;
|
|
2894
3118
|
}
|
|
2895
3119
|
|
|
2896
|
-
return {
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
};
|
|
3120
|
+
return _jsx(Provider, provider_objectSpread(provider_objectSpread({}, props), {}, {
|
|
3121
|
+
value: contextValue,
|
|
3122
|
+
children: children
|
|
3123
|
+
}));
|
|
2900
3124
|
}
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
* a formatted string for the branch that closely matches the current value.
|
|
2904
|
-
*
|
|
2905
|
-
* See https://formatjs.io/docs/core-concepts/icu-syntax#plural-format for more
|
|
2906
|
-
* details on how the `plural` statement works.
|
|
2907
|
-
*
|
|
2908
|
-
* @param {String} value
|
|
2909
|
-
* @param {String} matches
|
|
2910
|
-
* @param {String} locale
|
|
2911
|
-
* @param {String} values
|
|
2912
|
-
* @param {Function} format
|
|
2913
|
-
* @return {String}
|
|
2914
|
-
*/
|
|
3125
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/reducer.js
|
|
3126
|
+
function forms_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2915
3127
|
|
|
3128
|
+
function forms_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { forms_reducer_ownKeys(Object(source), true).forEach(function (key) { forms_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { forms_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2916
3129
|
|
|
2917
|
-
function
|
|
2918
|
-
var matches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2919
|
-
var locale = arguments.length > 2 ? arguments[2] : undefined;
|
|
2920
|
-
var values = arguments.length > 3 ? arguments[3] : undefined;
|
|
2921
|
-
var format = arguments.length > 4 ? arguments[4] : undefined;
|
|
3130
|
+
function forms_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2922
3131
|
|
|
2923
|
-
var _parseCases = parseCases(matches),
|
|
2924
|
-
args = _parseCases.args,
|
|
2925
|
-
cases = _parseCases.cases;
|
|
2926
3132
|
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3133
|
+
|
|
3134
|
+
const forms_reducer_initialState = {};
|
|
3135
|
+
const initialFormState = {
|
|
3136
|
+
controls: {}
|
|
3137
|
+
};
|
|
3138
|
+
const initialControlState = {
|
|
3139
|
+
value: '',
|
|
3140
|
+
touched: false
|
|
3141
|
+
};
|
|
3142
|
+
|
|
3143
|
+
function updateFormControl(state, formId, name, controlState) {
|
|
3144
|
+
var _state$formId;
|
|
3145
|
+
|
|
3146
|
+
const currentControlState = ((_state$formId = state[formId]) === null || _state$formId === void 0 ? void 0 : _state$formId.controls[name]) || initialControlState;
|
|
3147
|
+
return forms_reducer_objectSpread(forms_reducer_objectSpread({}, state), {}, {
|
|
3148
|
+
[formId]: forms_reducer_objectSpread(forms_reducer_objectSpread({}, state[formId]), {}, {
|
|
3149
|
+
controls: forms_reducer_objectSpread(forms_reducer_objectSpread({}, state[formId].controls), {}, {
|
|
3150
|
+
[name]: forms_reducer_objectSpread(forms_reducer_objectSpread({}, currentControlState), controlState)
|
|
3151
|
+
})
|
|
3152
|
+
})
|
|
2932
3153
|
});
|
|
2933
|
-
|
|
3154
|
+
}
|
|
2934
3155
|
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3156
|
+
/* harmony default export */ const forms_reducer = (forms_utils_createReducer({
|
|
3157
|
+
// Form handlers
|
|
3158
|
+
[registerForm]: (state, {
|
|
3159
|
+
formId,
|
|
3160
|
+
persistData
|
|
3161
|
+
}) => {
|
|
3162
|
+
const formState = persistData ? state[formId] ?? forms_reducer_objectSpread(forms_reducer_objectSpread({}, initialFormState), {}, {
|
|
3163
|
+
persistData
|
|
3164
|
+
}) : forms_reducer_objectSpread(forms_reducer_objectSpread({}, initialFormState), {}, {
|
|
3165
|
+
persistData
|
|
3166
|
+
});
|
|
3167
|
+
return forms_reducer_objectSpread(forms_reducer_objectSpread({}, state), {}, {
|
|
3168
|
+
[formId]: formState
|
|
3169
|
+
});
|
|
3170
|
+
},
|
|
3171
|
+
[deregisterForm]: (state, {
|
|
3172
|
+
formId
|
|
3173
|
+
}) => {
|
|
3174
|
+
var _newState$formId;
|
|
3175
|
+
|
|
3176
|
+
const newState = forms_reducer_objectSpread({}, state);
|
|
3177
|
+
|
|
3178
|
+
if (!((_newState$formId = newState[formId]) !== null && _newState$formId !== void 0 && _newState$formId.persistData)) {
|
|
3179
|
+
delete newState[formId];
|
|
2939
3180
|
}
|
|
2940
3181
|
|
|
2941
|
-
|
|
3182
|
+
return newState;
|
|
3183
|
+
},
|
|
3184
|
+
// Form control handlers
|
|
3185
|
+
[registerControl]: (state, {
|
|
3186
|
+
name,
|
|
3187
|
+
formId
|
|
3188
|
+
}) => {
|
|
3189
|
+
return updateFormControl(state, formId, name);
|
|
3190
|
+
},
|
|
3191
|
+
[deregisterControl]: (state, {
|
|
3192
|
+
formId,
|
|
3193
|
+
name
|
|
3194
|
+
}) => {
|
|
3195
|
+
const form = state[formId];
|
|
2942
3196
|
|
|
2943
|
-
if (
|
|
2944
|
-
|
|
3197
|
+
if (!form) {
|
|
3198
|
+
return state;
|
|
2945
3199
|
}
|
|
2946
|
-
}
|
|
2947
3200
|
|
|
2948
|
-
|
|
2949
|
-
|
|
3201
|
+
if (form.persistData) {
|
|
3202
|
+
return state;
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
const controls = forms_reducer_objectSpread({}, form.controls);
|
|
3206
|
+
|
|
3207
|
+
delete controls[name];
|
|
3208
|
+
return forms_reducer_objectSpread(forms_reducer_objectSpread({}, state), {}, {
|
|
3209
|
+
[formId]: forms_reducer_objectSpread(forms_reducer_objectSpread({}, form), {}, {
|
|
3210
|
+
controls
|
|
3211
|
+
})
|
|
3212
|
+
});
|
|
3213
|
+
},
|
|
3214
|
+
[updateControlValue]: (state, {
|
|
3215
|
+
formId,
|
|
3216
|
+
name,
|
|
3217
|
+
value
|
|
3218
|
+
}) => {
|
|
3219
|
+
return updateFormControl(state, formId, name, {
|
|
3220
|
+
value
|
|
3221
|
+
});
|
|
3222
|
+
},
|
|
3223
|
+
[updateControlTouched]: (state, {
|
|
3224
|
+
formId,
|
|
3225
|
+
name,
|
|
3226
|
+
touched
|
|
3227
|
+
}) => {
|
|
3228
|
+
return updateFormControl(state, formId, name, {
|
|
3229
|
+
touched
|
|
3230
|
+
});
|
|
2950
3231
|
}
|
|
3232
|
+
}, forms_reducer_initialState));
|
|
3233
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/index.js
|
|
2951
3234
|
|
|
2952
|
-
keywordPossibilities.push("=".concat(intValue), OTHER$1);
|
|
2953
|
-
|
|
2954
|
-
for (var i = 0; i < keywordPossibilities.length; i++) {
|
|
2955
|
-
var keyword = keywordPossibilities[i];
|
|
2956
3235
|
|
|
2957
|
-
if (keyword in cases) {
|
|
2958
|
-
var _replaceNumberSign = replaceNumberSign(cases[keyword], intValue),
|
|
2959
|
-
caseBody = _replaceNumberSign.caseBody,
|
|
2960
|
-
numberValues = _replaceNumberSign.numberValues;
|
|
2961
3236
|
|
|
2962
|
-
return format(caseBody, icu_message_formatter_es_objectSpread(icu_message_formatter_es_objectSpread({}, values), numberValues));
|
|
2963
|
-
}
|
|
2964
|
-
}
|
|
2965
3237
|
|
|
2966
|
-
return value;
|
|
2967
|
-
}
|
|
2968
3238
|
|
|
2969
|
-
/*
|
|
2970
|
-
* Copyright 2019, Emanuel Rabina (http://www.ultraq.net.nz/)
|
|
2971
|
-
*
|
|
2972
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2973
|
-
* you may not use this file except in compliance with the License.
|
|
2974
|
-
* You may obtain a copy of the License at
|
|
2975
|
-
*
|
|
2976
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2977
|
-
*
|
|
2978
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2979
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2980
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2981
|
-
* See the License for the specific language governing permissions and
|
|
2982
|
-
* limitations under the License.
|
|
2983
|
-
*/
|
|
2984
|
-
var OTHER = 'other';
|
|
2985
|
-
/**
|
|
2986
|
-
* Handler for `select` statements within ICU message syntax strings. Returns
|
|
2987
|
-
* a formatted string for the branch that closely matches the current value.
|
|
2988
|
-
*
|
|
2989
|
-
* See https://formatjs.io/docs/core-concepts/icu-syntax#select-format for more
|
|
2990
|
-
* details on how the `select` statement works.
|
|
2991
|
-
*
|
|
2992
|
-
* @param {String} value
|
|
2993
|
-
* @param {String} matches
|
|
2994
|
-
* @param {String} locale
|
|
2995
|
-
* @param {String} values
|
|
2996
|
-
* @param {Function} format
|
|
2997
|
-
* @return {String}
|
|
2998
|
-
*/
|
|
2999
3239
|
|
|
3000
|
-
|
|
3001
|
-
var matches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
3002
|
-
var values = arguments.length > 3 ? arguments[3] : undefined;
|
|
3003
|
-
var format = arguments.length > 4 ? arguments[4] : undefined;
|
|
3240
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/utils.js
|
|
3004
3241
|
|
|
3005
|
-
|
|
3006
|
-
|
|
3242
|
+
const {
|
|
3243
|
+
createActions: translations_utils_createActions,
|
|
3244
|
+
createReducer: translations_utils_createReducer,
|
|
3245
|
+
selectState: translations_utils_selectState
|
|
3246
|
+
} = createDomain('translations');
|
|
3247
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/actions.js
|
|
3007
3248
|
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
}
|
|
3249
|
+
const [enable, disable] = translations_utils_createActions('translate', {
|
|
3250
|
+
enable: locale => ({
|
|
3251
|
+
locale
|
|
3252
|
+
}),
|
|
3253
|
+
disable: () => ({})
|
|
3254
|
+
});
|
|
3255
|
+
const [enableEvent, disableEvent] = translations_utils_createActions('event', {
|
|
3256
|
+
enable: payloadId => ({
|
|
3257
|
+
payloadId
|
|
3258
|
+
}),
|
|
3259
|
+
disable: payloadId => ({
|
|
3260
|
+
payloadId
|
|
3261
|
+
})
|
|
3262
|
+
});
|
|
3263
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/selectors.js
|
|
3013
3264
|
|
|
3014
|
-
return value;
|
|
3015
|
-
}
|
|
3016
3265
|
|
|
3017
3266
|
|
|
3018
|
-
|
|
3267
|
+
const selectors_getState = translations_utils_selectState;
|
|
3268
|
+
const getOriginalPayloadIds = createSelector(selectors_getState, state => state.originalPayloadIds);
|
|
3269
|
+
const getIsPayloadTranslated = createSelector(getOriginalPayloadIds, getPropSelector('payloadId'), (payloadIds, payloadId) => !payloadIds.includes(payloadId));
|
|
3270
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/components/core/seamly-api-context.js
|
|
3019
3271
|
|
|
3020
|
-
|
|
3272
|
+
const seamly_api_context_SeamlyApiContext = (0,external_preact_namespaceObject.createContext)(null);
|
|
3273
|
+
const seamly_api_context_SeamlyEventBusContext = (0,external_preact_namespaceObject.createContext)('');
|
|
3274
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/seamly-api-hooks.js
|
|
3021
3275
|
|
|
3022
3276
|
|
|
3277
|
+
const seamly_api_hooks_useSeamlyApiContext = () => useContext(SeamlyApiContext);
|
|
3278
|
+
const seamly_api_hooks_useSeamlyObjectStore = () => {
|
|
3279
|
+
const api = seamly_api_hooks_useSeamlyApiContext();
|
|
3280
|
+
return api.store || {};
|
|
3281
|
+
};
|
|
3282
|
+
const useSeamlyConversationUrl = () => {
|
|
3283
|
+
const {
|
|
3284
|
+
get
|
|
3285
|
+
} = seamly_api_hooks_useSeamlyObjectStore();
|
|
3023
3286
|
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3287
|
+
if (get) {
|
|
3288
|
+
return get('conversationUrl');
|
|
3289
|
+
}
|
|
3027
3290
|
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
const initialLocale = useSelector(Selectors.selectInitialLocale);
|
|
3036
|
-
const t = useCallback((key, values = {}) => {
|
|
3037
|
-
const translation = translations[key];
|
|
3291
|
+
return null;
|
|
3292
|
+
};
|
|
3293
|
+
const seamly_api_hooks_useSeamlyHasConversation = () => {
|
|
3294
|
+
const url = useSeamlyConversationUrl();
|
|
3295
|
+
return !!url;
|
|
3296
|
+
};
|
|
3297
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-dispatch.js
|
|
3038
3298
|
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
}
|
|
3299
|
+
/* harmony default export */ const use_seamly_dispatch = ((/* unused pure expression or super */ null && (useStoreDispatch)));
|
|
3300
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/focus-helper-hooks.js
|
|
3042
3301
|
|
|
3043
|
-
return formatter.format(translation, values);
|
|
3044
|
-
}, [translations]);
|
|
3045
|
-
return {
|
|
3046
|
-
t,
|
|
3047
|
-
locale,
|
|
3048
|
-
initialLocale
|
|
3049
|
-
};
|
|
3050
|
-
}
|
|
3051
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/i18n/reducer.js
|
|
3052
|
-
function i18n_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3053
3302
|
|
|
3054
|
-
function i18n_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { i18n_reducer_ownKeys(Object(source), true).forEach(function (key) { i18n_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { i18n_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3055
3303
|
|
|
3056
|
-
function i18n_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3057
3304
|
|
|
3058
3305
|
|
|
3306
|
+
const {
|
|
3307
|
+
SET_SEAMLY_CONTAINER_ELEMENT: focus_helper_hooks_SET_SEAMLY_CONTAINER_ELEMENT
|
|
3308
|
+
} = seamly_utils_seamlyActions;
|
|
3059
3309
|
|
|
3060
|
-
const
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
'errors.general.srText': 'Something went wrong with the chat session. You can restart the chat.',
|
|
3068
|
-
'errors.general.title': 'Something went wrong',
|
|
3069
|
-
'errors.seamlyOffline.message': 'There might be a problem with your or our network connection. The chat session should resume as soon the connection is available again.',
|
|
3070
|
-
'errors.seamlyOffline.srText': 'The chat has connection issues. There might be a problem with your or our network connection. The chat session should resume as soon as the connection is available again.',
|
|
3071
|
-
'errors.seamlyOffline.title': 'Connection issues'
|
|
3072
|
-
},
|
|
3073
|
-
isLoading: false,
|
|
3074
|
-
initialLocale: undefined
|
|
3310
|
+
const focusWithRaf = el => {
|
|
3311
|
+
requestAnimationFrame(() => {
|
|
3312
|
+
requestAnimationFrame(() => {
|
|
3313
|
+
const focusEl = typeof el === 'string' ? document.getElementById(el) : el;
|
|
3314
|
+
focusElement(focusEl);
|
|
3315
|
+
});
|
|
3316
|
+
});
|
|
3075
3317
|
};
|
|
3076
|
-
/* harmony default export */ const i18n_reducer = (i18n_utils_createReducer({
|
|
3077
|
-
[setInitialLocale]: (state, {
|
|
3078
|
-
locale
|
|
3079
|
-
}) => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
3080
|
-
initialLocale: locale
|
|
3081
|
-
}),
|
|
3082
|
-
[setLocale.pending]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
3083
|
-
isLoading: true
|
|
3084
|
-
}),
|
|
3085
|
-
[setLocale.fulfilled]: (state, {
|
|
3086
|
-
payload: translations,
|
|
3087
|
-
meta: {
|
|
3088
|
-
arg: locale
|
|
3089
|
-
}
|
|
3090
|
-
}) => {
|
|
3091
|
-
if (!translations) {
|
|
3092
|
-
return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
3093
|
-
isLoading: false
|
|
3094
|
-
});
|
|
3095
|
-
}
|
|
3096
3318
|
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3319
|
+
const useSeamlyContainerElement = () => {
|
|
3320
|
+
const {
|
|
3321
|
+
seamlyContainerElement
|
|
3322
|
+
} = useSeamlyStateContext();
|
|
3323
|
+
const dispatch = useSeamlyDispatchContext();
|
|
3324
|
+
const setSeamlyContainerElement = useCallback(element => {
|
|
3325
|
+
dispatch({
|
|
3326
|
+
type: focus_helper_hooks_SET_SEAMLY_CONTAINER_ELEMENT,
|
|
3327
|
+
element
|
|
3103
3328
|
});
|
|
3104
|
-
},
|
|
3105
|
-
[
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3329
|
+
}, [dispatch]);
|
|
3330
|
+
return [seamlyContainerElement, setSeamlyContainerElement];
|
|
3331
|
+
};
|
|
3332
|
+
const focus_helper_hooks_useElementFocusingById = elementId => useCallback(() => {
|
|
3333
|
+
focusWithRaf(elementId);
|
|
3334
|
+
}, [elementId]);
|
|
3335
|
+
const focus_helper_hooks_useSkiplinkTargetFocusing = () => {
|
|
3336
|
+
const skiplinkTargetId = useSkiplink();
|
|
3337
|
+
return focus_helper_hooks_useElementFocusingById(skiplinkTargetId);
|
|
3338
|
+
};
|
|
3339
|
+
const useFocusIfSeamlyContainedFocus = () => {
|
|
3340
|
+
const containerElementRef = useRef(null);
|
|
3341
|
+
const [seamlyContainerElement] = useSeamlyContainerElement();
|
|
3342
|
+
containerElementRef.current = seamlyContainerElement;
|
|
3343
|
+
return useCallback(elementToFocus => {
|
|
3344
|
+
const focusFn = () => {
|
|
3345
|
+
focusWithRaf(elementToFocus);
|
|
3346
|
+
};
|
|
3347
|
+
|
|
3348
|
+
runIfElementContainsOrHasFocus(containerElementRef.current, focusFn);
|
|
3349
|
+
}, []);
|
|
3350
|
+
};
|
|
3351
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/component-helper-hooks.js
|
|
3110
3352
|
|
|
3111
3353
|
|
|
3112
3354
|
|
|
3355
|
+
const useSeamlyAppContainerClassNames = () => {
|
|
3356
|
+
return useConfig().appContainerClassNames;
|
|
3357
|
+
};
|
|
3358
|
+
const useSeamlyMessageContainerClassNames = event => {
|
|
3359
|
+
const {
|
|
3360
|
+
fromClient
|
|
3361
|
+
} = event.payload;
|
|
3362
|
+
const classNames = ['message'];
|
|
3113
3363
|
|
|
3364
|
+
if (event.type === 'info') {
|
|
3365
|
+
classNames.push('message--source-info');
|
|
3366
|
+
} else if (!fromClient) {
|
|
3367
|
+
classNames.push('message--source-agent');
|
|
3368
|
+
} else {
|
|
3369
|
+
classNames.push('message--source-user');
|
|
3370
|
+
}
|
|
3114
3371
|
|
|
3372
|
+
return classNames;
|
|
3373
|
+
};
|
|
3374
|
+
const useCobrowsingContainer = () => {
|
|
3375
|
+
const {
|
|
3376
|
+
cobrowsingContainerId: id
|
|
3377
|
+
} = useSeamlyStateContext();
|
|
3378
|
+
const focusContainer = useElementFocusingById(id);
|
|
3379
|
+
return {
|
|
3380
|
+
id,
|
|
3381
|
+
focusContainer
|
|
3382
|
+
};
|
|
3383
|
+
};
|
|
3115
3384
|
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/seamly-option-hooks.js
|
|
3116
3385
|
function seamly_option_hooks_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3117
3386
|
|
|
@@ -3408,14 +3677,10 @@ function hooks_useInterrupt() {
|
|
|
3408
3677
|
};
|
|
3409
3678
|
}
|
|
3410
3679
|
;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-general-error.js
|
|
3411
|
-
class SeamlyGeneralError extends Error {
|
|
3412
|
-
constructor(params) {
|
|
3413
|
-
super(params);
|
|
3414
|
-
|
|
3415
|
-
if (Error.captureStackTrace) {
|
|
3416
|
-
Error.captureStackTrace(this, SeamlyGeneralError);
|
|
3417
|
-
}
|
|
3418
3680
|
|
|
3681
|
+
class SeamlyGeneralError extends SeamlyBaseError {
|
|
3682
|
+
constructor(originalError, ...params) {
|
|
3683
|
+
super(originalError, ...params);
|
|
3419
3684
|
this.name = 'SeamlyGeneralError';
|
|
3420
3685
|
this.langKey = 'errors.general';
|
|
3421
3686
|
this.action = 'reset';
|
|
@@ -3423,56 +3688,30 @@ class SeamlyGeneralError extends Error {
|
|
|
3423
3688
|
|
|
3424
3689
|
}
|
|
3425
3690
|
;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-configuration-error.js
|
|
3426
|
-
class SeamlyConfigurationError extends Error {
|
|
3427
|
-
constructor(params) {
|
|
3428
|
-
super(params);
|
|
3429
|
-
|
|
3430
|
-
if (Error.captureStackTrace) {
|
|
3431
|
-
Error.captureStackTrace(this, SeamlyConfigurationError);
|
|
3432
|
-
}
|
|
3433
3691
|
|
|
3692
|
+
class SeamlyConfigurationError extends SeamlyBaseError {
|
|
3693
|
+
constructor(originalError, ...params) {
|
|
3694
|
+
super(originalError, ...params);
|
|
3434
3695
|
this.name = 'SeamlyConfigurationError';
|
|
3435
3696
|
this.langKey = 'errors.configError';
|
|
3436
3697
|
}
|
|
3437
3698
|
|
|
3438
|
-
}
|
|
3439
|
-
;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-session-expired-error.js
|
|
3440
|
-
class SeamlySessionExpiredError extends Error {
|
|
3441
|
-
constructor(params) {
|
|
3442
|
-
super(params);
|
|
3443
|
-
|
|
3444
|
-
if (Error.captureStackTrace) {
|
|
3445
|
-
Error.captureStackTrace(this, SeamlySessionExpiredError);
|
|
3446
|
-
}
|
|
3447
|
-
|
|
3448
|
-
this.name = 'SeamlySessionExpiredError';
|
|
3449
|
-
this.action = 'reset';
|
|
3450
|
-
}
|
|
3451
|
-
|
|
3452
3699
|
}
|
|
3453
3700
|
;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-offline-error.js
|
|
3454
|
-
class SeamlyOfflineError extends Error {
|
|
3455
|
-
constructor(params) {
|
|
3456
|
-
super(params);
|
|
3457
|
-
|
|
3458
|
-
if (Error.captureStackTrace) {
|
|
3459
|
-
Error.captureStackTrace(this, SeamlyOfflineError);
|
|
3460
|
-
}
|
|
3461
3701
|
|
|
3702
|
+
class SeamlyOfflineError extends SeamlyBaseError {
|
|
3703
|
+
constructor(originalError, ...params) {
|
|
3704
|
+
super(originalError, ...params);
|
|
3462
3705
|
this.name = 'SeamlyOfflineError';
|
|
3463
3706
|
this.langKey = 'errors.seamlyOffline';
|
|
3464
3707
|
}
|
|
3465
3708
|
|
|
3466
3709
|
}
|
|
3467
3710
|
;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-unauthorized-error.js
|
|
3468
|
-
class SeamlyUnauthorizedError extends Error {
|
|
3469
|
-
constructor(params) {
|
|
3470
|
-
super(params);
|
|
3471
|
-
|
|
3472
|
-
if (Error.captureStackTrace) {
|
|
3473
|
-
Error.captureStackTrace(this, SeamlyUnauthorizedError);
|
|
3474
|
-
}
|
|
3475
3711
|
|
|
3712
|
+
class SeamlyUnauthorizedError extends SeamlyBaseError {
|
|
3713
|
+
constructor(originalError, ...params) {
|
|
3714
|
+
super(originalError, ...params);
|
|
3476
3715
|
this.name = 'SeamlyUnauthorizedError';
|
|
3477
3716
|
this.langKey = 'errors.general';
|
|
3478
3717
|
this.action = 'reset';
|
|
@@ -3485,7 +3724,8 @@ class SeamlyUnauthorizedError extends Error {
|
|
|
3485
3724
|
|
|
3486
3725
|
|
|
3487
3726
|
|
|
3488
|
-
|
|
3727
|
+
|
|
3728
|
+
const handledErrorTypes = [SeamlyGeneralError, SeamlyConfigurationError, SeamlySessionExpiredError, SeamlyOfflineError, SeamlyUnauthorizedError, SeamlyUnavailableError];
|
|
3489
3729
|
function middleware_createMiddleware({
|
|
3490
3730
|
api
|
|
3491
3731
|
}) {
|
|
@@ -3517,20 +3757,22 @@ function interrupt_reducer_defineProperty(obj, key, value) { if (key in obj) { O
|
|
|
3517
3757
|
|
|
3518
3758
|
|
|
3519
3759
|
|
|
3760
|
+
|
|
3520
3761
|
const interrupt_reducer_initialState = {
|
|
3521
3762
|
error: undefined
|
|
3522
3763
|
};
|
|
3764
|
+
|
|
3765
|
+
const handleError = (state, {
|
|
3766
|
+
error
|
|
3767
|
+
}) => interrupt_reducer_objectSpread(interrupt_reducer_objectSpread({}, state), {}, {
|
|
3768
|
+
error
|
|
3769
|
+
});
|
|
3770
|
+
|
|
3523
3771
|
/* harmony default export */ const interrupt_reducer = (interrupt_utils_createReducer({
|
|
3524
|
-
[set]:
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
error
|
|
3529
|
-
});
|
|
3530
|
-
},
|
|
3531
|
-
[clear]: () => {
|
|
3532
|
-
return interrupt_reducer_initialState;
|
|
3533
|
-
}
|
|
3772
|
+
[set]: handleError,
|
|
3773
|
+
[app_actions_initialize.rejected]: handleError,
|
|
3774
|
+
[clear]: () => interrupt_reducer_initialState,
|
|
3775
|
+
[actions_reset]: () => interrupt_reducer_initialState
|
|
3534
3776
|
}, interrupt_reducer_initialState));
|
|
3535
3777
|
;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/index.js
|
|
3536
3778
|
|
|
@@ -3539,99 +3781,58 @@ const interrupt_reducer_initialState = {
|
|
|
3539
3781
|
|
|
3540
3782
|
|
|
3541
3783
|
|
|
3542
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/
|
|
3543
|
-
|
|
3544
|
-
const {
|
|
3545
|
-
createAction: app_utils_createAction,
|
|
3546
|
-
createThunk: app_utils_createThunk,
|
|
3547
|
-
createReducer: app_utils_createReducer,
|
|
3548
|
-
selectState: app_utils_selectState
|
|
3549
|
-
} = createDomain('app');
|
|
3550
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/app/actions.js
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
const setHasResponded = app_utils_createAction('setHasResponded', hasResponded => ({
|
|
3557
|
-
hasResponded
|
|
3558
|
-
}));
|
|
3559
|
-
const actions_initialize = app_utils_createThunk('initialize', async (config, {
|
|
3560
|
-
dispatch,
|
|
3561
|
-
extra: {
|
|
3562
|
-
api
|
|
3563
|
-
}
|
|
3564
|
-
}) => {
|
|
3565
|
-
try {
|
|
3566
|
-
var _config$context;
|
|
3784
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/hooks.js
|
|
3567
3785
|
|
|
3568
|
-
dispatch(initialize(config));
|
|
3569
|
-
const {
|
|
3570
|
-
features,
|
|
3571
|
-
defaultLocale
|
|
3572
|
-
} = await api.getConfig();
|
|
3573
|
-
dispatch({
|
|
3574
|
-
type: seamly_utils_seamlyActions.SET_FEATURES,
|
|
3575
|
-
features
|
|
3576
|
-
});
|
|
3577
|
-
let locale = (config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale) || defaultLocale;
|
|
3578
|
-
dispatch(setInitialLocale(locale));
|
|
3579
3786
|
|
|
3580
|
-
try {
|
|
3581
|
-
if (api.hasConversation()) {
|
|
3582
|
-
var _initialState$transla;
|
|
3583
3787
|
|
|
3584
|
-
const initialState = await api.getConversationIntitialState();
|
|
3585
|
-
dispatch({
|
|
3586
|
-
type: seamly_utils_seamlyActions.SET_INITIAL_STATE,
|
|
3587
|
-
initialState
|
|
3588
|
-
});
|
|
3589
|
-
locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
|
|
3590
3788
|
|
|
3591
|
-
if ('userResponded' in initialState) {
|
|
3592
|
-
dispatch(setHasResponded(initialState.userResponded));
|
|
3593
|
-
}
|
|
3594
|
-
}
|
|
3595
|
-
} catch (error) {
|
|
3596
|
-
dispatch(set(error));
|
|
3597
|
-
}
|
|
3598
3789
|
|
|
3599
|
-
await dispatch(setLocale(locale));
|
|
3600
|
-
} catch (error) {
|
|
3601
|
-
dispatch(set(error));
|
|
3602
|
-
}
|
|
3603
|
-
});
|
|
3604
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/app/selectors.js
|
|
3605
3790
|
|
|
3791
|
+
const hooks_useVisibility = () => {
|
|
3792
|
+
const dispatch = useStoreDispatch();
|
|
3793
|
+
const visible = useSelector(Selectors.selectVisibility);
|
|
3794
|
+
const isVisible = visible ? visible !== visibilityStates.hidden : false;
|
|
3795
|
+
const {
|
|
3796
|
+
layoutMode
|
|
3797
|
+
} = useConfig();
|
|
3798
|
+
const isOpen = visible && layoutMode ? visible === visibilityStates.open || layoutMode === 'inline' && visible !== visibilityStates.hidden : false;
|
|
3799
|
+
const setVisibility = useCallback(visibility => dispatch(Actions.setVisibility(visibility)), [dispatch]);
|
|
3800
|
+
return {
|
|
3801
|
+
isVisible,
|
|
3802
|
+
isOpen,
|
|
3803
|
+
visible,
|
|
3804
|
+
setVisibility
|
|
3805
|
+
};
|
|
3806
|
+
};
|
|
3807
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/reducer.js
|
|
3808
|
+
function visibility_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3606
3809
|
|
|
3607
|
-
|
|
3810
|
+
function visibility_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { visibility_reducer_ownKeys(Object(source), true).forEach(function (key) { visibility_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { visibility_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3608
3811
|
|
|
3609
|
-
|
|
3812
|
+
function visibility_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3610
3813
|
|
|
3611
3814
|
|
|
3612
|
-
function hooks_useUserHasResponded() {
|
|
3613
|
-
return useSelector(Selectors.selectUserHasResponded);
|
|
3614
|
-
}
|
|
3615
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/app/reducer.js
|
|
3616
|
-
function app_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3617
3815
|
|
|
3618
|
-
function app_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { app_reducer_ownKeys(Object(source), true).forEach(function (key) { app_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { app_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3619
3816
|
|
|
3620
|
-
|
|
3817
|
+
const visibility_reducer_initialState = {
|
|
3818
|
+
visibility: constants_visibilityStates.initialize
|
|
3819
|
+
};
|
|
3820
|
+
/* harmony default export */ const visibility_reducer = (visibility_utils_createReducer({
|
|
3821
|
+
[setFromStorage]: (state, {
|
|
3822
|
+
visibility
|
|
3823
|
+
}) => visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
|
|
3824
|
+
visibility
|
|
3825
|
+
}),
|
|
3826
|
+
[setVisibility.fulfilled]: (state, {
|
|
3827
|
+
payload: visibility
|
|
3828
|
+
}) => visibility ? visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
|
|
3829
|
+
visibility
|
|
3830
|
+
}) : state
|
|
3831
|
+
}, visibility_reducer_initialState));
|
|
3832
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/index.js
|
|
3621
3833
|
|
|
3622
3834
|
|
|
3623
3835
|
|
|
3624
|
-
const app_reducer_initialState = {
|
|
3625
|
-
userHasResponded: false
|
|
3626
|
-
};
|
|
3627
|
-
/* harmony default export */ const app_reducer = (app_utils_createReducer({
|
|
3628
|
-
[setHasResponded]: (state, {
|
|
3629
|
-
hasResponded
|
|
3630
|
-
}) => app_reducer_objectSpread(app_reducer_objectSpread({}, state), {}, {
|
|
3631
|
-
userHasResponded: hasResponded
|
|
3632
|
-
})
|
|
3633
|
-
}, app_reducer_initialState));
|
|
3634
|
-
;// CONCATENATED MODULE: ./src/javascripts/domains/app/index.js
|
|
3635
3836
|
|
|
3636
3837
|
|
|
3637
3838
|
|
|
@@ -3658,15 +3859,10 @@ function use_seamly_commands_defineProperty(obj, key, value) { if (key in obj) {
|
|
|
3658
3859
|
|
|
3659
3860
|
const {
|
|
3660
3861
|
ADD_EVENT: use_seamly_commands_ADD_EVENT,
|
|
3661
|
-
CLEAR_EVENTS: use_seamly_commands_CLEAR_EVENTS,
|
|
3662
3862
|
SET_IS_LOADING: use_seamly_commands_SET_IS_LOADING,
|
|
3663
|
-
CLEAR_PARTICIPANTS: use_seamly_commands_CLEAR_PARTICIPANTS,
|
|
3664
3863
|
SET_HEADER_SUB_TITLE: use_seamly_commands_SET_HEADER_SUB_TITLE,
|
|
3665
3864
|
SET_INITIAL_STATE: use_seamly_commands_SET_INITIAL_STATE,
|
|
3666
|
-
|
|
3667
|
-
SET_FEATURES: use_seamly_commands_SET_FEATURES,
|
|
3668
|
-
RESET_UPLOAD_STATE: use_seamly_commands_RESET_UPLOAD_STATE,
|
|
3669
|
-
RESET_ENTRY_STATE: use_seamly_commands_RESET_ENTRY_STATE
|
|
3865
|
+
SET_FEATURES: use_seamly_commands_SET_FEATURES
|
|
3670
3866
|
} = seamly_utils_seamlyActions;
|
|
3671
3867
|
|
|
3672
3868
|
const use_seamly_commands_useSeamlyCommands = () => {
|
|
@@ -3678,7 +3874,7 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
3678
3874
|
const hasConversation = useSeamlyHasConversation();
|
|
3679
3875
|
const {
|
|
3680
3876
|
visible: visibility
|
|
3681
|
-
} =
|
|
3877
|
+
} = useVisibility();
|
|
3682
3878
|
const unreadMessageCount = useSeamlyUnreadCount();
|
|
3683
3879
|
const emitEvent = useCallback((...args) => {
|
|
3684
3880
|
eventBus.emit(...args);
|
|
@@ -3700,26 +3896,12 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
3700
3896
|
});
|
|
3701
3897
|
}, [api, appConfig, emitEvent, hasResponded, hasConversation, visibility, unreadMessageCount]);
|
|
3702
3898
|
const reset = useCallback(async () => {
|
|
3899
|
+
dispatch(AppActions.reset());
|
|
3703
3900
|
dispatch(InterruptActions.clear());
|
|
3704
|
-
dispatch({
|
|
3705
|
-
type: use_seamly_commands_CLEAR_EVENTS
|
|
3706
|
-
});
|
|
3707
3901
|
dispatch({
|
|
3708
3902
|
type: use_seamly_commands_SET_IS_LOADING,
|
|
3709
3903
|
isLoading: true
|
|
3710
3904
|
});
|
|
3711
|
-
dispatch({
|
|
3712
|
-
type: use_seamly_commands_CLEAR_PARTICIPANTS
|
|
3713
|
-
});
|
|
3714
|
-
dispatch({
|
|
3715
|
-
type: use_seamly_commands_RESET_UPLOAD_STATE
|
|
3716
|
-
});
|
|
3717
|
-
dispatch({
|
|
3718
|
-
type: use_seamly_commands_RESET_ENTRY_STATE
|
|
3719
|
-
});
|
|
3720
|
-
dispatch({
|
|
3721
|
-
type: use_seamly_commands_CLEAR_FEATURES
|
|
3722
|
-
});
|
|
3723
3905
|
const {
|
|
3724
3906
|
agentName
|
|
3725
3907
|
} = appConfig.defaults || {};
|
|
@@ -3771,21 +3953,13 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
3771
3953
|
|
|
3772
3954
|
const message = use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, getTextMessageBase(body)), config);
|
|
3773
3955
|
|
|
3774
|
-
const sanitizedText = sanitizeText(body);
|
|
3775
|
-
|
|
3776
|
-
const sanitizedMessage = use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, message), {}, {
|
|
3777
|
-
body: {
|
|
3778
|
-
text: sanitizedText
|
|
3779
|
-
}
|
|
3780
|
-
});
|
|
3781
|
-
|
|
3782
3956
|
api.send('message', message);
|
|
3783
3957
|
emitEvent('message', message);
|
|
3784
3958
|
dispatch({
|
|
3785
3959
|
type: use_seamly_commands_ADD_EVENT,
|
|
3786
3960
|
event: {
|
|
3787
3961
|
type: 'message',
|
|
3788
|
-
payload:
|
|
3962
|
+
payload: message
|
|
3789
3963
|
}
|
|
3790
3964
|
});
|
|
3791
3965
|
}, [api, dispatch, emitEvent, getTextMessageBase]);
|
|
@@ -4068,121 +4242,6 @@ const useSeamlyEntry = () => {
|
|
|
4068
4242
|
setBlockAutoEntrySwitch
|
|
4069
4243
|
};
|
|
4070
4244
|
};
|
|
4071
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-stored-visibility.js
|
|
4072
|
-
function use_seamly_stored_visibility_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4073
|
-
|
|
4074
|
-
function use_seamly_stored_visibility_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { use_seamly_stored_visibility_ownKeys(Object(source), true).forEach(function (key) { use_seamly_stored_visibility_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { use_seamly_stored_visibility_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4075
|
-
|
|
4076
|
-
function use_seamly_stored_visibility_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
const use_seamly_stored_visibility_useSeamlyStoredVisibility = () => {
|
|
4083
|
-
const {
|
|
4084
|
-
layoutMode
|
|
4085
|
-
} = useConfig();
|
|
4086
|
-
const key = 'visibility';
|
|
4087
|
-
const {
|
|
4088
|
-
get,
|
|
4089
|
-
set
|
|
4090
|
-
} = useSeamlyObjectStore();
|
|
4091
|
-
let storedVisibilityObj = {};
|
|
4092
|
-
const savedVisibility = get ? get(key) : {};
|
|
4093
|
-
|
|
4094
|
-
if (savedVisibility) {
|
|
4095
|
-
storedVisibilityObj = savedVisibility;
|
|
4096
|
-
}
|
|
4097
|
-
|
|
4098
|
-
const setStoredVisibility = useCallback(state => {
|
|
4099
|
-
const saved = get ? get(key) : {};
|
|
4100
|
-
set(key, use_seamly_stored_visibility_objectSpread(use_seamly_stored_visibility_objectSpread({}, saved), {}, {
|
|
4101
|
-
[layoutMode]: state
|
|
4102
|
-
}));
|
|
4103
|
-
}, [set, get, layoutMode]);
|
|
4104
|
-
return [layoutMode ? storedVisibilityObj[layoutMode] : null, set && layoutMode ? setStoredVisibility : null];
|
|
4105
|
-
};
|
|
4106
|
-
|
|
4107
|
-
/* harmony default export */ const use_seamly_stored_visibility = ((/* unused pure expression or super */ null && (use_seamly_stored_visibility_useSeamlyStoredVisibility)));
|
|
4108
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-visibility.js
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
const {
|
|
4119
|
-
SET_VISIBILITY: use_seamly_visibility_SET_VISIBILITY
|
|
4120
|
-
} = seamly_utils_seamlyActions;
|
|
4121
|
-
|
|
4122
|
-
const use_seamly_visibility_useSeamlyVisibility = () => {
|
|
4123
|
-
const config = useConfig();
|
|
4124
|
-
const {
|
|
4125
|
-
layoutMode,
|
|
4126
|
-
visibilityCallback
|
|
4127
|
-
} = config;
|
|
4128
|
-
const {
|
|
4129
|
-
visible
|
|
4130
|
-
} = useSeamlyStateContext();
|
|
4131
|
-
const {
|
|
4132
|
-
emitEvent
|
|
4133
|
-
} = useSeamlyCommands();
|
|
4134
|
-
const dispatch = useSeamlyDispatchContext();
|
|
4135
|
-
const [storedVisibility, setStoredVisibility] = useSeamlyStoredVisibility();
|
|
4136
|
-
const hasResponded = useUserHasResponded();
|
|
4137
|
-
const hasConversation = useSeamlyHasConversation();
|
|
4138
|
-
const unreadMessageCount = useSeamlyUnreadCount();
|
|
4139
|
-
const isVisible = visible ? visible !== visibilityStates.hidden : false;
|
|
4140
|
-
const isOpen = visible && layoutMode ? visible === visibilityStates.open || layoutMode === 'inline' && visible !== visibilityStates.hidden : false;
|
|
4141
|
-
const setVisibility = useCallback(visibility => {
|
|
4142
|
-
const visibilityFn = visibilityCallback || calculateVisibility;
|
|
4143
|
-
const requestedVisibility = visibilityFn({
|
|
4144
|
-
hasConversation,
|
|
4145
|
-
hasResponded,
|
|
4146
|
-
previousVisibility: storedVisibility || null,
|
|
4147
|
-
requestedVisibility: visibility,
|
|
4148
|
-
config
|
|
4149
|
-
});
|
|
4150
|
-
|
|
4151
|
-
if (![visibilityStates.open, visibilityStates.minimized, visibilityStates.hidden].includes(requestedVisibility)) {
|
|
4152
|
-
console.error('The visibilityCallback function should return "open", "minimized" or "hidden".');
|
|
4153
|
-
return;
|
|
4154
|
-
}
|
|
4155
|
-
|
|
4156
|
-
if (requestedVisibility !== visible) {
|
|
4157
|
-
if (setStoredVisibility) {
|
|
4158
|
-
setStoredVisibility(requestedVisibility);
|
|
4159
|
-
} // Don't broadcast the init visibility state
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
if (visibility) {
|
|
4163
|
-
emitEvent('ui.visible', requestedVisibility, {
|
|
4164
|
-
visibility: requestedVisibility,
|
|
4165
|
-
hasConversation,
|
|
4166
|
-
hasResponded,
|
|
4167
|
-
unreadMessageCount
|
|
4168
|
-
});
|
|
4169
|
-
}
|
|
4170
|
-
|
|
4171
|
-
dispatch({
|
|
4172
|
-
type: use_seamly_visibility_SET_VISIBILITY,
|
|
4173
|
-
visible: requestedVisibility
|
|
4174
|
-
});
|
|
4175
|
-
}
|
|
4176
|
-
}, [visible, emitEvent, dispatch, hasConversation, hasResponded, storedVisibility, visibilityCallback, config, setStoredVisibility, unreadMessageCount]);
|
|
4177
|
-
return {
|
|
4178
|
-
isVisible,
|
|
4179
|
-
isOpen,
|
|
4180
|
-
visible,
|
|
4181
|
-
setVisibility
|
|
4182
|
-
};
|
|
4183
|
-
};
|
|
4184
|
-
|
|
4185
|
-
/* harmony default export */ const use_seamly_visibility = ((/* unused pure expression or super */ null && (use_seamly_visibility_useSeamlyVisibility)));
|
|
4186
4245
|
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.js
|
|
4187
4246
|
|
|
4188
4247
|
|
|
@@ -4204,9 +4263,8 @@ const useSeamlyChat = () => {
|
|
|
4204
4263
|
const {
|
|
4205
4264
|
isOpen,
|
|
4206
4265
|
isVisible,
|
|
4207
|
-
visible,
|
|
4208
4266
|
setVisibility
|
|
4209
|
-
} =
|
|
4267
|
+
} = useVisibility();
|
|
4210
4268
|
const dispatch = useSeamlyDispatchContext();
|
|
4211
4269
|
const events = useEvents();
|
|
4212
4270
|
const spinnerTimeout = useRef(null);
|
|
@@ -4250,7 +4308,6 @@ const useSeamlyChat = () => {
|
|
|
4250
4308
|
prevIsOpen.current = isOpen;
|
|
4251
4309
|
prevIsVisible.current = isVisible;
|
|
4252
4310
|
}, [isOpen, isVisible, sendAssertive, t]);
|
|
4253
|
-
useEffect(() => {}, [visible, sendAssertive]);
|
|
4254
4311
|
useEffect(() => {
|
|
4255
4312
|
// This delays the start of the loading inidicator we set when we initialise
|
|
4256
4313
|
// the application. This is done to only avoid BSOD on initial load if DCX is slow.
|
|
@@ -4348,7 +4405,7 @@ const useSeamlyIdleDetachCountdown = () => {
|
|
|
4348
4405
|
} = useSeamlyStateContext();
|
|
4349
4406
|
const {
|
|
4350
4407
|
isOpen: isSeamlyOpen
|
|
4351
|
-
} =
|
|
4408
|
+
} = useVisibility();
|
|
4352
4409
|
const stableState = useRef({});
|
|
4353
4410
|
stableState.current = {
|
|
4354
4411
|
hasCountdown: idleDetachCountdown.hasCountdown,
|
|
@@ -4547,8 +4604,6 @@ const useSeamlyResumeConversationPrompt = () => {
|
|
|
4547
4604
|
|
|
4548
4605
|
|
|
4549
4606
|
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
4607
|
// This hook isn't used within the core
|
|
4553
4608
|
// But it is used in implementations
|
|
4554
4609
|
// and imported directly from this file
|
|
@@ -5717,7 +5772,7 @@ function TranslationsChatStatus() {
|
|
|
5717
5772
|
|
|
5718
5773
|
|
|
5719
5774
|
;// CONCATENATED MODULE: ./src/javascripts/style-guide/components/static-core.js
|
|
5720
|
-
const static_core_excluded = ["translations", "interrupt", "config"];
|
|
5775
|
+
const static_core_excluded = ["translations", "interrupt", "config", "visibility"];
|
|
5721
5776
|
|
|
5722
5777
|
function static_core_objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = static_core_objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5723
5778
|
|
|
@@ -5733,6 +5788,8 @@ function static_core_objectWithoutPropertiesLoose(source, excluded) { if (source
|
|
|
5733
5788
|
|
|
5734
5789
|
|
|
5735
5790
|
|
|
5791
|
+
|
|
5792
|
+
|
|
5736
5793
|
const bareApi = {
|
|
5737
5794
|
send: () => {},
|
|
5738
5795
|
reset: () => {
|
|
@@ -5741,7 +5798,8 @@ const bareApi = {
|
|
|
5741
5798
|
store: {
|
|
5742
5799
|
get: () => {},
|
|
5743
5800
|
set: () => {}
|
|
5744
|
-
}
|
|
5801
|
+
},
|
|
5802
|
+
hasConversation: () => false
|
|
5745
5803
|
};
|
|
5746
5804
|
|
|
5747
5805
|
const SeamlyTestCore = ({
|
|
@@ -5758,7 +5816,8 @@ const SeamlyTestCore = ({
|
|
|
5758
5816
|
{
|
|
5759
5817
|
translations: translationsSlice,
|
|
5760
5818
|
interrupt: interruptSlice,
|
|
5761
|
-
config: configSlice
|
|
5819
|
+
config: configSlice,
|
|
5820
|
+
visibility: visibilitySlice
|
|
5762
5821
|
} = _ref,
|
|
5763
5822
|
restState = static_core_objectWithoutProperties(_ref, static_core_excluded);
|
|
5764
5823
|
|
|
@@ -5766,17 +5825,23 @@ const SeamlyTestCore = ({
|
|
|
5766
5825
|
reducers: {
|
|
5767
5826
|
state: stateReducer,
|
|
5768
5827
|
[String(app_reducer)]: app_reducer,
|
|
5769
|
-
[String(config_reducer)]: config_reducer,
|
|
5770
5828
|
[String(reducer)]: reducer,
|
|
5829
|
+
[String(forms_reducer)]: forms_reducer,
|
|
5771
5830
|
[String(translations_reducer)]: translations_reducer,
|
|
5772
5831
|
[String(i18n_reducer)]: i18n_reducer,
|
|
5773
|
-
[String(interrupt_reducer)]: interrupt_reducer
|
|
5832
|
+
[String(interrupt_reducer)]: interrupt_reducer,
|
|
5833
|
+
[String(visibility_reducer)]: visibility_reducer
|
|
5774
5834
|
},
|
|
5775
5835
|
initialState: {
|
|
5776
5836
|
state: restState,
|
|
5777
5837
|
[String(translations_reducer)]: translationsSlice,
|
|
5778
|
-
[String(interrupt_reducer)]: interruptSlice
|
|
5779
|
-
|
|
5838
|
+
[String(interrupt_reducer)]: interruptSlice,
|
|
5839
|
+
[String(visibility_reducer)]: visibilitySlice
|
|
5840
|
+
},
|
|
5841
|
+
middlewares: [es.withExtraArgument({
|
|
5842
|
+
api: bareApi,
|
|
5843
|
+
eventBus: eventBusRef.current
|
|
5844
|
+
})]
|
|
5780
5845
|
});
|
|
5781
5846
|
newStore.dispatch(initialize(configSlice || {}));
|
|
5782
5847
|
newStore.dispatch(setLocale.fulfilled('en-GB', translations));
|
|
@@ -5931,7 +5996,9 @@ const baseState = {
|
|
|
5931
5996
|
isActive: false
|
|
5932
5997
|
},
|
|
5933
5998
|
resumeConversationPrompt: false,
|
|
5934
|
-
|
|
5999
|
+
visibility: {
|
|
6000
|
+
visibility: web_ui_namespaceObject.visibilityStates.open
|
|
6001
|
+
},
|
|
5935
6002
|
serviceInfo: {
|
|
5936
6003
|
activeServiceSessionId: ''
|
|
5937
6004
|
},
|
|
@@ -6855,8 +6922,27 @@ const standardState = {
|
|
|
6855
6922
|
headingText: 'System messages',
|
|
6856
6923
|
description: ''
|
|
6857
6924
|
}, baseState), {}, {
|
|
6925
|
+
config: {
|
|
6926
|
+
overrideMessages: {
|
|
6927
|
+
timeIndicator: {
|
|
6928
|
+
enabled: true,
|
|
6929
|
+
threshold: 3600000
|
|
6930
|
+
}
|
|
6931
|
+
}
|
|
6932
|
+
},
|
|
6858
6933
|
participantInfo,
|
|
6859
|
-
events: [
|
|
6934
|
+
events: [{
|
|
6935
|
+
type: 'message',
|
|
6936
|
+
payload: states_objectSpread(states_objectSpread({}, shortTextMessage.payload), {}, {
|
|
6937
|
+
occurredAt: (Date.now() - 86400000 * 5) * 1000,
|
|
6938
|
+
id: (0,web_ui_namespaceObject.randomId)(),
|
|
6939
|
+
body: {
|
|
6940
|
+
text: 'Long ago when a dialog started',
|
|
6941
|
+
type: 'text',
|
|
6942
|
+
variables: {}
|
|
6943
|
+
}
|
|
6944
|
+
})
|
|
6945
|
+
}, participantMessage, participantMessageDefaultIcon, newTopicDivider, transcriptInfoMessage, ...[newTranslationDividerStart, newTranslationDividerStop].map(addTranslationData), infoMessage]
|
|
6860
6946
|
}),
|
|
6861
6947
|
choicePromptMessages: states_objectSpread(states_objectSpread({
|
|
6862
6948
|
category: categoryKeys.messages,
|
|
@@ -7009,34 +7095,24 @@ const standardState = {
|
|
|
7009
7095
|
}
|
|
7010
7096
|
}]
|
|
7011
7097
|
}),
|
|
7012
|
-
|
|
7013
|
-
// Important: This cannot pick up the language files so the text is hard set here.
|
|
7014
|
-
category: categoryKeys.errors,
|
|
7015
|
-
headingText: 'Disconnected interrupt',
|
|
7016
|
-
description: ''
|
|
7017
|
-
}, baseState), {}, {
|
|
7018
|
-
interrupt: {
|
|
7019
|
-
error: new web_ui_namespaceObject.SeamlyOfflineError()
|
|
7020
|
-
}
|
|
7021
|
-
}),
|
|
7022
|
-
generalErrorInterrupt: states_objectSpread(states_objectSpread({
|
|
7098
|
+
errorWithAction: states_objectSpread(states_objectSpread({
|
|
7023
7099
|
// Important: This cannot pick up the language files so the text is hard set here.
|
|
7024
7100
|
category: categoryKeys.errors,
|
|
7025
|
-
headingText: '
|
|
7101
|
+
headingText: 'Error with a user action',
|
|
7026
7102
|
description: ''
|
|
7027
7103
|
}, baseState), {}, {
|
|
7028
7104
|
interrupt: {
|
|
7029
7105
|
error: new web_ui_namespaceObject.SeamlyGeneralError()
|
|
7030
7106
|
}
|
|
7031
7107
|
}),
|
|
7032
|
-
|
|
7108
|
+
errorWithoutAction: states_objectSpread(states_objectSpread({
|
|
7033
7109
|
// Important: This cannot pick up the language files so the text is hard set here.
|
|
7034
7110
|
category: categoryKeys.errors,
|
|
7035
|
-
headingText: '
|
|
7111
|
+
headingText: 'Error without a user action',
|
|
7036
7112
|
description: ''
|
|
7037
7113
|
}, baseState), {}, {
|
|
7038
7114
|
interrupt: {
|
|
7039
|
-
error: new web_ui_namespaceObject.
|
|
7115
|
+
error: new web_ui_namespaceObject.SeamlyOfflineError()
|
|
7040
7116
|
}
|
|
7041
7117
|
}),
|
|
7042
7118
|
privacyDisclaimer: states_objectSpread(states_objectSpread({
|
|
@@ -7584,11 +7660,11 @@ const standardState = {
|
|
|
7584
7660
|
serviceInfo: {
|
|
7585
7661
|
activeServiceSessionId: '3942159e-9878-469e-9120-f44fd6be0f35'
|
|
7586
7662
|
},
|
|
7587
|
-
events: [infoMessage, shortTextMessage, states_objectSpread(states_objectSpread({}, choicePromptMessage), {}, {
|
|
7663
|
+
events: [newTranslationDividerStart, infoMessage, shortTextMessage, states_objectSpread(states_objectSpread({}, choicePromptMessage), {}, {
|
|
7588
7664
|
payload: states_objectSpread(states_objectSpread({}, choicePromptMessage.payload), {}, {
|
|
7589
7665
|
id: `${choicePromptMessage.payload.id}XXX`
|
|
7590
7666
|
})
|
|
7591
|
-
}), longTextMessage, userMessage, textMessageBoldItalicUnderline, newTopicDivider, newTranslationDividerStart, newTranslationDividerStop, imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage].map(addTranslationData),
|
|
7667
|
+
}), longTextMessage, userMessage, textMessageBoldItalicUnderline, newTopicDivider, newTranslationDividerStart, newTranslationDividerStop, imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage, newTranslationDividerStop, newTranslationDividerStart].map(addTranslationData),
|
|
7592
7668
|
translations: states_objectSpread(states_objectSpread({}, translationsSlice), {}, {
|
|
7593
7669
|
currentLocale: 'nl',
|
|
7594
7670
|
isActive: true,
|
|
@@ -7658,7 +7734,9 @@ const getStateObj = (layoutModes, customComponentEventBodies) => states_objectSp
|
|
|
7658
7734
|
config: states_objectSpread(states_objectSpread({}, baseState.config), {}, {
|
|
7659
7735
|
layoutMode: 'window'
|
|
7660
7736
|
}),
|
|
7661
|
-
|
|
7737
|
+
visibility: states_objectSpread(states_objectSpread({}, baseState.visibility), {}, {
|
|
7738
|
+
visibility: web_ui_namespaceObject.visibilityStates.minimized
|
|
7739
|
+
})
|
|
7662
7740
|
})
|
|
7663
7741
|
},
|
|
7664
7742
|
minimizedStarted: {
|
|
@@ -7669,7 +7747,9 @@ const getStateObj = (layoutModes, customComponentEventBodies) => states_objectSp
|
|
|
7669
7747
|
config: states_objectSpread(states_objectSpread({}, baseState.config), {}, {
|
|
7670
7748
|
layoutMode: 'window'
|
|
7671
7749
|
}),
|
|
7672
|
-
|
|
7750
|
+
visibility: states_objectSpread(states_objectSpread({}, baseState.visibility), {}, {
|
|
7751
|
+
visibility: web_ui_namespaceObject.visibilityStates.minimized
|
|
7752
|
+
}),
|
|
7673
7753
|
participantInfo,
|
|
7674
7754
|
headerTitles
|
|
7675
7755
|
})
|
|
@@ -7682,7 +7762,9 @@ const getStateObj = (layoutModes, customComponentEventBodies) => states_objectSp
|
|
|
7682
7762
|
config: states_objectSpread(states_objectSpread({}, baseState.config), {}, {
|
|
7683
7763
|
layoutMode: 'window'
|
|
7684
7764
|
}),
|
|
7685
|
-
|
|
7765
|
+
visibility: states_objectSpread(states_objectSpread({}, baseState.visibility), {}, {
|
|
7766
|
+
visibility: web_ui_namespaceObject.visibilityStates.minimized
|
|
7767
|
+
}),
|
|
7686
7768
|
participantInfo,
|
|
7687
7769
|
headerTitles,
|
|
7688
7770
|
unreadEvents: 12
|
|
@@ -7889,7 +7971,9 @@ const StyleGuideApp = ({
|
|
|
7889
7971
|
if (overlay) {
|
|
7890
7972
|
overlay.addEventListener('click', () => {
|
|
7891
7973
|
setStaticState(s => app_objectSpread(app_objectSpread({}, s), {}, {
|
|
7892
|
-
|
|
7974
|
+
visibility: app_objectSpread(app_objectSpread({}, s.visibility), {}, {
|
|
7975
|
+
visible: 'minimized'
|
|
7976
|
+
})
|
|
7893
7977
|
}));
|
|
7894
7978
|
});
|
|
7895
7979
|
}
|