@panneau/core 4.0.37 → 4.0.40-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hooks.js CHANGED
@@ -1,11 +1,7 @@
1
+ import { c } from 'react/compiler-runtime';
1
2
  import { useRef, useEffect, useCallback, useState, useMemo } from 'react';
2
3
  import { EventsManager, MediasParser } from '@panneau/core';
3
4
  import { createUseEvent, loadPackage } from '@panneau/core/utils';
4
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
5
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
7
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
8
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
9
5
  import { getCsrfToken, postJSON, getCSRFHeaders } from '@folklore/fetch';
10
6
  import get from 'lodash/get';
11
7
  import isArray from 'lodash/isArray';
@@ -16,221 +12,211 @@ import dayjs from 'dayjs';
16
12
  import { useIntl } from 'react-intl';
17
13
  import { match } from 'css-mediaquery';
18
14
 
19
- function useAnimationFrame(onFrame) {
20
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
21
- _ref$disabled = _ref.disabled,
22
- disabled = _ref$disabled === void 0 ? false : _ref$disabled;
23
- var requestRef = useRef(null);
24
- var startTimeRef = useRef(null);
25
- var _callback = function callback(time) {
26
- if (!startTimeRef.current) {
27
- startTimeRef.current = time;
28
- }
29
- var progress = time - startTimeRef.current;
30
- onFrame(progress);
31
- requestRef.current = requestAnimationFrame(_callback);
32
- };
33
- useEffect(function () {
34
- if (!disabled) {
35
- requestRef.current = requestAnimationFrame(_callback);
36
- }
37
- return function () {
38
- if (requestRef.current !== null) {
39
- cancelAnimationFrame(requestRef.current);
15
+ function useAnimationFrame(onFrame, t0) {
16
+ const $ = c(9);
17
+ let t1;
18
+ if ($[0] !== t0) {
19
+ t1 = t0 === undefined ? {} : t0;
20
+ $[0] = t0;
21
+ $[1] = t1;
22
+ } else {
23
+ t1 = $[1];
24
+ }
25
+ const {
26
+ disabled: t2
27
+ } = t1;
28
+ const disabled = t2 === undefined ? false : t2;
29
+ const requestRef = useRef(null);
30
+ const startTimeRef = useRef(null);
31
+ let callback;
32
+ if ($[2] !== onFrame) {
33
+ callback = time => {
34
+ if (!startTimeRef.current) {
35
+ startTimeRef.current = time;
36
+ }
37
+ const progress = time - startTimeRef.current;
38
+ onFrame(progress);
39
+ requestRef.current = requestAnimationFrame(callback);
40
+ };
41
+ $[2] = onFrame;
42
+ $[3] = callback;
43
+ } else {
44
+ callback = $[3];
45
+ }
46
+ let t3;
47
+ if ($[4] !== callback || $[5] !== disabled) {
48
+ t3 = () => {
49
+ if (!disabled) {
50
+ requestRef.current = requestAnimationFrame(callback);
40
51
  }
52
+ return () => {
53
+ if (requestRef.current !== null) {
54
+ cancelAnimationFrame(requestRef.current);
55
+ }
56
+ };
41
57
  };
42
- }, [disabled]);
58
+ $[4] = callback;
59
+ $[5] = disabled;
60
+ $[6] = t3;
61
+ } else {
62
+ t3 = $[6];
63
+ }
64
+ let t4;
65
+ if ($[7] !== disabled) {
66
+ t4 = [disabled];
67
+ $[7] = disabled;
68
+ $[8] = t4;
69
+ } else {
70
+ t4 = $[8];
71
+ }
72
+ useEffect(t3, t4);
43
73
  }
44
74
 
45
- function useFormattedDate() {
46
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
47
- _ref$format = _ref.format,
48
- format = _ref$format === void 0 ? null : _ref$format,
49
- _ref$showToday = _ref.showToday,
50
- showToday = _ref$showToday === void 0 ? true : _ref$showToday;
51
- var intl = useIntl();
52
- var today = dayjs();
53
- return useCallback(function (date) {
54
- var dateToFormat = isString(date) ? dayjs(date) : date;
75
+ function useFormattedDate({
76
+ format = null,
77
+ showToday = true
78
+ } = {}) {
79
+ const intl = useIntl();
80
+ const today = dayjs();
81
+ return useCallback(date => {
82
+ const dateToFormat = isString(date) ? dayjs(date) : date;
55
83
  if (showToday && dateToFormat.format('YYYY-MM-DD') === today.format('YYYY-MM-DD')) {
56
84
  return intl.formatMessage({
57
- "id": "v4Qtl9",
58
- "defaultMessage": [{
59
- "type": 0,
60
- "value": "Today"
61
- }]
85
+ id: "v4Qtl9"
62
86
  });
63
87
  }
64
- return intl.formatDate(dayjs(date).toDate(), _objectSpread({
88
+ return intl.formatDate(dayjs(date).toDate(), {
65
89
  year: 'numeric',
66
90
  month: 'long',
67
- day: '2-digit'
68
- }, format));
91
+ day: '2-digit',
92
+ ...format
93
+ });
69
94
  }, [today, showToday, format]);
70
95
  }
71
- function useFormattedTime() {
72
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
73
- _ref2$format = _ref2.format,
74
- format = _ref2$format === void 0 ? null : _ref2$format,
75
- _ref2$showNow = _ref2.showNow,
76
- showNow = _ref2$showNow === void 0 ? true : _ref2$showNow,
77
- _ref2$timeGap = _ref2.timeGap,
78
- timeGap = _ref2$timeGap === void 0 ? 2 : _ref2$timeGap;
79
- var intl = useIntl();
80
- var now = dayjs();
81
- return useCallback(function (date) {
82
- var dateToFormat = isString(date) ? dayjs(date) : date;
96
+ function useFormattedTime({
97
+ format = null,
98
+ showNow = true,
99
+ timeGap = 2
100
+ } = {}) {
101
+ const intl = useIntl();
102
+ const now = dayjs();
103
+ return useCallback(date => {
104
+ const dateToFormat = isString(date) ? dayjs(date) : date;
83
105
  if (showNow && dateToFormat.format('YYYY-MM-DD') === now.format('YYYY-MM-DD') && dateToFormat.hour() === now.hour() && dateToFormat.minute() > now.minute() - timeGap && dateToFormat.minute() < now.minute() + timeGap) {
84
106
  return intl.formatMessage({
85
- "id": "3na7F8",
86
- "defaultMessage": [{
87
- "type": 0,
88
- "value": "Now"
89
- }]
107
+ id: "3na7F8"
90
108
  });
91
109
  }
92
- return intl.formatTime(dateToFormat.toDate(), _objectSpread({
110
+ return intl.formatTime(dateToFormat.toDate(), {
93
111
  hour: 'numeric',
94
- minute: 'numeric'
95
- }, format));
112
+ minute: 'numeric',
113
+ ...format
114
+ });
96
115
  }, [now, showNow, timeGap, format]);
97
116
  }
98
117
 
99
- var eventsManager$1 = typeof document !== 'undefined' ? new EventsManager(document) : null;
100
- var useDocumentEvent = createUseEvent(eventsManager$1);
118
+ const eventsManager$1 = typeof document !== 'undefined' ? new EventsManager(document) : null;
119
+ const useDocumentEvent = createUseEvent(eventsManager$1);
101
120
 
102
- var _excluded$1 = ["value", "errors", "onChange"];
103
121
  // prettier-ignore
104
- function getFieldsPropsFromFields(fields, _ref) {
105
- var value = _ref.value,
106
- errors = _ref.errors,
107
- _onChange = _ref.onChange,
108
- props = _objectWithoutProperties(_ref, _excluded$1);
109
- var locales = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
110
- return (fields || []).reduce(function (allFields, field) {
111
- var _ref2 = isObject(field) ? field : {},
112
- _ref2$name = _ref2.name,
113
- name = _ref2$name === void 0 ? isString(field) ? field : null : _ref2$name,
114
- _ref2$fields = _ref2.fields,
115
- fieldFields = _ref2$fields === void 0 ? null : _ref2$fields,
116
- _ref2$component = _ref2.component,
117
- component = _ref2$component === void 0 ? null : _ref2$component;
118
- var fieldErrors = errors !== null ? errors[name] || [] : [];
119
- var finalErrors = component === 'localized' ? (locales || []).reduce(function (previousErrors, locale) {
120
- var items = errors !== null ? get(errors, "".concat(name, ".").concat(locale), []) || [] : [];
121
- var finalItems = isArray(items) ? items : [items];
122
- var finalPrevious = isArray(previousErrors) ? previousErrors : [];
123
- return [].concat(_toConsumableArray(finalPrevious), _toConsumableArray(finalItems));
122
+ function getFieldsPropsFromFields(fields, {
123
+ value,
124
+ errors,
125
+ onChange,
126
+ ...props
127
+ }, locales = []) {
128
+ return (fields || []).reduce((allFields, field) => {
129
+ const {
130
+ name = isString(field) ? field : null,
131
+ fields: fieldFields = null,
132
+ component = null
133
+ } = isObject(field) ? field : {};
134
+ const fieldErrors = errors !== null ? errors[name] || [] : [];
135
+ const finalErrors = component === 'localized' ? (locales || []).reduce((previousErrors, locale) => {
136
+ const items = errors !== null ? get(errors, `${name}.${locale}`, []) || [] : [];
137
+ const finalItems = isArray(items) ? items : [items];
138
+ const finalPrevious = isArray(previousErrors) ? previousErrors : [];
139
+ return [...finalPrevious, ...finalItems];
124
140
  }, fieldErrors) : fieldErrors;
125
- var subfieldErrors = errors;
141
+ let subfieldErrors = errors;
126
142
  if (errors !== null && name !== null) {
127
- subfieldErrors = Object.keys(errors).reduce(function (acc, key) {
143
+ subfieldErrors = Object.keys(errors).reduce((acc, key) => {
128
144
  if (key === name) {
129
145
  acc[key] = errors[key];
130
146
  }
131
- if (key.startsWith("".concat(name, ".")) || key.startsWith("".concat(name, "["))) {
132
- var finalKey = key.substring(name.length + 1);
147
+ if (key.startsWith(`${name}.`) || key.startsWith(`${name}[`)) {
148
+ const finalKey = key.substring(name.length + 1);
133
149
  acc[finalKey] = errors[key];
134
150
  }
135
151
  return acc;
136
152
  }, {});
137
153
  }
138
- return [].concat(_toConsumableArray(allFields), [_objectSpread(_objectSpread({}, isObject(field) ? field : null), {}, {
139
- name: name,
140
- component: component,
154
+ return [...allFields, {
155
+ ...(isObject(field) ? field : null),
156
+ name,
157
+ component,
141
158
  value: value !== null && name !== null ? value[name] || null : null,
142
159
  errors: finalErrors.length > 0 ? finalErrors : null,
143
- onChange: function onChange(fieldValue) {
144
- return _onChange(name, fieldValue);
145
- },
160
+ onChange: fieldValue => onChange(name, fieldValue),
146
161
  fields: fieldFields !== null && isArray(fieldFields) ? getFieldsPropsFromFields(fieldFields, {
147
162
  value: value !== null && name !== null && isObject(value[name]) ? value[name] : null,
148
163
  errors: subfieldErrors,
149
- onChange: _onChange
150
- }, locales) : null
151
- }, props)]);
164
+ onChange
165
+ }, locales) : null,
166
+ ...props
167
+ }];
152
168
  }, []);
153
169
  }
154
- function useForm() {
155
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
156
- var _opts$fields = opts.fields,
157
- fields = _opts$fields === void 0 ? [] : _opts$fields,
158
- _opts$action = opts.action,
159
- action = _opts$action === void 0 ? null : _opts$action,
160
- _opts$postForm = opts.postForm,
161
- postForm = _opts$postForm === void 0 ? null : _opts$postForm,
162
- _opts$initialErrors = opts.initialErrors,
163
- initialErrors = _opts$initialErrors === void 0 ? null : _opts$initialErrors,
164
- _opts$errors = opts.errors,
165
- providedErrors = _opts$errors === void 0 ? null : _opts$errors,
166
- _opts$setErrors = opts.setErrors,
167
- setProvidedErrors = _opts$setErrors === void 0 ? null : _opts$setErrors,
168
- _opts$initialGeneralE = opts.initialGeneralError,
169
- initialGeneralError = _opts$initialGeneralE === void 0 ? null : _opts$initialGeneralE,
170
- _opts$generalError = opts.generalError,
171
- providedGeneralError = _opts$generalError === void 0 ? null : _opts$generalError,
172
- _opts$setGeneralError = opts.setGeneralError,
173
- setProvidedGeneralError = _opts$setGeneralError === void 0 ? null : _opts$setGeneralError,
174
- _opts$initialValue = opts.initialValue,
175
- initialValue = _opts$initialValue === void 0 ? null : _opts$initialValue,
176
- _opts$value = opts.value,
177
- providedValue = _opts$value === void 0 ? null : _opts$value,
178
- _opts$setValue = opts.setValue,
179
- setProvidedValue = _opts$setValue === void 0 ? null : _opts$setValue,
180
- _opts$withoutDefault = opts.withoutDefault,
181
- withoutDefault = _opts$withoutDefault === void 0 ? true : _opts$withoutDefault,
182
- _opts$withoutPropagat = opts.withoutPropagation,
183
- withoutPropagation = _opts$withoutPropagat === void 0 ? true : _opts$withoutPropagat,
184
- _opts$onComplete = opts.onComplete,
185
- onComplete = _opts$onComplete === void 0 ? null : _opts$onComplete,
186
- _opts$onError = opts.onError,
187
- onError = _opts$onError === void 0 ? null : _opts$onError,
188
- _opts$locales = opts.locales,
189
- locales = _opts$locales === void 0 ? [] : _opts$locales;
190
- var _useState = useState(initialValue || providedValue),
191
- _useState2 = _slicedToArray(_useState, 2),
192
- stateValue = _useState2[0],
193
- setStateValue = _useState2[1];
194
- var _useState3 = useState(initialErrors || providedErrors),
195
- _useState4 = _slicedToArray(_useState3, 2),
196
- stateErrors = _useState4[0],
197
- setStateErrors = _useState4[1];
198
- var _useState5 = useState(initialGeneralError || providedGeneralError),
199
- _useState6 = _slicedToArray(_useState5, 2),
200
- stateGeneralError = _useState6[0],
201
- setStateGeneralError = _useState6[1];
202
- var _useState7 = useState({
203
- success: false,
204
- loading: false,
205
- error: false
206
- }),
207
- _useState8 = _slicedToArray(_useState7, 2),
208
- requestState = _useState8[0],
209
- setRequestState = _useState8[1];
210
- var _useState9 = useState(null),
211
- _useState0 = _slicedToArray(_useState9, 2),
212
- response = _useState0[0],
213
- setResponse = _useState0[1];
214
- var hasProvidedValue = setProvidedValue !== null;
215
- var value = hasProvidedValue ? providedValue : stateValue;
216
- var setValue = hasProvidedValue ? setProvidedValue : setStateValue;
217
- var hasProvidedErrors = setProvidedErrors !== null;
218
- var errors = hasProvidedErrors ? providedErrors : stateErrors;
219
- var setErrors = hasProvidedErrors ? setProvidedErrors : setStateErrors;
220
- var hasProvidedGeneralError = setProvidedGeneralError !== null;
221
- var generalError = hasProvidedGeneralError ? providedGeneralError : stateGeneralError;
222
- var setGeneralError = hasProvidedGeneralError ? setProvidedGeneralError : setStateGeneralError;
223
- var onFieldChange = useCallback(function (fieldName, fieldValue) {
224
- var _ref3 = requestState || {},
225
- _ref3$loading = _ref3.loading,
226
- loading = _ref3$loading === void 0 ? false : _ref3$loading,
227
- _ref3$success = _ref3.success,
228
- success = _ref3$success === void 0 ? false : _ref3$success,
229
- _ref3$error = _ref3.error,
230
- requestError = _ref3$error === void 0 ? false : _ref3$error;
231
- var fieldErrors = errors !== null ? errors[fieldName] || null : null;
170
+ function useForm(opts = {}) {
171
+ const {
172
+ fields = [],
173
+ action = null,
174
+ postForm = null,
175
+ initialErrors = null,
176
+ errors: providedErrors = null,
177
+ setErrors: setProvidedErrors = null,
178
+ initialGeneralError = null,
179
+ generalError: providedGeneralError = null,
180
+ setGeneralError: setProvidedGeneralError = null,
181
+ initialValue = null,
182
+ value: providedValue = null,
183
+ setValue: setProvidedValue = null,
184
+ withoutDefault = true,
185
+ withoutPropagation = true,
186
+ onComplete = null,
187
+ onError = null,
188
+ locales = []
189
+ } = opts;
190
+ const [stateValue, setStateValue] = useState(initialValue || providedValue);
191
+ const [stateErrors, setStateErrors] = useState(initialErrors || providedErrors);
192
+ const [stateGeneralError, setStateGeneralError] = useState(initialGeneralError || providedGeneralError);
193
+ const [requestState, setRequestState] = useState({
194
+ success: false,
195
+ loading: false,
196
+ error: false
197
+ });
198
+ const [response, setResponse] = useState(null);
199
+ const hasProvidedValue = setProvidedValue !== null;
200
+ const value = hasProvidedValue ? providedValue : stateValue;
201
+ const setValue = hasProvidedValue ? setProvidedValue : setStateValue;
202
+ const hasProvidedErrors = setProvidedErrors !== null;
203
+ const errors = hasProvidedErrors ? providedErrors : stateErrors;
204
+ const setErrors = hasProvidedErrors ? setProvidedErrors : setStateErrors;
205
+ const hasProvidedGeneralError = setProvidedGeneralError !== null;
206
+ const generalError = hasProvidedGeneralError ? providedGeneralError : stateGeneralError;
207
+ const setGeneralError = hasProvidedGeneralError ? setProvidedGeneralError : setStateGeneralError;
208
+ const onFieldChange = useCallback((fieldName, fieldValue) => {
209
+ const {
210
+ loading = false,
211
+ success = false,
212
+ error: requestError = false
213
+ } = requestState || {};
214
+ const fieldErrors = errors !== null ? errors[fieldName] || null : null;
232
215
  if (fieldErrors !== null) {
233
- setErrors(_objectSpread(_objectSpread({}, errors), {}, _defineProperty({}, fieldName, null)));
216
+ setErrors({
217
+ ...errors,
218
+ [fieldName]: null
219
+ });
234
220
  }
235
221
  if (!loading && (success !== false || requestError !== false)) {
236
222
  setRequestState({
@@ -239,28 +225,27 @@ function useForm() {
239
225
  error: false
240
226
  });
241
227
  }
242
- setValue(_objectSpread(_objectSpread({}, value || {}), {}, _defineProperty({}, fieldName, fieldValue)));
243
- }, [value, errors, requestState, setErrors, setValue].concat(_toConsumableArray(fields)));
244
- var fieldsProps = useMemo(function () {
245
- return getFieldsPropsFromFields(fields, {
246
- value: value,
247
- errors: errors,
248
- onChange: onFieldChange
249
- }, locales);
250
- }, [value, errors, locales, fields, onFieldChange].concat(_toConsumableArray(fields)));
251
- var csrfToken = useMemo(function () {
252
- return getCsrfToken();
253
- }, []);
254
- var onSubmitError = function onSubmitError(error) {
228
+ setValue({
229
+ ...(value || {}),
230
+ [fieldName]: fieldValue
231
+ });
232
+ }, [value, errors, requestState, setErrors, setValue, ...fields]);
233
+ const fieldsProps = useMemo(() => getFieldsPropsFromFields(fields, {
234
+ value,
235
+ errors,
236
+ onChange: onFieldChange
237
+ }, locales), [value, errors, locales, fields, onFieldChange, ...fields]);
238
+ const csrfToken = useMemo(() => getCsrfToken(), []);
239
+ const onSubmitError = error => {
255
240
  setRequestState({
256
241
  success: false,
257
242
  loading: false,
258
243
  error: true
259
244
  });
260
245
  if (error.name === 'ValidationError') {
261
- var _getResponseData = error.getResponseData(),
262
- _getResponseData$erro = _getResponseData.errors,
263
- validationErrors = _getResponseData$erro === void 0 ? null : _getResponseData$erro;
246
+ const {
247
+ errors: validationErrors = null
248
+ } = error.getResponseData();
264
249
  setErrors(validationErrors || null);
265
250
  } else {
266
251
  setGeneralError(error.message);
@@ -269,7 +254,7 @@ function useForm() {
269
254
  onError(error);
270
255
  }
271
256
  };
272
- var onSubmitSuccess = function onSubmitSuccess(resp) {
257
+ const onSubmitSuccess = resp => {
273
258
  setRequestState({
274
259
  success: true,
275
260
  loading: false,
@@ -280,14 +265,11 @@ function useForm() {
280
265
  onComplete(resp);
281
266
  }
282
267
  };
283
- var finalPostForm = useCallback(function (postAction, postData) {
284
- return postForm !== null ? postForm(postAction, postData) : postJSON(postAction, postData, {
285
- credentials: 'include',
286
- headers: getCSRFHeaders()
287
- });
288
- }, [postForm]);
289
- var submit = useCallback(function () {
290
- var submitValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : value;
268
+ const finalPostForm = useCallback((postAction, postData) => postForm !== null ? postForm(postAction, postData) : postJSON(postAction, postData, {
269
+ credentials: 'include',
270
+ headers: getCSRFHeaders()
271
+ }), [postForm]);
272
+ const submit = useCallback((submitValue = value) => {
291
273
  setRequestState({
292
274
  success: false,
293
275
  loading: true,
@@ -295,11 +277,12 @@ function useForm() {
295
277
  });
296
278
  setGeneralError(null);
297
279
  setErrors(null);
298
- finalPostForm(action, _objectSpread(_objectSpread({}, submitValue || {}), {}, {
280
+ finalPostForm(action, {
281
+ ...(submitValue || {}),
299
282
  _token: csrfToken
300
- })).then(onSubmitSuccess)["catch"](onSubmitError);
283
+ }).then(onSubmitSuccess).catch(onSubmitError);
301
284
  }, [value, setGeneralError, setErrors, finalPostForm, action, csrfToken, onSubmitSuccess, onSubmitError]);
302
- var onSubmit = useCallback(function (e) {
285
+ const onSubmit = useCallback(e => {
303
286
  if (withoutDefault) {
304
287
  e.preventDefault();
305
288
  }
@@ -310,7 +293,7 @@ function useForm() {
310
293
  // Nested forms (even in portals) will bubble the onSubmit event to the parent
311
294
  submit();
312
295
  }, [submit, withoutDefault, withoutPropagation]);
313
- var status = null;
296
+ let status = null;
314
297
  if (requestState.loading) {
315
298
  status = 'loading';
316
299
  } else if (requestState.success) {
@@ -318,153 +301,127 @@ function useForm() {
318
301
  } else if (requestState.error) {
319
302
  status = 'error';
320
303
  }
321
- return _objectSpread(_objectSpread({
322
- value: value,
323
- setValue: setValue,
324
- csrfToken: csrfToken,
325
- submit: submit,
326
- onSubmit: onSubmit
327
- }, requestState), {}, {
328
- status: status,
329
- response: response,
304
+ return {
305
+ value,
306
+ setValue,
307
+ csrfToken,
308
+ submit,
309
+ onSubmit,
310
+ ...requestState,
311
+ status,
312
+ response,
330
313
  fields: fieldsProps,
331
- errors: errors,
332
- generalError: generalError
333
- });
314
+ errors,
315
+ generalError
316
+ };
334
317
  }
335
318
 
336
319
  function buildThresholdArray() {
337
320
  return [0, 1.0];
338
321
  }
339
- var observersCache = new Map();
340
- function getOptionsKey(_ref) {
341
- var _ref$root = _ref.root,
342
- root = _ref$root === void 0 ? null : _ref$root,
343
- rootMargin = _ref.rootMargin,
344
- _ref$threshold = _ref.threshold,
345
- threshold = _ref$threshold === void 0 ? null : _ref$threshold;
346
- return "root_".concat(root, "_rootMargin_").concat(rootMargin || null, "_threshold_").concat(threshold);
322
+ const observersCache = new Map();
323
+ function getOptionsKey({
324
+ root = null,
325
+ rootMargin,
326
+ threshold = null
327
+ }) {
328
+ return `root_${root}_rootMargin_${rootMargin || null}_threshold_${threshold}`;
347
329
  }
348
- function createObserver(Observer) {
349
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
350
- var subscribers = [];
351
- var addSubscriber = function addSubscriber(element, callback) {
352
- var currentSubscriber = subscribers.find(function (it) {
353
- return it.element === element;
354
- }) || null;
330
+ function createObserver(Observer, options = {}) {
331
+ let subscribers = [];
332
+ const addSubscriber = (element, callback) => {
333
+ const currentSubscriber = subscribers.find(it => it.element === element) || null;
355
334
  if (currentSubscriber !== null) {
356
- return subscribers.map(function (it) {
357
- return it.element === element && it.callbacks.indexOf(callback) === -1 ? _objectSpread(_objectSpread({}, it), {}, {
358
- callbacks: [].concat(_toConsumableArray(it.callbacks), [callback])
359
- }) : it;
360
- }).filter(function (it) {
361
- return it.callbacks.length > 0;
362
- });
335
+ return subscribers.map(it => it.element === element && it.callbacks.indexOf(callback) === -1 ? {
336
+ ...it,
337
+ callbacks: [...it.callbacks, callback]
338
+ } : it).filter(it => it.callbacks.length > 0);
363
339
  }
364
- return [].concat(_toConsumableArray(subscribers), [{
365
- element: element,
340
+ return [...subscribers, {
341
+ element,
366
342
  callbacks: [callback]
367
- }]);
343
+ }];
368
344
  };
369
- var removeSubscriber = function removeSubscriber(element, callback) {
370
- return subscribers.map(function (it) {
371
- return it.element === element ? _objectSpread(_objectSpread({}, it), {}, {
372
- callbacks: it.callbacks.filter(function (subCallback) {
373
- return subCallback !== callback;
374
- })
375
- }) : it;
376
- }).filter(function (it) {
377
- return it.callbacks.length > 0;
378
- });
379
- };
380
- var onUpdate = function onUpdate(entries) {
381
- entries.forEach(function (entry) {
382
- subscribers.forEach(function (_ref2) {
383
- var element = _ref2.element,
384
- callbacks = _ref2.callbacks;
345
+ const removeSubscriber = (element, callback) => subscribers.map(it => it.element === element ? {
346
+ ...it,
347
+ callbacks: it.callbacks.filter(subCallback => subCallback !== callback)
348
+ } : it).filter(it => it.callbacks.length > 0);
349
+ const onUpdate = entries => {
350
+ entries.forEach(entry => {
351
+ subscribers.forEach(({
352
+ element,
353
+ callbacks
354
+ }) => {
385
355
  if (element === entry.target) {
386
- callbacks.forEach(function (callback) {
356
+ callbacks.forEach(callback => {
387
357
  callback(entry);
388
358
  });
389
359
  }
390
360
  });
391
361
  });
392
362
  };
393
- var observer = new Observer(onUpdate, options);
394
- var unsubscribe = function unsubscribe(element) {
395
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
363
+ const observer = new Observer(onUpdate, options);
364
+ const unsubscribe = (element, callback = null) => {
396
365
  subscribers = removeSubscriber(element, callback);
397
366
  if (typeof observer.unobserve === 'undefined') {
398
367
  observer.disconnect();
399
- subscribers.forEach(function (subscriber) {
368
+ subscribers.forEach(subscriber => {
400
369
  observer.observe(subscriber.element);
401
370
  });
402
371
  return;
403
372
  }
404
- var currentSubscriber = subscribers.find(function (it) {
405
- return it.element === element;
406
- }) || null;
373
+ const currentSubscriber = subscribers.find(it => it.element === element) || null;
407
374
  if (currentSubscriber === null) {
408
375
  observer.unobserve(element);
409
376
  }
410
377
  };
411
- var subscribe = function subscribe(element, callback) {
412
- var currentSubscriber = subscribers.find(function (it) {
413
- return it.element === element;
414
- }) || null;
378
+ const subscribe = (element, callback) => {
379
+ const currentSubscriber = subscribers.find(it => it.element === element) || null;
415
380
  subscribers = addSubscriber(element, callback);
416
381
  if (currentSubscriber === null) {
417
382
  observer.observe(element);
418
383
  }
419
384
  };
420
385
  return {
421
- subscribe: subscribe,
422
- unsubscribe: unsubscribe,
423
- observer: observer
386
+ subscribe,
387
+ unsubscribe,
388
+ observer
424
389
  };
425
390
  }
426
- function getObserver(Observer) {
427
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
391
+ function getObserver(Observer, options = {}) {
428
392
  if (Observer === null) {
429
393
  throw new Error('Observer constructor is null');
430
394
  }
431
- var observerKey = getOptionsKey(options);
395
+ const observerKey = getOptionsKey(options);
432
396
  if (!observersCache.has(Observer)) {
433
397
  observersCache.set(Observer, {});
434
398
  }
435
- var observers = observersCache.get(Observer);
399
+ const observers = observersCache.get(Observer);
436
400
  if (typeof observers[observerKey] === 'undefined') {
437
401
  observers[observerKey] = createObserver(Observer, options);
438
402
  observersCache.set(Observer, observers);
439
403
  }
440
404
  return observers[observerKey];
441
405
  }
442
- function useObserver(Observer) {
443
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
444
- var initialEntry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
445
- var _opts$root = opts.root,
446
- root = _opts$root === void 0 ? null : _opts$root,
447
- _opts$rootMargin = opts.rootMargin,
448
- rootMargin = _opts$rootMargin === void 0 ? null : _opts$rootMargin,
449
- _opts$threshold = opts.threshold,
450
- threshold = _opts$threshold === void 0 ? null : _opts$threshold,
451
- _opts$disabled = opts.disabled,
452
- disabled = _opts$disabled === void 0 ? false : _opts$disabled;
453
- var _useState = useState(initialEntry),
454
- _useState2 = _slicedToArray(_useState, 2),
455
- entry = _useState2[0],
456
- setEntry = _useState2[1];
457
- var nodeRef = useRef(null);
458
- var currentElement = useRef(null);
459
- var elementChanged = nodeRef.current !== currentElement.current;
460
- useEffect(function () {
461
- var nodeElement = nodeRef.current;
462
- var callback = function callback(newEntry) {
463
- return setEntry(newEntry);
464
- };
465
- var unsubscribe = null;
406
+ function useObserver(Observer, opts = {}, initialEntry = {}) {
407
+ const {
408
+ root = null,
409
+ rootMargin = null,
410
+ threshold = null,
411
+ disabled = false
412
+ } = opts;
413
+ const [entry, setEntry] = useState(initialEntry);
414
+ const nodeRef = useRef(null);
415
+ const currentElement = useRef(null);
416
+ const elementChanged = nodeRef.current !== currentElement.current;
417
+ useEffect(() => {
418
+ const {
419
+ current: nodeElement
420
+ } = nodeRef;
421
+ const callback = newEntry => setEntry(newEntry);
422
+ let unsubscribe = null;
466
423
  if (nodeElement !== null && Observer !== null) {
467
- var newOpts = {};
424
+ const newOpts = {};
468
425
  if (root !== null) {
469
426
  newOpts.root = root;
470
427
  }
@@ -474,14 +431,15 @@ function useObserver(Observer) {
474
431
  if (threshold !== null) {
475
432
  newOpts.threshold = threshold;
476
433
  }
477
- var _getObserver = getObserver(Observer, newOpts),
478
- subscribe = _getObserver.subscribe,
479
- localUnsubscribe = _getObserver.unsubscribe;
434
+ const {
435
+ subscribe,
436
+ unsubscribe: localUnsubscribe
437
+ } = getObserver(Observer, newOpts);
480
438
  unsubscribe = localUnsubscribe;
481
439
  subscribe(nodeElement, callback);
482
440
  }
483
441
  currentElement.current = nodeElement;
484
- return function () {
442
+ return () => {
485
443
  if (unsubscribe !== null && nodeElement !== null) {
486
444
  unsubscribe(nodeElement, callback);
487
445
  }
@@ -489,15 +447,15 @@ function useObserver(Observer) {
489
447
  }, [Observer, elementChanged, disabled, root, rootMargin, threshold]);
490
448
  return {
491
449
  ref: nodeRef,
492
- entry: entry
450
+ entry
493
451
  };
494
452
  }
495
453
 
496
454
  /**
497
455
  * Intersection Observer
498
456
  */
499
- var thresholdArray = buildThresholdArray();
500
- var intersectionObserverInitialEntry = {
457
+ const thresholdArray = buildThresholdArray();
458
+ const intersectionObserverInitialEntry = {
501
459
  target: null,
502
460
  time: null,
503
461
  isVisible: false,
@@ -507,68 +465,108 @@ var intersectionObserverInitialEntry = {
507
465
  boundingClientRect: null,
508
466
  rootBounds: null
509
467
  };
510
- function useIntersectionObserver() {
511
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
512
- _ref3$root = _ref3.root,
513
- root = _ref3$root === void 0 ? null : _ref3$root,
514
- _ref3$rootMargin = _ref3.rootMargin,
515
- rootMargin = _ref3$rootMargin === void 0 ? '0px' : _ref3$rootMargin,
516
- _ref3$threshold = _ref3.threshold,
517
- threshold = _ref3$threshold === void 0 ? thresholdArray : _ref3$threshold,
518
- _ref3$disabled = _ref3.disabled,
519
- disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
520
- return useObserver(typeof window !== 'undefined' ? IntersectionObserver : null, {
521
- root: root,
522
- rootMargin: rootMargin,
523
- threshold: threshold,
524
- disabled: disabled
525
- }, intersectionObserverInitialEntry);
468
+ function useIntersectionObserver(t0) {
469
+ const $ = c(7);
470
+ let t1;
471
+ if ($[0] !== t0) {
472
+ t1 = t0 === undefined ? {} : t0;
473
+ $[0] = t0;
474
+ $[1] = t1;
475
+ } else {
476
+ t1 = $[1];
477
+ }
478
+ const {
479
+ root: t2,
480
+ rootMargin: t3,
481
+ threshold: t4,
482
+ disabled: t5
483
+ } = t1;
484
+ const root = t2 === undefined ? null : t2;
485
+ const rootMargin = t3 === undefined ? "0px" : t3;
486
+ const threshold = t4 === undefined ? thresholdArray : t4;
487
+ const disabled = t5 === undefined ? false : t5;
488
+ let t6;
489
+ if ($[2] !== disabled || $[3] !== root || $[4] !== rootMargin || $[5] !== threshold) {
490
+ t6 = {
491
+ root,
492
+ rootMargin,
493
+ threshold,
494
+ disabled
495
+ };
496
+ $[2] = disabled;
497
+ $[3] = root;
498
+ $[4] = rootMargin;
499
+ $[5] = threshold;
500
+ $[6] = t6;
501
+ } else {
502
+ t6 = $[6];
503
+ }
504
+ return useObserver(typeof window !== "undefined" ? IntersectionObserver : null, t6, intersectionObserverInitialEntry);
526
505
  }
527
506
 
528
507
  /**
529
508
  * Resize Observer
530
509
  */
531
510
 
532
- var resizeObserverInitialEntry = {
511
+ const resizeObserverInitialEntry = {
533
512
  target: null,
534
513
  contentRect: null,
535
514
  contentBoxSize: null,
536
515
  borderBoxSize: null
537
516
  };
538
- function useResizeObserver() {
539
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
540
- _ref4$disabled = _ref4.disabled,
541
- disabled = _ref4$disabled === void 0 ? false : _ref4$disabled;
542
- return useObserver(typeof window !== 'undefined' ? ResizeObserver : null, {
543
- disabled: disabled
544
- }, resizeObserverInitialEntry);
517
+ function useResizeObserver(t0) {
518
+ const $ = c(4);
519
+ let t1;
520
+ if ($[0] !== t0) {
521
+ t1 = t0 === undefined ? {} : t0;
522
+ $[0] = t0;
523
+ $[1] = t1;
524
+ } else {
525
+ t1 = $[1];
526
+ }
527
+ const {
528
+ disabled: t2
529
+ } = t1;
530
+ const disabled = t2 === undefined ? false : t2;
531
+ let t3;
532
+ if ($[2] !== disabled) {
533
+ t3 = {
534
+ disabled
535
+ };
536
+ $[2] = disabled;
537
+ $[3] = t3;
538
+ } else {
539
+ t3 = $[3];
540
+ }
541
+ return useObserver(typeof window !== "undefined" ? ResizeObserver : null, t3, resizeObserverInitialEntry);
545
542
  }
546
543
 
547
- function useIsVisible() {
548
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
549
- rootMargin = _ref.rootMargin,
550
- _ref$threshold = _ref.threshold,
551
- threshold = _ref$threshold === void 0 ? 1 : _ref$threshold,
552
- _ref$persist = _ref.persist,
553
- persist = _ref$persist === void 0 ? false : _ref$persist;
554
- var _useIntersectionObser = useIntersectionObserver({
555
- rootMargin: rootMargin,
556
- threshold: threshold
557
- }),
558
- ref = _useIntersectionObser.ref,
559
- isIntersecting = _useIntersectionObser.entry.isIntersecting;
560
- var wasIntersecting = useRef(isIntersecting);
544
+ function useIsVisible({
545
+ rootMargin,
546
+ threshold = 1,
547
+ persist = false
548
+ } = {}) {
549
+ const {
550
+ ref,
551
+ entry: {
552
+ isIntersecting
553
+ }
554
+ } = useIntersectionObserver({
555
+ rootMargin,
556
+ threshold
557
+ });
558
+ const wasIntersecting = useRef(isIntersecting);
561
559
  if (isIntersecting && !wasIntersecting.current) {
562
560
  wasIntersecting.current = isIntersecting;
563
561
  }
564
- var isVisible = !persist && isIntersecting || persist && wasIntersecting.current;
562
+ const isVisible = !persist && isIntersecting || persist && wasIntersecting.current;
565
563
  return {
566
- ref: ref,
564
+ ref,
567
565
  visible: isVisible
568
566
  };
569
567
  }
570
568
 
571
- var KEYCODES = {
569
+ const KEYCODES = {
572
570
  ARROW_LEFT: 37,
573
571
  ARROW_UP: 38,
574
572
  ARROW_RIGHT: 39,
@@ -576,30 +574,84 @@ var KEYCODES = {
576
574
  ESCAPE: 27,
577
575
  SPACE: 32
578
576
  };
579
- function useKeyboardKeys() {
580
- var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
581
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
582
- _ref$eventName = _ref.eventName,
583
- eventName = _ref$eventName === void 0 ? 'keydown' : _ref$eventName;
584
- var keysNames = Object.keys(keys);
585
- var keysListeners = keysNames.map(function (key) {
586
- return keys[key];
587
- });
588
- useEffect(function () {
589
- var onKeyDown = function onKeyDown(e) {
590
- var keyCode = e.keyCode;
591
- if (typeof keys[keyCode] !== 'undefined') {
592
- keys[keyCode](e);
593
- }
594
- };
595
- document.addEventListener(eventName, onKeyDown);
596
- return function () {
597
- document.removeEventListener(eventName, onKeyDown);
577
+ function useKeyboardKeys(t0, t1) {
578
+ const $ = c(16);
579
+ let t2;
580
+ if ($[0] !== t0) {
581
+ t2 = t0 === undefined ? {} : t0;
582
+ $[0] = t0;
583
+ $[1] = t2;
584
+ } else {
585
+ t2 = $[1];
586
+ }
587
+ const keys = t2;
588
+ let t3;
589
+ if ($[2] !== t1) {
590
+ t3 = t1 === undefined ? {} : t1;
591
+ $[2] = t1;
592
+ $[3] = t3;
593
+ } else {
594
+ t3 = $[3];
595
+ }
596
+ const {
597
+ eventName: t4
598
+ } = t3;
599
+ const eventName = t4 === undefined ? "keydown" : t4;
600
+ let t5;
601
+ if ($[4] !== keys) {
602
+ t5 = Object.keys(keys);
603
+ $[4] = keys;
604
+ $[5] = t5;
605
+ } else {
606
+ t5 = $[5];
607
+ }
608
+ const keysNames = t5;
609
+ let t6;
610
+ if ($[6] !== keys || $[7] !== keysNames) {
611
+ t6 = keysNames.map(key => keys[key]);
612
+ $[6] = keys;
613
+ $[7] = keysNames;
614
+ $[8] = t6;
615
+ } else {
616
+ t6 = $[8];
617
+ }
618
+ const keysListeners = t6;
619
+ let t7;
620
+ if ($[9] !== eventName || $[10] !== keys) {
621
+ t7 = () => {
622
+ const onKeyDown = e => {
623
+ const {
624
+ keyCode
625
+ } = e;
626
+ if (typeof keys[keyCode] !== "undefined") {
627
+ keys[keyCode](e);
628
+ }
629
+ };
630
+ document.addEventListener(eventName, onKeyDown);
631
+ return () => {
632
+ document.removeEventListener(eventName, onKeyDown);
633
+ };
598
634
  };
599
- }, [].concat(keysNames, _toConsumableArray(keysListeners), [eventName]));
635
+ $[9] = eventName;
636
+ $[10] = keys;
637
+ $[11] = t7;
638
+ } else {
639
+ t7 = $[11];
640
+ }
641
+ let t8;
642
+ if ($[12] !== eventName || $[13] !== keysListeners || $[14] !== keysNames) {
643
+ t8 = [...keysNames, ...keysListeners, eventName];
644
+ $[12] = eventName;
645
+ $[13] = keysListeners;
646
+ $[14] = keysNames;
647
+ $[15] = t8;
648
+ } else {
649
+ t8 = $[15];
650
+ }
651
+ useEffect(t7, t8);
600
652
  }
601
653
 
602
- var fontsMap = {
654
+ const fontsMap = {
603
655
  loading: [],
604
656
  active: []
605
657
  };
@@ -610,511 +662,973 @@ function isFontActive(name) {
610
662
  return fontsMap.active.indexOf(name) !== -1;
611
663
  }
612
664
  function addFontLoading(name) {
613
- fontsMap.active = fontsMap.active.filter(function (it) {
614
- return it !== name;
615
- });
616
- fontsMap.loading = [].concat(_toConsumableArray(fontsMap.loading), [name]);
665
+ fontsMap.active = fontsMap.active.filter(it => it !== name);
666
+ fontsMap.loading = [...fontsMap.loading, name];
617
667
  }
618
668
  function removeFontLoading(name) {
619
- fontsMap.loading = fontsMap.loading.filter(function (it) {
620
- return it !== name;
621
- });
669
+ fontsMap.loading = fontsMap.loading.filter(it => it !== name);
622
670
  }
623
671
  function addFontActive(name) {
624
- fontsMap.loading = fontsMap.loading.filter(function (it) {
625
- return it !== name;
626
- });
627
- fontsMap.active = [].concat(_toConsumableArray(fontsMap.active), [name]);
672
+ fontsMap.loading = fontsMap.loading.filter(it => it !== name);
673
+ fontsMap.active = [...fontsMap.active, name];
628
674
  }
629
675
  function useLoadedFonts(fonts) {
630
- var _useState = useState(false),
631
- _useState2 = _slicedToArray(_useState, 2),
632
- loaded = _useState2[0],
633
- setLoaded = _useState2[1];
634
- useEffect(function () {
635
- var config = fonts.reduce(function (newConfig, font) {
636
- var _ref = isObject(font) ? font : {
637
- type: 'system',
638
- name: font
639
- },
640
- type = _ref.type,
641
- name = _ref.name;
676
+ const [loaded, setLoaded] = useState(false);
677
+ useEffect(() => {
678
+ const config = fonts.reduce((newConfig, font) => {
679
+ const {
680
+ type,
681
+ name
682
+ } = isObject(font) ? font : {
683
+ type: 'system',
684
+ name: font
685
+ };
642
686
  if ((type === 'google' || type === 'custom') && !isFontLoading(name) && !isFontActive(name)) {
643
- return _objectSpread(_objectSpread({}, newConfig), {}, _defineProperty({}, type, {
644
- families: [].concat(_toConsumableArray(newConfig !== null ? (newConfig[type] || {}).families || [] : []), [name])
645
- }));
687
+ return {
688
+ ...newConfig,
689
+ [type]: {
690
+ families: [...(newConfig !== null ? (newConfig[type] || {}).families || [] : []), name]
691
+ }
692
+ };
646
693
  }
647
694
  return newConfig;
648
695
  }, null);
649
- var hasConfig = config !== null;
696
+ const hasConfig = config !== null;
650
697
  if (hasConfig && typeof window !== 'undefined') {
651
- loadPackage('webfontloader', function () {
652
- return import('webfontloader');
653
- }).then(function (_ref2) {
654
- var WebFont = _ref2["default"];
655
- return WebFont.load(_objectSpread(_objectSpread({}, config), {}, {
656
- timeout: 3000,
657
- active: function active() {
658
- return setLoaded(true);
659
- },
660
- fontloading: function fontloading(name) {
661
- return addFontLoading(name);
662
- },
663
- fontactive: function fontactive(name) {
664
- return addFontActive(name);
665
- },
666
- fontinactive: function fontinactive(name) {
667
- return removeFontLoading(name);
668
- }
669
- }));
670
- });
698
+ loadPackage('webfontloader', () => import('webfontloader')).then(({
699
+ default: WebFont
700
+ }) => WebFont.load({
701
+ ...config,
702
+ timeout: 3000,
703
+ active: () => setLoaded(true),
704
+ fontloading: name_0 => addFontLoading(name_0),
705
+ fontactive: name_1 => addFontActive(name_1),
706
+ fontinactive: name_2 => removeFontLoading(name_2)
707
+ }));
671
708
  } else {
672
709
  setLoaded(true);
673
710
  }
674
711
  }, [fonts, setLoaded]);
675
712
  return {
676
- loaded: loaded
713
+ loaded
677
714
  };
678
715
  }
679
716
 
680
- var progressSteps = [0.1, 0.25, 0.5, 0.75, 0.9];
681
- function useMediaApi() {
682
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
683
- _ref$url = _ref.url,
684
- url = _ref$url === void 0 ? null : _ref$url,
685
- _ref$initialMuted = _ref.initialMuted,
686
- initialMuted = _ref$initialMuted === void 0 ? false : _ref$initialMuted,
687
- _ref$onTimeUpdate = _ref.onTimeUpdate,
688
- onTimeUpdate = _ref$onTimeUpdate === void 0 ? null : _ref$onTimeUpdate,
689
- _ref$onProgressStep = _ref.onProgressStep,
690
- onProgressStep = _ref$onProgressStep === void 0 ? null : _ref$onProgressStep,
691
- _ref$onDurationChange = _ref.onDurationChanged,
692
- onDurationChanged = _ref$onDurationChange === void 0 ? null : _ref$onDurationChange,
693
- _ref$onVolumeChanged = _ref.onVolumeChanged,
694
- onVolumeChanged = _ref$onVolumeChanged === void 0 ? null : _ref$onVolumeChanged,
695
- _ref$onPlay = _ref.onPlay,
696
- onPlay = _ref$onPlay === void 0 ? null : _ref$onPlay,
697
- _ref$onPause = _ref.onPause,
698
- onPause = _ref$onPause === void 0 ? null : _ref$onPause,
699
- _ref$onEnded = _ref.onEnded,
700
- onEnded = _ref$onEnded === void 0 ? null : _ref$onEnded,
701
- _ref$onSeeked = _ref.onSeeked,
702
- onSeeked = _ref$onSeeked === void 0 ? null : _ref$onSeeked,
703
- _ref$onLoadStart = _ref.onLoadStart,
704
- onLoadStart = _ref$onLoadStart === void 0 ? null : _ref$onLoadStart,
705
- _ref$onCanPlayThough = _ref.onCanPlayThough,
706
- onCanPlayThough = _ref$onCanPlayThough === void 0 ? null : _ref$onCanPlayThough;
707
- var ref = useRef(null);
708
- var _useState = useState(initialMuted),
709
- _useState2 = _slicedToArray(_useState, 2),
710
- muted = _useState2[0],
711
- setMuted = _useState2[1];
712
- var _useState3 = useState(null),
713
- _useState4 = _slicedToArray(_useState3, 2),
714
- currentTime = _useState4[0],
715
- setCurrentTime = _useState4[1];
716
- var _useState5 = useState(null),
717
- _useState6 = _slicedToArray(_useState5, 2),
718
- duration = _useState6[0],
719
- setDuration = _useState6[1];
720
- var _useState7 = useState(false),
721
- _useState8 = _slicedToArray(_useState7, 2),
722
- playing = _useState8[0],
723
- setPlaying = _useState8[1];
724
- var _useState9 = useState(false),
725
- _useState0 = _slicedToArray(_useState9, 2),
726
- ready = _useState0[0],
727
- setReady = _useState0[1];
728
- var _useState1 = useState(true),
729
- _useState10 = _slicedToArray(_useState1, 2),
730
- initialPlay = _useState10[0],
731
- setInitialPlay = _useState10[1];
732
- var progressStepsReached = useRef({});
733
- var paused = !playing;
734
-
735
- // Exposed methods
736
- var play = useCallback(function () {
737
- var media = ref.current;
738
- if (media !== null) {
739
- media.play();
740
- }
741
- }, []);
742
- var pause = useCallback(function () {
743
- var media = ref.current;
744
- if (media !== null) {
745
- media.pause();
746
- }
747
- }, []);
748
- var togglePlay = useCallback(function () {
749
- var media = ref.current;
750
- if (media !== null) {
751
- if (playing) {
752
- media.pause();
753
- } else {
717
+ const progressSteps = [0.1, 0.25, 0.5, 0.75, 0.9];
718
+ function useMediaApi(t0) {
719
+ const $ = c(54);
720
+ let t1;
721
+ if ($[0] !== t0) {
722
+ t1 = t0 === undefined ? {} : t0;
723
+ $[0] = t0;
724
+ $[1] = t1;
725
+ } else {
726
+ t1 = $[1];
727
+ }
728
+ const {
729
+ url: t2,
730
+ initialMuted: t3,
731
+ onTimeUpdate: t4,
732
+ onProgressStep: t5,
733
+ onDurationChanged: t6,
734
+ onVolumeChanged: t7,
735
+ onPlay: t8,
736
+ onPause: t9,
737
+ onEnded: t10,
738
+ onSeeked: t11,
739
+ onLoadStart: t12,
740
+ onCanPlayThough: t13
741
+ } = t1;
742
+ const url = t2 === undefined ? null : t2;
743
+ const initialMuted = t3 === undefined ? false : t3;
744
+ const onTimeUpdate = t4 === undefined ? null : t4;
745
+ const onProgressStep = t5 === undefined ? null : t5;
746
+ const onDurationChanged = t6 === undefined ? null : t6;
747
+ const onVolumeChanged = t7 === undefined ? null : t7;
748
+ const onPlay = t8 === undefined ? null : t8;
749
+ const onPause = t9 === undefined ? null : t9;
750
+ const onEnded = t10 === undefined ? null : t10;
751
+ const onSeeked = t11 === undefined ? null : t11;
752
+ const onLoadStart = t12 === undefined ? null : t12;
753
+ const onCanPlayThough = t13 === undefined ? null : t13;
754
+ const ref = useRef(null);
755
+ const [muted, setMuted] = useState(initialMuted);
756
+ const [currentTime, setCurrentTime] = useState(null);
757
+ const [duration, setDuration] = useState(null);
758
+ const [playing, setPlaying] = useState(false);
759
+ const [ready, setReady] = useState(false);
760
+ const [initialPlay, setInitialPlay] = useState(true);
761
+ let t14;
762
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
763
+ t14 = {};
764
+ $[2] = t14;
765
+ } else {
766
+ t14 = $[2];
767
+ }
768
+ const progressStepsReached = useRef(t14);
769
+ const paused = !playing;
770
+ let t15;
771
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
772
+ t15 = () => {
773
+ const {
774
+ current: media
775
+ } = ref;
776
+ if (media !== null) {
754
777
  media.play();
755
778
  }
756
- }
757
- }, [playing]);
758
- var stop = useCallback(function () {
759
- var media = ref.current;
760
- if (media !== null) {
761
- media.pause();
762
- media.currentTime = 0;
763
- }
764
- }, []);
765
- var seek = useCallback(function (time) {
766
- var media = ref.current;
767
- if (media !== null) {
768
- media.currentTime = time;
769
- }
770
- }, []);
771
- var mute = useCallback(function () {
772
- var media = ref.current;
773
- if (media !== null) {
774
- media.muted = true;
775
- }
776
- }, []);
777
- var unMute = useCallback(function () {
778
- var media = ref.current;
779
- if (media !== null) {
780
- media.muted = false;
781
- }
782
- }, []);
783
- var toggleMute = useCallback(function () {
784
- var media = ref.current;
785
- if (media !== null) {
786
- media.muted = !muted;
787
- }
788
- }, [muted]);
789
-
790
- // Media events callbacks
791
- var onCustomPlay = useCallback(function () {
792
- if (onPlay !== null) {
793
- onPlay({
794
- initial: initialPlay
795
- });
796
- }
797
- if (initialPlay) {
798
- setInitialPlay(false);
799
- }
800
- setPlaying(true);
801
- }, [initialPlay, setPlaying, onPlay]);
802
- var onCustomPause = useCallback(function () {
803
- var media = ref.current;
804
- setPlaying(false);
805
- if (onPause !== null) {
806
- onPause({
807
- midway: media.currentTime > 0 && media.currentTime < media.duration
779
+ };
780
+ $[3] = t15;
781
+ } else {
782
+ t15 = $[3];
783
+ }
784
+ const play = t15;
785
+ let t16;
786
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
787
+ t16 = () => {
788
+ const {
789
+ current: media_0
790
+ } = ref;
791
+ if (media_0 !== null) {
792
+ media_0.pause();
793
+ }
794
+ };
795
+ $[4] = t16;
796
+ } else {
797
+ t16 = $[4];
798
+ }
799
+ const pause = t16;
800
+ let t17;
801
+ if ($[5] !== playing) {
802
+ t17 = () => {
803
+ const {
804
+ current: media_1
805
+ } = ref;
806
+ if (media_1 !== null) {
807
+ if (playing) {
808
+ media_1.pause();
809
+ } else {
810
+ media_1.play();
811
+ }
812
+ }
813
+ };
814
+ $[5] = playing;
815
+ $[6] = t17;
816
+ } else {
817
+ t17 = $[6];
818
+ }
819
+ const togglePlay = t17;
820
+ let t18;
821
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
822
+ t18 = () => {
823
+ const {
824
+ current: media_2
825
+ } = ref;
826
+ if (media_2 !== null) {
827
+ media_2.pause();
828
+ media_2.currentTime = 0;
829
+ }
830
+ };
831
+ $[7] = t18;
832
+ } else {
833
+ t18 = $[7];
834
+ }
835
+ const stop = t18;
836
+ let t19;
837
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
838
+ t19 = time => {
839
+ const {
840
+ current: media_3
841
+ } = ref;
842
+ if (media_3 !== null) {
843
+ media_3.currentTime = time;
844
+ }
845
+ };
846
+ $[8] = t19;
847
+ } else {
848
+ t19 = $[8];
849
+ }
850
+ const seek = t19;
851
+ let t20;
852
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
853
+ t20 = () => {
854
+ const {
855
+ current: media_4
856
+ } = ref;
857
+ if (media_4 !== null) {
858
+ media_4.muted = true;
859
+ }
860
+ };
861
+ $[9] = t20;
862
+ } else {
863
+ t20 = $[9];
864
+ }
865
+ const mute = t20;
866
+ let t21;
867
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
868
+ t21 = () => {
869
+ const {
870
+ current: media_5
871
+ } = ref;
872
+ if (media_5 !== null) {
873
+ media_5.muted = false;
874
+ }
875
+ };
876
+ $[10] = t21;
877
+ } else {
878
+ t21 = $[10];
879
+ }
880
+ const unMute = t21;
881
+ let t22;
882
+ if ($[11] !== muted) {
883
+ t22 = () => {
884
+ const {
885
+ current: media_6
886
+ } = ref;
887
+ if (media_6 !== null) {
888
+ media_6.muted = !muted;
889
+ }
890
+ };
891
+ $[11] = muted;
892
+ $[12] = t22;
893
+ } else {
894
+ t22 = $[12];
895
+ }
896
+ const toggleMute = t22;
897
+ let t23;
898
+ if ($[13] !== initialPlay || $[14] !== onPlay) {
899
+ t23 = () => {
900
+ if (onPlay !== null) {
901
+ onPlay({
902
+ initial: initialPlay
903
+ });
904
+ }
905
+ if (initialPlay) {
906
+ setInitialPlay(false);
907
+ }
908
+ setPlaying(true);
909
+ };
910
+ $[13] = initialPlay;
911
+ $[14] = onPlay;
912
+ $[15] = t23;
913
+ } else {
914
+ t23 = $[15];
915
+ }
916
+ const onCustomPlay = t23;
917
+ let t24;
918
+ if ($[16] !== onPause) {
919
+ t24 = () => {
920
+ const {
921
+ current: media_7
922
+ } = ref;
923
+ setPlaying(false);
924
+ if (onPause !== null) {
925
+ onPause({
926
+ midway: media_7.currentTime > 0 && media_7.currentTime < media_7.duration
927
+ });
928
+ }
929
+ };
930
+ $[16] = onPause;
931
+ $[17] = t24;
932
+ } else {
933
+ t24 = $[17];
934
+ }
935
+ const onCustomPause = t24;
936
+ let t25;
937
+ if ($[18] !== onEnded) {
938
+ t25 = () => {
939
+ const {
940
+ current: media_8
941
+ } = ref;
942
+ media_8.currentTime = 0;
943
+ if (onEnded !== null) {
944
+ onEnded();
945
+ }
946
+ setInitialPlay(true);
947
+ };
948
+ $[18] = onEnded;
949
+ $[19] = t25;
950
+ } else {
951
+ t25 = $[19];
952
+ }
953
+ const onCustomEnded = t25;
954
+ let t26;
955
+ if ($[20] !== onProgressStep || $[21] !== onTimeUpdate) {
956
+ t26 = () => {
957
+ const {
958
+ current: media_9
959
+ } = ref;
960
+ setCurrentTime(media_9.currentTime);
961
+ if (onTimeUpdate !== null) {
962
+ onTimeUpdate(media_9.currentTime);
963
+ }
964
+ const progress = media_9.currentTime / media_9.duration;
965
+ const currentSteps = progressStepsReached.current;
966
+ const stepsToTrack = progressSteps.filter(step => progress > step && typeof currentSteps[step] === "undefined");
967
+ stepsToTrack.forEach(step_0 => {
968
+ if (onProgressStep !== null) {
969
+ onProgressStep(step_0);
970
+ }
971
+ currentSteps[step_0] = true;
808
972
  });
809
- }
810
- }, [setPlaying, onPause]);
811
- var onCustomEnded = useCallback(function () {
812
- var media = ref.current;
813
- media.currentTime = 0;
814
- if (onEnded !== null) {
815
- onEnded();
816
- }
817
- setInitialPlay(true);
818
- }, [setInitialPlay, onEnded]);
819
- var onCustomTimeUpdate = useCallback(function () {
820
- var media = ref.current;
821
- setCurrentTime(media.currentTime);
822
- if (onTimeUpdate !== null) {
823
- onTimeUpdate(media.currentTime);
824
- }
825
- var progress = media.currentTime / media.duration;
826
- var currentSteps = progressStepsReached.current;
827
- var stepsToTrack = progressSteps.filter(function (step) {
828
- return progress > step && typeof currentSteps[step] === 'undefined';
829
- });
830
- stepsToTrack.forEach(function (step) {
831
- if (onProgressStep !== null) {
832
- onProgressStep(step);
973
+ };
974
+ $[20] = onProgressStep;
975
+ $[21] = onTimeUpdate;
976
+ $[22] = t26;
977
+ } else {
978
+ t26 = $[22];
979
+ }
980
+ const onCustomTimeUpdate = t26;
981
+ let t27;
982
+ if ($[23] !== onDurationChanged) {
983
+ t27 = () => {
984
+ const {
985
+ current: media_10
986
+ } = ref;
987
+ setDuration(media_10.duration);
988
+ if (onDurationChanged !== null) {
989
+ onDurationChanged(media_10.duration);
833
990
  }
834
- currentSteps[step] = true;
835
- });
836
- }, [setCurrentTime, onTimeUpdate, onProgressStep]);
837
- var onCustomDurationChange = useCallback(function () {
838
- var media = ref.current;
839
- setDuration(media.duration);
840
- if (onDurationChanged !== null) {
841
- onDurationChanged(media.duration);
842
- }
843
- }, [setDuration, onDurationChanged]);
844
- var onCustomSeeked = useCallback(function () {
845
- var media = ref.current;
846
- if (onSeeked !== null) {
847
- onSeeked(media.currentTime);
848
- }
849
- }, [onSeeked]);
850
- var onCustomVolumeChange = useCallback(function () {
851
- var media = ref.current;
852
- setMuted(media.muted);
853
- if (onVolumeChanged !== null) {
854
- onVolumeChanged(media.muted, media.volume);
855
- }
856
- }, [setMuted, onVolumeChanged]);
857
- var onCustomLoadStart = useCallback(function () {
858
- setReady(false);
859
- if (onLoadStart !== null) {
860
- onLoadStart();
861
- }
862
- }, [setReady, onLoadStart]);
863
- var onCustomCanPlayThrough = useCallback(function () {
864
- setReady(true);
865
- if (onCanPlayThough !== null) {
866
- onCanPlayThough();
867
- }
868
- }, [setReady, onCanPlayThough]);
869
- useEffect(function () {
870
- var media = ref.current;
871
- if (media !== null) {
872
- media.addEventListener('timeupdate', onCustomTimeUpdate);
873
- media.addEventListener('durationchange', onCustomDurationChange);
874
- media.addEventListener('volumechange', onCustomVolumeChange);
875
- media.addEventListener('play', onCustomPlay);
876
- media.addEventListener('pause', onCustomPause);
877
- media.addEventListener('ended', onCustomEnded);
878
- media.addEventListener('seeked', onCustomSeeked);
879
- media.addEventListener('loadstart', onCustomLoadStart);
880
- media.addEventListener('canplaythrough', onCustomCanPlayThrough);
881
- }
882
- return function () {
883
- if (media !== null) {
884
- media.removeEventListener('timeupdate', onCustomTimeUpdate);
885
- media.removeEventListener('durationchange', onCustomDurationChange);
886
- media.removeEventListener('volumechange', onCustomVolumeChange);
887
- media.removeEventListener('play', onCustomPlay);
888
- media.removeEventListener('pause', onCustomPause);
889
- media.removeEventListener('ended', onCustomEnded);
890
- media.removeEventListener('seeked', onCustomSeeked);
891
- media.removeEventListener('loadstart', onCustomLoadStart);
892
- media.removeEventListener('canplaythrough', onCustomCanPlayThrough);
991
+ };
992
+ $[23] = onDurationChanged;
993
+ $[24] = t27;
994
+ } else {
995
+ t27 = $[24];
996
+ }
997
+ const onCustomDurationChange = t27;
998
+ let t28;
999
+ if ($[25] !== onSeeked) {
1000
+ t28 = () => {
1001
+ const {
1002
+ current: media_11
1003
+ } = ref;
1004
+ if (onSeeked !== null) {
1005
+ onSeeked(media_11.currentTime);
893
1006
  }
894
1007
  };
895
- }, [url]);
896
- return {
897
- ref: ref,
898
- play: play,
899
- pause: pause,
900
- togglePlay: togglePlay,
901
- stop: stop,
902
- seek: seek,
903
- mute: mute,
904
- unMute: unMute,
905
- toggleMute: toggleMute,
906
- muted: muted,
907
- currentTime: currentTime,
908
- duration: duration,
909
- playing: playing,
910
- paused: paused,
911
- ready: ready
912
- };
1008
+ $[25] = onSeeked;
1009
+ $[26] = t28;
1010
+ } else {
1011
+ t28 = $[26];
1012
+ }
1013
+ const onCustomSeeked = t28;
1014
+ let t29;
1015
+ if ($[27] !== onVolumeChanged) {
1016
+ t29 = () => {
1017
+ const {
1018
+ current: media_12
1019
+ } = ref;
1020
+ setMuted(media_12.muted);
1021
+ if (onVolumeChanged !== null) {
1022
+ onVolumeChanged(media_12.muted, media_12.volume);
1023
+ }
1024
+ };
1025
+ $[27] = onVolumeChanged;
1026
+ $[28] = t29;
1027
+ } else {
1028
+ t29 = $[28];
1029
+ }
1030
+ const onCustomVolumeChange = t29;
1031
+ let t30;
1032
+ if ($[29] !== onLoadStart) {
1033
+ t30 = () => {
1034
+ setReady(false);
1035
+ if (onLoadStart !== null) {
1036
+ onLoadStart();
1037
+ }
1038
+ };
1039
+ $[29] = onLoadStart;
1040
+ $[30] = t30;
1041
+ } else {
1042
+ t30 = $[30];
1043
+ }
1044
+ const onCustomLoadStart = t30;
1045
+ let t31;
1046
+ if ($[31] !== onCanPlayThough) {
1047
+ t31 = () => {
1048
+ setReady(true);
1049
+ if (onCanPlayThough !== null) {
1050
+ onCanPlayThough();
1051
+ }
1052
+ };
1053
+ $[31] = onCanPlayThough;
1054
+ $[32] = t31;
1055
+ } else {
1056
+ t31 = $[32];
1057
+ }
1058
+ const onCustomCanPlayThrough = t31;
1059
+ let t32;
1060
+ if ($[33] !== onCustomCanPlayThrough || $[34] !== onCustomDurationChange || $[35] !== onCustomEnded || $[36] !== onCustomLoadStart || $[37] !== onCustomPause || $[38] !== onCustomPlay || $[39] !== onCustomSeeked || $[40] !== onCustomTimeUpdate || $[41] !== onCustomVolumeChange) {
1061
+ t32 = () => {
1062
+ const {
1063
+ current: media_13
1064
+ } = ref;
1065
+ if (media_13 !== null) {
1066
+ media_13.addEventListener("timeupdate", onCustomTimeUpdate);
1067
+ media_13.addEventListener("durationchange", onCustomDurationChange);
1068
+ media_13.addEventListener("volumechange", onCustomVolumeChange);
1069
+ media_13.addEventListener("play", onCustomPlay);
1070
+ media_13.addEventListener("pause", onCustomPause);
1071
+ media_13.addEventListener("ended", onCustomEnded);
1072
+ media_13.addEventListener("seeked", onCustomSeeked);
1073
+ media_13.addEventListener("loadstart", onCustomLoadStart);
1074
+ media_13.addEventListener("canplaythrough", onCustomCanPlayThrough);
1075
+ }
1076
+ return () => {
1077
+ if (media_13 !== null) {
1078
+ media_13.removeEventListener("timeupdate", onCustomTimeUpdate);
1079
+ media_13.removeEventListener("durationchange", onCustomDurationChange);
1080
+ media_13.removeEventListener("volumechange", onCustomVolumeChange);
1081
+ media_13.removeEventListener("play", onCustomPlay);
1082
+ media_13.removeEventListener("pause", onCustomPause);
1083
+ media_13.removeEventListener("ended", onCustomEnded);
1084
+ media_13.removeEventListener("seeked", onCustomSeeked);
1085
+ media_13.removeEventListener("loadstart", onCustomLoadStart);
1086
+ media_13.removeEventListener("canplaythrough", onCustomCanPlayThrough);
1087
+ }
1088
+ };
1089
+ };
1090
+ $[33] = onCustomCanPlayThrough;
1091
+ $[34] = onCustomDurationChange;
1092
+ $[35] = onCustomEnded;
1093
+ $[36] = onCustomLoadStart;
1094
+ $[37] = onCustomPause;
1095
+ $[38] = onCustomPlay;
1096
+ $[39] = onCustomSeeked;
1097
+ $[40] = onCustomTimeUpdate;
1098
+ $[41] = onCustomVolumeChange;
1099
+ $[42] = t32;
1100
+ } else {
1101
+ t32 = $[42];
1102
+ }
1103
+ let t33;
1104
+ if ($[43] !== url) {
1105
+ t33 = [url];
1106
+ $[43] = url;
1107
+ $[44] = t33;
1108
+ } else {
1109
+ t33 = $[44];
1110
+ }
1111
+ useEffect(t32, t33);
1112
+ let t34;
1113
+ if ($[45] !== currentTime || $[46] !== duration || $[47] !== muted || $[48] !== paused || $[49] !== playing || $[50] !== ready || $[51] !== toggleMute || $[52] !== togglePlay) {
1114
+ t34 = {
1115
+ ref,
1116
+ play,
1117
+ pause,
1118
+ togglePlay,
1119
+ stop,
1120
+ seek,
1121
+ mute,
1122
+ unMute,
1123
+ toggleMute,
1124
+ muted,
1125
+ currentTime,
1126
+ duration,
1127
+ playing,
1128
+ paused,
1129
+ ready
1130
+ };
1131
+ $[45] = currentTime;
1132
+ $[46] = duration;
1133
+ $[47] = muted;
1134
+ $[48] = paused;
1135
+ $[49] = playing;
1136
+ $[50] = ready;
1137
+ $[51] = toggleMute;
1138
+ $[52] = togglePlay;
1139
+ $[53] = t34;
1140
+ } else {
1141
+ t34 = $[53];
1142
+ }
1143
+ return t34;
913
1144
  }
914
1145
 
915
1146
  function useMediasParser() {
916
- // const screensManager = useScreensManager();
917
- var fieldsManager = useFieldsManager();
918
-
919
- // Convert medias object to path
920
- var parser = useMemo(function () {
921
- return new MediasParser({
922
- // screensManager,
923
- fieldsManager: fieldsManager
1147
+ const $ = c(10);
1148
+ const fieldsManager = useFieldsManager();
1149
+ let t0;
1150
+ if ($[0] !== fieldsManager) {
1151
+ t0 = new MediasParser({
1152
+ fieldsManager
924
1153
  });
925
- }, [fieldsManager]);
926
- var toPath = useCallback(function (story) {
927
- return parser.toPath(story);
928
- }, [parser]);
929
- var fromPath = useCallback(function (story) {
930
- return parser.fromPath(story);
931
- }, [parser]);
932
- return {
933
- toPath: toPath,
934
- fromPath: fromPath,
935
- parser: parser
936
- };
1154
+ $[0] = fieldsManager;
1155
+ $[1] = t0;
1156
+ } else {
1157
+ t0 = $[1];
1158
+ }
1159
+ const parser = t0;
1160
+ let t1;
1161
+ if ($[2] !== parser) {
1162
+ t1 = story => parser.toPath(story);
1163
+ $[2] = parser;
1164
+ $[3] = t1;
1165
+ } else {
1166
+ t1 = $[3];
1167
+ }
1168
+ const toPath = t1;
1169
+ let t2;
1170
+ if ($[4] !== parser) {
1171
+ t2 = story_0 => parser.fromPath(story_0);
1172
+ $[4] = parser;
1173
+ $[5] = t2;
1174
+ } else {
1175
+ t2 = $[5];
1176
+ }
1177
+ const fromPath = t2;
1178
+ let t3;
1179
+ if ($[6] !== fromPath || $[7] !== parser || $[8] !== toPath) {
1180
+ t3 = {
1181
+ toPath,
1182
+ fromPath,
1183
+ parser
1184
+ };
1185
+ $[6] = fromPath;
1186
+ $[7] = parser;
1187
+ $[8] = toPath;
1188
+ $[9] = t3;
1189
+ } else {
1190
+ t3 = $[9];
1191
+ }
1192
+ return t3;
937
1193
  }
938
1194
 
939
- function useResourceTypeName(resource) {
940
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
941
- var typeName = useMemo(function () {
942
- var _ref = resource || {},
943
- _ref$name = _ref.name,
944
- resourceName = _ref$name === void 0 ? null : _ref$name,
945
- _ref$types = _ref.types,
946
- types = _ref$types === void 0 ? [] : _ref$types,
947
- _ref$settings = _ref.settings,
948
- settings = _ref$settings === void 0 ? {} : _ref$settings;
949
- var _ref2 = settings || {},
950
- _ref2$hideTypeNames = _ref2.hideTypeNames,
951
- hideTypeNames = _ref2$hideTypeNames === void 0 ? false : _ref2$hideTypeNames;
1195
+ function useResourceTypeName(resource, t0) {
1196
+ const $ = c(7);
1197
+ const type = t0 === undefined ? null : t0;
1198
+ let t1;
1199
+ bb0: {
1200
+ let t2;
1201
+ if ($[0] !== resource) {
1202
+ t2 = resource || {};
1203
+ $[0] = resource;
1204
+ $[1] = t2;
1205
+ } else {
1206
+ t2 = $[1];
1207
+ }
1208
+ const {
1209
+ name: t3,
1210
+ types: t4,
1211
+ settings: t5
1212
+ } = t2;
1213
+ const resourceName = t3 === undefined ? null : t3;
1214
+ let t6;
1215
+ if ($[2] !== t4) {
1216
+ t6 = t4 === undefined ? [] : t4;
1217
+ $[2] = t4;
1218
+ $[3] = t6;
1219
+ } else {
1220
+ t6 = $[3];
1221
+ }
1222
+ const types = t6;
1223
+ const settings = t5 === undefined ? {} : t5;
1224
+ const {
1225
+ hideTypeNames: t7
1226
+ } = settings || {};
1227
+ const hideTypeNames = t7 === undefined ? false : t7;
952
1228
  if (hideTypeNames) {
953
- return null;
1229
+ t1 = null;
1230
+ break bb0;
954
1231
  }
955
- var _ref3 = type !== null && types !== null && types.length > 1 ? (types || []).find(function (_ref4) {
956
- var _ref4$id = _ref4.id,
957
- id = _ref4$id === void 0 ? null : _ref4$id;
1232
+ let t8;
1233
+ if ($[4] !== type || $[5] !== types) {
1234
+ t8 = type !== null && types !== null && types.length > 1 ? (types || []).find(t9 => {
1235
+ const {
1236
+ id: t10
1237
+ } = t9;
1238
+ const id = t10 === undefined ? null : t10;
958
1239
  return id === type;
959
- }) || {} : {},
960
- _ref3$name = _ref3.name,
961
- name = _ref3$name === void 0 ? null : _ref3$name;
962
- return name === resourceName ? null : name;
963
- }, [type, resource]);
1240
+ }) || {} : {};
1241
+ $[4] = type;
1242
+ $[5] = types;
1243
+ $[6] = t8;
1244
+ } else {
1245
+ t8 = $[6];
1246
+ }
1247
+ const {
1248
+ name: t9
1249
+ } = t8;
1250
+ const name = t9 === undefined ? null : t9;
1251
+ t1 = name === resourceName ? null : name;
1252
+ }
1253
+ const typeName = t1;
964
1254
  return typeName;
965
1255
  }
966
1256
 
967
1257
  function getResource(resources, resourceId) {
968
- return resourceId !== null && !isObject(resourceId) ? resources.find(function (it) {
969
- return it.id === resourceId;
970
- }) || null : resourceId;
1258
+ return resourceId !== null && !isObject(resourceId) ? resources.find(it => it.id === resourceId) || null : resourceId;
971
1259
  }
972
- function useResourceUrlGenerator() {
973
- var resourceId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
974
- var resources = usePanneauResources();
975
- var contextResource = useResource();
976
- var resource = getResource(resources, resourceId) || contextResource;
977
- var route = useUrlGenerator();
978
- return function (routeResourceId) {
979
- var routeName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
980
- var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
981
- var finalRouteName = resourceId !== null ? routeResourceId : routeName;
982
- var finalParams = resourceId !== null ? routeName : params;
983
- var finalResource = getResource(resources, routeResourceId) || resource;
984
- var _ref = finalResource || {},
985
- _ref$id = _ref.id,
986
- id = _ref$id === void 0 ? null : _ref$id;
987
- var finalRoute = id !== null ? route("resources.".concat(finalRouteName), _objectSpread(_objectSpread({}, finalParams), {}, {
988
- resource: id
989
- })) : null;
990
- return finalRoute;
991
- };
1260
+ function useResourceUrlGenerator(t0) {
1261
+ const $ = c(9);
1262
+ const resourceId = t0 === undefined ? null : t0;
1263
+ const resources = usePanneauResources();
1264
+ const contextResource = useResource();
1265
+ let t1;
1266
+ if ($[0] !== contextResource || $[1] !== resourceId || $[2] !== resources) {
1267
+ t1 = getResource(resources, resourceId) || contextResource;
1268
+ $[0] = contextResource;
1269
+ $[1] = resourceId;
1270
+ $[2] = resources;
1271
+ $[3] = t1;
1272
+ } else {
1273
+ t1 = $[3];
1274
+ }
1275
+ const resource = t1;
1276
+ const route = useUrlGenerator();
1277
+ let t2;
1278
+ if ($[4] !== resource || $[5] !== resourceId || $[6] !== resources || $[7] !== route) {
1279
+ t2 = (routeResourceId, t3, t4) => {
1280
+ const routeName = t3 === undefined ? null : t3;
1281
+ const params = t4 === undefined ? null : t4;
1282
+ const finalRouteName = resourceId !== null ? routeResourceId : routeName;
1283
+ const finalParams = resourceId !== null ? routeName : params;
1284
+ const finalResource = getResource(resources, routeResourceId) || resource;
1285
+ const {
1286
+ id: t5
1287
+ } = finalResource || {};
1288
+ const id = t5 === undefined ? null : t5;
1289
+ const finalRoute = id !== null ? route(`resources.${finalRouteName}`, {
1290
+ ...finalParams,
1291
+ resource: id
1292
+ }) : null;
1293
+ return finalRoute;
1294
+ };
1295
+ $[4] = resource;
1296
+ $[5] = resourceId;
1297
+ $[6] = resources;
1298
+ $[7] = route;
1299
+ $[8] = t2;
1300
+ } else {
1301
+ t2 = $[8];
1302
+ }
1303
+ return t2;
992
1304
  }
993
1305
 
994
- function useQuery() {
995
- var initialBaseQuery = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
996
- var paginated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
997
- var initialQuery = useMemo(function () {
998
- return paginated ? _objectSpread({
1306
+ function useQuery(t0, t1) {
1307
+ const $ = c(15);
1308
+ const initialBaseQuery = t0 === undefined ? null : t0;
1309
+ const paginated = t1 === undefined ? true : t1;
1310
+ let t2;
1311
+ if ($[0] !== initialBaseQuery || $[1] !== paginated) {
1312
+ t2 = paginated ? {
999
1313
  page: 1,
1000
- count: 10
1001
- }, initialBaseQuery || {}) : initialBaseQuery || null;
1002
- }, [paginated, initialBaseQuery]);
1003
- var _useState = useState(initialQuery),
1004
- _useState2 = _slicedToArray(_useState, 2),
1005
- query = _useState2[0],
1006
- setQuery = _useState2[1];
1007
- useEffect(function () {
1008
- setQuery(initialQuery);
1009
- }, [initialQuery, setQuery]);
1010
- var onPageChange = useCallback(function (newPage) {
1011
- if (newPage !== null) {
1012
- setQuery(function (prev) {
1013
- return _objectSpread(_objectSpread({}, prev || {}), {}, {
1314
+ count: 10,
1315
+ ...(initialBaseQuery || {})
1316
+ } : initialBaseQuery || null;
1317
+ $[0] = initialBaseQuery;
1318
+ $[1] = paginated;
1319
+ $[2] = t2;
1320
+ } else {
1321
+ t2 = $[2];
1322
+ }
1323
+ const initialQuery = t2;
1324
+ const [query, setQuery] = useState(initialQuery);
1325
+ let t3;
1326
+ let t4;
1327
+ if ($[3] !== initialQuery) {
1328
+ t3 = () => {
1329
+ setQuery(initialQuery);
1330
+ };
1331
+ t4 = [initialQuery, setQuery];
1332
+ $[3] = initialQuery;
1333
+ $[4] = t3;
1334
+ $[5] = t4;
1335
+ } else {
1336
+ t3 = $[4];
1337
+ t4 = $[5];
1338
+ }
1339
+ useEffect(t3, t4);
1340
+ let t5;
1341
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
1342
+ t5 = newPage => {
1343
+ if (newPage !== null) {
1344
+ setQuery(prev => ({
1345
+ ...(prev || {}),
1014
1346
  page: newPage || 1
1015
- });
1347
+ }));
1348
+ }
1349
+ };
1350
+ $[6] = t5;
1351
+ } else {
1352
+ t5 = $[6];
1353
+ }
1354
+ const onPageChange = t5;
1355
+ let t6;
1356
+ if ($[7] !== initialQuery) {
1357
+ t6 = newQuery => {
1358
+ const finalQuery = newQuery !== null ? Object.keys(newQuery).reduce((currentQuery, key) => {
1359
+ const val = newQuery[key];
1360
+ return val !== null ? {
1361
+ ...(currentQuery || {}),
1362
+ [key]: val
1363
+ } : currentQuery;
1364
+ }, null) : null;
1365
+ setQuery({
1366
+ ...(initialQuery || {}),
1367
+ ...(finalQuery || {})
1016
1368
  });
1017
- }
1018
- }, [setQuery]);
1019
- var onQueryChange = useCallback(function (newQuery) {
1020
- var finalQuery = newQuery !== null ? Object.keys(newQuery).reduce(function (currentQuery, key) {
1021
- var val = newQuery[key];
1022
- return val !== null ? _objectSpread(_objectSpread({}, currentQuery || {}), {}, _defineProperty({}, key, val)) : currentQuery;
1023
- }, null) : null;
1024
- setQuery(_objectSpread(_objectSpread({}, initialQuery || {}), finalQuery || {}));
1025
- }, [setQuery, initialQuery]);
1026
- var onQueryReset = useCallback(function () {
1027
- setQuery(initialQuery);
1028
- }, [initialQuery, setQuery]);
1029
- return {
1030
- query: query,
1031
- onPageChange: onPageChange,
1032
- onQueryChange: onQueryChange,
1033
- onQueryReset: onQueryReset
1034
- };
1369
+ };
1370
+ $[7] = initialQuery;
1371
+ $[8] = t6;
1372
+ } else {
1373
+ t6 = $[8];
1374
+ }
1375
+ const onQueryChange = t6;
1376
+ let t7;
1377
+ if ($[9] !== initialQuery) {
1378
+ t7 = () => {
1379
+ setQuery(initialQuery);
1380
+ };
1381
+ $[9] = initialQuery;
1382
+ $[10] = t7;
1383
+ } else {
1384
+ t7 = $[10];
1385
+ }
1386
+ const onQueryReset = t7;
1387
+ let t8;
1388
+ if ($[11] !== onQueryChange || $[12] !== onQueryReset || $[13] !== query) {
1389
+ t8 = {
1390
+ query,
1391
+ onPageChange,
1392
+ onQueryChange,
1393
+ onQueryReset
1394
+ };
1395
+ $[11] = onQueryChange;
1396
+ $[12] = onQueryReset;
1397
+ $[13] = query;
1398
+ $[14] = t8;
1399
+ } else {
1400
+ t8 = $[14];
1401
+ }
1402
+ return t8;
1035
1403
  }
1036
1404
 
1037
- var _excluded = ["width", "height"],
1038
- _excluded2 = ["withoutMaxSize"];
1039
- function useScreenSize(_ref) {
1040
- var _ref$width = _ref.width,
1041
- width = _ref$width === void 0 ? null : _ref$width,
1042
- _ref$height = _ref.height,
1043
- height = _ref$height === void 0 ? null : _ref$height,
1044
- _ref$landscape = _ref.landscape,
1045
- landscape = _ref$landscape === void 0 ? false : _ref$landscape,
1046
- _ref$screens = _ref.screens,
1047
- screens = _ref$screens === void 0 ? [] : _ref$screens,
1048
- _ref$mediaType = _ref.mediaType,
1049
- mediaType = _ref$mediaType === void 0 ? 'screen' : _ref$mediaType,
1050
- _ref$media = _ref.media,
1051
- providedMedia = _ref$media === void 0 ? null : _ref$media;
1052
- // Get media
1053
- var media = useMemo(function () {
1054
- return providedMedia !== null ? providedMedia : {
1405
+ function useScreenSize(t0) {
1406
+ const $ = c(20);
1407
+ const {
1408
+ width: t1,
1409
+ height: t2,
1410
+ landscape: t3,
1411
+ screens: t4,
1412
+ mediaType: t5,
1413
+ media: t6
1414
+ } = t0;
1415
+ const width = t1 === undefined ? null : t1;
1416
+ const height = t2 === undefined ? null : t2;
1417
+ const landscape = t3 === undefined ? false : t3;
1418
+ let t7;
1419
+ if ($[0] !== t4) {
1420
+ t7 = t4 === undefined ? [] : t4;
1421
+ $[0] = t4;
1422
+ $[1] = t7;
1423
+ } else {
1424
+ t7 = $[1];
1425
+ }
1426
+ const screens = t7;
1427
+ const mediaType = t5 === undefined ? "screen" : t5;
1428
+ const providedMedia = t6 === undefined ? null : t6;
1429
+ let t8;
1430
+ if ($[2] !== height || $[3] !== mediaType || $[4] !== providedMedia || $[5] !== width) {
1431
+ t8 = providedMedia !== null ? providedMedia : {
1055
1432
  type: mediaType,
1056
- width: "".concat(width, "px"),
1057
- height: "".concat(height, "px")
1433
+ width: `${width}px`,
1434
+ height: `${height}px`
1058
1435
  };
1059
- }, [providedMedia, mediaType, width, height]);
1060
-
1061
- // Get matching screens
1062
- var matchingScreens = useMemo(function () {
1063
- return _toConsumableArray(screens).reverse().filter(function (_ref2) {
1064
- var _ref2$mediaQuery = _ref2.mediaQuery,
1065
- mediaQuery = _ref2$mediaQuery === void 0 ? null : _ref2$mediaQuery;
1066
- return mediaQuery === null || match(mediaQuery, media);
1067
- });
1068
- }, [screens, media]);
1069
- return {
1070
- screen: matchingScreens.length > 0 ? matchingScreens[0].name : null,
1071
- screens: _toConsumableArray(matchingScreens).reverse().map(function (_ref3) {
1072
- var name = _ref3.name;
1073
- return name;
1074
- }),
1075
- width: width,
1076
- height: height,
1077
- landscape: landscape
1078
- };
1436
+ $[2] = height;
1437
+ $[3] = mediaType;
1438
+ $[4] = providedMedia;
1439
+ $[5] = width;
1440
+ $[6] = t8;
1441
+ } else {
1442
+ t8 = $[6];
1443
+ }
1444
+ const media = t8;
1445
+ let t9;
1446
+ if ($[7] !== media || $[8] !== screens) {
1447
+ let t10;
1448
+ if ($[10] !== media) {
1449
+ t10 = t11 => {
1450
+ const {
1451
+ mediaQuery: t12
1452
+ } = t11;
1453
+ const mediaQuery = t12 === undefined ? null : t12;
1454
+ return mediaQuery === null || match(mediaQuery, media);
1455
+ };
1456
+ $[10] = media;
1457
+ $[11] = t10;
1458
+ } else {
1459
+ t10 = $[11];
1460
+ }
1461
+ t9 = [...screens].reverse().filter(t10);
1462
+ $[7] = media;
1463
+ $[8] = screens;
1464
+ $[9] = t9;
1465
+ } else {
1466
+ t9 = $[9];
1467
+ }
1468
+ const matchingScreens = t9;
1469
+ const t10 = matchingScreens.length > 0 ? matchingScreens[0].name : null;
1470
+ let t11;
1471
+ if ($[12] !== matchingScreens) {
1472
+ t11 = [...matchingScreens].reverse().map(_temp);
1473
+ $[12] = matchingScreens;
1474
+ $[13] = t11;
1475
+ } else {
1476
+ t11 = $[13];
1477
+ }
1478
+ let t12;
1479
+ if ($[14] !== height || $[15] !== landscape || $[16] !== t10 || $[17] !== t11 || $[18] !== width) {
1480
+ t12 = {
1481
+ screen: t10,
1482
+ screens: t11,
1483
+ width,
1484
+ height,
1485
+ landscape
1486
+ };
1487
+ $[14] = height;
1488
+ $[15] = landscape;
1489
+ $[16] = t10;
1490
+ $[17] = t11;
1491
+ $[18] = width;
1492
+ $[19] = t12;
1493
+ } else {
1494
+ t12 = $[19];
1495
+ }
1496
+ return t12;
1497
+ }
1498
+ function _temp(t0) {
1499
+ const {
1500
+ name
1501
+ } = t0;
1502
+ return name;
1079
1503
  }
1080
- function useScreenSizeFromElement() {
1081
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1082
- _ref4$width = _ref4.width,
1083
- width = _ref4$width === void 0 ? null : _ref4$width,
1084
- _ref4$height = _ref4.height,
1085
- height = _ref4$height === void 0 ? null : _ref4$height,
1086
- opts = _objectWithoutProperties(_ref4, _excluded);
1087
- var _useResizeObserver = useResizeObserver(),
1088
- ref = _useResizeObserver.ref,
1089
- contentRect = _useResizeObserver.entry.contentRect;
1090
- var _ref5 = contentRect || {},
1091
- _ref5$width = _ref5.width,
1092
- calculatedWidth = _ref5$width === void 0 ? 0 : _ref5$width,
1093
- _ref5$height = _ref5.height,
1094
- calculatedHeight = _ref5$height === void 0 ? 0 : _ref5$height;
1095
- var semiFinalWidth = width !== null ? width : calculatedWidth;
1096
- var semiFinalHeight = height !== null ? height : calculatedHeight;
1097
- var landscape = semiFinalHeight > 0 && semiFinalWidth > semiFinalHeight;
1098
- var _opts$withoutMaxSize = opts.withoutMaxSize,
1099
- withoutMaxSize = _opts$withoutMaxSize === void 0 ? false : _opts$withoutMaxSize,
1100
- restOpts = _objectWithoutProperties(opts, _excluded2);
1101
- var finalWidth = landscape && !withoutMaxSize ? Math.round(Math.max(320, 0.45 * semiFinalHeight)) : semiFinalWidth;
1102
- var finalHeight = landscape && !withoutMaxSize ? Math.round(Math.max(533, 0.75 * semiFinalHeight)) : semiFinalHeight;
1504
+ function useScreenSizeFromElement(t0) {
1505
+ const $ = c(28);
1506
+ let t1;
1507
+ if ($[0] !== t0) {
1508
+ t1 = t0 === undefined ? {} : t0;
1509
+ $[0] = t0;
1510
+ $[1] = t1;
1511
+ } else {
1512
+ t1 = $[1];
1513
+ }
1514
+ let opts;
1515
+ let t2;
1516
+ let t3;
1517
+ if ($[2] !== t1) {
1518
+ ({
1519
+ width: t2,
1520
+ height: t3,
1521
+ ...opts
1522
+ } = t1);
1523
+ $[2] = t1;
1524
+ $[3] = opts;
1525
+ $[4] = t2;
1526
+ $[5] = t3;
1527
+ } else {
1528
+ opts = $[3];
1529
+ t2 = $[4];
1530
+ t3 = $[5];
1531
+ }
1532
+ const width = t2 === undefined ? null : t2;
1533
+ const height = t3 === undefined ? null : t3;
1534
+ const {
1535
+ ref,
1536
+ entry: t4
1537
+ } = useResizeObserver();
1538
+ const {
1539
+ contentRect
1540
+ } = t4;
1541
+ let t5;
1542
+ if ($[6] !== contentRect) {
1543
+ t5 = contentRect || {};
1544
+ $[6] = contentRect;
1545
+ $[7] = t5;
1546
+ } else {
1547
+ t5 = $[7];
1548
+ }
1549
+ const {
1550
+ width: t6,
1551
+ height: t7
1552
+ } = t5;
1553
+ const calculatedWidth = t6 === undefined ? 0 : t6;
1554
+ const calculatedHeight = t7 === undefined ? 0 : t7;
1555
+ const semiFinalWidth = width !== null ? width : calculatedWidth;
1556
+ const semiFinalHeight = height !== null ? height : calculatedHeight;
1557
+ const landscape = semiFinalHeight > 0 && semiFinalWidth > semiFinalHeight;
1558
+ let restOpts;
1559
+ let t8;
1560
+ if ($[8] !== opts) {
1561
+ ({
1562
+ withoutMaxSize: t8,
1563
+ ...restOpts
1564
+ } = opts);
1565
+ $[8] = opts;
1566
+ $[9] = restOpts;
1567
+ $[10] = t8;
1568
+ } else {
1569
+ restOpts = $[9];
1570
+ t8 = $[10];
1571
+ }
1572
+ const withoutMaxSize = t8 === undefined ? false : t8;
1573
+ let t9;
1574
+ if ($[11] !== landscape || $[12] !== semiFinalHeight || $[13] !== semiFinalWidth || $[14] !== withoutMaxSize) {
1575
+ t9 = landscape && !withoutMaxSize ? Math.round(Math.max(320, 0.45 * semiFinalHeight)) : semiFinalWidth;
1576
+ $[11] = landscape;
1577
+ $[12] = semiFinalHeight;
1578
+ $[13] = semiFinalWidth;
1579
+ $[14] = withoutMaxSize;
1580
+ $[15] = t9;
1581
+ } else {
1582
+ t9 = $[15];
1583
+ }
1584
+ let finalWidth = t9;
1585
+ let t10;
1586
+ if ($[16] !== landscape || $[17] !== semiFinalHeight || $[18] !== withoutMaxSize) {
1587
+ t10 = landscape && !withoutMaxSize ? Math.round(Math.max(533, 0.75 * semiFinalHeight)) : semiFinalHeight;
1588
+ $[16] = landscape;
1589
+ $[17] = semiFinalHeight;
1590
+ $[18] = withoutMaxSize;
1591
+ $[19] = t10;
1592
+ } else {
1593
+ t10 = $[19];
1594
+ }
1595
+ let finalHeight = t10;
1103
1596
  if (finalWidth % 2 === 1) {
1104
- finalWidth -= 1;
1597
+ finalWidth = finalWidth - 1;
1105
1598
  }
1106
1599
  if (finalHeight % 2 === 1) {
1107
- finalHeight -= 1;
1600
+ finalHeight = finalHeight - 1;
1108
1601
  }
1109
- var screenSize = useScreenSize(_objectSpread({
1110
- width: finalWidth,
1111
- height: finalHeight,
1112
- landscape: landscape
1113
- }, restOpts));
1114
- return {
1115
- ref: ref,
1116
- screenSize: screenSize
1117
- };
1602
+ let t11;
1603
+ if ($[20] !== finalHeight || $[21] !== finalWidth || $[22] !== landscape || $[23] !== restOpts) {
1604
+ t11 = {
1605
+ width: finalWidth,
1606
+ height: finalHeight,
1607
+ landscape,
1608
+ ...restOpts
1609
+ };
1610
+ $[20] = finalHeight;
1611
+ $[21] = finalWidth;
1612
+ $[22] = landscape;
1613
+ $[23] = restOpts;
1614
+ $[24] = t11;
1615
+ } else {
1616
+ t11 = $[24];
1617
+ }
1618
+ const screenSize = useScreenSize(t11);
1619
+ let t12;
1620
+ if ($[25] !== ref || $[26] !== screenSize) {
1621
+ t12 = {
1622
+ ref,
1623
+ screenSize
1624
+ };
1625
+ $[25] = ref;
1626
+ $[26] = screenSize;
1627
+ $[27] = t12;
1628
+ } else {
1629
+ t12 = $[27];
1630
+ }
1631
+ return t12;
1118
1632
  }
1119
1633
  function getWindowSize() {
1120
1634
  return {
@@ -1122,29 +1636,63 @@ function getWindowSize() {
1122
1636
  height: typeof window !== 'undefined' ? window.innerHeight : null
1123
1637
  };
1124
1638
  }
1125
- function useScreenSizeFromWindow() {
1126
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1127
- var _useState = useState(getWindowSize()),
1128
- _useState2 = _slicedToArray(_useState, 2),
1129
- windowSize = _useState2[0],
1130
- setWindowSize = _useState2[1];
1131
- useEffect(function () {
1132
- var onResize = function onResize() {
1133
- return setWindowSize(getWindowSize());
1134
- };
1135
- if (typeof window !== 'undefined') {
1136
- window.addEventListener('resize', onResize);
1137
- }
1138
- return function () {
1139
- if (typeof window !== 'undefined') {
1140
- window.removeEventListener('resize', onResize);
1639
+ function useScreenSizeFromWindow(t0) {
1640
+ const $ = c(8);
1641
+ let t1;
1642
+ if ($[0] !== t0) {
1643
+ t1 = t0 === undefined ? {} : t0;
1644
+ $[0] = t0;
1645
+ $[1] = t1;
1646
+ } else {
1647
+ t1 = $[1];
1648
+ }
1649
+ const opts = t1;
1650
+ let t2;
1651
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
1652
+ t2 = getWindowSize();
1653
+ $[2] = t2;
1654
+ } else {
1655
+ t2 = $[2];
1656
+ }
1657
+ const [windowSize, setWindowSize] = useState(t2);
1658
+ let t3;
1659
+ let t4;
1660
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
1661
+ t3 = () => {
1662
+ const onResize = () => setWindowSize(getWindowSize());
1663
+ if (typeof window !== "undefined") {
1664
+ window.addEventListener("resize", onResize);
1141
1665
  }
1666
+ return () => {
1667
+ if (typeof window !== "undefined") {
1668
+ window.removeEventListener("resize", onResize);
1669
+ }
1670
+ };
1142
1671
  };
1143
- }, [setWindowSize]);
1144
- return useScreenSize(_objectSpread(_objectSpread({}, opts), windowSize));
1672
+ t4 = [setWindowSize];
1673
+ $[3] = t3;
1674
+ $[4] = t4;
1675
+ } else {
1676
+ t3 = $[3];
1677
+ t4 = $[4];
1678
+ }
1679
+ useEffect(t3, t4);
1680
+ let t5;
1681
+ if ($[5] !== opts || $[6] !== windowSize) {
1682
+ t5 = {
1683
+ ...opts,
1684
+ ...windowSize
1685
+ };
1686
+ $[5] = opts;
1687
+ $[6] = windowSize;
1688
+ $[7] = t5;
1689
+ } else {
1690
+ t5 = $[7];
1691
+ }
1692
+ return useScreenSize(t5);
1145
1693
  }
1146
1694
 
1147
- var eventsManager = typeof window !== 'undefined' ? new EventsManager(window) : null;
1148
- var useWindowEvent = createUseEvent(eventsManager);
1695
+ const eventsManager = typeof window !== 'undefined' ? new EventsManager(window) : null;
1696
+ const useWindowEvent = createUseEvent(eventsManager);
1149
1697
 
1150
1698
  export { KEYCODES, getObserver, useAnimationFrame, useDocumentEvent, useForm, useFormattedDate, useFormattedTime, useIntersectionObserver, useIsVisible, useKeyboardKeys, useLoadedFonts, useMediaApi, useMediasParser, useObserver, useQuery, useResizeObserver, useResourceTypeName, useResourceUrlGenerator, useScreenSizeFromElement, useScreenSizeFromWindow, useWindowEvent };