@micromag/core 0.4.69 → 0.4.74

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/es/utils.js CHANGED
@@ -2,28 +2,17 @@ import isString from 'lodash/isString';
2
2
  import isNumber from 'lodash/isNumber';
3
3
  import { kebabCase, pascalCase, snakeCase } from 'change-case';
4
4
  export { camelCase, pascalCase, snakeCase } from 'change-case';
5
- import _regenerator from '@babel/runtime/helpers/regenerator';
6
- import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
7
5
  import isObject from 'lodash/isObject';
8
- import { useEffect, useMemo } from 'react';
6
+ import { useEffect } from 'react';
9
7
  import tinycolor from 'tinycolor2';
10
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
11
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
12
8
  import isArray from 'lodash/isArray';
13
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
14
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
15
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
16
9
  import slugify from 'slugify';
17
10
 
18
11
  function addNonBreakingSpaces(text) {
19
12
  return isString(text) ? text.replace(/«\s/g, '« ').replace(/\s»/g, ' »').replace(/\s:\s/g, ' : ') : text;
20
13
  }
21
14
 
22
- var convertStyleToString = function convertStyleToString(style) {
23
- return style !== null ? Object.keys(style).map(function (key) {
24
- return "".concat(kebabCase(key), ":").concat(isNumber(style[key]) ? "".concat(style[key], "px") : style[key], ";");
25
- }).join('\n') : '';
26
- };
15
+ const convertStyleToString = style => style !== null ? Object.keys(style).map(key => `${kebabCase(key)}:${isNumber(style[key]) ? `${style[key]}px` : style[key]};`).join('\n') : '';
27
16
 
28
17
  /*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
29
18
 
@@ -33,143 +22,82 @@ var convertStyleToString = function convertStyleToString(style) {
33
22
  function makeError() {
34
23
  return new DOMException('The request is not allowed', 'NotAllowedError');
35
24
  }
36
- function copyClipboardApi(_x) {
37
- return _copyClipboardApi.apply(this, arguments);
38
- }
39
- function _copyClipboardApi() {
40
- _copyClipboardApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(text) {
41
- return _regenerator().w(function (_context) {
42
- while (1) switch (_context.n) {
43
- case 0:
44
- if (navigator.clipboard) {
45
- _context.n = 1;
46
- break;
47
- }
48
- throw makeError();
49
- case 1:
50
- return _context.a(2, navigator.clipboard.writeText(text));
51
- }
52
- }, _callee);
53
- }));
54
- return _copyClipboardApi.apply(this, arguments);
55
- }
56
- function copyExecCommand(_x2) {
57
- return _copyExecCommand.apply(this, arguments);
58
- }
59
- function _copyExecCommand() {
60
- _copyExecCommand = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(text) {
61
- var span, selection, range, success;
62
- return _regenerator().w(function (_context2) {
63
- while (1) switch (_context2.n) {
64
- case 0:
65
- // Put the text to copy into a <span>
66
- span = document.createElement('span');
67
- span.textContent = text;
68
-
69
- // Preserve consecutive spaces and newlines
70
- span.style.whiteSpace = 'pre';
71
- span.style.webkitUserSelect = 'auto';
72
- span.style.userSelect = 'all';
73
-
74
- // Add the <span> to the page
75
- document.body.appendChild(span);
76
-
77
- // Make a selection object representing the range of text selected by the user
78
- selection = window.getSelection();
79
- range = window.document.createRange();
80
- selection.removeAllRanges();
81
- range.selectNode(span);
82
- selection.addRange(range);
83
-
84
- // Copy text to the clipboard
85
- success = false;
86
- try {
87
- success = window.document.execCommand('copy');
88
- } finally {
89
- // Cleanup
90
- selection.removeAllRanges();
91
- window.document.body.removeChild(span);
92
- }
93
- if (success) {
94
- _context2.n = 1;
95
- break;
96
- }
97
- throw makeError();
98
- case 1:
99
- return _context2.a(2);
100
- }
101
- }, _callee2);
102
- }));
103
- return _copyExecCommand.apply(this, arguments);
25
+ async function copyClipboardApi(text) {
26
+ // Use the Async Clipboard API when available. Requires a secure browsing
27
+ // context (i.e. HTTPS)
28
+ if (!navigator.clipboard) {
29
+ throw makeError();
30
+ }
31
+ return navigator.clipboard.writeText(text);
104
32
  }
105
- function copyToClipboard(_x3) {
106
- return _copyToClipboard.apply(this, arguments);
33
+ async function copyExecCommand(text) {
34
+ // Put the text to copy into a <span>
35
+ const span = document.createElement('span');
36
+ span.textContent = text;
37
+
38
+ // Preserve consecutive spaces and newlines
39
+ span.style.whiteSpace = 'pre';
40
+ span.style.webkitUserSelect = 'auto';
41
+ span.style.userSelect = 'all';
42
+
43
+ // Add the <span> to the page
44
+ document.body.appendChild(span);
45
+
46
+ // Make a selection object representing the range of text selected by the user
47
+ const selection = window.getSelection();
48
+ const range = window.document.createRange();
49
+ selection.removeAllRanges();
50
+ range.selectNode(span);
51
+ selection.addRange(range);
52
+
53
+ // Copy text to the clipboard
54
+ let success = false;
55
+ try {
56
+ success = window.document.execCommand('copy');
57
+ } finally {
58
+ // Cleanup
59
+ selection.removeAllRanges();
60
+ window.document.body.removeChild(span);
61
+ }
62
+ if (!success) throw makeError();
107
63
  }
108
- function _copyToClipboard() {
109
- _copyToClipboard = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(text) {
110
- var _t, _t2;
111
- return _regenerator().w(function (_context3) {
112
- while (1) switch (_context3.p = _context3.n) {
113
- case 0:
114
- _context3.p = 0;
115
- _context3.n = 1;
116
- return copyClipboardApi(text);
117
- case 1:
118
- _context3.n = 6;
119
- break;
120
- case 2:
121
- _context3.p = 2;
122
- _t = _context3.v;
123
- _context3.p = 3;
124
- _context3.n = 4;
125
- return copyExecCommand(text);
126
- case 4:
127
- _context3.n = 6;
128
- break;
129
- case 5:
130
- _context3.p = 5;
131
- _t2 = _context3.v;
132
- throw _t2 || _t || makeError();
133
- case 6:
134
- return _context3.a(2);
135
- }
136
- }, _callee3, null, [[3, 5], [0, 2]]);
137
- }));
138
- return _copyToClipboard.apply(this, arguments);
64
+ async function copyToClipboard(text) {
65
+ try {
66
+ await copyClipboardApi(text);
67
+ } catch (err) {
68
+ // ...Otherwise, use document.execCommand() fallback
69
+ try {
70
+ await copyExecCommand(text);
71
+ } catch (err2) {
72
+ throw err2 || err || makeError();
73
+ }
74
+ }
139
75
  }
140
76
 
141
- var createNullableOnChange = function createNullableOnChange() {
142
- var onChange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
143
- return function (newValue) {
144
- var nullableValue = newValue;
145
- if (isObject(newValue)) {
146
- var allNull = Object.keys(newValue).reduce(function (acc, key) {
147
- return acc && newValue[key] === null;
148
- }, true);
149
- if (allNull) {
150
- nullableValue = null;
151
- }
77
+ const createNullableOnChange = (onChange = null) => newValue => {
78
+ let nullableValue = newValue;
79
+ if (isObject(newValue)) {
80
+ const allNull = Object.keys(newValue).reduce((acc, key) => acc && newValue[key] === null, true);
81
+ if (allNull) {
82
+ nullableValue = null;
152
83
  }
153
- if (onChange !== null) {
154
- onChange(nullableValue);
155
- }
156
- };
84
+ }
85
+ if (onChange !== null) {
86
+ onChange(nullableValue);
87
+ }
157
88
  };
158
89
 
159
- var createUseEvent = function createUseEvent(eventsManager) {
160
- return function (event, callback) {
161
- var enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
162
- useEffect(function () {
90
+ const createUseEvent = eventsManager => (event, callback, enabled = true) => {
91
+ useEffect(() => {
92
+ if (enabled && eventsManager !== null) {
93
+ eventsManager.subscribe(event, callback);
94
+ }
95
+ return () => {
163
96
  if (enabled && eventsManager !== null) {
164
- eventsManager.subscribe(event, callback);
97
+ eventsManager.unsubscribe(event, callback);
165
98
  }
166
- return function () {
167
- if (enabled && eventsManager !== null) {
168
- eventsManager.unsubscribe(event, callback);
169
- }
170
- };
171
- }, [eventsManager, event, callback, enabled]);
172
- };
99
+ };
100
+ }, [eventsManager, event, callback, enabled]);
173
101
  };
174
102
 
175
103
  function cssEscape(value) {
@@ -177,121 +105,59 @@ function cssEscape(value) {
177
105
  }
178
106
 
179
107
  /* eslint-disable */
