UNPKG

365 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
3 typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
4 (global = global || self, factory(global.ReactBeautifulDnd = {}, global.React, global.ReactDOM));
5}(this, (function (exports, React, ReactDOM) { 'use strict';
6
7 var React__default = 'default' in React ? React['default'] : React;
8 var ReactDOM__default = 'default' in ReactDOM ? ReactDOM['default'] : ReactDOM;
9
10 function _inheritsLoose(subClass, superClass) {
11 subClass.prototype = Object.create(superClass.prototype);
12 subClass.prototype.constructor = subClass;
13 subClass.__proto__ = superClass;
14 }
15
16 var spacesAndTabs = /[ \t]{2,}/g;
17 var lineStartWithSpaces = /^[ \t]*/gm;
18
19 var clean = function clean(value) {
20 return value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();
21 };
22
23 var getDevMessage = function getDevMessage(message) {
24 return clean("\n %creact-beautiful-dnd\n\n %c" + clean(message) + "\n\n %c\uD83D\uDC77\u200D This is a development only message. It will be removed in production builds.\n");
25 };
26
27 var getFormattedMessage = function getFormattedMessage(message) {
28 return [getDevMessage(message), 'color: #00C584; font-size: 1.2em; font-weight: bold;', 'line-height: 1.5', 'color: #723874;'];
29 };
30 var isDisabledFlag = '__react-beautiful-dnd-disable-dev-warnings';
31 function log(type, message) {
32 var _console;
33
34 if (typeof window !== 'undefined' && window[isDisabledFlag]) {
35 return;
36 }
37
38 (_console = console)[type].apply(_console, getFormattedMessage(message));
39 }
40 var warning = log.bind(null, 'warn');
41 var error = log.bind(null, 'error');
42
43 function noop() {}
44
45 function _extends() {
46 _extends = Object.assign || function (target) {
47 for (var i = 1; i < arguments.length; i++) {
48 var source = arguments[i];
49
50 for (var key in source) {
51 if (Object.prototype.hasOwnProperty.call(source, key)) {
52 target[key] = source[key];
53 }
54 }
55 }
56
57 return target;
58 };
59
60 return _extends.apply(this, arguments);
61 }
62
63 function getOptions(shared, fromBinding) {
64 return _extends({}, shared, {}, fromBinding);
65 }
66
67 function bindEvents(el, bindings, sharedOptions) {
68 var unbindings = bindings.map(function (binding) {
69 var options = getOptions(sharedOptions, binding.options);
70 el.addEventListener(binding.eventName, binding.fn, options);
71 return function unbind() {
72 el.removeEventListener(binding.eventName, binding.fn, options);
73 };
74 });
75 return function unbindAll() {
76 unbindings.forEach(function (unbind) {
77 unbind();
78 });
79 };
80 }
81
82 var prefix = 'Invariant failed';
83 function RbdInvariant(message) {
84 this.message = message;
85 }
86
87 RbdInvariant.prototype.toString = function toString() {
88 return this.message;
89 };
90
91 function invariant(condition, message) {
92 if (condition) {
93 return;
94 }
95
96 {
97 throw new RbdInvariant(prefix + ": " + (message || ''));
98 }
99 }
100
101 var ErrorBoundary = function (_React$Component) {
102 _inheritsLoose(ErrorBoundary, _React$Component);
103
104 function ErrorBoundary() {
105 var _this;
106
107 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
108 args[_key] = arguments[_key];
109 }
110
111 _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
112 _this.callbacks = null;
113 _this.unbind = noop;
114
115 _this.onWindowError = function (event) {
116 var callbacks = _this.getCallbacks();
117
118 if (callbacks.isDragging()) {
119 callbacks.tryAbort();
120 warning("\n An error was caught by our window 'error' event listener while a drag was occurring.\n The active drag has been aborted.\n ") ;
121 }
122
123 var err = event.error;
124
125 if (err instanceof RbdInvariant) {
126 event.preventDefault();
127
128 {
129 error(err.message);
130 }
131 }
132 };
133
134 _this.getCallbacks = function () {
135 if (!_this.callbacks) {
136 throw new Error('Unable to find AppCallbacks in <ErrorBoundary/>');
137 }
138
139 return _this.callbacks;
140 };
141
142 _this.setCallbacks = function (callbacks) {
143 _this.callbacks = callbacks;
144 };
145
146 return _this;
147 }
148
149 var _proto = ErrorBoundary.prototype;
150
151 _proto.componentDidMount = function componentDidMount() {
152 this.unbind = bindEvents(window, [{
153 eventName: 'error',
154 fn: this.onWindowError
155 }]);
156 };
157
158 _proto.componentDidCatch = function componentDidCatch(err) {
159 if (err instanceof RbdInvariant) {
160 {
161 error(err.message);
162 }
163
164 this.setState({});
165 return;
166 }
167
168 throw err;
169 };
170
171 _proto.componentWillUnmount = function componentWillUnmount() {
172 this.unbind();
173 };
174
175 _proto.render = function render() {
176 return this.props.children(this.setCallbacks);
177 };
178
179 return ErrorBoundary;
180 }(React__default.Component);
181
182 var dragHandleUsageInstructions = "\n Press space bar to start a drag.\n When dragging you can use the arrow keys to move the item around and escape to cancel.\n Some screen readers may require you to be in focus mode or to use your pass through key\n";
183
184 var position = function position(index) {
185 return index + 1;
186 };
187
188 var onDragStart = function onDragStart(start) {
189 return "\n You have lifted an item in position " + position(start.source.index) + "\n";
190 };
191
192 var withLocation = function withLocation(source, destination) {
193 var isInHomeList = source.droppableId === destination.droppableId;
194 var startPosition = position(source.index);
195 var endPosition = position(destination.index);
196
197 if (isInHomeList) {
198 return "\n You have moved the item from position " + startPosition + "\n to position " + endPosition + "\n ";
199 }
200
201 return "\n You have moved the item from position " + startPosition + "\n in list " + source.droppableId + "\n to list " + destination.droppableId + "\n in position " + endPosition + "\n ";
202 };
203
204 var withCombine = function withCombine(id, source, combine) {
205 var inHomeList = source.droppableId === combine.droppableId;
206
207 if (inHomeList) {
208 return "\n The item " + id + "\n has been combined with " + combine.draggableId;
209 }
210
211 return "\n The item " + id + "\n in list " + source.droppableId + "\n has been combined with " + combine.draggableId + "\n in list " + combine.droppableId + "\n ";
212 };
213
214 var onDragUpdate = function onDragUpdate(update) {
215 var location = update.destination;
216
217 if (location) {
218 return withLocation(update.source, location);
219 }
220
221 var combine = update.combine;
222
223 if (combine) {
224 return withCombine(update.draggableId, update.source, combine);
225 }
226
227 return 'You are over an area that cannot be dropped on';
228 };
229
230 var returnedToStart = function returnedToStart(source) {
231 return "\n The item has returned to its starting position\n of " + position(source.index) + "\n";
232 };
233
234 var onDragEnd = function onDragEnd(result) {
235 if (result.reason === 'CANCEL') {
236 return "\n Movement cancelled.\n " + returnedToStart(result.source) + "\n ";
237 }
238
239 var location = result.destination;
240 var combine = result.combine;
241
242 if (location) {
243 return "\n You have dropped the item.\n " + withLocation(result.source, location) + "\n ";
244 }
245
246 if (combine) {
247 return "\n You have dropped the item.\n " + withCombine(result.draggableId, result.source, combine) + "\n ";
248 }
249
250 return "\n The item has been dropped while not over a drop area.\n " + returnedToStart(result.source) + "\n ";
251 };
252
253 var preset = {
254 dragHandleUsageInstructions: dragHandleUsageInstructions,
255 onDragStart: onDragStart,
256 onDragUpdate: onDragUpdate,
257 onDragEnd: onDragEnd
258 };
259
260 function symbolObservablePonyfill(root) {
261 var result;
262 var Symbol = root.Symbol;
263
264 if (typeof Symbol === 'function') {
265 if (Symbol.observable) {
266 result = Symbol.observable;
267 } else {
268 result = Symbol('observable');
269 Symbol.observable = result;
270 }
271 } else {
272 result = '@@observable';
273 }
274
275 return result;
276 }
277
278 /* global window */
279
280 var root;
281
282 if (typeof self !== 'undefined') {
283 root = self;
284 } else if (typeof window !== 'undefined') {
285 root = window;
286 } else if (typeof global !== 'undefined') {
287 root = global;
288 } else if (typeof module !== 'undefined') {
289 root = module;
290 } else {
291 root = Function('return this')();
292 }
293
294 var result = symbolObservablePonyfill(root);
295
296 /**
297 * These are private action types reserved by Redux.
298 * For any unknown actions, you must return the current state.
299 * If the current state is undefined, you must return the initial state.
300 * Do not reference these action types directly in your code.
301 */
302 var randomString = function randomString() {
303 return Math.random().toString(36).substring(7).split('').join('.');
304 };
305
306 var ActionTypes = {
307 INIT: "@@redux/INIT" + randomString(),
308 REPLACE: "@@redux/REPLACE" + randomString(),
309 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
310 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
311 }
312 };
313
314 /**
315 * @param {any} obj The object to inspect.
316 * @returns {boolean} True if the argument appears to be a plain object.
317 */
318 function isPlainObject(obj) {
319 if (typeof obj !== 'object' || obj === null) return false;
320 var proto = obj;
321
322 while (Object.getPrototypeOf(proto) !== null) {
323 proto = Object.getPrototypeOf(proto);
324 }
325
326 return Object.getPrototypeOf(obj) === proto;
327 }
328
329 /**
330 * Creates a Redux store that holds the state tree.
331 * The only way to change the data in the store is to call `dispatch()` on it.
332 *
333 * There should only be a single store in your app. To specify how different
334 * parts of the state tree respond to actions, you may combine several reducers
335 * into a single reducer function by using `combineReducers`.
336 *
337 * @param {Function} reducer A function that returns the next state tree, given
338 * the current state tree and the action to handle.
339 *
340 * @param {any} [preloadedState] The initial state. You may optionally specify it
341 * to hydrate the state from the server in universal apps, or to restore a
342 * previously serialized user session.
343 * If you use `combineReducers` to produce the root reducer function, this must be
344 * an object with the same shape as `combineReducers` keys.
345 *
346 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
347 * to enhance the store with third-party capabilities such as middleware,
348 * time travel, persistence, etc. The only store enhancer that ships with Redux
349 * is `applyMiddleware()`.
350 *
351 * @returns {Store} A Redux store that lets you read the state, dispatch actions
352 * and subscribe to changes.
353 */
354
355 function createStore(reducer, preloadedState, enhancer) {
356 var _ref2;
357
358 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
359 throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function.');
360 }
361
362 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
363 enhancer = preloadedState;
364 preloadedState = undefined;
365 }
366
367 if (typeof enhancer !== 'undefined') {
368 if (typeof enhancer !== 'function') {
369 throw new Error('Expected the enhancer to be a function.');
370 }
371
372 return enhancer(createStore)(reducer, preloadedState);
373 }
374
375 if (typeof reducer !== 'function') {
376 throw new Error('Expected the reducer to be a function.');
377 }
378
379 var currentReducer = reducer;
380 var currentState = preloadedState;
381 var currentListeners = [];
382 var nextListeners = currentListeners;
383 var isDispatching = false;
384 /**
385 * This makes a shallow copy of currentListeners so we can use
386 * nextListeners as a temporary list while dispatching.
387 *
388 * This prevents any bugs around consumers calling
389 * subscribe/unsubscribe in the middle of a dispatch.
390 */
391
392 function ensureCanMutateNextListeners() {
393 if (nextListeners === currentListeners) {
394 nextListeners = currentListeners.slice();
395 }
396 }
397 /**
398 * Reads the state tree managed by the store.
399 *
400 * @returns {any} The current state tree of your application.
401 */
402
403
404 function getState() {
405 if (isDispatching) {
406 throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
407 }
408
409 return currentState;
410 }
411 /**
412 * Adds a change listener. It will be called any time an action is dispatched,
413 * and some part of the state tree may potentially have changed. You may then
414 * call `getState()` to read the current state tree inside the callback.
415 *
416 * You may call `dispatch()` from a change listener, with the following
417 * caveats:
418 *
419 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
420 * If you subscribe or unsubscribe while the listeners are being invoked, this
421 * will not have any effect on the `dispatch()` that is currently in progress.
422 * However, the next `dispatch()` call, whether nested or not, will use a more
423 * recent snapshot of the subscription list.
424 *
425 * 2. The listener should not expect to see all state changes, as the state
426 * might have been updated multiple times during a nested `dispatch()` before
427 * the listener is called. It is, however, guaranteed that all subscribers
428 * registered before the `dispatch()` started will be called with the latest
429 * state by the time it exits.
430 *
431 * @param {Function} listener A callback to be invoked on every dispatch.
432 * @returns {Function} A function to remove this change listener.
433 */
434
435
436 function subscribe(listener) {
437 if (typeof listener !== 'function') {
438 throw new Error('Expected the listener to be a function.');
439 }
440
441 if (isDispatching) {
442 throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.');
443 }
444
445 var isSubscribed = true;
446 ensureCanMutateNextListeners();
447 nextListeners.push(listener);
448 return function unsubscribe() {
449 if (!isSubscribed) {
450 return;
451 }
452
453 if (isDispatching) {
454 throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.');
455 }
456
457 isSubscribed = false;
458 ensureCanMutateNextListeners();
459 var index = nextListeners.indexOf(listener);
460 nextListeners.splice(index, 1);
461 currentListeners = null;
462 };
463 }
464 /**
465 * Dispatches an action. It is the only way to trigger a state change.
466 *
467 * The `reducer` function, used to create the store, will be called with the
468 * current state tree and the given `action`. Its return value will
469 * be considered the **next** state of the tree, and the change listeners
470 * will be notified.
471 *
472 * The base implementation only supports plain object actions. If you want to
473 * dispatch a Promise, an Observable, a thunk, or something else, you need to
474 * wrap your store creating function into the corresponding middleware. For
475 * example, see the documentation for the `redux-thunk` package. Even the
476 * middleware will eventually dispatch plain object actions using this method.
477 *
478 * @param {Object} action A plain object representing “what changed”. It is
479 * a good idea to keep actions serializable so you can record and replay user
480 * sessions, or use the time travelling `redux-devtools`. An action must have
481 * a `type` property which may not be `undefined`. It is a good idea to use
482 * string constants for action types.
483 *
484 * @returns {Object} For convenience, the same action object you dispatched.
485 *
486 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
487 * return something else (for example, a Promise you can await).
488 */
489
490
491 function dispatch(action) {
492 if (!isPlainObject(action)) {
493 throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
494 }
495
496 if (typeof action.type === 'undefined') {
497 throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
498 }
499
500 if (isDispatching) {
501 throw new Error('Reducers may not dispatch actions.');
502 }
503
504 try {
505 isDispatching = true;
506 currentState = currentReducer(currentState, action);
507 } finally {
508 isDispatching = false;
509 }
510
511 var listeners = currentListeners = nextListeners;
512
513 for (var i = 0; i < listeners.length; i++) {
514 var listener = listeners[i];
515 listener();
516 }
517
518 return action;
519 }
520 /**
521 * Replaces the reducer currently used by the store to calculate the state.
522 *
523 * You might need this if your app implements code splitting and you want to
524 * load some of the reducers dynamically. You might also need this if you
525 * implement a hot reloading mechanism for Redux.
526 *
527 * @param {Function} nextReducer The reducer for the store to use instead.
528 * @returns {void}
529 */
530
531
532 function replaceReducer(nextReducer) {
533 if (typeof nextReducer !== 'function') {
534 throw new Error('Expected the nextReducer to be a function.');
535 }
536
537 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
538 // Any reducers that existed in both the new and old rootReducer
539 // will receive the previous state. This effectively populates
540 // the new state tree with any relevant data from the old one.
541
542 dispatch({
543 type: ActionTypes.REPLACE
544 });
545 }
546 /**
547 * Interoperability point for observable/reactive libraries.
548 * @returns {observable} A minimal observable of state changes.
549 * For more information, see the observable proposal:
550 * https://github.com/tc39/proposal-observable
551 */
552
553
554 function observable() {
555 var _ref;
556
557 var outerSubscribe = subscribe;
558 return _ref = {
559 /**
560 * The minimal observable subscription method.
561 * @param {Object} observer Any object that can be used as an observer.
562 * The observer object should have a `next` method.
563 * @returns {subscription} An object with an `unsubscribe` method that can
564 * be used to unsubscribe the observable from the store, and prevent further
565 * emission of values from the observable.
566 */
567 subscribe: function subscribe(observer) {
568 if (typeof observer !== 'object' || observer === null) {
569 throw new TypeError('Expected the observer to be an object.');
570 }
571
572 function observeState() {
573 if (observer.next) {
574 observer.next(getState());
575 }
576 }
577
578 observeState();
579 var unsubscribe = outerSubscribe(observeState);
580 return {
581 unsubscribe: unsubscribe
582 };
583 }
584 }, _ref[result] = function () {
585 return this;
586 }, _ref;
587 } // When a store is created, an "INIT" action is dispatched so that every
588 // reducer returns their initial state. This effectively populates
589 // the initial state tree.
590
591
592 dispatch({
593 type: ActionTypes.INIT
594 });
595 return _ref2 = {
596 dispatch: dispatch,
597 subscribe: subscribe,
598 getState: getState,
599 replaceReducer: replaceReducer
600 }, _ref2[result] = observable, _ref2;
601 }
602
603 /**
604 * Prints a warning in the console if it exists.
605 *
606 * @param {String} message The warning message.
607 * @returns {void}
608 */
609 function warning$1(message) {
610 /* eslint-disable no-console */
611 if (typeof console !== 'undefined' && typeof console.error === 'function') {
612 console.error(message);
613 }
614 /* eslint-enable no-console */
615
616
617 try {
618 // This error was thrown as a convenience so that if you enable
619 // "break on all exceptions" in your console,
620 // it would pause the execution at this line.
621 throw new Error(message);
622 } catch (e) {} // eslint-disable-line no-empty
623
624 }
625
626 function bindActionCreator(actionCreator, dispatch) {
627 return function () {
628 return dispatch(actionCreator.apply(this, arguments));
629 };
630 }
631 /**
632 * Turns an object whose values are action creators, into an object with the
633 * same keys, but with every function wrapped into a `dispatch` call so they
634 * may be invoked directly. This is just a convenience method, as you can call
635 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
636 *
637 * For convenience, you can also pass an action creator as the first argument,
638 * and get a dispatch wrapped function in return.
639 *
640 * @param {Function|Object} actionCreators An object whose values are action
641 * creator functions. One handy way to obtain it is to use ES6 `import * as`
642 * syntax. You may also pass a single function.
643 *
644 * @param {Function} dispatch The `dispatch` function available on your Redux
645 * store.
646 *
647 * @returns {Function|Object} The object mimicking the original object, but with
648 * every action creator wrapped into the `dispatch` call. If you passed a
649 * function as `actionCreators`, the return value will also be a single
650 * function.
651 */
652
653
654 function bindActionCreators(actionCreators, dispatch) {
655 if (typeof actionCreators === 'function') {
656 return bindActionCreator(actionCreators, dispatch);
657 }
658
659 if (typeof actionCreators !== 'object' || actionCreators === null) {
660 throw new Error("bindActionCreators expected an object or a function, instead received " + (actionCreators === null ? 'null' : typeof actionCreators) + ". " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
661 }
662
663 var boundActionCreators = {};
664
665 for (var key in actionCreators) {
666 var actionCreator = actionCreators[key];
667
668 if (typeof actionCreator === 'function') {
669 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
670 }
671 }
672
673 return boundActionCreators;
674 }
675
676 function _defineProperty(obj, key, value) {
677 if (key in obj) {
678 Object.defineProperty(obj, key, {
679 value: value,
680 enumerable: true,
681 configurable: true,
682 writable: true
683 });
684 } else {
685 obj[key] = value;
686 }
687
688 return obj;
689 }
690
691 function ownKeys(object, enumerableOnly) {
692 var keys = Object.keys(object);
693
694 if (Object.getOwnPropertySymbols) {
695 keys.push.apply(keys, Object.getOwnPropertySymbols(object));
696 }
697
698 if (enumerableOnly) keys = keys.filter(function (sym) {
699 return Object.getOwnPropertyDescriptor(object, sym).enumerable;
700 });
701 return keys;
702 }
703
704 function _objectSpread2(target) {
705 for (var i = 1; i < arguments.length; i++) {
706 var source = arguments[i] != null ? arguments[i] : {};
707
708 if (i % 2) {
709 ownKeys(source, true).forEach(function (key) {
710 _defineProperty(target, key, source[key]);
711 });
712 } else if (Object.getOwnPropertyDescriptors) {
713 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
714 } else {
715 ownKeys(source).forEach(function (key) {
716 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
717 });
718 }
719 }
720
721 return target;
722 }
723
724 /**
725 * Composes single-argument functions from right to left. The rightmost
726 * function can take multiple arguments as it provides the signature for
727 * the resulting composite function.
728 *
729 * @param {...Function} funcs The functions to compose.
730 * @returns {Function} A function obtained by composing the argument functions
731 * from right to left. For example, compose(f, g, h) is identical to doing
732 * (...args) => f(g(h(...args))).
733 */
734 function compose() {
735 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
736 funcs[_key] = arguments[_key];
737 }
738
739 if (funcs.length === 0) {
740 return function (arg) {
741 return arg;
742 };
743 }
744
745 if (funcs.length === 1) {
746 return funcs[0];
747 }
748
749 return funcs.reduce(function (a, b) {
750 return function () {
751 return a(b.apply(void 0, arguments));
752 };
753 });
754 }
755
756 /**
757 * Creates a store enhancer that applies middleware to the dispatch method
758 * of the Redux store. This is handy for a variety of tasks, such as expressing
759 * asynchronous actions in a concise manner, or logging every action payload.
760 *
761 * See `redux-thunk` package as an example of the Redux middleware.
762 *
763 * Because middleware is potentially asynchronous, this should be the first
764 * store enhancer in the composition chain.
765 *
766 * Note that each middleware will be given the `dispatch` and `getState` functions
767 * as named arguments.
768 *
769 * @param {...Function} middlewares The middleware chain to be applied.
770 * @returns {Function} A store enhancer applying the middleware.
771 */
772
773 function applyMiddleware() {
774 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
775 middlewares[_key] = arguments[_key];
776 }
777
778 return function (createStore) {
779 return function () {
780 var store = createStore.apply(void 0, arguments);
781
782 var _dispatch = function dispatch() {
783 throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
784 };
785
786 var middlewareAPI = {
787 getState: store.getState,
788 dispatch: function dispatch() {
789 return _dispatch.apply(void 0, arguments);
790 }
791 };
792 var chain = middlewares.map(function (middleware) {
793 return middleware(middlewareAPI);
794 });
795 _dispatch = compose.apply(void 0, chain)(store.dispatch);
796 return _objectSpread2({}, store, {
797 dispatch: _dispatch
798 });
799 };
800 };
801 }
802
803 /*
804 * This is a dummy function to check if the function name has been altered by minification.
805 * If the function has been minified and NODE_ENV !== 'production', warn the user.
806 */
807
808 function isCrushed() {}
809
810 if ( typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
811 warning$1('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
812 }
813
814 function unwrapExports (x) {
815 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
816 }
817
818 function createCommonjsModule(fn, module) {
819 return module = { exports: {} }, fn(module, module.exports), module.exports;
820 }
821
822 var reactIs_production_min = createCommonjsModule(function (module, exports) {
823 Object.defineProperty(exports,"__esModule",{value:!0});
824 var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
825 60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118,x=b?Symbol.for("react.scope"):60119;function y(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function z(a){return y(a)===m}
826 exports.typeOf=y;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
827 exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w||a.$$typeof===x)};exports.isAsyncMode=function(a){return z(a)||y(a)===l};exports.isConcurrentMode=z;exports.isContextConsumer=function(a){return y(a)===k};exports.isContextProvider=function(a){return y(a)===h};
828 exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return y(a)===n};exports.isFragment=function(a){return y(a)===e};exports.isLazy=function(a){return y(a)===t};exports.isMemo=function(a){return y(a)===r};exports.isPortal=function(a){return y(a)===d};exports.isProfiler=function(a){return y(a)===g};exports.isStrictMode=function(a){return y(a)===f};exports.isSuspense=function(a){return y(a)===p};
829 });
830
831 unwrapExports(reactIs_production_min);
832 var reactIs_production_min_1 = reactIs_production_min.typeOf;
833 var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
834 var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
835 var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
836 var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
837 var reactIs_production_min_6 = reactIs_production_min.Element;
838 var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
839 var reactIs_production_min_8 = reactIs_production_min.Fragment;
840 var reactIs_production_min_9 = reactIs_production_min.Lazy;
841 var reactIs_production_min_10 = reactIs_production_min.Memo;
842 var reactIs_production_min_11 = reactIs_production_min.Portal;
843 var reactIs_production_min_12 = reactIs_production_min.Profiler;
844 var reactIs_production_min_13 = reactIs_production_min.StrictMode;
845 var reactIs_production_min_14 = reactIs_production_min.Suspense;
846 var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
847 var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
848 var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
849 var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
850 var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
851 var reactIs_production_min_20 = reactIs_production_min.isElement;
852 var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
853 var reactIs_production_min_22 = reactIs_production_min.isFragment;
854 var reactIs_production_min_23 = reactIs_production_min.isLazy;
855 var reactIs_production_min_24 = reactIs_production_min.isMemo;
856 var reactIs_production_min_25 = reactIs_production_min.isPortal;
857 var reactIs_production_min_26 = reactIs_production_min.isProfiler;
858 var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
859 var reactIs_production_min_28 = reactIs_production_min.isSuspense;
860
861 var reactIs_development = createCommonjsModule(function (module, exports) {
862
863
864
865 {
866 (function() {
867
868 Object.defineProperty(exports, '__esModule', { value: true });
869
870 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
871 // nor polyfill, then a plain number is used for performance.
872 var hasSymbol = typeof Symbol === 'function' && Symbol.for;
873 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
874 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
875 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
876 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
877 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
878 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
879 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
880 // (unstable) APIs that have been removed. Can we remove the symbols?
881
882 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
883 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
884 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
885 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
886 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
887 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
888 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
889 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
890 var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
891 var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
892
893 function isValidElementType(type) {
894 return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
895 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE);
896 }
897
898 /**
899 * Forked from fbjs/warning:
900 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
901 *
902 * Only change is we use console.warn instead of console.error,
903 * and do nothing when 'console' is not supported.
904 * This really simplifies the code.
905 * ---
906 * Similar to invariant but only logs a warning if the condition is not met.
907 * This can be used to log issues in development environments in critical
908 * paths. Removing the logging code for production environments will keep the
909 * same logic and follow the same code paths.
910 */
911 var lowPriorityWarningWithoutStack = function () {};
912
913 {
914 var printWarning = function (format) {
915 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
916 args[_key - 1] = arguments[_key];
917 }
918
919 var argIndex = 0;
920 var message = 'Warning: ' + format.replace(/%s/g, function () {
921 return args[argIndex++];
922 });
923
924 if (typeof console !== 'undefined') {
925 console.warn(message);
926 }
927
928 try {
929 // --- Welcome to debugging React ---
930 // This error was thrown as a convenience so that you can use this stack
931 // to find the callsite that caused this warning to fire.
932 throw new Error(message);
933 } catch (x) {}
934 };
935
936 lowPriorityWarningWithoutStack = function (condition, format) {
937 if (format === undefined) {
938 throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
939 }
940
941 if (!condition) {
942 for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
943 args[_key2 - 2] = arguments[_key2];
944 }
945
946 printWarning.apply(void 0, [format].concat(args));
947 }
948 };
949 }
950
951 var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
952
953 function typeOf(object) {
954 if (typeof object === 'object' && object !== null) {
955 var $$typeof = object.$$typeof;
956
957 switch ($$typeof) {
958 case REACT_ELEMENT_TYPE:
959 var type = object.type;
960
961 switch (type) {
962 case REACT_ASYNC_MODE_TYPE:
963 case REACT_CONCURRENT_MODE_TYPE:
964 case REACT_FRAGMENT_TYPE:
965 case REACT_PROFILER_TYPE:
966 case REACT_STRICT_MODE_TYPE:
967 case REACT_SUSPENSE_TYPE:
968 return type;
969
970 default:
971 var $$typeofType = type && type.$$typeof;
972
973 switch ($$typeofType) {
974 case REACT_CONTEXT_TYPE:
975 case REACT_FORWARD_REF_TYPE:
976 case REACT_LAZY_TYPE:
977 case REACT_MEMO_TYPE:
978 case REACT_PROVIDER_TYPE:
979 return $$typeofType;
980
981 default:
982 return $$typeof;
983 }
984
985 }
986
987 case REACT_PORTAL_TYPE:
988 return $$typeof;
989 }
990 }
991
992 return undefined;
993 } // AsyncMode is deprecated along with isAsyncMode
994
995 var AsyncMode = REACT_ASYNC_MODE_TYPE;
996 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
997 var ContextConsumer = REACT_CONTEXT_TYPE;
998 var ContextProvider = REACT_PROVIDER_TYPE;
999 var Element = REACT_ELEMENT_TYPE;
1000 var ForwardRef = REACT_FORWARD_REF_TYPE;
1001 var Fragment = REACT_FRAGMENT_TYPE;
1002 var Lazy = REACT_LAZY_TYPE;
1003 var Memo = REACT_MEMO_TYPE;
1004 var Portal = REACT_PORTAL_TYPE;
1005 var Profiler = REACT_PROFILER_TYPE;
1006 var StrictMode = REACT_STRICT_MODE_TYPE;
1007 var Suspense = REACT_SUSPENSE_TYPE;
1008 var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
1009
1010 function isAsyncMode(object) {
1011 {
1012 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
1013 hasWarnedAboutDeprecatedIsAsyncMode = true;
1014 lowPriorityWarningWithoutStack$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
1015 }
1016 }
1017
1018 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
1019 }
1020 function isConcurrentMode(object) {
1021 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
1022 }
1023 function isContextConsumer(object) {
1024 return typeOf(object) === REACT_CONTEXT_TYPE;
1025 }
1026 function isContextProvider(object) {
1027 return typeOf(object) === REACT_PROVIDER_TYPE;
1028 }
1029 function isElement(object) {
1030 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1031 }
1032 function isForwardRef(object) {
1033 return typeOf(object) === REACT_FORWARD_REF_TYPE;
1034 }
1035 function isFragment(object) {
1036 return typeOf(object) === REACT_FRAGMENT_TYPE;
1037 }
1038 function isLazy(object) {
1039 return typeOf(object) === REACT_LAZY_TYPE;
1040 }
1041 function isMemo(object) {
1042 return typeOf(object) === REACT_MEMO_TYPE;
1043 }
1044 function isPortal(object) {
1045 return typeOf(object) === REACT_PORTAL_TYPE;
1046 }
1047 function isProfiler(object) {
1048 return typeOf(object) === REACT_PROFILER_TYPE;
1049 }
1050 function isStrictMode(object) {
1051 return typeOf(object) === REACT_STRICT_MODE_TYPE;
1052 }
1053 function isSuspense(object) {
1054 return typeOf(object) === REACT_SUSPENSE_TYPE;
1055 }
1056
1057 exports.typeOf = typeOf;
1058 exports.AsyncMode = AsyncMode;
1059 exports.ConcurrentMode = ConcurrentMode;
1060 exports.ContextConsumer = ContextConsumer;
1061 exports.ContextProvider = ContextProvider;
1062 exports.Element = Element;
1063 exports.ForwardRef = ForwardRef;
1064 exports.Fragment = Fragment;
1065 exports.Lazy = Lazy;
1066 exports.Memo = Memo;
1067 exports.Portal = Portal;
1068 exports.Profiler = Profiler;
1069 exports.StrictMode = StrictMode;
1070 exports.Suspense = Suspense;
1071 exports.isValidElementType = isValidElementType;
1072 exports.isAsyncMode = isAsyncMode;
1073 exports.isConcurrentMode = isConcurrentMode;
1074 exports.isContextConsumer = isContextConsumer;
1075 exports.isContextProvider = isContextProvider;
1076 exports.isElement = isElement;
1077 exports.isForwardRef = isForwardRef;
1078 exports.isFragment = isFragment;
1079 exports.isLazy = isLazy;
1080 exports.isMemo = isMemo;
1081 exports.isPortal = isPortal;
1082 exports.isProfiler = isProfiler;
1083 exports.isStrictMode = isStrictMode;
1084 exports.isSuspense = isSuspense;
1085 })();
1086 }
1087 });
1088
1089 unwrapExports(reactIs_development);
1090 var reactIs_development_1 = reactIs_development.typeOf;
1091 var reactIs_development_2 = reactIs_development.AsyncMode;
1092 var reactIs_development_3 = reactIs_development.ConcurrentMode;
1093 var reactIs_development_4 = reactIs_development.ContextConsumer;
1094 var reactIs_development_5 = reactIs_development.ContextProvider;
1095 var reactIs_development_6 = reactIs_development.Element;
1096 var reactIs_development_7 = reactIs_development.ForwardRef;
1097 var reactIs_development_8 = reactIs_development.Fragment;
1098 var reactIs_development_9 = reactIs_development.Lazy;
1099 var reactIs_development_10 = reactIs_development.Memo;
1100 var reactIs_development_11 = reactIs_development.Portal;
1101 var reactIs_development_12 = reactIs_development.Profiler;
1102 var reactIs_development_13 = reactIs_development.StrictMode;
1103 var reactIs_development_14 = reactIs_development.Suspense;
1104 var reactIs_development_15 = reactIs_development.isValidElementType;
1105 var reactIs_development_16 = reactIs_development.isAsyncMode;
1106 var reactIs_development_17 = reactIs_development.isConcurrentMode;
1107 var reactIs_development_18 = reactIs_development.isContextConsumer;
1108 var reactIs_development_19 = reactIs_development.isContextProvider;
1109 var reactIs_development_20 = reactIs_development.isElement;
1110 var reactIs_development_21 = reactIs_development.isForwardRef;
1111 var reactIs_development_22 = reactIs_development.isFragment;
1112 var reactIs_development_23 = reactIs_development.isLazy;
1113 var reactIs_development_24 = reactIs_development.isMemo;
1114 var reactIs_development_25 = reactIs_development.isPortal;
1115 var reactIs_development_26 = reactIs_development.isProfiler;
1116 var reactIs_development_27 = reactIs_development.isStrictMode;
1117 var reactIs_development_28 = reactIs_development.isSuspense;
1118
1119 var reactIs = createCommonjsModule(function (module) {
1120
1121 {
1122 module.exports = reactIs_development;
1123 }
1124 });
1125 var reactIs_1 = reactIs.isValidElementType;
1126 var reactIs_2 = reactIs.isContextConsumer;
1127
1128 /*
1129 object-assign
1130 (c) Sindre Sorhus
1131 @license MIT
1132 */
1133 /* eslint-disable no-unused-vars */
1134 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1135 var hasOwnProperty = Object.prototype.hasOwnProperty;
1136 var propIsEnumerable = Object.prototype.propertyIsEnumerable;
1137
1138 function toObject(val) {
1139 if (val === null || val === undefined) {
1140 throw new TypeError('Object.assign cannot be called with null or undefined');
1141 }
1142
1143 return Object(val);
1144 }
1145
1146 function shouldUseNative() {
1147 try {
1148 if (!Object.assign) {
1149 return false;
1150 }
1151
1152 // Detect buggy property enumeration order in older V8 versions.
1153
1154 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
1155 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
1156 test1[5] = 'de';
1157 if (Object.getOwnPropertyNames(test1)[0] === '5') {
1158 return false;
1159 }
1160
1161 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
1162 var test2 = {};
1163 for (var i = 0; i < 10; i++) {
1164 test2['_' + String.fromCharCode(i)] = i;
1165 }
1166 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
1167 return test2[n];
1168 });
1169 if (order2.join('') !== '0123456789') {
1170 return false;
1171 }
1172
1173 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
1174 var test3 = {};
1175 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
1176 test3[letter] = letter;
1177 });
1178 if (Object.keys(Object.assign({}, test3)).join('') !==
1179 'abcdefghijklmnopqrst') {
1180 return false;
1181 }
1182
1183 return true;
1184 } catch (err) {
1185 // We don't expect any of the above to throw, but better to be safe.
1186 return false;
1187 }
1188 }
1189
1190 var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
1191 var from;
1192 var to = toObject(target);
1193 var symbols;
1194
1195 for (var s = 1; s < arguments.length; s++) {
1196 from = Object(arguments[s]);
1197
1198 for (var key in from) {
1199 if (hasOwnProperty.call(from, key)) {
1200 to[key] = from[key];
1201 }
1202 }
1203
1204 if (getOwnPropertySymbols) {
1205 symbols = getOwnPropertySymbols(from);
1206 for (var i = 0; i < symbols.length; i++) {
1207 if (propIsEnumerable.call(from, symbols[i])) {
1208 to[symbols[i]] = from[symbols[i]];
1209 }
1210 }
1211 }
1212 }
1213
1214 return to;
1215 };
1216
1217 /**
1218 * Copyright (c) 2013-present, Facebook, Inc.
1219 *
1220 * This source code is licensed under the MIT license found in the
1221 * LICENSE file in the root directory of this source tree.
1222 */
1223
1224 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1225
1226 var ReactPropTypesSecret_1 = ReactPropTypesSecret;
1227
1228 var printWarning = function() {};
1229
1230 {
1231 var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
1232 var loggedTypeFailures = {};
1233 var has = Function.call.bind(Object.prototype.hasOwnProperty);
1234
1235 printWarning = function(text) {
1236 var message = 'Warning: ' + text;
1237 if (typeof console !== 'undefined') {
1238 console.error(message);
1239 }
1240 try {
1241 // --- Welcome to debugging React ---
1242 // This error was thrown as a convenience so that you can use this stack
1243 // to find the callsite that caused this warning to fire.
1244 throw new Error(message);
1245 } catch (x) {}
1246 };
1247 }
1248
1249 /**
1250 * Assert that the values match with the type specs.
1251 * Error messages are memorized and will only be shown once.
1252 *
1253 * @param {object} typeSpecs Map of name to a ReactPropType
1254 * @param {object} values Runtime values that need to be type-checked
1255 * @param {string} location e.g. "prop", "context", "child context"
1256 * @param {string} componentName Name of the component for error messages.
1257 * @param {?Function} getStack Returns the component stack.
1258 * @private
1259 */
1260 function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
1261 {
1262 for (var typeSpecName in typeSpecs) {
1263 if (has(typeSpecs, typeSpecName)) {
1264 var error;
1265 // Prop type validation may throw. In case they do, we don't want to
1266 // fail the render phase where it didn't fail before. So we log it.
1267 // After these have been cleaned up, we'll let them throw.
1268 try {
1269 // This is intentionally an invariant that gets caught. It's the same
1270 // behavior as without this statement except with a better message.
1271 if (typeof typeSpecs[typeSpecName] !== 'function') {
1272 var err = Error(
1273 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
1274 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
1275 );
1276 err.name = 'Invariant Violation';
1277 throw err;
1278 }
1279 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
1280 } catch (ex) {
1281 error = ex;
1282 }
1283 if (error && !(error instanceof Error)) {
1284 printWarning(
1285 (componentName || 'React class') + ': type specification of ' +
1286 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
1287 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
1288 'You may have forgotten to pass an argument to the type checker ' +
1289 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
1290 'shape all require an argument).'
1291 );
1292 }
1293 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
1294 // Only monitor this failure once because there tends to be a lot of the
1295 // same error.
1296 loggedTypeFailures[error.message] = true;
1297
1298 var stack = getStack ? getStack() : '';
1299
1300 printWarning(
1301 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
1302 );
1303 }
1304 }
1305 }
1306 }
1307 }
1308
1309 /**
1310 * Resets warning cache when testing.
1311 *
1312 * @private
1313 */
1314 checkPropTypes.resetWarningCache = function() {
1315 {
1316 loggedTypeFailures = {};
1317 }
1318 };
1319
1320 var checkPropTypes_1 = checkPropTypes;
1321
1322 var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
1323 var printWarning$1 = function() {};
1324
1325 {
1326 printWarning$1 = function(text) {
1327 var message = 'Warning: ' + text;
1328 if (typeof console !== 'undefined') {
1329 console.error(message);
1330 }
1331 try {
1332 // --- Welcome to debugging React ---
1333 // This error was thrown as a convenience so that you can use this stack
1334 // to find the callsite that caused this warning to fire.
1335 throw new Error(message);
1336 } catch (x) {}
1337 };
1338 }
1339
1340 function emptyFunctionThatReturnsNull() {
1341 return null;
1342 }
1343
1344 var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
1345 /* global Symbol */
1346 var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
1347 var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
1348
1349 /**
1350 * Returns the iterator method function contained on the iterable object.
1351 *
1352 * Be sure to invoke the function with the iterable as context:
1353 *
1354 * var iteratorFn = getIteratorFn(myIterable);
1355 * if (iteratorFn) {
1356 * var iterator = iteratorFn.call(myIterable);
1357 * ...
1358 * }
1359 *
1360 * @param {?object} maybeIterable
1361 * @return {?function}
1362 */
1363 function getIteratorFn(maybeIterable) {
1364 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
1365 if (typeof iteratorFn === 'function') {
1366 return iteratorFn;
1367 }
1368 }
1369
1370 /**
1371 * Collection of methods that allow declaration and validation of props that are
1372 * supplied to React components. Example usage:
1373 *
1374 * var Props = require('ReactPropTypes');
1375 * var MyArticle = React.createClass({
1376 * propTypes: {
1377 * // An optional string prop named "description".
1378 * description: Props.string,
1379 *
1380 * // A required enum prop named "category".
1381 * category: Props.oneOf(['News','Photos']).isRequired,
1382 *
1383 * // A prop named "dialog" that requires an instance of Dialog.
1384 * dialog: Props.instanceOf(Dialog).isRequired
1385 * },
1386 * render: function() { ... }
1387 * });
1388 *
1389 * A more formal specification of how these methods are used:
1390 *
1391 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
1392 * decl := ReactPropTypes.{type}(.isRequired)?
1393 *
1394 * Each and every declaration produces a function with the same signature. This
1395 * allows the creation of custom validation functions. For example:
1396 *
1397 * var MyLink = React.createClass({
1398 * propTypes: {
1399 * // An optional string or URI prop named "href".
1400 * href: function(props, propName, componentName) {
1401 * var propValue = props[propName];
1402 * if (propValue != null && typeof propValue !== 'string' &&
1403 * !(propValue instanceof URI)) {
1404 * return new Error(
1405 * 'Expected a string or an URI for ' + propName + ' in ' +
1406 * componentName
1407 * );
1408 * }
1409 * }
1410 * },
1411 * render: function() {...}
1412 * });
1413 *
1414 * @internal
1415 */
1416
1417 var ANONYMOUS = '<<anonymous>>';
1418
1419 // Important!
1420 // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
1421 var ReactPropTypes = {
1422 array: createPrimitiveTypeChecker('array'),
1423 bool: createPrimitiveTypeChecker('boolean'),
1424 func: createPrimitiveTypeChecker('function'),
1425 number: createPrimitiveTypeChecker('number'),
1426 object: createPrimitiveTypeChecker('object'),
1427 string: createPrimitiveTypeChecker('string'),
1428 symbol: createPrimitiveTypeChecker('symbol'),
1429
1430 any: createAnyTypeChecker(),
1431 arrayOf: createArrayOfTypeChecker,
1432 element: createElementTypeChecker(),
1433 elementType: createElementTypeTypeChecker(),
1434 instanceOf: createInstanceTypeChecker,
1435 node: createNodeChecker(),
1436 objectOf: createObjectOfTypeChecker,
1437 oneOf: createEnumTypeChecker,
1438 oneOfType: createUnionTypeChecker,
1439 shape: createShapeTypeChecker,
1440 exact: createStrictShapeTypeChecker,
1441 };
1442
1443 /**
1444 * inlined Object.is polyfill to avoid requiring consumers ship their own
1445 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1446 */
1447 /*eslint-disable no-self-compare*/
1448 function is(x, y) {
1449 // SameValue algorithm
1450 if (x === y) {
1451 // Steps 1-5, 7-10
1452 // Steps 6.b-6.e: +0 != -0
1453 return x !== 0 || 1 / x === 1 / y;
1454 } else {
1455 // Step 6.a: NaN == NaN
1456 return x !== x && y !== y;
1457 }
1458 }
1459 /*eslint-enable no-self-compare*/
1460
1461 /**
1462 * We use an Error-like object for backward compatibility as people may call
1463 * PropTypes directly and inspect their output. However, we don't use real
1464 * Errors anymore. We don't inspect their stack anyway, and creating them
1465 * is prohibitively expensive if they are created too often, such as what
1466 * happens in oneOfType() for any type before the one that matched.
1467 */
1468 function PropTypeError(message) {
1469 this.message = message;
1470 this.stack = '';
1471 }
1472 // Make `instanceof Error` still work for returned errors.
1473 PropTypeError.prototype = Error.prototype;
1474
1475 function createChainableTypeChecker(validate) {
1476 {
1477 var manualPropTypeCallCache = {};
1478 var manualPropTypeWarningCount = 0;
1479 }
1480 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
1481 componentName = componentName || ANONYMOUS;
1482 propFullName = propFullName || propName;
1483
1484 if (secret !== ReactPropTypesSecret_1) {
1485 if (throwOnDirectAccess) {
1486 // New behavior only for users of `prop-types` package
1487 var err = new Error(
1488 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
1489 'Use `PropTypes.checkPropTypes()` to call them. ' +
1490 'Read more at http://fb.me/use-check-prop-types'
1491 );
1492 err.name = 'Invariant Violation';
1493 throw err;
1494 } else if ( typeof console !== 'undefined') {
1495 // Old behavior for people using React.PropTypes
1496 var cacheKey = componentName + ':' + propName;
1497 if (
1498 !manualPropTypeCallCache[cacheKey] &&
1499 // Avoid spamming the console because they are often not actionable except for lib authors
1500 manualPropTypeWarningCount < 3
1501 ) {
1502 printWarning$1(
1503 'You are manually calling a React.PropTypes validation ' +
1504 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
1505 'and will throw in the standalone `prop-types` package. ' +
1506 'You may be seeing this warning due to a third-party PropTypes ' +
1507 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
1508 );
1509 manualPropTypeCallCache[cacheKey] = true;
1510 manualPropTypeWarningCount++;
1511 }
1512 }
1513 }
1514 if (props[propName] == null) {
1515 if (isRequired) {
1516 if (props[propName] === null) {
1517 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
1518 }
1519 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
1520 }
1521 return null;
1522 } else {
1523 return validate(props, propName, componentName, location, propFullName);
1524 }
1525 }
1526
1527 var chainedCheckType = checkType.bind(null, false);
1528 chainedCheckType.isRequired = checkType.bind(null, true);
1529
1530 return chainedCheckType;
1531 }
1532
1533 function createPrimitiveTypeChecker(expectedType) {
1534 function validate(props, propName, componentName, location, propFullName, secret) {
1535 var propValue = props[propName];
1536 var propType = getPropType(propValue);
1537 if (propType !== expectedType) {
1538 // `propValue` being instance of, say, date/regexp, pass the 'object'
1539 // check, but we can offer a more precise error message here rather than
1540 // 'of type `object`'.
1541 var preciseType = getPreciseType(propValue);
1542
1543 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
1544 }
1545 return null;
1546 }
1547 return createChainableTypeChecker(validate);
1548 }
1549
1550 function createAnyTypeChecker() {
1551 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
1552 }
1553
1554 function createArrayOfTypeChecker(typeChecker) {
1555 function validate(props, propName, componentName, location, propFullName) {
1556 if (typeof typeChecker !== 'function') {
1557 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
1558 }
1559 var propValue = props[propName];
1560 if (!Array.isArray(propValue)) {
1561 var propType = getPropType(propValue);
1562 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
1563 }
1564 for (var i = 0; i < propValue.length; i++) {
1565 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
1566 if (error instanceof Error) {
1567 return error;
1568 }
1569 }
1570 return null;
1571 }
1572 return createChainableTypeChecker(validate);
1573 }
1574
1575 function createElementTypeChecker() {
1576 function validate(props, propName, componentName, location, propFullName) {
1577 var propValue = props[propName];
1578 if (!isValidElement(propValue)) {
1579 var propType = getPropType(propValue);
1580 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
1581 }
1582 return null;
1583 }
1584 return createChainableTypeChecker(validate);
1585 }
1586
1587 function createElementTypeTypeChecker() {
1588 function validate(props, propName, componentName, location, propFullName) {
1589 var propValue = props[propName];
1590 if (!reactIs.isValidElementType(propValue)) {
1591 var propType = getPropType(propValue);
1592 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
1593 }
1594 return null;
1595 }
1596 return createChainableTypeChecker(validate);
1597 }
1598
1599 function createInstanceTypeChecker(expectedClass) {
1600 function validate(props, propName, componentName, location, propFullName) {
1601 if (!(props[propName] instanceof expectedClass)) {
1602 var expectedClassName = expectedClass.name || ANONYMOUS;
1603 var actualClassName = getClassName(props[propName]);
1604 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
1605 }
1606 return null;
1607 }
1608 return createChainableTypeChecker(validate);
1609 }
1610
1611 function createEnumTypeChecker(expectedValues) {
1612 if (!Array.isArray(expectedValues)) {
1613 {
1614 if (arguments.length > 1) {
1615 printWarning$1(
1616 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
1617 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
1618 );
1619 } else {
1620 printWarning$1('Invalid argument supplied to oneOf, expected an array.');
1621 }
1622 }
1623 return emptyFunctionThatReturnsNull;
1624 }
1625
1626 function validate(props, propName, componentName, location, propFullName) {
1627 var propValue = props[propName];
1628 for (var i = 0; i < expectedValues.length; i++) {
1629 if (is(propValue, expectedValues[i])) {
1630 return null;
1631 }
1632 }
1633
1634 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
1635 var type = getPreciseType(value);
1636 if (type === 'symbol') {
1637 return String(value);
1638 }
1639 return value;
1640 });
1641 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
1642 }
1643 return createChainableTypeChecker(validate);
1644 }
1645
1646 function createObjectOfTypeChecker(typeChecker) {
1647 function validate(props, propName, componentName, location, propFullName) {
1648 if (typeof typeChecker !== 'function') {
1649 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
1650 }
1651 var propValue = props[propName];
1652 var propType = getPropType(propValue);
1653 if (propType !== 'object') {
1654 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
1655 }
1656 for (var key in propValue) {
1657 if (has$1(propValue, key)) {
1658 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
1659 if (error instanceof Error) {
1660 return error;
1661 }
1662 }
1663 }
1664 return null;
1665 }
1666 return createChainableTypeChecker(validate);
1667 }
1668
1669 function createUnionTypeChecker(arrayOfTypeCheckers) {
1670 if (!Array.isArray(arrayOfTypeCheckers)) {
1671 printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') ;
1672 return emptyFunctionThatReturnsNull;
1673 }
1674
1675 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1676 var checker = arrayOfTypeCheckers[i];
1677 if (typeof checker !== 'function') {
1678 printWarning$1(
1679 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
1680 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
1681 );
1682 return emptyFunctionThatReturnsNull;
1683 }
1684 }
1685
1686 function validate(props, propName, componentName, location, propFullName) {
1687 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1688 var checker = arrayOfTypeCheckers[i];
1689 if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
1690 return null;
1691 }
1692 }
1693
1694 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
1695 }
1696 return createChainableTypeChecker(validate);
1697 }
1698
1699 function createNodeChecker() {
1700 function validate(props, propName, componentName, location, propFullName) {
1701 if (!isNode(props[propName])) {
1702 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
1703 }
1704 return null;
1705 }
1706 return createChainableTypeChecker(validate);
1707 }
1708
1709 function createShapeTypeChecker(shapeTypes) {
1710 function validate(props, propName, componentName, location, propFullName) {
1711 var propValue = props[propName];
1712 var propType = getPropType(propValue);
1713 if (propType !== 'object') {
1714 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1715 }
1716 for (var key in shapeTypes) {
1717 var checker = shapeTypes[key];
1718 if (!checker) {
1719 continue;
1720 }
1721 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
1722 if (error) {
1723 return error;
1724 }
1725 }
1726 return null;
1727 }
1728 return createChainableTypeChecker(validate);
1729 }
1730
1731 function createStrictShapeTypeChecker(shapeTypes) {
1732 function validate(props, propName, componentName, location, propFullName) {
1733 var propValue = props[propName];
1734 var propType = getPropType(propValue);
1735 if (propType !== 'object') {
1736 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1737 }
1738 // We need to check all keys in case some are required but missing from
1739 // props.
1740 var allKeys = objectAssign({}, props[propName], shapeTypes);
1741 for (var key in allKeys) {
1742 var checker = shapeTypes[key];
1743 if (!checker) {
1744 return new PropTypeError(
1745 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
1746 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
1747 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
1748 );
1749 }
1750 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
1751 if (error) {
1752 return error;
1753 }
1754 }
1755 return null;
1756 }
1757
1758 return createChainableTypeChecker(validate);
1759 }
1760
1761 function isNode(propValue) {
1762 switch (typeof propValue) {
1763 case 'number':
1764 case 'string':
1765 case 'undefined':
1766 return true;
1767 case 'boolean':
1768 return !propValue;
1769 case 'object':
1770 if (Array.isArray(propValue)) {
1771 return propValue.every(isNode);
1772 }
1773 if (propValue === null || isValidElement(propValue)) {
1774 return true;
1775 }
1776
1777 var iteratorFn = getIteratorFn(propValue);
1778 if (iteratorFn) {
1779 var iterator = iteratorFn.call(propValue);
1780 var step;
1781 if (iteratorFn !== propValue.entries) {
1782 while (!(step = iterator.next()).done) {
1783 if (!isNode(step.value)) {
1784 return false;
1785 }
1786 }
1787 } else {
1788 // Iterator will provide entry [k,v] tuples rather than values.
1789 while (!(step = iterator.next()).done) {
1790 var entry = step.value;
1791 if (entry) {
1792 if (!isNode(entry[1])) {
1793 return false;
1794 }
1795 }
1796 }
1797 }
1798 } else {
1799 return false;
1800 }
1801
1802 return true;
1803 default:
1804 return false;
1805 }
1806 }
1807
1808 function isSymbol(propType, propValue) {
1809 // Native Symbol.
1810 if (propType === 'symbol') {
1811 return true;
1812 }
1813
1814 // falsy value can't be a Symbol
1815 if (!propValue) {
1816 return false;
1817 }
1818
1819 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1820 if (propValue['@@toStringTag'] === 'Symbol') {
1821 return true;
1822 }
1823
1824 // Fallback for non-spec compliant Symbols which are polyfilled.
1825 if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1826 return true;
1827 }
1828
1829 return false;
1830 }
1831
1832 // Equivalent of `typeof` but with special handling for array and regexp.
1833 function getPropType(propValue) {
1834 var propType = typeof propValue;
1835 if (Array.isArray(propValue)) {
1836 return 'array';
1837 }
1838 if (propValue instanceof RegExp) {
1839 // Old webkits (at least until Android 4.0) return 'function' rather than
1840 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1841 // passes PropTypes.object.
1842 return 'object';
1843 }
1844 if (isSymbol(propType, propValue)) {
1845 return 'symbol';
1846 }
1847 return propType;
1848 }
1849
1850 // This handles more types than `getPropType`. Only used for error messages.
1851 // See `createPrimitiveTypeChecker`.
1852 function getPreciseType(propValue) {
1853 if (typeof propValue === 'undefined' || propValue === null) {
1854 return '' + propValue;
1855 }
1856 var propType = getPropType(propValue);
1857 if (propType === 'object') {
1858 if (propValue instanceof Date) {
1859 return 'date';
1860 } else if (propValue instanceof RegExp) {
1861 return 'regexp';
1862 }
1863 }
1864 return propType;
1865 }
1866
1867 // Returns a string that is postfixed to a warning about an invalid type.
1868 // For example, "undefined" or "of type array"
1869 function getPostfixForTypeWarning(value) {
1870 var type = getPreciseType(value);
1871 switch (type) {
1872 case 'array':
1873 case 'object':
1874 return 'an ' + type;
1875 case 'boolean':
1876 case 'date':
1877 case 'regexp':
1878 return 'a ' + type;
1879 default:
1880 return type;
1881 }
1882 }
1883
1884 // Returns class name of the object, if any.
1885 function getClassName(propValue) {
1886 if (!propValue.constructor || !propValue.constructor.name) {
1887 return ANONYMOUS;
1888 }
1889 return propValue.constructor.name;
1890 }
1891
1892 ReactPropTypes.checkPropTypes = checkPropTypes_1;
1893 ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
1894 ReactPropTypes.PropTypes = ReactPropTypes;
1895
1896 return ReactPropTypes;
1897 };
1898
1899 var propTypes = createCommonjsModule(function (module) {
1900 /**
1901 * Copyright (c) 2013-present, Facebook, Inc.
1902 *
1903 * This source code is licensed under the MIT license found in the
1904 * LICENSE file in the root directory of this source tree.
1905 */
1906
1907 {
1908 var ReactIs = reactIs;
1909
1910 // By explicitly using `prop-types` you are opting into new development behavior.
1911 // http://fb.me/prop-types-in-prod
1912 var throwOnDirectAccess = true;
1913 module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
1914 }
1915 });
1916
1917 var ReactReduxContext =
1918 /*#__PURE__*/
1919 React__default.createContext(null);
1920
1921 {
1922 ReactReduxContext.displayName = 'ReactRedux';
1923 }
1924
1925 // Default to a dummy "batch" implementation that just runs the callback
1926 function defaultNoopBatch(callback) {
1927 callback();
1928 }
1929
1930 var batch = defaultNoopBatch; // Allow injecting another batching function later
1931
1932 var setBatch = function setBatch(newBatch) {
1933 return batch = newBatch;
1934 }; // Supply a getter just to skip dealing with ESM bindings
1935
1936 var getBatch = function getBatch() {
1937 return batch;
1938 };
1939
1940 // well as nesting subscriptions of descendant components, so that we can ensure the
1941 // ancestor components re-render before descendants
1942
1943 var nullListeners = {
1944 notify: function notify() {}
1945 };
1946
1947 function createListenerCollection() {
1948 var batch = getBatch();
1949 var first = null;
1950 var last = null;
1951 return {
1952 clear: function clear() {
1953 first = null;
1954 last = null;
1955 },
1956 notify: function notify() {
1957 batch(function () {
1958 var listener = first;
1959
1960 while (listener) {
1961 listener.callback();
1962 listener = listener.next;
1963 }
1964 });
1965 },
1966 get: function get() {
1967 var listeners = [];
1968 var listener = first;
1969
1970 while (listener) {
1971 listeners.push(listener);
1972 listener = listener.next;
1973 }
1974
1975 return listeners;
1976 },
1977 subscribe: function subscribe(callback) {
1978 var isSubscribed = true;
1979 var listener = last = {
1980 callback: callback,
1981 next: null,
1982 prev: last
1983 };
1984
1985 if (listener.prev) {
1986 listener.prev.next = listener;
1987 } else {
1988 first = listener;
1989 }
1990
1991 return function unsubscribe() {
1992 if (!isSubscribed || first === null) return;
1993 isSubscribed = false;
1994
1995 if (listener.next) {
1996 listener.next.prev = listener.prev;
1997 } else {
1998 last = listener.prev;
1999 }
2000
2001 if (listener.prev) {
2002 listener.prev.next = listener.next;
2003 } else {
2004 first = listener.next;
2005 }
2006 };
2007 }
2008 };
2009 }
2010
2011 var Subscription =
2012 /*#__PURE__*/
2013 function () {
2014 function Subscription(store, parentSub) {
2015 this.store = store;
2016 this.parentSub = parentSub;
2017 this.unsubscribe = null;
2018 this.listeners = nullListeners;
2019 this.handleChangeWrapper = this.handleChangeWrapper.bind(this);
2020 }
2021
2022 var _proto = Subscription.prototype;
2023
2024 _proto.addNestedSub = function addNestedSub(listener) {
2025 this.trySubscribe();
2026 return this.listeners.subscribe(listener);
2027 };
2028
2029 _proto.notifyNestedSubs = function notifyNestedSubs() {
2030 this.listeners.notify();
2031 };
2032
2033 _proto.handleChangeWrapper = function handleChangeWrapper() {
2034 if (this.onStateChange) {
2035 this.onStateChange();
2036 }
2037 };
2038
2039 _proto.isSubscribed = function isSubscribed() {
2040 return Boolean(this.unsubscribe);
2041 };
2042
2043 _proto.trySubscribe = function trySubscribe() {
2044 if (!this.unsubscribe) {
2045 this.unsubscribe = this.parentSub ? this.parentSub.addNestedSub(this.handleChangeWrapper) : this.store.subscribe(this.handleChangeWrapper);
2046 this.listeners = createListenerCollection();
2047 }
2048 };
2049
2050 _proto.tryUnsubscribe = function tryUnsubscribe() {
2051 if (this.unsubscribe) {
2052 this.unsubscribe();
2053 this.unsubscribe = null;
2054 this.listeners.clear();
2055 this.listeners = nullListeners;
2056 }
2057 };
2058
2059 return Subscription;
2060 }();
2061
2062 function Provider(_ref) {
2063 var store = _ref.store,
2064 context = _ref.context,
2065 children = _ref.children;
2066 var contextValue = React.useMemo(function () {
2067 var subscription = new Subscription(store);
2068 subscription.onStateChange = subscription.notifyNestedSubs;
2069 return {
2070 store: store,
2071 subscription: subscription
2072 };
2073 }, [store]);
2074 var previousState = React.useMemo(function () {
2075 return store.getState();
2076 }, [store]);
2077 React.useEffect(function () {
2078 var subscription = contextValue.subscription;
2079 subscription.trySubscribe();
2080
2081 if (previousState !== store.getState()) {
2082 subscription.notifyNestedSubs();
2083 }
2084
2085 return function () {
2086 subscription.tryUnsubscribe();
2087 subscription.onStateChange = null;
2088 };
2089 }, [contextValue, previousState]);
2090 var Context = context || ReactReduxContext;
2091 return React__default.createElement(Context.Provider, {
2092 value: contextValue
2093 }, children);
2094 }
2095
2096 {
2097 Provider.propTypes = {
2098 store: propTypes.shape({
2099 subscribe: propTypes.func.isRequired,
2100 dispatch: propTypes.func.isRequired,
2101 getState: propTypes.func.isRequired
2102 }),
2103 context: propTypes.object,
2104 children: propTypes.any
2105 };
2106 }
2107
2108 function _extends$1() {
2109 _extends$1 = Object.assign || function (target) {
2110 for (var i = 1; i < arguments.length; i++) {
2111 var source = arguments[i];
2112
2113 for (var key in source) {
2114 if (Object.prototype.hasOwnProperty.call(source, key)) {
2115 target[key] = source[key];
2116 }
2117 }
2118 }
2119
2120 return target;
2121 };
2122
2123 return _extends$1.apply(this, arguments);
2124 }
2125
2126 function _objectWithoutPropertiesLoose(source, excluded) {
2127 if (source == null) return {};
2128 var target = {};
2129 var sourceKeys = Object.keys(source);
2130 var key, i;
2131
2132 for (i = 0; i < sourceKeys.length; i++) {
2133 key = sourceKeys[i];
2134 if (excluded.indexOf(key) >= 0) continue;
2135 target[key] = source[key];
2136 }
2137
2138 return target;
2139 }
2140
2141 /**
2142 * Copyright 2015, Yahoo! Inc.
2143 * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
2144 */
2145 var REACT_STATICS = {
2146 childContextTypes: true,
2147 contextType: true,
2148 contextTypes: true,
2149 defaultProps: true,
2150 displayName: true,
2151 getDefaultProps: true,
2152 getDerivedStateFromError: true,
2153 getDerivedStateFromProps: true,
2154 mixins: true,
2155 propTypes: true,
2156 type: true
2157 };
2158 var KNOWN_STATICS = {
2159 name: true,
2160 length: true,
2161 prototype: true,
2162 caller: true,
2163 callee: true,
2164 arguments: true,
2165 arity: true
2166 };
2167 var FORWARD_REF_STATICS = {
2168 '$$typeof': true,
2169 render: true,
2170 defaultProps: true,
2171 displayName: true,
2172 propTypes: true
2173 };
2174 var MEMO_STATICS = {
2175 '$$typeof': true,
2176 compare: true,
2177 defaultProps: true,
2178 displayName: true,
2179 propTypes: true,
2180 type: true
2181 };
2182 var TYPE_STATICS = {};
2183 TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
2184 TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
2185
2186 function getStatics(component) {
2187 // React v16.11 and below
2188 if (reactIs.isMemo(component)) {
2189 return MEMO_STATICS;
2190 } // React v16.12 and above
2191
2192
2193 return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
2194 }
2195
2196 var defineProperty = Object.defineProperty;
2197 var getOwnPropertyNames = Object.getOwnPropertyNames;
2198 var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
2199 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2200 var getPrototypeOf = Object.getPrototypeOf;
2201 var objectPrototype = Object.prototype;
2202 function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
2203 if (typeof sourceComponent !== 'string') {
2204 // don't hoist over string (html) components
2205 if (objectPrototype) {
2206 var inheritedComponent = getPrototypeOf(sourceComponent);
2207
2208 if (inheritedComponent && inheritedComponent !== objectPrototype) {
2209 hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
2210 }
2211 }
2212
2213 var keys = getOwnPropertyNames(sourceComponent);
2214
2215 if (getOwnPropertySymbols$1) {
2216 keys = keys.concat(getOwnPropertySymbols$1(sourceComponent));
2217 }
2218
2219 var targetStatics = getStatics(targetComponent);
2220 var sourceStatics = getStatics(sourceComponent);
2221
2222 for (var i = 0; i < keys.length; ++i) {
2223 var key = keys[i];
2224
2225 if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
2226 var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
2227
2228 try {
2229 // Avoid failures from read-only properties
2230 defineProperty(targetComponent, key, descriptor);
2231 } catch (e) {}
2232 }
2233 }
2234 }
2235
2236 return targetComponent;
2237 }
2238
2239 var hoistNonReactStatics_cjs = hoistNonReactStatics;
2240
2241 // To get around it, we can conditionally useEffect on the server (no-op) and
2242 // useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
2243 // subscription callback always has the selector from the latest render commit
2244 // available, otherwise a store update may happen between render and the effect,
2245 // which may cause missed updates; we also must ensure the store subscription
2246 // is created synchronously, otherwise a store update may occur before the
2247 // subscription is created and an inconsistent state may be observed
2248
2249 var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect;
2250
2251 var EMPTY_ARRAY = [];
2252 var NO_SUBSCRIPTION_ARRAY = [null, null];
2253
2254 var stringifyComponent = function stringifyComponent(Comp) {
2255 try {
2256 return JSON.stringify(Comp);
2257 } catch (err) {
2258 return String(Comp);
2259 }
2260 };
2261
2262 function storeStateUpdatesReducer(state, action) {
2263 var updateCount = state[1];
2264 return [action.payload, updateCount + 1];
2265 }
2266
2267 function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
2268 useIsomorphicLayoutEffect(function () {
2269 return effectFunc.apply(void 0, effectArgs);
2270 }, dependencies);
2271 }
2272
2273 function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs) {
2274 // We want to capture the wrapper props and child props we used for later comparisons
2275 lastWrapperProps.current = wrapperProps;
2276 lastChildProps.current = actualChildProps;
2277 renderIsScheduled.current = false; // If the render was from a store update, clear out that reference and cascade the subscriber update
2278
2279 if (childPropsFromStoreUpdate.current) {
2280 childPropsFromStoreUpdate.current = null;
2281 notifyNestedSubs();
2282 }
2283 }
2284
2285 function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch) {
2286 // If we're not subscribed to the store, nothing to do here
2287 if (!shouldHandleStateChanges) return; // Capture values for checking if and when this component unmounts
2288
2289 var didUnsubscribe = false;
2290 var lastThrownError = null; // We'll run this callback every time a store subscription update propagates to this component
2291
2292 var checkForUpdates = function checkForUpdates() {
2293 if (didUnsubscribe) {
2294 // Don't run stale listeners.
2295 // Redux doesn't guarantee unsubscriptions happen until next dispatch.
2296 return;
2297 }
2298
2299 var latestStoreState = store.getState();
2300 var newChildProps, error;
2301
2302 try {
2303 // Actually run the selector with the most recent store state and wrapper props
2304 // to determine what the child props should be
2305 newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current);
2306 } catch (e) {
2307 error = e;
2308 lastThrownError = e;
2309 }
2310
2311 if (!error) {
2312 lastThrownError = null;
2313 } // If the child props haven't changed, nothing to do here - cascade the subscription update
2314
2315
2316 if (newChildProps === lastChildProps.current) {
2317 if (!renderIsScheduled.current) {
2318 notifyNestedSubs();
2319 }
2320 } else {
2321 // Save references to the new child props. Note that we track the "child props from store update"
2322 // as a ref instead of a useState/useReducer because we need a way to determine if that value has
2323 // been processed. If this went into useState/useReducer, we couldn't clear out the value without
2324 // forcing another re-render, which we don't want.
2325 lastChildProps.current = newChildProps;
2326 childPropsFromStoreUpdate.current = newChildProps;
2327 renderIsScheduled.current = true; // If the child props _did_ change (or we caught an error), this wrapper component needs to re-render
2328
2329 forceComponentUpdateDispatch({
2330 type: 'STORE_UPDATED',
2331 payload: {
2332 error: error
2333 }
2334 });
2335 }
2336 }; // Actually subscribe to the nearest connected ancestor (or store)
2337
2338
2339 subscription.onStateChange = checkForUpdates;
2340 subscription.trySubscribe(); // Pull data from the store after first render in case the store has
2341 // changed since we began.
2342
2343 checkForUpdates();
2344
2345 var unsubscribeWrapper = function unsubscribeWrapper() {
2346 didUnsubscribe = true;
2347 subscription.tryUnsubscribe();
2348 subscription.onStateChange = null;
2349
2350 if (lastThrownError) {
2351 // It's possible that we caught an error due to a bad mapState function, but the
2352 // parent re-rendered without this component and we're about to unmount.
2353 // This shouldn't happen as long as we do top-down subscriptions correctly, but
2354 // if we ever do those wrong, this throw will surface the error in our tests.
2355 // In that case, throw the error from here so it doesn't get lost.
2356 throw lastThrownError;
2357 }
2358 };
2359
2360 return unsubscribeWrapper;
2361 }
2362
2363 var initStateUpdates = function initStateUpdates() {
2364 return [null, 0];
2365 };
2366
2367 function connectAdvanced(
2368 /*
2369 selectorFactory is a func that is responsible for returning the selector function used to
2370 compute new props from state, props, and dispatch. For example:
2371 export default connectAdvanced((dispatch, options) => (state, props) => ({
2372 thing: state.things[props.thingId],
2373 saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)),
2374 }))(YourComponent)
2375 Access to dispatch is provided to the factory so selectorFactories can bind actionCreators
2376 outside of their selector as an optimization. Options passed to connectAdvanced are passed to
2377 the selectorFactory, along with displayName and WrappedComponent, as the second argument.
2378 Note that selectorFactory is responsible for all caching/memoization of inbound and outbound
2379 props. Do not use connectAdvanced directly without memoizing results between calls to your
2380 selector, otherwise the Connect component will re-render on every state or props change.
2381 */
2382 selectorFactory, // options object:
2383 _ref) {
2384 if (_ref === void 0) {
2385 _ref = {};
2386 }
2387
2388 var _ref2 = _ref,
2389 _ref2$getDisplayName = _ref2.getDisplayName,
2390 getDisplayName = _ref2$getDisplayName === void 0 ? function (name) {
2391 return "ConnectAdvanced(" + name + ")";
2392 } : _ref2$getDisplayName,
2393 _ref2$methodName = _ref2.methodName,
2394 methodName = _ref2$methodName === void 0 ? 'connectAdvanced' : _ref2$methodName,
2395 _ref2$renderCountProp = _ref2.renderCountProp,
2396 renderCountProp = _ref2$renderCountProp === void 0 ? undefined : _ref2$renderCountProp,
2397 _ref2$shouldHandleSta = _ref2.shouldHandleStateChanges,
2398 shouldHandleStateChanges = _ref2$shouldHandleSta === void 0 ? true : _ref2$shouldHandleSta,
2399 _ref2$storeKey = _ref2.storeKey,
2400 storeKey = _ref2$storeKey === void 0 ? 'store' : _ref2$storeKey,
2401 _ref2$withRef = _ref2.withRef,
2402 withRef = _ref2$withRef === void 0 ? false : _ref2$withRef,
2403 _ref2$forwardRef = _ref2.forwardRef,
2404 forwardRef = _ref2$forwardRef === void 0 ? false : _ref2$forwardRef,
2405 _ref2$context = _ref2.context,
2406 context = _ref2$context === void 0 ? ReactReduxContext : _ref2$context,
2407 connectOptions = _objectWithoutPropertiesLoose(_ref2, ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"]);
2408
2409 {
2410 if (renderCountProp !== undefined) {
2411 throw new Error("renderCountProp is removed. render counting is built into the latest React Dev Tools profiling extension");
2412 }
2413
2414 if (withRef) {
2415 throw new Error('withRef is removed. To access the wrapped instance, use a ref on the connected component');
2416 }
2417
2418 var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: <Provider context={MyContext}><ConnectedComponent context={MyContext} /></Provider>. ' + 'You may also pass a {context : MyContext} option to connect';
2419
2420 if (storeKey !== 'store') {
2421 throw new Error('storeKey has been removed and does not do anything. ' + customStoreWarningMessage);
2422 }
2423 }
2424
2425 var Context = context;
2426 return function wrapWithConnect(WrappedComponent) {
2427 if ( !reactIs_1(WrappedComponent)) {
2428 throw new Error("You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent)));
2429 }
2430
2431 var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
2432 var displayName = getDisplayName(wrappedComponentName);
2433
2434 var selectorFactoryOptions = _extends$1({}, connectOptions, {
2435 getDisplayName: getDisplayName,
2436 methodName: methodName,
2437 renderCountProp: renderCountProp,
2438 shouldHandleStateChanges: shouldHandleStateChanges,
2439 storeKey: storeKey,
2440 displayName: displayName,
2441 wrappedComponentName: wrappedComponentName,
2442 WrappedComponent: WrappedComponent
2443 });
2444
2445 var pure = connectOptions.pure;
2446
2447 function createChildSelector(store) {
2448 return selectorFactory(store.dispatch, selectorFactoryOptions);
2449 } // If we aren't running in "pure" mode, we don't want to memoize values.
2450 // To avoid conditionally calling hooks, we fall back to a tiny wrapper
2451 // that just executes the given callback immediately.
2452
2453
2454 var usePureOnlyMemo = pure ? React.useMemo : function (callback) {
2455 return callback();
2456 };
2457
2458 function ConnectFunction(props) {
2459 var _useMemo = React.useMemo(function () {
2460 // Distinguish between actual "data" props that were passed to the wrapper component,
2461 // and values needed to control behavior (forwarded refs, alternate context instances).
2462 // To maintain the wrapperProps object reference, memoize this destructuring.
2463 var forwardedRef = props.forwardedRef,
2464 wrapperProps = _objectWithoutPropertiesLoose(props, ["forwardedRef"]);
2465
2466 return [props.context, forwardedRef, wrapperProps];
2467 }, [props]),
2468 propsContext = _useMemo[0],
2469 forwardedRef = _useMemo[1],
2470 wrapperProps = _useMemo[2];
2471
2472 var ContextToUse = React.useMemo(function () {
2473 // Users may optionally pass in a custom context instance to use instead of our ReactReduxContext.
2474 // Memoize the check that determines which context instance we should use.
2475 return propsContext && propsContext.Consumer && reactIs_2(React__default.createElement(propsContext.Consumer, null)) ? propsContext : Context;
2476 }, [propsContext, Context]); // Retrieve the store and ancestor subscription via context, if available
2477
2478 var contextValue = React.useContext(ContextToUse); // The store _must_ exist as either a prop or in context.
2479 // We'll check to see if it _looks_ like a Redux store first.
2480 // This allows us to pass through a `store` prop that is just a plain value.
2481
2482 var didStoreComeFromProps = Boolean(props.store) && Boolean(props.store.getState) && Boolean(props.store.dispatch);
2483 var didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store);
2484
2485 if ( !didStoreComeFromProps && !didStoreComeFromContext) {
2486 throw new Error("Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a <Provider>, ") + "or pass a custom React context provider to <Provider> and the corresponding " + ("React context consumer to " + displayName + " in connect options."));
2487 } // Based on the previous check, one of these must be true
2488
2489
2490 var store = didStoreComeFromProps ? props.store : contextValue.store;
2491 var childPropsSelector = React.useMemo(function () {
2492 // The child props selector needs the store reference as an input.
2493 // Re-create this selector whenever the store changes.
2494 return createChildSelector(store);
2495 }, [store]);
2496
2497 var _useMemo2 = React.useMemo(function () {
2498 if (!shouldHandleStateChanges) return NO_SUBSCRIPTION_ARRAY; // This Subscription's source should match where store came from: props vs. context. A component
2499 // connected to the store via props shouldn't use subscription from context, or vice versa.
2500
2501 var subscription = new Subscription(store, didStoreComeFromProps ? null : contextValue.subscription); // `notifyNestedSubs` is duplicated to handle the case where the component is unmounted in
2502 // the middle of the notification loop, where `subscription` will then be null. This can
2503 // probably be avoided if Subscription's listeners logic is changed to not call listeners
2504 // that have been unsubscribed in the middle of the notification loop.
2505
2506 var notifyNestedSubs = subscription.notifyNestedSubs.bind(subscription);
2507 return [subscription, notifyNestedSubs];
2508 }, [store, didStoreComeFromProps, contextValue]),
2509 subscription = _useMemo2[0],
2510 notifyNestedSubs = _useMemo2[1]; // Determine what {store, subscription} value should be put into nested context, if necessary,
2511 // and memoize that value to avoid unnecessary context updates.
2512
2513
2514 var overriddenContextValue = React.useMemo(function () {
2515 if (didStoreComeFromProps) {
2516 // This component is directly subscribed to a store from props.
2517 // We don't want descendants reading from this store - pass down whatever
2518 // the existing context value is from the nearest connected ancestor.
2519 return contextValue;
2520 } // Otherwise, put this component's subscription instance into context, so that
2521 // connected descendants won't update until after this component is done
2522
2523
2524 return _extends$1({}, contextValue, {
2525 subscription: subscription
2526 });
2527 }, [didStoreComeFromProps, contextValue, subscription]); // We need to force this wrapper component to re-render whenever a Redux store update
2528 // causes a change to the calculated child component props (or we caught an error in mapState)
2529
2530 var _useReducer = React.useReducer(storeStateUpdatesReducer, EMPTY_ARRAY, initStateUpdates),
2531 _useReducer$ = _useReducer[0],
2532 previousStateUpdateResult = _useReducer$[0],
2533 forceComponentUpdateDispatch = _useReducer[1]; // Propagate any mapState/mapDispatch errors upwards
2534
2535
2536 if (previousStateUpdateResult && previousStateUpdateResult.error) {
2537 throw previousStateUpdateResult.error;
2538 } // Set up refs to coordinate values between the subscription effect and the render logic
2539
2540
2541 var lastChildProps = React.useRef();
2542 var lastWrapperProps = React.useRef(wrapperProps);
2543 var childPropsFromStoreUpdate = React.useRef();
2544 var renderIsScheduled = React.useRef(false);
2545 var actualChildProps = usePureOnlyMemo(function () {
2546 // Tricky logic here:
2547 // - This render may have been triggered by a Redux store update that produced new child props
2548 // - However, we may have gotten new wrapper props after that
2549 // If we have new child props, and the same wrapper props, we know we should use the new child props as-is.
2550 // But, if we have new wrapper props, those might change the child props, so we have to recalculate things.
2551 // So, we'll use the child props from store update only if the wrapper props are the same as last time.
2552 if (childPropsFromStoreUpdate.current && wrapperProps === lastWrapperProps.current) {
2553 return childPropsFromStoreUpdate.current;
2554 } // TODO We're reading the store directly in render() here. Bad idea?
2555 // This will likely cause Bad Things (TM) to happen in Concurrent Mode.
2556 // Note that we do this because on renders _not_ caused by store updates, we need the latest store state
2557 // to determine what the child props should be.
2558
2559
2560 return childPropsSelector(store.getState(), wrapperProps);
2561 }, [store, previousStateUpdateResult, wrapperProps]); // We need this to execute synchronously every time we re-render. However, React warns
2562 // about useLayoutEffect in SSR, so we try to detect environment and fall back to
2563 // just useEffect instead to avoid the warning, since neither will run anyway.
2564
2565 useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs]); // Our re-subscribe logic only runs when the store/subscription setup changes
2566
2567 useIsomorphicLayoutEffectWithArgs(subscribeUpdates, [shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch], [store, subscription, childPropsSelector]); // Now that all that's done, we can finally try to actually render the child component.
2568 // We memoize the elements for the rendered child component as an optimization.
2569
2570 var renderedWrappedComponent = React.useMemo(function () {
2571 return React__default.createElement(WrappedComponent, _extends$1({}, actualChildProps, {
2572 ref: forwardedRef
2573 }));
2574 }, [forwardedRef, WrappedComponent, actualChildProps]); // If React sees the exact same element reference as last time, it bails out of re-rendering
2575 // that child, same as if it was wrapped in React.memo() or returned false from shouldComponentUpdate.
2576
2577 var renderedChild = React.useMemo(function () {
2578 if (shouldHandleStateChanges) {
2579 // If this component is subscribed to store updates, we need to pass its own
2580 // subscription instance down to our descendants. That means rendering the same
2581 // Context instance, and putting a different value into the context.
2582 return React__default.createElement(ContextToUse.Provider, {
2583 value: overriddenContextValue
2584 }, renderedWrappedComponent);
2585 }
2586
2587 return renderedWrappedComponent;
2588 }, [ContextToUse, renderedWrappedComponent, overriddenContextValue]);
2589 return renderedChild;
2590 } // If we're in "pure" mode, ensure our wrapper component only re-renders when incoming props have changed.
2591
2592
2593 var Connect = pure ? React__default.memo(ConnectFunction) : ConnectFunction;
2594 Connect.WrappedComponent = WrappedComponent;
2595 Connect.displayName = displayName;
2596
2597 if (forwardRef) {
2598 var forwarded = React__default.forwardRef(function forwardConnectRef(props, ref) {
2599 return React__default.createElement(Connect, _extends$1({}, props, {
2600 forwardedRef: ref
2601 }));
2602 });
2603 forwarded.displayName = displayName;
2604 forwarded.WrappedComponent = WrappedComponent;
2605 return hoistNonReactStatics_cjs(forwarded, WrappedComponent);
2606 }
2607
2608 return hoistNonReactStatics_cjs(Connect, WrappedComponent);
2609 };
2610 }
2611
2612 function is(x, y) {
2613 if (x === y) {
2614 return x !== 0 || y !== 0 || 1 / x === 1 / y;
2615 } else {
2616 return x !== x && y !== y;
2617 }
2618 }
2619
2620 function shallowEqual(objA, objB) {
2621 if (is(objA, objB)) return true;
2622
2623 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
2624 return false;
2625 }
2626
2627 var keysA = Object.keys(objA);
2628 var keysB = Object.keys(objB);
2629 if (keysA.length !== keysB.length) return false;
2630
2631 for (var i = 0; i < keysA.length; i++) {
2632 if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
2633 return false;
2634 }
2635 }
2636
2637 return true;
2638 }
2639
2640 /**
2641 * @param {any} obj The object to inspect.
2642 * @returns {boolean} True if the argument appears to be a plain object.
2643 */
2644 function isPlainObject$1(obj) {
2645 if (typeof obj !== 'object' || obj === null) return false;
2646 var proto = Object.getPrototypeOf(obj);
2647 if (proto === null) return true;
2648 var baseProto = proto;
2649
2650 while (Object.getPrototypeOf(baseProto) !== null) {
2651 baseProto = Object.getPrototypeOf(baseProto);
2652 }
2653
2654 return proto === baseProto;
2655 }
2656
2657 /**
2658 * Prints a warning in the console if it exists.
2659 *
2660 * @param {String} message The warning message.
2661 * @returns {void}
2662 */
2663 function warning$2(message) {
2664 /* eslint-disable no-console */
2665 if (typeof console !== 'undefined' && typeof console.error === 'function') {
2666 console.error(message);
2667 }
2668 /* eslint-enable no-console */
2669
2670
2671 try {
2672 // This error was thrown as a convenience so that if you enable
2673 // "break on all exceptions" in your console,
2674 // it would pause the execution at this line.
2675 throw new Error(message);
2676 /* eslint-disable no-empty */
2677 } catch (e) {}
2678 /* eslint-enable no-empty */
2679
2680 }
2681
2682 function verifyPlainObject(value, displayName, methodName) {
2683 if (!isPlainObject$1(value)) {
2684 warning$2(methodName + "() in " + displayName + " must return a plain object. Instead received " + value + ".");
2685 }
2686 }
2687
2688 function wrapMapToPropsConstant(getConstant) {
2689 return function initConstantSelector(dispatch, options) {
2690 var constant = getConstant(dispatch, options);
2691
2692 function constantSelector() {
2693 return constant;
2694 }
2695
2696 constantSelector.dependsOnOwnProps = false;
2697 return constantSelector;
2698 };
2699 } // dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args
2700 // to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine
2701 // whether mapToProps needs to be invoked when props have changed.
2702 //
2703 // A length of one signals that mapToProps does not depend on props from the parent component.
2704 // A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and
2705 // therefore not reporting its length accurately..
2706
2707 function getDependsOnOwnProps(mapToProps) {
2708 return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
2709 } // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,
2710 // this function wraps mapToProps in a proxy function which does several things:
2711 //
2712 // * Detects whether the mapToProps function being called depends on props, which
2713 // is used by selectorFactory to decide if it should reinvoke on props changes.
2714 //
2715 // * On first call, handles mapToProps if returns another function, and treats that
2716 // new function as the true mapToProps for subsequent calls.
2717 //
2718 // * On first call, verifies the first result is a plain object, in order to warn
2719 // the developer that their mapToProps function is not returning a valid result.
2720 //
2721
2722 function wrapMapToPropsFunc(mapToProps, methodName) {
2723 return function initProxySelector(dispatch, _ref) {
2724 var displayName = _ref.displayName;
2725
2726 var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
2727 return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);
2728 }; // allow detectFactoryAndVerify to get ownProps
2729
2730
2731 proxy.dependsOnOwnProps = true;
2732
2733 proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
2734 proxy.mapToProps = mapToProps;
2735 proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
2736 var props = proxy(stateOrDispatch, ownProps);
2737
2738 if (typeof props === 'function') {
2739 proxy.mapToProps = props;
2740 proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
2741 props = proxy(stateOrDispatch, ownProps);
2742 }
2743
2744 verifyPlainObject(props, displayName, methodName);
2745 return props;
2746 };
2747
2748 return proxy;
2749 };
2750 }
2751
2752 function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
2753 return typeof mapDispatchToProps === 'function' ? wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps') : undefined;
2754 }
2755 function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
2756 return !mapDispatchToProps ? wrapMapToPropsConstant(function (dispatch) {
2757 return {
2758 dispatch: dispatch
2759 };
2760 }) : undefined;
2761 }
2762 function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
2763 return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? wrapMapToPropsConstant(function (dispatch) {
2764 return bindActionCreators(mapDispatchToProps, dispatch);
2765 }) : undefined;
2766 }
2767 var defaultMapDispatchToPropsFactories = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject];
2768
2769 function whenMapStateToPropsIsFunction(mapStateToProps) {
2770 return typeof mapStateToProps === 'function' ? wrapMapToPropsFunc(mapStateToProps, 'mapStateToProps') : undefined;
2771 }
2772 function whenMapStateToPropsIsMissing(mapStateToProps) {
2773 return !mapStateToProps ? wrapMapToPropsConstant(function () {
2774 return {};
2775 }) : undefined;
2776 }
2777 var defaultMapStateToPropsFactories = [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing];
2778
2779 function defaultMergeProps(stateProps, dispatchProps, ownProps) {
2780 return _extends$1({}, ownProps, {}, stateProps, {}, dispatchProps);
2781 }
2782 function wrapMergePropsFunc(mergeProps) {
2783 return function initMergePropsProxy(dispatch, _ref) {
2784 var displayName = _ref.displayName,
2785 pure = _ref.pure,
2786 areMergedPropsEqual = _ref.areMergedPropsEqual;
2787 var hasRunOnce = false;
2788 var mergedProps;
2789 return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
2790 var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2791
2792 if (hasRunOnce) {
2793 if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps;
2794 } else {
2795 hasRunOnce = true;
2796 mergedProps = nextMergedProps;
2797 verifyPlainObject(mergedProps, displayName, 'mergeProps');
2798 }
2799
2800 return mergedProps;
2801 };
2802 };
2803 }
2804 function whenMergePropsIsFunction(mergeProps) {
2805 return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined;
2806 }
2807 function whenMergePropsIsOmitted(mergeProps) {
2808 return !mergeProps ? function () {
2809 return defaultMergeProps;
2810 } : undefined;
2811 }
2812 var defaultMergePropsFactories = [whenMergePropsIsFunction, whenMergePropsIsOmitted];
2813
2814 function verify(selector, methodName, displayName) {
2815 if (!selector) {
2816 throw new Error("Unexpected value for " + methodName + " in " + displayName + ".");
2817 } else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
2818 if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {
2819 warning$2("The selector for " + methodName + " of " + displayName + " did not specify a value for dependsOnOwnProps.");
2820 }
2821 }
2822 }
2823
2824 function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) {
2825 verify(mapStateToProps, 'mapStateToProps', displayName);
2826 verify(mapDispatchToProps, 'mapDispatchToProps', displayName);
2827 verify(mergeProps, 'mergeProps', displayName);
2828 }
2829
2830 function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) {
2831 return function impureFinalPropsSelector(state, ownProps) {
2832 return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps);
2833 };
2834 }
2835 function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) {
2836 var areStatesEqual = _ref.areStatesEqual,
2837 areOwnPropsEqual = _ref.areOwnPropsEqual,
2838 areStatePropsEqual = _ref.areStatePropsEqual;
2839 var hasRunAtLeastOnce = false;
2840 var state;
2841 var ownProps;
2842 var stateProps;
2843 var dispatchProps;
2844 var mergedProps;
2845
2846 function handleFirstCall(firstState, firstOwnProps) {
2847 state = firstState;
2848 ownProps = firstOwnProps;
2849 stateProps = mapStateToProps(state, ownProps);
2850 dispatchProps = mapDispatchToProps(dispatch, ownProps);
2851 mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2852 hasRunAtLeastOnce = true;
2853 return mergedProps;
2854 }
2855
2856 function handleNewPropsAndNewState() {
2857 stateProps = mapStateToProps(state, ownProps);
2858 if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
2859 mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2860 return mergedProps;
2861 }
2862
2863 function handleNewProps() {
2864 if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps);
2865 if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
2866 mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2867 return mergedProps;
2868 }
2869
2870 function handleNewState() {
2871 var nextStateProps = mapStateToProps(state, ownProps);
2872 var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
2873 stateProps = nextStateProps;
2874 if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2875 return mergedProps;
2876 }
2877
2878 function handleSubsequentCalls(nextState, nextOwnProps) {
2879 var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
2880 var stateChanged = !areStatesEqual(nextState, state);
2881 state = nextState;
2882 ownProps = nextOwnProps;
2883 if (propsChanged && stateChanged) return handleNewPropsAndNewState();
2884 if (propsChanged) return handleNewProps();
2885 if (stateChanged) return handleNewState();
2886 return mergedProps;
2887 }
2888
2889 return function pureFinalPropsSelector(nextState, nextOwnProps) {
2890 return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
2891 };
2892 } // TODO: Add more comments
2893 // If pure is true, the selector returned by selectorFactory will memoize its results,
2894 // allowing connectAdvanced's shouldComponentUpdate to return false if final
2895 // props have not changed. If false, the selector will always return a new
2896 // object and shouldComponentUpdate will always return true.
2897
2898 function finalPropsSelectorFactory(dispatch, _ref2) {
2899 var initMapStateToProps = _ref2.initMapStateToProps,
2900 initMapDispatchToProps = _ref2.initMapDispatchToProps,
2901 initMergeProps = _ref2.initMergeProps,
2902 options = _objectWithoutPropertiesLoose(_ref2, ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]);
2903
2904 var mapStateToProps = initMapStateToProps(dispatch, options);
2905 var mapDispatchToProps = initMapDispatchToProps(dispatch, options);
2906 var mergeProps = initMergeProps(dispatch, options);
2907
2908 {
2909 verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName);
2910 }
2911
2912 var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory;
2913 return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
2914 }
2915
2916 /*
2917 connect is a facade over connectAdvanced. It turns its args into a compatible
2918 selectorFactory, which has the signature:
2919
2920 (dispatch, options) => (nextState, nextOwnProps) => nextFinalProps
2921
2922 connect passes its args to connectAdvanced as options, which will in turn pass them to
2923 selectorFactory each time a Connect component instance is instantiated or hot reloaded.
2924
2925 selectorFactory returns a final props selector from its mapStateToProps,
2926 mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps,
2927 mergePropsFactories, and pure args.
2928
2929 The resulting final props selector is called by the Connect component instance whenever
2930 it receives new props or store state.
2931 */
2932
2933 function match(arg, factories, name) {
2934 for (var i = factories.length - 1; i >= 0; i--) {
2935 var result = factories[i](arg);
2936 if (result) return result;
2937 }
2938
2939 return function (dispatch, options) {
2940 throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + ".");
2941 };
2942 }
2943
2944 function strictEqual(a, b) {
2945 return a === b;
2946 } // createConnect with default args builds the 'official' connect behavior. Calling it with
2947 // different options opens up some testing and extensibility scenarios
2948
2949
2950 function createConnect(_temp) {
2951 var _ref = _temp === void 0 ? {} : _temp,
2952 _ref$connectHOC = _ref.connectHOC,
2953 connectHOC = _ref$connectHOC === void 0 ? connectAdvanced : _ref$connectHOC,
2954 _ref$mapStateToPropsF = _ref.mapStateToPropsFactories,
2955 mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? defaultMapStateToPropsFactories : _ref$mapStateToPropsF,
2956 _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories,
2957 mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? defaultMapDispatchToPropsFactories : _ref$mapDispatchToPro,
2958 _ref$mergePropsFactor = _ref.mergePropsFactories,
2959 mergePropsFactories = _ref$mergePropsFactor === void 0 ? defaultMergePropsFactories : _ref$mergePropsFactor,
2960 _ref$selectorFactory = _ref.selectorFactory,
2961 selectorFactory = _ref$selectorFactory === void 0 ? finalPropsSelectorFactory : _ref$selectorFactory;
2962
2963 return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) {
2964 if (_ref2 === void 0) {
2965 _ref2 = {};
2966 }
2967
2968 var _ref3 = _ref2,
2969 _ref3$pure = _ref3.pure,
2970 pure = _ref3$pure === void 0 ? true : _ref3$pure,
2971 _ref3$areStatesEqual = _ref3.areStatesEqual,
2972 areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual,
2973 _ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual,
2974 areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? shallowEqual : _ref3$areOwnPropsEqua,
2975 _ref3$areStatePropsEq = _ref3.areStatePropsEqual,
2976 areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? shallowEqual : _ref3$areStatePropsEq,
2977 _ref3$areMergedPropsE = _ref3.areMergedPropsEqual,
2978 areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? shallowEqual : _ref3$areMergedPropsE,
2979 extraOptions = _objectWithoutPropertiesLoose(_ref3, ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]);
2980
2981 var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
2982 var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
2983 var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
2984 return connectHOC(selectorFactory, _extends$1({
2985 // used in error messages
2986 methodName: 'connect',
2987 // used to compute Connect's displayName from the wrapped component's displayName.
2988 getDisplayName: function getDisplayName(name) {
2989 return "Connect(" + name + ")";
2990 },
2991 // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes
2992 shouldHandleStateChanges: Boolean(mapStateToProps),
2993 // passed through to selectorFactory
2994 initMapStateToProps: initMapStateToProps,
2995 initMapDispatchToProps: initMapDispatchToProps,
2996 initMergeProps: initMergeProps,
2997 pure: pure,
2998 areStatesEqual: areStatesEqual,
2999 areOwnPropsEqual: areOwnPropsEqual,
3000 areStatePropsEqual: areStatePropsEqual,
3001 areMergedPropsEqual: areMergedPropsEqual
3002 }, extraOptions));
3003 };
3004 }
3005 var connect = /*#__PURE__*/
3006 createConnect();
3007
3008 setBatch(ReactDOM.unstable_batchedUpdates);
3009
3010 function areInputsEqual(newInputs, lastInputs) {
3011 if (newInputs.length !== lastInputs.length) {
3012 return false;
3013 }
3014
3015 for (var i = 0; i < newInputs.length; i++) {
3016 if (newInputs[i] !== lastInputs[i]) {
3017 return false;
3018 }
3019 }
3020
3021 return true;
3022 }
3023
3024 function useMemoOne(getResult, inputs) {
3025 var initial = React.useState(function () {
3026 return {
3027 inputs: inputs,
3028 result: getResult()
3029 };
3030 })[0];
3031 var committed = React.useRef(initial);
3032 var isInputMatch = Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
3033 var cache = isInputMatch ? committed.current : {
3034 inputs: inputs,
3035 result: getResult()
3036 };
3037 React.useEffect(function () {
3038 committed.current = cache;
3039 }, [cache]);
3040 return cache.result;
3041 }
3042 function useCallbackOne(callback, inputs) {
3043 return useMemoOne(function () {
3044 return callback;
3045 }, inputs);
3046 }
3047 var useMemo = useMemoOne;
3048 var useCallback = useCallbackOne;
3049
3050 var origin = {
3051 x: 0,
3052 y: 0
3053 };
3054 var add = function add(point1, point2) {
3055 return {
3056 x: point1.x + point2.x,
3057 y: point1.y + point2.y
3058 };
3059 };
3060 var subtract = function subtract(point1, point2) {
3061 return {
3062 x: point1.x - point2.x,
3063 y: point1.y - point2.y
3064 };
3065 };
3066 var isEqual = function isEqual(point1, point2) {
3067 return point1.x === point2.x && point1.y === point2.y;
3068 };
3069 var negate = function negate(point) {
3070 return {
3071 x: point.x !== 0 ? -point.x : 0,
3072 y: point.y !== 0 ? -point.y : 0
3073 };
3074 };
3075 var patch = function patch(line, value, otherValue) {
3076 var _ref;
3077
3078 if (otherValue === void 0) {
3079 otherValue = 0;
3080 }
3081
3082 return _ref = {}, _ref[line] = value, _ref[line === 'x' ? 'y' : 'x'] = otherValue, _ref;
3083 };
3084 var distance = function distance(point1, point2) {
3085 return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
3086 };
3087 var closest = function closest(target, points) {
3088 return Math.min.apply(Math, points.map(function (point) {
3089 return distance(target, point);
3090 }));
3091 };
3092 var apply = function apply(fn) {
3093 return function (point) {
3094 return {
3095 x: fn(point.x),
3096 y: fn(point.y)
3097 };
3098 };
3099 };
3100
3101 var prefix$1 = 'Invariant failed';
3102 function invariant$1(condition, message) {
3103 if (condition) {
3104 return;
3105 }
3106 throw new Error(prefix$1 + ": " + (message || ''));
3107 }
3108
3109 var getRect = function getRect(_ref) {
3110 var top = _ref.top,
3111 right = _ref.right,
3112 bottom = _ref.bottom,
3113 left = _ref.left;
3114 var width = right - left;
3115 var height = bottom - top;
3116 var rect = {
3117 top: top,
3118 right: right,
3119 bottom: bottom,
3120 left: left,
3121 width: width,
3122 height: height,
3123 x: left,
3124 y: top,
3125 center: {
3126 x: (right + left) / 2,
3127 y: (bottom + top) / 2
3128 }
3129 };
3130 return rect;
3131 };
3132 var expand = function expand(target, expandBy) {
3133 return {
3134 top: target.top - expandBy.top,
3135 left: target.left - expandBy.left,
3136 bottom: target.bottom + expandBy.bottom,
3137 right: target.right + expandBy.right
3138 };
3139 };
3140 var shrink = function shrink(target, shrinkBy) {
3141 return {
3142 top: target.top + shrinkBy.top,
3143 left: target.left + shrinkBy.left,
3144 bottom: target.bottom - shrinkBy.bottom,
3145 right: target.right - shrinkBy.right
3146 };
3147 };
3148
3149 var shift = function shift(target, shiftBy) {
3150 return {
3151 top: target.top + shiftBy.y,
3152 left: target.left + shiftBy.x,
3153 bottom: target.bottom + shiftBy.y,
3154 right: target.right + shiftBy.x
3155 };
3156 };
3157
3158 var noSpacing = {
3159 top: 0,
3160 right: 0,
3161 bottom: 0,
3162 left: 0
3163 };
3164 var createBox = function createBox(_ref2) {
3165 var borderBox = _ref2.borderBox,
3166 _ref2$margin = _ref2.margin,
3167 margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin,
3168 _ref2$border = _ref2.border,
3169 border = _ref2$border === void 0 ? noSpacing : _ref2$border,
3170 _ref2$padding = _ref2.padding,
3171 padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
3172 var marginBox = getRect(expand(borderBox, margin));
3173 var paddingBox = getRect(shrink(borderBox, border));
3174 var contentBox = getRect(shrink(paddingBox, padding));
3175 return {
3176 marginBox: marginBox,
3177 borderBox: getRect(borderBox),
3178 paddingBox: paddingBox,
3179 contentBox: contentBox,
3180 margin: margin,
3181 border: border,
3182 padding: padding
3183 };
3184 };
3185
3186 var parse = function parse(raw) {
3187 var value = raw.slice(0, -2);
3188 var suffix = raw.slice(-2);
3189
3190 if (suffix !== 'px') {
3191 return 0;
3192 }
3193
3194 var result = Number(value);
3195 !!isNaN(result) ? invariant$1(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : void 0;
3196 return result;
3197 };
3198
3199 var getWindowScroll = function getWindowScroll() {
3200 return {
3201 x: window.pageXOffset,
3202 y: window.pageYOffset
3203 };
3204 };
3205
3206 var offset = function offset(original, change) {
3207 var borderBox = original.borderBox,
3208 border = original.border,
3209 margin = original.margin,
3210 padding = original.padding;
3211 var shifted = shift(borderBox, change);
3212 return createBox({
3213 borderBox: shifted,
3214 border: border,
3215 margin: margin,
3216 padding: padding
3217 });
3218 };
3219 var withScroll = function withScroll(original, scroll) {
3220 if (scroll === void 0) {
3221 scroll = getWindowScroll();
3222 }
3223
3224 return offset(original, scroll);
3225 };
3226 var calculateBox = function calculateBox(borderBox, styles) {
3227 var margin = {
3228 top: parse(styles.marginTop),
3229 right: parse(styles.marginRight),
3230 bottom: parse(styles.marginBottom),
3231 left: parse(styles.marginLeft)
3232 };
3233 var padding = {
3234 top: parse(styles.paddingTop),
3235 right: parse(styles.paddingRight),
3236 bottom: parse(styles.paddingBottom),
3237 left: parse(styles.paddingLeft)
3238 };
3239 var border = {
3240 top: parse(styles.borderTopWidth),
3241 right: parse(styles.borderRightWidth),
3242 bottom: parse(styles.borderBottomWidth),
3243 left: parse(styles.borderLeftWidth)
3244 };
3245 return createBox({
3246 borderBox: borderBox,
3247 margin: margin,
3248 padding: padding,
3249 border: border
3250 });
3251 };
3252 var getBox = function getBox(el) {
3253 var borderBox = el.getBoundingClientRect();
3254 var styles = window.getComputedStyle(el);
3255 return calculateBox(borderBox, styles);
3256 };
3257
3258 var executeClip = (function (frame, subject) {
3259 var result = getRect({
3260 top: Math.max(subject.top, frame.top),
3261 right: Math.min(subject.right, frame.right),
3262 bottom: Math.min(subject.bottom, frame.bottom),
3263 left: Math.max(subject.left, frame.left)
3264 });
3265
3266 if (result.width <= 0 || result.height <= 0) {
3267 return null;
3268 }
3269
3270 return result;
3271 });
3272
3273 var offsetByPosition = function offsetByPosition(spacing, point) {
3274 return {
3275 top: spacing.top + point.y,
3276 left: spacing.left + point.x,
3277 bottom: spacing.bottom + point.y,
3278 right: spacing.right + point.x
3279 };
3280 };
3281 var getCorners = function getCorners(spacing) {
3282 return [{
3283 x: spacing.left,
3284 y: spacing.top
3285 }, {
3286 x: spacing.right,
3287 y: spacing.top
3288 }, {
3289 x: spacing.left,
3290 y: spacing.bottom
3291 }, {
3292 x: spacing.right,
3293 y: spacing.bottom
3294 }];
3295 };
3296 var noSpacing$1 = {
3297 top: 0,
3298 right: 0,
3299 bottom: 0,
3300 left: 0
3301 };
3302
3303 var scroll = function scroll(target, frame) {
3304 if (!frame) {
3305 return target;
3306 }
3307
3308 return offsetByPosition(target, frame.scroll.diff.displacement);
3309 };
3310
3311 var increase = function increase(target, axis, withPlaceholder) {
3312 if (withPlaceholder && withPlaceholder.increasedBy) {
3313 var _extends2;
3314
3315 return _extends({}, target, (_extends2 = {}, _extends2[axis.end] = target[axis.end] + withPlaceholder.increasedBy[axis.line], _extends2));
3316 }
3317
3318 return target;
3319 };
3320
3321 var clip = function clip(target, frame) {
3322 if (frame && frame.shouldClipSubject) {
3323 return executeClip(frame.pageMarginBox, target);
3324 }
3325
3326 return getRect(target);
3327 };
3328
3329 var getSubject = (function (_ref) {
3330 var page = _ref.page,
3331 withPlaceholder = _ref.withPlaceholder,
3332 axis = _ref.axis,
3333 frame = _ref.frame;
3334 var scrolled = scroll(page.marginBox, frame);
3335 var increased = increase(scrolled, axis, withPlaceholder);
3336 var clipped = clip(increased, frame);
3337 return {
3338 page: page,
3339 withPlaceholder: withPlaceholder,
3340 active: clipped
3341 };
3342 });
3343
3344 var scrollDroppable = (function (droppable, newScroll) {
3345 !droppable.frame ? invariant(false) : void 0;
3346 var scrollable = droppable.frame;
3347 var scrollDiff = subtract(newScroll, scrollable.scroll.initial);
3348 var scrollDisplacement = negate(scrollDiff);
3349
3350 var frame = _extends({}, scrollable, {
3351 scroll: {
3352 initial: scrollable.scroll.initial,
3353 current: newScroll,
3354 diff: {
3355 value: scrollDiff,
3356 displacement: scrollDisplacement
3357 },
3358 max: scrollable.scroll.max
3359 }
3360 });
3361
3362 var subject = getSubject({
3363 page: droppable.subject.page,
3364 withPlaceholder: droppable.subject.withPlaceholder,
3365 axis: droppable.axis,
3366 frame: frame
3367 });
3368
3369 var result = _extends({}, droppable, {
3370 frame: frame,
3371 subject: subject
3372 });
3373
3374 return result;
3375 });
3376
3377 function areInputsEqual$1(newInputs, lastInputs) {
3378 if (newInputs.length !== lastInputs.length) {
3379 return false;
3380 }
3381 for (var i = 0; i < newInputs.length; i++) {
3382 if (newInputs[i] !== lastInputs[i]) {
3383 return false;
3384 }
3385 }
3386 return true;
3387 }
3388
3389 function memoizeOne(resultFn, isEqual) {
3390 if (isEqual === void 0) { isEqual = areInputsEqual$1; }
3391 var lastThis;
3392 var lastArgs = [];
3393 var lastResult;
3394 var calledOnce = false;
3395 function memoized() {
3396 var newArgs = [];
3397 for (var _i = 0; _i < arguments.length; _i++) {
3398 newArgs[_i] = arguments[_i];
3399 }
3400 if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
3401 return lastResult;
3402 }
3403 lastResult = resultFn.apply(this, newArgs);
3404 calledOnce = true;
3405 lastThis = this;
3406 lastArgs = newArgs;
3407 return lastResult;
3408 }
3409 return memoized;
3410 }
3411
3412 function isInteger(value) {
3413 if (Number.isInteger) {
3414 return Number.isInteger(value);
3415 }
3416
3417 return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
3418 }
3419 function values(map) {
3420 if (Object.values) {
3421 return Object.values(map);
3422 }
3423
3424 return Object.keys(map).map(function (key) {
3425 return map[key];
3426 });
3427 }
3428 function findIndex(list, predicate) {
3429 if (list.findIndex) {
3430 return list.findIndex(predicate);
3431 }
3432
3433 for (var i = 0; i < list.length; i++) {
3434 if (predicate(list[i])) {
3435 return i;
3436 }
3437 }
3438
3439 return -1;
3440 }
3441 function find(list, predicate) {
3442 if (list.find) {
3443 return list.find(predicate);
3444 }
3445
3446 var index = findIndex(list, predicate);
3447
3448 if (index !== -1) {
3449 return list[index];
3450 }
3451
3452 return undefined;
3453 }
3454 function toArray(list) {
3455 return Array.prototype.slice.call(list);
3456 }
3457
3458 var toDroppableMap = memoizeOne(function (droppables) {
3459 return droppables.reduce(function (previous, current) {
3460 previous[current.descriptor.id] = current;
3461 return previous;
3462 }, {});
3463 });
3464 var toDraggableMap = memoizeOne(function (draggables) {
3465 return draggables.reduce(function (previous, current) {
3466 previous[current.descriptor.id] = current;
3467 return previous;
3468 }, {});
3469 });
3470 var toDroppableList = memoizeOne(function (droppables) {
3471 return values(droppables);
3472 });
3473 var toDraggableList = memoizeOne(function (draggables) {
3474 return values(draggables);
3475 });
3476
3477 var getDraggablesInsideDroppable = memoizeOne(function (droppableId, draggables) {
3478 var result = toDraggableList(draggables).filter(function (draggable) {
3479 return droppableId === draggable.descriptor.droppableId;
3480 }).sort(function (a, b) {
3481 return a.descriptor.index - b.descriptor.index;
3482 });
3483 return result;
3484 });
3485
3486 function tryGetDestination(impact) {
3487 if (impact.at && impact.at.type === 'REORDER') {
3488 return impact.at.destination;
3489 }
3490
3491 return null;
3492 }
3493 function tryGetCombine(impact) {
3494 if (impact.at && impact.at.type === 'COMBINE') {
3495 return impact.at.combine;
3496 }
3497
3498 return null;
3499 }
3500
3501 var removeDraggableFromList = memoizeOne(function (remove, list) {
3502 return list.filter(function (item) {
3503 return item.descriptor.id !== remove.descriptor.id;
3504 });
3505 });
3506
3507 var moveToNextCombine = (function (_ref) {
3508 var isMovingForward = _ref.isMovingForward,
3509 draggable = _ref.draggable,
3510 destination = _ref.destination,
3511 insideDestination = _ref.insideDestination,
3512 previousImpact = _ref.previousImpact;
3513
3514 if (!destination.isCombineEnabled) {
3515 return null;
3516 }
3517
3518 var location = tryGetDestination(previousImpact);
3519
3520 if (!location) {
3521 return null;
3522 }
3523
3524 function getImpact(target) {
3525 var at = {
3526 type: 'COMBINE',
3527 combine: {
3528 draggableId: target,
3529 droppableId: destination.descriptor.id
3530 }
3531 };
3532 return _extends({}, previousImpact, {
3533 at: at
3534 });
3535 }
3536
3537 var all = previousImpact.displaced.all;
3538 var closestId = all.length ? all[0] : null;
3539
3540 if (isMovingForward) {
3541 return closestId ? getImpact(closestId) : null;
3542 }
3543
3544 var withoutDraggable = removeDraggableFromList(draggable, insideDestination);
3545
3546 if (!closestId) {
3547 if (!withoutDraggable.length) {
3548 return null;
3549 }
3550
3551 var last = withoutDraggable[withoutDraggable.length - 1];
3552 return getImpact(last.descriptor.id);
3553 }
3554
3555 var indexOfClosest = findIndex(withoutDraggable, function (d) {
3556 return d.descriptor.id === closestId;
3557 });
3558 !(indexOfClosest !== -1) ? invariant(false, 'Could not find displaced item in set') : void 0;
3559 var proposedIndex = indexOfClosest - 1;
3560
3561 if (proposedIndex < 0) {
3562 return null;
3563 }
3564
3565 var before = withoutDraggable[proposedIndex];
3566 return getImpact(before.descriptor.id);
3567 });
3568
3569 var isHomeOf = (function (draggable, destination) {
3570 return draggable.descriptor.droppableId === destination.descriptor.id;
3571 });
3572
3573 var noDisplacedBy = {
3574 point: origin,
3575 value: 0
3576 };
3577 var emptyGroups = {
3578 invisible: {},
3579 visible: {},
3580 all: []
3581 };
3582 var noImpact = {
3583 displaced: emptyGroups,
3584 displacedBy: noDisplacedBy,
3585 at: null
3586 };
3587
3588 var isWithin = (function (lowerBound, upperBound) {
3589 return function (value) {
3590 return lowerBound <= value && value <= upperBound;
3591 };
3592 });
3593
3594 var isPartiallyVisibleThroughFrame = (function (frame) {
3595 var isWithinVertical = isWithin(frame.top, frame.bottom);
3596 var isWithinHorizontal = isWithin(frame.left, frame.right);
3597 return function (subject) {
3598 var isContained = isWithinVertical(subject.top) && isWithinVertical(subject.bottom) && isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
3599
3600 if (isContained) {
3601 return true;
3602 }
3603
3604 var isPartiallyVisibleVertically = isWithinVertical(subject.top) || isWithinVertical(subject.bottom);
3605 var isPartiallyVisibleHorizontally = isWithinHorizontal(subject.left) || isWithinHorizontal(subject.right);
3606 var isPartiallyContained = isPartiallyVisibleVertically && isPartiallyVisibleHorizontally;
3607
3608 if (isPartiallyContained) {
3609 return true;
3610 }
3611
3612 var isBiggerVertically = subject.top < frame.top && subject.bottom > frame.bottom;
3613 var isBiggerHorizontally = subject.left < frame.left && subject.right > frame.right;
3614 var isTargetBiggerThanFrame = isBiggerVertically && isBiggerHorizontally;
3615
3616 if (isTargetBiggerThanFrame) {
3617 return true;
3618 }
3619
3620 var isTargetBiggerOnOneAxis = isBiggerVertically && isPartiallyVisibleHorizontally || isBiggerHorizontally && isPartiallyVisibleVertically;
3621 return isTargetBiggerOnOneAxis;
3622 };
3623 });
3624
3625 var isTotallyVisibleThroughFrame = (function (frame) {
3626 var isWithinVertical = isWithin(frame.top, frame.bottom);
3627 var isWithinHorizontal = isWithin(frame.left, frame.right);
3628 return function (subject) {
3629 var isContained = isWithinVertical(subject.top) && isWithinVertical(subject.bottom) && isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
3630 return isContained;
3631 };
3632 });
3633
3634 var vertical = {
3635 direction: 'vertical',
3636 line: 'y',
3637 crossAxisLine: 'x',
3638 start: 'top',
3639 end: 'bottom',
3640 size: 'height',
3641 crossAxisStart: 'left',
3642 crossAxisEnd: 'right',
3643 crossAxisSize: 'width'
3644 };
3645 var horizontal = {
3646 direction: 'horizontal',
3647 line: 'x',
3648 crossAxisLine: 'y',
3649 start: 'left',
3650 end: 'right',
3651 size: 'width',
3652 crossAxisStart: 'top',
3653 crossAxisEnd: 'bottom',
3654 crossAxisSize: 'height'
3655 };
3656
3657 var isTotallyVisibleThroughFrameOnAxis = (function (axis) {
3658 return function (frame) {
3659 var isWithinVertical = isWithin(frame.top, frame.bottom);
3660 var isWithinHorizontal = isWithin(frame.left, frame.right);
3661 return function (subject) {
3662 if (axis === vertical) {
3663 return isWithinVertical(subject.top) && isWithinVertical(subject.bottom);
3664 }
3665
3666 return isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
3667 };
3668 };
3669 });
3670
3671 var getDroppableDisplaced = function getDroppableDisplaced(target, destination) {
3672 var displacement = destination.frame ? destination.frame.scroll.diff.displacement : origin;
3673 return offsetByPosition(target, displacement);
3674 };
3675
3676 var isVisibleInDroppable = function isVisibleInDroppable(target, destination, isVisibleThroughFrameFn) {
3677 if (!destination.subject.active) {
3678 return false;
3679 }
3680
3681 return isVisibleThroughFrameFn(destination.subject.active)(target);
3682 };
3683
3684 var isVisibleInViewport = function isVisibleInViewport(target, viewport, isVisibleThroughFrameFn) {
3685 return isVisibleThroughFrameFn(viewport)(target);
3686 };
3687
3688 var isVisible = function isVisible(_ref) {
3689 var toBeDisplaced = _ref.target,
3690 destination = _ref.destination,
3691 viewport = _ref.viewport,
3692 withDroppableDisplacement = _ref.withDroppableDisplacement,
3693 isVisibleThroughFrameFn = _ref.isVisibleThroughFrameFn;
3694 var displacedTarget = withDroppableDisplacement ? getDroppableDisplaced(toBeDisplaced, destination) : toBeDisplaced;
3695 return isVisibleInDroppable(displacedTarget, destination, isVisibleThroughFrameFn) && isVisibleInViewport(displacedTarget, viewport, isVisibleThroughFrameFn);
3696 };
3697
3698 var isPartiallyVisible = function isPartiallyVisible(args) {
3699 return isVisible(_extends({}, args, {
3700 isVisibleThroughFrameFn: isPartiallyVisibleThroughFrame
3701 }));
3702 };
3703 var isTotallyVisible = function isTotallyVisible(args) {
3704 return isVisible(_extends({}, args, {
3705 isVisibleThroughFrameFn: isTotallyVisibleThroughFrame
3706 }));
3707 };
3708 var isTotallyVisibleOnAxis = function isTotallyVisibleOnAxis(args) {
3709 return isVisible(_extends({}, args, {
3710 isVisibleThroughFrameFn: isTotallyVisibleThroughFrameOnAxis(args.destination.axis)
3711 }));
3712 };
3713
3714 var getShouldAnimate = function getShouldAnimate(id, last, forceShouldAnimate) {
3715 if (typeof forceShouldAnimate === 'boolean') {
3716 return forceShouldAnimate;
3717 }
3718
3719 if (!last) {
3720 return true;
3721 }
3722
3723 var invisible = last.invisible,
3724 visible = last.visible;
3725
3726 if (invisible[id]) {
3727 return false;
3728 }
3729
3730 var previous = visible[id];
3731 return previous ? previous.shouldAnimate : true;
3732 };
3733
3734 function getTarget(draggable, displacedBy) {
3735 var marginBox = draggable.page.marginBox;
3736 var expandBy = {
3737 top: displacedBy.point.y,
3738 right: 0,
3739 bottom: 0,
3740 left: displacedBy.point.x
3741 };
3742 return getRect(expand(marginBox, expandBy));
3743 }
3744
3745 function getDisplacementGroups(_ref) {
3746 var afterDragging = _ref.afterDragging,
3747 destination = _ref.destination,
3748 displacedBy = _ref.displacedBy,
3749 viewport = _ref.viewport,
3750 forceShouldAnimate = _ref.forceShouldAnimate,
3751 last = _ref.last;
3752 return afterDragging.reduce(function process(groups, draggable) {
3753 var target = getTarget(draggable, displacedBy);
3754 var id = draggable.descriptor.id;
3755 groups.all.push(id);
3756 var isVisible = isPartiallyVisible({
3757 target: target,
3758 destination: destination,
3759 viewport: viewport,
3760 withDroppableDisplacement: true
3761 });
3762
3763 if (!isVisible) {
3764 groups.invisible[draggable.descriptor.id] = true;
3765 return groups;
3766 }
3767
3768 var shouldAnimate = getShouldAnimate(id, last, forceShouldAnimate);
3769 var displacement = {
3770 draggableId: id,
3771 shouldAnimate: shouldAnimate
3772 };
3773 groups.visible[id] = displacement;
3774 return groups;
3775 }, {
3776 all: [],
3777 visible: {},
3778 invisible: {}
3779 });
3780 }
3781
3782 function getIndexOfLastItem(draggables, options) {
3783 if (!draggables.length) {
3784 return 0;
3785 }
3786
3787 var indexOfLastItem = draggables[draggables.length - 1].descriptor.index;
3788 return options.inHomeList ? indexOfLastItem : indexOfLastItem + 1;
3789 }
3790
3791 function goAtEnd(_ref) {
3792 var insideDestination = _ref.insideDestination,
3793 inHomeList = _ref.inHomeList,
3794 displacedBy = _ref.displacedBy,
3795 destination = _ref.destination;
3796 var newIndex = getIndexOfLastItem(insideDestination, {
3797 inHomeList: inHomeList
3798 });
3799 return {
3800 displaced: emptyGroups,
3801 displacedBy: displacedBy,
3802 at: {
3803 type: 'REORDER',
3804 destination: {
3805 droppableId: destination.descriptor.id,
3806 index: newIndex
3807 }
3808 }
3809 };
3810 }
3811
3812 function calculateReorderImpact(_ref2) {
3813 var draggable = _ref2.draggable,
3814 insideDestination = _ref2.insideDestination,
3815 destination = _ref2.destination,
3816 viewport = _ref2.viewport,
3817 displacedBy = _ref2.displacedBy,
3818 last = _ref2.last,
3819 index = _ref2.index,
3820 forceShouldAnimate = _ref2.forceShouldAnimate;
3821 var inHomeList = isHomeOf(draggable, destination);
3822
3823 if (index == null) {
3824 return goAtEnd({
3825 insideDestination: insideDestination,
3826 inHomeList: inHomeList,
3827 displacedBy: displacedBy,
3828 destination: destination
3829 });
3830 }
3831
3832 var match = find(insideDestination, function (item) {
3833 return item.descriptor.index === index;
3834 });
3835
3836 if (!match) {
3837 return goAtEnd({
3838 insideDestination: insideDestination,
3839 inHomeList: inHomeList,
3840 displacedBy: displacedBy,
3841 destination: destination
3842 });
3843 }
3844
3845 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
3846 var sliceFrom = insideDestination.indexOf(match);
3847 var impacted = withoutDragging.slice(sliceFrom);
3848 var displaced = getDisplacementGroups({
3849 afterDragging: impacted,
3850 destination: destination,
3851 displacedBy: displacedBy,
3852 last: last,
3853 viewport: viewport.frame,
3854 forceShouldAnimate: forceShouldAnimate
3855 });
3856 return {
3857 displaced: displaced,
3858 displacedBy: displacedBy,
3859 at: {
3860 type: 'REORDER',
3861 destination: {
3862 droppableId: destination.descriptor.id,
3863 index: index
3864 }
3865 }
3866 };
3867 }
3868
3869 function didStartAfterCritical(draggableId, afterCritical) {
3870 return Boolean(afterCritical.effected[draggableId]);
3871 }
3872
3873 var fromCombine = (function (_ref) {
3874 var isMovingForward = _ref.isMovingForward,
3875 destination = _ref.destination,
3876 draggables = _ref.draggables,
3877 combine = _ref.combine,
3878 afterCritical = _ref.afterCritical;
3879
3880 if (!destination.isCombineEnabled) {
3881 return null;
3882 }
3883
3884 var combineId = combine.draggableId;
3885 var combineWith = draggables[combineId];
3886 var combineWithIndex = combineWith.descriptor.index;
3887 var didCombineWithStartAfterCritical = didStartAfterCritical(combineId, afterCritical);
3888
3889 if (didCombineWithStartAfterCritical) {
3890 if (isMovingForward) {
3891 return combineWithIndex;
3892 }
3893
3894 return combineWithIndex - 1;
3895 }
3896
3897 if (isMovingForward) {
3898 return combineWithIndex + 1;
3899 }
3900
3901 return combineWithIndex;
3902 });
3903
3904 var fromReorder = (function (_ref) {
3905 var isMovingForward = _ref.isMovingForward,
3906 isInHomeList = _ref.isInHomeList,
3907 insideDestination = _ref.insideDestination,
3908 location = _ref.location;
3909
3910 if (!insideDestination.length) {
3911 return null;
3912 }
3913
3914 var currentIndex = location.index;
3915 var proposedIndex = isMovingForward ? currentIndex + 1 : currentIndex - 1;
3916 var firstIndex = insideDestination[0].descriptor.index;
3917 var lastIndex = insideDestination[insideDestination.length - 1].descriptor.index;
3918 var upperBound = isInHomeList ? lastIndex : lastIndex + 1;
3919
3920 if (proposedIndex < firstIndex) {
3921 return null;
3922 }
3923
3924 if (proposedIndex > upperBound) {
3925 return null;
3926 }
3927
3928 return proposedIndex;
3929 });
3930
3931 var moveToNextIndex = (function (_ref) {
3932 var isMovingForward = _ref.isMovingForward,
3933 isInHomeList = _ref.isInHomeList,
3934 draggable = _ref.draggable,
3935 draggables = _ref.draggables,
3936 destination = _ref.destination,
3937 insideDestination = _ref.insideDestination,
3938 previousImpact = _ref.previousImpact,
3939 viewport = _ref.viewport,
3940 afterCritical = _ref.afterCritical;
3941 var wasAt = previousImpact.at;
3942 !wasAt ? invariant(false, 'Cannot move in direction without previous impact location') : void 0;
3943
3944 if (wasAt.type === 'REORDER') {
3945 var _newIndex = fromReorder({
3946 isMovingForward: isMovingForward,
3947 isInHomeList: isInHomeList,
3948 location: wasAt.destination,
3949 insideDestination: insideDestination
3950 });
3951
3952 if (_newIndex == null) {
3953 return null;
3954 }
3955
3956 return calculateReorderImpact({
3957 draggable: draggable,
3958 insideDestination: insideDestination,
3959 destination: destination,
3960 viewport: viewport,
3961 last: previousImpact.displaced,
3962 displacedBy: previousImpact.displacedBy,
3963 index: _newIndex
3964 });
3965 }
3966
3967 var newIndex = fromCombine({
3968 isMovingForward: isMovingForward,
3969 destination: destination,
3970 displaced: previousImpact.displaced,
3971 draggables: draggables,
3972 combine: wasAt.combine,
3973 afterCritical: afterCritical
3974 });
3975
3976 if (newIndex == null) {
3977 return null;
3978 }
3979
3980 return calculateReorderImpact({
3981 draggable: draggable,
3982 insideDestination: insideDestination,
3983 destination: destination,
3984 viewport: viewport,
3985 last: previousImpact.displaced,
3986 displacedBy: previousImpact.displacedBy,
3987 index: newIndex
3988 });
3989 });
3990
3991 var getCombinedItemDisplacement = (function (_ref) {
3992 var displaced = _ref.displaced,
3993 afterCritical = _ref.afterCritical,
3994 combineWith = _ref.combineWith,
3995 displacedBy = _ref.displacedBy;
3996 var isDisplaced = Boolean(displaced.visible[combineWith] || displaced.invisible[combineWith]);
3997
3998 if (didStartAfterCritical(combineWith, afterCritical)) {
3999 return isDisplaced ? origin : negate(displacedBy.point);
4000 }
4001
4002 return isDisplaced ? displacedBy.point : origin;
4003 });
4004
4005 var whenCombining = (function (_ref) {
4006 var afterCritical = _ref.afterCritical,
4007 impact = _ref.impact,
4008 draggables = _ref.draggables;
4009 var combine = tryGetCombine(impact);
4010 !combine ? invariant(false) : void 0;
4011 var combineWith = combine.draggableId;
4012 var center = draggables[combineWith].page.borderBox.center;
4013 var displaceBy = getCombinedItemDisplacement({
4014 displaced: impact.displaced,
4015 afterCritical: afterCritical,
4016 combineWith: combineWith,
4017 displacedBy: impact.displacedBy
4018 });
4019 return add(center, displaceBy);
4020 });
4021
4022 var distanceFromStartToBorderBoxCenter = function distanceFromStartToBorderBoxCenter(axis, box) {
4023 return box.margin[axis.start] + box.borderBox[axis.size] / 2;
4024 };
4025
4026 var distanceFromEndToBorderBoxCenter = function distanceFromEndToBorderBoxCenter(axis, box) {
4027 return box.margin[axis.end] + box.borderBox[axis.size] / 2;
4028 };
4029
4030 var getCrossAxisBorderBoxCenter = function getCrossAxisBorderBoxCenter(axis, target, isMoving) {
4031 return target[axis.crossAxisStart] + isMoving.margin[axis.crossAxisStart] + isMoving.borderBox[axis.crossAxisSize] / 2;
4032 };
4033
4034 var goAfter = function goAfter(_ref) {
4035 var axis = _ref.axis,
4036 moveRelativeTo = _ref.moveRelativeTo,
4037 isMoving = _ref.isMoving;
4038 return patch(axis.line, moveRelativeTo.marginBox[axis.end] + distanceFromStartToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving));
4039 };
4040 var goBefore = function goBefore(_ref2) {
4041 var axis = _ref2.axis,
4042 moveRelativeTo = _ref2.moveRelativeTo,
4043 isMoving = _ref2.isMoving;
4044 return patch(axis.line, moveRelativeTo.marginBox[axis.start] - distanceFromEndToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving));
4045 };
4046 var goIntoStart = function goIntoStart(_ref3) {
4047 var axis = _ref3.axis,
4048 moveInto = _ref3.moveInto,
4049 isMoving = _ref3.isMoving;
4050 return patch(axis.line, moveInto.contentBox[axis.start] + distanceFromStartToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveInto.contentBox, isMoving));
4051 };
4052
4053 var whenReordering = (function (_ref) {
4054 var impact = _ref.impact,
4055 draggable = _ref.draggable,
4056 draggables = _ref.draggables,
4057 droppable = _ref.droppable,
4058 afterCritical = _ref.afterCritical;
4059 var insideDestination = getDraggablesInsideDroppable(droppable.descriptor.id, draggables);
4060 var draggablePage = draggable.page;
4061 var axis = droppable.axis;
4062
4063 if (!insideDestination.length) {
4064 return goIntoStart({
4065 axis: axis,
4066 moveInto: droppable.page,
4067 isMoving: draggablePage
4068 });
4069 }
4070
4071 var displaced = impact.displaced,
4072 displacedBy = impact.displacedBy;
4073 var closestAfter = displaced.all[0];
4074
4075 if (closestAfter) {
4076 var closest = draggables[closestAfter];
4077
4078 if (didStartAfterCritical(closestAfter, afterCritical)) {
4079 return goBefore({
4080 axis: axis,
4081 moveRelativeTo: closest.page,
4082 isMoving: draggablePage
4083 });
4084 }
4085
4086 var withDisplacement = offset(closest.page, displacedBy.point);
4087 return goBefore({
4088 axis: axis,
4089 moveRelativeTo: withDisplacement,
4090 isMoving: draggablePage
4091 });
4092 }
4093
4094 var last = insideDestination[insideDestination.length - 1];
4095
4096 if (last.descriptor.id === draggable.descriptor.id) {
4097 return draggablePage.borderBox.center;
4098 }
4099
4100 if (didStartAfterCritical(last.descriptor.id, afterCritical)) {
4101 var page = offset(last.page, negate(afterCritical.displacedBy.point));
4102 return goAfter({
4103 axis: axis,
4104 moveRelativeTo: page,
4105 isMoving: draggablePage
4106 });
4107 }
4108
4109 return goAfter({
4110 axis: axis,
4111 moveRelativeTo: last.page,
4112 isMoving: draggablePage
4113 });
4114 });
4115
4116 var withDroppableDisplacement = (function (droppable, point) {
4117 var frame = droppable.frame;
4118
4119 if (!frame) {
4120 return point;
4121 }
4122
4123 return add(point, frame.scroll.diff.displacement);
4124 });
4125
4126 var getResultWithoutDroppableDisplacement = function getResultWithoutDroppableDisplacement(_ref) {
4127 var impact = _ref.impact,
4128 draggable = _ref.draggable,
4129 droppable = _ref.droppable,
4130 draggables = _ref.draggables,
4131 afterCritical = _ref.afterCritical;
4132 var original = draggable.page.borderBox.center;
4133 var at = impact.at;
4134
4135 if (!droppable) {
4136 return original;
4137 }
4138
4139 if (!at) {
4140 return original;
4141 }
4142
4143 if (at.type === 'REORDER') {
4144 return whenReordering({
4145 impact: impact,
4146 draggable: draggable,
4147 draggables: draggables,
4148 droppable: droppable,
4149 afterCritical: afterCritical
4150 });
4151 }
4152
4153 return whenCombining({
4154 impact: impact,
4155 draggables: draggables,
4156 afterCritical: afterCritical
4157 });
4158 };
4159
4160 var getPageBorderBoxCenterFromImpact = (function (args) {
4161 var withoutDisplacement = getResultWithoutDroppableDisplacement(args);
4162 var droppable = args.droppable;
4163 var withDisplacement = droppable ? withDroppableDisplacement(droppable, withoutDisplacement) : withoutDisplacement;
4164 return withDisplacement;
4165 });
4166
4167 var scrollViewport = (function (viewport, newScroll) {
4168 var diff = subtract(newScroll, viewport.scroll.initial);
4169 var displacement = negate(diff);
4170 var frame = getRect({
4171 top: newScroll.y,
4172 bottom: newScroll.y + viewport.frame.height,
4173 left: newScroll.x,
4174 right: newScroll.x + viewport.frame.width
4175 });
4176 var updated = {
4177 frame: frame,
4178 scroll: {
4179 initial: viewport.scroll.initial,
4180 max: viewport.scroll.max,
4181 current: newScroll,
4182 diff: {
4183 value: diff,
4184 displacement: displacement
4185 }
4186 }
4187 };
4188 return updated;
4189 });
4190
4191 function getDraggables(ids, draggables) {
4192 return ids.map(function (id) {
4193 return draggables[id];
4194 });
4195 }
4196
4197 function tryGetVisible(id, groups) {
4198 for (var i = 0; i < groups.length; i++) {
4199 var displacement = groups[i].visible[id];
4200
4201 if (displacement) {
4202 return displacement;
4203 }
4204 }
4205
4206 return null;
4207 }
4208
4209 var speculativelyIncrease = (function (_ref) {
4210 var impact = _ref.impact,
4211 viewport = _ref.viewport,
4212 destination = _ref.destination,
4213 draggables = _ref.draggables,
4214 maxScrollChange = _ref.maxScrollChange;
4215 var scrolledViewport = scrollViewport(viewport, add(viewport.scroll.current, maxScrollChange));
4216 var scrolledDroppable = destination.frame ? scrollDroppable(destination, add(destination.frame.scroll.current, maxScrollChange)) : destination;
4217 var last = impact.displaced;
4218 var withViewportScroll = getDisplacementGroups({
4219 afterDragging: getDraggables(last.all, draggables),
4220 destination: destination,
4221 displacedBy: impact.displacedBy,
4222 viewport: scrolledViewport.frame,
4223 last: last,
4224 forceShouldAnimate: false
4225 });
4226 var withDroppableScroll = getDisplacementGroups({
4227 afterDragging: getDraggables(last.all, draggables),
4228 destination: scrolledDroppable,
4229 displacedBy: impact.displacedBy,
4230 viewport: viewport.frame,
4231 last: last,
4232 forceShouldAnimate: false
4233 });
4234 var invisible = {};
4235 var visible = {};
4236 var groups = [last, withViewportScroll, withDroppableScroll];
4237 last.all.forEach(function (id) {
4238 var displacement = tryGetVisible(id, groups);
4239
4240 if (displacement) {
4241 visible[id] = displacement;
4242 return;
4243 }
4244
4245 invisible[id] = true;
4246 });
4247
4248 var newImpact = _extends({}, impact, {
4249 displaced: {
4250 all: last.all,
4251 invisible: invisible,
4252 visible: visible
4253 }
4254 });
4255
4256 return newImpact;
4257 });
4258
4259 var withViewportDisplacement = (function (viewport, point) {
4260 return add(viewport.scroll.diff.displacement, point);
4261 });
4262
4263 var getClientFromPageBorderBoxCenter = (function (_ref) {
4264 var pageBorderBoxCenter = _ref.pageBorderBoxCenter,
4265 draggable = _ref.draggable,
4266 viewport = _ref.viewport;
4267 var withoutPageScrollChange = withViewportDisplacement(viewport, pageBorderBoxCenter);
4268 var offset = subtract(withoutPageScrollChange, draggable.page.borderBox.center);
4269 return add(draggable.client.borderBox.center, offset);
4270 });
4271
4272 var isTotallyVisibleInNewLocation = (function (_ref) {
4273 var draggable = _ref.draggable,
4274 destination = _ref.destination,
4275 newPageBorderBoxCenter = _ref.newPageBorderBoxCenter,
4276 viewport = _ref.viewport,
4277 withDroppableDisplacement = _ref.withDroppableDisplacement,
4278 _ref$onlyOnMainAxis = _ref.onlyOnMainAxis,
4279 onlyOnMainAxis = _ref$onlyOnMainAxis === void 0 ? false : _ref$onlyOnMainAxis;
4280 var changeNeeded = subtract(newPageBorderBoxCenter, draggable.page.borderBox.center);
4281 var shifted = offsetByPosition(draggable.page.borderBox, changeNeeded);
4282 var args = {
4283 target: shifted,
4284 destination: destination,
4285 withDroppableDisplacement: withDroppableDisplacement,
4286 viewport: viewport
4287 };
4288 return onlyOnMainAxis ? isTotallyVisibleOnAxis(args) : isTotallyVisible(args);
4289 });
4290
4291 var moveToNextPlace = (function (_ref) {
4292 var isMovingForward = _ref.isMovingForward,
4293 draggable = _ref.draggable,
4294 destination = _ref.destination,
4295 draggables = _ref.draggables,
4296 previousImpact = _ref.previousImpact,
4297 viewport = _ref.viewport,
4298 previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
4299 previousClientSelection = _ref.previousClientSelection,
4300 afterCritical = _ref.afterCritical;
4301
4302 if (!destination.isEnabled) {
4303 return null;
4304 }
4305
4306 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
4307 var isInHomeList = isHomeOf(draggable, destination);
4308 var impact = moveToNextCombine({
4309 isMovingForward: isMovingForward,
4310 draggable: draggable,
4311 destination: destination,
4312 insideDestination: insideDestination,
4313 previousImpact: previousImpact
4314 }) || moveToNextIndex({
4315 isMovingForward: isMovingForward,
4316 isInHomeList: isInHomeList,
4317 draggable: draggable,
4318 draggables: draggables,
4319 destination: destination,
4320 insideDestination: insideDestination,
4321 previousImpact: previousImpact,
4322 viewport: viewport,
4323 afterCritical: afterCritical
4324 });
4325
4326 if (!impact) {
4327 return null;
4328 }
4329
4330 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
4331 impact: impact,
4332 draggable: draggable,
4333 droppable: destination,
4334 draggables: draggables,
4335 afterCritical: afterCritical
4336 });
4337 var isVisibleInNewLocation = isTotallyVisibleInNewLocation({
4338 draggable: draggable,
4339 destination: destination,
4340 newPageBorderBoxCenter: pageBorderBoxCenter,
4341 viewport: viewport.frame,
4342 withDroppableDisplacement: false,
4343 onlyOnMainAxis: true
4344 });
4345
4346 if (isVisibleInNewLocation) {
4347 var clientSelection = getClientFromPageBorderBoxCenter({
4348 pageBorderBoxCenter: pageBorderBoxCenter,
4349 draggable: draggable,
4350 viewport: viewport
4351 });
4352 return {
4353 clientSelection: clientSelection,
4354 impact: impact,
4355 scrollJumpRequest: null
4356 };
4357 }
4358
4359 var distance = subtract(pageBorderBoxCenter, previousPageBorderBoxCenter);
4360 var cautious = speculativelyIncrease({
4361 impact: impact,
4362 viewport: viewport,
4363 destination: destination,
4364 draggables: draggables,
4365 maxScrollChange: distance
4366 });
4367 return {
4368 clientSelection: previousClientSelection,
4369 impact: cautious,
4370 scrollJumpRequest: distance
4371 };
4372 });
4373
4374 var getKnownActive = function getKnownActive(droppable) {
4375 var rect = droppable.subject.active;
4376 !rect ? invariant(false, 'Cannot get clipped area from droppable') : void 0;
4377 return rect;
4378 };
4379
4380 var getBestCrossAxisDroppable = (function (_ref) {
4381 var isMovingForward = _ref.isMovingForward,
4382 pageBorderBoxCenter = _ref.pageBorderBoxCenter,
4383 source = _ref.source,
4384 droppables = _ref.droppables,
4385 viewport = _ref.viewport;
4386 var active = source.subject.active;
4387
4388 if (!active) {
4389 return null;
4390 }
4391
4392 var axis = source.axis;
4393 var isBetweenSourceClipped = isWithin(active[axis.start], active[axis.end]);
4394 var candidates = toDroppableList(droppables).filter(function (droppable) {
4395 return droppable !== source;
4396 }).filter(function (droppable) {
4397 return droppable.isEnabled;
4398 }).filter(function (droppable) {
4399 return Boolean(droppable.subject.active);
4400 }).filter(function (droppable) {
4401 return isPartiallyVisibleThroughFrame(viewport.frame)(getKnownActive(droppable));
4402 }).filter(function (droppable) {
4403 var activeOfTarget = getKnownActive(droppable);
4404
4405 if (isMovingForward) {
4406 return active[axis.crossAxisEnd] < activeOfTarget[axis.crossAxisEnd];
4407 }
4408
4409 return activeOfTarget[axis.crossAxisStart] < active[axis.crossAxisStart];
4410 }).filter(function (droppable) {
4411 var activeOfTarget = getKnownActive(droppable);
4412 var isBetweenDestinationClipped = isWithin(activeOfTarget[axis.start], activeOfTarget[axis.end]);
4413 return isBetweenSourceClipped(activeOfTarget[axis.start]) || isBetweenSourceClipped(activeOfTarget[axis.end]) || isBetweenDestinationClipped(active[axis.start]) || isBetweenDestinationClipped(active[axis.end]);
4414 }).sort(function (a, b) {
4415 var first = getKnownActive(a)[axis.crossAxisStart];
4416 var second = getKnownActive(b)[axis.crossAxisStart];
4417
4418 if (isMovingForward) {
4419 return first - second;
4420 }
4421
4422 return second - first;
4423 }).filter(function (droppable, index, array) {
4424 return getKnownActive(droppable)[axis.crossAxisStart] === getKnownActive(array[0])[axis.crossAxisStart];
4425 });
4426
4427 if (!candidates.length) {
4428 return null;
4429 }
4430
4431 if (candidates.length === 1) {
4432 return candidates[0];
4433 }
4434
4435 var contains = candidates.filter(function (droppable) {
4436 var isWithinDroppable = isWithin(getKnownActive(droppable)[axis.start], getKnownActive(droppable)[axis.end]);
4437 return isWithinDroppable(pageBorderBoxCenter[axis.line]);
4438 });
4439
4440 if (contains.length === 1) {
4441 return contains[0];
4442 }
4443
4444 if (contains.length > 1) {
4445 return contains.sort(function (a, b) {
4446 return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
4447 })[0];
4448 }
4449
4450 return candidates.sort(function (a, b) {
4451 var first = closest(pageBorderBoxCenter, getCorners(getKnownActive(a)));
4452 var second = closest(pageBorderBoxCenter, getCorners(getKnownActive(b)));
4453
4454 if (first !== second) {
4455 return first - second;
4456 }
4457
4458 return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
4459 })[0];
4460 });
4461
4462 var getCurrentPageBorderBoxCenter = function getCurrentPageBorderBoxCenter(draggable, afterCritical) {
4463 var original = draggable.page.borderBox.center;
4464 return didStartAfterCritical(draggable.descriptor.id, afterCritical) ? subtract(original, afterCritical.displacedBy.point) : original;
4465 };
4466 var getCurrentPageBorderBox = function getCurrentPageBorderBox(draggable, afterCritical) {
4467 var original = draggable.page.borderBox;
4468 return didStartAfterCritical(draggable.descriptor.id, afterCritical) ? offsetByPosition(original, negate(afterCritical.displacedBy.point)) : original;
4469 };
4470
4471 var getClosestDraggable = (function (_ref) {
4472 var pageBorderBoxCenter = _ref.pageBorderBoxCenter,
4473 viewport = _ref.viewport,
4474 destination = _ref.destination,
4475 insideDestination = _ref.insideDestination,
4476 afterCritical = _ref.afterCritical;
4477 var sorted = insideDestination.filter(function (draggable) {
4478 return isTotallyVisible({
4479 target: getCurrentPageBorderBox(draggable, afterCritical),
4480 destination: destination,
4481 viewport: viewport.frame,
4482 withDroppableDisplacement: true
4483 });
4484 }).sort(function (a, b) {
4485 var distanceToA = distance(pageBorderBoxCenter, withDroppableDisplacement(destination, getCurrentPageBorderBoxCenter(a, afterCritical)));
4486 var distanceToB = distance(pageBorderBoxCenter, withDroppableDisplacement(destination, getCurrentPageBorderBoxCenter(b, afterCritical)));
4487
4488 if (distanceToA < distanceToB) {
4489 return -1;
4490 }
4491
4492 if (distanceToB < distanceToA) {
4493 return 1;
4494 }
4495
4496 return a.descriptor.index - b.descriptor.index;
4497 });
4498 return sorted[0] || null;
4499 });
4500
4501 var getDisplacedBy = memoizeOne(function getDisplacedBy(axis, displaceBy) {
4502 var displacement = displaceBy[axis.line];
4503 return {
4504 value: displacement,
4505 point: patch(axis.line, displacement)
4506 };
4507 });
4508
4509 var getRequiredGrowthForPlaceholder = function getRequiredGrowthForPlaceholder(droppable, placeholderSize, draggables) {
4510 var axis = droppable.axis;
4511
4512 if (droppable.descriptor.mode === 'virtual') {
4513 return patch(axis.line, placeholderSize[axis.line]);
4514 }
4515
4516 var availableSpace = droppable.subject.page.contentBox[axis.size];
4517 var insideDroppable = getDraggablesInsideDroppable(droppable.descriptor.id, draggables);
4518 var spaceUsed = insideDroppable.reduce(function (sum, dimension) {
4519 return sum + dimension.client.marginBox[axis.size];
4520 }, 0);
4521 var requiredSpace = spaceUsed + placeholderSize[axis.line];
4522 var needsToGrowBy = requiredSpace - availableSpace;
4523
4524 if (needsToGrowBy <= 0) {
4525 return null;
4526 }
4527
4528 return patch(axis.line, needsToGrowBy);
4529 };
4530
4531 var withMaxScroll = function withMaxScroll(frame, max) {
4532 return _extends({}, frame, {
4533 scroll: _extends({}, frame.scroll, {
4534 max: max
4535 })
4536 });
4537 };
4538
4539 var addPlaceholder = function addPlaceholder(droppable, draggable, draggables) {
4540 var frame = droppable.frame;
4541 !!isHomeOf(draggable, droppable) ? invariant(false, 'Should not add placeholder space to home list') : void 0;
4542 !!droppable.subject.withPlaceholder ? invariant(false, 'Cannot add placeholder size to a subject when it already has one') : void 0;
4543 var placeholderSize = getDisplacedBy(droppable.axis, draggable.displaceBy).point;
4544 var requiredGrowth = getRequiredGrowthForPlaceholder(droppable, placeholderSize, draggables);
4545 var added = {
4546 placeholderSize: placeholderSize,
4547 increasedBy: requiredGrowth,
4548 oldFrameMaxScroll: droppable.frame ? droppable.frame.scroll.max : null
4549 };
4550
4551 if (!frame) {
4552 var _subject = getSubject({
4553 page: droppable.subject.page,
4554 withPlaceholder: added,
4555 axis: droppable.axis,
4556 frame: droppable.frame
4557 });
4558
4559 return _extends({}, droppable, {
4560 subject: _subject
4561 });
4562 }
4563
4564 var maxScroll = requiredGrowth ? add(frame.scroll.max, requiredGrowth) : frame.scroll.max;
4565 var newFrame = withMaxScroll(frame, maxScroll);
4566 var subject = getSubject({
4567 page: droppable.subject.page,
4568 withPlaceholder: added,
4569 axis: droppable.axis,
4570 frame: newFrame
4571 });
4572 return _extends({}, droppable, {
4573 subject: subject,
4574 frame: newFrame
4575 });
4576 };
4577 var removePlaceholder = function removePlaceholder(droppable) {
4578 var added = droppable.subject.withPlaceholder;
4579 !added ? invariant(false, 'Cannot remove placeholder form subject when there was none') : void 0;
4580 var frame = droppable.frame;
4581
4582 if (!frame) {
4583 var _subject2 = getSubject({
4584 page: droppable.subject.page,
4585 axis: droppable.axis,
4586 frame: null,
4587 withPlaceholder: null
4588 });
4589
4590 return _extends({}, droppable, {
4591 subject: _subject2
4592 });
4593 }
4594
4595 var oldMaxScroll = added.oldFrameMaxScroll;
4596 !oldMaxScroll ? invariant(false, 'Expected droppable with frame to have old max frame scroll when removing placeholder') : void 0;
4597 var newFrame = withMaxScroll(frame, oldMaxScroll);
4598 var subject = getSubject({
4599 page: droppable.subject.page,
4600 axis: droppable.axis,
4601 frame: newFrame,
4602 withPlaceholder: null
4603 });
4604 return _extends({}, droppable, {
4605 subject: subject,
4606 frame: newFrame
4607 });
4608 };
4609
4610 var moveToNewDroppable = (function (_ref) {
4611 var previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
4612 moveRelativeTo = _ref.moveRelativeTo,
4613 insideDestination = _ref.insideDestination,
4614 draggable = _ref.draggable,
4615 draggables = _ref.draggables,
4616 destination = _ref.destination,
4617 viewport = _ref.viewport,
4618 afterCritical = _ref.afterCritical;
4619
4620 if (!moveRelativeTo) {
4621 if (insideDestination.length) {
4622 return null;
4623 }
4624
4625 var proposed = {
4626 displaced: emptyGroups,
4627 displacedBy: noDisplacedBy,
4628 at: {
4629 type: 'REORDER',
4630 destination: {
4631 droppableId: destination.descriptor.id,
4632 index: 0
4633 }
4634 }
4635 };
4636 var proposedPageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
4637 impact: proposed,
4638 draggable: draggable,
4639 droppable: destination,
4640 draggables: draggables,
4641 afterCritical: afterCritical
4642 });
4643 var withPlaceholder = isHomeOf(draggable, destination) ? destination : addPlaceholder(destination, draggable, draggables);
4644 var isVisibleInNewLocation = isTotallyVisibleInNewLocation({
4645 draggable: draggable,
4646 destination: withPlaceholder,
4647 newPageBorderBoxCenter: proposedPageBorderBoxCenter,
4648 viewport: viewport.frame,
4649 withDroppableDisplacement: false,
4650 onlyOnMainAxis: true
4651 });
4652 return isVisibleInNewLocation ? proposed : null;
4653 }
4654
4655 var isGoingBeforeTarget = Boolean(previousPageBorderBoxCenter[destination.axis.line] <= moveRelativeTo.page.borderBox.center[destination.axis.line]);
4656
4657 var proposedIndex = function () {
4658 var relativeTo = moveRelativeTo.descriptor.index;
4659
4660 if (moveRelativeTo.descriptor.id === draggable.descriptor.id) {
4661 return relativeTo;
4662 }
4663
4664 if (isGoingBeforeTarget) {
4665 return relativeTo;
4666 }
4667
4668 return relativeTo + 1;
4669 }();
4670
4671 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
4672 return calculateReorderImpact({
4673 draggable: draggable,
4674 insideDestination: insideDestination,
4675 destination: destination,
4676 viewport: viewport,
4677 displacedBy: displacedBy,
4678 last: emptyGroups,
4679 index: proposedIndex
4680 });
4681 });
4682
4683 var moveCrossAxis = (function (_ref) {
4684 var isMovingForward = _ref.isMovingForward,
4685 previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
4686 draggable = _ref.draggable,
4687 isOver = _ref.isOver,
4688 draggables = _ref.draggables,
4689 droppables = _ref.droppables,
4690 viewport = _ref.viewport,
4691 afterCritical = _ref.afterCritical;
4692 var destination = getBestCrossAxisDroppable({
4693 isMovingForward: isMovingForward,
4694 pageBorderBoxCenter: previousPageBorderBoxCenter,
4695 source: isOver,
4696 droppables: droppables,
4697 viewport: viewport
4698 });
4699
4700 if (!destination) {
4701 return null;
4702 }
4703
4704 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
4705 var moveRelativeTo = getClosestDraggable({
4706 pageBorderBoxCenter: previousPageBorderBoxCenter,
4707 viewport: viewport,
4708 destination: destination,
4709 insideDestination: insideDestination,
4710 afterCritical: afterCritical
4711 });
4712 var impact = moveToNewDroppable({
4713 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
4714 destination: destination,
4715 draggable: draggable,
4716 draggables: draggables,
4717 moveRelativeTo: moveRelativeTo,
4718 insideDestination: insideDestination,
4719 viewport: viewport,
4720 afterCritical: afterCritical
4721 });
4722
4723 if (!impact) {
4724 return null;
4725 }
4726
4727 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
4728 impact: impact,
4729 draggable: draggable,
4730 droppable: destination,
4731 draggables: draggables,
4732 afterCritical: afterCritical
4733 });
4734 var clientSelection = getClientFromPageBorderBoxCenter({
4735 pageBorderBoxCenter: pageBorderBoxCenter,
4736 draggable: draggable,
4737 viewport: viewport
4738 });
4739 return {
4740 clientSelection: clientSelection,
4741 impact: impact,
4742 scrollJumpRequest: null
4743 };
4744 });
4745
4746 var whatIsDraggedOver = (function (impact) {
4747 var at = impact.at;
4748
4749 if (!at) {
4750 return null;
4751 }
4752
4753 if (at.type === 'REORDER') {
4754 return at.destination.droppableId;
4755 }
4756
4757 return at.combine.droppableId;
4758 });
4759
4760 var getDroppableOver = function getDroppableOver(impact, droppables) {
4761 var id = whatIsDraggedOver(impact);
4762 return id ? droppables[id] : null;
4763 };
4764
4765 var moveInDirection = (function (_ref) {
4766 var state = _ref.state,
4767 type = _ref.type;
4768 var isActuallyOver = getDroppableOver(state.impact, state.dimensions.droppables);
4769 var isMainAxisMovementAllowed = Boolean(isActuallyOver);
4770 var home = state.dimensions.droppables[state.critical.droppable.id];
4771 var isOver = isActuallyOver || home;
4772 var direction = isOver.axis.direction;
4773 var isMovingOnMainAxis = direction === 'vertical' && (type === 'MOVE_UP' || type === 'MOVE_DOWN') || direction === 'horizontal' && (type === 'MOVE_LEFT' || type === 'MOVE_RIGHT');
4774
4775 if (isMovingOnMainAxis && !isMainAxisMovementAllowed) {
4776 return null;
4777 }
4778
4779 var isMovingForward = type === 'MOVE_DOWN' || type === 'MOVE_RIGHT';
4780 var draggable = state.dimensions.draggables[state.critical.draggable.id];
4781 var previousPageBorderBoxCenter = state.current.page.borderBoxCenter;
4782 var _state$dimensions = state.dimensions,
4783 draggables = _state$dimensions.draggables,
4784 droppables = _state$dimensions.droppables;
4785 return isMovingOnMainAxis ? moveToNextPlace({
4786 isMovingForward: isMovingForward,
4787 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
4788 draggable: draggable,
4789 destination: isOver,
4790 draggables: draggables,
4791 viewport: state.viewport,
4792 previousClientSelection: state.current.client.selection,
4793 previousImpact: state.impact,
4794 afterCritical: state.afterCritical
4795 }) : moveCrossAxis({
4796 isMovingForward: isMovingForward,
4797 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
4798 draggable: draggable,
4799 isOver: isOver,
4800 draggables: draggables,
4801 droppables: droppables,
4802 viewport: state.viewport,
4803 afterCritical: state.afterCritical
4804 });
4805 });
4806
4807 function isMovementAllowed(state) {
4808 return state.phase === 'DRAGGING' || state.phase === 'COLLECTING';
4809 }
4810
4811 function isPositionInFrame(frame) {
4812 var isWithinVertical = isWithin(frame.top, frame.bottom);
4813 var isWithinHorizontal = isWithin(frame.left, frame.right);
4814 return function run(point) {
4815 return isWithinVertical(point.y) && isWithinHorizontal(point.x);
4816 };
4817 }
4818
4819 function getHasOverlap(first, second) {
4820 return first.left < second.right && first.right > second.left && first.top < second.bottom && first.bottom > second.top;
4821 }
4822
4823 function getFurthestAway(_ref) {
4824 var pageBorderBox = _ref.pageBorderBox,
4825 draggable = _ref.draggable,
4826 candidates = _ref.candidates;
4827 var startCenter = draggable.page.borderBox.center;
4828 var sorted = candidates.map(function (candidate) {
4829 var axis = candidate.axis;
4830 var target = patch(candidate.axis.line, pageBorderBox.center[axis.line], candidate.page.borderBox.center[axis.crossAxisLine]);
4831 return {
4832 id: candidate.descriptor.id,
4833 distance: distance(startCenter, target)
4834 };
4835 }).sort(function (a, b) {
4836 return b.distance - a.distance;
4837 });
4838 return sorted[0] ? sorted[0].id : null;
4839 }
4840
4841 function getDroppableOver$1(_ref2) {
4842 var pageBorderBox = _ref2.pageBorderBox,
4843 draggable = _ref2.draggable,
4844 droppables = _ref2.droppables;
4845 var candidates = toDroppableList(droppables).filter(function (item) {
4846 if (!item.isEnabled) {
4847 return false;
4848 }
4849
4850 var active = item.subject.active;
4851
4852 if (!active) {
4853 return false;
4854 }
4855
4856 if (!getHasOverlap(pageBorderBox, active)) {
4857 return false;
4858 }
4859
4860 if (isPositionInFrame(active)(pageBorderBox.center)) {
4861 return true;
4862 }
4863
4864 var axis = item.axis;
4865 var childCenter = active.center[axis.crossAxisLine];
4866 var crossAxisStart = pageBorderBox[axis.crossAxisStart];
4867 var crossAxisEnd = pageBorderBox[axis.crossAxisEnd];
4868 var isContained = isWithin(active[axis.crossAxisStart], active[axis.crossAxisEnd]);
4869 var isStartContained = isContained(crossAxisStart);
4870 var isEndContained = isContained(crossAxisEnd);
4871
4872 if (!isStartContained && !isEndContained) {
4873 return true;
4874 }
4875
4876 if (isStartContained) {
4877 return crossAxisStart < childCenter;
4878 }
4879
4880 return crossAxisEnd > childCenter;
4881 });
4882
4883 if (!candidates.length) {
4884 return null;
4885 }
4886
4887 if (candidates.length === 1) {
4888 return candidates[0].descriptor.id;
4889 }
4890
4891 return getFurthestAway({
4892 pageBorderBox: pageBorderBox,
4893 draggable: draggable,
4894 candidates: candidates
4895 });
4896 }
4897
4898 var offsetRectByPosition = function offsetRectByPosition(rect, point) {
4899 return getRect(offsetByPosition(rect, point));
4900 };
4901
4902 var withDroppableScroll = (function (droppable, area) {
4903 var frame = droppable.frame;
4904
4905 if (!frame) {
4906 return area;
4907 }
4908
4909 return offsetRectByPosition(area, frame.scroll.diff.value);
4910 });
4911
4912 function getIsDisplaced(_ref) {
4913 var displaced = _ref.displaced,
4914 id = _ref.id;
4915 return Boolean(displaced.visible[id] || displaced.invisible[id]);
4916 }
4917
4918 function atIndex(_ref) {
4919 var draggable = _ref.draggable,
4920 closest = _ref.closest,
4921 inHomeList = _ref.inHomeList;
4922
4923 if (!closest) {
4924 return null;
4925 }
4926
4927 if (!inHomeList) {
4928 return closest.descriptor.index;
4929 }
4930
4931 if (closest.descriptor.index > draggable.descriptor.index) {
4932 return closest.descriptor.index - 1;
4933 }
4934
4935 return closest.descriptor.index;
4936 }
4937
4938 var getReorderImpact = (function (_ref2) {
4939 var targetRect = _ref2.pageBorderBoxWithDroppableScroll,
4940 draggable = _ref2.draggable,
4941 destination = _ref2.destination,
4942 insideDestination = _ref2.insideDestination,
4943 last = _ref2.last,
4944 viewport = _ref2.viewport,
4945 afterCritical = _ref2.afterCritical;
4946 var axis = destination.axis;
4947 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
4948 var displacement = displacedBy.value;
4949 var targetStart = targetRect[axis.start];
4950 var targetEnd = targetRect[axis.end];
4951 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
4952 var closest = find(withoutDragging, function (child) {
4953 var id = child.descriptor.id;
4954 var childCenter = child.page.borderBox.center[axis.line];
4955 var didStartAfterCritical$1 = didStartAfterCritical(id, afterCritical);
4956 var isDisplaced = getIsDisplaced({
4957 displaced: last,
4958 id: id
4959 });
4960
4961 if (didStartAfterCritical$1) {
4962 if (isDisplaced) {
4963 return targetEnd <= childCenter;
4964 }
4965
4966 return targetStart < childCenter - displacement;
4967 }
4968
4969 if (isDisplaced) {
4970 return targetEnd <= childCenter + displacement;
4971 }
4972
4973 return targetStart < childCenter;
4974 });
4975 var newIndex = atIndex({
4976 draggable: draggable,
4977 closest: closest,
4978 inHomeList: isHomeOf(draggable, destination)
4979 });
4980 return calculateReorderImpact({
4981 draggable: draggable,
4982 insideDestination: insideDestination,
4983 destination: destination,
4984 viewport: viewport,
4985 last: last,
4986 displacedBy: displacedBy,
4987 index: newIndex
4988 });
4989 });
4990
4991 var combineThresholdDivisor = 4;
4992 var getCombineImpact = (function (_ref) {
4993 var draggable = _ref.draggable,
4994 targetRect = _ref.pageBorderBoxWithDroppableScroll,
4995 previousImpact = _ref.previousImpact,
4996 destination = _ref.destination,
4997 insideDestination = _ref.insideDestination,
4998 afterCritical = _ref.afterCritical;
4999
5000 if (!destination.isCombineEnabled) {
5001 return null;
5002 }
5003
5004 var axis = destination.axis;
5005 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
5006 var displacement = displacedBy.value;
5007 var targetStart = targetRect[axis.start];
5008 var targetEnd = targetRect[axis.end];
5009 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
5010 var combineWith = find(withoutDragging, function (child) {
5011 var id = child.descriptor.id;
5012 var childRect = child.page.borderBox;
5013 var childSize = childRect[axis.size];
5014 var threshold = childSize / combineThresholdDivisor;
5015 var didStartAfterCritical$1 = didStartAfterCritical(id, afterCritical);
5016 var isDisplaced = getIsDisplaced({
5017 displaced: previousImpact.displaced,
5018 id: id
5019 });
5020
5021 if (didStartAfterCritical$1) {
5022 if (isDisplaced) {
5023 return targetEnd > childRect[axis.start] + threshold && targetEnd < childRect[axis.end] - threshold;
5024 }
5025
5026 return targetStart > childRect[axis.start] - displacement + threshold && targetStart < childRect[axis.end] - displacement - threshold;
5027 }
5028
5029 if (isDisplaced) {
5030 return targetEnd > childRect[axis.start] + displacement + threshold && targetEnd < childRect[axis.end] + displacement - threshold;
5031 }
5032
5033 return targetStart > childRect[axis.start] + threshold && targetStart < childRect[axis.end] - threshold;
5034 });
5035
5036 if (!combineWith) {
5037 return null;
5038 }
5039
5040 var impact = {
5041 displacedBy: displacedBy,
5042 displaced: previousImpact.displaced,
5043 at: {
5044 type: 'COMBINE',
5045 combine: {
5046 draggableId: combineWith.descriptor.id,
5047 droppableId: destination.descriptor.id
5048 }
5049 }
5050 };
5051 return impact;
5052 });
5053
5054 var getDragImpact = (function (_ref) {
5055 var pageOffset = _ref.pageOffset,
5056 draggable = _ref.draggable,
5057 draggables = _ref.draggables,
5058 droppables = _ref.droppables,
5059 previousImpact = _ref.previousImpact,
5060 viewport = _ref.viewport,
5061 afterCritical = _ref.afterCritical;
5062 var pageBorderBox = offsetRectByPosition(draggable.page.borderBox, pageOffset);
5063 var destinationId = getDroppableOver$1({
5064 pageBorderBox: pageBorderBox,
5065 draggable: draggable,
5066 droppables: droppables
5067 });
5068
5069 if (!destinationId) {
5070 return noImpact;
5071 }
5072
5073 var destination = droppables[destinationId];
5074 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
5075 var pageBorderBoxWithDroppableScroll = withDroppableScroll(destination, pageBorderBox);
5076 return getCombineImpact({
5077 pageBorderBoxWithDroppableScroll: pageBorderBoxWithDroppableScroll,
5078 draggable: draggable,
5079 previousImpact: previousImpact,
5080 destination: destination,
5081 insideDestination: insideDestination,
5082 afterCritical: afterCritical
5083 }) || getReorderImpact({
5084 pageBorderBoxWithDroppableScroll: pageBorderBoxWithDroppableScroll,
5085 draggable: draggable,
5086 destination: destination,
5087 insideDestination: insideDestination,
5088 last: previousImpact.displaced,
5089 viewport: viewport,
5090 afterCritical: afterCritical
5091 });
5092 });
5093
5094 var patchDroppableMap = (function (droppables, updated) {
5095 var _extends2;
5096
5097 return _extends({}, droppables, (_extends2 = {}, _extends2[updated.descriptor.id] = updated, _extends2));
5098 });
5099
5100 var clearUnusedPlaceholder = function clearUnusedPlaceholder(_ref) {
5101 var previousImpact = _ref.previousImpact,
5102 impact = _ref.impact,
5103 droppables = _ref.droppables;
5104 var last = whatIsDraggedOver(previousImpact);
5105 var now = whatIsDraggedOver(impact);
5106
5107 if (!last) {
5108 return droppables;
5109 }
5110
5111 if (last === now) {
5112 return droppables;
5113 }
5114
5115 var lastDroppable = droppables[last];
5116
5117 if (!lastDroppable.subject.withPlaceholder) {
5118 return droppables;
5119 }
5120
5121 var updated = removePlaceholder(lastDroppable);
5122 return patchDroppableMap(droppables, updated);
5123 };
5124
5125 var recomputePlaceholders = (function (_ref2) {
5126 var draggable = _ref2.draggable,
5127 draggables = _ref2.draggables,
5128 droppables = _ref2.droppables,
5129 previousImpact = _ref2.previousImpact,
5130 impact = _ref2.impact;
5131 var cleaned = clearUnusedPlaceholder({
5132 previousImpact: previousImpact,
5133 impact: impact,
5134 droppables: droppables
5135 });
5136 var isOver = whatIsDraggedOver(impact);
5137
5138 if (!isOver) {
5139 return cleaned;
5140 }
5141
5142 var droppable = droppables[isOver];
5143
5144 if (isHomeOf(draggable, droppable)) {
5145 return cleaned;
5146 }
5147
5148 if (droppable.subject.withPlaceholder) {
5149 return cleaned;
5150 }
5151
5152 var patched = addPlaceholder(droppable, draggable, draggables);
5153 return patchDroppableMap(cleaned, patched);
5154 });
5155
5156 var update = (function (_ref) {
5157 var state = _ref.state,
5158 forcedClientSelection = _ref.clientSelection,
5159 forcedDimensions = _ref.dimensions,
5160 forcedViewport = _ref.viewport,
5161 forcedImpact = _ref.impact,
5162 scrollJumpRequest = _ref.scrollJumpRequest;
5163 var viewport = forcedViewport || state.viewport;
5164 var dimensions = forcedDimensions || state.dimensions;
5165 var clientSelection = forcedClientSelection || state.current.client.selection;
5166 var offset = subtract(clientSelection, state.initial.client.selection);
5167 var client = {
5168 offset: offset,
5169 selection: clientSelection,
5170 borderBoxCenter: add(state.initial.client.borderBoxCenter, offset)
5171 };
5172 var page = {
5173 selection: add(client.selection, viewport.scroll.current),
5174 borderBoxCenter: add(client.borderBoxCenter, viewport.scroll.current),
5175 offset: add(client.offset, viewport.scroll.diff.value)
5176 };
5177 var current = {
5178 client: client,
5179 page: page
5180 };
5181
5182 if (state.phase === 'COLLECTING') {
5183 return _extends({
5184 phase: 'COLLECTING'
5185 }, state, {
5186 dimensions: dimensions,
5187 viewport: viewport,
5188 current: current
5189 });
5190 }
5191
5192 var draggable = dimensions.draggables[state.critical.draggable.id];
5193 var newImpact = forcedImpact || getDragImpact({
5194 pageOffset: page.offset,
5195 draggable: draggable,
5196 draggables: dimensions.draggables,
5197 droppables: dimensions.droppables,
5198 previousImpact: state.impact,
5199 viewport: viewport,
5200 afterCritical: state.afterCritical
5201 });
5202 var withUpdatedPlaceholders = recomputePlaceholders({
5203 draggable: draggable,
5204 impact: newImpact,
5205 previousImpact: state.impact,
5206 draggables: dimensions.draggables,
5207 droppables: dimensions.droppables
5208 });
5209
5210 var result = _extends({}, state, {
5211 current: current,
5212 dimensions: {
5213 draggables: dimensions.draggables,
5214 droppables: withUpdatedPlaceholders
5215 },
5216 impact: newImpact,
5217 viewport: viewport,
5218 scrollJumpRequest: scrollJumpRequest || null,
5219 forceShouldAnimate: scrollJumpRequest ? false : null
5220 });
5221
5222 return result;
5223 });
5224
5225 function getDraggables$1(ids, draggables) {
5226 return ids.map(function (id) {
5227 return draggables[id];
5228 });
5229 }
5230
5231 var recompute = (function (_ref) {
5232 var impact = _ref.impact,
5233 viewport = _ref.viewport,
5234 draggables = _ref.draggables,
5235 destination = _ref.destination,
5236 forceShouldAnimate = _ref.forceShouldAnimate;
5237 var last = impact.displaced;
5238 var afterDragging = getDraggables$1(last.all, draggables);
5239 var displaced = getDisplacementGroups({
5240 afterDragging: afterDragging,
5241 destination: destination,
5242 displacedBy: impact.displacedBy,
5243 viewport: viewport.frame,
5244 forceShouldAnimate: forceShouldAnimate,
5245 last: last
5246 });
5247 return _extends({}, impact, {
5248 displaced: displaced
5249 });
5250 });
5251
5252 var getClientBorderBoxCenter = (function (_ref) {
5253 var impact = _ref.impact,
5254 draggable = _ref.draggable,
5255 droppable = _ref.droppable,
5256 draggables = _ref.draggables,
5257 viewport = _ref.viewport,
5258 afterCritical = _ref.afterCritical;
5259 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
5260 impact: impact,
5261 draggable: draggable,
5262 draggables: draggables,
5263 droppable: droppable,
5264 afterCritical: afterCritical
5265 });
5266 return getClientFromPageBorderBoxCenter({
5267 pageBorderBoxCenter: pageBorderBoxCenter,
5268 draggable: draggable,
5269 viewport: viewport
5270 });
5271 });
5272
5273 var refreshSnap = (function (_ref) {
5274 var state = _ref.state,
5275 forcedDimensions = _ref.dimensions,
5276 forcedViewport = _ref.viewport;
5277 !(state.movementMode === 'SNAP') ? invariant(false) : void 0;
5278 var needsVisibilityCheck = state.impact;
5279 var viewport = forcedViewport || state.viewport;
5280 var dimensions = forcedDimensions || state.dimensions;
5281 var draggables = dimensions.draggables,
5282 droppables = dimensions.droppables;
5283 var draggable = draggables[state.critical.draggable.id];
5284 var isOver = whatIsDraggedOver(needsVisibilityCheck);
5285 !isOver ? invariant(false, 'Must be over a destination in SNAP movement mode') : void 0;
5286 var destination = droppables[isOver];
5287 var impact = recompute({
5288 impact: needsVisibilityCheck,
5289 viewport: viewport,
5290 destination: destination,
5291 draggables: draggables
5292 });
5293 var clientSelection = getClientBorderBoxCenter({
5294 impact: impact,
5295 draggable: draggable,
5296 droppable: destination,
5297 draggables: draggables,
5298 viewport: viewport,
5299 afterCritical: state.afterCritical
5300 });
5301 return update({
5302 impact: impact,
5303 clientSelection: clientSelection,
5304 state: state,
5305 dimensions: dimensions,
5306 viewport: viewport
5307 });
5308 });
5309
5310 var getHomeLocation = (function (descriptor) {
5311 return {
5312 index: descriptor.index,
5313 droppableId: descriptor.droppableId
5314 };
5315 });
5316
5317 var getLiftEffect = (function (_ref) {
5318 var draggable = _ref.draggable,
5319 home = _ref.home,
5320 draggables = _ref.draggables,
5321 viewport = _ref.viewport;
5322 var displacedBy = getDisplacedBy(home.axis, draggable.displaceBy);
5323 var insideHome = getDraggablesInsideDroppable(home.descriptor.id, draggables);
5324 var rawIndex = insideHome.indexOf(draggable);
5325 !(rawIndex !== -1) ? invariant(false, 'Expected draggable to be inside home list') : void 0;
5326 var afterDragging = insideHome.slice(rawIndex + 1);
5327 var effected = afterDragging.reduce(function (previous, item) {
5328 previous[item.descriptor.id] = true;
5329 return previous;
5330 }, {});
5331 var afterCritical = {
5332 inVirtualList: home.descriptor.mode === 'virtual',
5333 displacedBy: displacedBy,
5334 effected: effected
5335 };
5336 var displaced = getDisplacementGroups({
5337 afterDragging: afterDragging,
5338 destination: home,
5339 displacedBy: displacedBy,
5340 last: null,
5341 viewport: viewport.frame,
5342 forceShouldAnimate: false
5343 });
5344 var impact = {
5345 displaced: displaced,
5346 displacedBy: displacedBy,
5347 at: {
5348 type: 'REORDER',
5349 destination: getHomeLocation(draggable.descriptor)
5350 }
5351 };
5352 return {
5353 impact: impact,
5354 afterCritical: afterCritical
5355 };
5356 });
5357
5358 var patchDimensionMap = (function (dimensions, updated) {
5359 return {
5360 draggables: dimensions.draggables,
5361 droppables: patchDroppableMap(dimensions.droppables, updated)
5362 };
5363 });
5364
5365 var offsetDraggable = (function (_ref) {
5366 var draggable = _ref.draggable,
5367 offset$1 = _ref.offset,
5368 initialWindowScroll = _ref.initialWindowScroll;
5369 var client = offset(draggable.client, offset$1);
5370 var page = withScroll(client, initialWindowScroll);
5371
5372 var moved = _extends({}, draggable, {
5373 placeholder: _extends({}, draggable.placeholder, {
5374 client: client
5375 }),
5376 client: client,
5377 page: page
5378 });
5379
5380 return moved;
5381 });
5382
5383 var getFrame = (function (droppable) {
5384 var frame = droppable.frame;
5385 !frame ? invariant(false, 'Expected Droppable to have a frame') : void 0;
5386 return frame;
5387 });
5388
5389 var adjustAdditionsForScrollChanges = (function (_ref) {
5390 var additions = _ref.additions,
5391 updatedDroppables = _ref.updatedDroppables,
5392 viewport = _ref.viewport;
5393 var windowScrollChange = viewport.scroll.diff.value;
5394 return additions.map(function (draggable) {
5395 var droppableId = draggable.descriptor.droppableId;
5396 var modified = updatedDroppables[droppableId];
5397 var frame = getFrame(modified);
5398 var droppableScrollChange = frame.scroll.diff.value;
5399 var totalChange = add(windowScrollChange, droppableScrollChange);
5400 var moved = offsetDraggable({
5401 draggable: draggable,
5402 offset: totalChange,
5403 initialWindowScroll: viewport.scroll.initial
5404 });
5405 return moved;
5406 });
5407 });
5408
5409 var publishWhileDraggingInVirtual = (function (_ref) {
5410 var state = _ref.state,
5411 published = _ref.published;
5412 var withScrollChange = published.modified.map(function (update) {
5413 var existing = state.dimensions.droppables[update.droppableId];
5414 var scrolled = scrollDroppable(existing, update.scroll);
5415 return scrolled;
5416 });
5417
5418 var droppables = _extends({}, state.dimensions.droppables, {}, toDroppableMap(withScrollChange));
5419
5420 var updatedAdditions = toDraggableMap(adjustAdditionsForScrollChanges({
5421 additions: published.additions,
5422 updatedDroppables: droppables,
5423 viewport: state.viewport
5424 }));
5425
5426 var draggables = _extends({}, state.dimensions.draggables, {}, updatedAdditions);
5427
5428 published.removals.forEach(function (id) {
5429 delete draggables[id];
5430 });
5431 var dimensions = {
5432 droppables: droppables,
5433 draggables: draggables
5434 };
5435 var wasOverId = whatIsDraggedOver(state.impact);
5436 var wasOver = wasOverId ? dimensions.droppables[wasOverId] : null;
5437 var draggable = dimensions.draggables[state.critical.draggable.id];
5438 var home = dimensions.droppables[state.critical.droppable.id];
5439
5440 var _getLiftEffect = getLiftEffect({
5441 draggable: draggable,
5442 home: home,
5443 draggables: draggables,
5444 viewport: state.viewport
5445 }),
5446 onLiftImpact = _getLiftEffect.impact,
5447 afterCritical = _getLiftEffect.afterCritical;
5448
5449 var previousImpact = wasOver && wasOver.isCombineEnabled ? state.impact : onLiftImpact;
5450 var impact = getDragImpact({
5451 pageOffset: state.current.page.offset,
5452 draggable: dimensions.draggables[state.critical.draggable.id],
5453 draggables: dimensions.draggables,
5454 droppables: dimensions.droppables,
5455 previousImpact: previousImpact,
5456 viewport: state.viewport,
5457 afterCritical: afterCritical
5458 });
5459
5460 var draggingState = _extends({
5461 phase: 'DRAGGING'
5462 }, state, {
5463 phase: 'DRAGGING',
5464 impact: impact,
5465 onLiftImpact: onLiftImpact,
5466 dimensions: dimensions,
5467 afterCritical: afterCritical,
5468 forceShouldAnimate: false
5469 });
5470
5471 if (state.phase === 'COLLECTING') {
5472 return draggingState;
5473 }
5474
5475 var dropPending = _extends({
5476 phase: 'DROP_PENDING'
5477 }, draggingState, {
5478 phase: 'DROP_PENDING',
5479 reason: state.reason,
5480 isWaiting: false
5481 });
5482
5483 return dropPending;
5484 });
5485
5486 var isSnapping = function isSnapping(state) {
5487 return state.movementMode === 'SNAP';
5488 };
5489
5490 var postDroppableChange = function postDroppableChange(state, updated, isEnabledChanging) {
5491 var dimensions = patchDimensionMap(state.dimensions, updated);
5492
5493 if (!isSnapping(state) || isEnabledChanging) {
5494 return update({
5495 state: state,
5496 dimensions: dimensions
5497 });
5498 }
5499
5500 return refreshSnap({
5501 state: state,
5502 dimensions: dimensions
5503 });
5504 };
5505
5506 function removeScrollJumpRequest(state) {
5507 if (state.isDragging && state.movementMode === 'SNAP') {
5508 return _extends({
5509 phase: 'DRAGGING'
5510 }, state, {
5511 scrollJumpRequest: null
5512 });
5513 }
5514
5515 return state;
5516 }
5517
5518 var idle = {
5519 phase: 'IDLE',
5520 completed: null,
5521 shouldFlush: false
5522 };
5523 var reducer = (function (state, action) {
5524 if (state === void 0) {
5525 state = idle;
5526 }
5527
5528 if (action.type === 'FLUSH') {
5529 return _extends({}, idle, {
5530 shouldFlush: true
5531 });
5532 }
5533
5534 if (action.type === 'INITIAL_PUBLISH') {
5535 !(state.phase === 'IDLE') ? invariant(false, 'INITIAL_PUBLISH must come after a IDLE phase') : void 0;
5536 var _action$payload = action.payload,
5537 critical = _action$payload.critical,
5538 clientSelection = _action$payload.clientSelection,
5539 viewport = _action$payload.viewport,
5540 dimensions = _action$payload.dimensions,
5541 movementMode = _action$payload.movementMode;
5542 var draggable = dimensions.draggables[critical.draggable.id];
5543 var home = dimensions.droppables[critical.droppable.id];
5544 var client = {
5545 selection: clientSelection,
5546 borderBoxCenter: draggable.client.borderBox.center,
5547 offset: origin
5548 };
5549 var initial = {
5550 client: client,
5551 page: {
5552 selection: add(client.selection, viewport.scroll.initial),
5553 borderBoxCenter: add(client.selection, viewport.scroll.initial),
5554 offset: add(client.selection, viewport.scroll.diff.value)
5555 }
5556 };
5557 var isWindowScrollAllowed = toDroppableList(dimensions.droppables).every(function (item) {
5558 return !item.isFixedOnPage;
5559 });
5560
5561 var _getLiftEffect = getLiftEffect({
5562 draggable: draggable,
5563 home: home,
5564 draggables: dimensions.draggables,
5565 viewport: viewport
5566 }),
5567 impact = _getLiftEffect.impact,
5568 afterCritical = _getLiftEffect.afterCritical;
5569
5570 var result = {
5571 phase: 'DRAGGING',
5572 isDragging: true,
5573 critical: critical,
5574 movementMode: movementMode,
5575 dimensions: dimensions,
5576 initial: initial,
5577 current: initial,
5578 isWindowScrollAllowed: isWindowScrollAllowed,
5579 impact: impact,
5580 afterCritical: afterCritical,
5581 onLiftImpact: impact,
5582 viewport: viewport,
5583 scrollJumpRequest: null,
5584 forceShouldAnimate: null
5585 };
5586 return result;
5587 }
5588
5589 if (action.type === 'COLLECTION_STARTING') {
5590 if (state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') {
5591 return state;
5592 }
5593
5594 !(state.phase === 'DRAGGING') ? invariant(false, "Collection cannot start from phase " + state.phase) : void 0;
5595
5596 var _result = _extends({
5597 phase: 'COLLECTING'
5598 }, state, {
5599 phase: 'COLLECTING'
5600 });
5601
5602 return _result;
5603 }
5604
5605 if (action.type === 'PUBLISH_WHILE_DRAGGING') {
5606 !(state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') ? invariant(false, "Unexpected " + action.type + " received in phase " + state.phase) : void 0;
5607 return publishWhileDraggingInVirtual({
5608 state: state,
5609 published: action.payload
5610 });
5611 }
5612
5613 if (action.type === 'MOVE') {
5614 if (state.phase === 'DROP_PENDING') {
5615 return state;
5616 }
5617
5618 !isMovementAllowed(state) ? invariant(false, action.type + " not permitted in phase " + state.phase) : void 0;
5619 var _clientSelection = action.payload.client;
5620
5621 if (isEqual(_clientSelection, state.current.client.selection)) {
5622 return state;
5623 }
5624
5625 return update({
5626 state: state,
5627 clientSelection: _clientSelection,
5628 impact: isSnapping(state) ? state.impact : null
5629 });
5630 }
5631
5632 if (action.type === 'UPDATE_DROPPABLE_SCROLL') {
5633 if (state.phase === 'DROP_PENDING') {
5634 return removeScrollJumpRequest(state);
5635 }
5636
5637 if (state.phase === 'COLLECTING') {
5638 return removeScrollJumpRequest(state);
5639 }
5640
5641 !isMovementAllowed(state) ? invariant(false, action.type + " not permitted in phase " + state.phase) : void 0;
5642 var _action$payload2 = action.payload,
5643 id = _action$payload2.id,
5644 newScroll = _action$payload2.newScroll;
5645 var target = state.dimensions.droppables[id];
5646
5647 if (!target) {
5648 return state;
5649 }
5650
5651 var scrolled = scrollDroppable(target, newScroll);
5652 return postDroppableChange(state, scrolled, false);
5653 }
5654
5655 if (action.type === 'UPDATE_DROPPABLE_IS_ENABLED') {
5656 if (state.phase === 'DROP_PENDING') {
5657 return state;
5658 }
5659
5660 !isMovementAllowed(state) ? invariant(false, "Attempting to move in an unsupported phase " + state.phase) : void 0;
5661 var _action$payload3 = action.payload,
5662 _id = _action$payload3.id,
5663 isEnabled = _action$payload3.isEnabled;
5664 var _target = state.dimensions.droppables[_id];
5665 !_target ? invariant(false, "Cannot find Droppable[id: " + _id + "] to toggle its enabled state") : void 0;
5666 !(_target.isEnabled !== isEnabled) ? invariant(false, "Trying to set droppable isEnabled to " + String(isEnabled) + "\n but it is already " + String(_target.isEnabled)) : void 0;
5667
5668 var updated = _extends({}, _target, {
5669 isEnabled: isEnabled
5670 });
5671
5672 return postDroppableChange(state, updated, true);
5673 }
5674
5675 if (action.type === 'UPDATE_DROPPABLE_IS_COMBINE_ENABLED') {
5676 if (state.phase === 'DROP_PENDING') {
5677 return state;
5678 }
5679
5680 !isMovementAllowed(state) ? invariant(false, "Attempting to move in an unsupported phase " + state.phase) : void 0;
5681 var _action$payload4 = action.payload,
5682 _id2 = _action$payload4.id,
5683 isCombineEnabled = _action$payload4.isCombineEnabled;
5684 var _target2 = state.dimensions.droppables[_id2];
5685 !_target2 ? invariant(false, "Cannot find Droppable[id: " + _id2 + "] to toggle its isCombineEnabled state") : void 0;
5686 !(_target2.isCombineEnabled !== isCombineEnabled) ? invariant(false, "Trying to set droppable isCombineEnabled to " + String(isCombineEnabled) + "\n but it is already " + String(_target2.isCombineEnabled)) : void 0;
5687
5688 var _updated = _extends({}, _target2, {
5689 isCombineEnabled: isCombineEnabled
5690 });
5691
5692 return postDroppableChange(state, _updated, true);
5693 }
5694
5695 if (action.type === 'MOVE_BY_WINDOW_SCROLL') {
5696 if (state.phase === 'DROP_PENDING' || state.phase === 'DROP_ANIMATING') {
5697 return state;
5698 }
5699
5700 !isMovementAllowed(state) ? invariant(false, "Cannot move by window in phase " + state.phase) : void 0;
5701 !state.isWindowScrollAllowed ? invariant(false, 'Window scrolling is currently not supported for fixed lists') : void 0;
5702 var _newScroll = action.payload.newScroll;
5703
5704 if (isEqual(state.viewport.scroll.current, _newScroll)) {
5705 return removeScrollJumpRequest(state);
5706 }
5707
5708 var _viewport = scrollViewport(state.viewport, _newScroll);
5709
5710 if (isSnapping(state)) {
5711 return refreshSnap({
5712 state: state,
5713 viewport: _viewport
5714 });
5715 }
5716
5717 return update({
5718 state: state,
5719 viewport: _viewport
5720 });
5721 }
5722
5723 if (action.type === 'UPDATE_VIEWPORT_MAX_SCROLL') {
5724 if (!isMovementAllowed(state)) {
5725 return state;
5726 }
5727
5728 var maxScroll = action.payload.maxScroll;
5729
5730 if (isEqual(maxScroll, state.viewport.scroll.max)) {
5731 return state;
5732 }
5733
5734 var withMaxScroll = _extends({}, state.viewport, {
5735 scroll: _extends({}, state.viewport.scroll, {
5736 max: maxScroll
5737 })
5738 });
5739
5740 return _extends({
5741 phase: 'DRAGGING'
5742 }, state, {
5743 viewport: withMaxScroll
5744 });
5745 }
5746
5747 if (action.type === 'MOVE_UP' || action.type === 'MOVE_DOWN' || action.type === 'MOVE_LEFT' || action.type === 'MOVE_RIGHT') {
5748 if (state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') {
5749 return state;
5750 }
5751
5752 !(state.phase === 'DRAGGING') ? invariant(false, action.type + " received while not in DRAGGING phase") : void 0;
5753
5754 var _result2 = moveInDirection({
5755 state: state,
5756 type: action.type
5757 });
5758
5759 if (!_result2) {
5760 return state;
5761 }
5762
5763 return update({
5764 state: state,
5765 impact: _result2.impact,
5766 clientSelection: _result2.clientSelection,
5767 scrollJumpRequest: _result2.scrollJumpRequest
5768 });
5769 }
5770
5771 if (action.type === 'DROP_PENDING') {
5772 var reason = action.payload.reason;
5773 !(state.phase === 'COLLECTING') ? invariant(false, 'Can only move into the DROP_PENDING phase from the COLLECTING phase') : void 0;
5774
5775 var newState = _extends({
5776 phase: 'DROP_PENDING'
5777 }, state, {
5778 phase: 'DROP_PENDING',
5779 isWaiting: true,
5780 reason: reason
5781 });
5782
5783 return newState;
5784 }
5785
5786 if (action.type === 'DROP_ANIMATE') {
5787 var _action$payload5 = action.payload,
5788 completed = _action$payload5.completed,
5789 dropDuration = _action$payload5.dropDuration,
5790 newHomeClientOffset = _action$payload5.newHomeClientOffset;
5791 !(state.phase === 'DRAGGING' || state.phase === 'DROP_PENDING') ? invariant(false, "Cannot animate drop from phase " + state.phase) : void 0;
5792 var _result3 = {
5793 phase: 'DROP_ANIMATING',
5794 completed: completed,
5795 dropDuration: dropDuration,
5796 newHomeClientOffset: newHomeClientOffset,
5797 dimensions: state.dimensions
5798 };
5799 return _result3;
5800 }
5801
5802 if (action.type === 'DROP_COMPLETE') {
5803 var _completed = action.payload.completed;
5804 return {
5805 phase: 'IDLE',
5806 completed: _completed,
5807 shouldFlush: false
5808 };
5809 }
5810
5811 return state;
5812 });
5813
5814 var beforeInitialCapture = function beforeInitialCapture(args) {
5815 return {
5816 type: 'BEFORE_INITIAL_CAPTURE',
5817 payload: args
5818 };
5819 };
5820 var lift = function lift(args) {
5821 return {
5822 type: 'LIFT',
5823 payload: args
5824 };
5825 };
5826 var initialPublish = function initialPublish(args) {
5827 return {
5828 type: 'INITIAL_PUBLISH',
5829 payload: args
5830 };
5831 };
5832 var publishWhileDragging = function publishWhileDragging(args) {
5833 return {
5834 type: 'PUBLISH_WHILE_DRAGGING',
5835 payload: args
5836 };
5837 };
5838 var collectionStarting = function collectionStarting() {
5839 return {
5840 type: 'COLLECTION_STARTING',
5841 payload: null
5842 };
5843 };
5844 var updateDroppableScroll = function updateDroppableScroll(args) {
5845 return {
5846 type: 'UPDATE_DROPPABLE_SCROLL',
5847 payload: args
5848 };
5849 };
5850 var updateDroppableIsEnabled = function updateDroppableIsEnabled(args) {
5851 return {
5852 type: 'UPDATE_DROPPABLE_IS_ENABLED',
5853 payload: args
5854 };
5855 };
5856 var updateDroppableIsCombineEnabled = function updateDroppableIsCombineEnabled(args) {
5857 return {
5858 type: 'UPDATE_DROPPABLE_IS_COMBINE_ENABLED',
5859 payload: args
5860 };
5861 };
5862 var move = function move(args) {
5863 return {
5864 type: 'MOVE',
5865 payload: args
5866 };
5867 };
5868 var moveByWindowScroll = function moveByWindowScroll(args) {
5869 return {
5870 type: 'MOVE_BY_WINDOW_SCROLL',
5871 payload: args
5872 };
5873 };
5874 var updateViewportMaxScroll = function updateViewportMaxScroll(args) {
5875 return {
5876 type: 'UPDATE_VIEWPORT_MAX_SCROLL',
5877 payload: args
5878 };
5879 };
5880 var moveUp = function moveUp() {
5881 return {
5882 type: 'MOVE_UP',
5883 payload: null
5884 };
5885 };
5886 var moveDown = function moveDown() {
5887 return {
5888 type: 'MOVE_DOWN',
5889 payload: null
5890 };
5891 };
5892 var moveRight = function moveRight() {
5893 return {
5894 type: 'MOVE_RIGHT',
5895 payload: null
5896 };
5897 };
5898 var moveLeft = function moveLeft() {
5899 return {
5900 type: 'MOVE_LEFT',
5901 payload: null
5902 };
5903 };
5904 var flush = function flush() {
5905 return {
5906 type: 'FLUSH',
5907 payload: null
5908 };
5909 };
5910 var animateDrop = function animateDrop(args) {
5911 return {
5912 type: 'DROP_ANIMATE',
5913 payload: args
5914 };
5915 };
5916 var completeDrop = function completeDrop(args) {
5917 return {
5918 type: 'DROP_COMPLETE',
5919 payload: args
5920 };
5921 };
5922 var drop = function drop(args) {
5923 return {
5924 type: 'DROP',
5925 payload: args
5926 };
5927 };
5928 var dropPending = function dropPending(args) {
5929 return {
5930 type: 'DROP_PENDING',
5931 payload: args
5932 };
5933 };
5934 var dropAnimationFinished = function dropAnimationFinished() {
5935 return {
5936 type: 'DROP_ANIMATION_FINISHED',
5937 payload: null
5938 };
5939 };
5940
5941 function checkIndexes(insideDestination) {
5942 if (insideDestination.length <= 1) {
5943 return;
5944 }
5945
5946 var indexes = insideDestination.map(function (d) {
5947 return d.descriptor.index;
5948 });
5949 var errors = {};
5950
5951 for (var i = 1; i < indexes.length; i++) {
5952 var current = indexes[i];
5953 var previous = indexes[i - 1];
5954
5955 if (current !== previous + 1) {
5956 errors[current] = true;
5957 }
5958 }
5959
5960 if (!Object.keys(errors).length) {
5961 return;
5962 }
5963
5964 var formatted = indexes.map(function (index) {
5965 var hasError = Boolean(errors[index]);
5966 return hasError ? "[\uD83D\uDD25" + index + "]" : "" + index;
5967 }).join(', ');
5968 warning("\n Detected non-consecutive <Draggable /> indexes.\n\n (This can cause unexpected bugs)\n\n " + formatted + "\n ") ;
5969 }
5970
5971 function validateDimensions(critical, dimensions) {
5972 {
5973 var insideDestination = getDraggablesInsideDroppable(critical.droppable.id, dimensions.draggables);
5974 checkIndexes(insideDestination);
5975 }
5976 }
5977
5978 var lift$1 = (function (marshal) {
5979 return function (_ref) {
5980 var getState = _ref.getState,
5981 dispatch = _ref.dispatch;
5982 return function (next) {
5983 return function (action) {
5984 if (action.type !== 'LIFT') {
5985 next(action);
5986 return;
5987 }
5988
5989 var _action$payload = action.payload,
5990 id = _action$payload.id,
5991 clientSelection = _action$payload.clientSelection,
5992 movementMode = _action$payload.movementMode;
5993 var initial = getState();
5994
5995 if (initial.phase === 'DROP_ANIMATING') {
5996 dispatch(completeDrop({
5997 completed: initial.completed
5998 }));
5999 }
6000
6001 !(getState().phase === 'IDLE') ? invariant(false, 'Unexpected phase to start a drag') : void 0;
6002 dispatch(flush());
6003 dispatch(beforeInitialCapture({
6004 draggableId: id,
6005 movementMode: movementMode
6006 }));
6007 var scrollOptions = {
6008 shouldPublishImmediately: movementMode === 'SNAP'
6009 };
6010 var request = {
6011 draggableId: id,
6012 scrollOptions: scrollOptions
6013 };
6014
6015 var _marshal$startPublish = marshal.startPublishing(request),
6016 critical = _marshal$startPublish.critical,
6017 dimensions = _marshal$startPublish.dimensions,
6018 viewport = _marshal$startPublish.viewport;
6019
6020 validateDimensions(critical, dimensions);
6021 dispatch(initialPublish({
6022 critical: critical,
6023 dimensions: dimensions,
6024 clientSelection: clientSelection,
6025 movementMode: movementMode,
6026 viewport: viewport
6027 }));
6028 };
6029 };
6030 };
6031 });
6032
6033 var style = (function (marshal) {
6034 return function () {
6035 return function (next) {
6036 return function (action) {
6037 if (action.type === 'INITIAL_PUBLISH') {
6038 marshal.dragging();
6039 }
6040
6041 if (action.type === 'DROP_ANIMATE') {
6042 marshal.dropping(action.payload.completed.result.reason);
6043 }
6044
6045 if (action.type === 'FLUSH' || action.type === 'DROP_COMPLETE') {
6046 marshal.resting();
6047 }
6048
6049 next(action);
6050 };
6051 };
6052 };
6053 });
6054
6055 var curves = {
6056 outOfTheWay: 'cubic-bezier(0.2, 0, 0, 1)',
6057 drop: 'cubic-bezier(.2,1,.1,1)'
6058 };
6059 var combine = {
6060 opacity: {
6061 drop: 0,
6062 combining: 0.7
6063 },
6064 scale: {
6065 drop: 0.75
6066 }
6067 };
6068 var timings = {
6069 outOfTheWay: 0.2,
6070 minDropTime: 0.33,
6071 maxDropTime: 0.55
6072 };
6073 var outOfTheWayTiming = timings.outOfTheWay + "s " + curves.outOfTheWay;
6074 var transitions = {
6075 fluid: "opacity " + outOfTheWayTiming,
6076 snap: "transform " + outOfTheWayTiming + ", opacity " + outOfTheWayTiming,
6077 drop: function drop(duration) {
6078 var timing = duration + "s " + curves.drop;
6079 return "transform " + timing + ", opacity " + timing;
6080 },
6081 outOfTheWay: "transform " + outOfTheWayTiming,
6082 placeholder: "height " + outOfTheWayTiming + ", width " + outOfTheWayTiming + ", margin " + outOfTheWayTiming
6083 };
6084
6085 var moveTo = function moveTo(offset) {
6086 return isEqual(offset, origin) ? null : "translate(" + offset.x + "px, " + offset.y + "px)";
6087 };
6088
6089 var transforms = {
6090 moveTo: moveTo,
6091 drop: function drop(offset, isCombining) {
6092 var translate = moveTo(offset);
6093
6094 if (!translate) {
6095 return null;
6096 }
6097
6098 if (!isCombining) {
6099 return translate;
6100 }
6101
6102 return translate + " scale(" + combine.scale.drop + ")";
6103 }
6104 };
6105
6106 var minDropTime = timings.minDropTime,
6107 maxDropTime = timings.maxDropTime;
6108 var dropTimeRange = maxDropTime - minDropTime;
6109 var maxDropTimeAtDistance = 1500;
6110 var cancelDropModifier = 0.6;
6111 var getDropDuration = (function (_ref) {
6112 var current = _ref.current,
6113 destination = _ref.destination,
6114 reason = _ref.reason;
6115 var distance$1 = distance(current, destination);
6116
6117 if (distance$1 <= 0) {
6118 return minDropTime;
6119 }
6120
6121 if (distance$1 >= maxDropTimeAtDistance) {
6122 return maxDropTime;
6123 }
6124
6125 var percentage = distance$1 / maxDropTimeAtDistance;
6126 var duration = minDropTime + dropTimeRange * percentage;
6127 var withDuration = reason === 'CANCEL' ? duration * cancelDropModifier : duration;
6128 return Number(withDuration.toFixed(2));
6129 });
6130
6131 var getNewHomeClientOffset = (function (_ref) {
6132 var impact = _ref.impact,
6133 draggable = _ref.draggable,
6134 dimensions = _ref.dimensions,
6135 viewport = _ref.viewport,
6136 afterCritical = _ref.afterCritical;
6137 var draggables = dimensions.draggables,
6138 droppables = dimensions.droppables;
6139 var droppableId = whatIsDraggedOver(impact);
6140 var destination = droppableId ? droppables[droppableId] : null;
6141 var home = droppables[draggable.descriptor.droppableId];
6142 var newClientCenter = getClientBorderBoxCenter({
6143 impact: impact,
6144 draggable: draggable,
6145 draggables: draggables,
6146 afterCritical: afterCritical,
6147 droppable: destination || home,
6148 viewport: viewport
6149 });
6150 var offset = subtract(newClientCenter, draggable.client.borderBox.center);
6151 return offset;
6152 });
6153
6154 var getDropImpact = (function (_ref) {
6155 var draggables = _ref.draggables,
6156 reason = _ref.reason,
6157 lastImpact = _ref.lastImpact,
6158 home = _ref.home,
6159 viewport = _ref.viewport,
6160 onLiftImpact = _ref.onLiftImpact;
6161
6162 if (!lastImpact.at || reason !== 'DROP') {
6163 var recomputedHomeImpact = recompute({
6164 draggables: draggables,
6165 impact: onLiftImpact,
6166 destination: home,
6167 viewport: viewport,
6168 forceShouldAnimate: true
6169 });
6170 return {
6171 impact: recomputedHomeImpact,
6172 didDropInsideDroppable: false
6173 };
6174 }
6175
6176 if (lastImpact.at.type === 'REORDER') {
6177 return {
6178 impact: lastImpact,
6179 didDropInsideDroppable: true
6180 };
6181 }
6182
6183 var withoutMovement = _extends({}, lastImpact, {
6184 displaced: emptyGroups
6185 });
6186
6187 return {
6188 impact: withoutMovement,
6189 didDropInsideDroppable: true
6190 };
6191 });
6192
6193 var drop$1 = (function (_ref) {
6194 var getState = _ref.getState,
6195 dispatch = _ref.dispatch;
6196 return function (next) {
6197 return function (action) {
6198 if (action.type !== 'DROP') {
6199 next(action);
6200 return;
6201 }
6202
6203 var state = getState();
6204 var reason = action.payload.reason;
6205
6206 if (state.phase === 'COLLECTING') {
6207 dispatch(dropPending({
6208 reason: reason
6209 }));
6210 return;
6211 }
6212
6213 if (state.phase === 'IDLE') {
6214 return;
6215 }
6216
6217 var isWaitingForDrop = state.phase === 'DROP_PENDING' && state.isWaiting;
6218 !!isWaitingForDrop ? invariant(false, 'A DROP action occurred while DROP_PENDING and still waiting') : void 0;
6219 !(state.phase === 'DRAGGING' || state.phase === 'DROP_PENDING') ? invariant(false, "Cannot drop in phase: " + state.phase) : void 0;
6220 var critical = state.critical;
6221 var dimensions = state.dimensions;
6222 var draggable = dimensions.draggables[state.critical.draggable.id];
6223
6224 var _getDropImpact = getDropImpact({
6225 reason: reason,
6226 lastImpact: state.impact,
6227 afterCritical: state.afterCritical,
6228 onLiftImpact: state.onLiftImpact,
6229 home: state.dimensions.droppables[state.critical.droppable.id],
6230 viewport: state.viewport,
6231 draggables: state.dimensions.draggables
6232 }),
6233 impact = _getDropImpact.impact,
6234 didDropInsideDroppable = _getDropImpact.didDropInsideDroppable;
6235
6236 var destination = didDropInsideDroppable ? tryGetDestination(impact) : null;
6237 var combine = didDropInsideDroppable ? tryGetCombine(impact) : null;
6238 var source = {
6239 index: critical.draggable.index,
6240 droppableId: critical.droppable.id
6241 };
6242 var result = {
6243 draggableId: draggable.descriptor.id,
6244 type: draggable.descriptor.type,
6245 source: source,
6246 reason: reason,
6247 mode: state.movementMode,
6248 destination: destination,
6249 combine: combine
6250 };
6251 var newHomeClientOffset = getNewHomeClientOffset({
6252 impact: impact,
6253 draggable: draggable,
6254 dimensions: dimensions,
6255 viewport: state.viewport,
6256 afterCritical: state.afterCritical
6257 });
6258 var completed = {
6259 critical: state.critical,
6260 afterCritical: state.afterCritical,
6261 result: result,
6262 impact: impact
6263 };
6264 var isAnimationRequired = !isEqual(state.current.client.offset, newHomeClientOffset) || Boolean(result.combine);
6265
6266 if (!isAnimationRequired) {
6267 dispatch(completeDrop({
6268 completed: completed
6269 }));
6270 return;
6271 }
6272
6273 var dropDuration = getDropDuration({
6274 current: state.current.client.offset,
6275 destination: newHomeClientOffset,
6276 reason: reason
6277 });
6278 var args = {
6279 newHomeClientOffset: newHomeClientOffset,
6280 dropDuration: dropDuration,
6281 completed: completed
6282 };
6283 dispatch(animateDrop(args));
6284 };
6285 };
6286 });
6287
6288 var rafSchd = function rafSchd(fn) {
6289 var lastArgs = [];
6290 var frameId = null;
6291
6292 var wrapperFn = function wrapperFn() {
6293 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6294 args[_key] = arguments[_key];
6295 }
6296
6297 lastArgs = args;
6298
6299 if (frameId) {
6300 return;
6301 }
6302
6303 frameId = requestAnimationFrame(function () {
6304 frameId = null;
6305 fn.apply(void 0, lastArgs);
6306 });
6307 };
6308
6309 wrapperFn.cancel = function () {
6310 if (!frameId) {
6311 return;
6312 }
6313
6314 cancelAnimationFrame(frameId);
6315 frameId = null;
6316 };
6317
6318 return wrapperFn;
6319 };
6320
6321 var getWindowScroll$1 = (function () {
6322 return {
6323 x: window.pageXOffset,
6324 y: window.pageYOffset
6325 };
6326 });
6327
6328 function getWindowScrollBinding(update) {
6329 return {
6330 eventName: 'scroll',
6331 options: {
6332 passive: true,
6333 capture: false
6334 },
6335 fn: function fn(event) {
6336 if (event.target !== window && event.target !== window.document) {
6337 return;
6338 }
6339
6340 update();
6341 }
6342 };
6343 }
6344
6345 function getScrollListener(_ref) {
6346 var onWindowScroll = _ref.onWindowScroll;
6347
6348 function updateScroll() {
6349 onWindowScroll(getWindowScroll$1());
6350 }
6351
6352 var scheduled = rafSchd(updateScroll);
6353 var binding = getWindowScrollBinding(scheduled);
6354 var unbind = noop;
6355
6356 function isActive() {
6357 return unbind !== noop;
6358 }
6359
6360 function start() {
6361 !!isActive() ? invariant(false, 'Cannot start scroll listener when already active') : void 0;
6362 unbind = bindEvents(window, [binding]);
6363 }
6364
6365 function stop() {
6366 !isActive() ? invariant(false, 'Cannot stop scroll listener when not active') : void 0;
6367 scheduled.cancel();
6368 unbind();
6369 unbind = noop;
6370 }
6371
6372 return {
6373 start: start,
6374 stop: stop,
6375 isActive: isActive
6376 };
6377 }
6378
6379 var shouldEnd = function shouldEnd(action) {
6380 return action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATE' || action.type === 'FLUSH';
6381 };
6382
6383 var scrollListener = (function (store) {
6384 var listener = getScrollListener({
6385 onWindowScroll: function onWindowScroll(newScroll) {
6386 store.dispatch(moveByWindowScroll({
6387 newScroll: newScroll
6388 }));
6389 }
6390 });
6391 return function (next) {
6392 return function (action) {
6393 if (!listener.isActive() && action.type === 'INITIAL_PUBLISH') {
6394 listener.start();
6395 }
6396
6397 if (listener.isActive() && shouldEnd(action)) {
6398 listener.stop();
6399 }
6400
6401 next(action);
6402 };
6403 };
6404 });
6405
6406 var getExpiringAnnounce = (function (announce) {
6407 var wasCalled = false;
6408 var isExpired = false;
6409 var timeoutId = setTimeout(function () {
6410 isExpired = true;
6411 });
6412
6413 var result = function result(message) {
6414 if (wasCalled) {
6415 warning('Announcement already made. Not making a second announcement') ;
6416 return;
6417 }
6418
6419 if (isExpired) {
6420 warning("\n Announcements cannot be made asynchronously.\n Default message has already been announced.\n ") ;
6421 return;
6422 }
6423
6424 wasCalled = true;
6425 announce(message);
6426 clearTimeout(timeoutId);
6427 };
6428
6429 result.wasCalled = function () {
6430 return wasCalled;
6431 };
6432
6433 return result;
6434 });
6435
6436 var getAsyncMarshal = (function () {
6437 var entries = [];
6438
6439 var execute = function execute(timerId) {
6440 var index = findIndex(entries, function (item) {
6441 return item.timerId === timerId;
6442 });
6443 !(index !== -1) ? invariant(false, 'Could not find timer') : void 0;
6444
6445 var _entries$splice = entries.splice(index, 1),
6446 entry = _entries$splice[0];
6447
6448 entry.callback();
6449 };
6450
6451 var add = function add(fn) {
6452 var timerId = setTimeout(function () {
6453 return execute(timerId);
6454 });
6455 var entry = {
6456 timerId: timerId,
6457 callback: fn
6458 };
6459 entries.push(entry);
6460 };
6461
6462 var flush = function flush() {
6463 if (!entries.length) {
6464 return;
6465 }
6466
6467 var shallow = [].concat(entries);
6468 entries.length = 0;
6469 shallow.forEach(function (entry) {
6470 clearTimeout(entry.timerId);
6471 entry.callback();
6472 });
6473 };
6474
6475 return {
6476 add: add,
6477 flush: flush
6478 };
6479 });
6480
6481 var areLocationsEqual = function areLocationsEqual(first, second) {
6482 if (first == null && second == null) {
6483 return true;
6484 }
6485
6486 if (first == null || second == null) {
6487 return false;
6488 }
6489
6490 return first.droppableId === second.droppableId && first.index === second.index;
6491 };
6492 var isCombineEqual = function isCombineEqual(first, second) {
6493 if (first == null && second == null) {
6494 return true;
6495 }
6496
6497 if (first == null || second == null) {
6498 return false;
6499 }
6500
6501 return first.draggableId === second.draggableId && first.droppableId === second.droppableId;
6502 };
6503 var isCriticalEqual = function isCriticalEqual(first, second) {
6504 if (first === second) {
6505 return true;
6506 }
6507
6508 var isDraggableEqual = first.draggable.id === second.draggable.id && first.draggable.droppableId === second.draggable.droppableId && first.draggable.type === second.draggable.type && first.draggable.index === second.draggable.index;
6509 var isDroppableEqual = first.droppable.id === second.droppable.id && first.droppable.type === second.droppable.type;
6510 return isDraggableEqual && isDroppableEqual;
6511 };
6512
6513 var withTimings = function withTimings(key, fn) {
6514 fn();
6515 };
6516
6517 var getDragStart = function getDragStart(critical, mode) {
6518 return {
6519 draggableId: critical.draggable.id,
6520 type: critical.droppable.type,
6521 source: {
6522 droppableId: critical.droppable.id,
6523 index: critical.draggable.index
6524 },
6525 mode: mode
6526 };
6527 };
6528
6529 var execute = function execute(responder, data, announce, getDefaultMessage) {
6530 if (!responder) {
6531 announce(getDefaultMessage(data));
6532 return;
6533 }
6534
6535 var willExpire = getExpiringAnnounce(announce);
6536 var provided = {
6537 announce: willExpire
6538 };
6539 responder(data, provided);
6540
6541 if (!willExpire.wasCalled()) {
6542 announce(getDefaultMessage(data));
6543 }
6544 };
6545
6546 var getPublisher = (function (getResponders, announce) {
6547 var asyncMarshal = getAsyncMarshal();
6548 var dragging = null;
6549
6550 var beforeCapture = function beforeCapture(draggableId, mode) {
6551 !!dragging ? invariant(false, 'Cannot fire onBeforeCapture as a drag start has already been published') : void 0;
6552 withTimings('onBeforeCapture', function () {
6553 var fn = getResponders().onBeforeCapture;
6554
6555 if (fn) {
6556 var before = {
6557 draggableId: draggableId,
6558 mode: mode
6559 };
6560 fn(before);
6561 }
6562 });
6563 };
6564
6565 var beforeStart = function beforeStart(critical, mode) {
6566 !!dragging ? invariant(false, 'Cannot fire onBeforeDragStart as a drag start has already been published') : void 0;
6567 withTimings('onBeforeDragStart', function () {
6568 var fn = getResponders().onBeforeDragStart;
6569
6570 if (fn) {
6571 fn(getDragStart(critical, mode));
6572 }
6573 });
6574 };
6575
6576 var start = function start(critical, mode) {
6577 !!dragging ? invariant(false, 'Cannot fire onBeforeDragStart as a drag start has already been published') : void 0;
6578 var data = getDragStart(critical, mode);
6579 dragging = {
6580 mode: mode,
6581 lastCritical: critical,
6582 lastLocation: data.source,
6583 lastCombine: null
6584 };
6585 asyncMarshal.add(function () {
6586 withTimings('onDragStart', function () {
6587 return execute(getResponders().onDragStart, data, announce, preset.onDragStart);
6588 });
6589 });
6590 };
6591
6592 var update = function update(critical, impact) {
6593 var location = tryGetDestination(impact);
6594 var combine = tryGetCombine(impact);
6595 !dragging ? invariant(false, 'Cannot fire onDragMove when onDragStart has not been called') : void 0;
6596 var hasCriticalChanged = !isCriticalEqual(critical, dragging.lastCritical);
6597
6598 if (hasCriticalChanged) {
6599 dragging.lastCritical = critical;
6600 }
6601
6602 var hasLocationChanged = !areLocationsEqual(dragging.lastLocation, location);
6603
6604 if (hasLocationChanged) {
6605 dragging.lastLocation = location;
6606 }
6607
6608 var hasGroupingChanged = !isCombineEqual(dragging.lastCombine, combine);
6609
6610 if (hasGroupingChanged) {
6611 dragging.lastCombine = combine;
6612 }
6613
6614 if (!hasCriticalChanged && !hasLocationChanged && !hasGroupingChanged) {
6615 return;
6616 }
6617
6618 var data = _extends({}, getDragStart(critical, dragging.mode), {
6619 combine: combine,
6620 destination: location
6621 });
6622
6623 asyncMarshal.add(function () {
6624 withTimings('onDragUpdate', function () {
6625 return execute(getResponders().onDragUpdate, data, announce, preset.onDragUpdate);
6626 });
6627 });
6628 };
6629
6630 var flush = function flush() {
6631 !dragging ? invariant(false, 'Can only flush responders while dragging') : void 0;
6632 asyncMarshal.flush();
6633 };
6634
6635 var drop = function drop(result) {
6636 !dragging ? invariant(false, 'Cannot fire onDragEnd when there is no matching onDragStart') : void 0;
6637 dragging = null;
6638 withTimings('onDragEnd', function () {
6639 return execute(getResponders().onDragEnd, result, announce, preset.onDragEnd);
6640 });
6641 };
6642
6643 var abort = function abort() {
6644 if (!dragging) {
6645 return;
6646 }
6647
6648 var result = _extends({}, getDragStart(dragging.lastCritical, dragging.mode), {
6649 combine: null,
6650 destination: null,
6651 reason: 'CANCEL'
6652 });
6653
6654 drop(result);
6655 };
6656
6657 return {
6658 beforeCapture: beforeCapture,
6659 beforeStart: beforeStart,
6660 start: start,
6661 update: update,
6662 flush: flush,
6663 drop: drop,
6664 abort: abort
6665 };
6666 });
6667
6668 var responders = (function (getResponders, announce) {
6669 var publisher = getPublisher(getResponders, announce);
6670 return function (store) {
6671 return function (next) {
6672 return function (action) {
6673 if (action.type === 'BEFORE_INITIAL_CAPTURE') {
6674 publisher.beforeCapture(action.payload.draggableId, action.payload.movementMode);
6675 return;
6676 }
6677
6678 if (action.type === 'INITIAL_PUBLISH') {
6679 var critical = action.payload.critical;
6680 publisher.beforeStart(critical, action.payload.movementMode);
6681 next(action);
6682 publisher.start(critical, action.payload.movementMode);
6683 return;
6684 }
6685
6686 if (action.type === 'DROP_COMPLETE') {
6687 var result = action.payload.completed.result;
6688 publisher.flush();
6689 next(action);
6690 publisher.drop(result);
6691 return;
6692 }
6693
6694 next(action);
6695
6696 if (action.type === 'FLUSH') {
6697 publisher.abort();
6698 return;
6699 }
6700
6701 var state = store.getState();
6702
6703 if (state.phase === 'DRAGGING') {
6704 publisher.update(state.critical, state.impact);
6705 }
6706 };
6707 };
6708 };
6709 });
6710
6711 var dropAnimationFinish = (function (store) {
6712 return function (next) {
6713 return function (action) {
6714 if (action.type !== 'DROP_ANIMATION_FINISHED') {
6715 next(action);
6716 return;
6717 }
6718
6719 var state = store.getState();
6720 !(state.phase === 'DROP_ANIMATING') ? invariant(false, 'Cannot finish a drop animating when no drop is occurring') : void 0;
6721 store.dispatch(completeDrop({
6722 completed: state.completed
6723 }));
6724 };
6725 };
6726 });
6727
6728 var dropAnimationFlushOnScroll = (function (store) {
6729 var unbind = null;
6730 var frameId = null;
6731
6732 function clear() {
6733 if (frameId) {
6734 cancelAnimationFrame(frameId);
6735 frameId = null;
6736 }
6737
6738 if (unbind) {
6739 unbind();
6740 unbind = null;
6741 }
6742 }
6743
6744 return function (next) {
6745 return function (action) {
6746 if (action.type === 'FLUSH' || action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATION_FINISHED') {
6747 clear();
6748 }
6749
6750 next(action);
6751
6752 if (action.type !== 'DROP_ANIMATE') {
6753 return;
6754 }
6755
6756 var binding = {
6757 eventName: 'scroll',
6758 options: {
6759 capture: true,
6760 passive: false,
6761 once: true
6762 },
6763 fn: function flushDropAnimation() {
6764 var state = store.getState();
6765
6766 if (state.phase === 'DROP_ANIMATING') {
6767 store.dispatch(dropAnimationFinished());
6768 }
6769 }
6770 };
6771 frameId = requestAnimationFrame(function () {
6772 frameId = null;
6773 unbind = bindEvents(window, [binding]);
6774 });
6775 };
6776 };
6777 });
6778
6779 var dimensionMarshalStopper = (function (marshal) {
6780 return function () {
6781 return function (next) {
6782 return function (action) {
6783 if (action.type === 'DROP_COMPLETE' || action.type === 'FLUSH' || action.type === 'DROP_ANIMATE') {
6784 marshal.stopPublishing();
6785 }
6786
6787 next(action);
6788 };
6789 };
6790 };
6791 });
6792
6793 var focus = (function (marshal) {
6794 var isWatching = false;
6795 return function () {
6796 return function (next) {
6797 return function (action) {
6798 if (action.type === 'INITIAL_PUBLISH') {
6799 isWatching = true;
6800 marshal.tryRecordFocus(action.payload.critical.draggable.id);
6801 next(action);
6802 marshal.tryRestoreFocusRecorded();
6803 return;
6804 }
6805
6806 next(action);
6807
6808 if (!isWatching) {
6809 return;
6810 }
6811
6812 if (action.type === 'FLUSH') {
6813 isWatching = false;
6814 marshal.tryRestoreFocusRecorded();
6815 return;
6816 }
6817
6818 if (action.type === 'DROP_COMPLETE') {
6819 isWatching = false;
6820 var result = action.payload.completed.result;
6821
6822 if (result.combine) {
6823 marshal.tryShiftRecord(result.draggableId, result.combine.draggableId);
6824 }
6825
6826 marshal.tryRestoreFocusRecorded();
6827 }
6828 };
6829 };
6830 };
6831 });
6832
6833 var shouldStop = function shouldStop(action) {
6834 return action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATE' || action.type === 'FLUSH';
6835 };
6836
6837 var autoScroll = (function (autoScroller) {
6838 return function (store) {
6839 return function (next) {
6840 return function (action) {
6841 if (shouldStop(action)) {
6842 autoScroller.stop();
6843 next(action);
6844 return;
6845 }
6846
6847 if (action.type === 'INITIAL_PUBLISH') {
6848 next(action);
6849 var state = store.getState();
6850 !(state.phase === 'DRAGGING') ? invariant(false, 'Expected phase to be DRAGGING after INITIAL_PUBLISH') : void 0;
6851 autoScroller.start(state);
6852 return;
6853 }
6854
6855 next(action);
6856 autoScroller.scroll(store.getState());
6857 };
6858 };
6859 };
6860 });
6861
6862 var pendingDrop = (function (store) {
6863 return function (next) {
6864 return function (action) {
6865 next(action);
6866
6867 if (action.type !== 'PUBLISH_WHILE_DRAGGING') {
6868 return;
6869 }
6870
6871 var postActionState = store.getState();
6872
6873 if (postActionState.phase !== 'DROP_PENDING') {
6874 return;
6875 }
6876
6877 if (postActionState.isWaiting) {
6878 return;
6879 }
6880
6881 store.dispatch(drop({
6882 reason: postActionState.reason
6883 }));
6884 };
6885 };
6886 });
6887
6888 var composeEnhancers = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
6889 name: 'react-beautiful-dnd'
6890 }) : compose;
6891 var createStore$1 = (function (_ref) {
6892 var dimensionMarshal = _ref.dimensionMarshal,
6893 focusMarshal = _ref.focusMarshal,
6894 styleMarshal = _ref.styleMarshal,
6895 getResponders = _ref.getResponders,
6896 announce = _ref.announce,
6897 autoScroller = _ref.autoScroller;
6898 return createStore(reducer, composeEnhancers(applyMiddleware(style(styleMarshal), dimensionMarshalStopper(dimensionMarshal), lift$1(dimensionMarshal), drop$1, dropAnimationFinish, dropAnimationFlushOnScroll, pendingDrop, autoScroll(autoScroller), scrollListener, focus(focusMarshal), responders(getResponders, announce))));
6899 });
6900
6901 var clean$1 = function clean() {
6902 return {
6903 additions: {},
6904 removals: {},
6905 modified: {}
6906 };
6907 };
6908 function createPublisher(_ref) {
6909 var registry = _ref.registry,
6910 callbacks = _ref.callbacks;
6911 var staging = clean$1();
6912 var frameId = null;
6913
6914 var collect = function collect() {
6915 if (frameId) {
6916 return;
6917 }
6918
6919 callbacks.collectionStarting();
6920 frameId = requestAnimationFrame(function () {
6921 frameId = null;
6922 var _staging = staging,
6923 additions = _staging.additions,
6924 removals = _staging.removals,
6925 modified = _staging.modified;
6926 var added = Object.keys(additions).map(function (id) {
6927 return registry.draggable.getById(id).getDimension(origin);
6928 }).sort(function (a, b) {
6929 return a.descriptor.index - b.descriptor.index;
6930 });
6931 var updated = Object.keys(modified).map(function (id) {
6932 var entry = registry.droppable.getById(id);
6933 var scroll = entry.callbacks.getScrollWhileDragging();
6934 return {
6935 droppableId: id,
6936 scroll: scroll
6937 };
6938 });
6939 var result = {
6940 additions: added,
6941 removals: Object.keys(removals),
6942 modified: updated
6943 };
6944 staging = clean$1();
6945 callbacks.publish(result);
6946 });
6947 };
6948
6949 var add = function add(entry) {
6950 var id = entry.descriptor.id;
6951 staging.additions[id] = entry;
6952 staging.modified[entry.descriptor.droppableId] = true;
6953
6954 if (staging.removals[id]) {
6955 delete staging.removals[id];
6956 }
6957
6958 collect();
6959 };
6960
6961 var remove = function remove(entry) {
6962 var descriptor = entry.descriptor;
6963 staging.removals[descriptor.id] = true;
6964 staging.modified[descriptor.droppableId] = true;
6965
6966 if (staging.additions[descriptor.id]) {
6967 delete staging.additions[descriptor.id];
6968 }
6969
6970 collect();
6971 };
6972
6973 var stop = function stop() {
6974 if (!frameId) {
6975 return;
6976 }
6977
6978 cancelAnimationFrame(frameId);
6979 frameId = null;
6980 staging = clean$1();
6981 };
6982
6983 return {
6984 add: add,
6985 remove: remove,
6986 stop: stop
6987 };
6988 }
6989
6990 var getMaxScroll = (function (_ref) {
6991 var scrollHeight = _ref.scrollHeight,
6992 scrollWidth = _ref.scrollWidth,
6993 height = _ref.height,
6994 width = _ref.width;
6995 var maxScroll = subtract({
6996 x: scrollWidth,
6997 y: scrollHeight
6998 }, {
6999 x: width,
7000 y: height
7001 });
7002 var adjustedMaxScroll = {
7003 x: Math.max(0, maxScroll.x),
7004 y: Math.max(0, maxScroll.y)
7005 };
7006 return adjustedMaxScroll;
7007 });
7008
7009 var getDocumentElement = (function () {
7010 var doc = document.documentElement;
7011 !doc ? invariant(false, 'Cannot find document.documentElement') : void 0;
7012 return doc;
7013 });
7014
7015 var getMaxWindowScroll = (function () {
7016 var doc = getDocumentElement();
7017 var maxScroll = getMaxScroll({
7018 scrollHeight: doc.scrollHeight,
7019 scrollWidth: doc.scrollWidth,
7020 width: doc.clientWidth,
7021 height: doc.clientHeight
7022 });
7023 return maxScroll;
7024 });
7025
7026 var getViewport = (function () {
7027 var scroll = getWindowScroll$1();
7028 var maxScroll = getMaxWindowScroll();
7029 var top = scroll.y;
7030 var left = scroll.x;
7031 var doc = getDocumentElement();
7032 var width = doc.clientWidth;
7033 var height = doc.clientHeight;
7034 var right = left + width;
7035 var bottom = top + height;
7036 var frame = getRect({
7037 top: top,
7038 left: left,
7039 right: right,
7040 bottom: bottom
7041 });
7042 var viewport = {
7043 frame: frame,
7044 scroll: {
7045 initial: scroll,
7046 current: scroll,
7047 max: maxScroll,
7048 diff: {
7049 value: origin,
7050 displacement: origin
7051 }
7052 }
7053 };
7054 return viewport;
7055 });
7056
7057 var getInitialPublish = (function (_ref) {
7058 var critical = _ref.critical,
7059 scrollOptions = _ref.scrollOptions,
7060 registry = _ref.registry;
7061 var viewport = getViewport();
7062 var windowScroll = viewport.scroll.current;
7063 var home = critical.droppable;
7064 var droppables = registry.droppable.getAllByType(home.type).map(function (entry) {
7065 return entry.callbacks.getDimensionAndWatchScroll(windowScroll, scrollOptions);
7066 });
7067 var draggables = registry.draggable.getAllByType(critical.draggable.type).map(function (entry) {
7068 return entry.getDimension(windowScroll);
7069 });
7070 var dimensions = {
7071 draggables: toDraggableMap(draggables),
7072 droppables: toDroppableMap(droppables)
7073 };
7074 var result = {
7075 dimensions: dimensions,
7076 critical: critical,
7077 viewport: viewport
7078 };
7079 return result;
7080 });
7081
7082 function shouldPublishUpdate(registry, dragging, entry) {
7083 if (entry.descriptor.id === dragging.id) {
7084 return false;
7085 }
7086
7087 if (entry.descriptor.type !== dragging.type) {
7088 return false;
7089 }
7090
7091 var home = registry.droppable.getById(entry.descriptor.droppableId);
7092
7093 if (home.descriptor.mode !== 'virtual') {
7094 warning("\n You are attempting to add or remove a Draggable [id: " + entry.descriptor.id + "]\n while a drag is occurring. This is only supported for virtual lists.\n\n See https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/patterns/virtual-lists.md\n ") ;
7095 return false;
7096 }
7097
7098 return true;
7099 }
7100
7101 var createDimensionMarshal = (function (registry, callbacks) {
7102 var collection = null;
7103 var publisher = createPublisher({
7104 callbacks: {
7105 publish: callbacks.publishWhileDragging,
7106 collectionStarting: callbacks.collectionStarting
7107 },
7108 registry: registry
7109 });
7110
7111 var updateDroppableIsEnabled = function updateDroppableIsEnabled(id, isEnabled) {
7112 !registry.droppable.exists(id) ? invariant(false, "Cannot update is enabled flag of Droppable " + id + " as it is not registered") : void 0;
7113
7114 if (!collection) {
7115 return;
7116 }
7117
7118 callbacks.updateDroppableIsEnabled({
7119 id: id,
7120 isEnabled: isEnabled
7121 });
7122 };
7123
7124 var updateDroppableIsCombineEnabled = function updateDroppableIsCombineEnabled(id, isCombineEnabled) {
7125 if (!collection) {
7126 return;
7127 }
7128
7129 !registry.droppable.exists(id) ? invariant(false, "Cannot update isCombineEnabled flag of Droppable " + id + " as it is not registered") : void 0;
7130 callbacks.updateDroppableIsCombineEnabled({
7131 id: id,
7132 isCombineEnabled: isCombineEnabled
7133 });
7134 };
7135
7136 var updateDroppableScroll = function updateDroppableScroll(id, newScroll) {
7137 if (!collection) {
7138 return;
7139 }
7140
7141 !registry.droppable.exists(id) ? invariant(false, "Cannot update the scroll on Droppable " + id + " as it is not registered") : void 0;
7142 callbacks.updateDroppableScroll({
7143 id: id,
7144 newScroll: newScroll
7145 });
7146 };
7147
7148 var scrollDroppable = function scrollDroppable(id, change) {
7149 if (!collection) {
7150 return;
7151 }
7152
7153 registry.droppable.getById(id).callbacks.scroll(change);
7154 };
7155
7156 var stopPublishing = function stopPublishing() {
7157 if (!collection) {
7158 return;
7159 }
7160
7161 publisher.stop();
7162 var home = collection.critical.droppable;
7163 registry.droppable.getAllByType(home.type).forEach(function (entry) {
7164 return entry.callbacks.dragStopped();
7165 });
7166 collection.unsubscribe();
7167 collection = null;
7168 };
7169
7170 var subscriber = function subscriber(event) {
7171 !collection ? invariant(false, 'Should only be subscribed when a collection is occurring') : void 0;
7172 var dragging = collection.critical.draggable;
7173
7174 if (event.type === 'ADDITION') {
7175 if (shouldPublishUpdate(registry, dragging, event.value)) {
7176 publisher.add(event.value);
7177 }
7178 }
7179
7180 if (event.type === 'REMOVAL') {
7181 if (shouldPublishUpdate(registry, dragging, event.value)) {
7182 publisher.remove(event.value);
7183 }
7184 }
7185 };
7186
7187 var startPublishing = function startPublishing(request) {
7188 !!collection ? invariant(false, 'Cannot start capturing critical dimensions as there is already a collection') : void 0;
7189 var entry = registry.draggable.getById(request.draggableId);
7190 var home = registry.droppable.getById(entry.descriptor.droppableId);
7191 var critical = {
7192 draggable: entry.descriptor,
7193 droppable: home.descriptor
7194 };
7195 var unsubscribe = registry.subscribe(subscriber);
7196 collection = {
7197 critical: critical,
7198 unsubscribe: unsubscribe
7199 };
7200 return getInitialPublish({
7201 critical: critical,
7202 registry: registry,
7203 scrollOptions: request.scrollOptions
7204 });
7205 };
7206
7207 var marshal = {
7208 updateDroppableIsEnabled: updateDroppableIsEnabled,
7209 updateDroppableIsCombineEnabled: updateDroppableIsCombineEnabled,
7210 scrollDroppable: scrollDroppable,
7211 updateDroppableScroll: updateDroppableScroll,
7212 startPublishing: startPublishing,
7213 stopPublishing: stopPublishing
7214 };
7215 return marshal;
7216 });
7217
7218 var canStartDrag = (function (state, id) {
7219 if (state.phase === 'IDLE') {
7220 return true;
7221 }
7222
7223 if (state.phase !== 'DROP_ANIMATING') {
7224 return false;
7225 }
7226
7227 if (state.completed.result.draggableId === id) {
7228 return false;
7229 }
7230
7231 return state.completed.result.reason === 'DROP';
7232 });
7233
7234 var scrollWindow = (function (change) {
7235 window.scrollBy(change.x, change.y);
7236 });
7237
7238 var getScrollableDroppables = memoizeOne(function (droppables) {
7239 return toDroppableList(droppables).filter(function (droppable) {
7240 if (!droppable.isEnabled) {
7241 return false;
7242 }
7243
7244 if (!droppable.frame) {
7245 return false;
7246 }
7247
7248 return true;
7249 });
7250 });
7251
7252 var getScrollableDroppableOver = function getScrollableDroppableOver(target, droppables) {
7253 var maybe = find(getScrollableDroppables(droppables), function (droppable) {
7254 !droppable.frame ? invariant(false, 'Invalid result') : void 0;
7255 return isPositionInFrame(droppable.frame.pageMarginBox)(target);
7256 });
7257 return maybe;
7258 };
7259
7260 var getBestScrollableDroppable = (function (_ref) {
7261 var center = _ref.center,
7262 destination = _ref.destination,
7263 droppables = _ref.droppables;
7264
7265 if (destination) {
7266 var _dimension = droppables[destination];
7267
7268 if (!_dimension.frame) {
7269 return null;
7270 }
7271
7272 return _dimension;
7273 }
7274
7275 var dimension = getScrollableDroppableOver(center, droppables);
7276 return dimension;
7277 });
7278
7279 var config = {
7280 startFromPercentage: 0.25,
7281 maxScrollAtPercentage: 0.05,
7282 maxPixelScroll: 28,
7283 ease: function ease(percentage) {
7284 return Math.pow(percentage, 2);
7285 },
7286 durationDampening: {
7287 stopDampeningAt: 1200,
7288 accelerateAt: 360
7289 }
7290 };
7291
7292 var getDistanceThresholds = (function (container, axis) {
7293 var startScrollingFrom = container[axis.size] * config.startFromPercentage;
7294 var maxScrollValueAt = container[axis.size] * config.maxScrollAtPercentage;
7295 var thresholds = {
7296 startScrollingFrom: startScrollingFrom,
7297 maxScrollValueAt: maxScrollValueAt
7298 };
7299 return thresholds;
7300 });
7301
7302 var getPercentage = (function (_ref) {
7303 var startOfRange = _ref.startOfRange,
7304 endOfRange = _ref.endOfRange,
7305 current = _ref.current;
7306 var range = endOfRange - startOfRange;
7307
7308 if (range === 0) {
7309 warning("\n Detected distance range of 0 in the fluid auto scroller\n This is unexpected and would cause a divide by 0 issue.\n Not allowing an auto scroll\n ") ;
7310 return 0;
7311 }
7312
7313 var currentInRange = current - startOfRange;
7314 var percentage = currentInRange / range;
7315 return percentage;
7316 });
7317
7318 var minScroll = 1;
7319
7320 var getValueFromDistance = (function (distanceToEdge, thresholds) {
7321 if (distanceToEdge > thresholds.startScrollingFrom) {
7322 return 0;
7323 }
7324
7325 if (distanceToEdge <= thresholds.maxScrollValueAt) {
7326 return config.maxPixelScroll;
7327 }
7328
7329 if (distanceToEdge === thresholds.startScrollingFrom) {
7330 return minScroll;
7331 }
7332
7333 var percentageFromMaxScrollValueAt = getPercentage({
7334 startOfRange: thresholds.maxScrollValueAt,
7335 endOfRange: thresholds.startScrollingFrom,
7336 current: distanceToEdge
7337 });
7338 var percentageFromStartScrollingFrom = 1 - percentageFromMaxScrollValueAt;
7339 var scroll = config.maxPixelScroll * config.ease(percentageFromStartScrollingFrom);
7340 return Math.ceil(scroll);
7341 });
7342
7343 var accelerateAt = config.durationDampening.accelerateAt;
7344 var stopAt = config.durationDampening.stopDampeningAt;
7345 var dampenValueByTime = (function (proposedScroll, dragStartTime) {
7346 var startOfRange = dragStartTime;
7347 var endOfRange = stopAt;
7348 var now = Date.now();
7349 var runTime = now - startOfRange;
7350
7351 if (runTime >= stopAt) {
7352 return proposedScroll;
7353 }
7354
7355 if (runTime < accelerateAt) {
7356 return minScroll;
7357 }
7358
7359 var betweenAccelerateAtAndStopAtPercentage = getPercentage({
7360 startOfRange: accelerateAt,
7361 endOfRange: endOfRange,
7362 current: runTime
7363 });
7364 var scroll = proposedScroll * config.ease(betweenAccelerateAtAndStopAtPercentage);
7365 return Math.ceil(scroll);
7366 });
7367
7368 var getValue = (function (_ref) {
7369 var distanceToEdge = _ref.distanceToEdge,
7370 thresholds = _ref.thresholds,
7371 dragStartTime = _ref.dragStartTime,
7372 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
7373 var scroll = getValueFromDistance(distanceToEdge, thresholds);
7374
7375 if (scroll === 0) {
7376 return 0;
7377 }
7378
7379 if (!shouldUseTimeDampening) {
7380 return scroll;
7381 }
7382
7383 return Math.max(dampenValueByTime(scroll, dragStartTime), minScroll);
7384 });
7385
7386 var getScrollOnAxis = (function (_ref) {
7387 var container = _ref.container,
7388 distanceToEdges = _ref.distanceToEdges,
7389 dragStartTime = _ref.dragStartTime,
7390 axis = _ref.axis,
7391 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
7392 var thresholds = getDistanceThresholds(container, axis);
7393 var isCloserToEnd = distanceToEdges[axis.end] < distanceToEdges[axis.start];
7394
7395 if (isCloserToEnd) {
7396 return getValue({
7397 distanceToEdge: distanceToEdges[axis.end],
7398 thresholds: thresholds,
7399 dragStartTime: dragStartTime,
7400 shouldUseTimeDampening: shouldUseTimeDampening
7401 });
7402 }
7403
7404 return -1 * getValue({
7405 distanceToEdge: distanceToEdges[axis.start],
7406 thresholds: thresholds,
7407 dragStartTime: dragStartTime,
7408 shouldUseTimeDampening: shouldUseTimeDampening
7409 });
7410 });
7411
7412 var adjustForSizeLimits = (function (_ref) {
7413 var container = _ref.container,
7414 subject = _ref.subject,
7415 proposedScroll = _ref.proposedScroll;
7416 var isTooBigVertically = subject.height > container.height;
7417 var isTooBigHorizontally = subject.width > container.width;
7418
7419 if (!isTooBigHorizontally && !isTooBigVertically) {
7420 return proposedScroll;
7421 }
7422
7423 if (isTooBigHorizontally && isTooBigVertically) {
7424 return null;
7425 }
7426
7427 return {
7428 x: isTooBigHorizontally ? 0 : proposedScroll.x,
7429 y: isTooBigVertically ? 0 : proposedScroll.y
7430 };
7431 });
7432
7433 var clean$2 = apply(function (value) {
7434 return value === 0 ? 0 : value;
7435 });
7436 var getScroll = (function (_ref) {
7437 var dragStartTime = _ref.dragStartTime,
7438 container = _ref.container,
7439 subject = _ref.subject,
7440 center = _ref.center,
7441 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
7442 var distanceToEdges = {
7443 top: center.y - container.top,
7444 right: container.right - center.x,
7445 bottom: container.bottom - center.y,
7446 left: center.x - container.left
7447 };
7448 var y = getScrollOnAxis({
7449 container: container,
7450 distanceToEdges: distanceToEdges,
7451 dragStartTime: dragStartTime,
7452 axis: vertical,
7453 shouldUseTimeDampening: shouldUseTimeDampening
7454 });
7455 var x = getScrollOnAxis({
7456 container: container,
7457 distanceToEdges: distanceToEdges,
7458 dragStartTime: dragStartTime,
7459 axis: horizontal,
7460 shouldUseTimeDampening: shouldUseTimeDampening
7461 });
7462 var required = clean$2({
7463 x: x,
7464 y: y
7465 });
7466
7467 if (isEqual(required, origin)) {
7468 return null;
7469 }
7470
7471 var limited = adjustForSizeLimits({
7472 container: container,
7473 subject: subject,
7474 proposedScroll: required
7475 });
7476
7477 if (!limited) {
7478 return null;
7479 }
7480
7481 return isEqual(limited, origin) ? null : limited;
7482 });
7483
7484 var smallestSigned = apply(function (value) {
7485 if (value === 0) {
7486 return 0;
7487 }
7488
7489 return value > 0 ? 1 : -1;
7490 });
7491 var getOverlap = function () {
7492 var getRemainder = function getRemainder(target, max) {
7493 if (target < 0) {
7494 return target;
7495 }
7496
7497 if (target > max) {
7498 return target - max;
7499 }
7500
7501 return 0;
7502 };
7503
7504 return function (_ref) {
7505 var current = _ref.current,
7506 max = _ref.max,
7507 change = _ref.change;
7508 var targetScroll = add(current, change);
7509 var overlap = {
7510 x: getRemainder(targetScroll.x, max.x),
7511 y: getRemainder(targetScroll.y, max.y)
7512 };
7513
7514 if (isEqual(overlap, origin)) {
7515 return null;
7516 }
7517
7518 return overlap;
7519 };
7520 }();
7521 var canPartiallyScroll = function canPartiallyScroll(_ref2) {
7522 var rawMax = _ref2.max,
7523 current = _ref2.current,
7524 change = _ref2.change;
7525 var max = {
7526 x: Math.max(current.x, rawMax.x),
7527 y: Math.max(current.y, rawMax.y)
7528 };
7529 var smallestChange = smallestSigned(change);
7530 var overlap = getOverlap({
7531 max: max,
7532 current: current,
7533 change: smallestChange
7534 });
7535
7536 if (!overlap) {
7537 return true;
7538 }
7539
7540 if (smallestChange.x !== 0 && overlap.x === 0) {
7541 return true;
7542 }
7543
7544 if (smallestChange.y !== 0 && overlap.y === 0) {
7545 return true;
7546 }
7547
7548 return false;
7549 };
7550 var canScrollWindow = function canScrollWindow(viewport, change) {
7551 return canPartiallyScroll({
7552 current: viewport.scroll.current,
7553 max: viewport.scroll.max,
7554 change: change
7555 });
7556 };
7557 var getWindowOverlap = function getWindowOverlap(viewport, change) {
7558 if (!canScrollWindow(viewport, change)) {
7559 return null;
7560 }
7561
7562 var max = viewport.scroll.max;
7563 var current = viewport.scroll.current;
7564 return getOverlap({
7565 current: current,
7566 max: max,
7567 change: change
7568 });
7569 };
7570 var canScrollDroppable = function canScrollDroppable(droppable, change) {
7571 var frame = droppable.frame;
7572
7573 if (!frame) {
7574 return false;
7575 }
7576
7577 return canPartiallyScroll({
7578 current: frame.scroll.current,
7579 max: frame.scroll.max,
7580 change: change
7581 });
7582 };
7583 var getDroppableOverlap = function getDroppableOverlap(droppable, change) {
7584 var frame = droppable.frame;
7585
7586 if (!frame) {
7587 return null;
7588 }
7589
7590 if (!canScrollDroppable(droppable, change)) {
7591 return null;
7592 }
7593
7594 return getOverlap({
7595 current: frame.scroll.current,
7596 max: frame.scroll.max,
7597 change: change
7598 });
7599 };
7600
7601 var getWindowScrollChange = (function (_ref) {
7602 var viewport = _ref.viewport,
7603 subject = _ref.subject,
7604 center = _ref.center,
7605 dragStartTime = _ref.dragStartTime,
7606 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
7607 var scroll = getScroll({
7608 dragStartTime: dragStartTime,
7609 container: viewport.frame,
7610 subject: subject,
7611 center: center,
7612 shouldUseTimeDampening: shouldUseTimeDampening
7613 });
7614 return scroll && canScrollWindow(viewport, scroll) ? scroll : null;
7615 });
7616
7617 var getDroppableScrollChange = (function (_ref) {
7618 var droppable = _ref.droppable,
7619 subject = _ref.subject,
7620 center = _ref.center,
7621 dragStartTime = _ref.dragStartTime,
7622 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
7623 var frame = droppable.frame;
7624
7625 if (!frame) {
7626 return null;
7627 }
7628
7629 var scroll = getScroll({
7630 dragStartTime: dragStartTime,
7631 container: frame.pageMarginBox,
7632 subject: subject,
7633 center: center,
7634 shouldUseTimeDampening: shouldUseTimeDampening
7635 });
7636 return scroll && canScrollDroppable(droppable, scroll) ? scroll : null;
7637 });
7638
7639 var scroll$1 = (function (_ref) {
7640 var state = _ref.state,
7641 dragStartTime = _ref.dragStartTime,
7642 shouldUseTimeDampening = _ref.shouldUseTimeDampening,
7643 scrollWindow = _ref.scrollWindow,
7644 scrollDroppable = _ref.scrollDroppable;
7645 var center = state.current.page.borderBoxCenter;
7646 var draggable = state.dimensions.draggables[state.critical.draggable.id];
7647 var subject = draggable.page.marginBox;
7648
7649 if (state.isWindowScrollAllowed) {
7650 var viewport = state.viewport;
7651
7652 var _change = getWindowScrollChange({
7653 dragStartTime: dragStartTime,
7654 viewport: viewport,
7655 subject: subject,
7656 center: center,
7657 shouldUseTimeDampening: shouldUseTimeDampening
7658 });
7659
7660 if (_change) {
7661 scrollWindow(_change);
7662 return;
7663 }
7664 }
7665
7666 var droppable = getBestScrollableDroppable({
7667 center: center,
7668 destination: whatIsDraggedOver(state.impact),
7669 droppables: state.dimensions.droppables
7670 });
7671
7672 if (!droppable) {
7673 return;
7674 }
7675
7676 var change = getDroppableScrollChange({
7677 dragStartTime: dragStartTime,
7678 droppable: droppable,
7679 subject: subject,
7680 center: center,
7681 shouldUseTimeDampening: shouldUseTimeDampening
7682 });
7683
7684 if (change) {
7685 scrollDroppable(droppable.descriptor.id, change);
7686 }
7687 });
7688
7689 var createFluidScroller = (function (_ref) {
7690 var scrollWindow = _ref.scrollWindow,
7691 scrollDroppable = _ref.scrollDroppable;
7692 var scheduleWindowScroll = rafSchd(scrollWindow);
7693 var scheduleDroppableScroll = rafSchd(scrollDroppable);
7694 var dragging = null;
7695
7696 var tryScroll = function tryScroll(state) {
7697 !dragging ? invariant(false, 'Cannot fluid scroll if not dragging') : void 0;
7698 var _dragging = dragging,
7699 shouldUseTimeDampening = _dragging.shouldUseTimeDampening,
7700 dragStartTime = _dragging.dragStartTime;
7701 scroll$1({
7702 state: state,
7703 scrollWindow: scheduleWindowScroll,
7704 scrollDroppable: scheduleDroppableScroll,
7705 dragStartTime: dragStartTime,
7706 shouldUseTimeDampening: shouldUseTimeDampening
7707 });
7708 };
7709
7710 var start = function start(state) {
7711 !!dragging ? invariant(false, 'Cannot start auto scrolling when already started') : void 0;
7712 var dragStartTime = Date.now();
7713 var wasScrollNeeded = false;
7714
7715 var fakeScrollCallback = function fakeScrollCallback() {
7716 wasScrollNeeded = true;
7717 };
7718
7719 scroll$1({
7720 state: state,
7721 dragStartTime: 0,
7722 shouldUseTimeDampening: false,
7723 scrollWindow: fakeScrollCallback,
7724 scrollDroppable: fakeScrollCallback
7725 });
7726 dragging = {
7727 dragStartTime: dragStartTime,
7728 shouldUseTimeDampening: wasScrollNeeded
7729 };
7730
7731 if (wasScrollNeeded) {
7732 tryScroll(state);
7733 }
7734 };
7735
7736 var stop = function stop() {
7737 if (!dragging) {
7738 return;
7739 }
7740
7741 scheduleWindowScroll.cancel();
7742 scheduleDroppableScroll.cancel();
7743 dragging = null;
7744 };
7745
7746 return {
7747 start: start,
7748 stop: stop,
7749 scroll: tryScroll
7750 };
7751 });
7752
7753 var createJumpScroller = (function (_ref) {
7754 var move = _ref.move,
7755 scrollDroppable = _ref.scrollDroppable,
7756 scrollWindow = _ref.scrollWindow;
7757
7758 var moveByOffset = function moveByOffset(state, offset) {
7759 var client = add(state.current.client.selection, offset);
7760 move({
7761 client: client
7762 });
7763 };
7764
7765 var scrollDroppableAsMuchAsItCan = function scrollDroppableAsMuchAsItCan(droppable, change) {
7766 if (!canScrollDroppable(droppable, change)) {
7767 return change;
7768 }
7769
7770 var overlap = getDroppableOverlap(droppable, change);
7771
7772 if (!overlap) {
7773 scrollDroppable(droppable.descriptor.id, change);
7774 return null;
7775 }
7776
7777 var whatTheDroppableCanScroll = subtract(change, overlap);
7778 scrollDroppable(droppable.descriptor.id, whatTheDroppableCanScroll);
7779 var remainder = subtract(change, whatTheDroppableCanScroll);
7780 return remainder;
7781 };
7782
7783 var scrollWindowAsMuchAsItCan = function scrollWindowAsMuchAsItCan(isWindowScrollAllowed, viewport, change) {
7784 if (!isWindowScrollAllowed) {
7785 return change;
7786 }
7787
7788 if (!canScrollWindow(viewport, change)) {
7789 return change;
7790 }
7791
7792 var overlap = getWindowOverlap(viewport, change);
7793
7794 if (!overlap) {
7795 scrollWindow(change);
7796 return null;
7797 }
7798
7799 var whatTheWindowCanScroll = subtract(change, overlap);
7800 scrollWindow(whatTheWindowCanScroll);
7801 var remainder = subtract(change, whatTheWindowCanScroll);
7802 return remainder;
7803 };
7804
7805 var jumpScroller = function jumpScroller(state) {
7806 var request = state.scrollJumpRequest;
7807
7808 if (!request) {
7809 return;
7810 }
7811
7812 var destination = whatIsDraggedOver(state.impact);
7813 !destination ? invariant(false, 'Cannot perform a jump scroll when there is no destination') : void 0;
7814 var droppableRemainder = scrollDroppableAsMuchAsItCan(state.dimensions.droppables[destination], request);
7815
7816 if (!droppableRemainder) {
7817 return;
7818 }
7819
7820 var viewport = state.viewport;
7821 var windowRemainder = scrollWindowAsMuchAsItCan(state.isWindowScrollAllowed, viewport, droppableRemainder);
7822
7823 if (!windowRemainder) {
7824 return;
7825 }
7826
7827 moveByOffset(state, windowRemainder);
7828 };
7829
7830 return jumpScroller;
7831 });
7832
7833 var createAutoScroller = (function (_ref) {
7834 var scrollDroppable = _ref.scrollDroppable,
7835 scrollWindow = _ref.scrollWindow,
7836 move = _ref.move;
7837 var fluidScroller = createFluidScroller({
7838 scrollWindow: scrollWindow,
7839 scrollDroppable: scrollDroppable
7840 });
7841 var jumpScroll = createJumpScroller({
7842 move: move,
7843 scrollWindow: scrollWindow,
7844 scrollDroppable: scrollDroppable
7845 });
7846
7847 var scroll = function scroll(state) {
7848 if (state.phase !== 'DRAGGING') {
7849 return;
7850 }
7851
7852 if (state.movementMode === 'FLUID') {
7853 fluidScroller.scroll(state);
7854 return;
7855 }
7856
7857 if (!state.scrollJumpRequest) {
7858 return;
7859 }
7860
7861 jumpScroll(state);
7862 };
7863
7864 var scroller = {
7865 scroll: scroll,
7866 start: fluidScroller.start,
7867 stop: fluidScroller.stop
7868 };
7869 return scroller;
7870 });
7871
7872 var prefix$2 = 'data-rbd';
7873 var dragHandle = function () {
7874 var base = prefix$2 + "-drag-handle";
7875 return {
7876 base: base,
7877 draggableId: base + "-draggable-id",
7878 contextId: base + "-context-id"
7879 };
7880 }();
7881 var draggable = function () {
7882 var base = prefix$2 + "-draggable";
7883 return {
7884 base: base,
7885 contextId: base + "-context-id",
7886 id: base + "-id"
7887 };
7888 }();
7889 var droppable = function () {
7890 var base = prefix$2 + "-droppable";
7891 return {
7892 base: base,
7893 contextId: base + "-context-id",
7894 id: base + "-id"
7895 };
7896 }();
7897 var scrollContainer = {
7898 contextId: prefix$2 + "-scroll-container-context-id"
7899 };
7900
7901 var makeGetSelector = function makeGetSelector(context) {
7902 return function (attribute) {
7903 return "[" + attribute + "=\"" + context + "\"]";
7904 };
7905 };
7906
7907 var getStyles = function getStyles(rules, property) {
7908 return rules.map(function (rule) {
7909 var value = rule.styles[property];
7910
7911 if (!value) {
7912 return '';
7913 }
7914
7915 return rule.selector + " { " + value + " }";
7916 }).join(' ');
7917 };
7918
7919 var noPointerEvents = 'pointer-events: none;';
7920 var getStyles$1 = (function (contextId) {
7921 var getSelector = makeGetSelector(contextId);
7922
7923 var dragHandle$1 = function () {
7924 var grabCursor = "\n cursor: -webkit-grab;\n cursor: grab;\n ";
7925 return {
7926 selector: getSelector(dragHandle.contextId),
7927 styles: {
7928 always: "\n -webkit-touch-callout: none;\n -webkit-tap-highlight-color: rgba(0,0,0,0);\n touch-action: manipulation;\n ",
7929 resting: grabCursor,
7930 dragging: noPointerEvents,
7931 dropAnimating: grabCursor
7932 }
7933 };
7934 }();
7935
7936 var draggable$1 = function () {
7937 var transition = "\n transition: " + transitions.outOfTheWay + ";\n ";
7938 return {
7939 selector: getSelector(draggable.contextId),
7940 styles: {
7941 dragging: transition,
7942 dropAnimating: transition,
7943 userCancel: transition
7944 }
7945 };
7946 }();
7947
7948 var droppable$1 = {
7949 selector: getSelector(droppable.contextId),
7950 styles: {
7951 always: "overflow-anchor: none;"
7952 }
7953 };
7954 var body = {
7955 selector: 'body',
7956 styles: {
7957 dragging: "\n cursor: grabbing;\n cursor: -webkit-grabbing;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n overflow-anchor: none;\n "
7958 }
7959 };
7960 var rules = [draggable$1, dragHandle$1, droppable$1, body];
7961 return {
7962 always: getStyles(rules, 'always'),
7963 resting: getStyles(rules, 'resting'),
7964 dragging: getStyles(rules, 'dragging'),
7965 dropAnimating: getStyles(rules, 'dropAnimating'),
7966 userCancel: getStyles(rules, 'userCancel')
7967 };
7968 });
7969
7970 var useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect;
7971
7972 var getHead = function getHead() {
7973 var head = document.querySelector('head');
7974 !head ? invariant(false, 'Cannot find the head to append a style to') : void 0;
7975 return head;
7976 };
7977
7978 var createStyleEl = function createStyleEl(nonce) {
7979 var el = document.createElement('style');
7980
7981 if (nonce) {
7982 el.setAttribute('nonce', nonce);
7983 }
7984
7985 el.type = 'text/css';
7986 return el;
7987 };
7988
7989 function useStyleMarshal(contextId, nonce) {
7990 var styles = useMemo(function () {
7991 return getStyles$1(contextId);
7992 }, [contextId]);
7993 var alwaysRef = React.useRef(null);
7994 var dynamicRef = React.useRef(null);
7995 var setDynamicStyle = useCallback(memoizeOne(function (proposed) {
7996 var el = dynamicRef.current;
7997 !el ? invariant(false, 'Cannot set dynamic style element if it is not set') : void 0;
7998 el.textContent = proposed;
7999 }), []);
8000 var setAlwaysStyle = useCallback(function (proposed) {
8001 var el = alwaysRef.current;
8002 !el ? invariant(false, 'Cannot set dynamic style element if it is not set') : void 0;
8003 el.textContent = proposed;
8004 }, []);
8005 useIsomorphicLayoutEffect$1(function () {
8006 !(!alwaysRef.current && !dynamicRef.current) ? invariant(false, 'style elements already mounted') : void 0;
8007 var always = createStyleEl(nonce);
8008 var dynamic = createStyleEl(nonce);
8009 alwaysRef.current = always;
8010 dynamicRef.current = dynamic;
8011 always.setAttribute(prefix$2 + "-always", contextId);
8012 dynamic.setAttribute(prefix$2 + "-dynamic", contextId);
8013 getHead().appendChild(always);
8014 getHead().appendChild(dynamic);
8015 setAlwaysStyle(styles.always);
8016 setDynamicStyle(styles.resting);
8017 return function () {
8018 var remove = function remove(ref) {
8019 var current = ref.current;
8020 !current ? invariant(false, 'Cannot unmount ref as it is not set') : void 0;
8021 getHead().removeChild(current);
8022 ref.current = null;
8023 };
8024
8025 remove(alwaysRef);
8026 remove(dynamicRef);
8027 };
8028 }, [nonce, setAlwaysStyle, setDynamicStyle, styles.always, styles.resting, contextId]);
8029 var dragging = useCallback(function () {
8030 return setDynamicStyle(styles.dragging);
8031 }, [setDynamicStyle, styles.dragging]);
8032 var dropping = useCallback(function (reason) {
8033 if (reason === 'DROP') {
8034 setDynamicStyle(styles.dropAnimating);
8035 return;
8036 }
8037
8038 setDynamicStyle(styles.userCancel);
8039 }, [setDynamicStyle, styles.dropAnimating, styles.userCancel]);
8040 var resting = useCallback(function () {
8041 if (!dynamicRef.current) {
8042 return;
8043 }
8044
8045 setDynamicStyle(styles.resting);
8046 }, [setDynamicStyle, styles.resting]);
8047 var marshal = useMemo(function () {
8048 return {
8049 dragging: dragging,
8050 dropping: dropping,
8051 resting: resting
8052 };
8053 }, [dragging, dropping, resting]);
8054 return marshal;
8055 }
8056
8057 var getWindowFromEl = (function (el) {
8058 return el && el.ownerDocument ? el.ownerDocument.defaultView : window;
8059 });
8060
8061 function isHtmlElement(el) {
8062 return el instanceof getWindowFromEl(el).HTMLElement;
8063 }
8064
8065 function findDragHandle(contextId, draggableId) {
8066 var selector = "[" + dragHandle.contextId + "=\"" + contextId + "\"]";
8067 var possible = toArray(document.querySelectorAll(selector));
8068
8069 if (!possible.length) {
8070 warning("Unable to find any drag handles in the context \"" + contextId + "\"") ;
8071 return null;
8072 }
8073
8074 var handle = find(possible, function (el) {
8075 return el.getAttribute(dragHandle.draggableId) === draggableId;
8076 });
8077
8078 if (!handle) {
8079 warning("Unable to find drag handle with id \"" + draggableId + "\" as no handle with a matching id was found") ;
8080 return null;
8081 }
8082
8083 if (!isHtmlElement(handle)) {
8084 warning('drag handle needs to be a HTMLElement') ;
8085 return null;
8086 }
8087
8088 return handle;
8089 }
8090
8091 function useFocusMarshal(contextId) {
8092 var entriesRef = React.useRef({});
8093 var recordRef = React.useRef(null);
8094 var restoreFocusFrameRef = React.useRef(null);
8095 var isMountedRef = React.useRef(false);
8096 var register = useCallback(function register(id, focus) {
8097 var entry = {
8098 id: id,
8099 focus: focus
8100 };
8101 entriesRef.current[id] = entry;
8102 return function unregister() {
8103 var entries = entriesRef.current;
8104 var current = entries[id];
8105
8106 if (current !== entry) {
8107 delete entries[id];
8108 }
8109 };
8110 }, []);
8111 var tryGiveFocus = useCallback(function tryGiveFocus(tryGiveFocusTo) {
8112 var handle = findDragHandle(contextId, tryGiveFocusTo);
8113
8114 if (handle && handle !== document.activeElement) {
8115 handle.focus();
8116 }
8117 }, [contextId]);
8118 var tryShiftRecord = useCallback(function tryShiftRecord(previous, redirectTo) {
8119 if (recordRef.current === previous) {
8120 recordRef.current = redirectTo;
8121 }
8122 }, []);
8123 var tryRestoreFocusRecorded = useCallback(function tryRestoreFocusRecorded() {
8124 if (restoreFocusFrameRef.current) {
8125 return;
8126 }
8127
8128 if (!isMountedRef.current) {
8129 return;
8130 }
8131
8132 restoreFocusFrameRef.current = requestAnimationFrame(function () {
8133 restoreFocusFrameRef.current = null;
8134 var record = recordRef.current;
8135
8136 if (record) {
8137 tryGiveFocus(record);
8138 }
8139 });
8140 }, [tryGiveFocus]);
8141 var tryRecordFocus = useCallback(function tryRecordFocus(id) {
8142 recordRef.current = null;
8143 var focused = document.activeElement;
8144
8145 if (!focused) {
8146 return;
8147 }
8148
8149 if (focused.getAttribute(dragHandle.draggableId) !== id) {
8150 return;
8151 }
8152
8153 recordRef.current = id;
8154 }, []);
8155 useIsomorphicLayoutEffect$1(function () {
8156 isMountedRef.current = true;
8157 return function clearFrameOnUnmount() {
8158 isMountedRef.current = false;
8159 var frameId = restoreFocusFrameRef.current;
8160
8161 if (frameId) {
8162 cancelAnimationFrame(frameId);
8163 }
8164 };
8165 }, []);
8166 var marshal = useMemo(function () {
8167 return {
8168 register: register,
8169 tryRecordFocus: tryRecordFocus,
8170 tryRestoreFocusRecorded: tryRestoreFocusRecorded,
8171 tryShiftRecord: tryShiftRecord
8172 };
8173 }, [register, tryRecordFocus, tryRestoreFocusRecorded, tryShiftRecord]);
8174 return marshal;
8175 }
8176
8177 function createRegistry() {
8178 var entries = {
8179 draggables: {},
8180 droppables: {}
8181 };
8182 var subscribers = [];
8183
8184 function subscribe(cb) {
8185 subscribers.push(cb);
8186 return function unsubscribe() {
8187 var index = subscribers.indexOf(cb);
8188
8189 if (index === -1) {
8190 return;
8191 }
8192
8193 subscribers.splice(index, 1);
8194 };
8195 }
8196
8197 function notify(event) {
8198 if (subscribers.length) {
8199 subscribers.forEach(function (cb) {
8200 return cb(event);
8201 });
8202 }
8203 }
8204
8205 function findDraggableById(id) {
8206 return entries.draggables[id] || null;
8207 }
8208
8209 function getDraggableById(id) {
8210 var entry = findDraggableById(id);
8211 !entry ? invariant(false, "Cannot find draggable entry with id [" + id + "]") : void 0;
8212 return entry;
8213 }
8214
8215 var draggableAPI = {
8216 register: function register(entry) {
8217 entries.draggables[entry.descriptor.id] = entry;
8218 notify({
8219 type: 'ADDITION',
8220 value: entry
8221 });
8222 },
8223 update: function update(entry, last) {
8224 var current = entries.draggables[last.descriptor.id];
8225
8226 if (!current) {
8227 return;
8228 }
8229
8230 if (current.uniqueId !== entry.uniqueId) {
8231 return;
8232 }
8233
8234 delete entries.draggables[last.descriptor.id];
8235 entries.draggables[entry.descriptor.id] = entry;
8236 },
8237 unregister: function unregister(entry) {
8238 var draggableId = entry.descriptor.id;
8239 var current = findDraggableById(draggableId);
8240
8241 if (!current) {
8242 return;
8243 }
8244
8245 if (entry.uniqueId !== current.uniqueId) {
8246 return;
8247 }
8248
8249 delete entries.draggables[draggableId];
8250 notify({
8251 type: 'REMOVAL',
8252 value: entry
8253 });
8254 },
8255 getById: getDraggableById,
8256 findById: findDraggableById,
8257 exists: function exists(id) {
8258 return Boolean(findDraggableById(id));
8259 },
8260 getAllByType: function getAllByType(type) {
8261 return values(entries.draggables).filter(function (entry) {
8262 return entry.descriptor.type === type;
8263 });
8264 }
8265 };
8266
8267 function findDroppableById(id) {
8268 return entries.droppables[id] || null;
8269 }
8270
8271 function getDroppableById(id) {
8272 var entry = findDroppableById(id);
8273 !entry ? invariant(false, "Cannot find droppable entry with id [" + id + "]") : void 0;
8274 return entry;
8275 }
8276
8277 var droppableAPI = {
8278 register: function register(entry) {
8279 entries.droppables[entry.descriptor.id] = entry;
8280 },
8281 unregister: function unregister(entry) {
8282 var current = findDroppableById(entry.descriptor.id);
8283
8284 if (!current) {
8285 return;
8286 }
8287
8288 if (entry.uniqueId !== current.uniqueId) {
8289 return;
8290 }
8291
8292 delete entries.droppables[entry.descriptor.id];
8293 },
8294 getById: getDroppableById,
8295 findById: findDroppableById,
8296 exists: function exists(id) {
8297 return Boolean(findDroppableById(id));
8298 },
8299 getAllByType: function getAllByType(type) {
8300 return values(entries.droppables).filter(function (entry) {
8301 return entry.descriptor.type === type;
8302 });
8303 }
8304 };
8305
8306 function clean() {
8307 entries.draggables = {};
8308 entries.droppables = {};
8309 subscribers.length = 0;
8310 }
8311
8312 return {
8313 draggable: draggableAPI,
8314 droppable: droppableAPI,
8315 subscribe: subscribe,
8316 clean: clean
8317 };
8318 }
8319
8320 function useRegistry() {
8321 var registry = useMemo(createRegistry, []);
8322 React.useEffect(function () {
8323 return function unmount() {
8324 requestAnimationFrame(registry.clean);
8325 };
8326 }, [registry]);
8327 return registry;
8328 }
8329
8330 var StoreContext = React__default.createContext(null);
8331
8332 var getBodyElement = (function () {
8333 var body = document.body;
8334 !body ? invariant(false, 'Cannot find document.body') : void 0;
8335 return body;
8336 });
8337
8338 var visuallyHidden = {
8339 position: 'absolute',
8340 width: '1px',
8341 height: '1px',
8342 margin: '-1px',
8343 border: '0',
8344 padding: '0',
8345 overflow: 'hidden',
8346 clip: 'rect(0 0 0 0)',
8347 'clip-path': 'inset(100%)'
8348 };
8349
8350 var getId = function getId(contextId) {
8351 return "rbd-announcement-" + contextId;
8352 };
8353 function useAnnouncer(contextId) {
8354 var id = useMemo(function () {
8355 return getId(contextId);
8356 }, [contextId]);
8357 var ref = React.useRef(null);
8358 React.useEffect(function setup() {
8359 var el = document.createElement('div');
8360 ref.current = el;
8361 el.id = id;
8362 el.setAttribute('aria-live', 'assertive');
8363 el.setAttribute('aria-atomic', 'true');
8364
8365 _extends(el.style, visuallyHidden);
8366
8367 getBodyElement().appendChild(el);
8368 return function cleanup() {
8369 setTimeout(function remove() {
8370 var body = getBodyElement();
8371
8372 if (body.contains(el)) {
8373 body.removeChild(el);
8374 }
8375
8376 if (el === ref.current) {
8377 ref.current = null;
8378 }
8379 });
8380 };
8381 }, [id]);
8382 var announce = useCallback(function (message) {
8383 var el = ref.current;
8384
8385 if (el) {
8386 el.textContent = message;
8387 return;
8388 }
8389
8390 warning("\n A screen reader message was trying to be announced but it was unable to do so.\n This can occur if you unmount your <DragDropContext /> in your onDragEnd.\n Consider calling provided.announce() before the unmount so that the instruction will\n not be lost for users relying on a screen reader.\n\n Message not passed to screen reader:\n\n \"" + message + "\"\n ") ;
8391 }, []);
8392 return announce;
8393 }
8394
8395 var count = 0;
8396 var defaults = {
8397 separator: '::'
8398 };
8399 function reset() {
8400 count = 0;
8401 }
8402 function useUniqueId(prefix, options) {
8403 if (options === void 0) {
8404 options = defaults;
8405 }
8406
8407 return useMemo(function () {
8408 return "" + prefix + options.separator + count++;
8409 }, [options.separator, prefix]);
8410 }
8411
8412 function getElementId(_ref) {
8413 var contextId = _ref.contextId,
8414 uniqueId = _ref.uniqueId;
8415 return "rbd-hidden-text-" + contextId + "-" + uniqueId;
8416 }
8417 function useHiddenTextElement(_ref2) {
8418 var contextId = _ref2.contextId,
8419 text = _ref2.text;
8420 var uniqueId = useUniqueId('hidden-text', {
8421 separator: '-'
8422 });
8423 var id = useMemo(function () {
8424 return getElementId({
8425 contextId: contextId,
8426 uniqueId: uniqueId
8427 });
8428 }, [uniqueId, contextId]);
8429 React.useEffect(function mount() {
8430 var el = document.createElement('div');
8431 el.id = id;
8432 el.textContent = text;
8433 el.style.display = 'none';
8434 getBodyElement().appendChild(el);
8435 return function unmount() {
8436 var body = getBodyElement();
8437
8438 if (body.contains(el)) {
8439 body.removeChild(el);
8440 }
8441 };
8442 }, [id, text]);
8443 return id;
8444 }
8445
8446 var AppContext = React__default.createContext(null);
8447
8448 var peerDependencies = {
8449 react: "^16.8.5 || ^17.0.0 || ^18.0.0",
8450 "react-dom": "^16.8.5 || ^17.0.0 || ^18.0.0"
8451 };
8452
8453 var semver = /(\d+)\.(\d+)\.(\d+)/;
8454
8455 var getVersion = function getVersion(value) {
8456 var result = semver.exec(value);
8457 !(result != null) ? invariant(false, "Unable to parse React version " + value) : void 0;
8458 var major = Number(result[1]);
8459 var minor = Number(result[2]);
8460 var patch = Number(result[3]);
8461 return {
8462 major: major,
8463 minor: minor,
8464 patch: patch,
8465 raw: value
8466 };
8467 };
8468
8469 var isSatisfied = function isSatisfied(expected, actual) {
8470 if (actual.major > expected.major) {
8471 return true;
8472 }
8473
8474 if (actual.major < expected.major) {
8475 return false;
8476 }
8477
8478 if (actual.minor > expected.minor) {
8479 return true;
8480 }
8481
8482 if (actual.minor < expected.minor) {
8483 return false;
8484 }
8485
8486 return actual.patch >= expected.patch;
8487 };
8488
8489 var checkReactVersion = (function (peerDepValue, actualValue) {
8490 var peerDep = getVersion(peerDepValue);
8491 var actual = getVersion(actualValue);
8492
8493 if (isSatisfied(peerDep, actual)) {
8494 return;
8495 }
8496
8497 warning("\n React version: [" + actual.raw + "]\n does not satisfy expected peer dependency version: [" + peerDep.raw + "]\n\n This can result in run time bugs, and even fatal crashes\n ") ;
8498 });
8499
8500 var suffix = "\n We expect a html5 doctype: <!doctype html>\n This is to ensure consistent browser layout and measurement\n\n More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/doctype.md\n";
8501 var checkDoctype = (function (doc) {
8502 var doctype = doc.doctype;
8503
8504 if (!doctype) {
8505 warning("\n No <!doctype html> found.\n\n " + suffix + "\n ") ;
8506 return;
8507 }
8508
8509 if (doctype.name.toLowerCase() !== 'html') {
8510 warning("\n Unexpected <!doctype> found: (" + doctype.name + ")\n\n " + suffix + "\n ") ;
8511 }
8512
8513 if (doctype.publicId !== '') {
8514 warning("\n Unexpected <!doctype> publicId found: (" + doctype.publicId + ")\n A html5 doctype does not have a publicId\n\n " + suffix + "\n ") ;
8515 }
8516 });
8517
8518 function useDev(useHook) {
8519 {
8520 useHook();
8521 }
8522 }
8523
8524 function useDevSetupWarning(fn, inputs) {
8525 useDev(function () {
8526 React.useEffect(function () {
8527 try {
8528 fn();
8529 } catch (e) {
8530 error("\n A setup problem was encountered.\n\n > " + e.message + "\n ");
8531 }
8532 }, inputs);
8533 });
8534 }
8535
8536 function useStartupValidation() {
8537 useDevSetupWarning(function () {
8538 checkReactVersion(peerDependencies.react, React__default.version);
8539 checkDoctype(document);
8540 }, []);
8541 }
8542
8543 function usePrevious(current) {
8544 var ref = React.useRef(current);
8545 React.useEffect(function () {
8546 ref.current = current;
8547 });
8548 return ref;
8549 }
8550
8551 function create() {
8552 var lock = null;
8553
8554 function isClaimed() {
8555 return Boolean(lock);
8556 }
8557
8558 function isActive(value) {
8559 return value === lock;
8560 }
8561
8562 function claim(abandon) {
8563 !!lock ? invariant(false, 'Cannot claim lock as it is already claimed') : void 0;
8564 var newLock = {
8565 abandon: abandon
8566 };
8567 lock = newLock;
8568 return newLock;
8569 }
8570
8571 function release() {
8572 !lock ? invariant(false, 'Cannot release lock when there is no lock') : void 0;
8573 lock = null;
8574 }
8575
8576 function tryAbandon() {
8577 if (lock) {
8578 lock.abandon();
8579 release();
8580 }
8581 }
8582
8583 return {
8584 isClaimed: isClaimed,
8585 isActive: isActive,
8586 claim: claim,
8587 release: release,
8588 tryAbandon: tryAbandon
8589 };
8590 }
8591
8592 var tab = 9;
8593 var enter = 13;
8594 var escape = 27;
8595 var space = 32;
8596 var pageUp = 33;
8597 var pageDown = 34;
8598 var end = 35;
8599 var home = 36;
8600 var arrowLeft = 37;
8601 var arrowUp = 38;
8602 var arrowRight = 39;
8603 var arrowDown = 40;
8604
8605 var _preventedKeys;
8606 var preventedKeys = (_preventedKeys = {}, _preventedKeys[enter] = true, _preventedKeys[tab] = true, _preventedKeys);
8607 var preventStandardKeyEvents = (function (event) {
8608 if (preventedKeys[event.keyCode]) {
8609 event.preventDefault();
8610 }
8611 });
8612
8613 var supportedEventName = function () {
8614 var base = 'visibilitychange';
8615
8616 if (typeof document === 'undefined') {
8617 return base;
8618 }
8619
8620 var candidates = [base, "ms" + base, "webkit" + base, "moz" + base, "o" + base];
8621 var supported = find(candidates, function (eventName) {
8622 return "on" + eventName in document;
8623 });
8624 return supported || base;
8625 }();
8626
8627 var primaryButton = 0;
8628 var sloppyClickThreshold = 5;
8629
8630 function isSloppyClickThresholdExceeded(original, current) {
8631 return Math.abs(current.x - original.x) >= sloppyClickThreshold || Math.abs(current.y - original.y) >= sloppyClickThreshold;
8632 }
8633
8634 var idle$1 = {
8635 type: 'IDLE'
8636 };
8637
8638 function getCaptureBindings(_ref) {
8639 var cancel = _ref.cancel,
8640 completed = _ref.completed,
8641 getPhase = _ref.getPhase,
8642 setPhase = _ref.setPhase;
8643 return [{
8644 eventName: 'mousemove',
8645 fn: function fn(event) {
8646 var button = event.button,
8647 clientX = event.clientX,
8648 clientY = event.clientY;
8649
8650 if (button !== primaryButton) {
8651 return;
8652 }
8653
8654 var point = {
8655 x: clientX,
8656 y: clientY
8657 };
8658 var phase = getPhase();
8659
8660 if (phase.type === 'DRAGGING') {
8661 event.preventDefault();
8662 phase.actions.move(point);
8663 return;
8664 }
8665
8666 !(phase.type === 'PENDING') ? invariant(false, 'Cannot be IDLE') : void 0;
8667 var pending = phase.point;
8668
8669 if (!isSloppyClickThresholdExceeded(pending, point)) {
8670 return;
8671 }
8672
8673 event.preventDefault();
8674 var actions = phase.actions.fluidLift(point);
8675 setPhase({
8676 type: 'DRAGGING',
8677 actions: actions
8678 });
8679 }
8680 }, {
8681 eventName: 'mouseup',
8682 fn: function fn(event) {
8683 var phase = getPhase();
8684
8685 if (phase.type !== 'DRAGGING') {
8686 cancel();
8687 return;
8688 }
8689
8690 event.preventDefault();
8691 phase.actions.drop({
8692 shouldBlockNextClick: true
8693 });
8694 completed();
8695 }
8696 }, {
8697 eventName: 'mousedown',
8698 fn: function fn(event) {
8699 if (getPhase().type === 'DRAGGING') {
8700 event.preventDefault();
8701 }
8702
8703 cancel();
8704 }
8705 }, {
8706 eventName: 'keydown',
8707 fn: function fn(event) {
8708 var phase = getPhase();
8709
8710 if (phase.type === 'PENDING') {
8711 cancel();
8712 return;
8713 }
8714
8715 if (event.keyCode === escape) {
8716 event.preventDefault();
8717 cancel();
8718 return;
8719 }
8720
8721 preventStandardKeyEvents(event);
8722 }
8723 }, {
8724 eventName: 'resize',
8725 fn: cancel
8726 }, {
8727 eventName: 'scroll',
8728 options: {
8729 passive: true,
8730 capture: false
8731 },
8732 fn: function fn() {
8733 if (getPhase().type === 'PENDING') {
8734 cancel();
8735 }
8736 }
8737 }, {
8738 eventName: 'webkitmouseforcedown',
8739 fn: function fn(event) {
8740 var phase = getPhase();
8741 !(phase.type !== 'IDLE') ? invariant(false, 'Unexpected phase') : void 0;
8742
8743 if (phase.actions.shouldRespectForcePress()) {
8744 cancel();
8745 return;
8746 }
8747
8748 event.preventDefault();
8749 }
8750 }, {
8751 eventName: supportedEventName,
8752 fn: cancel
8753 }];
8754 }
8755
8756 function useMouseSensor(api) {
8757 var phaseRef = React.useRef(idle$1);
8758 var unbindEventsRef = React.useRef(noop);
8759 var startCaptureBinding = useMemo(function () {
8760 return {
8761 eventName: 'mousedown',
8762 fn: function onMouseDown(event) {
8763 if (event.defaultPrevented) {
8764 return;
8765 }
8766
8767 if (event.button !== primaryButton) {
8768 return;
8769 }
8770
8771 if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
8772 return;
8773 }
8774
8775 var draggableId = api.findClosestDraggableId(event);
8776
8777 if (!draggableId) {
8778 return;
8779 }
8780
8781 var actions = api.tryGetLock(draggableId, stop, {
8782 sourceEvent: event
8783 });
8784
8785 if (!actions) {
8786 return;
8787 }
8788
8789 event.preventDefault();
8790 var point = {
8791 x: event.clientX,
8792 y: event.clientY
8793 };
8794 unbindEventsRef.current();
8795 startPendingDrag(actions, point);
8796 }
8797 };
8798 }, [api]);
8799 var preventForcePressBinding = useMemo(function () {
8800 return {
8801 eventName: 'webkitmouseforcewillbegin',
8802 fn: function fn(event) {
8803 if (event.defaultPrevented) {
8804 return;
8805 }
8806
8807 var id = api.findClosestDraggableId(event);
8808
8809 if (!id) {
8810 return;
8811 }
8812
8813 var options = api.findOptionsForDraggable(id);
8814
8815 if (!options) {
8816 return;
8817 }
8818
8819 if (options.shouldRespectForcePress) {
8820 return;
8821 }
8822
8823 if (!api.canGetLock(id)) {
8824 return;
8825 }
8826
8827 event.preventDefault();
8828 }
8829 };
8830 }, [api]);
8831 var listenForCapture = useCallback(function listenForCapture() {
8832 var options = {
8833 passive: false,
8834 capture: true
8835 };
8836 unbindEventsRef.current = bindEvents(window, [preventForcePressBinding, startCaptureBinding], options);
8837 }, [preventForcePressBinding, startCaptureBinding]);
8838 var stop = useCallback(function () {
8839 var current = phaseRef.current;
8840
8841 if (current.type === 'IDLE') {
8842 return;
8843 }
8844
8845 phaseRef.current = idle$1;
8846 unbindEventsRef.current();
8847 listenForCapture();
8848 }, [listenForCapture]);
8849 var cancel = useCallback(function () {
8850 var phase = phaseRef.current;
8851 stop();
8852
8853 if (phase.type === 'DRAGGING') {
8854 phase.actions.cancel({
8855 shouldBlockNextClick: true
8856 });
8857 }
8858
8859 if (phase.type === 'PENDING') {
8860 phase.actions.abort();
8861 }
8862 }, [stop]);
8863 var bindCapturingEvents = useCallback(function bindCapturingEvents() {
8864 var options = {
8865 capture: true,
8866 passive: false
8867 };
8868 var bindings = getCaptureBindings({
8869 cancel: cancel,
8870 completed: stop,
8871 getPhase: function getPhase() {
8872 return phaseRef.current;
8873 },
8874 setPhase: function setPhase(phase) {
8875 phaseRef.current = phase;
8876 }
8877 });
8878 unbindEventsRef.current = bindEvents(window, bindings, options);
8879 }, [cancel, stop]);
8880 var startPendingDrag = useCallback(function startPendingDrag(actions, point) {
8881 !(phaseRef.current.type === 'IDLE') ? invariant(false, 'Expected to move from IDLE to PENDING drag') : void 0;
8882 phaseRef.current = {
8883 type: 'PENDING',
8884 point: point,
8885 actions: actions
8886 };
8887 bindCapturingEvents();
8888 }, [bindCapturingEvents]);
8889 useIsomorphicLayoutEffect$1(function mount() {
8890 listenForCapture();
8891 return function unmount() {
8892 unbindEventsRef.current();
8893 };
8894 }, [listenForCapture]);
8895 }
8896
8897 var _scrollJumpKeys;
8898
8899 function noop$1() {}
8900
8901 var scrollJumpKeys = (_scrollJumpKeys = {}, _scrollJumpKeys[pageDown] = true, _scrollJumpKeys[pageUp] = true, _scrollJumpKeys[home] = true, _scrollJumpKeys[end] = true, _scrollJumpKeys);
8902
8903 function getDraggingBindings(actions, stop) {
8904 function cancel() {
8905 stop();
8906 actions.cancel();
8907 }
8908
8909 function drop() {
8910 stop();
8911 actions.drop();
8912 }
8913
8914 return [{
8915 eventName: 'keydown',
8916 fn: function fn(event) {
8917 if (event.keyCode === escape) {
8918 event.preventDefault();
8919 cancel();
8920 return;
8921 }
8922
8923 if (event.keyCode === space) {
8924 event.preventDefault();
8925 drop();
8926 return;
8927 }
8928
8929 if (event.keyCode === arrowDown) {
8930 event.preventDefault();
8931 actions.moveDown();
8932 return;
8933 }
8934
8935 if (event.keyCode === arrowUp) {
8936 event.preventDefault();
8937 actions.moveUp();
8938 return;
8939 }
8940
8941 if (event.keyCode === arrowRight) {
8942 event.preventDefault();
8943 actions.moveRight();
8944 return;
8945 }
8946
8947 if (event.keyCode === arrowLeft) {
8948 event.preventDefault();
8949 actions.moveLeft();
8950 return;
8951 }
8952
8953 if (scrollJumpKeys[event.keyCode]) {
8954 event.preventDefault();
8955 return;
8956 }
8957
8958 preventStandardKeyEvents(event);
8959 }
8960 }, {
8961 eventName: 'mousedown',
8962 fn: cancel
8963 }, {
8964 eventName: 'mouseup',
8965 fn: cancel
8966 }, {
8967 eventName: 'click',
8968 fn: cancel
8969 }, {
8970 eventName: 'touchstart',
8971 fn: cancel
8972 }, {
8973 eventName: 'resize',
8974 fn: cancel
8975 }, {
8976 eventName: 'wheel',
8977 fn: cancel,
8978 options: {
8979 passive: true
8980 }
8981 }, {
8982 eventName: supportedEventName,
8983 fn: cancel
8984 }];
8985 }
8986
8987 function useKeyboardSensor(api) {
8988 var unbindEventsRef = React.useRef(noop$1);
8989 var startCaptureBinding = useMemo(function () {
8990 return {
8991 eventName: 'keydown',
8992 fn: function onKeyDown(event) {
8993 if (event.defaultPrevented) {
8994 return;
8995 }
8996
8997 if (event.keyCode !== space) {
8998 return;
8999 }
9000
9001 var draggableId = api.findClosestDraggableId(event);
9002
9003 if (!draggableId) {
9004 return;
9005 }
9006
9007 var preDrag = api.tryGetLock(draggableId, stop, {
9008 sourceEvent: event
9009 });
9010
9011 if (!preDrag) {
9012 return;
9013 }
9014
9015 event.preventDefault();
9016 var isCapturing = true;
9017 var actions = preDrag.snapLift();
9018 unbindEventsRef.current();
9019
9020 function stop() {
9021 !isCapturing ? invariant(false, 'Cannot stop capturing a keyboard drag when not capturing') : void 0;
9022 isCapturing = false;
9023 unbindEventsRef.current();
9024 listenForCapture();
9025 }
9026
9027 unbindEventsRef.current = bindEvents(window, getDraggingBindings(actions, stop), {
9028 capture: true,
9029 passive: false
9030 });
9031 }
9032 };
9033 }, [api]);
9034 var listenForCapture = useCallback(function tryStartCapture() {
9035 var options = {
9036 passive: false,
9037 capture: true
9038 };
9039 unbindEventsRef.current = bindEvents(window, [startCaptureBinding], options);
9040 }, [startCaptureBinding]);
9041 useIsomorphicLayoutEffect$1(function mount() {
9042 listenForCapture();
9043 return function unmount() {
9044 unbindEventsRef.current();
9045 };
9046 }, [listenForCapture]);
9047 }
9048
9049 var idle$2 = {
9050 type: 'IDLE'
9051 };
9052 var timeForLongPress = 120;
9053 var forcePressThreshold = 0.15;
9054
9055 function getWindowBindings(_ref) {
9056 var cancel = _ref.cancel,
9057 getPhase = _ref.getPhase;
9058 return [{
9059 eventName: 'orientationchange',
9060 fn: cancel
9061 }, {
9062 eventName: 'resize',
9063 fn: cancel
9064 }, {
9065 eventName: 'contextmenu',
9066 fn: function fn(event) {
9067 event.preventDefault();
9068 }
9069 }, {
9070 eventName: 'keydown',
9071 fn: function fn(event) {
9072 if (getPhase().type !== 'DRAGGING') {
9073 cancel();
9074 return;
9075 }
9076
9077 if (event.keyCode === escape) {
9078 event.preventDefault();
9079 }
9080
9081 cancel();
9082 }
9083 }, {
9084 eventName: supportedEventName,
9085 fn: cancel
9086 }];
9087 }
9088
9089 function getHandleBindings(_ref2) {
9090 var cancel = _ref2.cancel,
9091 completed = _ref2.completed,
9092 getPhase = _ref2.getPhase;
9093 return [{
9094 eventName: 'touchmove',
9095 options: {
9096 capture: false
9097 },
9098 fn: function fn(event) {
9099 var phase = getPhase();
9100
9101 if (phase.type !== 'DRAGGING') {
9102 cancel();
9103 return;
9104 }
9105
9106 phase.hasMoved = true;
9107 var _event$touches$ = event.touches[0],
9108 clientX = _event$touches$.clientX,
9109 clientY = _event$touches$.clientY;
9110 var point = {
9111 x: clientX,
9112 y: clientY
9113 };
9114 event.preventDefault();
9115 phase.actions.move(point);
9116 }
9117 }, {
9118 eventName: 'touchend',
9119 fn: function fn(event) {
9120 var phase = getPhase();
9121
9122 if (phase.type !== 'DRAGGING') {
9123 cancel();
9124 return;
9125 }
9126
9127 event.preventDefault();
9128 phase.actions.drop({
9129 shouldBlockNextClick: true
9130 });
9131 completed();
9132 }
9133 }, {
9134 eventName: 'touchcancel',
9135 fn: function fn(event) {
9136 if (getPhase().type !== 'DRAGGING') {
9137 cancel();
9138 return;
9139 }
9140
9141 event.preventDefault();
9142 cancel();
9143 }
9144 }, {
9145 eventName: 'touchforcechange',
9146 fn: function fn(event) {
9147 var phase = getPhase();
9148 !(phase.type !== 'IDLE') ? invariant(false) : void 0;
9149 var touch = event.touches[0];
9150
9151 if (!touch) {
9152 return;
9153 }
9154
9155 var isForcePress = touch.force >= forcePressThreshold;
9156
9157 if (!isForcePress) {
9158 return;
9159 }
9160
9161 var shouldRespect = phase.actions.shouldRespectForcePress();
9162
9163 if (phase.type === 'PENDING') {
9164 if (shouldRespect) {
9165 cancel();
9166 }
9167
9168 return;
9169 }
9170
9171 if (shouldRespect) {
9172 if (phase.hasMoved) {
9173 event.preventDefault();
9174 return;
9175 }
9176
9177 cancel();
9178 return;
9179 }
9180
9181 event.preventDefault();
9182 }
9183 }, {
9184 eventName: supportedEventName,
9185 fn: cancel
9186 }];
9187 }
9188
9189 function useTouchSensor(api) {
9190 var phaseRef = React.useRef(idle$2);
9191 var unbindEventsRef = React.useRef(noop);
9192 var getPhase = useCallback(function getPhase() {
9193 return phaseRef.current;
9194 }, []);
9195 var setPhase = useCallback(function setPhase(phase) {
9196 phaseRef.current = phase;
9197 }, []);
9198 var startCaptureBinding = useMemo(function () {
9199 return {
9200 eventName: 'touchstart',
9201 fn: function onTouchStart(event) {
9202 if (event.defaultPrevented) {
9203 return;
9204 }
9205
9206 var draggableId = api.findClosestDraggableId(event);
9207
9208 if (!draggableId) {
9209 return;
9210 }
9211
9212 var actions = api.tryGetLock(draggableId, stop, {
9213 sourceEvent: event
9214 });
9215
9216 if (!actions) {
9217 return;
9218 }
9219
9220 var touch = event.touches[0];
9221 var clientX = touch.clientX,
9222 clientY = touch.clientY;
9223 var point = {
9224 x: clientX,
9225 y: clientY
9226 };
9227 unbindEventsRef.current();
9228 startPendingDrag(actions, point);
9229 }
9230 };
9231 }, [api]);
9232 var listenForCapture = useCallback(function listenForCapture() {
9233 var options = {
9234 capture: true,
9235 passive: false
9236 };
9237 unbindEventsRef.current = bindEvents(window, [startCaptureBinding], options);
9238 }, [startCaptureBinding]);
9239 var stop = useCallback(function () {
9240 var current = phaseRef.current;
9241
9242 if (current.type === 'IDLE') {
9243 return;
9244 }
9245
9246 if (current.type === 'PENDING') {
9247 clearTimeout(current.longPressTimerId);
9248 }
9249
9250 setPhase(idle$2);
9251 unbindEventsRef.current();
9252 listenForCapture();
9253 }, [listenForCapture, setPhase]);
9254 var cancel = useCallback(function () {
9255 var phase = phaseRef.current;
9256 stop();
9257
9258 if (phase.type === 'DRAGGING') {
9259 phase.actions.cancel({
9260 shouldBlockNextClick: true
9261 });
9262 }
9263
9264 if (phase.type === 'PENDING') {
9265 phase.actions.abort();
9266 }
9267 }, [stop]);
9268 var bindCapturingEvents = useCallback(function bindCapturingEvents() {
9269 var options = {
9270 capture: true,
9271 passive: false
9272 };
9273 var args = {
9274 cancel: cancel,
9275 completed: stop,
9276 getPhase: getPhase
9277 };
9278 var unbindTarget = bindEvents(window, getHandleBindings(args), options);
9279 var unbindWindow = bindEvents(window, getWindowBindings(args), options);
9280
9281 unbindEventsRef.current = function unbindAll() {
9282 unbindTarget();
9283 unbindWindow();
9284 };
9285 }, [cancel, getPhase, stop]);
9286 var startDragging = useCallback(function startDragging() {
9287 var phase = getPhase();
9288 !(phase.type === 'PENDING') ? invariant(false, "Cannot start dragging from phase " + phase.type) : void 0;
9289 var actions = phase.actions.fluidLift(phase.point);
9290 setPhase({
9291 type: 'DRAGGING',
9292 actions: actions,
9293 hasMoved: false
9294 });
9295 }, [getPhase, setPhase]);
9296 var startPendingDrag = useCallback(function startPendingDrag(actions, point) {
9297 !(getPhase().type === 'IDLE') ? invariant(false, 'Expected to move from IDLE to PENDING drag') : void 0;
9298 var longPressTimerId = setTimeout(startDragging, timeForLongPress);
9299 setPhase({
9300 type: 'PENDING',
9301 point: point,
9302 actions: actions,
9303 longPressTimerId: longPressTimerId
9304 });
9305 bindCapturingEvents();
9306 }, [bindCapturingEvents, getPhase, setPhase, startDragging]);
9307 useIsomorphicLayoutEffect$1(function mount() {
9308 listenForCapture();
9309 return function unmount() {
9310 unbindEventsRef.current();
9311 var phase = getPhase();
9312
9313 if (phase.type === 'PENDING') {
9314 clearTimeout(phase.longPressTimerId);
9315 setPhase(idle$2);
9316 }
9317 };
9318 }, [getPhase, listenForCapture, setPhase]);
9319 useIsomorphicLayoutEffect$1(function webkitHack() {
9320 var unbind = bindEvents(window, [{
9321 eventName: 'touchmove',
9322 fn: function fn() {},
9323 options: {
9324 capture: false,
9325 passive: false
9326 }
9327 }]);
9328 return unbind;
9329 }, []);
9330 }
9331
9332 function useValidateSensorHooks(sensorHooks) {
9333 useDev(function () {
9334 var previousRef = usePrevious(sensorHooks);
9335 useDevSetupWarning(function () {
9336 !(previousRef.current.length === sensorHooks.length) ? "development" !== "production" ? invariant(false, 'Cannot change the amount of sensor hooks after mounting') : invariant(false) : void 0;
9337 });
9338 });
9339 }
9340
9341 var interactiveTagNames = {
9342 input: true,
9343 button: true,
9344 textarea: true,
9345 select: true,
9346 option: true,
9347 optgroup: true,
9348 video: true,
9349 audio: true
9350 };
9351
9352 function isAnInteractiveElement(parent, current) {
9353 if (current == null) {
9354 return false;
9355 }
9356
9357 var hasAnInteractiveTag = Boolean(interactiveTagNames[current.tagName.toLowerCase()]);
9358
9359 if (hasAnInteractiveTag) {
9360 return true;
9361 }
9362
9363 var attribute = current.getAttribute('contenteditable');
9364
9365 if (attribute === 'true' || attribute === '') {
9366 return true;
9367 }
9368
9369 if (current === parent) {
9370 return false;
9371 }
9372
9373 return isAnInteractiveElement(parent, current.parentElement);
9374 }
9375
9376 function isEventInInteractiveElement(draggable, event) {
9377 var target = event.target;
9378
9379 if (!isHtmlElement(target)) {
9380 return false;
9381 }
9382
9383 return isAnInteractiveElement(draggable, target);
9384 }
9385
9386 var getBorderBoxCenterPosition = (function (el) {
9387 return getRect(el.getBoundingClientRect()).center;
9388 });
9389
9390 function isElement(el) {
9391 return el instanceof getWindowFromEl(el).Element;
9392 }
9393
9394 var supportedMatchesName = function () {
9395 var base = 'matches';
9396
9397 if (typeof document === 'undefined') {
9398 return base;
9399 }
9400
9401 var candidates = [base, 'msMatchesSelector', 'webkitMatchesSelector'];
9402 var value = find(candidates, function (name) {
9403 return name in Element.prototype;
9404 });
9405 return value || base;
9406 }();
9407
9408 function closestPonyfill(el, selector) {
9409 if (el == null) {
9410 return null;
9411 }
9412
9413 if (el[supportedMatchesName](selector)) {
9414 return el;
9415 }
9416
9417 return closestPonyfill(el.parentElement, selector);
9418 }
9419
9420 function closest$1(el, selector) {
9421 if (el.closest) {
9422 return el.closest(selector);
9423 }
9424
9425 return closestPonyfill(el, selector);
9426 }
9427
9428 function getSelector(contextId) {
9429 return "[" + dragHandle.contextId + "=\"" + contextId + "\"]";
9430 }
9431
9432 function findClosestDragHandleFromEvent(contextId, event) {
9433 var target = event.target;
9434
9435 if (!isElement(target)) {
9436 warning('event.target must be a Element') ;
9437 return null;
9438 }
9439
9440 var selector = getSelector(contextId);
9441 var handle = closest$1(target, selector);
9442
9443 if (!handle) {
9444 return null;
9445 }
9446
9447 if (!isHtmlElement(handle)) {
9448 warning('drag handle must be a HTMLElement') ;
9449 return null;
9450 }
9451
9452 return handle;
9453 }
9454
9455 function tryGetClosestDraggableIdFromEvent(contextId, event) {
9456 var handle = findClosestDragHandleFromEvent(contextId, event);
9457
9458 if (!handle) {
9459 return null;
9460 }
9461
9462 return handle.getAttribute(dragHandle.draggableId);
9463 }
9464
9465 function findDraggable(contextId, draggableId) {
9466 var selector = "[" + draggable.contextId + "=\"" + contextId + "\"]";
9467 var possible = toArray(document.querySelectorAll(selector));
9468 var draggable$1 = find(possible, function (el) {
9469 return el.getAttribute(draggable.id) === draggableId;
9470 });
9471
9472 if (!draggable$1) {
9473 return null;
9474 }
9475
9476 if (!isHtmlElement(draggable$1)) {
9477 warning('Draggable element is not a HTMLElement') ;
9478 return null;
9479 }
9480
9481 return draggable$1;
9482 }
9483
9484 function preventDefault(event) {
9485 event.preventDefault();
9486 }
9487
9488 function _isActive(_ref) {
9489 var expected = _ref.expected,
9490 phase = _ref.phase,
9491 isLockActive = _ref.isLockActive,
9492 shouldWarn = _ref.shouldWarn;
9493
9494 if (!isLockActive()) {
9495 if (shouldWarn) {
9496 warning("\n Cannot perform action.\n The sensor no longer has an action lock.\n\n Tips:\n\n - Throw away your action handlers when forceStop() is called\n - Check actions.isActive() if you really need to\n ") ;
9497 }
9498
9499 return false;
9500 }
9501
9502 if (expected !== phase) {
9503 if (shouldWarn) {
9504 warning("\n Cannot perform action.\n The actions you used belong to an outdated phase\n\n Current phase: " + expected + "\n You called an action from outdated phase: " + phase + "\n\n Tips:\n\n - Do not use preDragActions actions after calling preDragActions.lift()\n ") ;
9505 }
9506
9507 return false;
9508 }
9509
9510 return true;
9511 }
9512
9513 function canStart(_ref2) {
9514 var lockAPI = _ref2.lockAPI,
9515 store = _ref2.store,
9516 registry = _ref2.registry,
9517 draggableId = _ref2.draggableId;
9518
9519 if (lockAPI.isClaimed()) {
9520 return false;
9521 }
9522
9523 var entry = registry.draggable.findById(draggableId);
9524
9525 if (!entry) {
9526 warning("Unable to find draggable with id: " + draggableId) ;
9527 return false;
9528 }
9529
9530 if (!entry.options.isEnabled) {
9531 return false;
9532 }
9533
9534 if (!canStartDrag(store.getState(), draggableId)) {
9535 return false;
9536 }
9537
9538 return true;
9539 }
9540
9541 function tryStart(_ref3) {
9542 var lockAPI = _ref3.lockAPI,
9543 contextId = _ref3.contextId,
9544 store = _ref3.store,
9545 registry = _ref3.registry,
9546 draggableId = _ref3.draggableId,
9547 forceSensorStop = _ref3.forceSensorStop,
9548 sourceEvent = _ref3.sourceEvent;
9549 var shouldStart = canStart({
9550 lockAPI: lockAPI,
9551 store: store,
9552 registry: registry,
9553 draggableId: draggableId
9554 });
9555
9556 if (!shouldStart) {
9557 return null;
9558 }
9559
9560 var entry = registry.draggable.getById(draggableId);
9561 var el = findDraggable(contextId, entry.descriptor.id);
9562
9563 if (!el) {
9564 warning("Unable to find draggable element with id: " + draggableId) ;
9565 return null;
9566 }
9567
9568 if (sourceEvent && !entry.options.canDragInteractiveElements && isEventInInteractiveElement(el, sourceEvent)) {
9569 return null;
9570 }
9571
9572 var lock = lockAPI.claim(forceSensorStop || noop);
9573 var phase = 'PRE_DRAG';
9574
9575 function getShouldRespectForcePress() {
9576 return entry.options.shouldRespectForcePress;
9577 }
9578
9579 function isLockActive() {
9580 return lockAPI.isActive(lock);
9581 }
9582
9583 function tryDispatch(expected, getAction) {
9584 if (_isActive({
9585 expected: expected,
9586 phase: phase,
9587 isLockActive: isLockActive,
9588 shouldWarn: true
9589 })) {
9590 store.dispatch(getAction());
9591 }
9592 }
9593
9594 var tryDispatchWhenDragging = tryDispatch.bind(null, 'DRAGGING');
9595
9596 function lift$1(args) {
9597 function completed() {
9598 lockAPI.release();
9599 phase = 'COMPLETED';
9600 }
9601
9602 if (phase !== 'PRE_DRAG') {
9603 completed();
9604 !(phase === 'PRE_DRAG') ? invariant(false, "Cannot lift in phase " + phase) : void 0;
9605 }
9606
9607 store.dispatch(lift(args.liftActionArgs));
9608 phase = 'DRAGGING';
9609
9610 function finish(reason, options) {
9611 if (options === void 0) {
9612 options = {
9613 shouldBlockNextClick: false
9614 };
9615 }
9616
9617 args.cleanup();
9618
9619 if (options.shouldBlockNextClick) {
9620 var unbind = bindEvents(window, [{
9621 eventName: 'click',
9622 fn: preventDefault,
9623 options: {
9624 once: true,
9625 passive: false,
9626 capture: true
9627 }
9628 }]);
9629 setTimeout(unbind);
9630 }
9631
9632 completed();
9633 store.dispatch(drop({
9634 reason: reason
9635 }));
9636 }
9637
9638 return _extends({
9639 isActive: function isActive() {
9640 return _isActive({
9641 expected: 'DRAGGING',
9642 phase: phase,
9643 isLockActive: isLockActive,
9644 shouldWarn: false
9645 });
9646 },
9647 shouldRespectForcePress: getShouldRespectForcePress,
9648 drop: function drop(options) {
9649 return finish('DROP', options);
9650 },
9651 cancel: function cancel(options) {
9652 return finish('CANCEL', options);
9653 }
9654 }, args.actions);
9655 }
9656
9657 function fluidLift(clientSelection) {
9658 var move$1 = rafSchd(function (client) {
9659 tryDispatchWhenDragging(function () {
9660 return move({
9661 client: client
9662 });
9663 });
9664 });
9665 var api = lift$1({
9666 liftActionArgs: {
9667 id: draggableId,
9668 clientSelection: clientSelection,
9669 movementMode: 'FLUID'
9670 },
9671 cleanup: function cleanup() {
9672 return move$1.cancel();
9673 },
9674 actions: {
9675 move: move$1
9676 }
9677 });
9678 return _extends({}, api, {
9679 move: move$1
9680 });
9681 }
9682
9683 function snapLift() {
9684 var actions = {
9685 moveUp: function moveUp$1() {
9686 return tryDispatchWhenDragging(moveUp);
9687 },
9688 moveRight: function moveRight$1() {
9689 return tryDispatchWhenDragging(moveRight);
9690 },
9691 moveDown: function moveDown$1() {
9692 return tryDispatchWhenDragging(moveDown);
9693 },
9694 moveLeft: function moveLeft$1() {
9695 return tryDispatchWhenDragging(moveLeft);
9696 }
9697 };
9698 return lift$1({
9699 liftActionArgs: {
9700 id: draggableId,
9701 clientSelection: getBorderBoxCenterPosition(el),
9702 movementMode: 'SNAP'
9703 },
9704 cleanup: noop,
9705 actions: actions
9706 });
9707 }
9708
9709 function abortPreDrag() {
9710 var shouldRelease = _isActive({
9711 expected: 'PRE_DRAG',
9712 phase: phase,
9713 isLockActive: isLockActive,
9714 shouldWarn: true
9715 });
9716
9717 if (shouldRelease) {
9718 lockAPI.release();
9719 }
9720 }
9721
9722 var preDrag = {
9723 isActive: function isActive() {
9724 return _isActive({
9725 expected: 'PRE_DRAG',
9726 phase: phase,
9727 isLockActive: isLockActive,
9728 shouldWarn: false
9729 });
9730 },
9731 shouldRespectForcePress: getShouldRespectForcePress,
9732 fluidLift: fluidLift,
9733 snapLift: snapLift,
9734 abort: abortPreDrag
9735 };
9736 return preDrag;
9737 }
9738
9739 var defaultSensors = [useMouseSensor, useKeyboardSensor, useTouchSensor];
9740 function useSensorMarshal(_ref4) {
9741 var contextId = _ref4.contextId,
9742 store = _ref4.store,
9743 registry = _ref4.registry,
9744 customSensors = _ref4.customSensors,
9745 enableDefaultSensors = _ref4.enableDefaultSensors;
9746 var useSensors = [].concat(enableDefaultSensors ? defaultSensors : [], customSensors || []);
9747 var lockAPI = React.useState(function () {
9748 return create();
9749 })[0];
9750 var tryAbandonLock = useCallback(function tryAbandonLock(previous, current) {
9751 if (previous.isDragging && !current.isDragging) {
9752 lockAPI.tryAbandon();
9753 }
9754 }, [lockAPI]);
9755 useIsomorphicLayoutEffect$1(function listenToStore() {
9756 var previous = store.getState();
9757 var unsubscribe = store.subscribe(function () {
9758 var current = store.getState();
9759 tryAbandonLock(previous, current);
9760 previous = current;
9761 });
9762 return unsubscribe;
9763 }, [lockAPI, store, tryAbandonLock]);
9764 useIsomorphicLayoutEffect$1(function () {
9765 return lockAPI.tryAbandon;
9766 }, [lockAPI.tryAbandon]);
9767 var canGetLock = useCallback(function (draggableId) {
9768 return canStart({
9769 lockAPI: lockAPI,
9770 registry: registry,
9771 store: store,
9772 draggableId: draggableId
9773 });
9774 }, [lockAPI, registry, store]);
9775 var tryGetLock = useCallback(function (draggableId, forceStop, options) {
9776 return tryStart({
9777 lockAPI: lockAPI,
9778 registry: registry,
9779 contextId: contextId,
9780 store: store,
9781 draggableId: draggableId,
9782 forceSensorStop: forceStop,
9783 sourceEvent: options && options.sourceEvent ? options.sourceEvent : null
9784 });
9785 }, [contextId, lockAPI, registry, store]);
9786 var findClosestDraggableId = useCallback(function (event) {
9787 return tryGetClosestDraggableIdFromEvent(contextId, event);
9788 }, [contextId]);
9789 var findOptionsForDraggable = useCallback(function (id) {
9790 var entry = registry.draggable.findById(id);
9791 return entry ? entry.options : null;
9792 }, [registry.draggable]);
9793 var tryReleaseLock = useCallback(function tryReleaseLock() {
9794 if (!lockAPI.isClaimed()) {
9795 return;
9796 }
9797
9798 lockAPI.tryAbandon();
9799
9800 if (store.getState().phase !== 'IDLE') {
9801 store.dispatch(flush());
9802 }
9803 }, [lockAPI, store]);
9804 var isLockClaimed = useCallback(lockAPI.isClaimed, [lockAPI]);
9805 var api = useMemo(function () {
9806 return {
9807 canGetLock: canGetLock,
9808 tryGetLock: tryGetLock,
9809 findClosestDraggableId: findClosestDraggableId,
9810 findOptionsForDraggable: findOptionsForDraggable,
9811 tryReleaseLock: tryReleaseLock,
9812 isLockClaimed: isLockClaimed
9813 };
9814 }, [canGetLock, tryGetLock, findClosestDraggableId, findOptionsForDraggable, tryReleaseLock, isLockClaimed]);
9815 useValidateSensorHooks(useSensors);
9816
9817 for (var i = 0; i < useSensors.length; i++) {
9818 useSensors[i](api);
9819 }
9820 }
9821
9822 var createResponders = function createResponders(props) {
9823 return {
9824 onBeforeCapture: props.onBeforeCapture,
9825 onBeforeDragStart: props.onBeforeDragStart,
9826 onDragStart: props.onDragStart,
9827 onDragEnd: props.onDragEnd,
9828 onDragUpdate: props.onDragUpdate
9829 };
9830 };
9831
9832 function getStore(lazyRef) {
9833 !lazyRef.current ? invariant(false, 'Could not find store from lazy ref') : void 0;
9834 return lazyRef.current;
9835 }
9836
9837 function App(props) {
9838 var contextId = props.contextId,
9839 setCallbacks = props.setCallbacks,
9840 sensors = props.sensors,
9841 nonce = props.nonce,
9842 dragHandleUsageInstructions = props.dragHandleUsageInstructions;
9843 var lazyStoreRef = React.useRef(null);
9844 useStartupValidation();
9845 var lastPropsRef = usePrevious(props);
9846 var getResponders = useCallback(function () {
9847 return createResponders(lastPropsRef.current);
9848 }, [lastPropsRef]);
9849 var announce = useAnnouncer(contextId);
9850 var dragHandleUsageInstructionsId = useHiddenTextElement({
9851 contextId: contextId,
9852 text: dragHandleUsageInstructions
9853 });
9854 var styleMarshal = useStyleMarshal(contextId, nonce);
9855 var lazyDispatch = useCallback(function (action) {
9856 getStore(lazyStoreRef).dispatch(action);
9857 }, []);
9858 var marshalCallbacks = useMemo(function () {
9859 return bindActionCreators({
9860 publishWhileDragging: publishWhileDragging,
9861 updateDroppableScroll: updateDroppableScroll,
9862 updateDroppableIsEnabled: updateDroppableIsEnabled,
9863 updateDroppableIsCombineEnabled: updateDroppableIsCombineEnabled,
9864 collectionStarting: collectionStarting
9865 }, lazyDispatch);
9866 }, [lazyDispatch]);
9867 var registry = useRegistry();
9868 var dimensionMarshal = useMemo(function () {
9869 return createDimensionMarshal(registry, marshalCallbacks);
9870 }, [registry, marshalCallbacks]);
9871 var autoScroller = useMemo(function () {
9872 return createAutoScroller(_extends({
9873 scrollWindow: scrollWindow,
9874 scrollDroppable: dimensionMarshal.scrollDroppable
9875 }, bindActionCreators({
9876 move: move
9877 }, lazyDispatch)));
9878 }, [dimensionMarshal.scrollDroppable, lazyDispatch]);
9879 var focusMarshal = useFocusMarshal(contextId);
9880 var store = useMemo(function () {
9881 return createStore$1({
9882 announce: announce,
9883 autoScroller: autoScroller,
9884 dimensionMarshal: dimensionMarshal,
9885 focusMarshal: focusMarshal,
9886 getResponders: getResponders,
9887 styleMarshal: styleMarshal
9888 });
9889 }, [announce, autoScroller, dimensionMarshal, focusMarshal, getResponders, styleMarshal]);
9890
9891 {
9892 if (lazyStoreRef.current && lazyStoreRef.current !== store) {
9893 warning('unexpected store change') ;
9894 }
9895 }
9896
9897 lazyStoreRef.current = store;
9898 var tryResetStore = useCallback(function () {
9899 var current = getStore(lazyStoreRef);
9900 var state = current.getState();
9901
9902 if (state.phase !== 'IDLE') {
9903 current.dispatch(flush());
9904 }
9905 }, []);
9906 var isDragging = useCallback(function () {
9907 var state = getStore(lazyStoreRef).getState();
9908 return state.isDragging || state.phase === 'DROP_ANIMATING';
9909 }, []);
9910 var appCallbacks = useMemo(function () {
9911 return {
9912 isDragging: isDragging,
9913 tryAbort: tryResetStore
9914 };
9915 }, [isDragging, tryResetStore]);
9916 setCallbacks(appCallbacks);
9917 var getCanLift = useCallback(function (id) {
9918 return canStartDrag(getStore(lazyStoreRef).getState(), id);
9919 }, []);
9920 var getIsMovementAllowed = useCallback(function () {
9921 return isMovementAllowed(getStore(lazyStoreRef).getState());
9922 }, []);
9923 var appContext = useMemo(function () {
9924 return {
9925 marshal: dimensionMarshal,
9926 focus: focusMarshal,
9927 contextId: contextId,
9928 canLift: getCanLift,
9929 isMovementAllowed: getIsMovementAllowed,
9930 dragHandleUsageInstructionsId: dragHandleUsageInstructionsId,
9931 registry: registry
9932 };
9933 }, [contextId, dimensionMarshal, dragHandleUsageInstructionsId, focusMarshal, getCanLift, getIsMovementAllowed, registry]);
9934 useSensorMarshal({
9935 contextId: contextId,
9936 store: store,
9937 registry: registry,
9938 customSensors: sensors,
9939 enableDefaultSensors: props.enableDefaultSensors !== false
9940 });
9941 React.useEffect(function () {
9942 return tryResetStore;
9943 }, [tryResetStore]);
9944 return React__default.createElement(AppContext.Provider, {
9945 value: appContext
9946 }, React__default.createElement(Provider, {
9947 context: StoreContext,
9948 store: store
9949 }, props.children));
9950 }
9951
9952 var count$1 = 0;
9953 function reset$1() {
9954 count$1 = 0;
9955 }
9956 function useInstanceCount() {
9957 return useMemo(function () {
9958 return "" + count$1++;
9959 }, []);
9960 }
9961
9962 function resetServerContext() {
9963 reset$1();
9964 reset();
9965 }
9966 function DragDropContext(props) {
9967 var contextId = useInstanceCount();
9968 var dragHandleUsageInstructions = props.dragHandleUsageInstructions || preset.dragHandleUsageInstructions;
9969 return React__default.createElement(ErrorBoundary, null, function (setCallbacks) {
9970 return React__default.createElement(App, {
9971 nonce: props.nonce,
9972 contextId: contextId,
9973 setCallbacks: setCallbacks,
9974 dragHandleUsageInstructions: dragHandleUsageInstructions,
9975 enableDefaultSensors: props.enableDefaultSensors,
9976 sensors: props.sensors,
9977 onBeforeCapture: props.onBeforeCapture,
9978 onBeforeDragStart: props.onBeforeDragStart,
9979 onDragStart: props.onDragStart,
9980 onDragUpdate: props.onDragUpdate,
9981 onDragEnd: props.onDragEnd
9982 }, props.children);
9983 });
9984 }
9985
9986 var isEqual$1 = function isEqual(base) {
9987 return function (value) {
9988 return base === value;
9989 };
9990 };
9991
9992 var isScroll = isEqual$1('scroll');
9993 var isAuto = isEqual$1('auto');
9994 var isVisible$1 = isEqual$1('visible');
9995
9996 var isEither = function isEither(overflow, fn) {
9997 return fn(overflow.overflowX) || fn(overflow.overflowY);
9998 };
9999
10000 var isBoth = function isBoth(overflow, fn) {
10001 return fn(overflow.overflowX) && fn(overflow.overflowY);
10002 };
10003
10004 var isElementScrollable = function isElementScrollable(el) {
10005 var style = window.getComputedStyle(el);
10006 var overflow = {
10007 overflowX: style.overflowX,
10008 overflowY: style.overflowY
10009 };
10010 return isEither(overflow, isScroll) || isEither(overflow, isAuto);
10011 };
10012
10013 var isBodyScrollable = function isBodyScrollable() {
10014
10015 var body = getBodyElement();
10016 var html = document.documentElement;
10017 !html ? invariant(false) : void 0;
10018
10019 if (!isElementScrollable(body)) {
10020 return false;
10021 }
10022
10023 var htmlStyle = window.getComputedStyle(html);
10024 var htmlOverflow = {
10025 overflowX: htmlStyle.overflowX,
10026 overflowY: htmlStyle.overflowY
10027 };
10028
10029 if (isBoth(htmlOverflow, isVisible$1)) {
10030 return false;
10031 }
10032
10033 warning("\n We have detected that your <body> element might be a scroll container.\n We have found no reliable way of detecting whether the <body> element is a scroll container.\n Under most circumstances a <body> scroll bar will be on the <html> element (document.documentElement)\n\n Because we cannot determine if the <body> is a scroll container, and generally it is not one,\n we will be treating the <body> as *not* a scroll container\n\n More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/how-we-detect-scroll-containers.md\n ") ;
10034 return false;
10035 };
10036
10037 var getClosestScrollable = function getClosestScrollable(el) {
10038 if (el == null) {
10039 return null;
10040 }
10041
10042 if (el === document.body) {
10043 return isBodyScrollable() ? el : null;
10044 }
10045
10046 if (el === document.documentElement) {
10047 return null;
10048 }
10049
10050 if (!isElementScrollable(el)) {
10051 return getClosestScrollable(el.parentElement);
10052 }
10053
10054 return el;
10055 };
10056
10057 var checkForNestedScrollContainers = (function (scrollable) {
10058 if (!scrollable) {
10059 return;
10060 }
10061
10062 var anotherScrollParent = getClosestScrollable(scrollable.parentElement);
10063
10064 if (!anotherScrollParent) {
10065 return;
10066 }
10067
10068 warning("\n Droppable: unsupported nested scroll container detected.\n A Droppable can only have one scroll parent (which can be itself)\n Nested scroll containers are currently not supported.\n\n We hope to support nested scroll containers soon: https://github.com/atlassian/react-beautiful-dnd/issues/131\n ") ;
10069 });
10070
10071 var getScroll$1 = (function (el) {
10072 return {
10073 x: el.scrollLeft,
10074 y: el.scrollTop
10075 };
10076 });
10077
10078 var getIsFixed = function getIsFixed(el) {
10079 if (!el) {
10080 return false;
10081 }
10082
10083 var style = window.getComputedStyle(el);
10084
10085 if (style.position === 'fixed') {
10086 return true;
10087 }
10088
10089 return getIsFixed(el.parentElement);
10090 };
10091
10092 var getEnv = (function (start) {
10093 var closestScrollable = getClosestScrollable(start);
10094 var isFixedOnPage = getIsFixed(start);
10095 return {
10096 closestScrollable: closestScrollable,
10097 isFixedOnPage: isFixedOnPage
10098 };
10099 });
10100
10101 var getDroppableDimension = (function (_ref) {
10102 var descriptor = _ref.descriptor,
10103 isEnabled = _ref.isEnabled,
10104 isCombineEnabled = _ref.isCombineEnabled,
10105 isFixedOnPage = _ref.isFixedOnPage,
10106 direction = _ref.direction,
10107 client = _ref.client,
10108 page = _ref.page,
10109 closest = _ref.closest;
10110
10111 var frame = function () {
10112 if (!closest) {
10113 return null;
10114 }
10115
10116 var scrollSize = closest.scrollSize,
10117 frameClient = closest.client;
10118 var maxScroll = getMaxScroll({
10119 scrollHeight: scrollSize.scrollHeight,
10120 scrollWidth: scrollSize.scrollWidth,
10121 height: frameClient.paddingBox.height,
10122 width: frameClient.paddingBox.width
10123 });
10124 return {
10125 pageMarginBox: closest.page.marginBox,
10126 frameClient: frameClient,
10127 scrollSize: scrollSize,
10128 shouldClipSubject: closest.shouldClipSubject,
10129 scroll: {
10130 initial: closest.scroll,
10131 current: closest.scroll,
10132 max: maxScroll,
10133 diff: {
10134 value: origin,
10135 displacement: origin
10136 }
10137 }
10138 };
10139 }();
10140
10141 var axis = direction === 'vertical' ? vertical : horizontal;
10142 var subject = getSubject({
10143 page: page,
10144 withPlaceholder: null,
10145 axis: axis,
10146 frame: frame
10147 });
10148 var dimension = {
10149 descriptor: descriptor,
10150 isCombineEnabled: isCombineEnabled,
10151 isFixedOnPage: isFixedOnPage,
10152 axis: axis,
10153 isEnabled: isEnabled,
10154 client: client,
10155 page: page,
10156 frame: frame,
10157 subject: subject
10158 };
10159 return dimension;
10160 });
10161
10162 var getClient = function getClient(targetRef, closestScrollable) {
10163 var base = getBox(targetRef);
10164
10165 if (!closestScrollable) {
10166 return base;
10167 }
10168
10169 if (targetRef !== closestScrollable) {
10170 return base;
10171 }
10172
10173 var top = base.paddingBox.top - closestScrollable.scrollTop;
10174 var left = base.paddingBox.left - closestScrollable.scrollLeft;
10175 var bottom = top + closestScrollable.scrollHeight;
10176 var right = left + closestScrollable.scrollWidth;
10177 var paddingBox = {
10178 top: top,
10179 right: right,
10180 bottom: bottom,
10181 left: left
10182 };
10183 var borderBox = expand(paddingBox, base.border);
10184 var client = createBox({
10185 borderBox: borderBox,
10186 margin: base.margin,
10187 border: base.border,
10188 padding: base.padding
10189 });
10190 return client;
10191 };
10192
10193 var getDimension = (function (_ref) {
10194 var ref = _ref.ref,
10195 descriptor = _ref.descriptor,
10196 env = _ref.env,
10197 windowScroll = _ref.windowScroll,
10198 direction = _ref.direction,
10199 isDropDisabled = _ref.isDropDisabled,
10200 isCombineEnabled = _ref.isCombineEnabled,
10201 shouldClipSubject = _ref.shouldClipSubject;
10202 var closestScrollable = env.closestScrollable;
10203 var client = getClient(ref, closestScrollable);
10204 var page = withScroll(client, windowScroll);
10205
10206 var closest = function () {
10207 if (!closestScrollable) {
10208 return null;
10209 }
10210
10211 var frameClient = getBox(closestScrollable);
10212 var scrollSize = {
10213 scrollHeight: closestScrollable.scrollHeight,
10214 scrollWidth: closestScrollable.scrollWidth
10215 };
10216 return {
10217 client: frameClient,
10218 page: withScroll(frameClient, windowScroll),
10219 scroll: getScroll$1(closestScrollable),
10220 scrollSize: scrollSize,
10221 shouldClipSubject: shouldClipSubject
10222 };
10223 }();
10224
10225 var dimension = getDroppableDimension({
10226 descriptor: descriptor,
10227 isEnabled: !isDropDisabled,
10228 isCombineEnabled: isCombineEnabled,
10229 isFixedOnPage: env.isFixedOnPage,
10230 direction: direction,
10231 client: client,
10232 page: page,
10233 closest: closest
10234 });
10235 return dimension;
10236 });
10237
10238 var immediate = {
10239 passive: false
10240 };
10241 var delayed = {
10242 passive: true
10243 };
10244 var getListenerOptions = (function (options) {
10245 return options.shouldPublishImmediately ? immediate : delayed;
10246 });
10247
10248 function useRequiredContext(Context) {
10249 var result = React.useContext(Context);
10250 !result ? invariant(false, 'Could not find required context') : void 0;
10251 return result;
10252 }
10253
10254 var getClosestScrollableFromDrag = function getClosestScrollableFromDrag(dragging) {
10255 return dragging && dragging.env.closestScrollable || null;
10256 };
10257
10258 function useDroppablePublisher(args) {
10259 var whileDraggingRef = React.useRef(null);
10260 var appContext = useRequiredContext(AppContext);
10261 var uniqueId = useUniqueId('droppable');
10262 var registry = appContext.registry,
10263 marshal = appContext.marshal;
10264 var previousRef = usePrevious(args);
10265 var descriptor = useMemo(function () {
10266 return {
10267 id: args.droppableId,
10268 type: args.type,
10269 mode: args.mode
10270 };
10271 }, [args.droppableId, args.mode, args.type]);
10272 var publishedDescriptorRef = React.useRef(descriptor);
10273 var memoizedUpdateScroll = useMemo(function () {
10274 return memoizeOne(function (x, y) {
10275 !whileDraggingRef.current ? invariant(false, 'Can only update scroll when dragging') : void 0;
10276 var scroll = {
10277 x: x,
10278 y: y
10279 };
10280 marshal.updateDroppableScroll(descriptor.id, scroll);
10281 });
10282 }, [descriptor.id, marshal]);
10283 var getClosestScroll = useCallback(function () {
10284 var dragging = whileDraggingRef.current;
10285
10286 if (!dragging || !dragging.env.closestScrollable) {
10287 return origin;
10288 }
10289
10290 return getScroll$1(dragging.env.closestScrollable);
10291 }, []);
10292 var updateScroll = useCallback(function () {
10293 var scroll = getClosestScroll();
10294 memoizedUpdateScroll(scroll.x, scroll.y);
10295 }, [getClosestScroll, memoizedUpdateScroll]);
10296 var scheduleScrollUpdate = useMemo(function () {
10297 return rafSchd(updateScroll);
10298 }, [updateScroll]);
10299 var onClosestScroll = useCallback(function () {
10300 var dragging = whileDraggingRef.current;
10301 var closest = getClosestScrollableFromDrag(dragging);
10302 !(dragging && closest) ? invariant(false, 'Could not find scroll options while scrolling') : void 0;
10303 var options = dragging.scrollOptions;
10304
10305 if (options.shouldPublishImmediately) {
10306 updateScroll();
10307 return;
10308 }
10309
10310 scheduleScrollUpdate();
10311 }, [scheduleScrollUpdate, updateScroll]);
10312 var getDimensionAndWatchScroll = useCallback(function (windowScroll, options) {
10313 !!whileDraggingRef.current ? invariant(false, 'Cannot collect a droppable while a drag is occurring') : void 0;
10314 var previous = previousRef.current;
10315 var ref = previous.getDroppableRef();
10316 !ref ? invariant(false, 'Cannot collect without a droppable ref') : void 0;
10317 var env = getEnv(ref);
10318 var dragging = {
10319 ref: ref,
10320 descriptor: descriptor,
10321 env: env,
10322 scrollOptions: options
10323 };
10324 whileDraggingRef.current = dragging;
10325 var dimension = getDimension({
10326 ref: ref,
10327 descriptor: descriptor,
10328 env: env,
10329 windowScroll: windowScroll,
10330 direction: previous.direction,
10331 isDropDisabled: previous.isDropDisabled,
10332 isCombineEnabled: previous.isCombineEnabled,
10333 shouldClipSubject: !previous.ignoreContainerClipping
10334 });
10335 var scrollable = env.closestScrollable;
10336
10337 if (scrollable) {
10338 scrollable.setAttribute(scrollContainer.contextId, appContext.contextId);
10339 scrollable.addEventListener('scroll', onClosestScroll, getListenerOptions(dragging.scrollOptions));
10340
10341 {
10342 checkForNestedScrollContainers(scrollable);
10343 }
10344 }
10345
10346 return dimension;
10347 }, [appContext.contextId, descriptor, onClosestScroll, previousRef]);
10348 var getScrollWhileDragging = useCallback(function () {
10349 var dragging = whileDraggingRef.current;
10350 var closest = getClosestScrollableFromDrag(dragging);
10351 !(dragging && closest) ? invariant(false, 'Can only recollect Droppable client for Droppables that have a scroll container') : void 0;
10352 return getScroll$1(closest);
10353 }, []);
10354 var dragStopped = useCallback(function () {
10355 var dragging = whileDraggingRef.current;
10356 !dragging ? invariant(false, 'Cannot stop drag when no active drag') : void 0;
10357 var closest = getClosestScrollableFromDrag(dragging);
10358 whileDraggingRef.current = null;
10359
10360 if (!closest) {
10361 return;
10362 }
10363
10364 scheduleScrollUpdate.cancel();
10365 closest.removeAttribute(scrollContainer.contextId);
10366 closest.removeEventListener('scroll', onClosestScroll, getListenerOptions(dragging.scrollOptions));
10367 }, [onClosestScroll, scheduleScrollUpdate]);
10368 var scroll = useCallback(function (change) {
10369 var dragging = whileDraggingRef.current;
10370 !dragging ? invariant(false, 'Cannot scroll when there is no drag') : void 0;
10371 var closest = getClosestScrollableFromDrag(dragging);
10372 !closest ? invariant(false, 'Cannot scroll a droppable with no closest scrollable') : void 0;
10373 closest.scrollTop += change.y;
10374 closest.scrollLeft += change.x;
10375 }, []);
10376 var callbacks = useMemo(function () {
10377 return {
10378 getDimensionAndWatchScroll: getDimensionAndWatchScroll,
10379 getScrollWhileDragging: getScrollWhileDragging,
10380 dragStopped: dragStopped,
10381 scroll: scroll
10382 };
10383 }, [dragStopped, getDimensionAndWatchScroll, getScrollWhileDragging, scroll]);
10384 var entry = useMemo(function () {
10385 return {
10386 uniqueId: uniqueId,
10387 descriptor: descriptor,
10388 callbacks: callbacks
10389 };
10390 }, [callbacks, descriptor, uniqueId]);
10391 useIsomorphicLayoutEffect$1(function () {
10392 publishedDescriptorRef.current = entry.descriptor;
10393 registry.droppable.register(entry);
10394 return function () {
10395 if (whileDraggingRef.current) {
10396 warning('Unsupported: changing the droppableId or type of a Droppable during a drag') ;
10397 dragStopped();
10398 }
10399
10400 registry.droppable.unregister(entry);
10401 };
10402 }, [callbacks, descriptor, dragStopped, entry, marshal, registry.droppable]);
10403 useIsomorphicLayoutEffect$1(function () {
10404 if (!whileDraggingRef.current) {
10405 return;
10406 }
10407
10408 marshal.updateDroppableIsEnabled(publishedDescriptorRef.current.id, !args.isDropDisabled);
10409 }, [args.isDropDisabled, marshal]);
10410 useIsomorphicLayoutEffect$1(function () {
10411 if (!whileDraggingRef.current) {
10412 return;
10413 }
10414
10415 marshal.updateDroppableIsCombineEnabled(publishedDescriptorRef.current.id, args.isCombineEnabled);
10416 }, [args.isCombineEnabled, marshal]);
10417 }
10418
10419 function noop$2() {}
10420
10421 var empty = {
10422 width: 0,
10423 height: 0,
10424 margin: noSpacing$1
10425 };
10426
10427 var getSize = function getSize(_ref) {
10428 var isAnimatingOpenOnMount = _ref.isAnimatingOpenOnMount,
10429 placeholder = _ref.placeholder,
10430 animate = _ref.animate;
10431
10432 if (isAnimatingOpenOnMount) {
10433 return empty;
10434 }
10435
10436 if (animate === 'close') {
10437 return empty;
10438 }
10439
10440 return {
10441 height: placeholder.client.borderBox.height,
10442 width: placeholder.client.borderBox.width,
10443 margin: placeholder.client.margin
10444 };
10445 };
10446
10447 var getStyle = function getStyle(_ref2) {
10448 var isAnimatingOpenOnMount = _ref2.isAnimatingOpenOnMount,
10449 placeholder = _ref2.placeholder,
10450 animate = _ref2.animate;
10451 var size = getSize({
10452 isAnimatingOpenOnMount: isAnimatingOpenOnMount,
10453 placeholder: placeholder,
10454 animate: animate
10455 });
10456 return {
10457 display: placeholder.display,
10458 boxSizing: 'border-box',
10459 width: size.width,
10460 height: size.height,
10461 marginTop: size.margin.top,
10462 marginRight: size.margin.right,
10463 marginBottom: size.margin.bottom,
10464 marginLeft: size.margin.left,
10465 flexShrink: '0',
10466 flexGrow: '0',
10467 pointerEvents: 'none',
10468 transition: animate !== 'none' ? transitions.placeholder : null
10469 };
10470 };
10471
10472 function Placeholder(props) {
10473 var animateOpenTimerRef = React.useRef(null);
10474 var tryClearAnimateOpenTimer = useCallback(function () {
10475 if (!animateOpenTimerRef.current) {
10476 return;
10477 }
10478
10479 clearTimeout(animateOpenTimerRef.current);
10480 animateOpenTimerRef.current = null;
10481 }, []);
10482 var animate = props.animate,
10483 onTransitionEnd = props.onTransitionEnd,
10484 onClose = props.onClose,
10485 contextId = props.contextId;
10486
10487 var _useState = React.useState(props.animate === 'open'),
10488 isAnimatingOpenOnMount = _useState[0],
10489 setIsAnimatingOpenOnMount = _useState[1];
10490
10491 React.useEffect(function () {
10492 if (!isAnimatingOpenOnMount) {
10493 return noop$2;
10494 }
10495
10496 if (animate !== 'open') {
10497 tryClearAnimateOpenTimer();
10498 setIsAnimatingOpenOnMount(false);
10499 return noop$2;
10500 }
10501
10502 if (animateOpenTimerRef.current) {
10503 return noop$2;
10504 }
10505
10506 animateOpenTimerRef.current = setTimeout(function () {
10507 animateOpenTimerRef.current = null;
10508 setIsAnimatingOpenOnMount(false);
10509 });
10510 return tryClearAnimateOpenTimer;
10511 }, [animate, isAnimatingOpenOnMount, tryClearAnimateOpenTimer]);
10512 var onSizeChangeEnd = useCallback(function (event) {
10513 if (event.propertyName !== 'height') {
10514 return;
10515 }
10516
10517 onTransitionEnd();
10518
10519 if (animate === 'close') {
10520 onClose();
10521 }
10522 }, [animate, onClose, onTransitionEnd]);
10523 var style = getStyle({
10524 isAnimatingOpenOnMount: isAnimatingOpenOnMount,
10525 animate: props.animate,
10526 placeholder: props.placeholder
10527 });
10528 return React__default.createElement(props.placeholder.tagName, {
10529 style: style,
10530 'data-rbd-placeholder-context-id': contextId,
10531 onTransitionEnd: onSizeChangeEnd,
10532 ref: props.innerRef
10533 });
10534 }
10535
10536 var Placeholder$1 = React__default.memo(Placeholder);
10537
10538 var DroppableContext = React__default.createContext(null);
10539
10540 function checkIsValidInnerRef(el) {
10541 !(el && isHtmlElement(el)) ? invariant(false, "\n provided.innerRef has not been provided with a HTMLElement.\n\n You can find a guide on using the innerRef callback functions at:\n https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/using-inner-ref.md\n ") : void 0;
10542 }
10543
10544 function isBoolean(value) {
10545 return typeof value === 'boolean';
10546 }
10547
10548 function runChecks(args, checks) {
10549 checks.forEach(function (check) {
10550 return check(args);
10551 });
10552 }
10553
10554 var shared = [function required(_ref) {
10555 var props = _ref.props;
10556 !props.droppableId ? invariant(false, 'A Droppable requires a droppableId prop') : void 0;
10557 !(typeof props.droppableId === 'string') ? invariant(false, "A Droppable requires a [string] droppableId. Provided: [" + typeof props.droppableId + "]") : void 0;
10558 }, function _boolean(_ref2) {
10559 var props = _ref2.props;
10560 !isBoolean(props.isDropDisabled) ? invariant(false, 'isDropDisabled must be a boolean') : void 0;
10561 !isBoolean(props.isCombineEnabled) ? invariant(false, 'isCombineEnabled must be a boolean') : void 0;
10562 !isBoolean(props.ignoreContainerClipping) ? invariant(false, 'ignoreContainerClipping must be a boolean') : void 0;
10563 }, function ref(_ref3) {
10564 var getDroppableRef = _ref3.getDroppableRef;
10565 checkIsValidInnerRef(getDroppableRef());
10566 }];
10567 var standard = [function placeholder(_ref4) {
10568 var props = _ref4.props,
10569 getPlaceholderRef = _ref4.getPlaceholderRef;
10570
10571 if (!props.placeholder) {
10572 return;
10573 }
10574
10575 var ref = getPlaceholderRef();
10576
10577 if (ref) {
10578 return;
10579 }
10580
10581 warning("\n Droppable setup issue [droppableId: \"" + props.droppableId + "\"]:\n DroppableProvided > placeholder could not be found.\n\n Please be sure to add the {provided.placeholder} React Node as a child of your Droppable.\n More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/api/droppable.md\n ") ;
10582 }];
10583 var virtual = [function hasClone(_ref5) {
10584 var props = _ref5.props;
10585 !props.renderClone ? invariant(false, 'Must provide a clone render function (renderClone) for virtual lists') : void 0;
10586 }, function hasNoPlaceholder(_ref6) {
10587 var getPlaceholderRef = _ref6.getPlaceholderRef;
10588 !!getPlaceholderRef() ? invariant(false, 'Expected virtual list to not have a placeholder') : void 0;
10589 }];
10590 function useValidation(args) {
10591 useDevSetupWarning(function () {
10592 runChecks(args, shared);
10593
10594 if (args.props.mode === 'standard') {
10595 runChecks(args, standard);
10596 }
10597
10598 if (args.props.mode === 'virtual') {
10599 runChecks(args, virtual);
10600 }
10601 });
10602 }
10603
10604 var AnimateInOut = function (_React$PureComponent) {
10605 _inheritsLoose(AnimateInOut, _React$PureComponent);
10606
10607 function AnimateInOut() {
10608 var _this;
10609
10610 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10611 args[_key] = arguments[_key];
10612 }
10613
10614 _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
10615 _this.state = {
10616 isVisible: Boolean(_this.props.on),
10617 data: _this.props.on,
10618 animate: _this.props.shouldAnimate && _this.props.on ? 'open' : 'none'
10619 };
10620
10621 _this.onClose = function () {
10622 if (_this.state.animate !== 'close') {
10623 return;
10624 }
10625
10626 _this.setState({
10627 isVisible: false
10628 });
10629 };
10630
10631 return _this;
10632 }
10633
10634 AnimateInOut.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
10635 if (!props.shouldAnimate) {
10636 return {
10637 isVisible: Boolean(props.on),
10638 data: props.on,
10639 animate: 'none'
10640 };
10641 }
10642
10643 if (props.on) {
10644 return {
10645 isVisible: true,
10646 data: props.on,
10647 animate: 'open'
10648 };
10649 }
10650
10651 if (state.isVisible) {
10652 return {
10653 isVisible: true,
10654 data: state.data,
10655 animate: 'close'
10656 };
10657 }
10658
10659 return {
10660 isVisible: false,
10661 animate: 'close',
10662 data: null
10663 };
10664 };
10665
10666 var _proto = AnimateInOut.prototype;
10667
10668 _proto.render = function render() {
10669 if (!this.state.isVisible) {
10670 return null;
10671 }
10672
10673 var provided = {
10674 onClose: this.onClose,
10675 data: this.state.data,
10676 animate: this.state.animate
10677 };
10678 return this.props.children(provided);
10679 };
10680
10681 return AnimateInOut;
10682 }(React__default.PureComponent);
10683
10684 var zIndexOptions = {
10685 dragging: 5000,
10686 dropAnimating: 4500
10687 };
10688
10689 var getDraggingTransition = function getDraggingTransition(shouldAnimateDragMovement, dropping) {
10690 if (dropping) {
10691 return transitions.drop(dropping.duration);
10692 }
10693
10694 if (shouldAnimateDragMovement) {
10695 return transitions.snap;
10696 }
10697
10698 return transitions.fluid;
10699 };
10700
10701 var getDraggingOpacity = function getDraggingOpacity(isCombining, isDropAnimating) {
10702 if (!isCombining) {
10703 return null;
10704 }
10705
10706 return isDropAnimating ? combine.opacity.drop : combine.opacity.combining;
10707 };
10708
10709 var getShouldDraggingAnimate = function getShouldDraggingAnimate(dragging) {
10710 if (dragging.forceShouldAnimate != null) {
10711 return dragging.forceShouldAnimate;
10712 }
10713
10714 return dragging.mode === 'SNAP';
10715 };
10716
10717 function getDraggingStyle(dragging) {
10718 var dimension = dragging.dimension;
10719 var box = dimension.client;
10720 var offset = dragging.offset,
10721 combineWith = dragging.combineWith,
10722 dropping = dragging.dropping;
10723 var isCombining = Boolean(combineWith);
10724 var shouldAnimate = getShouldDraggingAnimate(dragging);
10725 var isDropAnimating = Boolean(dropping);
10726 var transform = isDropAnimating ? transforms.drop(offset, isCombining) : transforms.moveTo(offset);
10727 var style = {
10728 position: 'fixed',
10729 top: box.marginBox.top,
10730 left: box.marginBox.left,
10731 boxSizing: 'border-box',
10732 width: box.borderBox.width,
10733 height: box.borderBox.height,
10734 transition: getDraggingTransition(shouldAnimate, dropping),
10735 transform: transform,
10736 opacity: getDraggingOpacity(isCombining, isDropAnimating),
10737 zIndex: isDropAnimating ? zIndexOptions.dropAnimating : zIndexOptions.dragging,
10738 pointerEvents: 'none'
10739 };
10740 return style;
10741 }
10742
10743 function getSecondaryStyle(secondary) {
10744 return {
10745 transform: transforms.moveTo(secondary.offset),
10746 transition: secondary.shouldAnimateDisplacement ? null : 'none'
10747 };
10748 }
10749
10750 function getStyle$1(mapped) {
10751 return mapped.type === 'DRAGGING' ? getDraggingStyle(mapped) : getSecondaryStyle(mapped);
10752 }
10753
10754 function getDimension$1(descriptor, el, windowScroll) {
10755 if (windowScroll === void 0) {
10756 windowScroll = origin;
10757 }
10758
10759 var computedStyles = window.getComputedStyle(el);
10760 var borderBox = el.getBoundingClientRect();
10761 var client = calculateBox(borderBox, computedStyles);
10762 var page = withScroll(client, windowScroll);
10763 var placeholder = {
10764 client: client,
10765 tagName: el.tagName.toLowerCase(),
10766 display: computedStyles.display
10767 };
10768 var displaceBy = {
10769 x: client.marginBox.width,
10770 y: client.marginBox.height
10771 };
10772 var dimension = {
10773 descriptor: descriptor,
10774 placeholder: placeholder,
10775 displaceBy: displaceBy,
10776 client: client,
10777 page: page
10778 };
10779 return dimension;
10780 }
10781
10782 function useDraggablePublisher(args) {
10783 var uniqueId = useUniqueId('draggable');
10784 var descriptor = args.descriptor,
10785 registry = args.registry,
10786 getDraggableRef = args.getDraggableRef,
10787 canDragInteractiveElements = args.canDragInteractiveElements,
10788 shouldRespectForcePress = args.shouldRespectForcePress,
10789 isEnabled = args.isEnabled;
10790 var options = useMemo(function () {
10791 return {
10792 canDragInteractiveElements: canDragInteractiveElements,
10793 shouldRespectForcePress: shouldRespectForcePress,
10794 isEnabled: isEnabled
10795 };
10796 }, [canDragInteractiveElements, isEnabled, shouldRespectForcePress]);
10797 var getDimension = useCallback(function (windowScroll) {
10798 var el = getDraggableRef();
10799 !el ? invariant(false, 'Cannot get dimension when no ref is set') : void 0;
10800 return getDimension$1(descriptor, el, windowScroll);
10801 }, [descriptor, getDraggableRef]);
10802 var entry = useMemo(function () {
10803 return {
10804 uniqueId: uniqueId,
10805 descriptor: descriptor,
10806 options: options,
10807 getDimension: getDimension
10808 };
10809 }, [descriptor, getDimension, options, uniqueId]);
10810 var publishedRef = React.useRef(entry);
10811 var isFirstPublishRef = React.useRef(true);
10812 useIsomorphicLayoutEffect$1(function () {
10813 registry.draggable.register(publishedRef.current);
10814 return function () {
10815 return registry.draggable.unregister(publishedRef.current);
10816 };
10817 }, [registry.draggable]);
10818 useIsomorphicLayoutEffect$1(function () {
10819 if (isFirstPublishRef.current) {
10820 isFirstPublishRef.current = false;
10821 return;
10822 }
10823
10824 var last = publishedRef.current;
10825 publishedRef.current = entry;
10826 registry.draggable.update(entry, last);
10827 }, [entry, registry.draggable]);
10828 }
10829
10830 function useValidation$1(props, contextId, getRef) {
10831 useDevSetupWarning(function () {
10832 function prefix(id) {
10833 return "Draggable[id: " + id + "]: ";
10834 }
10835
10836 var id = props.draggableId;
10837 !id ? "development" !== "production" ? invariant(false, 'Draggable requires a draggableId') : invariant(false) : void 0;
10838 !(typeof id === 'string') ? "development" !== "production" ? invariant(false, "Draggable requires a [string] draggableId.\n Provided: [type: " + typeof id + "] (value: " + id + ")") : invariant(false) : void 0;
10839 !isInteger(props.index) ? "development" !== "production" ? invariant(false, prefix(id) + " requires an integer index prop") : invariant(false) : void 0;
10840
10841 if (props.mapped.type === 'DRAGGING') {
10842 return;
10843 }
10844
10845 checkIsValidInnerRef(getRef());
10846
10847 if (props.isEnabled) {
10848 !findDragHandle(contextId, id) ? "development" !== "production" ? invariant(false, prefix(id) + " Unable to find drag handle") : invariant(false) : void 0;
10849 }
10850 });
10851 }
10852 function useClonePropValidation(isClone) {
10853 useDev(function () {
10854 var initialRef = React.useRef(isClone);
10855 useDevSetupWarning(function () {
10856 !(isClone === initialRef.current) ? "development" !== "production" ? invariant(false, 'Draggable isClone prop value changed during component life') : invariant(false) : void 0;
10857 }, [isClone]);
10858 });
10859 }
10860
10861 function preventHtml5Dnd(event) {
10862 event.preventDefault();
10863 }
10864
10865 function Draggable(props) {
10866 var ref = React.useRef(null);
10867 var setRef = useCallback(function (el) {
10868 ref.current = el;
10869 }, []);
10870 var getRef = useCallback(function () {
10871 return ref.current;
10872 }, []);
10873
10874 var _useRequiredContext = useRequiredContext(AppContext),
10875 contextId = _useRequiredContext.contextId,
10876 dragHandleUsageInstructionsId = _useRequiredContext.dragHandleUsageInstructionsId,
10877 registry = _useRequiredContext.registry;
10878
10879 var _useRequiredContext2 = useRequiredContext(DroppableContext),
10880 type = _useRequiredContext2.type,
10881 droppableId = _useRequiredContext2.droppableId;
10882
10883 var descriptor = useMemo(function () {
10884 return {
10885 id: props.draggableId,
10886 index: props.index,
10887 type: type,
10888 droppableId: droppableId
10889 };
10890 }, [props.draggableId, props.index, type, droppableId]);
10891 var children = props.children,
10892 draggableId = props.draggableId,
10893 isEnabled = props.isEnabled,
10894 shouldRespectForcePress = props.shouldRespectForcePress,
10895 canDragInteractiveElements = props.canDragInteractiveElements,
10896 isClone = props.isClone,
10897 mapped = props.mapped,
10898 dropAnimationFinishedAction = props.dropAnimationFinished;
10899 useValidation$1(props, contextId, getRef);
10900 useClonePropValidation(isClone);
10901
10902 if (!isClone) {
10903 var forPublisher = useMemo(function () {
10904 return {
10905 descriptor: descriptor,
10906 registry: registry,
10907 getDraggableRef: getRef,
10908 canDragInteractiveElements: canDragInteractiveElements,
10909 shouldRespectForcePress: shouldRespectForcePress,
10910 isEnabled: isEnabled
10911 };
10912 }, [descriptor, registry, getRef, canDragInteractiveElements, shouldRespectForcePress, isEnabled]);
10913 useDraggablePublisher(forPublisher);
10914 }
10915
10916 var dragHandleProps = useMemo(function () {
10917 return isEnabled ? {
10918 tabIndex: 0,
10919 role: 'button',
10920 'aria-describedby': dragHandleUsageInstructionsId,
10921 'data-rbd-drag-handle-draggable-id': draggableId,
10922 'data-rbd-drag-handle-context-id': contextId,
10923 draggable: false,
10924 onDragStart: preventHtml5Dnd
10925 } : null;
10926 }, [contextId, dragHandleUsageInstructionsId, draggableId, isEnabled]);
10927 var onMoveEnd = useCallback(function (event) {
10928 if (mapped.type !== 'DRAGGING') {
10929 return;
10930 }
10931
10932 if (!mapped.dropping) {
10933 return;
10934 }
10935
10936 if (event.propertyName !== 'transform') {
10937 return;
10938 }
10939
10940 dropAnimationFinishedAction();
10941 }, [dropAnimationFinishedAction, mapped]);
10942 var provided = useMemo(function () {
10943 var style = getStyle$1(mapped);
10944 var onTransitionEnd = mapped.type === 'DRAGGING' && mapped.dropping ? onMoveEnd : null;
10945 var result = {
10946 innerRef: setRef,
10947 draggableProps: {
10948 'data-rbd-draggable-context-id': contextId,
10949 'data-rbd-draggable-id': draggableId,
10950 style: style,
10951 onTransitionEnd: onTransitionEnd
10952 },
10953 dragHandleProps: dragHandleProps
10954 };
10955 return result;
10956 }, [contextId, dragHandleProps, draggableId, mapped, onMoveEnd, setRef]);
10957 var rubric = useMemo(function () {
10958 return {
10959 draggableId: descriptor.id,
10960 type: descriptor.type,
10961 source: {
10962 index: descriptor.index,
10963 droppableId: descriptor.droppableId
10964 }
10965 };
10966 }, [descriptor.droppableId, descriptor.id, descriptor.index, descriptor.type]);
10967 return children(provided, mapped.snapshot, rubric);
10968 }
10969
10970 var isStrictEqual = (function (a, b) {
10971 return a === b;
10972 });
10973
10974 var whatIsDraggedOverFromResult = (function (result) {
10975 var combine = result.combine,
10976 destination = result.destination;
10977
10978 if (destination) {
10979 return destination.droppableId;
10980 }
10981
10982 if (combine) {
10983 return combine.droppableId;
10984 }
10985
10986 return null;
10987 });
10988
10989 var getCombineWithFromResult = function getCombineWithFromResult(result) {
10990 return result.combine ? result.combine.draggableId : null;
10991 };
10992
10993 var getCombineWithFromImpact = function getCombineWithFromImpact(impact) {
10994 return impact.at && impact.at.type === 'COMBINE' ? impact.at.combine.draggableId : null;
10995 };
10996
10997 function getDraggableSelector() {
10998 var memoizedOffset = memoizeOne(function (x, y) {
10999 return {
11000 x: x,
11001 y: y
11002 };
11003 });
11004 var getMemoizedSnapshot = memoizeOne(function (mode, isClone, draggingOver, combineWith, dropping) {
11005 return {
11006 isDragging: true,
11007 isClone: isClone,
11008 isDropAnimating: Boolean(dropping),
11009 dropAnimation: dropping,
11010 mode: mode,
11011 draggingOver: draggingOver,
11012 combineWith: combineWith,
11013 combineTargetFor: null
11014 };
11015 });
11016 var getMemoizedProps = memoizeOne(function (offset, mode, dimension, isClone, draggingOver, combineWith, forceShouldAnimate) {
11017 return {
11018 mapped: {
11019 type: 'DRAGGING',
11020 dropping: null,
11021 draggingOver: draggingOver,
11022 combineWith: combineWith,
11023 mode: mode,
11024 offset: offset,
11025 dimension: dimension,
11026 forceShouldAnimate: forceShouldAnimate,
11027 snapshot: getMemoizedSnapshot(mode, isClone, draggingOver, combineWith, null)
11028 }
11029 };
11030 });
11031
11032 var selector = function selector(state, ownProps) {
11033 if (state.isDragging) {
11034 if (state.critical.draggable.id !== ownProps.draggableId) {
11035 return null;
11036 }
11037
11038 var offset = state.current.client.offset;
11039 var dimension = state.dimensions.draggables[ownProps.draggableId];
11040 var draggingOver = whatIsDraggedOver(state.impact);
11041 var combineWith = getCombineWithFromImpact(state.impact);
11042 var forceShouldAnimate = state.forceShouldAnimate;
11043 return getMemoizedProps(memoizedOffset(offset.x, offset.y), state.movementMode, dimension, ownProps.isClone, draggingOver, combineWith, forceShouldAnimate);
11044 }
11045
11046 if (state.phase === 'DROP_ANIMATING') {
11047 var completed = state.completed;
11048
11049 if (completed.result.draggableId !== ownProps.draggableId) {
11050 return null;
11051 }
11052
11053 var isClone = ownProps.isClone;
11054 var _dimension = state.dimensions.draggables[ownProps.draggableId];
11055 var result = completed.result;
11056 var mode = result.mode;
11057
11058 var _draggingOver = whatIsDraggedOverFromResult(result);
11059
11060 var _combineWith = getCombineWithFromResult(result);
11061
11062 var duration = state.dropDuration;
11063 var dropping = {
11064 duration: duration,
11065 curve: curves.drop,
11066 moveTo: state.newHomeClientOffset,
11067 opacity: _combineWith ? combine.opacity.drop : null,
11068 scale: _combineWith ? combine.scale.drop : null
11069 };
11070 return {
11071 mapped: {
11072 type: 'DRAGGING',
11073 offset: state.newHomeClientOffset,
11074 dimension: _dimension,
11075 dropping: dropping,
11076 draggingOver: _draggingOver,
11077 combineWith: _combineWith,
11078 mode: mode,
11079 forceShouldAnimate: null,
11080 snapshot: getMemoizedSnapshot(mode, isClone, _draggingOver, _combineWith, dropping)
11081 }
11082 };
11083 }
11084
11085 return null;
11086 };
11087
11088 return selector;
11089 }
11090
11091 function getSecondarySnapshot(combineTargetFor) {
11092 return {
11093 isDragging: false,
11094 isDropAnimating: false,
11095 isClone: false,
11096 dropAnimation: null,
11097 mode: null,
11098 draggingOver: null,
11099 combineTargetFor: combineTargetFor,
11100 combineWith: null
11101 };
11102 }
11103
11104 var atRest = {
11105 mapped: {
11106 type: 'SECONDARY',
11107 offset: origin,
11108 combineTargetFor: null,
11109 shouldAnimateDisplacement: true,
11110 snapshot: getSecondarySnapshot(null)
11111 }
11112 };
11113
11114 function getSecondarySelector() {
11115 var memoizedOffset = memoizeOne(function (x, y) {
11116 return {
11117 x: x,
11118 y: y
11119 };
11120 });
11121 var getMemoizedSnapshot = memoizeOne(getSecondarySnapshot);
11122 var getMemoizedProps = memoizeOne(function (offset, combineTargetFor, shouldAnimateDisplacement) {
11123 if (combineTargetFor === void 0) {
11124 combineTargetFor = null;
11125 }
11126
11127 return {
11128 mapped: {
11129 type: 'SECONDARY',
11130 offset: offset,
11131 combineTargetFor: combineTargetFor,
11132 shouldAnimateDisplacement: shouldAnimateDisplacement,
11133 snapshot: getMemoizedSnapshot(combineTargetFor)
11134 }
11135 };
11136 });
11137
11138 var getFallback = function getFallback(combineTargetFor) {
11139 return combineTargetFor ? getMemoizedProps(origin, combineTargetFor, true) : null;
11140 };
11141
11142 var getProps = function getProps(ownId, draggingId, impact, afterCritical) {
11143 var visualDisplacement = impact.displaced.visible[ownId];
11144 var isAfterCriticalInVirtualList = Boolean(afterCritical.inVirtualList && afterCritical.effected[ownId]);
11145 var combine = tryGetCombine(impact);
11146 var combineTargetFor = combine && combine.draggableId === ownId ? draggingId : null;
11147
11148 if (!visualDisplacement) {
11149 if (!isAfterCriticalInVirtualList) {
11150 return getFallback(combineTargetFor);
11151 }
11152
11153 if (impact.displaced.invisible[ownId]) {
11154 return null;
11155 }
11156
11157 var change = negate(afterCritical.displacedBy.point);
11158
11159 var _offset = memoizedOffset(change.x, change.y);
11160
11161 return getMemoizedProps(_offset, combineTargetFor, true);
11162 }
11163
11164 if (isAfterCriticalInVirtualList) {
11165 return getFallback(combineTargetFor);
11166 }
11167
11168 var displaceBy = impact.displacedBy.point;
11169 var offset = memoizedOffset(displaceBy.x, displaceBy.y);
11170 return getMemoizedProps(offset, combineTargetFor, visualDisplacement.shouldAnimate);
11171 };
11172
11173 var selector = function selector(state, ownProps) {
11174 if (state.isDragging) {
11175 if (state.critical.draggable.id === ownProps.draggableId) {
11176 return null;
11177 }
11178
11179 return getProps(ownProps.draggableId, state.critical.draggable.id, state.impact, state.afterCritical);
11180 }
11181
11182 if (state.phase === 'DROP_ANIMATING') {
11183 var completed = state.completed;
11184
11185 if (completed.result.draggableId === ownProps.draggableId) {
11186 return null;
11187 }
11188
11189 return getProps(ownProps.draggableId, completed.result.draggableId, completed.impact, completed.afterCritical);
11190 }
11191
11192 return null;
11193 };
11194
11195 return selector;
11196 }
11197
11198 var makeMapStateToProps = function makeMapStateToProps() {
11199 var draggingSelector = getDraggableSelector();
11200 var secondarySelector = getSecondarySelector();
11201
11202 var selector = function selector(state, ownProps) {
11203 return draggingSelector(state, ownProps) || secondarySelector(state, ownProps) || atRest;
11204 };
11205
11206 return selector;
11207 };
11208 var mapDispatchToProps = {
11209 dropAnimationFinished: dropAnimationFinished
11210 };
11211 var ConnectedDraggable = connect(makeMapStateToProps, mapDispatchToProps, null, {
11212 context: StoreContext,
11213 pure: true,
11214 areStatePropsEqual: isStrictEqual
11215 })(Draggable);
11216
11217 function PrivateDraggable(props) {
11218 var droppableContext = useRequiredContext(DroppableContext);
11219 var isUsingCloneFor = droppableContext.isUsingCloneFor;
11220
11221 if (isUsingCloneFor === props.draggableId && !props.isClone) {
11222 return null;
11223 }
11224
11225 return React__default.createElement(ConnectedDraggable, props);
11226 }
11227 function PublicDraggable(props) {
11228 var isEnabled = typeof props.isDragDisabled === 'boolean' ? !props.isDragDisabled : true;
11229 var canDragInteractiveElements = Boolean(props.disableInteractiveElementBlocking);
11230 var shouldRespectForcePress = Boolean(props.shouldRespectForcePress);
11231 return React__default.createElement(PrivateDraggable, _extends({}, props, {
11232 isClone: false,
11233 isEnabled: isEnabled,
11234 canDragInteractiveElements: canDragInteractiveElements,
11235 shouldRespectForcePress: shouldRespectForcePress
11236 }));
11237 }
11238
11239 function Droppable(props) {
11240 var appContext = React.useContext(AppContext);
11241 !appContext ? invariant(false, 'Could not find app context') : void 0;
11242 var contextId = appContext.contextId,
11243 isMovementAllowed = appContext.isMovementAllowed;
11244 var droppableRef = React.useRef(null);
11245 var placeholderRef = React.useRef(null);
11246 var children = props.children,
11247 droppableId = props.droppableId,
11248 type = props.type,
11249 mode = props.mode,
11250 direction = props.direction,
11251 ignoreContainerClipping = props.ignoreContainerClipping,
11252 isDropDisabled = props.isDropDisabled,
11253 isCombineEnabled = props.isCombineEnabled,
11254 snapshot = props.snapshot,
11255 useClone = props.useClone,
11256 updateViewportMaxScroll = props.updateViewportMaxScroll,
11257 getContainerForClone = props.getContainerForClone;
11258 var getDroppableRef = useCallback(function () {
11259 return droppableRef.current;
11260 }, []);
11261 var setDroppableRef = useCallback(function (value) {
11262 droppableRef.current = value;
11263 }, []);
11264 var getPlaceholderRef = useCallback(function () {
11265 return placeholderRef.current;
11266 }, []);
11267 var setPlaceholderRef = useCallback(function (value) {
11268 placeholderRef.current = value;
11269 }, []);
11270 useValidation({
11271 props: props,
11272 getDroppableRef: getDroppableRef,
11273 getPlaceholderRef: getPlaceholderRef
11274 });
11275 var onPlaceholderTransitionEnd = useCallback(function () {
11276 if (isMovementAllowed()) {
11277 updateViewportMaxScroll({
11278 maxScroll: getMaxWindowScroll()
11279 });
11280 }
11281 }, [isMovementAllowed, updateViewportMaxScroll]);
11282 useDroppablePublisher({
11283 droppableId: droppableId,
11284 type: type,
11285 mode: mode,
11286 direction: direction,
11287 isDropDisabled: isDropDisabled,
11288 isCombineEnabled: isCombineEnabled,
11289 ignoreContainerClipping: ignoreContainerClipping,
11290 getDroppableRef: getDroppableRef
11291 });
11292 var placeholder = React__default.createElement(AnimateInOut, {
11293 on: props.placeholder,
11294 shouldAnimate: props.shouldAnimatePlaceholder
11295 }, function (_ref) {
11296 var onClose = _ref.onClose,
11297 data = _ref.data,
11298 animate = _ref.animate;
11299 return React__default.createElement(Placeholder$1, {
11300 placeholder: data,
11301 onClose: onClose,
11302 innerRef: setPlaceholderRef,
11303 animate: animate,
11304 contextId: contextId,
11305 onTransitionEnd: onPlaceholderTransitionEnd
11306 });
11307 });
11308 var provided = useMemo(function () {
11309 return {
11310 innerRef: setDroppableRef,
11311 placeholder: placeholder,
11312 droppableProps: {
11313 'data-rbd-droppable-id': droppableId,
11314 'data-rbd-droppable-context-id': contextId
11315 }
11316 };
11317 }, [contextId, droppableId, placeholder, setDroppableRef]);
11318 var isUsingCloneFor = useClone ? useClone.dragging.draggableId : null;
11319 var droppableContext = useMemo(function () {
11320 return {
11321 droppableId: droppableId,
11322 type: type,
11323 isUsingCloneFor: isUsingCloneFor
11324 };
11325 }, [droppableId, isUsingCloneFor, type]);
11326
11327 function getClone() {
11328 if (!useClone) {
11329 return null;
11330 }
11331
11332 var dragging = useClone.dragging,
11333 render = useClone.render;
11334 var node = React__default.createElement(PrivateDraggable, {
11335 draggableId: dragging.draggableId,
11336 index: dragging.source.index,
11337 isClone: true,
11338 isEnabled: true,
11339 shouldRespectForcePress: false,
11340 canDragInteractiveElements: true
11341 }, function (draggableProvided, draggableSnapshot) {
11342 return render(draggableProvided, draggableSnapshot, dragging);
11343 });
11344 return ReactDOM__default.createPortal(node, getContainerForClone());
11345 }
11346
11347 return React__default.createElement(DroppableContext.Provider, {
11348 value: droppableContext
11349 }, children(provided, snapshot), getClone());
11350 }
11351
11352 var isMatchingType = function isMatchingType(type, critical) {
11353 return type === critical.droppable.type;
11354 };
11355
11356 var getDraggable = function getDraggable(critical, dimensions) {
11357 return dimensions.draggables[critical.draggable.id];
11358 };
11359
11360 var makeMapStateToProps$1 = function makeMapStateToProps() {
11361 var idleWithAnimation = {
11362 placeholder: null,
11363 shouldAnimatePlaceholder: true,
11364 snapshot: {
11365 isDraggingOver: false,
11366 draggingOverWith: null,
11367 draggingFromThisWith: null,
11368 isUsingPlaceholder: false
11369 },
11370 useClone: null
11371 };
11372
11373 var idleWithoutAnimation = _extends({}, idleWithAnimation, {
11374 shouldAnimatePlaceholder: false
11375 });
11376
11377 var getDraggableRubric = memoizeOne(function (descriptor) {
11378 return {
11379 draggableId: descriptor.id,
11380 type: descriptor.type,
11381 source: {
11382 index: descriptor.index,
11383 droppableId: descriptor.droppableId
11384 }
11385 };
11386 });
11387 var getMapProps = memoizeOne(function (id, isEnabled, isDraggingOverForConsumer, isDraggingOverForImpact, dragging, renderClone) {
11388 var draggableId = dragging.descriptor.id;
11389 var isHome = dragging.descriptor.droppableId === id;
11390
11391 if (isHome) {
11392 var useClone = renderClone ? {
11393 render: renderClone,
11394 dragging: getDraggableRubric(dragging.descriptor)
11395 } : null;
11396 var _snapshot = {
11397 isDraggingOver: isDraggingOverForConsumer,
11398 draggingOverWith: isDraggingOverForConsumer ? draggableId : null,
11399 draggingFromThisWith: draggableId,
11400 isUsingPlaceholder: true
11401 };
11402 return {
11403 placeholder: dragging.placeholder,
11404 shouldAnimatePlaceholder: false,
11405 snapshot: _snapshot,
11406 useClone: useClone
11407 };
11408 }
11409
11410 if (!isEnabled) {
11411 return idleWithoutAnimation;
11412 }
11413
11414 if (!isDraggingOverForImpact) {
11415 return idleWithAnimation;
11416 }
11417
11418 var snapshot = {
11419 isDraggingOver: isDraggingOverForConsumer,
11420 draggingOverWith: draggableId,
11421 draggingFromThisWith: null,
11422 isUsingPlaceholder: true
11423 };
11424 return {
11425 placeholder: dragging.placeholder,
11426 shouldAnimatePlaceholder: true,
11427 snapshot: snapshot,
11428 useClone: null
11429 };
11430 });
11431
11432 var selector = function selector(state, ownProps) {
11433 var id = ownProps.droppableId;
11434 var type = ownProps.type;
11435 var isEnabled = !ownProps.isDropDisabled;
11436 var renderClone = ownProps.renderClone;
11437
11438 if (state.isDragging) {
11439 var critical = state.critical;
11440
11441 if (!isMatchingType(type, critical)) {
11442 return idleWithoutAnimation;
11443 }
11444
11445 var dragging = getDraggable(critical, state.dimensions);
11446 var isDraggingOver = whatIsDraggedOver(state.impact) === id;
11447 return getMapProps(id, isEnabled, isDraggingOver, isDraggingOver, dragging, renderClone);
11448 }
11449
11450 if (state.phase === 'DROP_ANIMATING') {
11451 var completed = state.completed;
11452
11453 if (!isMatchingType(type, completed.critical)) {
11454 return idleWithoutAnimation;
11455 }
11456
11457 var _dragging = getDraggable(completed.critical, state.dimensions);
11458
11459 return getMapProps(id, isEnabled, whatIsDraggedOverFromResult(completed.result) === id, whatIsDraggedOver(completed.impact) === id, _dragging, renderClone);
11460 }
11461
11462 if (state.phase === 'IDLE' && state.completed && !state.shouldFlush) {
11463 var _completed = state.completed;
11464
11465 if (!isMatchingType(type, _completed.critical)) {
11466 return idleWithoutAnimation;
11467 }
11468
11469 var wasOver = whatIsDraggedOver(_completed.impact) === id;
11470 var wasCombining = Boolean(_completed.impact.at && _completed.impact.at.type === 'COMBINE');
11471 var isHome = _completed.critical.droppable.id === id;
11472
11473 if (wasOver) {
11474 return wasCombining ? idleWithAnimation : idleWithoutAnimation;
11475 }
11476
11477 if (isHome) {
11478 return idleWithAnimation;
11479 }
11480
11481 return idleWithoutAnimation;
11482 }
11483
11484 return idleWithoutAnimation;
11485 };
11486
11487 return selector;
11488 };
11489 var mapDispatchToProps$1 = {
11490 updateViewportMaxScroll: updateViewportMaxScroll
11491 };
11492
11493 function getBody() {
11494 !document.body ? invariant(false, 'document.body is not ready') : void 0;
11495 return document.body;
11496 }
11497
11498 var defaultProps = {
11499 mode: 'standard',
11500 type: 'DEFAULT',
11501 direction: 'vertical',
11502 isDropDisabled: false,
11503 isCombineEnabled: false,
11504 ignoreContainerClipping: false,
11505 renderClone: null,
11506 getContainerForClone: getBody
11507 };
11508 var ConnectedDroppable = connect(makeMapStateToProps$1, mapDispatchToProps$1, null, {
11509 context: StoreContext,
11510 pure: true,
11511 areStatePropsEqual: isStrictEqual
11512 })(Droppable);
11513 ConnectedDroppable.defaultProps = defaultProps;
11514
11515 exports.DragDropContext = DragDropContext;
11516 exports.Draggable = PublicDraggable;
11517 exports.Droppable = ConnectedDroppable;
11518 exports.resetServerContext = resetServerContext;
11519 exports.useKeyboardSensor = useKeyboardSensor;
11520 exports.useMouseSensor = useMouseSensor;
11521 exports.useTouchSensor = useTouchSensor;
11522
11523 Object.defineProperty(exports, '__esModule', { value: true });
11524
11525})));