180
- var easings = {
181
- linear: function linear(x) {
182
- return x;
183
- },
184
- easeInQuad: function easeInQuad(x) {
185
- return x * x;
186
- },
187
- easeOutQuad: function easeOutQuad(x) {
188
- return 1 - (1 - x) * (1 - x);
189
- },
190
- easeInOutQuad: function easeInOutQuad(x) {
191
- return x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2;
192
- },
193
- easeInCubic: function easeInCubic(x) {
194
- return x * x * x;
195
- },
196
- easeOutCubic: function easeOutCubic(x) {
197
- return 1 - Math.pow(1 - x, 3);
198
- },
199
- easeInOutCubic: function easeInOutCubic(x) {
200
- return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
201
- },
202
- easeInQuart: function easeInQuart(x) {
203
- return x * x * x * x;
204
- },
205
- easeOutQuart: function easeOutQuart(x) {
206
- return 1 - Math.pow(1 - x, 4);
207
- },
208
- easeInOutQuart: function easeInOutQuart(x) {
209
- return x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2;
210
- },
211
- easeInQuint: function easeInQuint(x) {
212
- return x * x * x * x * x;
213
- },
214
- easeOutQuint: function easeOutQuint(x) {
215
- return 1 - Math.pow(1 - x, 5);
216
- },
217
- easeInOutQuint: function easeInOutQuint(x) {
218
- return x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2;
219
- },
220
- easeInSine: function easeInSine(x) {
221
- return 1 - Math.cos(x * Math.PI / 2);
222
- },
223
- easeOutSine: function easeOutSine(x) {
224
- return Math.sin(x * Math.PI / 2);
225
- },
226
- easeInOutSine: function easeInOutSine(x) {
227
- return -(Math.cos(Math.PI * x) - 1) / 2;
228
- },
229
- easeInExpo: function easeInExpo(x) {
230
- return x === 0 ? 0 : Math.pow(2, 10 * x - 10);
231
- },
232
- easeOutExpo: function easeOutExpo(x) {
233
- return x === 1 ? 1 : 1 - Math.pow(2, -10 * x);
234
- },
235
- easeInOutExpo: function easeInOutExpo(x) {
236
- return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? Math.pow(2, 20 * x - 10) / 2 : (2 - Math.pow(2, -20 * x + 10)) / 2;
237
- },
238
- easeInCirc: function easeInCirc(x) {
239
- return 1 - Math.sqrt(1 - Math.pow(x, 2));
240
- },
241
- easeOutCirc: function easeOutCirc(x) {
242
- return Math.sqrt(1 - Math.pow(x - 1, 2));
243
- },
244
- easeInOutCirc: function easeInOutCirc(x) {
245
- return x < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2;
246
- },
247
- easeInBack: function easeInBack(x) {
248
- return c3 * x * x * x - c1 * x * x;
249
- },
250
- easeOutBack: function easeOutBack(x) {
251
- return 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2);
252
- },
253
- easeInOutBack: function easeInOutBack(x) {
254
- return x < 0.5 ? Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;
255
- },
256
- easeInElastic: function easeInElastic(x) {
257
- return x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4);
258
- },
259
- easeOutElastic: function easeOutElastic(x) {
260
- return x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
261
- },
262
- easeInOutElastic: function easeInOutElastic(x) {
263
- return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1;
264
- }
108
+ const easings = {
109
+ linear: x => x,
110
+ easeInQuad: x => x * x,
111
+ easeOutQuad: x => 1 - (1 - x) * (1 - x),
112
+ easeInOutQuad: x => x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2,
113
+ easeInCubic: x => x * x * x,
114
+ easeOutCubic: x => 1 - (1 - x) ** 3,
115
+ easeInOutCubic: x => x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2,
116
+ easeInQuart: x => x * x * x * x,
117
+ easeOutQuart: x => 1 - (1 - x) ** 4,
118
+ easeInOutQuart: x => x < 0.5 ? 8 * x * x * x * x : 1 - (-2 * x + 2) ** 4 / 2,
119
+ easeInQuint: x => x * x * x * x * x,
120
+ easeOutQuint: x => 1 - (1 - x) ** 5,
121
+ easeInOutQuint: x => x < 0.5 ? 16 * x * x * x * x * x : 1 - (-2 * x + 2) ** 5 / 2,
122
+ easeInSine: x => 1 - Math.cos(x * Math.PI / 2),
123
+ easeOutSine: x => Math.sin(x * Math.PI / 2),
124
+ easeInOutSine: x => -(Math.cos(Math.PI * x) - 1) / 2,
125
+ easeInExpo: x => x === 0 ? 0 : 2 ** (10 * x - 10),
126
+ easeOutExpo: x => x === 1 ? 1 : 1 - 2 ** (-10 * x),
127
+ easeInOutExpo: x => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? 2 ** (20 * x - 10) / 2 : (2 - 2 ** (-20 * x + 10)) / 2,
128
+ easeInCirc: x => 1 - Math.sqrt(1 - x ** 2),
129
+ easeOutCirc: x => Math.sqrt(1 - (x - 1) ** 2),
130
+ easeInOutCirc: x => x < 0.5 ? (1 - Math.sqrt(1 - (2 * x) ** 2)) / 2 : (Math.sqrt(1 - (-2 * x + 2) ** 2) + 1) / 2,
131
+ easeInBack: x => c3 * x * x * x - c1 * x * x,
132
+ easeOutBack: x => 1 + c3 * (x - 1) ** 3 + c1 * (x - 1) ** 2,
133
+ easeInOutBack: x => x < 0.5 ? (2 * x) ** 2 * ((c2 + 1) * 2 * x - c2) / 2 : ((2 * x - 2) ** 2 * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2,
134
+ easeInElastic: x => x === 0 ? 0 : x === 1 ? 1 : -(2 ** (10 * x - 10)) * Math.sin((x * 10 - 10.75) * c4),
135
+ easeOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : 2 ** (-10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
136
+ easeInOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(2 ** (20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : 2 ** (-20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1
265
137
  };
266
138
 
267
- var getColorAsString = function getColorAsString() {
268
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
269
- var overideAlpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
139
+ const getColorAsString = (value = null, overideAlpha = null) => {
270
140
  if (value === null) {
271
141
  return null;
272
142
  }
273
- var _ref = isString(value) ? {
274
- color: value
275
- } : value,
276
- _ref$color = _ref.color,
277
- color = _ref$color === void 0 ? null : _ref$color,
278
- _ref$alpha = _ref.alpha,
279
- alpha = _ref$alpha === void 0 ? null : _ref$alpha;
143
+ const {
144
+ color = null,
145
+ alpha = null
146
+ } = isString(value) ? {
147
+ color: value
148
+ } : value;
280
149
  return alpha !== null || overideAlpha !== null ? tinycolor(color).setAlpha(overideAlpha !== null ? overideAlpha : alpha).toRgbString() : color;
281
150
  };
282
151
 
283
- var getComponentFromName = function getComponentFromName() {
284
- var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
285
- var components = arguments.length > 1 ? arguments[1] : undefined;
286
- var defaultComponent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
152
+ const getComponentFromName = (name = null, components, defaultComponent = null) => {
287
153
  if (components === null || name === null) {
288
154
  return defaultComponent;
289
155
  }
290
- var pascalName = pascalCase(name);
156
+ const pascalName = pascalCase(name);
291
157
  return components[pascalName] || components[name] || defaultComponent;
292
158
  };
293
159
 
294
- var deviceScreens = [{
160
+ const deviceScreens = [{
295
161
  name: 'mobile'
296
162
  }, {
297
163
  name: 'small',
@@ -308,299 +174,274 @@ var deviceScreens = [{
308
174
  }];
309
175
 
310
176
  // eslint-disable-next-line import/prefer-default-export
311
- var getDeviceScreens = function getDeviceScreens() {
312
- return deviceScreens;
313
- };
177
+ const getDeviceScreens = () => deviceScreens;
314
178
 
315
- var getDisplayName = function getDisplayName(_ref) {
316
- var _ref$displayName = _ref.displayName,
317
- displayName = _ref$displayName === void 0 ? null : _ref$displayName,
318
- _ref$name = _ref.name,
319
- name = _ref$name === void 0 ? null : _ref$name;
320
- return displayName || name || 'Component';
321
- };
179
+ const getDisplayName = ({
180
+ displayName = null,
181
+ name = null
182
+ }) => displayName || name || 'Component';
322
183
 
323
- var _getFieldByName = function getFieldByName(fields, name) {
324
- return fields.reduce(function (foundField, it) {
325
- if (foundField !== null) {
326
- return foundField;
327
- }
328
- var _it$name = it.name,
329
- fieldName = _it$name === void 0 ? null : _it$name,
330
- _it$fields = it.fields,
331
- subFields = _it$fields === void 0 ? [] : _it$fields;
332
- if (name !== null && fieldName === name) {
333
- return it;
334
- }
335
- return _getFieldByName(subFields, name);
336
- }, null);
337
- };
184
+ const getFieldByName = (fields, name) => fields.reduce((foundField, it) => {
185
+ if (foundField !== null) {
186
+ return foundField;
187
+ }
188
+ const {
189
+ name: fieldName = null,
190
+ fields: subFields = []
191
+ } = it;
192
+ if (name !== null && fieldName === name) {
193
+ return it;
194
+ }
195
+ return getFieldByName(subFields, name);
196
+ }, null);
338
197
 
339
- var getFieldFromPath = function getFieldFromPath(path, fields, fieldManager) {
340
- return (isArray(path) ? path : [path]).reduce(function (foundField, key) {
341
- if (foundField === null) {
342
- return null;
343
- }
344
- var _foundField$type = foundField.type,
345
- type = _foundField$type === void 0 ? null : _foundField$type,
346
- _foundField$fields = foundField.fields,
347
- fieldFields = _foundField$fields === void 0 ? null : _foundField$fields,
348
- _foundField$field = foundField.field,
349
- field = _foundField$field === void 0 ? null : _foundField$field,
350
- _foundField$itemsFiel = foundField.itemsField,
351
- itemsField = _foundField$itemsFiel === void 0 ? null : _foundField$itemsFiel;
352
- var finalType = field !== null ? field.type || type : type;
353
- var definition = fieldManager.getDefinition(finalType);
354
- var _ref = finalType !== null ? definition : foundField,
355
- _ref$fields = _ref.fields,
356
- subFields = _ref$fields === void 0 ? null : _ref$fields,
357
- _ref$settings = _ref.settings,
358
- settings = _ref$settings === void 0 ? null : _ref$settings,
359
- _ref$itemsField = _ref.itemsField,
360
- defItemsField = _ref$itemsField === void 0 ? null : _ref$itemsField;
361
- var finalItemsField = itemsField || defItemsField;
362
- if (finalItemsField !== null && key.match(/^[0-9]+$/)) {
363
- return _objectSpread(_objectSpread({}, finalItemsField), {}, {
364
- name: path.join('/'),
365
- listItems: true
366
- });
367
- }
368
- return _getFieldByName([].concat(_toConsumableArray(fieldFields || []), _toConsumableArray(subFields || []), _toConsumableArray(settings || [])), key);
369
- }, {
370
- fields: fields
371
- });
372
- };
198
+ const getFieldFromPath = (path, fields, fieldManager) => (isArray(path) ? path : [path]).reduce((foundField, key) => {
199
+ if (foundField === null) {
200
+ return null;
201
+ }
202
+ const {
203
+ type = null,
204
+ fields: fieldFields = null,
205
+ field = null,
206
+ itemsField = null
207
+ } = foundField;
208
+ const finalType = field !== null ? field.type || type : type;
209
+ const definition = fieldManager.getDefinition(finalType);
210
+ const {
211
+ fields: subFields = null,
212
+ settings = null,
213
+ itemsField: defItemsField = null
214
+ } = finalType !== null ? definition : foundField;
215
+ const finalItemsField = itemsField || defItemsField;
216
+ if (finalItemsField !== null && key.match(/^[0-9]+$/)) {
217
+ return {
218
+ ...finalItemsField,
219
+ name: path.join('/'),
220
+ listItems: true
221
+ };
222
+ }
223
+ return getFieldByName([...(fieldFields || []), ...(subFields || []), ...(settings || [])], key);
224
+ }, {
225
+ fields
226
+ });
373
227
 
374
- var getFileName = function getFileName() {
375
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
228
+ const getFileName = (url = null) => {
376
229
  if (url === null || typeof url.match === 'undefined') {
377
230
  return null;
378
231
  }
379
232
  return url.match(/([^/]+)(\?.*)?$/)[1] || url;
380
233
  };
381
234
 
382
- var getFontFamily = function getFontFamily(value) {
235
+ const getFontFamily = value => {
383
236
  if (value == null) {
384
237
  return null;
385
238
  }
386
- var _ref = isObject(value) ? value : {
387
- name: value
388
- },
389
- name = _ref.name,
390
- _ref$fallback = _ref.fallback,
391
- fallback = _ref$fallback === void 0 ? null : _ref$fallback;
392
- return [name, fallback].filter(function (it) {
393
- return it !== null;
394
- }).map(function (it) {
395
- return "\"".concat(it, "\"");
396
- }).join(', ');
239
+ const {
240
+ name,
241
+ fallback = null
242
+ } = isObject(value) ? value : {
243
+ name: value
244
+ };
245
+ return [name, fallback].filter(it => it !== null).map(it => `"${it}"`).join(', ');
397
246
  };
398
247
 
399
- var _excluded$1 = ["isPreview", "isView", "current", "openWebView", "enableInteraction", "disableInteraction"];
400
- var getFooterProps = function getFooterProps() {
401
- var footer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
402
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
403
- _ref$isPreview = _ref.isPreview,
404
- isPreview = _ref$isPreview === void 0 ? false : _ref$isPreview,
405
- _ref$isView = _ref.isView,
406
- isView = _ref$isView === void 0 ? false : _ref$isView,
407
- _ref$current = _ref.current,
408
- current = _ref$current === void 0 ? false : _ref$current,
409
- _ref$openWebView = _ref.openWebView,
410
- openWebView = _ref$openWebView === void 0 ? false : _ref$openWebView,
411
- _ref$enableInteractio = _ref.enableInteraction,
412
- enableInteraction = _ref$enableInteractio === void 0 ? true : _ref$enableInteractio,
413
- _ref$disableInteracti = _ref.disableInteraction,
414
- disableInteraction = _ref$disableInteracti === void 0 ? false : _ref$disableInteracti,
415
- otherProps = _objectWithoutProperties(_ref, _excluded$1);
416
- var _ref2 = footer || {},
417
- _ref2$callToAction = _ref2.callToAction,
418
- callToAction = _ref2$callToAction === void 0 ? null : _ref2$callToAction;
419
- var footerProps = useMemo(function () {
420
- return {
421
- callToAction: _objectSpread(_objectSpread({}, callToAction), {}, {
422
- animationDisabled: isPreview,
423
- focusable: current && isView,
424
- openWebView: openWebView,
425
- enableInteraction: enableInteraction,
426
- disableInteraction: disableInteraction
427
- }, otherProps)
428
- };
429
- }, [callToAction, isPreview, isView, current, enableInteraction, disableInteraction, otherProps]);
430
- return footerProps;
431
- };
248
+ function getFooterProps(footer = {}, {
249
+ isPreview = false,
250
+ isView = false,
251
+ current = false,
252
+ openWebView = false,
253
+ enableInteraction = true,
254
+ disableInteraction = false,
255
+ ...otherProps
256
+ } = {}) {
257
+ const {
258
+ callToAction = null
259
+ } = footer || {};
260
+ return {
261
+ callToAction: {
262
+ ...callToAction,
263
+ animationDisabled: isPreview,
264
+ focusable: current && isView,
265
+ openWebView,
266
+ enableInteraction,
267
+ disableInteraction,
268
+ ...otherProps
269
+ }
270
+ };
271
+ }
432
272
 
433
- var getGridLayoutName = function getGridLayoutName(layout) {
434
- return layout.map(function (it) {
435
- return "".concat(it.rows, "_").concat(it.columns.join('_'));
436
- }).join('|');
437
- };
273
+ const getGridLayoutName = layout => layout.map(it => `${it.rows}_${it.columns.join('_')}`).join('|');
438
274
 
439
- var getRemainder = function getRemainder(number) {
440
- var remainder = number - Math.floor(number);
275
+ const getRemainder = number => {
276
+ const remainder = number - Math.floor(number);
441
277
  return remainder.toFixed(4);
442
278
  };
443
- var largestRemainderRound = function largestRemainderRound(numbers, desiredTotal) {
279
+ const largestRemainderRound = (numbers, desiredTotal) => {
444
280
  if (!isArray(numbers) || numbers.length < 1) return numbers;
445
- var result = numbers.map(function (number, index) {
446
- return {
447
- floor: Math.floor(number) || 0,
448
- remainder: getRemainder(number),
449
- index: index
450
- };
451
- }).sort(function (a, b) {
452
- return b.remainder - a.remainder;
453
- });
454
- var lowerSum = result.reduce(function (sum, current) {
455
- return sum + current.floor;
456
- }, 0);
457
- var delta = desiredTotal - lowerSum;
458
- for (var i = 0; i < delta; i += 1) {
281
+ const result = numbers.map((number, index) => ({
282
+ floor: Math.floor(number) || 0,
283
+ remainder: getRemainder(number),
284
+ index
285
+ })).sort((a, b) => b.remainder - a.remainder);
286
+ const lowerSum = result.reduce((sum, current) => sum + current.floor, 0);
287
+ const delta = desiredTotal - lowerSum;
288
+ for (let i = 0; i < delta; i += 1) {
459
289
  if (result[i]) {
460
290
  result[i].floor += 1;
461
291
  }
462
292
  }
463
- return result.sort(function (a, b) {
464
- return a.index - b.index;
465
- }).map(function (res) {
466
- return res.floor;
467
- });
293
+ return result.sort((a, b) => a.index - b.index).map(res => res.floor);
468
294
  };
469
295
 
470
- var _excluded = ["image", "video", "media", "color"];
471
- var getLayersFromBackground = function getLayersFromBackground() {
472
- var background = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
296
+ const getLayersFromBackground = (background = null) => {
473
297
  if (background === null) {
474
298
  return [];
475
299
  }
476
- return (isArray(background) ? background : [background]).reduce(function (layers, _ref) {
477
- var _ref$image = _ref.image,
478
- image = _ref$image === void 0 ? null : _ref$image,
479
- _ref$video = _ref.video,
480
- video = _ref$video === void 0 ? null : _ref$video,
481
- _ref$media = _ref.media,
482
- media = _ref$media === void 0 ? null : _ref$media,
483
- _ref$color = _ref.color,
484
- color = _ref$color === void 0 ? null : _ref$color,
485
- data = _objectWithoutProperties(_ref, _excluded);
300
+ return (isArray(background) ? background : [background]).reduce((layers, {
301
+ image = null,
302
+ video = null,
303
+ media = null,
304
+ color = null,
305
+ ...data
306
+ }) => {
486
307
  if (image === null && video === null && color === null) {
487
308
  return layers;
488
309
  }
489
310
  if (image !== null && video !== null) {
490
- return [].concat(_toConsumableArray(layers), [_objectSpread({
491
- media: image
492
- }, data), _objectSpread({
311
+ return [...layers, {
312
+ media: image,
313
+ ...data
314
+ }, {
493
315
  media: video,
494
- color: color
495
- }, data)]);
316
+ color,
317
+ ...data
318
+ }];
496
319
  }
497
- return [].concat(_toConsumableArray(layers), [_objectSpread({
320
+ return [...layers, {
498
321
  media: media || image || video,
499
- color: color
500
- }, data)]);
322
+ color,
323
+ ...data
324
+ }];
501
325
  }, []);
502
326
  };
503
327
 
504
- var getMediaFilesAsArray = function getMediaFilesAsArray(files) {
505
- return files !== null && isArray(files) ? files : Object.keys(files || {}).reduce(function (newFiles, key) {
506
- return [].concat(_toConsumableArray(newFiles), [_objectSpread({
507
- handle: key
508
- }, files[key])]);
509
- }, []);
510
- };
328
+ const getMediaFilesAsArray = files => files !== null && isArray(files) ? files : Object.keys(files || {}).reduce((newFiles, key) => [...newFiles, {
329
+ handle: key,
330
+ ...files[key]
331
+ }], []);
332
+
333
+ function getMediaThumbnail(media, thumbnail = null) {
334
+ if (isObject(thumbnail)) {
335
+ return thumbnail;
336
+ }
337
+ const {
338
+ thumbnail_url: defaultThumbnailUrl = null,
339
+ files = null,
340
+ metadata = null
341
+ } = media || {};
342
+ const {
343
+ width: mediaWidth,
344
+ height: mediaHeight
345
+ } = metadata || {};
346
+ const filesArray = getMediaFilesAsArray(files) || [];
347
+ const {
348
+ url = null
349
+ } = (thumbnail !== null ? filesArray.find(({
350
+ handle
351
+ }) => handle === thumbnail) || null : null) || {};
352
+ return url !== null || defaultThumbnailUrl !== null ? {
353
+ url: url || defaultThumbnailUrl,
354
+ metadata: {
355
+ width: mediaWidth,
356
+ height: mediaHeight
357
+ }
358
+ } : null;
359
+ }
511
360
 
512
361
  // eslint-disable-next-line import/prefer-default-export
513
- var getOptimalImageUrl = function getOptimalImageUrl() {
514
- var media = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
515
- var containerWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
516
- var containerHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
517
- var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
518
- _ref$resolution = _ref.resolution,
519
- resolution = _ref$resolution === void 0 ? 1 : _ref$resolution,
520
- _ref$maxDiff = _ref.maxDiff,
521
- maxDiff = _ref$maxDiff === void 0 ? 800 : _ref$maxDiff,
522
- _ref$supportsWebp = _ref.supportsWebp,
523
- supportsWebp = _ref$supportsWebp === void 0 ? false : _ref$supportsWebp;
524
- var _ref2 = media || {},
525
- _ref2$sizes = _ref2.sizes,
526
- sizes = _ref2$sizes === void 0 ? null : _ref2$sizes,
527
- _ref2$url = _ref2.url,
528
- defaultUrl = _ref2$url === void 0 ? null : _ref2$url,
529
- _ref2$webp_url = _ref2.webp_url,
530
- defaultWebpUrl = _ref2$webp_url === void 0 ? null : _ref2$webp_url,
531
- _ref2$metadata = _ref2.metadata,
532
- _ref2$metadata2 = _ref2$metadata === void 0 ? {} : _ref2$metadata,
533
- imgWidth = _ref2$metadata2.width,
534
- imgHeight = _ref2$metadata2.height;
535
- var finalDefaultUrl = supportsWebp && defaultWebpUrl !== null ? defaultWebpUrl : defaultUrl;
362
+ const getOptimalImageUrl = (media = null, containerWidth = null, containerHeight = null, {
363
+ resolution = 1,
364
+ maxDiff = 800,
365
+ supportsWebp = false
366
+ } = {}) => {
367
+ const {
368
+ sizes = null,
369
+ url: defaultUrl = null,
370
+ webp_url: defaultWebpUrl = null,
371
+ metadata: {
372
+ width: imgWidth,
373
+ height: imgHeight
374
+ } = {}
375
+ } = media || {};
376
+ const finalDefaultUrl = supportsWebp && defaultWebpUrl !== null ? defaultWebpUrl : defaultUrl;
536
377
  if (sizes === null || containerWidth === null && containerHeight === null) {
537
378
  return finalDefaultUrl;
538
379
  }
539
- var finalSizes = _objectSpread({
380
+ const finalSizes = {
540
381
  original: {
541
382
  url: finalDefaultUrl,
542
383
  width: imgWidth,
543
384
  height: imgHeight
385
+ },
386
+ ...sizes
387
+ };
388
+ const finalContainerWidth = containerWidth !== null && resolution !== null ? containerWidth * resolution : containerWidth;
389
+ const finalContainerHeight = containerHeight !== null && resolution !== null ? containerHeight * resolution : containerHeight;
390
+ const {
391
+ url: finalUrl
392
+ } = Object.keys(finalSizes).reduce((acc, key) => {
393
+ const {
394
+ diff: currentDiff,
395
+ isLarger: currentIsLarger,
396
+ size: currentSize
397
+ } = acc;
398
+ const {
399
+ url,
400
+ webp_url: webpUrl = null,
401
+ width = null,
402
+ height = null
403
+ } = finalSizes[key];
404
+ const sizeUrl = supportsWebp && webpUrl !== null ? webpUrl : url;
405
+ const diffWidth = width !== null && finalContainerWidth !== null ? width - finalContainerWidth : null;
406
+ const diffHeight = height !== null && finalContainerHeight !== null ? height - finalContainerHeight : null;
407
+ const isLarger = (diffWidth === null || diffWidth >= 0) && (diffHeight === null || diffHeight >= 0);
408
+ let diff = [diffWidth, diffHeight].reduce((total, value) => value !== null ? (total || 0) + Math.abs(value) : total, null);
409
+ if (diff === null) {
410
+ diff = Infinity;
544
411
  }
545
- }, sizes);
546
- var finalContainerWidth = containerWidth !== null && resolution !== null ? containerWidth * resolution : containerWidth;
547
- var finalContainerHeight = containerHeight !== null && resolution !== null ? containerHeight * resolution : containerHeight;
548
- var _Object$keys$reduce = Object.keys(finalSizes).reduce(function (acc, key) {
549
- var currentDiff = acc.diff,
550
- currentIsLarger = acc.isLarger,
551
- currentSize = acc.size;
552
- var _finalSizes$key = finalSizes[key],
553
- url = _finalSizes$key.url,
554
- _finalSizes$key$webp_ = _finalSizes$key.webp_url,
555
- webpUrl = _finalSizes$key$webp_ === void 0 ? null : _finalSizes$key$webp_,
556
- _finalSizes$key$width = _finalSizes$key.width,
557
- width = _finalSizes$key$width === void 0 ? null : _finalSizes$key$width,
558
- _finalSizes$key$heigh = _finalSizes$key.height,
559
- height = _finalSizes$key$heigh === void 0 ? null : _finalSizes$key$heigh;
560
- var sizeUrl = supportsWebp && webpUrl !== null ? webpUrl : url;
561
- var diffWidth = width !== null && finalContainerWidth !== null ? width - finalContainerWidth : null;
562
- var diffHeight = height !== null && finalContainerHeight !== null ? height - finalContainerHeight : null;
563
- var isLarger = (diffWidth === null || diffWidth >= 0) && (diffHeight === null || diffHeight >= 0);
564
- var diff = [diffWidth, diffHeight].reduce(function (total, value) {
565
- return value !== null ? (total || 0) + Math.abs(value) : total;
566
- }, null);
567
- if (diff === null) {
568
- diff = Infinity;
569
- }
570
- var size = (width || 0) + (height || 0);
571
- var sizeIsLarger = size > currentSize;
572
- if (
573
- // Difference is lower and image is larger
574
- diff < currentDiff && isLarger ||
575
- // Difference is lower and current is not larger or diff is greater than max
576
- diff < currentDiff && (!currentIsLarger && sizeIsLarger || currentDiff > maxDiff) ||
577
- // Image is larger and diff is smaller than max
578
- diff <= maxDiff && !currentIsLarger && isLarger ||
579
- // Image is larger than previous
580
- diff <= maxDiff && !currentIsLarger && !isLarger && sizeIsLarger) {
581
- return {
582
- key: key,
583
- url: sizeUrl,
584
- diff: diff,
585
- isLarger: isLarger
586
- };
587
- }
588
- return acc;
589
- }, {
590
- key: null,
591
- url: finalDefaultUrl,
592
- diff: Infinity,
593
- isLarger: false,
594
- size: 0
595
- }),
596
- finalUrl = _Object$keys$reduce.url;
412
+ const size = (width || 0) + (height || 0);
413
+ const sizeIsLarger = size > currentSize;
414
+ if (
415
+ // Difference is lower and image is larger
416
+ diff < currentDiff && isLarger ||
417
+ // Difference is lower and current is not larger or diff is greater than max
418
+ diff < currentDiff && (!currentIsLarger && sizeIsLarger || currentDiff > maxDiff) ||
419
+ // Image is larger and diff is smaller than max
420
+ diff <= maxDiff && !currentIsLarger && isLarger ||
421
+ // Image is larger than previous
422
+ diff <= maxDiff && !currentIsLarger && !isLarger && sizeIsLarger) {
423
+ return {
424
+ key,
425
+ url: sizeUrl,
426
+ diff,
427
+ isLarger
428
+ };
429
+ }
430
+ return acc;
431
+ }, {
432
+ key: null,
433
+ url: finalDefaultUrl,
434
+ diff: Infinity,
435
+ isLarger: false,
436
+ size: 0
437
+ });
597
438
  return finalUrl;
598
439
  };
599
440
 
600
- var getSecondsFromTime = function getSecondsFromTime(time) {
601
- var t = time.split(':');
441
+ const getSecondsFromTime = time => {
442
+ const t = time.split(':');
602
443
  try {
603
- var s = t[2].split(',');
444
+ let s = t[2].split(',');
604
445
  if (s.length === 1) {
605
446
  s = t[2].split('.');
606
447
  }
@@ -610,72 +451,62 @@ var getSecondsFromTime = function getSecondsFromTime(time) {
610
451
  }
611
452
  };
612
453
 
613
- var getScreenExtraField = function getScreenExtraField(intl) {
614
- return {
615
- name: 'parameters',
616
- type: 'parameters',
617
- label: intl.formatMessage({
618
- id: "8A8cuq",
619
- defaultMessage: [{
620
- "type": 0,
621
- "value": "Parameters"
622
- }]
623
- })
624
- };
625
- };
454
+ const getScreenExtraField = intl => ({
455
+ name: 'parameters',
456
+ type: 'parameters',
457
+ label: intl.formatMessage({
458
+ id: "8A8cuq",
459
+ defaultMessage: "Parameters"
460
+ })
461
+ });
626
462
 
627
463
  function getScreenFieldsWithStates(definition) {
628
- var _ref = definition || {},
629
- _ref$fields = _ref.fields,
630
- screenFields = _ref$fields === void 0 ? null : _ref$fields,
631
- _ref$states = _ref.states,
632
- states = _ref$states === void 0 ? null : _ref$states;
464
+ const {
465
+ fields: screenFields = null,
466
+ states = null
467
+ } = definition || {};
633
468
  if (states === null) {
634
469
  return screenFields;
635
470
  }
636
- var extraFields = states.reduce(function (statesFields, current) {
637
- var _ref2 = current || {},
638
- id = _ref2.id,
639
- _ref2$fields = _ref2.fields,
640
- fields = _ref2$fields === void 0 ? [] : _ref2$fields,
641
- _ref2$repeatable = _ref2.repeatable,
642
- repeatable = _ref2$repeatable === void 0 ? false : _ref2$repeatable,
643
- _ref2$fieldName = _ref2.fieldName,
644
- fieldName = _ref2$fieldName === void 0 ? null : _ref2$fieldName,
645
- label = _ref2.label,
646
- _ref2$defaultValue = _ref2.defaultValue,
647
- defaultValue = _ref2$defaultValue === void 0 ? null : _ref2$defaultValue;
648
- return [].concat(_toConsumableArray(statesFields), _toConsumableArray(repeatable ? [{
471
+ const extraFields = states.reduce((statesFields, current) => {
472
+ const {
473
+ id,
474
+ fields = [],
475
+ repeatable = false,
476
+ fieldName = null,
477
+ label,
478
+ defaultValue = null
479
+ } = current || {};
480
+ return [...statesFields, ...(repeatable ? [{
649
481
  type: 'items',
650
482
  name: fieldName || id,
651
- label: label,
652
- defaultValue: defaultValue,
483
+ label,
484
+ defaultValue,
653
485
  stateId: id,
654
486
  itemsField: {
655
- label: label,
487
+ label,
656
488
  type: 'fields',
657
- fields: fields
489
+ fields
658
490
  }
659
- }] : []), _toConsumableArray(!repeatable && fieldName !== null ? [{
491
+ }] : []), ...(!repeatable && fieldName !== null ? [{
660
492
  type: 'fields',
661
493
  name: fieldName,
662
494
  stateId: id,
663
- fields: fields
664
- }] : []), _toConsumableArray(!repeatable && fieldName === null ? fields.map(function (it) {
665
- return _objectSpread(_objectSpread({}, it), {}, {
666
- stateId: id
667
- });
668
- }) : []));
495
+ fields
496
+ }] : []), ...(!repeatable && fieldName === null ? fields.map(it => ({
497
+ ...it,
498
+ stateId: id
499
+ })) : [])];
669
500
  }, []);
670
- return [].concat(_toConsumableArray(extraFields), _toConsumableArray(screenFields));
501
+ return [...extraFields, ...screenFields];
671
502
  }
672
503
 
673
504
  function getShadowCoords(angle, distance) {
674
- var x = (Math.cos(angle) * distance).toFixed(3);
675
- var y = (Math.sin(angle) * distance).toFixed(3);
505
+ const x = (Math.cos(angle) * distance).toFixed(3);
506
+ const y = (Math.sin(angle) * distance).toFixed(3);
676
507
  return {
677
- x: x,
678
- y: y
508
+ x,
509
+ y
679
510
  };
680
511
  }
681
512
 
@@ -691,18 +522,16 @@ function getAlignItems(vertical) {
691
522
  if (vertical === 'bottom') return 'flex-end';
692
523
  return null;
693
524
  }
694
- var getStyleFromAlignment = function getStyleFromAlignment(value) {
695
- var invertAxis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
696
- var defaultAlignment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
525
+ const getStyleFromAlignment = (value, invertAxis = false, defaultAlignment = null) => {
697
526
  if (value === null) {
698
527
  return null;
699
528
  }
700
- var _value$horizontal = value.horizontal,
701
- horizontal = _value$horizontal === void 0 ? null : _value$horizontal,
702
- _value$vertical = value.vertical,
703
- vertical = _value$vertical === void 0 ? null : _value$vertical;
704
- var justifyContent = getJustifyContent(horizontal);
705
- var alignItems = getAlignItems(vertical);
529
+ const {
530
+ horizontal = null,
531
+ vertical = null
532
+ } = value;
533
+ const justifyContent = getJustifyContent(horizontal);
534
+ const alignItems = getAlignItems(vertical);
706
535
  if (invertAxis) {
707
536
  return {
708
537
  justifyContent: alignItems || defaultAlignment,
@@ -715,417 +544,419 @@ var getStyleFromAlignment = function getStyleFromAlignment(value) {
715
544
  };
716
545
  };
717
546
 
718
- var getStyleFromColor = function getStyleFromColor() {
719
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
720
- var property = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'backgroundColor';
721
- var overideAlpha = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
722
- var color = getColorAsString(value, overideAlpha);
723
- return color !== null ? _defineProperty({}, property, color) : null;
547
+ const getStyleFromColor = (value = null, property = 'backgroundColor', overideAlpha = null) => {
548
+ const color = getColorAsString(value, overideAlpha);
549
+ return color !== null ? {
550
+ [property]: color
551
+ } : null;
724
552
  };
725
553
 
726
- var getStyleFromBorder = function getStyleFromBorder(value) {
554
+ const getStyleFromBorder = value => {
727
555
  if (value == null) {
728
556
  return null;
729
557
  }
730
- var _value$width = value.width,
731
- width = _value$width === void 0 ? null : _value$width,
732
- _value$style = value.style,
733
- borderStyle = _value$style === void 0 ? null : _value$style,
734
- _value$color = value.color,
735
- color = _value$color === void 0 ? null : _value$color;
736
- return _objectSpread(_objectSpread(_objectSpread({}, width !== null ? {
737
- borderWidth: width
738
- } : null), borderStyle !== null ? {
739
- borderStyle: borderStyle
740
- } : null), getStyleFromColor(color, 'borderColor'));
558
+ const {
559
+ width = null,
560
+ style: borderStyle = null,
561
+ color = null
562
+ } = value;
563
+ return {
564
+ ...(width !== null ? {
565
+ borderWidth: width
566
+ } : null),
567
+ ...(borderStyle !== null ? {
568
+ borderStyle
569
+ } : null),
570
+ ...getStyleFromColor(color, 'borderColor')
571
+ };
741
572
  };
742
573
 
743
- var getStyleFromShadow = function getStyleFromShadow(value) {
574
+ const getStyleFromShadow = value => {
744
575
  if (value == null) {
745
576
  return null;
746
577
  }
747
- var _ref = value || {},
748
- _ref$shadowAngle = _ref.shadowAngle,
749
- shadowAngle = _ref$shadowAngle === void 0 ? null : _ref$shadowAngle,
750
- _ref$shadowDistance = _ref.shadowDistance,
751
- shadowDistance = _ref$shadowDistance === void 0 ? null : _ref$shadowDistance,
752
- _ref$shadowBlur = _ref.shadowBlur,
753
- shadowBlur = _ref$shadowBlur === void 0 ? null : _ref$shadowBlur,
754
- _ref$shadowColor = _ref.shadowColor,
755
- shadowColor = _ref$shadowColor === void 0 ? null : _ref$shadowColor;
578
+ const {
579
+ shadowAngle = null,
580
+ shadowDistance = null,
581
+ shadowBlur = null,
582
+ shadowColor = null
583
+ } = value || {};
756
584
  if (!shadowAngle) return null;
757
- var blur = shadowBlur || '0';
758
- var color = getColorAsString(shadowColor) || '#000000';
759
- var _getShadowCoords = getShadowCoords(shadowAngle, shadowDistance),
760
- x = _getShadowCoords.x,
761
- y = _getShadowCoords.y;
762
- var boxShadow = "".concat(x, "px ").concat(y, "px ").concat(blur, "px 0 ").concat(color);
585
+ const blur = shadowBlur || '0';
586
+ const color = getColorAsString(shadowColor) || '#000000';
587
+ const {
588
+ x,
589
+ y
590
+ } = getShadowCoords(shadowAngle, shadowDistance);
591
+ const boxShadow = `${x}px ${y}px ${blur}px 0 ${color}`;
763
592
  return {
764
- boxShadow: boxShadow
593
+ boxShadow
765
594
  };
766
595
  };
767
596
 
768
597
  // @todo hmm, gotta find a better way to handle this
769
- var getStyleFromBox = function getStyleFromBox(value) {
598
+ const getStyleFromBox = value => {
770
599
  if (value === null) {
771
600
  return null;
772
601
  }
773
- var _value$backgroundColo = value.backgroundColor,
774
- backgroundColor = _value$backgroundColo === void 0 ? null : _value$backgroundColo,
775
- _value$borderRadius = value.borderRadius,
776
- borderRadius = _value$borderRadius === void 0 ? null : _value$borderRadius,
777
- _value$padding = value.padding,
778
- padding = _value$padding === void 0 ? null : _value$padding,
779
- _value$paddingTop = value.paddingTop,
780
- paddingTop = _value$paddingTop === void 0 ? null : _value$paddingTop,
781
- _value$paddingRight = value.paddingRight,
782
- paddingRight = _value$paddingRight === void 0 ? null : _value$paddingRight,
783
- _value$paddingBottom = value.paddingBottom,
784
- paddingBottom = _value$paddingBottom === void 0 ? null : _value$paddingBottom,
785
- _value$paddingLeft = value.paddingLeft,
786
- paddingLeft = _value$paddingLeft === void 0 ? null : _value$paddingLeft,
787
- _value$borderWidth = value.borderWidth,
788
- borderWidth = _value$borderWidth === void 0 ? null : _value$borderWidth,
789
- _value$borderStyle = value.borderStyle,
790
- borderStyle = _value$borderStyle === void 0 ? null : _value$borderStyle,
791
- _value$borderColor = value.borderColor,
792
- borderColor = _value$borderColor === void 0 ? null : _value$borderColor,
793
- _value$shadowAngle = value.shadowAngle,
794
- shadowAngle = _value$shadowAngle === void 0 ? null : _value$shadowAngle,
795
- _value$shadowDistance = value.shadowDistance,
796
- shadowDistance = _value$shadowDistance === void 0 ? null : _value$shadowDistance,
797
- _value$shadowBlur = value.shadowBlur,
798
- shadowBlur = _value$shadowBlur === void 0 ? null : _value$shadowBlur,
799
- _value$shadowColor = value.shadowColor,
800
- shadowColor = _value$shadowColor === void 0 ? null : _value$shadowColor;
801
- var border = {
602
+ const {
603
+ backgroundColor = null,
604
+ borderRadius = null,
605
+ padding = null,
606
+ paddingTop = null,
607
+ paddingRight = null,
608
+ paddingBottom = null,
609
+ paddingLeft = null,
610
+ borderWidth = null,
611
+ borderStyle = null,
612
+ borderColor = null,
613
+ shadowAngle = null,
614
+ shadowDistance = null,
615
+ shadowBlur = null,
616
+ shadowColor = null
617
+ } = value;
618
+ const border = {
802
619
  width: borderWidth,
803
620
  style: borderStyle,
804
621
  color: borderColor
805
622
  };
806
- var shadow = {
807
- shadowAngle: shadowAngle,
808
- shadowDistance: shadowDistance,
809
- shadowBlur: shadowBlur,
810
- shadowColor: shadowColor
623
+ const shadow = {
624
+ shadowAngle,
625
+ shadowDistance,
626
+ shadowBlur,
627
+ shadowColor
811
628
  };
812
- var _ref = isObject(padding) ? padding : {
813
- padding: padding
814
- },
815
- _ref$top = _ref.top,
816
- paddingValueTop = _ref$top === void 0 ? null : _ref$top,
817
- _ref$right = _ref.right,
818
- paddingValueRight = _ref$right === void 0 ? null : _ref$right,
819
- _ref$bottom = _ref.bottom,
820
- paddingValueBottom = _ref$bottom === void 0 ? null : _ref$bottom,
821
- _ref$left = _ref.left,
822
- paddingValueLeft = _ref$left === void 0 ? null : _ref$left,
823
- _ref$padding = _ref.padding,
824
- paddingValue = _ref$padding === void 0 ? null : _ref$padding;
825
- var basePadding = padding || paddingValue;
826
- var hasBasePadding = basePadding !== null;
827
- var topVal = paddingTop || paddingValueTop;
828
- var rightVal = paddingRight || paddingValueRight;
829
- var bottomVal = paddingBottom || paddingValueBottom;
830
- var leftVal = paddingLeft || paddingValueLeft;
831
- var hasAnyIndividual = topVal !== null || rightVal !== null || bottomVal !== null || leftVal !== null;
629
+ const {
630
+ top: paddingValueTop = null,
631
+ right: paddingValueRight = null,
632
+ bottom: paddingValueBottom = null,
633
+ left: paddingValueLeft = null,
634
+ padding: paddingValue = null
635
+ } = isObject(padding) ? padding : {
636
+ padding
637
+ };
638
+ const basePadding = padding || paddingValue;
639
+ const hasBasePadding = basePadding !== null;
640
+ const topVal = paddingTop || paddingValueTop;
641
+ const rightVal = paddingRight || paddingValueRight;
642
+ const bottomVal = paddingBottom || paddingValueBottom;
643
+ const leftVal = paddingLeft || paddingValueLeft;
644
+ const hasAnyIndividual = topVal !== null || rightVal !== null || bottomVal !== null || leftVal !== null;
832
645
 
833
646
  // Avoid mixing shorthand `padding` with longhand `paddingTop`/etc — React warns about this
834
- var paddingStyles = hasBasePadding && hasAnyIndividual ? {
835
- paddingTop: topVal !== null && topVal !== void 0 ? topVal : basePadding,
836
- paddingRight: rightVal !== null && rightVal !== void 0 ? rightVal : basePadding,
837
- paddingBottom: bottomVal !== null && bottomVal !== void 0 ? bottomVal : basePadding,
838
- paddingLeft: leftVal !== null && leftVal !== void 0 ? leftVal : basePadding
839
- } : _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, hasBasePadding ? {
840
- padding: basePadding
841
- } : null), topVal !== null ? {
842
- paddingTop: topVal
843
- } : null), rightVal !== null ? {
844
- paddingRight: rightVal
845
- } : null), bottomVal !== null ? {
846
- paddingBottom: bottomVal
847
- } : null), leftVal !== null ? {
848
- paddingLeft: leftVal
849
- } : null);
850
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getStyleFromColor(backgroundColor, 'backgroundColor')), borderRadius !== null ? {
851
- borderRadius: borderRadius
852
- } : null), getStyleFromBorder(border)), getStyleFromShadow(shadow)), paddingStyles);
647
+ const paddingStyles = hasBasePadding && hasAnyIndividual ? {
648
+ paddingTop: topVal ?? basePadding,
649
+ paddingRight: rightVal ?? basePadding,
650
+ paddingBottom: bottomVal ?? basePadding,
651
+ paddingLeft: leftVal ?? basePadding
652
+ } : {
653
+ ...(hasBasePadding ? {
654
+ padding: basePadding
655
+ } : null),
656
+ ...(topVal !== null ? {
657
+ paddingTop: topVal
658
+ } : null),
659
+ ...(rightVal !== null ? {
660
+ paddingRight: rightVal
661
+ } : null),
662
+ ...(bottomVal !== null ? {
663
+ paddingBottom: bottomVal
664
+ } : null),
665
+ ...(leftVal !== null ? {
666
+ paddingLeft: leftVal
667
+ } : null)
668
+ };
669
+ return {
670
+ ...getStyleFromColor(backgroundColor, 'backgroundColor'),
671
+ ...(borderRadius !== null ? {
672
+ borderRadius
673
+ } : null),
674
+ ...getStyleFromBorder(border),
675
+ ...getStyleFromShadow(shadow),
676
+ ...paddingStyles
677
+ };
853
678
  };
854
679
 
855
- var getStyleFromContainer = function getStyleFromContainer(value) {
680
+ const getStyleFromContainer = value => {
856
681
  if (value == null) {
857
682
  return null;
858
683
  }
859
- var _value$size = value.size,
860
- size = _value$size === void 0 ? {} : _value$size,
861
- _value$backgroundColo = value.backgroundColor,
862
- backgroundColor = _value$backgroundColo === void 0 ? null : _value$backgroundColo;
863
- var _size$width = size.width,
864
- width = _size$width === void 0 ? null : _size$width,
865
- _size$height = size.height,
866
- height = _size$height === void 0 ? null : _size$height;
867
- return _objectSpread(_objectSpread(_objectSpread({}, width ? {
868
- width: "".concat(width, "%")
869
- } : null), height ? {
870
- height: "".concat(height, "%")
871
- } : null), getStyleFromColor(backgroundColor, 'backgroundColor'));
684
+ const {
685
+ size = {},
686
+ backgroundColor = null
687
+ } = value;
688
+ const {
689
+ width = null,
690
+ height = null
691
+ } = size;
692
+ return {
693
+ // DO NOT OVERRIDE
694
+ ...(width ? {
695
+ width: `${width}%`
696
+ } : null),
697
+ ...(height ? {
698
+ height: `${height}%`
699
+ } : null),
700
+ ...getStyleFromColor(backgroundColor, 'backgroundColor')
701
+ };
872
702
  };
873
703
 
874
- var getStyleFromHighlight = function getStyleFromHighlight(value) {
704
+ const getStyleFromHighlight = value => {
875
705
  if (value == null) {
876
706
  return null;
877
707
  }
878
- var _value$textColor = value.textColor,
879
- textColor = _value$textColor === void 0 ? null : _value$textColor,
880
- _value$color = value.color,
881
- color = _value$color === void 0 ? null : _value$color;
882
- var colorString = color !== null ? getColorAsString(color) : null;
883
- var boxShadow = colorString !== null ? "0.05em 0px 0px ".concat(colorString, ", -0.05em 0px 0px ").concat(colorString) : null;
884
- return color !== null || textColor !== null ? _objectSpread(_objectSpread(_objectSpread({}, color !== null ? getStyleFromColor(color, 'backgroundColor') : null), textColor !== null ? getStyleFromColor(textColor, 'color') : null), color !== null ? {
885
- boxShadow: boxShadow,
886
- mozBoxShadow: boxShadow,
887
- msBoxShadow: boxShadow,
888
- webkitBoxShadow: boxShadow
889
- } : null) : null;
708
+ const {
709
+ textColor = null,
710
+ color = null
711
+ } = value;
712
+ const colorString = color !== null ? getColorAsString(color) : null;
713
+ const boxShadow = colorString !== null ? `0.05em 0px 0px ${colorString}, -0.05em 0px 0px ${colorString}` : null;
714
+ return color !== null || textColor !== null ? {
715
+ ...(color !== null ? getStyleFromColor(color, 'backgroundColor') : null),
716
+ ...(textColor !== null ? getStyleFromColor(textColor, 'color') : null),
717
+ ...(color !== null ? {
718
+ boxShadow,
719
+ mozBoxShadow: boxShadow,
720
+ msBoxShadow: boxShadow,
721
+ webkitBoxShadow: boxShadow
722
+ } : null)
723
+ } : null;
890
724
  };
891
725
 
892
- var getStyleFromImage = function getStyleFromImage(value) {
726
+ const getStyleFromImage = value => {
893
727
  if (value == null) {
894
728
  return null;
895
729
  }
896
- var _value$fit = value.fit,
897
- fit = _value$fit === void 0 ? {} : _value$fit,
898
- _value$backgroundColo = value.backgroundColor,
899
- backgroundColor = _value$backgroundColo === void 0 ? null : _value$backgroundColo;
900
- var _fit$size = fit.size,
901
- size = _fit$size === void 0 ? null : _fit$size,
902
- _fit$position = fit.position,
903
- position = _fit$position === void 0 ? {} : _fit$position;
904
- var _position$axisAlign = position.axisAlign,
905
- axisAlign = _position$axisAlign === void 0 ? null : _position$axisAlign,
906
- _position$crossAlign = position.crossAlign,
907
- crossAlign = _position$crossAlign === void 0 ? null : _position$crossAlign;
908
- return _objectSpread(_objectSpread(_objectSpread({}, size !== null ? {
909
- objectFit: size
910
- } : null), axisAlign !== null && crossAlign !== null ? {
911
- objectPosition: "".concat(axisAlign, " ").concat(crossAlign)
912
- } : null), getStyleFromColor(backgroundColor, 'backgroundColor'));
730
+ const {
731
+ fit = {},
732
+ backgroundColor = null
733
+ } = value;
734
+ const {
735
+ size = null,
736
+ position = {}
737
+ } = fit;
738
+ const {
739
+ axisAlign = null,
740
+ crossAlign = null
741
+ } = position;
742
+ return {
743
+ ...(size !== null ? {
744
+ objectFit: size
745
+ } : null),
746
+ ...(axisAlign !== null && crossAlign !== null ? {
747
+ objectPosition: `${axisAlign} ${crossAlign}`
748
+ } : null),
749
+ ...getStyleFromColor(backgroundColor, 'backgroundColor')
750
+ };
913
751
  };
914
752
 
915
- var getStyleFromLink = function getStyleFromLink(value) {
753
+ const getStyleFromLink = value => {
916
754
  if (value == null) {
917
755
  return null;
918
756
  }
919
- var _value$color = value.color,
920
- color = _value$color === void 0 ? null : _value$color,
921
- fontStyle = value.fontStyle;
922
- var _ref = fontStyle || {},
923
- _ref$italic = _ref.italic,
924
- italic = _ref$italic === void 0 ? false : _ref$italic,
925
- _ref$bold = _ref.bold,
926
- bold = _ref$bold === void 0 ? false : _ref$bold,
927
- _ref$underline = _ref.underline,
928
- underline = _ref$underline === void 0 ? false : _ref$underline;
929
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, color !== null ? getStyleFromColor(color, 'color') : null), italic ? {
930
- fontStyle: 'italic'
931
- } : null), bold ? {
932
- fontWeight: 'bold'
933
- } : null), underline ? {
934
- textDecoration: 'underline'
935
- } : null);
757
+ const {
758
+ color = null,
759
+ fontStyle
760
+ } = value;
761
+ const {
762
+ italic = false,
763
+ bold = false,
764
+ underline = false
765
+ } = fontStyle || {};
766
+ return {
767
+ ...(color !== null ? getStyleFromColor(color, 'color') : null),
768
+ ...(italic ? {
769
+ fontStyle: 'italic'
770
+ } : null),
771
+ ...(bold ? {
772
+ fontWeight: 'bold'
773
+ } : null),
774
+ ...(underline ? {
775
+ textDecoration: 'underline'
776
+ } : null)
777
+ };
936
778
  };
937
779
 
938
- var getStyleFromText = function getStyleFromText(value) {
780
+ const getStyleFromText = value => {
939
781
  if (value == null) {
940
782
  return null;
941
783
  }
942
- var _value$fontFamily = value.fontFamily,
943
- fontFamily = _value$fontFamily === void 0 ? null : _value$fontFamily,
944
- _value$fontSize = value.fontSize,
945
- fontSize = _value$fontSize === void 0 ? null : _value$fontSize,
946
- _value$fontStyle = value.fontStyle,
947
- fontStyle = _value$fontStyle === void 0 ? null : _value$fontStyle,
948
- _value$fontWeight = value.fontWeight,
949
- fontWeight = _value$fontWeight === void 0 ? null : _value$fontWeight,
950
- _value$lineHeight = value.lineHeight,
951
- lineHeight = _value$lineHeight === void 0 ? null : _value$lineHeight,
952
- _value$letterSpacing = value.letterSpacing,
953
- letterSpacing = _value$letterSpacing === void 0 ? null : _value$letterSpacing,
954
- _value$align = value.align,
955
- textAlign = _value$align === void 0 ? null : _value$align,
956
- _value$color = value.color,
957
- color = _value$color === void 0 ? null : _value$color;
958
- var _ref = fontStyle || {},
959
- _ref$italic = _ref.italic,
960
- italic = _ref$italic === void 0 ? false : _ref$italic,
961
- _ref$bold = _ref.bold,
962
- bold = _ref$bold === void 0 ? false : _ref$bold,
963
- _ref$underline = _ref.underline,
964
- underline = _ref$underline === void 0 ? false : _ref$underline,
965
- _ref$transform = _ref.transform,
966
- textTransform = _ref$transform === void 0 ? null : _ref$transform,
967
- _ref$outline = _ref.outline,
968
- outline = _ref$outline === void 0 ? false : _ref$outline;
969
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
970
- fontFamily: getFontFamily(fontFamily)
971
- }, fontSize !== null ? {
972
- fontSize: fontSize
973
- } : null), italic ? {
974
- fontStyle: 'italic'
975
- } : null), bold ? {
976
- fontWeight: 'bold'
977
- } : null), fontWeight !== null ? {
978
- fontWeight: fontWeight
979
- } : null), underline ? {
980
- textDecoration: 'underline'
981
- } : null), textTransform !== null ? {
982
- textTransform: textTransform
983
- } : null), textAlign !== null ? {
984
- textAlign: textAlign
985
- } : null), lineHeight !== null ? {
986
- lineHeight: lineHeight
987
- } : null), letterSpacing !== null ? {
988
- letterSpacing: letterSpacing
989
- } : null), getStyleFromColor(color, 'color')), outline ? {
990
- WebkitTextStroke: "2px ".concat(getColorAsString(color, 'color')),
991
- color: 'transparent'
992
- } : null);
784
+ const {
785
+ fontFamily = null,
786
+ fontSize = null,
787
+ fontStyle = null,
788
+ fontWeight = null,
789
+ lineHeight = null,
790
+ letterSpacing = null,
791
+ align: textAlign = null,
792
+ color = null
793
+ } = value;
794
+ const {
795
+ italic = false,
796
+ bold = false,
797
+ underline = false,
798
+ transform: textTransform = null,
799
+ outline = false
800
+ } = fontStyle || {};
801
+ return {
802
+ fontFamily: getFontFamily(fontFamily),
803
+ ...(fontSize !== null ? {
804
+ fontSize
805
+ } : null),
806
+ ...(italic ? {
807
+ fontStyle: 'italic'
808
+ } : null),
809
+ ...(bold ? {
810
+ fontWeight: 'bold'
811
+ } : null),
812
+ ...(fontWeight !== null ? {
813
+ fontWeight
814
+ } : null),
815
+ ...(underline ? {
816
+ textDecoration: 'underline'
817
+ } : null),
818
+ ...(textTransform !== null ? {
819
+ textTransform
820
+ } : null),
821
+ ...(textAlign !== null ? {
822
+ textAlign
823
+ } : null),
824
+ ...(lineHeight !== null ? {
825
+ lineHeight
826
+ } : null),
827
+ ...(letterSpacing !== null ? {
828
+ letterSpacing
829
+ } : null),
830
+ ...getStyleFromColor(color, 'color'),
831
+ ...(outline ? {
832
+ WebkitTextStroke: `2px ${getColorAsString(color, 'color')}`,
833
+ color: 'transparent'
834
+ } : null)
835
+ };
993
836
  };
994
837
 
995
- var getStyleFromMargin = function getStyleFromMargin(value) {
838
+ const getStyleFromMargin = value => {
996
839
  if (value == null) {
997
840
  return null;
998
841
  }
999
- var _value$top = value.top,
1000
- marginTop = _value$top === void 0 ? null : _value$top,
1001
- _value$bottom = value.bottom,
1002
- marginBottom = _value$bottom === void 0 ? null : _value$bottom;
1003
- return _objectSpread(_objectSpread({}, marginTop !== null ? {
1004
- marginTop: marginTop
1005
- } : null), marginBottom !== null ? {
1006
- marginBottom: marginBottom
1007
- } : null);
842
+ const {
843
+ top: marginTop = null,
844
+ bottom: marginBottom = null
845
+ } = value;
846
+ return {
847
+ ...(marginTop !== null ? {
848
+ marginTop
849
+ } : null),
850
+ ...(marginBottom !== null ? {
851
+ marginBottom
852
+ } : null)
853
+ };
1008
854
  };
1009
855
 
1010
856
  // const possibleMimes = ['video/webm', 'video/mp4', 'video/ogg', 'application/vnd.apple.mpegurl'];
1011
- var possibleMimes = ['video/mp4'];
1012
- var supportedMimes = null;
1013
- function getVideoSupportedMimes() {
1014
- var mimes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : possibleMimes;
857
+ const possibleMimes = ['video/mp4'];
858
+ let supportedMimes = null;
859
+ function getVideoSupportedMimes(mimes = possibleMimes) {
1015
860
  if (supportedMimes === null) {
1016
- var video = document.createElement('video');
1017
- supportedMimes = (mimes || possibleMimes).filter(function (mime) {
1018
- return video.canPlayType(mime) !== '';
1019
- });
861
+ const video = document.createElement('video');
862
+ supportedMimes = (mimes || possibleMimes).filter(mime => video.canPlayType(mime) !== '');
1020
863
  }
1021
864
  return supportedMimes;
1022
865
  }
1023
866
 
1024
- var getLayoutParts = function getLayoutParts() {
1025
- var layout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1026
- var _ref = layout !== null && layout.indexOf('-') !== false ? layout.split('-') : [layout, null, null],
1027
- _ref2 = _slicedToArray(_ref, 3),
1028
- horizontal = _ref2[0],
1029
- vertical = _ref2[1],
1030
- suffix = _ref2[2];
867
+ const getLayoutParts = (layout = null) => {
868
+ const [horizontal, vertical, suffix] = layout !== null && layout.indexOf('-') !== false ? layout.split('-') : [layout, null, null];
1031
869
  return {
1032
- horizontal: horizontal,
1033
- vertical: vertical,
1034
- suffix: suffix
870
+ horizontal,
871
+ vertical,
872
+ suffix
1035
873
  };
1036
874
  };
1037
875
 
1038
- var isHeaderFilled = function isHeaderFilled() {
1039
- var header = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
876
+ const isHeaderFilled = (header = {}) => {
1040
877
  if (header === null || typeof header === 'undefined') {
1041
878
  return false;
1042
879
  }
1043
- var _ref = header || {},
1044
- _ref$badge = _ref.badge,
1045
- badge = _ref$badge === void 0 ? null : _ref$badge;
1046
- var _ref2 = badge || {},
1047
- _ref2$active = _ref2.active,
1048
- badgeActive = _ref2$active === void 0 ? false : _ref2$active,
1049
- _ref2$label = _ref2.label,
1050
- label = _ref2$label === void 0 ? null : _ref2$label;
1051
- var _ref3 = label || {},
1052
- _ref3$body = _ref3.body,
1053
- body = _ref3$body === void 0 ? null : _ref3$body;
880
+ const {
881
+ badge = null
882
+ } = header || {};
883
+ const {
884
+ active: badgeActive = false,
885
+ label = null
886
+ } = badge || {};
887
+ const {
888
+ body = null
889
+ } = label || {};
1054
890
  return badgeActive && body !== null;
1055
891
  };
1056
892
 
1057
- var isFooterFilled = function isFooterFilled() {
1058
- var footer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
893
+ const isFooterFilled = (footer = {}) => {
1059
894
  if (footer === null || typeof footer === 'undefined') {
1060
895
  return false;
1061
896
  }
1062
- var _ref = footer || {},
1063
- _ref$callToAction = _ref.callToAction,
1064
- callToAction = _ref$callToAction === void 0 ? null : _ref$callToAction;
1065
- var _ref2 = callToAction || {},
1066
- _ref2$active = _ref2.active,
1067
- callToActionActive = _ref2$active === void 0 ? false : _ref2$active,
1068
- _ref2$label = _ref2.label,
1069
- label = _ref2$label === void 0 ? null : _ref2$label;
1070
- var _ref3 = label || {},
1071
- _ref3$body = _ref3.body,
1072
- body = _ref3$body === void 0 ? null : _ref3$body;
897
+ const {
898
+ callToAction = null
899
+ } = footer || {};
900
+ const {
901
+ active: callToActionActive = false,
902
+ label = null
903
+ } = callToAction || {};
904
+ const {
905
+ body = null
906
+ } = label || {};
1073
907
  return callToActionActive && body !== null;
1074
908
  };
1075
909
 
1076
- var isMessage = function isMessage(message) {
1077
- return isObject(message) && typeof message.defaultMessage !== 'undefined';
1078
- };
910
+ function isMessage(message) {
911
+ return message !== null && isObject(message) && typeof message.id !== 'undefined';
912
+ }
1079
913
 
1080
- var isIos = function isIos() {
1081
- return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
1082
- // iPad on iOS 13 detection
1083
- navigator.userAgent.includes('Mac') && 'ontouchend' in document;
1084
- };
914
+ const isIos = () => ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
915
+ // iPad on iOS 13 detection
916
+ navigator.userAgent.includes('Mac') && 'ontouchend' in document;
1085
917
 
1086
- var isImageFilled = function isImageFilled(image) {
918
+ const isImageFilled = image => {
1087
919
  if (image === null || typeof image === 'undefined') {
1088
920
  return false;
1089
921
  }
1090
- var _ref = image || {},
1091
- _ref$media = _ref.media,
1092
- media = _ref$media === void 0 ? null : _ref$media,
1093
- _ref$url = _ref.url,
1094
- url = _ref$url === void 0 ? null : _ref$url;
922
+ const {
923
+ media = null,
924
+ url = null
925
+ } = image || {};
1095
926
  return media !== null || url !== null;
1096
927
  };
1097
928
 
1098
- var isTextFilled$1 = function isTextFilled(text) {
929
+ const isTextFilled$1 = text => {
1099
930
  if (text === null || typeof text === 'undefined') {
1100
931
  return false;
1101
932
  }
1102
- var _ref = text || {},
1103
- _ref$label = _ref.label,
1104
- label = _ref$label === void 0 ? null : _ref$label;
1105
- var _ref2 = label || {},
1106
- _ref2$length = _ref2.length,
1107
- length = _ref2$length === void 0 ? 0 : _ref2$length;
933
+ const {
934
+ label = null
935
+ } = text || {};
936
+ const {
937
+ length = 0
938
+ } = label || {};
1108
939
  return typeof length === 'number' && length > 0;
1109
940
  };
1110
941
 
1111
- var isTextFilled = function isTextFilled(text) {
942
+ const isTextFilled = text => {
1112
943
  if (text === null || typeof text === 'undefined') {
1113
944
  return false;
1114
945
  }
1115
- var _ref = text || {},
1116
- _ref$body = _ref.body,
1117
- body = _ref$body === void 0 ? null : _ref$body;
1118
- var _ref2 = body || {},
1119
- _ref2$length = _ref2.length,
1120
- length = _ref2$length === void 0 ? 0 : _ref2$length;
946
+ const {
947
+ body = null
948
+ } = text || {};
949
+ const {
950
+ length = 0
951
+ } = body || {};
1121
952
  return typeof length === 'number' && length > 0;
1122
953
  };
1123
954
 
1124
- var isValidUrl = function isValidUrl(string) {
955
+ const isValidUrl = string => {
1125
956
  if (string === null || typeof string === 'undefined') {
1126
957
  return false;
1127
958
  }
1128
- var url;
959
+ let url;
1129
960
  try {
1130
961
  url = new URL(string);
1131
962
  } catch (_) {
@@ -1134,20 +965,28 @@ var isValidUrl = function isValidUrl(string) {
1134
965
  return url.protocol === 'http:' || url.protocol === 'https:';
1135
966
  };
1136
967
 
1137
- var createSchemaId = function createSchemaId(id) {
1138
- return "https://schemas.micromag.ca/0.1/".concat(id, ".json");
1139
- };
968
+ function mergeRefs(...refs) {
969
+ return value => {
970
+ refs.forEach(ref => {
971
+ if (typeof ref === 'function') {
972
+ ref(value);
973
+ } else if (ref != null) {
974
+ ref.current = value;
975
+ }
976
+ });
977
+ };
978
+ }
1140
979
 
1141
- var schemaId = function schemaId(str) {
1142
- return createSchemaId(str.join('/'));
1143
- };
980
+ const createSchemaId = id => `https://schemas.micromag.ca/0.1/${id}.json`;
1144
981
 
1145
- var _setValue = function setValue(value, keyParts, fieldValue) {
1146
- var key = keyParts.shift();
1147
- var isArray = key.match(/^[0-9]+$/) !== null;
982
+ const schemaId = str => createSchemaId(str.join('/'));
983
+
984
+ const setValue = (value, keyParts, fieldValue) => {
985
+ const key = keyParts.shift();
986
+ const isArray = key.match(/^[0-9]+$/) !== null;
1148
987
  if (value !== null || fieldValue !== null) {
1149
988
  if (isArray) {
1150
- var index = parseInt(key, 10);
989
+ const index = parseInt(key, 10);
1151
990
  // TODO: fix this with an explicit delete
1152
991
  // instead on splicing out the element on null fieldValue
1153
992
  // const newArrayValue =
@@ -1165,17 +1004,19 @@ var _setValue = function setValue(value, keyParts, fieldValue) {
1165
1004
  // ]
1166
1005
  // : [...value.slice(0, index), ...value.slice(index + 1)];
1167
1006
 
1168
- var newArrayValue = [].concat(_toConsumableArray(value.slice(0, index)), [keyParts.length > 0 ? _setValue(value !== null ? value[index] || null : null, keyParts, fieldValue) : fieldValue], _toConsumableArray(value.slice(index + 1)));
1007
+ const newArrayValue = [...value.slice(0, index), keyParts.length > 0 ? setValue(value !== null ? value[index] || null : null, keyParts, fieldValue) : fieldValue, ...value.slice(index + 1)];
1169
1008
  return newArrayValue.length > 0 ? newArrayValue : null;
1170
1009
  }
1171
- return _objectSpread(_objectSpread({}, value), {}, _defineProperty({}, key, keyParts.length > 0 ? _setValue(value !== null ? value[key] || null : null, keyParts, fieldValue) : fieldValue));
1010
+ return {
1011
+ ...value,
1012
+ [key]: keyParts.length > 0 ? setValue(value !== null ? value[key] || null : null, keyParts, fieldValue) : fieldValue
1013
+ };
1172
1014
  }
1173
1015
  return null;
1174
1016
  };
1175
1017
 
1176
- var slug = function slug(str) {
1177
- var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1178
- var toSlug;
1018
+ const slug = (str, separator = null) => {
1019
+ let toSlug;
1179
1020
  if (separator === '-') {
1180
1021
  toSlug = kebabCase(str);
1181
1022
  } else {
@@ -1186,29 +1027,23 @@ var slug = function slug(str) {
1186
1027
  });
1187
1028
  };
1188
1029
 
1189
- var unique = function unique(arrArg) {
1190
- return arrArg !== null ? arrArg.filter(function (elem, pos, arr) {
1191
- return arr.indexOf(elem) === pos;
1192
- }) : [];
1193
- };
1030
+ const unique = arrArg => arrArg !== null ? arrArg.filter((elem, pos, arr) => arr.indexOf(elem) === pos) : [];
1194
1031
 
1195
- var _validateFields = function validateFields(fields, value) {
1196
- return fields.reduce(function (acc, field) {
1197
- if (acc === true) {
1198
- if (field.type === 'fields' && field.fields) {
1199
- return _validateFields(field.fields, value);
1200
- }
1201
- var val = value && value[field.name] ? value[field.name] : false;
1202
- return !(field.required && !val);
1032
+ const validateFields = (fields, value) => fields.reduce((acc, field) => {
1033
+ if (acc === true) {
1034
+ if (field.type === 'fields' && field.fields) {
1035
+ return validateFields(field.fields, value);
1203
1036
  }
1204
- return acc;
1205
- }, true);
1206
- };
1037
+ const val = value && value[field.name] ? value[field.name] : false;
1038
+ return !(field.required && !val);
1039
+ }
1040
+ return acc;
1041
+ }, true);
1207
1042
 
1208
- var getContrastingColor = function getContrastingColor(backgroundColor) {
1209
- var _ref = backgroundColor || {},
1210
- _ref$color = _ref.color,
1211
- color = _ref$color === void 0 ? 'white' : _ref$color;
1043
+ const getContrastingColor = backgroundColor => {
1044
+ const {
1045
+ color = 'white'
1046
+ } = backgroundColor || {};
1212
1047
  if (tinycolor.equals(color, tinycolor('white'))) {
1213
1048
  return '#A13DFF';
1214
1049
  }
@@ -1218,4 +1053,35 @@ var getContrastingColor = function getContrastingColor(backgroundColor) {
1218
1053
  return tinycolor(color).spin(30).toString();
1219
1054
  };
1220
1055
 
1221
- export { addNonBreakingSpaces, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, cssEscape, easings, getColorAsString, getComponentFromName, getContrastingColor, getDeviceScreens, getDisplayName, _getFieldByName as getFieldByName, getFieldFromPath, getFileName, getFontFamily as getFontFamilyFromFont, getFooterProps, getGridLayoutName, largestRemainderRound as getLargestRemainderRound, getLayersFromBackground, getLayoutParts, getMediaFilesAsArray, getOptimalImageUrl, getScreenExtraField, getScreenFieldsWithStates, getSecondsFromTime, getShadowCoords, getStyleFromAlignment, getStyleFromBorder, getStyleFromBox, getStyleFromColor, getStyleFromContainer, getStyleFromHighlight, getStyleFromImage, getStyleFromLink, getStyleFromMargin, getStyleFromText, getVideoSupportedMimes, isFooterFilled, isHeaderFilled, isImageFilled, isIos, isTextFilled$1 as isLabelFilled, isMessage, isTextFilled, isValidUrl, schemaId, _setValue as setFieldValue, slug, unique, _validateFields as validateFields };
1056
+ function getMediaCurrentTime(media, tsOffset = 0) {
1057
+ return media !== null ? Math.max((media?.currentTime || 0) - tsOffset, 0) : 0;
1058
+ }
1059
+ function getMediaDuration(media, tsOffset = 0) {
1060
+ return media !== null ? Math.max((media?.duration || 0) - tsOffset, 0) : 0;
1061
+ }
1062
+ function getMediaTimestampOffset(media, attributeName = 'data-ts-offset') {
1063
+ return media !== null && media.hasAttribute(attributeName) ? parseFloat(media.getAttribute(attributeName)) : 0;
1064
+ }
1065
+ function getMediaIsMuted(media) {
1066
+ return media !== null && (media.muted || media.volume === 0);
1067
+ }
1068
+ function getMediaIsPlaying(media) {
1069
+ return media !== null && !!(media.currentTime > 0 && !media.paused && !media.ended && media.readyState > 2);
1070
+ }
1071
+ function getMediaIsBuffering(media) {
1072
+ return media !== null && (media.networkState === media.NETWORK_LOADING || media.readyState < media.HAVE_FUTURE_DATA);
1073
+ }
1074
+ function getMediaIsReady(media) {
1075
+ return media !== null && media.readyState >= 0;
1076
+ }
1077
+ function getMediaSrc(media) {
1078
+ return media !== null ? media.currentSrc || media.src : null;
1079
+ }
1080
+ function getMediaHasAudio(media) {
1081
+ return media !== null && (media.tagName.toLowerCase() === 'audio' || media.dataset.hasAudio === 'true');
1082
+ }
1083
+ function getMediaFilename(src) {
1084
+ return src !== null ? src.split('/')[src.split('/').length - 1].split('#')[0] || null : null;
1085
+ }
1086
+
1087
+ export { addNonBreakingSpaces, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, cssEscape, easings, getColorAsString, getComponentFromName, getContrastingColor, getDeviceScreens, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getFontFamily as getFontFamilyFromFont, getFooterProps, getGridLayoutName, largestRemainderRound as getLargestRemainderRound, getLayersFromBackground, getLayoutParts, getMediaCurrentTime, getMediaDuration, getMediaFilename, getMediaFilesAsArray, getMediaHasAudio, getMediaIsBuffering, getMediaIsMuted, getMediaIsPlaying, getMediaIsReady, getMediaSrc, getMediaThumbnail, getMediaTimestampOffset, getOptimalImageUrl, getScreenExtraField, getScreenFieldsWithStates, getSecondsFromTime, getShadowCoords, getStyleFromAlignment, getStyleFromBorder, getStyleFromBox, getStyleFromColor, getStyleFromContainer, getStyleFromHighlight, getStyleFromImage, getStyleFromLink, getStyleFromMargin, getStyleFromText, getVideoSupportedMimes, isFooterFilled, isHeaderFilled, isImageFilled, isIos, isTextFilled$1 as isLabelFilled, isMessage, isTextFilled, isValidUrl, mergeRefs, schemaId, setValue as setFieldValue, slug, unique, validateFields };