UNPKG

243 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7var React = require('react');
8var React__default = _interopDefault(React);
9var _inheritsLoose = _interopDefault(require('@babel/runtime/helpers/inheritsLoose'));
10var _extends = _interopDefault(require('@babel/runtime/helpers/extends'));
11var redux = require('redux');
12var reactRedux = require('react-redux');
13var useMemoOne = require('use-memo-one');
14var cssBoxModel = require('css-box-model');
15var memoizeOne = _interopDefault(require('memoize-one'));
16var rafSchd = _interopDefault(require('raf-schd'));
17var ReactDOM = _interopDefault(require('react-dom'));
18
19var isProduction = process.env.NODE_ENV === 'production';
20var spacesAndTabs = /[ \t]{2,}/g;
21var lineStartWithSpaces = /^[ \t]*/gm;
22
23var clean = function clean(value) {
24 return value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();
25};
26
27var getDevMessage = function getDevMessage(message) {
28 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");
29};
30
31var getFormattedMessage = function getFormattedMessage(message) {
32 return [getDevMessage(message), 'color: #00C584; font-size: 1.2em; font-weight: bold;', 'line-height: 1.5', 'color: #723874;'];
33};
34var isDisabledFlag = '__react-beautiful-dnd-disable-dev-warnings';
35function log(type, message) {
36 var _console;
37
38 if (isProduction) {
39 return;
40 }
41
42 if (typeof window !== 'undefined' && window[isDisabledFlag]) {
43 return;
44 }
45
46 (_console = console)[type].apply(_console, getFormattedMessage(message));
47}
48var warning = log.bind(null, 'warn');
49var error = log.bind(null, 'error');
50
51function noop() {}
52
53function getOptions(shared, fromBinding) {
54 return _extends({}, shared, {}, fromBinding);
55}
56
57function bindEvents(el, bindings, sharedOptions) {
58 var unbindings = bindings.map(function (binding) {
59 var options = getOptions(sharedOptions, binding.options);
60 el.addEventListener(binding.eventName, binding.fn, options);
61 return function unbind() {
62 el.removeEventListener(binding.eventName, binding.fn, options);
63 };
64 });
65 return function unbindAll() {
66 unbindings.forEach(function (unbind) {
67 unbind();
68 });
69 };
70}
71
72var isProduction$1 = process.env.NODE_ENV === 'production';
73var prefix = 'Invariant failed';
74function RbdInvariant(message) {
75 this.message = message;
76}
77
78RbdInvariant.prototype.toString = function toString() {
79 return this.message;
80};
81
82function invariant(condition, message) {
83 if (condition) {
84 return;
85 }
86
87 if (isProduction$1) {
88 throw new RbdInvariant(prefix);
89 } else {
90 throw new RbdInvariant(prefix + ": " + (message || ''));
91 }
92}
93
94var ErrorBoundary = function (_React$Component) {
95 _inheritsLoose(ErrorBoundary, _React$Component);
96
97 function ErrorBoundary() {
98 var _this;
99
100 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
101 args[_key] = arguments[_key];
102 }
103
104 _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
105 _this.callbacks = null;
106 _this.unbind = noop;
107
108 _this.onWindowError = function (event) {
109 var callbacks = _this.getCallbacks();
110
111 if (callbacks.isDragging()) {
112 callbacks.tryAbort();
113 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
114 }
115
116 var err = event.error;
117
118 if (err instanceof RbdInvariant) {
119 event.preventDefault();
120
121 if (process.env.NODE_ENV !== 'production') {
122 error(err.message);
123 }
124 }
125 };
126
127 _this.getCallbacks = function () {
128 if (!_this.callbacks) {
129 throw new Error('Unable to find AppCallbacks in <ErrorBoundary/>');
130 }
131
132 return _this.callbacks;
133 };
134
135 _this.setCallbacks = function (callbacks) {
136 _this.callbacks = callbacks;
137 };
138
139 return _this;
140 }
141
142 var _proto = ErrorBoundary.prototype;
143
144 _proto.componentDidMount = function componentDidMount() {
145 this.unbind = bindEvents(window, [{
146 eventName: 'error',
147 fn: this.onWindowError
148 }]);
149 };
150
151 _proto.componentDidCatch = function componentDidCatch(err) {
152 if (err instanceof RbdInvariant) {
153 if (process.env.NODE_ENV !== 'production') {
154 error(err.message);
155 }
156
157 this.setState({});
158 return;
159 }
160
161 throw err;
162 };
163
164 _proto.componentWillUnmount = function componentWillUnmount() {
165 this.unbind();
166 };
167
168 _proto.render = function render() {
169 return this.props.children(this.setCallbacks);
170 };
171
172 return ErrorBoundary;
173}(React__default.Component);
174
175var 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";
176
177var position = function position(index) {
178 return index + 1;
179};
180
181var onDragStart = function onDragStart(start) {
182 return "\n You have lifted an item in position " + position(start.source.index) + "\n";
183};
184
185var withLocation = function withLocation(source, destination) {
186 var isInHomeList = source.droppableId === destination.droppableId;
187 var startPosition = position(source.index);
188 var endPosition = position(destination.index);
189
190 if (isInHomeList) {
191 return "\n You have moved the item from position " + startPosition + "\n to position " + endPosition + "\n ";
192 }
193
194 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 ";
195};
196
197var withCombine = function withCombine(id, source, combine) {
198 var inHomeList = source.droppableId === combine.droppableId;
199
200 if (inHomeList) {
201 return "\n The item " + id + "\n has been combined with " + combine.draggableId;
202 }
203
204 return "\n The item " + id + "\n in list " + source.droppableId + "\n has been combined with " + combine.draggableId + "\n in list " + combine.droppableId + "\n ";
205};
206
207var onDragUpdate = function onDragUpdate(update) {
208 var location = update.destination;
209
210 if (location) {
211 return withLocation(update.source, location);
212 }
213
214 var combine = update.combine;
215
216 if (combine) {
217 return withCombine(update.draggableId, update.source, combine);
218 }
219
220 return 'You are over an area that cannot be dropped on';
221};
222
223var returnedToStart = function returnedToStart(source) {
224 return "\n The item has returned to its starting position\n of " + position(source.index) + "\n";
225};
226
227var onDragEnd = function onDragEnd(result) {
228 if (result.reason === 'CANCEL') {
229 return "\n Movement cancelled.\n " + returnedToStart(result.source) + "\n ";
230 }
231
232 var location = result.destination;
233 var combine = result.combine;
234
235 if (location) {
236 return "\n You have dropped the item.\n " + withLocation(result.source, location) + "\n ";
237 }
238
239 if (combine) {
240 return "\n You have dropped the item.\n " + withCombine(result.draggableId, result.source, combine) + "\n ";
241 }
242
243 return "\n The item has been dropped while not over a drop area.\n " + returnedToStart(result.source) + "\n ";
244};
245
246var preset = {
247 dragHandleUsageInstructions: dragHandleUsageInstructions,
248 onDragStart: onDragStart,
249 onDragUpdate: onDragUpdate,
250 onDragEnd: onDragEnd
251};
252
253var origin = {
254 x: 0,
255 y: 0
256};
257var add = function add(point1, point2) {
258 return {
259 x: point1.x + point2.x,
260 y: point1.y + point2.y
261 };
262};
263var subtract = function subtract(point1, point2) {
264 return {
265 x: point1.x - point2.x,
266 y: point1.y - point2.y
267 };
268};
269var isEqual = function isEqual(point1, point2) {
270 return point1.x === point2.x && point1.y === point2.y;
271};
272var negate = function negate(point) {
273 return {
274 x: point.x !== 0 ? -point.x : 0,
275 y: point.y !== 0 ? -point.y : 0
276 };
277};
278var patch = function patch(line, value, otherValue) {
279 var _ref;
280
281 if (otherValue === void 0) {
282 otherValue = 0;
283 }
284
285 return _ref = {}, _ref[line] = value, _ref[line === 'x' ? 'y' : 'x'] = otherValue, _ref;
286};
287var distance = function distance(point1, point2) {
288 return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
289};
290var closest = function closest(target, points) {
291 return Math.min.apply(Math, points.map(function (point) {
292 return distance(target, point);
293 }));
294};
295var apply = function apply(fn) {
296 return function (point) {
297 return {
298 x: fn(point.x),
299 y: fn(point.y)
300 };
301 };
302};
303
304var executeClip = (function (frame, subject) {
305 var result = cssBoxModel.getRect({
306 top: Math.max(subject.top, frame.top),
307 right: Math.min(subject.right, frame.right),
308 bottom: Math.min(subject.bottom, frame.bottom),
309 left: Math.max(subject.left, frame.left)
310 });
311
312 if (result.width <= 0 || result.height <= 0) {
313 return null;
314 }
315
316 return result;
317});
318
319var offsetByPosition = function offsetByPosition(spacing, point) {
320 return {
321 top: spacing.top + point.y,
322 left: spacing.left + point.x,
323 bottom: spacing.bottom + point.y,
324 right: spacing.right + point.x
325 };
326};
327var getCorners = function getCorners(spacing) {
328 return [{
329 x: spacing.left,
330 y: spacing.top
331 }, {
332 x: spacing.right,
333 y: spacing.top
334 }, {
335 x: spacing.left,
336 y: spacing.bottom
337 }, {
338 x: spacing.right,
339 y: spacing.bottom
340 }];
341};
342var noSpacing = {
343 top: 0,
344 right: 0,
345 bottom: 0,
346 left: 0
347};
348
349var scroll = function scroll(target, frame) {
350 if (!frame) {
351 return target;
352 }
353
354 return offsetByPosition(target, frame.scroll.diff.displacement);
355};
356
357var increase = function increase(target, axis, withPlaceholder) {
358 if (withPlaceholder && withPlaceholder.increasedBy) {
359 var _extends2;
360
361 return _extends({}, target, (_extends2 = {}, _extends2[axis.end] = target[axis.end] + withPlaceholder.increasedBy[axis.line], _extends2));
362 }
363
364 return target;
365};
366
367var clip = function clip(target, frame) {
368 if (frame && frame.shouldClipSubject) {
369 return executeClip(frame.pageMarginBox, target);
370 }
371
372 return cssBoxModel.getRect(target);
373};
374
375var getSubject = (function (_ref) {
376 var page = _ref.page,
377 withPlaceholder = _ref.withPlaceholder,
378 axis = _ref.axis,
379 frame = _ref.frame;
380 var scrolled = scroll(page.marginBox, frame);
381 var increased = increase(scrolled, axis, withPlaceholder);
382 var clipped = clip(increased, frame);
383 return {
384 page: page,
385 withPlaceholder: withPlaceholder,
386 active: clipped
387 };
388});
389
390var scrollDroppable = (function (droppable, newScroll) {
391 !droppable.frame ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
392 var scrollable = droppable.frame;
393 var scrollDiff = subtract(newScroll, scrollable.scroll.initial);
394 var scrollDisplacement = negate(scrollDiff);
395
396 var frame = _extends({}, scrollable, {
397 scroll: {
398 initial: scrollable.scroll.initial,
399 current: newScroll,
400 diff: {
401 value: scrollDiff,
402 displacement: scrollDisplacement
403 },
404 max: scrollable.scroll.max
405 }
406 });
407
408 var subject = getSubject({
409 page: droppable.subject.page,
410 withPlaceholder: droppable.subject.withPlaceholder,
411 axis: droppable.axis,
412 frame: frame
413 });
414
415 var result = _extends({}, droppable, {
416 frame: frame,
417 subject: subject
418 });
419
420 return result;
421});
422
423function isInteger(value) {
424 if (Number.isInteger) {
425 return Number.isInteger(value);
426 }
427
428 return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
429}
430function values(map) {
431 if (Object.values) {
432 return Object.values(map);
433 }
434
435 return Object.keys(map).map(function (key) {
436 return map[key];
437 });
438}
439function findIndex(list, predicate) {
440 if (list.findIndex) {
441 return list.findIndex(predicate);
442 }
443
444 for (var i = 0; i < list.length; i++) {
445 if (predicate(list[i])) {
446 return i;
447 }
448 }
449
450 return -1;
451}
452function find(list, predicate) {
453 if (list.find) {
454 return list.find(predicate);
455 }
456
457 var index = findIndex(list, predicate);
458
459 if (index !== -1) {
460 return list[index];
461 }
462
463 return undefined;
464}
465function toArray(list) {
466 return Array.prototype.slice.call(list);
467}
468
469var toDroppableMap = memoizeOne(function (droppables) {
470 return droppables.reduce(function (previous, current) {
471 previous[current.descriptor.id] = current;
472 return previous;
473 }, {});
474});
475var toDraggableMap = memoizeOne(function (draggables) {
476 return draggables.reduce(function (previous, current) {
477 previous[current.descriptor.id] = current;
478 return previous;
479 }, {});
480});
481var toDroppableList = memoizeOne(function (droppables) {
482 return values(droppables);
483});
484var toDraggableList = memoizeOne(function (draggables) {
485 return values(draggables);
486});
487
488var getDraggablesInsideDroppable = memoizeOne(function (droppableId, draggables) {
489 var result = toDraggableList(draggables).filter(function (draggable) {
490 return droppableId === draggable.descriptor.droppableId;
491 }).sort(function (a, b) {
492 return a.descriptor.index - b.descriptor.index;
493 });
494 return result;
495});
496
497function tryGetDestination(impact) {
498 if (impact.at && impact.at.type === 'REORDER') {
499 return impact.at.destination;
500 }
501
502 return null;
503}
504function tryGetCombine(impact) {
505 if (impact.at && impact.at.type === 'COMBINE') {
506 return impact.at.combine;
507 }
508
509 return null;
510}
511
512var removeDraggableFromList = memoizeOne(function (remove, list) {
513 return list.filter(function (item) {
514 return item.descriptor.id !== remove.descriptor.id;
515 });
516});
517
518var moveToNextCombine = (function (_ref) {
519 var isMovingForward = _ref.isMovingForward,
520 draggable = _ref.draggable,
521 destination = _ref.destination,
522 insideDestination = _ref.insideDestination,
523 previousImpact = _ref.previousImpact;
524
525 if (!destination.isCombineEnabled) {
526 return null;
527 }
528
529 var location = tryGetDestination(previousImpact);
530
531 if (!location) {
532 return null;
533 }
534
535 function getImpact(target) {
536 var at = {
537 type: 'COMBINE',
538 combine: {
539 draggableId: target,
540 droppableId: destination.descriptor.id
541 }
542 };
543 return _extends({}, previousImpact, {
544 at: at
545 });
546 }
547
548 var all = previousImpact.displaced.all;
549 var closestId = all.length ? all[0] : null;
550
551 if (isMovingForward) {
552 return closestId ? getImpact(closestId) : null;
553 }
554
555 var withoutDraggable = removeDraggableFromList(draggable, insideDestination);
556
557 if (!closestId) {
558 if (!withoutDraggable.length) {
559 return null;
560 }
561
562 var last = withoutDraggable[withoutDraggable.length - 1];
563 return getImpact(last.descriptor.id);
564 }
565
566 var indexOfClosest = findIndex(withoutDraggable, function (d) {
567 return d.descriptor.id === closestId;
568 });
569 !(indexOfClosest !== -1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find displaced item in set') : invariant(false) : void 0;
570 var proposedIndex = indexOfClosest - 1;
571
572 if (proposedIndex < 0) {
573 return null;
574 }
575
576 var before = withoutDraggable[proposedIndex];
577 return getImpact(before.descriptor.id);
578});
579
580var isHomeOf = (function (draggable, destination) {
581 return draggable.descriptor.droppableId === destination.descriptor.id;
582});
583
584var noDisplacedBy = {
585 point: origin,
586 value: 0
587};
588var emptyGroups = {
589 invisible: {},
590 visible: {},
591 all: []
592};
593var noImpact = {
594 displaced: emptyGroups,
595 displacedBy: noDisplacedBy,
596 at: null
597};
598
599var isWithin = (function (lowerBound, upperBound) {
600 return function (value) {
601 return lowerBound <= value && value <= upperBound;
602 };
603});
604
605var isPartiallyVisibleThroughFrame = (function (frame) {
606 var isWithinVertical = isWithin(frame.top, frame.bottom);
607 var isWithinHorizontal = isWithin(frame.left, frame.right);
608 return function (subject) {
609 var isContained = isWithinVertical(subject.top) && isWithinVertical(subject.bottom) && isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
610
611 if (isContained) {
612 return true;
613 }
614
615 var isPartiallyVisibleVertically = isWithinVertical(subject.top) || isWithinVertical(subject.bottom);
616 var isPartiallyVisibleHorizontally = isWithinHorizontal(subject.left) || isWithinHorizontal(subject.right);
617 var isPartiallyContained = isPartiallyVisibleVertically && isPartiallyVisibleHorizontally;
618
619 if (isPartiallyContained) {
620 return true;
621 }
622
623 var isBiggerVertically = subject.top < frame.top && subject.bottom > frame.bottom;
624 var isBiggerHorizontally = subject.left < frame.left && subject.right > frame.right;
625 var isTargetBiggerThanFrame = isBiggerVertically && isBiggerHorizontally;
626
627 if (isTargetBiggerThanFrame) {
628 return true;
629 }
630
631 var isTargetBiggerOnOneAxis = isBiggerVertically && isPartiallyVisibleHorizontally || isBiggerHorizontally && isPartiallyVisibleVertically;
632 return isTargetBiggerOnOneAxis;
633 };
634});
635
636var isTotallyVisibleThroughFrame = (function (frame) {
637 var isWithinVertical = isWithin(frame.top, frame.bottom);
638 var isWithinHorizontal = isWithin(frame.left, frame.right);
639 return function (subject) {
640 var isContained = isWithinVertical(subject.top) && isWithinVertical(subject.bottom) && isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
641 return isContained;
642 };
643});
644
645var vertical = {
646 direction: 'vertical',
647 line: 'y',
648 crossAxisLine: 'x',
649 start: 'top',
650 end: 'bottom',
651 size: 'height',
652 crossAxisStart: 'left',
653 crossAxisEnd: 'right',
654 crossAxisSize: 'width'
655};
656var horizontal = {
657 direction: 'horizontal',
658 line: 'x',
659 crossAxisLine: 'y',
660 start: 'left',
661 end: 'right',
662 size: 'width',
663 crossAxisStart: 'top',
664 crossAxisEnd: 'bottom',
665 crossAxisSize: 'height'
666};
667
668var isTotallyVisibleThroughFrameOnAxis = (function (axis) {
669 return function (frame) {
670 var isWithinVertical = isWithin(frame.top, frame.bottom);
671 var isWithinHorizontal = isWithin(frame.left, frame.right);
672 return function (subject) {
673 if (axis === vertical) {
674 return isWithinVertical(subject.top) && isWithinVertical(subject.bottom);
675 }
676
677 return isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
678 };
679 };
680});
681
682var getDroppableDisplaced = function getDroppableDisplaced(target, destination) {
683 var displacement = destination.frame ? destination.frame.scroll.diff.displacement : origin;
684 return offsetByPosition(target, displacement);
685};
686
687var isVisibleInDroppable = function isVisibleInDroppable(target, destination, isVisibleThroughFrameFn) {
688 if (!destination.subject.active) {
689 return false;
690 }
691
692 return isVisibleThroughFrameFn(destination.subject.active)(target);
693};
694
695var isVisibleInViewport = function isVisibleInViewport(target, viewport, isVisibleThroughFrameFn) {
696 return isVisibleThroughFrameFn(viewport)(target);
697};
698
699var isVisible = function isVisible(_ref) {
700 var toBeDisplaced = _ref.target,
701 destination = _ref.destination,
702 viewport = _ref.viewport,
703 withDroppableDisplacement = _ref.withDroppableDisplacement,
704 isVisibleThroughFrameFn = _ref.isVisibleThroughFrameFn;
705 var displacedTarget = withDroppableDisplacement ? getDroppableDisplaced(toBeDisplaced, destination) : toBeDisplaced;
706 return isVisibleInDroppable(displacedTarget, destination, isVisibleThroughFrameFn) && isVisibleInViewport(displacedTarget, viewport, isVisibleThroughFrameFn);
707};
708
709var isPartiallyVisible = function isPartiallyVisible(args) {
710 return isVisible(_extends({}, args, {
711 isVisibleThroughFrameFn: isPartiallyVisibleThroughFrame
712 }));
713};
714var isTotallyVisible = function isTotallyVisible(args) {
715 return isVisible(_extends({}, args, {
716 isVisibleThroughFrameFn: isTotallyVisibleThroughFrame
717 }));
718};
719var isTotallyVisibleOnAxis = function isTotallyVisibleOnAxis(args) {
720 return isVisible(_extends({}, args, {
721 isVisibleThroughFrameFn: isTotallyVisibleThroughFrameOnAxis(args.destination.axis)
722 }));
723};
724
725var getShouldAnimate = function getShouldAnimate(id, last, forceShouldAnimate) {
726 if (typeof forceShouldAnimate === 'boolean') {
727 return forceShouldAnimate;
728 }
729
730 if (!last) {
731 return true;
732 }
733
734 var invisible = last.invisible,
735 visible = last.visible;
736
737 if (invisible[id]) {
738 return false;
739 }
740
741 var previous = visible[id];
742 return previous ? previous.shouldAnimate : true;
743};
744
745function getTarget(draggable, displacedBy) {
746 var marginBox = draggable.page.marginBox;
747 var expandBy = {
748 top: displacedBy.point.y,
749 right: 0,
750 bottom: 0,
751 left: displacedBy.point.x
752 };
753 return cssBoxModel.getRect(cssBoxModel.expand(marginBox, expandBy));
754}
755
756function getDisplacementGroups(_ref) {
757 var afterDragging = _ref.afterDragging,
758 destination = _ref.destination,
759 displacedBy = _ref.displacedBy,
760 viewport = _ref.viewport,
761 forceShouldAnimate = _ref.forceShouldAnimate,
762 last = _ref.last;
763 return afterDragging.reduce(function process(groups, draggable) {
764 var target = getTarget(draggable, displacedBy);
765 var id = draggable.descriptor.id;
766 groups.all.push(id);
767 var isVisible = isPartiallyVisible({
768 target: target,
769 destination: destination,
770 viewport: viewport,
771 withDroppableDisplacement: true
772 });
773
774 if (!isVisible) {
775 groups.invisible[draggable.descriptor.id] = true;
776 return groups;
777 }
778
779 var shouldAnimate = getShouldAnimate(id, last, forceShouldAnimate);
780 var displacement = {
781 draggableId: id,
782 shouldAnimate: shouldAnimate
783 };
784 groups.visible[id] = displacement;
785 return groups;
786 }, {
787 all: [],
788 visible: {},
789 invisible: {}
790 });
791}
792
793function getIndexOfLastItem(draggables, options) {
794 if (!draggables.length) {
795 return 0;
796 }
797
798 var indexOfLastItem = draggables[draggables.length - 1].descriptor.index;
799 return options.inHomeList ? indexOfLastItem : indexOfLastItem + 1;
800}
801
802function goAtEnd(_ref) {
803 var insideDestination = _ref.insideDestination,
804 inHomeList = _ref.inHomeList,
805 displacedBy = _ref.displacedBy,
806 destination = _ref.destination;
807 var newIndex = getIndexOfLastItem(insideDestination, {
808 inHomeList: inHomeList
809 });
810 return {
811 displaced: emptyGroups,
812 displacedBy: displacedBy,
813 at: {
814 type: 'REORDER',
815 destination: {
816 droppableId: destination.descriptor.id,
817 index: newIndex
818 }
819 }
820 };
821}
822
823function calculateReorderImpact(_ref2) {
824 var draggable = _ref2.draggable,
825 insideDestination = _ref2.insideDestination,
826 destination = _ref2.destination,
827 viewport = _ref2.viewport,
828 displacedBy = _ref2.displacedBy,
829 last = _ref2.last,
830 index = _ref2.index,
831 forceShouldAnimate = _ref2.forceShouldAnimate;
832 var inHomeList = isHomeOf(draggable, destination);
833
834 if (index == null) {
835 return goAtEnd({
836 insideDestination: insideDestination,
837 inHomeList: inHomeList,
838 displacedBy: displacedBy,
839 destination: destination
840 });
841 }
842
843 var match = find(insideDestination, function (item) {
844 return item.descriptor.index === index;
845 });
846
847 if (!match) {
848 return goAtEnd({
849 insideDestination: insideDestination,
850 inHomeList: inHomeList,
851 displacedBy: displacedBy,
852 destination: destination
853 });
854 }
855
856 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
857 var sliceFrom = insideDestination.indexOf(match);
858 var impacted = withoutDragging.slice(sliceFrom);
859 var displaced = getDisplacementGroups({
860 afterDragging: impacted,
861 destination: destination,
862 displacedBy: displacedBy,
863 last: last,
864 viewport: viewport.frame,
865 forceShouldAnimate: forceShouldAnimate
866 });
867 return {
868 displaced: displaced,
869 displacedBy: displacedBy,
870 at: {
871 type: 'REORDER',
872 destination: {
873 droppableId: destination.descriptor.id,
874 index: index
875 }
876 }
877 };
878}
879
880function didStartAfterCritical(draggableId, afterCritical) {
881 return Boolean(afterCritical.effected[draggableId]);
882}
883
884var fromCombine = (function (_ref) {
885 var isMovingForward = _ref.isMovingForward,
886 destination = _ref.destination,
887 draggables = _ref.draggables,
888 combine = _ref.combine,
889 afterCritical = _ref.afterCritical;
890
891 if (!destination.isCombineEnabled) {
892 return null;
893 }
894
895 var combineId = combine.draggableId;
896 var combineWith = draggables[combineId];
897 var combineWithIndex = combineWith.descriptor.index;
898 var didCombineWithStartAfterCritical = didStartAfterCritical(combineId, afterCritical);
899
900 if (didCombineWithStartAfterCritical) {
901 if (isMovingForward) {
902 return combineWithIndex;
903 }
904
905 return combineWithIndex - 1;
906 }
907
908 if (isMovingForward) {
909 return combineWithIndex + 1;
910 }
911
912 return combineWithIndex;
913});
914
915var fromReorder = (function (_ref) {
916 var isMovingForward = _ref.isMovingForward,
917 isInHomeList = _ref.isInHomeList,
918 insideDestination = _ref.insideDestination,
919 location = _ref.location;
920
921 if (!insideDestination.length) {
922 return null;
923 }
924
925 var currentIndex = location.index;
926 var proposedIndex = isMovingForward ? currentIndex + 1 : currentIndex - 1;
927 var firstIndex = insideDestination[0].descriptor.index;
928 var lastIndex = insideDestination[insideDestination.length - 1].descriptor.index;
929 var upperBound = isInHomeList ? lastIndex : lastIndex + 1;
930
931 if (proposedIndex < firstIndex) {
932 return null;
933 }
934
935 if (proposedIndex > upperBound) {
936 return null;
937 }
938
939 return proposedIndex;
940});
941
942var moveToNextIndex = (function (_ref) {
943 var isMovingForward = _ref.isMovingForward,
944 isInHomeList = _ref.isInHomeList,
945 draggable = _ref.draggable,
946 draggables = _ref.draggables,
947 destination = _ref.destination,
948 insideDestination = _ref.insideDestination,
949 previousImpact = _ref.previousImpact,
950 viewport = _ref.viewport,
951 afterCritical = _ref.afterCritical;
952 var wasAt = previousImpact.at;
953 !wasAt ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot move in direction without previous impact location') : invariant(false) : void 0;
954
955 if (wasAt.type === 'REORDER') {
956 var _newIndex = fromReorder({
957 isMovingForward: isMovingForward,
958 isInHomeList: isInHomeList,
959 location: wasAt.destination,
960 insideDestination: insideDestination
961 });
962
963 if (_newIndex == null) {
964 return null;
965 }
966
967 return calculateReorderImpact({
968 draggable: draggable,
969 insideDestination: insideDestination,
970 destination: destination,
971 viewport: viewport,
972 last: previousImpact.displaced,
973 displacedBy: previousImpact.displacedBy,
974 index: _newIndex
975 });
976 }
977
978 var newIndex = fromCombine({
979 isMovingForward: isMovingForward,
980 destination: destination,
981 displaced: previousImpact.displaced,
982 draggables: draggables,
983 combine: wasAt.combine,
984 afterCritical: afterCritical
985 });
986
987 if (newIndex == null) {
988 return null;
989 }
990
991 return calculateReorderImpact({
992 draggable: draggable,
993 insideDestination: insideDestination,
994 destination: destination,
995 viewport: viewport,
996 last: previousImpact.displaced,
997 displacedBy: previousImpact.displacedBy,
998 index: newIndex
999 });
1000});
1001
1002var getCombinedItemDisplacement = (function (_ref) {
1003 var displaced = _ref.displaced,
1004 afterCritical = _ref.afterCritical,
1005 combineWith = _ref.combineWith,
1006 displacedBy = _ref.displacedBy;
1007 var isDisplaced = Boolean(displaced.visible[combineWith] || displaced.invisible[combineWith]);
1008
1009 if (didStartAfterCritical(combineWith, afterCritical)) {
1010 return isDisplaced ? origin : negate(displacedBy.point);
1011 }
1012
1013 return isDisplaced ? displacedBy.point : origin;
1014});
1015
1016var whenCombining = (function (_ref) {
1017 var afterCritical = _ref.afterCritical,
1018 impact = _ref.impact,
1019 draggables = _ref.draggables;
1020 var combine = tryGetCombine(impact);
1021 !combine ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
1022 var combineWith = combine.draggableId;
1023 var center = draggables[combineWith].page.borderBox.center;
1024 var displaceBy = getCombinedItemDisplacement({
1025 displaced: impact.displaced,
1026 afterCritical: afterCritical,
1027 combineWith: combineWith,
1028 displacedBy: impact.displacedBy
1029 });
1030 return add(center, displaceBy);
1031});
1032
1033var distanceFromStartToBorderBoxCenter = function distanceFromStartToBorderBoxCenter(axis, box) {
1034 return box.margin[axis.start] + box.borderBox[axis.size] / 2;
1035};
1036
1037var distanceFromEndToBorderBoxCenter = function distanceFromEndToBorderBoxCenter(axis, box) {
1038 return box.margin[axis.end] + box.borderBox[axis.size] / 2;
1039};
1040
1041var getCrossAxisBorderBoxCenter = function getCrossAxisBorderBoxCenter(axis, target, isMoving) {
1042 return target[axis.crossAxisStart] + isMoving.margin[axis.crossAxisStart] + isMoving.borderBox[axis.crossAxisSize] / 2;
1043};
1044
1045var goAfter = function goAfter(_ref) {
1046 var axis = _ref.axis,
1047 moveRelativeTo = _ref.moveRelativeTo,
1048 isMoving = _ref.isMoving;
1049 return patch(axis.line, moveRelativeTo.marginBox[axis.end] + distanceFromStartToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving));
1050};
1051var goBefore = function goBefore(_ref2) {
1052 var axis = _ref2.axis,
1053 moveRelativeTo = _ref2.moveRelativeTo,
1054 isMoving = _ref2.isMoving;
1055 return patch(axis.line, moveRelativeTo.marginBox[axis.start] - distanceFromEndToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving));
1056};
1057var goIntoStart = function goIntoStart(_ref3) {
1058 var axis = _ref3.axis,
1059 moveInto = _ref3.moveInto,
1060 isMoving = _ref3.isMoving;
1061 return patch(axis.line, moveInto.contentBox[axis.start] + distanceFromStartToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveInto.contentBox, isMoving));
1062};
1063
1064var whenReordering = (function (_ref) {
1065 var impact = _ref.impact,
1066 draggable = _ref.draggable,
1067 draggables = _ref.draggables,
1068 droppable = _ref.droppable,
1069 afterCritical = _ref.afterCritical;
1070 var insideDestination = getDraggablesInsideDroppable(droppable.descriptor.id, draggables);
1071 var draggablePage = draggable.page;
1072 var axis = droppable.axis;
1073
1074 if (!insideDestination.length) {
1075 return goIntoStart({
1076 axis: axis,
1077 moveInto: droppable.page,
1078 isMoving: draggablePage
1079 });
1080 }
1081
1082 var displaced = impact.displaced,
1083 displacedBy = impact.displacedBy;
1084 var closestAfter = displaced.all[0];
1085
1086 if (closestAfter) {
1087 var closest = draggables[closestAfter];
1088
1089 if (didStartAfterCritical(closestAfter, afterCritical)) {
1090 return goBefore({
1091 axis: axis,
1092 moveRelativeTo: closest.page,
1093 isMoving: draggablePage
1094 });
1095 }
1096
1097 var withDisplacement = cssBoxModel.offset(closest.page, displacedBy.point);
1098 return goBefore({
1099 axis: axis,
1100 moveRelativeTo: withDisplacement,
1101 isMoving: draggablePage
1102 });
1103 }
1104
1105 var last = insideDestination[insideDestination.length - 1];
1106
1107 if (last.descriptor.id === draggable.descriptor.id) {
1108 return draggablePage.borderBox.center;
1109 }
1110
1111 if (didStartAfterCritical(last.descriptor.id, afterCritical)) {
1112 var page = cssBoxModel.offset(last.page, negate(afterCritical.displacedBy.point));
1113 return goAfter({
1114 axis: axis,
1115 moveRelativeTo: page,
1116 isMoving: draggablePage
1117 });
1118 }
1119
1120 return goAfter({
1121 axis: axis,
1122 moveRelativeTo: last.page,
1123 isMoving: draggablePage
1124 });
1125});
1126
1127var withDroppableDisplacement = (function (droppable, point) {
1128 var frame = droppable.frame;
1129
1130 if (!frame) {
1131 return point;
1132 }
1133
1134 return add(point, frame.scroll.diff.displacement);
1135});
1136
1137var getResultWithoutDroppableDisplacement = function getResultWithoutDroppableDisplacement(_ref) {
1138 var impact = _ref.impact,
1139 draggable = _ref.draggable,
1140 droppable = _ref.droppable,
1141 draggables = _ref.draggables,
1142 afterCritical = _ref.afterCritical;
1143 var original = draggable.page.borderBox.center;
1144 var at = impact.at;
1145
1146 if (!droppable) {
1147 return original;
1148 }
1149
1150 if (!at) {
1151 return original;
1152 }
1153
1154 if (at.type === 'REORDER') {
1155 return whenReordering({
1156 impact: impact,
1157 draggable: draggable,
1158 draggables: draggables,
1159 droppable: droppable,
1160 afterCritical: afterCritical
1161 });
1162 }
1163
1164 return whenCombining({
1165 impact: impact,
1166 draggables: draggables,
1167 afterCritical: afterCritical
1168 });
1169};
1170
1171var getPageBorderBoxCenterFromImpact = (function (args) {
1172 var withoutDisplacement = getResultWithoutDroppableDisplacement(args);
1173 var droppable = args.droppable;
1174 var withDisplacement = droppable ? withDroppableDisplacement(droppable, withoutDisplacement) : withoutDisplacement;
1175 return withDisplacement;
1176});
1177
1178var scrollViewport = (function (viewport, newScroll) {
1179 var diff = subtract(newScroll, viewport.scroll.initial);
1180 var displacement = negate(diff);
1181 var frame = cssBoxModel.getRect({
1182 top: newScroll.y,
1183 bottom: newScroll.y + viewport.frame.height,
1184 left: newScroll.x,
1185 right: newScroll.x + viewport.frame.width
1186 });
1187 var updated = {
1188 frame: frame,
1189 scroll: {
1190 initial: viewport.scroll.initial,
1191 max: viewport.scroll.max,
1192 current: newScroll,
1193 diff: {
1194 value: diff,
1195 displacement: displacement
1196 }
1197 }
1198 };
1199 return updated;
1200});
1201
1202function getDraggables(ids, draggables) {
1203 return ids.map(function (id) {
1204 return draggables[id];
1205 });
1206}
1207
1208function tryGetVisible(id, groups) {
1209 for (var i = 0; i < groups.length; i++) {
1210 var displacement = groups[i].visible[id];
1211
1212 if (displacement) {
1213 return displacement;
1214 }
1215 }
1216
1217 return null;
1218}
1219
1220var speculativelyIncrease = (function (_ref) {
1221 var impact = _ref.impact,
1222 viewport = _ref.viewport,
1223 destination = _ref.destination,
1224 draggables = _ref.draggables,
1225 maxScrollChange = _ref.maxScrollChange;
1226 var scrolledViewport = scrollViewport(viewport, add(viewport.scroll.current, maxScrollChange));
1227 var scrolledDroppable = destination.frame ? scrollDroppable(destination, add(destination.frame.scroll.current, maxScrollChange)) : destination;
1228 var last = impact.displaced;
1229 var withViewportScroll = getDisplacementGroups({
1230 afterDragging: getDraggables(last.all, draggables),
1231 destination: destination,
1232 displacedBy: impact.displacedBy,
1233 viewport: scrolledViewport.frame,
1234 last: last,
1235 forceShouldAnimate: false
1236 });
1237 var withDroppableScroll = getDisplacementGroups({
1238 afterDragging: getDraggables(last.all, draggables),
1239 destination: scrolledDroppable,
1240 displacedBy: impact.displacedBy,
1241 viewport: viewport.frame,
1242 last: last,
1243 forceShouldAnimate: false
1244 });
1245 var invisible = {};
1246 var visible = {};
1247 var groups = [last, withViewportScroll, withDroppableScroll];
1248 last.all.forEach(function (id) {
1249 var displacement = tryGetVisible(id, groups);
1250
1251 if (displacement) {
1252 visible[id] = displacement;
1253 return;
1254 }
1255
1256 invisible[id] = true;
1257 });
1258
1259 var newImpact = _extends({}, impact, {
1260 displaced: {
1261 all: last.all,
1262 invisible: invisible,
1263 visible: visible
1264 }
1265 });
1266
1267 return newImpact;
1268});
1269
1270var withViewportDisplacement = (function (viewport, point) {
1271 return add(viewport.scroll.diff.displacement, point);
1272});
1273
1274var getClientFromPageBorderBoxCenter = (function (_ref) {
1275 var pageBorderBoxCenter = _ref.pageBorderBoxCenter,
1276 draggable = _ref.draggable,
1277 viewport = _ref.viewport;
1278 var withoutPageScrollChange = withViewportDisplacement(viewport, pageBorderBoxCenter);
1279 var offset = subtract(withoutPageScrollChange, draggable.page.borderBox.center);
1280 return add(draggable.client.borderBox.center, offset);
1281});
1282
1283var isTotallyVisibleInNewLocation = (function (_ref) {
1284 var draggable = _ref.draggable,
1285 destination = _ref.destination,
1286 newPageBorderBoxCenter = _ref.newPageBorderBoxCenter,
1287 viewport = _ref.viewport,
1288 withDroppableDisplacement = _ref.withDroppableDisplacement,
1289 _ref$onlyOnMainAxis = _ref.onlyOnMainAxis,
1290 onlyOnMainAxis = _ref$onlyOnMainAxis === void 0 ? false : _ref$onlyOnMainAxis;
1291 var changeNeeded = subtract(newPageBorderBoxCenter, draggable.page.borderBox.center);
1292 var shifted = offsetByPosition(draggable.page.borderBox, changeNeeded);
1293 var args = {
1294 target: shifted,
1295 destination: destination,
1296 withDroppableDisplacement: withDroppableDisplacement,
1297 viewport: viewport
1298 };
1299 return onlyOnMainAxis ? isTotallyVisibleOnAxis(args) : isTotallyVisible(args);
1300});
1301
1302var moveToNextPlace = (function (_ref) {
1303 var isMovingForward = _ref.isMovingForward,
1304 draggable = _ref.draggable,
1305 destination = _ref.destination,
1306 draggables = _ref.draggables,
1307 previousImpact = _ref.previousImpact,
1308 viewport = _ref.viewport,
1309 previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
1310 previousClientSelection = _ref.previousClientSelection,
1311 afterCritical = _ref.afterCritical;
1312
1313 if (!destination.isEnabled) {
1314 return null;
1315 }
1316
1317 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
1318 var isInHomeList = isHomeOf(draggable, destination);
1319 var impact = moveToNextCombine({
1320 isMovingForward: isMovingForward,
1321 draggable: draggable,
1322 destination: destination,
1323 insideDestination: insideDestination,
1324 previousImpact: previousImpact
1325 }) || moveToNextIndex({
1326 isMovingForward: isMovingForward,
1327 isInHomeList: isInHomeList,
1328 draggable: draggable,
1329 draggables: draggables,
1330 destination: destination,
1331 insideDestination: insideDestination,
1332 previousImpact: previousImpact,
1333 viewport: viewport,
1334 afterCritical: afterCritical
1335 });
1336
1337 if (!impact) {
1338 return null;
1339 }
1340
1341 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
1342 impact: impact,
1343 draggable: draggable,
1344 droppable: destination,
1345 draggables: draggables,
1346 afterCritical: afterCritical
1347 });
1348 var isVisibleInNewLocation = isTotallyVisibleInNewLocation({
1349 draggable: draggable,
1350 destination: destination,
1351 newPageBorderBoxCenter: pageBorderBoxCenter,
1352 viewport: viewport.frame,
1353 withDroppableDisplacement: false,
1354 onlyOnMainAxis: true
1355 });
1356
1357 if (isVisibleInNewLocation) {
1358 var clientSelection = getClientFromPageBorderBoxCenter({
1359 pageBorderBoxCenter: pageBorderBoxCenter,
1360 draggable: draggable,
1361 viewport: viewport
1362 });
1363 return {
1364 clientSelection: clientSelection,
1365 impact: impact,
1366 scrollJumpRequest: null
1367 };
1368 }
1369
1370 var distance = subtract(pageBorderBoxCenter, previousPageBorderBoxCenter);
1371 var cautious = speculativelyIncrease({
1372 impact: impact,
1373 viewport: viewport,
1374 destination: destination,
1375 draggables: draggables,
1376 maxScrollChange: distance
1377 });
1378 return {
1379 clientSelection: previousClientSelection,
1380 impact: cautious,
1381 scrollJumpRequest: distance
1382 };
1383});
1384
1385var getKnownActive = function getKnownActive(droppable) {
1386 var rect = droppable.subject.active;
1387 !rect ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot get clipped area from droppable') : invariant(false) : void 0;
1388 return rect;
1389};
1390
1391var getBestCrossAxisDroppable = (function (_ref) {
1392 var isMovingForward = _ref.isMovingForward,
1393 pageBorderBoxCenter = _ref.pageBorderBoxCenter,
1394 source = _ref.source,
1395 droppables = _ref.droppables,
1396 viewport = _ref.viewport;
1397 var active = source.subject.active;
1398
1399 if (!active) {
1400 return null;
1401 }
1402
1403 var axis = source.axis;
1404 var isBetweenSourceClipped = isWithin(active[axis.start], active[axis.end]);
1405 var candidates = toDroppableList(droppables).filter(function (droppable) {
1406 return droppable !== source;
1407 }).filter(function (droppable) {
1408 return droppable.isEnabled;
1409 }).filter(function (droppable) {
1410 return Boolean(droppable.subject.active);
1411 }).filter(function (droppable) {
1412 return isPartiallyVisibleThroughFrame(viewport.frame)(getKnownActive(droppable));
1413 }).filter(function (droppable) {
1414 var activeOfTarget = getKnownActive(droppable);
1415
1416 if (isMovingForward) {
1417 return active[axis.crossAxisEnd] < activeOfTarget[axis.crossAxisEnd];
1418 }
1419
1420 return activeOfTarget[axis.crossAxisStart] < active[axis.crossAxisStart];
1421 }).filter(function (droppable) {
1422 var activeOfTarget = getKnownActive(droppable);
1423 var isBetweenDestinationClipped = isWithin(activeOfTarget[axis.start], activeOfTarget[axis.end]);
1424 return isBetweenSourceClipped(activeOfTarget[axis.start]) || isBetweenSourceClipped(activeOfTarget[axis.end]) || isBetweenDestinationClipped(active[axis.start]) || isBetweenDestinationClipped(active[axis.end]);
1425 }).sort(function (a, b) {
1426 var first = getKnownActive(a)[axis.crossAxisStart];
1427 var second = getKnownActive(b)[axis.crossAxisStart];
1428
1429 if (isMovingForward) {
1430 return first - second;
1431 }
1432
1433 return second - first;
1434 }).filter(function (droppable, index, array) {
1435 return getKnownActive(droppable)[axis.crossAxisStart] === getKnownActive(array[0])[axis.crossAxisStart];
1436 });
1437
1438 if (!candidates.length) {
1439 return null;
1440 }
1441
1442 if (candidates.length === 1) {
1443 return candidates[0];
1444 }
1445
1446 var contains = candidates.filter(function (droppable) {
1447 var isWithinDroppable = isWithin(getKnownActive(droppable)[axis.start], getKnownActive(droppable)[axis.end]);
1448 return isWithinDroppable(pageBorderBoxCenter[axis.line]);
1449 });
1450
1451 if (contains.length === 1) {
1452 return contains[0];
1453 }
1454
1455 if (contains.length > 1) {
1456 return contains.sort(function (a, b) {
1457 return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
1458 })[0];
1459 }
1460
1461 return candidates.sort(function (a, b) {
1462 var first = closest(pageBorderBoxCenter, getCorners(getKnownActive(a)));
1463 var second = closest(pageBorderBoxCenter, getCorners(getKnownActive(b)));
1464
1465 if (first !== second) {
1466 return first - second;
1467 }
1468
1469 return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
1470 })[0];
1471});
1472
1473var getCurrentPageBorderBoxCenter = function getCurrentPageBorderBoxCenter(draggable, afterCritical) {
1474 var original = draggable.page.borderBox.center;
1475 return didStartAfterCritical(draggable.descriptor.id, afterCritical) ? subtract(original, afterCritical.displacedBy.point) : original;
1476};
1477var getCurrentPageBorderBox = function getCurrentPageBorderBox(draggable, afterCritical) {
1478 var original = draggable.page.borderBox;
1479 return didStartAfterCritical(draggable.descriptor.id, afterCritical) ? offsetByPosition(original, negate(afterCritical.displacedBy.point)) : original;
1480};
1481
1482var getClosestDraggable = (function (_ref) {
1483 var pageBorderBoxCenter = _ref.pageBorderBoxCenter,
1484 viewport = _ref.viewport,
1485 destination = _ref.destination,
1486 insideDestination = _ref.insideDestination,
1487 afterCritical = _ref.afterCritical;
1488 var sorted = insideDestination.filter(function (draggable) {
1489 return isTotallyVisible({
1490 target: getCurrentPageBorderBox(draggable, afterCritical),
1491 destination: destination,
1492 viewport: viewport.frame,
1493 withDroppableDisplacement: true
1494 });
1495 }).sort(function (a, b) {
1496 var distanceToA = distance(pageBorderBoxCenter, withDroppableDisplacement(destination, getCurrentPageBorderBoxCenter(a, afterCritical)));
1497 var distanceToB = distance(pageBorderBoxCenter, withDroppableDisplacement(destination, getCurrentPageBorderBoxCenter(b, afterCritical)));
1498
1499 if (distanceToA < distanceToB) {
1500 return -1;
1501 }
1502
1503 if (distanceToB < distanceToA) {
1504 return 1;
1505 }
1506
1507 return a.descriptor.index - b.descriptor.index;
1508 });
1509 return sorted[0] || null;
1510});
1511
1512var getDisplacedBy = memoizeOne(function getDisplacedBy(axis, displaceBy) {
1513 var displacement = displaceBy[axis.line];
1514 return {
1515 value: displacement,
1516 point: patch(axis.line, displacement)
1517 };
1518});
1519
1520var getRequiredGrowthForPlaceholder = function getRequiredGrowthForPlaceholder(droppable, placeholderSize, draggables) {
1521 var axis = droppable.axis;
1522
1523 if (droppable.descriptor.mode === 'virtual') {
1524 return patch(axis.line, placeholderSize[axis.line]);
1525 }
1526
1527 var availableSpace = droppable.subject.page.contentBox[axis.size];
1528 var insideDroppable = getDraggablesInsideDroppable(droppable.descriptor.id, draggables);
1529 var spaceUsed = insideDroppable.reduce(function (sum, dimension) {
1530 return sum + dimension.client.marginBox[axis.size];
1531 }, 0);
1532 var requiredSpace = spaceUsed + placeholderSize[axis.line];
1533 var needsToGrowBy = requiredSpace - availableSpace;
1534
1535 if (needsToGrowBy <= 0) {
1536 return null;
1537 }
1538
1539 return patch(axis.line, needsToGrowBy);
1540};
1541
1542var withMaxScroll = function withMaxScroll(frame, max) {
1543 return _extends({}, frame, {
1544 scroll: _extends({}, frame.scroll, {
1545 max: max
1546 })
1547 });
1548};
1549
1550var addPlaceholder = function addPlaceholder(droppable, draggable, draggables) {
1551 var frame = droppable.frame;
1552 !!isHomeOf(draggable, droppable) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Should not add placeholder space to home list') : invariant(false) : void 0;
1553 !!droppable.subject.withPlaceholder ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot add placeholder size to a subject when it already has one') : invariant(false) : void 0;
1554 var placeholderSize = getDisplacedBy(droppable.axis, draggable.displaceBy).point;
1555 var requiredGrowth = getRequiredGrowthForPlaceholder(droppable, placeholderSize, draggables);
1556 var added = {
1557 placeholderSize: placeholderSize,
1558 increasedBy: requiredGrowth,
1559 oldFrameMaxScroll: droppable.frame ? droppable.frame.scroll.max : null
1560 };
1561
1562 if (!frame) {
1563 var _subject = getSubject({
1564 page: droppable.subject.page,
1565 withPlaceholder: added,
1566 axis: droppable.axis,
1567 frame: droppable.frame
1568 });
1569
1570 return _extends({}, droppable, {
1571 subject: _subject
1572 });
1573 }
1574
1575 var maxScroll = requiredGrowth ? add(frame.scroll.max, requiredGrowth) : frame.scroll.max;
1576 var newFrame = withMaxScroll(frame, maxScroll);
1577 var subject = getSubject({
1578 page: droppable.subject.page,
1579 withPlaceholder: added,
1580 axis: droppable.axis,
1581 frame: newFrame
1582 });
1583 return _extends({}, droppable, {
1584 subject: subject,
1585 frame: newFrame
1586 });
1587};
1588var removePlaceholder = function removePlaceholder(droppable) {
1589 var added = droppable.subject.withPlaceholder;
1590 !added ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot remove placeholder form subject when there was none') : invariant(false) : void 0;
1591 var frame = droppable.frame;
1592
1593 if (!frame) {
1594 var _subject2 = getSubject({
1595 page: droppable.subject.page,
1596 axis: droppable.axis,
1597 frame: null,
1598 withPlaceholder: null
1599 });
1600
1601 return _extends({}, droppable, {
1602 subject: _subject2
1603 });
1604 }
1605
1606 var oldMaxScroll = added.oldFrameMaxScroll;
1607 !oldMaxScroll ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected droppable with frame to have old max frame scroll when removing placeholder') : invariant(false) : void 0;
1608 var newFrame = withMaxScroll(frame, oldMaxScroll);
1609 var subject = getSubject({
1610 page: droppable.subject.page,
1611 axis: droppable.axis,
1612 frame: newFrame,
1613 withPlaceholder: null
1614 });
1615 return _extends({}, droppable, {
1616 subject: subject,
1617 frame: newFrame
1618 });
1619};
1620
1621var moveToNewDroppable = (function (_ref) {
1622 var previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
1623 moveRelativeTo = _ref.moveRelativeTo,
1624 insideDestination = _ref.insideDestination,
1625 draggable = _ref.draggable,
1626 draggables = _ref.draggables,
1627 destination = _ref.destination,
1628 viewport = _ref.viewport,
1629 afterCritical = _ref.afterCritical;
1630
1631 if (!moveRelativeTo) {
1632 if (insideDestination.length) {
1633 return null;
1634 }
1635
1636 var proposed = {
1637 displaced: emptyGroups,
1638 displacedBy: noDisplacedBy,
1639 at: {
1640 type: 'REORDER',
1641 destination: {
1642 droppableId: destination.descriptor.id,
1643 index: 0
1644 }
1645 }
1646 };
1647 var proposedPageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
1648 impact: proposed,
1649 draggable: draggable,
1650 droppable: destination,
1651 draggables: draggables,
1652 afterCritical: afterCritical
1653 });
1654 var withPlaceholder = isHomeOf(draggable, destination) ? destination : addPlaceholder(destination, draggable, draggables);
1655 var isVisibleInNewLocation = isTotallyVisibleInNewLocation({
1656 draggable: draggable,
1657 destination: withPlaceholder,
1658 newPageBorderBoxCenter: proposedPageBorderBoxCenter,
1659 viewport: viewport.frame,
1660 withDroppableDisplacement: false,
1661 onlyOnMainAxis: true
1662 });
1663 return isVisibleInNewLocation ? proposed : null;
1664 }
1665
1666 var isGoingBeforeTarget = Boolean(previousPageBorderBoxCenter[destination.axis.line] <= moveRelativeTo.page.borderBox.center[destination.axis.line]);
1667
1668 var proposedIndex = function () {
1669 var relativeTo = moveRelativeTo.descriptor.index;
1670
1671 if (moveRelativeTo.descriptor.id === draggable.descriptor.id) {
1672 return relativeTo;
1673 }
1674
1675 if (isGoingBeforeTarget) {
1676 return relativeTo;
1677 }
1678
1679 return relativeTo + 1;
1680 }();
1681
1682 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
1683 return calculateReorderImpact({
1684 draggable: draggable,
1685 insideDestination: insideDestination,
1686 destination: destination,
1687 viewport: viewport,
1688 displacedBy: displacedBy,
1689 last: emptyGroups,
1690 index: proposedIndex
1691 });
1692});
1693
1694var moveCrossAxis = (function (_ref) {
1695 var isMovingForward = _ref.isMovingForward,
1696 previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
1697 draggable = _ref.draggable,
1698 isOver = _ref.isOver,
1699 draggables = _ref.draggables,
1700 droppables = _ref.droppables,
1701 viewport = _ref.viewport,
1702 afterCritical = _ref.afterCritical;
1703 var destination = getBestCrossAxisDroppable({
1704 isMovingForward: isMovingForward,
1705 pageBorderBoxCenter: previousPageBorderBoxCenter,
1706 source: isOver,
1707 droppables: droppables,
1708 viewport: viewport
1709 });
1710
1711 if (!destination) {
1712 return null;
1713 }
1714
1715 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
1716 var moveRelativeTo = getClosestDraggable({
1717 pageBorderBoxCenter: previousPageBorderBoxCenter,
1718 viewport: viewport,
1719 destination: destination,
1720 insideDestination: insideDestination,
1721 afterCritical: afterCritical
1722 });
1723 var impact = moveToNewDroppable({
1724 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
1725 destination: destination,
1726 draggable: draggable,
1727 draggables: draggables,
1728 moveRelativeTo: moveRelativeTo,
1729 insideDestination: insideDestination,
1730 viewport: viewport,
1731 afterCritical: afterCritical
1732 });
1733
1734 if (!impact) {
1735 return null;
1736 }
1737
1738 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
1739 impact: impact,
1740 draggable: draggable,
1741 droppable: destination,
1742 draggables: draggables,
1743 afterCritical: afterCritical
1744 });
1745 var clientSelection = getClientFromPageBorderBoxCenter({
1746 pageBorderBoxCenter: pageBorderBoxCenter,
1747 draggable: draggable,
1748 viewport: viewport
1749 });
1750 return {
1751 clientSelection: clientSelection,
1752 impact: impact,
1753 scrollJumpRequest: null
1754 };
1755});
1756
1757var whatIsDraggedOver = (function (impact) {
1758 var at = impact.at;
1759
1760 if (!at) {
1761 return null;
1762 }
1763
1764 if (at.type === 'REORDER') {
1765 return at.destination.droppableId;
1766 }
1767
1768 return at.combine.droppableId;
1769});
1770
1771var getDroppableOver = function getDroppableOver(impact, droppables) {
1772 var id = whatIsDraggedOver(impact);
1773 return id ? droppables[id] : null;
1774};
1775
1776var moveInDirection = (function (_ref) {
1777 var state = _ref.state,
1778 type = _ref.type;
1779 var isActuallyOver = getDroppableOver(state.impact, state.dimensions.droppables);
1780 var isMainAxisMovementAllowed = Boolean(isActuallyOver);
1781 var home = state.dimensions.droppables[state.critical.droppable.id];
1782 var isOver = isActuallyOver || home;
1783 var direction = isOver.axis.direction;
1784 var isMovingOnMainAxis = direction === 'vertical' && (type === 'MOVE_UP' || type === 'MOVE_DOWN') || direction === 'horizontal' && (type === 'MOVE_LEFT' || type === 'MOVE_RIGHT');
1785
1786 if (isMovingOnMainAxis && !isMainAxisMovementAllowed) {
1787 return null;
1788 }
1789
1790 var isMovingForward = type === 'MOVE_DOWN' || type === 'MOVE_RIGHT';
1791 var draggable = state.dimensions.draggables[state.critical.draggable.id];
1792 var previousPageBorderBoxCenter = state.current.page.borderBoxCenter;
1793 var _state$dimensions = state.dimensions,
1794 draggables = _state$dimensions.draggables,
1795 droppables = _state$dimensions.droppables;
1796 return isMovingOnMainAxis ? moveToNextPlace({
1797 isMovingForward: isMovingForward,
1798 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
1799 draggable: draggable,
1800 destination: isOver,
1801 draggables: draggables,
1802 viewport: state.viewport,
1803 previousClientSelection: state.current.client.selection,
1804 previousImpact: state.impact,
1805 afterCritical: state.afterCritical
1806 }) : moveCrossAxis({
1807 isMovingForward: isMovingForward,
1808 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
1809 draggable: draggable,
1810 isOver: isOver,
1811 draggables: draggables,
1812 droppables: droppables,
1813 viewport: state.viewport,
1814 afterCritical: state.afterCritical
1815 });
1816});
1817
1818function isMovementAllowed(state) {
1819 return state.phase === 'DRAGGING' || state.phase === 'COLLECTING';
1820}
1821
1822function isPositionInFrame(frame) {
1823 var isWithinVertical = isWithin(frame.top, frame.bottom);
1824 var isWithinHorizontal = isWithin(frame.left, frame.right);
1825 return function run(point) {
1826 return isWithinVertical(point.y) && isWithinHorizontal(point.x);
1827 };
1828}
1829
1830function getHasOverlap(first, second) {
1831 return first.left < second.right && first.right > second.left && first.top < second.bottom && first.bottom > second.top;
1832}
1833
1834function getFurthestAway(_ref) {
1835 var pageBorderBox = _ref.pageBorderBox,
1836 draggable = _ref.draggable,
1837 candidates = _ref.candidates;
1838 var startCenter = draggable.page.borderBox.center;
1839 var sorted = candidates.map(function (candidate) {
1840 var axis = candidate.axis;
1841 var target = patch(candidate.axis.line, pageBorderBox.center[axis.line], candidate.page.borderBox.center[axis.crossAxisLine]);
1842 return {
1843 id: candidate.descriptor.id,
1844 distance: distance(startCenter, target)
1845 };
1846 }).sort(function (a, b) {
1847 return b.distance - a.distance;
1848 });
1849 return sorted[0] ? sorted[0].id : null;
1850}
1851
1852function getDroppableOver$1(_ref2) {
1853 var pageBorderBox = _ref2.pageBorderBox,
1854 draggable = _ref2.draggable,
1855 droppables = _ref2.droppables;
1856 var candidates = toDroppableList(droppables).filter(function (item) {
1857 if (!item.isEnabled) {
1858 return false;
1859 }
1860
1861 var active = item.subject.active;
1862
1863 if (!active) {
1864 return false;
1865 }
1866
1867 if (!getHasOverlap(pageBorderBox, active)) {
1868 return false;
1869 }
1870
1871 if (isPositionInFrame(active)(pageBorderBox.center)) {
1872 return true;
1873 }
1874
1875 var axis = item.axis;
1876 var childCenter = active.center[axis.crossAxisLine];
1877 var crossAxisStart = pageBorderBox[axis.crossAxisStart];
1878 var crossAxisEnd = pageBorderBox[axis.crossAxisEnd];
1879 var isContained = isWithin(active[axis.crossAxisStart], active[axis.crossAxisEnd]);
1880 var isStartContained = isContained(crossAxisStart);
1881 var isEndContained = isContained(crossAxisEnd);
1882
1883 if (!isStartContained && !isEndContained) {
1884 return true;
1885 }
1886
1887 if (isStartContained) {
1888 return crossAxisStart < childCenter;
1889 }
1890
1891 return crossAxisEnd > childCenter;
1892 });
1893
1894 if (!candidates.length) {
1895 return null;
1896 }
1897
1898 if (candidates.length === 1) {
1899 return candidates[0].descriptor.id;
1900 }
1901
1902 return getFurthestAway({
1903 pageBorderBox: pageBorderBox,
1904 draggable: draggable,
1905 candidates: candidates
1906 });
1907}
1908
1909var offsetRectByPosition = function offsetRectByPosition(rect, point) {
1910 return cssBoxModel.getRect(offsetByPosition(rect, point));
1911};
1912
1913var withDroppableScroll = (function (droppable, area) {
1914 var frame = droppable.frame;
1915
1916 if (!frame) {
1917 return area;
1918 }
1919
1920 return offsetRectByPosition(area, frame.scroll.diff.value);
1921});
1922
1923function getIsDisplaced(_ref) {
1924 var displaced = _ref.displaced,
1925 id = _ref.id;
1926 return Boolean(displaced.visible[id] || displaced.invisible[id]);
1927}
1928
1929function atIndex(_ref) {
1930 var draggable = _ref.draggable,
1931 closest = _ref.closest,
1932 inHomeList = _ref.inHomeList;
1933
1934 if (!closest) {
1935 return null;
1936 }
1937
1938 if (!inHomeList) {
1939 return closest.descriptor.index;
1940 }
1941
1942 if (closest.descriptor.index > draggable.descriptor.index) {
1943 return closest.descriptor.index - 1;
1944 }
1945
1946 return closest.descriptor.index;
1947}
1948
1949var getReorderImpact = (function (_ref2) {
1950 var targetRect = _ref2.pageBorderBoxWithDroppableScroll,
1951 draggable = _ref2.draggable,
1952 destination = _ref2.destination,
1953 insideDestination = _ref2.insideDestination,
1954 last = _ref2.last,
1955 viewport = _ref2.viewport,
1956 afterCritical = _ref2.afterCritical;
1957 var axis = destination.axis;
1958 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
1959 var displacement = displacedBy.value;
1960 var targetStart = targetRect[axis.start];
1961 var targetEnd = targetRect[axis.end];
1962 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
1963 var closest = find(withoutDragging, function (child) {
1964 var id = child.descriptor.id;
1965 var childCenter = child.page.borderBox.center[axis.line];
1966 var didStartAfterCritical$1 = didStartAfterCritical(id, afterCritical);
1967 var isDisplaced = getIsDisplaced({
1968 displaced: last,
1969 id: id
1970 });
1971
1972 if (didStartAfterCritical$1) {
1973 if (isDisplaced) {
1974 return targetEnd <= childCenter;
1975 }
1976
1977 return targetStart < childCenter - displacement;
1978 }
1979
1980 if (isDisplaced) {
1981 return targetEnd <= childCenter + displacement;
1982 }
1983
1984 return targetStart < childCenter;
1985 });
1986 var newIndex = atIndex({
1987 draggable: draggable,
1988 closest: closest,
1989 inHomeList: isHomeOf(draggable, destination)
1990 });
1991 return calculateReorderImpact({
1992 draggable: draggable,
1993 insideDestination: insideDestination,
1994 destination: destination,
1995 viewport: viewport,
1996 last: last,
1997 displacedBy: displacedBy,
1998 index: newIndex
1999 });
2000});
2001
2002var combineThresholdDivisor = 4;
2003var getCombineImpact = (function (_ref) {
2004 var draggable = _ref.draggable,
2005 targetRect = _ref.pageBorderBoxWithDroppableScroll,
2006 previousImpact = _ref.previousImpact,
2007 destination = _ref.destination,
2008 insideDestination = _ref.insideDestination,
2009 afterCritical = _ref.afterCritical;
2010
2011 if (!destination.isCombineEnabled) {
2012 return null;
2013 }
2014
2015 var axis = destination.axis;
2016 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
2017 var displacement = displacedBy.value;
2018 var targetStart = targetRect[axis.start];
2019 var targetEnd = targetRect[axis.end];
2020 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
2021 var combineWith = find(withoutDragging, function (child) {
2022 var id = child.descriptor.id;
2023 var childRect = child.page.borderBox;
2024 var childSize = childRect[axis.size];
2025 var threshold = childSize / combineThresholdDivisor;
2026 var didStartAfterCritical$1 = didStartAfterCritical(id, afterCritical);
2027 var isDisplaced = getIsDisplaced({
2028 displaced: previousImpact.displaced,
2029 id: id
2030 });
2031
2032 if (didStartAfterCritical$1) {
2033 if (isDisplaced) {
2034 return targetEnd > childRect[axis.start] + threshold && targetEnd < childRect[axis.end] - threshold;
2035 }
2036
2037 return targetStart > childRect[axis.start] - displacement + threshold && targetStart < childRect[axis.end] - displacement - threshold;
2038 }
2039
2040 if (isDisplaced) {
2041 return targetEnd > childRect[axis.start] + displacement + threshold && targetEnd < childRect[axis.end] + displacement - threshold;
2042 }
2043
2044 return targetStart > childRect[axis.start] + threshold && targetStart < childRect[axis.end] - threshold;
2045 });
2046
2047 if (!combineWith) {
2048 return null;
2049 }
2050
2051 var impact = {
2052 displacedBy: displacedBy,
2053 displaced: previousImpact.displaced,
2054 at: {
2055 type: 'COMBINE',
2056 combine: {
2057 draggableId: combineWith.descriptor.id,
2058 droppableId: destination.descriptor.id
2059 }
2060 }
2061 };
2062 return impact;
2063});
2064
2065var getDragImpact = (function (_ref) {
2066 var pageOffset = _ref.pageOffset,
2067 draggable = _ref.draggable,
2068 draggables = _ref.draggables,
2069 droppables = _ref.droppables,
2070 previousImpact = _ref.previousImpact,
2071 viewport = _ref.viewport,
2072 afterCritical = _ref.afterCritical;
2073 var pageBorderBox = offsetRectByPosition(draggable.page.borderBox, pageOffset);
2074 var destinationId = getDroppableOver$1({
2075 pageBorderBox: pageBorderBox,
2076 draggable: draggable,
2077 droppables: droppables
2078 });
2079
2080 if (!destinationId) {
2081 return noImpact;
2082 }
2083
2084 var destination = droppables[destinationId];
2085 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
2086 var pageBorderBoxWithDroppableScroll = withDroppableScroll(destination, pageBorderBox);
2087 return getCombineImpact({
2088 pageBorderBoxWithDroppableScroll: pageBorderBoxWithDroppableScroll,
2089 draggable: draggable,
2090 previousImpact: previousImpact,
2091 destination: destination,
2092 insideDestination: insideDestination,
2093 afterCritical: afterCritical
2094 }) || getReorderImpact({
2095 pageBorderBoxWithDroppableScroll: pageBorderBoxWithDroppableScroll,
2096 draggable: draggable,
2097 destination: destination,
2098 insideDestination: insideDestination,
2099 last: previousImpact.displaced,
2100 viewport: viewport,
2101 afterCritical: afterCritical
2102 });
2103});
2104
2105var patchDroppableMap = (function (droppables, updated) {
2106 var _extends2;
2107
2108 return _extends({}, droppables, (_extends2 = {}, _extends2[updated.descriptor.id] = updated, _extends2));
2109});
2110
2111var clearUnusedPlaceholder = function clearUnusedPlaceholder(_ref) {
2112 var previousImpact = _ref.previousImpact,
2113 impact = _ref.impact,
2114 droppables = _ref.droppables;
2115 var last = whatIsDraggedOver(previousImpact);
2116 var now = whatIsDraggedOver(impact);
2117
2118 if (!last) {
2119 return droppables;
2120 }
2121
2122 if (last === now) {
2123 return droppables;
2124 }
2125
2126 var lastDroppable = droppables[last];
2127
2128 if (!lastDroppable.subject.withPlaceholder) {
2129 return droppables;
2130 }
2131
2132 var updated = removePlaceholder(lastDroppable);
2133 return patchDroppableMap(droppables, updated);
2134};
2135
2136var recomputePlaceholders = (function (_ref2) {
2137 var draggable = _ref2.draggable,
2138 draggables = _ref2.draggables,
2139 droppables = _ref2.droppables,
2140 previousImpact = _ref2.previousImpact,
2141 impact = _ref2.impact;
2142 var cleaned = clearUnusedPlaceholder({
2143 previousImpact: previousImpact,
2144 impact: impact,
2145 droppables: droppables
2146 });
2147 var isOver = whatIsDraggedOver(impact);
2148
2149 if (!isOver) {
2150 return cleaned;
2151 }
2152
2153 var droppable = droppables[isOver];
2154
2155 if (isHomeOf(draggable, droppable)) {
2156 return cleaned;
2157 }
2158
2159 if (droppable.subject.withPlaceholder) {
2160 return cleaned;
2161 }
2162
2163 var patched = addPlaceholder(droppable, draggable, draggables);
2164 return patchDroppableMap(cleaned, patched);
2165});
2166
2167var update = (function (_ref) {
2168 var state = _ref.state,
2169 forcedClientSelection = _ref.clientSelection,
2170 forcedDimensions = _ref.dimensions,
2171 forcedViewport = _ref.viewport,
2172 forcedImpact = _ref.impact,
2173 scrollJumpRequest = _ref.scrollJumpRequest;
2174 var viewport = forcedViewport || state.viewport;
2175 var dimensions = forcedDimensions || state.dimensions;
2176 var clientSelection = forcedClientSelection || state.current.client.selection;
2177 var offset = subtract(clientSelection, state.initial.client.selection);
2178 var client = {
2179 offset: offset,
2180 selection: clientSelection,
2181 borderBoxCenter: add(state.initial.client.borderBoxCenter, offset)
2182 };
2183 var page = {
2184 selection: add(client.selection, viewport.scroll.current),
2185 borderBoxCenter: add(client.borderBoxCenter, viewport.scroll.current),
2186 offset: add(client.offset, viewport.scroll.diff.value)
2187 };
2188 var current = {
2189 client: client,
2190 page: page
2191 };
2192
2193 if (state.phase === 'COLLECTING') {
2194 return _extends({
2195 phase: 'COLLECTING'
2196 }, state, {
2197 dimensions: dimensions,
2198 viewport: viewport,
2199 current: current
2200 });
2201 }
2202
2203 var draggable = dimensions.draggables[state.critical.draggable.id];
2204 var newImpact = forcedImpact || getDragImpact({
2205 pageOffset: page.offset,
2206 draggable: draggable,
2207 draggables: dimensions.draggables,
2208 droppables: dimensions.droppables,
2209 previousImpact: state.impact,
2210 viewport: viewport,
2211 afterCritical: state.afterCritical
2212 });
2213 var withUpdatedPlaceholders = recomputePlaceholders({
2214 draggable: draggable,
2215 impact: newImpact,
2216 previousImpact: state.impact,
2217 draggables: dimensions.draggables,
2218 droppables: dimensions.droppables
2219 });
2220
2221 var result = _extends({}, state, {
2222 current: current,
2223 dimensions: {
2224 draggables: dimensions.draggables,
2225 droppables: withUpdatedPlaceholders
2226 },
2227 impact: newImpact,
2228 viewport: viewport,
2229 scrollJumpRequest: scrollJumpRequest || null,
2230 forceShouldAnimate: scrollJumpRequest ? false : null
2231 });
2232
2233 return result;
2234});
2235
2236function getDraggables$1(ids, draggables) {
2237 return ids.map(function (id) {
2238 return draggables[id];
2239 });
2240}
2241
2242var recompute = (function (_ref) {
2243 var impact = _ref.impact,
2244 viewport = _ref.viewport,
2245 draggables = _ref.draggables,
2246 destination = _ref.destination,
2247 forceShouldAnimate = _ref.forceShouldAnimate;
2248 var last = impact.displaced;
2249 var afterDragging = getDraggables$1(last.all, draggables);
2250 var displaced = getDisplacementGroups({
2251 afterDragging: afterDragging,
2252 destination: destination,
2253 displacedBy: impact.displacedBy,
2254 viewport: viewport.frame,
2255 forceShouldAnimate: forceShouldAnimate,
2256 last: last
2257 });
2258 return _extends({}, impact, {
2259 displaced: displaced
2260 });
2261});
2262
2263var getClientBorderBoxCenter = (function (_ref) {
2264 var impact = _ref.impact,
2265 draggable = _ref.draggable,
2266 droppable = _ref.droppable,
2267 draggables = _ref.draggables,
2268 viewport = _ref.viewport,
2269 afterCritical = _ref.afterCritical;
2270 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
2271 impact: impact,
2272 draggable: draggable,
2273 draggables: draggables,
2274 droppable: droppable,
2275 afterCritical: afterCritical
2276 });
2277 return getClientFromPageBorderBoxCenter({
2278 pageBorderBoxCenter: pageBorderBoxCenter,
2279 draggable: draggable,
2280 viewport: viewport
2281 });
2282});
2283
2284var refreshSnap = (function (_ref) {
2285 var state = _ref.state,
2286 forcedDimensions = _ref.dimensions,
2287 forcedViewport = _ref.viewport;
2288 !(state.movementMode === 'SNAP') ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
2289 var needsVisibilityCheck = state.impact;
2290 var viewport = forcedViewport || state.viewport;
2291 var dimensions = forcedDimensions || state.dimensions;
2292 var draggables = dimensions.draggables,
2293 droppables = dimensions.droppables;
2294 var draggable = draggables[state.critical.draggable.id];
2295 var isOver = whatIsDraggedOver(needsVisibilityCheck);
2296 !isOver ? process.env.NODE_ENV !== "production" ? invariant(false, 'Must be over a destination in SNAP movement mode') : invariant(false) : void 0;
2297 var destination = droppables[isOver];
2298 var impact = recompute({
2299 impact: needsVisibilityCheck,
2300 viewport: viewport,
2301 destination: destination,
2302 draggables: draggables
2303 });
2304 var clientSelection = getClientBorderBoxCenter({
2305 impact: impact,
2306 draggable: draggable,
2307 droppable: destination,
2308 draggables: draggables,
2309 viewport: viewport,
2310 afterCritical: state.afterCritical
2311 });
2312 return update({
2313 impact: impact,
2314 clientSelection: clientSelection,
2315 state: state,
2316 dimensions: dimensions,
2317 viewport: viewport
2318 });
2319});
2320
2321var getHomeLocation = (function (descriptor) {
2322 return {
2323 index: descriptor.index,
2324 droppableId: descriptor.droppableId
2325 };
2326});
2327
2328var getLiftEffect = (function (_ref) {
2329 var draggable = _ref.draggable,
2330 home = _ref.home,
2331 draggables = _ref.draggables,
2332 viewport = _ref.viewport;
2333 var displacedBy = getDisplacedBy(home.axis, draggable.displaceBy);
2334 var insideHome = getDraggablesInsideDroppable(home.descriptor.id, draggables);
2335 var rawIndex = insideHome.indexOf(draggable);
2336 !(rawIndex !== -1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected draggable to be inside home list') : invariant(false) : void 0;
2337 var afterDragging = insideHome.slice(rawIndex + 1);
2338 var effected = afterDragging.reduce(function (previous, item) {
2339 previous[item.descriptor.id] = true;
2340 return previous;
2341 }, {});
2342 var afterCritical = {
2343 inVirtualList: home.descriptor.mode === 'virtual',
2344 displacedBy: displacedBy,
2345 effected: effected
2346 };
2347 var displaced = getDisplacementGroups({
2348 afterDragging: afterDragging,
2349 destination: home,
2350 displacedBy: displacedBy,
2351 last: null,
2352 viewport: viewport.frame,
2353 forceShouldAnimate: false
2354 });
2355 var impact = {
2356 displaced: displaced,
2357 displacedBy: displacedBy,
2358 at: {
2359 type: 'REORDER',
2360 destination: getHomeLocation(draggable.descriptor)
2361 }
2362 };
2363 return {
2364 impact: impact,
2365 afterCritical: afterCritical
2366 };
2367});
2368
2369var patchDimensionMap = (function (dimensions, updated) {
2370 return {
2371 draggables: dimensions.draggables,
2372 droppables: patchDroppableMap(dimensions.droppables, updated)
2373 };
2374});
2375
2376var start = function start(key) {
2377 if (process.env.NODE_ENV !== 'production') {
2378 {
2379 return;
2380 }
2381 }
2382};
2383var finish = function finish(key) {
2384 if (process.env.NODE_ENV !== 'production') {
2385 {
2386 return;
2387 }
2388 }
2389};
2390
2391var offsetDraggable = (function (_ref) {
2392 var draggable = _ref.draggable,
2393 offset = _ref.offset,
2394 initialWindowScroll = _ref.initialWindowScroll;
2395 var client = cssBoxModel.offset(draggable.client, offset);
2396 var page = cssBoxModel.withScroll(client, initialWindowScroll);
2397
2398 var moved = _extends({}, draggable, {
2399 placeholder: _extends({}, draggable.placeholder, {
2400 client: client
2401 }),
2402 client: client,
2403 page: page
2404 });
2405
2406 return moved;
2407});
2408
2409var getFrame = (function (droppable) {
2410 var frame = droppable.frame;
2411 !frame ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected Droppable to have a frame') : invariant(false) : void 0;
2412 return frame;
2413});
2414
2415var adjustAdditionsForScrollChanges = (function (_ref) {
2416 var additions = _ref.additions,
2417 updatedDroppables = _ref.updatedDroppables,
2418 viewport = _ref.viewport;
2419 var windowScrollChange = viewport.scroll.diff.value;
2420 return additions.map(function (draggable) {
2421 var droppableId = draggable.descriptor.droppableId;
2422 var modified = updatedDroppables[droppableId];
2423 var frame = getFrame(modified);
2424 var droppableScrollChange = frame.scroll.diff.value;
2425 var totalChange = add(windowScrollChange, droppableScrollChange);
2426 var moved = offsetDraggable({
2427 draggable: draggable,
2428 offset: totalChange,
2429 initialWindowScroll: viewport.scroll.initial
2430 });
2431 return moved;
2432 });
2433});
2434
2435var publishWhileDraggingInVirtual = (function (_ref) {
2436 var state = _ref.state,
2437 published = _ref.published;
2438 start();
2439 var withScrollChange = published.modified.map(function (update) {
2440 var existing = state.dimensions.droppables[update.droppableId];
2441 var scrolled = scrollDroppable(existing, update.scroll);
2442 return scrolled;
2443 });
2444
2445 var droppables = _extends({}, state.dimensions.droppables, {}, toDroppableMap(withScrollChange));
2446
2447 var updatedAdditions = toDraggableMap(adjustAdditionsForScrollChanges({
2448 additions: published.additions,
2449 updatedDroppables: droppables,
2450 viewport: state.viewport
2451 }));
2452
2453 var draggables = _extends({}, state.dimensions.draggables, {}, updatedAdditions);
2454
2455 published.removals.forEach(function (id) {
2456 delete draggables[id];
2457 });
2458 var dimensions = {
2459 droppables: droppables,
2460 draggables: draggables
2461 };
2462 var wasOverId = whatIsDraggedOver(state.impact);
2463 var wasOver = wasOverId ? dimensions.droppables[wasOverId] : null;
2464 var draggable = dimensions.draggables[state.critical.draggable.id];
2465 var home = dimensions.droppables[state.critical.droppable.id];
2466
2467 var _getLiftEffect = getLiftEffect({
2468 draggable: draggable,
2469 home: home,
2470 draggables: draggables,
2471 viewport: state.viewport
2472 }),
2473 onLiftImpact = _getLiftEffect.impact,
2474 afterCritical = _getLiftEffect.afterCritical;
2475
2476 var previousImpact = wasOver && wasOver.isCombineEnabled ? state.impact : onLiftImpact;
2477 var impact = getDragImpact({
2478 pageOffset: state.current.page.offset,
2479 draggable: dimensions.draggables[state.critical.draggable.id],
2480 draggables: dimensions.draggables,
2481 droppables: dimensions.droppables,
2482 previousImpact: previousImpact,
2483 viewport: state.viewport,
2484 afterCritical: afterCritical
2485 });
2486 finish();
2487
2488 var draggingState = _extends({
2489 phase: 'DRAGGING'
2490 }, state, {
2491 phase: 'DRAGGING',
2492 impact: impact,
2493 onLiftImpact: onLiftImpact,
2494 dimensions: dimensions,
2495 afterCritical: afterCritical,
2496 forceShouldAnimate: false
2497 });
2498
2499 if (state.phase === 'COLLECTING') {
2500 return draggingState;
2501 }
2502
2503 var dropPending = _extends({
2504 phase: 'DROP_PENDING'
2505 }, draggingState, {
2506 phase: 'DROP_PENDING',
2507 reason: state.reason,
2508 isWaiting: false
2509 });
2510
2511 return dropPending;
2512});
2513
2514var isSnapping = function isSnapping(state) {
2515 return state.movementMode === 'SNAP';
2516};
2517
2518var postDroppableChange = function postDroppableChange(state, updated, isEnabledChanging) {
2519 var dimensions = patchDimensionMap(state.dimensions, updated);
2520
2521 if (!isSnapping(state) || isEnabledChanging) {
2522 return update({
2523 state: state,
2524 dimensions: dimensions
2525 });
2526 }
2527
2528 return refreshSnap({
2529 state: state,
2530 dimensions: dimensions
2531 });
2532};
2533
2534function removeScrollJumpRequest(state) {
2535 if (state.isDragging && state.movementMode === 'SNAP') {
2536 return _extends({
2537 phase: 'DRAGGING'
2538 }, state, {
2539 scrollJumpRequest: null
2540 });
2541 }
2542
2543 return state;
2544}
2545
2546var idle = {
2547 phase: 'IDLE',
2548 completed: null,
2549 shouldFlush: false
2550};
2551var reducer = (function (state, action) {
2552 if (state === void 0) {
2553 state = idle;
2554 }
2555
2556 if (action.type === 'FLUSH') {
2557 return _extends({}, idle, {
2558 shouldFlush: true
2559 });
2560 }
2561
2562 if (action.type === 'INITIAL_PUBLISH') {
2563 !(state.phase === 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'INITIAL_PUBLISH must come after a IDLE phase') : invariant(false) : void 0;
2564 var _action$payload = action.payload,
2565 critical = _action$payload.critical,
2566 clientSelection = _action$payload.clientSelection,
2567 viewport = _action$payload.viewport,
2568 dimensions = _action$payload.dimensions,
2569 movementMode = _action$payload.movementMode;
2570 var draggable = dimensions.draggables[critical.draggable.id];
2571 var home = dimensions.droppables[critical.droppable.id];
2572 var client = {
2573 selection: clientSelection,
2574 borderBoxCenter: draggable.client.borderBox.center,
2575 offset: origin
2576 };
2577 var initial = {
2578 client: client,
2579 page: {
2580 selection: add(client.selection, viewport.scroll.initial),
2581 borderBoxCenter: add(client.selection, viewport.scroll.initial),
2582 offset: add(client.selection, viewport.scroll.diff.value)
2583 }
2584 };
2585 var isWindowScrollAllowed = toDroppableList(dimensions.droppables).every(function (item) {
2586 return !item.isFixedOnPage;
2587 });
2588
2589 var _getLiftEffect = getLiftEffect({
2590 draggable: draggable,
2591 home: home,
2592 draggables: dimensions.draggables,
2593 viewport: viewport
2594 }),
2595 impact = _getLiftEffect.impact,
2596 afterCritical = _getLiftEffect.afterCritical;
2597
2598 var result = {
2599 phase: 'DRAGGING',
2600 isDragging: true,
2601 critical: critical,
2602 movementMode: movementMode,
2603 dimensions: dimensions,
2604 initial: initial,
2605 current: initial,
2606 isWindowScrollAllowed: isWindowScrollAllowed,
2607 impact: impact,
2608 afterCritical: afterCritical,
2609 onLiftImpact: impact,
2610 viewport: viewport,
2611 scrollJumpRequest: null,
2612 forceShouldAnimate: null
2613 };
2614 return result;
2615 }
2616
2617 if (action.type === 'COLLECTION_STARTING') {
2618 if (state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') {
2619 return state;
2620 }
2621
2622 !(state.phase === 'DRAGGING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Collection cannot start from phase " + state.phase) : invariant(false) : void 0;
2623
2624 var _result = _extends({
2625 phase: 'COLLECTING'
2626 }, state, {
2627 phase: 'COLLECTING'
2628 });
2629
2630 return _result;
2631 }
2632
2633 if (action.type === 'PUBLISH_WHILE_DRAGGING') {
2634 !(state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Unexpected " + action.type + " received in phase " + state.phase) : invariant(false) : void 0;
2635 return publishWhileDraggingInVirtual({
2636 state: state,
2637 published: action.payload
2638 });
2639 }
2640
2641 if (action.type === 'MOVE') {
2642 if (state.phase === 'DROP_PENDING') {
2643 return state;
2644 }
2645
2646 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, action.type + " not permitted in phase " + state.phase) : invariant(false) : void 0;
2647 var _clientSelection = action.payload.client;
2648
2649 if (isEqual(_clientSelection, state.current.client.selection)) {
2650 return state;
2651 }
2652
2653 return update({
2654 state: state,
2655 clientSelection: _clientSelection,
2656 impact: isSnapping(state) ? state.impact : null
2657 });
2658 }
2659
2660 if (action.type === 'UPDATE_DROPPABLE_SCROLL') {
2661 if (state.phase === 'DROP_PENDING') {
2662 return removeScrollJumpRequest(state);
2663 }
2664
2665 if (state.phase === 'COLLECTING') {
2666 return removeScrollJumpRequest(state);
2667 }
2668
2669 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, action.type + " not permitted in phase " + state.phase) : invariant(false) : void 0;
2670 var _action$payload2 = action.payload,
2671 id = _action$payload2.id,
2672 newScroll = _action$payload2.newScroll;
2673 var target = state.dimensions.droppables[id];
2674
2675 if (!target) {
2676 return state;
2677 }
2678
2679 var scrolled = scrollDroppable(target, newScroll);
2680 return postDroppableChange(state, scrolled, false);
2681 }
2682
2683 if (action.type === 'UPDATE_DROPPABLE_IS_ENABLED') {
2684 if (state.phase === 'DROP_PENDING') {
2685 return state;
2686 }
2687
2688 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, "Attempting to move in an unsupported phase " + state.phase) : invariant(false) : void 0;
2689 var _action$payload3 = action.payload,
2690 _id = _action$payload3.id,
2691 isEnabled = _action$payload3.isEnabled;
2692 var _target = state.dimensions.droppables[_id];
2693 !_target ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot find Droppable[id: " + _id + "] to toggle its enabled state") : invariant(false) : void 0;
2694 !(_target.isEnabled !== isEnabled) ? process.env.NODE_ENV !== "production" ? invariant(false, "Trying to set droppable isEnabled to " + String(isEnabled) + "\n but it is already " + String(_target.isEnabled)) : invariant(false) : void 0;
2695
2696 var updated = _extends({}, _target, {
2697 isEnabled: isEnabled
2698 });
2699
2700 return postDroppableChange(state, updated, true);
2701 }
2702
2703 if (action.type === 'UPDATE_DROPPABLE_IS_COMBINE_ENABLED') {
2704 if (state.phase === 'DROP_PENDING') {
2705 return state;
2706 }
2707
2708 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, "Attempting to move in an unsupported phase " + state.phase) : invariant(false) : void 0;
2709 var _action$payload4 = action.payload,
2710 _id2 = _action$payload4.id,
2711 isCombineEnabled = _action$payload4.isCombineEnabled;
2712 var _target2 = state.dimensions.droppables[_id2];
2713 !_target2 ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot find Droppable[id: " + _id2 + "] to toggle its isCombineEnabled state") : invariant(false) : void 0;
2714 !(_target2.isCombineEnabled !== isCombineEnabled) ? process.env.NODE_ENV !== "production" ? invariant(false, "Trying to set droppable isCombineEnabled to " + String(isCombineEnabled) + "\n but it is already " + String(_target2.isCombineEnabled)) : invariant(false) : void 0;
2715
2716 var _updated = _extends({}, _target2, {
2717 isCombineEnabled: isCombineEnabled
2718 });
2719
2720 return postDroppableChange(state, _updated, true);
2721 }
2722
2723 if (action.type === 'MOVE_BY_WINDOW_SCROLL') {
2724 if (state.phase === 'DROP_PENDING' || state.phase === 'DROP_ANIMATING') {
2725 return state;
2726 }
2727
2728 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot move by window in phase " + state.phase) : invariant(false) : void 0;
2729 !state.isWindowScrollAllowed ? process.env.NODE_ENV !== "production" ? invariant(false, 'Window scrolling is currently not supported for fixed lists') : invariant(false) : void 0;
2730 var _newScroll = action.payload.newScroll;
2731
2732 if (isEqual(state.viewport.scroll.current, _newScroll)) {
2733 return removeScrollJumpRequest(state);
2734 }
2735
2736 var _viewport = scrollViewport(state.viewport, _newScroll);
2737
2738 if (isSnapping(state)) {
2739 return refreshSnap({
2740 state: state,
2741 viewport: _viewport
2742 });
2743 }
2744
2745 return update({
2746 state: state,
2747 viewport: _viewport
2748 });
2749 }
2750
2751 if (action.type === 'UPDATE_VIEWPORT_MAX_SCROLL') {
2752 if (!isMovementAllowed(state)) {
2753 return state;
2754 }
2755
2756 var maxScroll = action.payload.maxScroll;
2757
2758 if (isEqual(maxScroll, state.viewport.scroll.max)) {
2759 return state;
2760 }
2761
2762 var withMaxScroll = _extends({}, state.viewport, {
2763 scroll: _extends({}, state.viewport.scroll, {
2764 max: maxScroll
2765 })
2766 });
2767
2768 return _extends({
2769 phase: 'DRAGGING'
2770 }, state, {
2771 viewport: withMaxScroll
2772 });
2773 }
2774
2775 if (action.type === 'MOVE_UP' || action.type === 'MOVE_DOWN' || action.type === 'MOVE_LEFT' || action.type === 'MOVE_RIGHT') {
2776 if (state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') {
2777 return state;
2778 }
2779
2780 !(state.phase === 'DRAGGING') ? process.env.NODE_ENV !== "production" ? invariant(false, action.type + " received while not in DRAGGING phase") : invariant(false) : void 0;
2781
2782 var _result2 = moveInDirection({
2783 state: state,
2784 type: action.type
2785 });
2786
2787 if (!_result2) {
2788 return state;
2789 }
2790
2791 return update({
2792 state: state,
2793 impact: _result2.impact,
2794 clientSelection: _result2.clientSelection,
2795 scrollJumpRequest: _result2.scrollJumpRequest
2796 });
2797 }
2798
2799 if (action.type === 'DROP_PENDING') {
2800 var reason = action.payload.reason;
2801 !(state.phase === 'COLLECTING') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Can only move into the DROP_PENDING phase from the COLLECTING phase') : invariant(false) : void 0;
2802
2803 var newState = _extends({
2804 phase: 'DROP_PENDING'
2805 }, state, {
2806 phase: 'DROP_PENDING',
2807 isWaiting: true,
2808 reason: reason
2809 });
2810
2811 return newState;
2812 }
2813
2814 if (action.type === 'DROP_ANIMATE') {
2815 var _action$payload5 = action.payload,
2816 completed = _action$payload5.completed,
2817 dropDuration = _action$payload5.dropDuration,
2818 newHomeClientOffset = _action$payload5.newHomeClientOffset;
2819 !(state.phase === 'DRAGGING' || state.phase === 'DROP_PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot animate drop from phase " + state.phase) : invariant(false) : void 0;
2820 var _result3 = {
2821 phase: 'DROP_ANIMATING',
2822 completed: completed,
2823 dropDuration: dropDuration,
2824 newHomeClientOffset: newHomeClientOffset,
2825 dimensions: state.dimensions
2826 };
2827 return _result3;
2828 }
2829
2830 if (action.type === 'DROP_COMPLETE') {
2831 var _completed = action.payload.completed;
2832 return {
2833 phase: 'IDLE',
2834 completed: _completed,
2835 shouldFlush: false
2836 };
2837 }
2838
2839 return state;
2840});
2841
2842var beforeInitialCapture = function beforeInitialCapture(args) {
2843 return {
2844 type: 'BEFORE_INITIAL_CAPTURE',
2845 payload: args
2846 };
2847};
2848var lift = function lift(args) {
2849 return {
2850 type: 'LIFT',
2851 payload: args
2852 };
2853};
2854var initialPublish = function initialPublish(args) {
2855 return {
2856 type: 'INITIAL_PUBLISH',
2857 payload: args
2858 };
2859};
2860var publishWhileDragging = function publishWhileDragging(args) {
2861 return {
2862 type: 'PUBLISH_WHILE_DRAGGING',
2863 payload: args
2864 };
2865};
2866var collectionStarting = function collectionStarting() {
2867 return {
2868 type: 'COLLECTION_STARTING',
2869 payload: null
2870 };
2871};
2872var updateDroppableScroll = function updateDroppableScroll(args) {
2873 return {
2874 type: 'UPDATE_DROPPABLE_SCROLL',
2875 payload: args
2876 };
2877};
2878var updateDroppableIsEnabled = function updateDroppableIsEnabled(args) {
2879 return {
2880 type: 'UPDATE_DROPPABLE_IS_ENABLED',
2881 payload: args
2882 };
2883};
2884var updateDroppableIsCombineEnabled = function updateDroppableIsCombineEnabled(args) {
2885 return {
2886 type: 'UPDATE_DROPPABLE_IS_COMBINE_ENABLED',
2887 payload: args
2888 };
2889};
2890var move = function move(args) {
2891 return {
2892 type: 'MOVE',
2893 payload: args
2894 };
2895};
2896var moveByWindowScroll = function moveByWindowScroll(args) {
2897 return {
2898 type: 'MOVE_BY_WINDOW_SCROLL',
2899 payload: args
2900 };
2901};
2902var updateViewportMaxScroll = function updateViewportMaxScroll(args) {
2903 return {
2904 type: 'UPDATE_VIEWPORT_MAX_SCROLL',
2905 payload: args
2906 };
2907};
2908var moveUp = function moveUp() {
2909 return {
2910 type: 'MOVE_UP',
2911 payload: null
2912 };
2913};
2914var moveDown = function moveDown() {
2915 return {
2916 type: 'MOVE_DOWN',
2917 payload: null
2918 };
2919};
2920var moveRight = function moveRight() {
2921 return {
2922 type: 'MOVE_RIGHT',
2923 payload: null
2924 };
2925};
2926var moveLeft = function moveLeft() {
2927 return {
2928 type: 'MOVE_LEFT',
2929 payload: null
2930 };
2931};
2932var flush = function flush() {
2933 return {
2934 type: 'FLUSH',
2935 payload: null
2936 };
2937};
2938var animateDrop = function animateDrop(args) {
2939 return {
2940 type: 'DROP_ANIMATE',
2941 payload: args
2942 };
2943};
2944var completeDrop = function completeDrop(args) {
2945 return {
2946 type: 'DROP_COMPLETE',
2947 payload: args
2948 };
2949};
2950var drop = function drop(args) {
2951 return {
2952 type: 'DROP',
2953 payload: args
2954 };
2955};
2956var dropPending = function dropPending(args) {
2957 return {
2958 type: 'DROP_PENDING',
2959 payload: args
2960 };
2961};
2962var dropAnimationFinished = function dropAnimationFinished() {
2963 return {
2964 type: 'DROP_ANIMATION_FINISHED',
2965 payload: null
2966 };
2967};
2968
2969function checkIndexes(insideDestination) {
2970 if (insideDestination.length <= 1) {
2971 return;
2972 }
2973
2974 var indexes = insideDestination.map(function (d) {
2975 return d.descriptor.index;
2976 });
2977 var errors = {};
2978
2979 for (var i = 1; i < indexes.length; i++) {
2980 var current = indexes[i];
2981 var previous = indexes[i - 1];
2982
2983 if (current !== previous + 1) {
2984 errors[current] = true;
2985 }
2986 }
2987
2988 if (!Object.keys(errors).length) {
2989 return;
2990 }
2991
2992 var formatted = indexes.map(function (index) {
2993 var hasError = Boolean(errors[index]);
2994 return hasError ? "[\uD83D\uDD25" + index + "]" : "" + index;
2995 }).join(', ');
2996 process.env.NODE_ENV !== "production" ? warning("\n Detected non-consecutive <Draggable /> indexes.\n\n (This can cause unexpected bugs)\n\n " + formatted + "\n ") : void 0;
2997}
2998
2999function validateDimensions(critical, dimensions) {
3000 if (process.env.NODE_ENV !== 'production') {
3001 var insideDestination = getDraggablesInsideDroppable(critical.droppable.id, dimensions.draggables);
3002 checkIndexes(insideDestination);
3003 }
3004}
3005
3006var lift$1 = (function (marshal) {
3007 return function (_ref) {
3008 var getState = _ref.getState,
3009 dispatch = _ref.dispatch;
3010 return function (next) {
3011 return function (action) {
3012 if (action.type !== 'LIFT') {
3013 next(action);
3014 return;
3015 }
3016
3017 var _action$payload = action.payload,
3018 id = _action$payload.id,
3019 clientSelection = _action$payload.clientSelection,
3020 movementMode = _action$payload.movementMode;
3021 var initial = getState();
3022
3023 if (initial.phase === 'DROP_ANIMATING') {
3024 dispatch(completeDrop({
3025 completed: initial.completed
3026 }));
3027 }
3028
3029 !(getState().phase === 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Unexpected phase to start a drag') : invariant(false) : void 0;
3030 dispatch(flush());
3031 dispatch(beforeInitialCapture({
3032 draggableId: id,
3033 movementMode: movementMode
3034 }));
3035 var scrollOptions = {
3036 shouldPublishImmediately: movementMode === 'SNAP'
3037 };
3038 var request = {
3039 draggableId: id,
3040 scrollOptions: scrollOptions
3041 };
3042
3043 var _marshal$startPublish = marshal.startPublishing(request),
3044 critical = _marshal$startPublish.critical,
3045 dimensions = _marshal$startPublish.dimensions,
3046 viewport = _marshal$startPublish.viewport;
3047
3048 validateDimensions(critical, dimensions);
3049 dispatch(initialPublish({
3050 critical: critical,
3051 dimensions: dimensions,
3052 clientSelection: clientSelection,
3053 movementMode: movementMode,
3054 viewport: viewport
3055 }));
3056 };
3057 };
3058 };
3059});
3060
3061var style = (function (marshal) {
3062 return function () {
3063 return function (next) {
3064 return function (action) {
3065 if (action.type === 'INITIAL_PUBLISH') {
3066 marshal.dragging();
3067 }
3068
3069 if (action.type === 'DROP_ANIMATE') {
3070 marshal.dropping(action.payload.completed.result.reason);
3071 }
3072
3073 if (action.type === 'FLUSH' || action.type === 'DROP_COMPLETE') {
3074 marshal.resting();
3075 }
3076
3077 next(action);
3078 };
3079 };
3080 };
3081});
3082
3083var curves = {
3084 outOfTheWay: 'cubic-bezier(0.2, 0, 0, 1)',
3085 drop: 'cubic-bezier(.2,1,.1,1)'
3086};
3087var combine = {
3088 opacity: {
3089 drop: 0,
3090 combining: 0.7
3091 },
3092 scale: {
3093 drop: 0.75
3094 }
3095};
3096var timings = {
3097 outOfTheWay: 0.2,
3098 minDropTime: 0.33,
3099 maxDropTime: 0.55
3100};
3101var outOfTheWayTiming = timings.outOfTheWay + "s " + curves.outOfTheWay;
3102var transitions = {
3103 fluid: "opacity " + outOfTheWayTiming,
3104 snap: "transform " + outOfTheWayTiming + ", opacity " + outOfTheWayTiming,
3105 drop: function drop(duration) {
3106 var timing = duration + "s " + curves.drop;
3107 return "transform " + timing + ", opacity " + timing;
3108 },
3109 outOfTheWay: "transform " + outOfTheWayTiming,
3110 placeholder: "height " + outOfTheWayTiming + ", width " + outOfTheWayTiming + ", margin " + outOfTheWayTiming
3111};
3112
3113var moveTo = function moveTo(offset) {
3114 return isEqual(offset, origin) ? null : "translate(" + offset.x + "px, " + offset.y + "px)";
3115};
3116
3117var transforms = {
3118 moveTo: moveTo,
3119 drop: function drop(offset, isCombining) {
3120 var translate = moveTo(offset);
3121
3122 if (!translate) {
3123 return null;
3124 }
3125
3126 if (!isCombining) {
3127 return translate;
3128 }
3129
3130 return translate + " scale(" + combine.scale.drop + ")";
3131 }
3132};
3133
3134var minDropTime = timings.minDropTime,
3135 maxDropTime = timings.maxDropTime;
3136var dropTimeRange = maxDropTime - minDropTime;
3137var maxDropTimeAtDistance = 1500;
3138var cancelDropModifier = 0.6;
3139var getDropDuration = (function (_ref) {
3140 var current = _ref.current,
3141 destination = _ref.destination,
3142 reason = _ref.reason;
3143 var distance$1 = distance(current, destination);
3144
3145 if (distance$1 <= 0) {
3146 return minDropTime;
3147 }
3148
3149 if (distance$1 >= maxDropTimeAtDistance) {
3150 return maxDropTime;
3151 }
3152
3153 var percentage = distance$1 / maxDropTimeAtDistance;
3154 var duration = minDropTime + dropTimeRange * percentage;
3155 var withDuration = reason === 'CANCEL' ? duration * cancelDropModifier : duration;
3156 return Number(withDuration.toFixed(2));
3157});
3158
3159var getNewHomeClientOffset = (function (_ref) {
3160 var impact = _ref.impact,
3161 draggable = _ref.draggable,
3162 dimensions = _ref.dimensions,
3163 viewport = _ref.viewport,
3164 afterCritical = _ref.afterCritical;
3165 var draggables = dimensions.draggables,
3166 droppables = dimensions.droppables;
3167 var droppableId = whatIsDraggedOver(impact);
3168 var destination = droppableId ? droppables[droppableId] : null;
3169 var home = droppables[draggable.descriptor.droppableId];
3170 var newClientCenter = getClientBorderBoxCenter({
3171 impact: impact,
3172 draggable: draggable,
3173 draggables: draggables,
3174 afterCritical: afterCritical,
3175 droppable: destination || home,
3176 viewport: viewport
3177 });
3178 var offset = subtract(newClientCenter, draggable.client.borderBox.center);
3179 return offset;
3180});
3181
3182var getDropImpact = (function (_ref) {
3183 var draggables = _ref.draggables,
3184 reason = _ref.reason,
3185 lastImpact = _ref.lastImpact,
3186 home = _ref.home,
3187 viewport = _ref.viewport,
3188 onLiftImpact = _ref.onLiftImpact;
3189
3190 if (!lastImpact.at || reason !== 'DROP') {
3191 var recomputedHomeImpact = recompute({
3192 draggables: draggables,
3193 impact: onLiftImpact,
3194 destination: home,
3195 viewport: viewport,
3196 forceShouldAnimate: true
3197 });
3198 return {
3199 impact: recomputedHomeImpact,
3200 didDropInsideDroppable: false
3201 };
3202 }
3203
3204 if (lastImpact.at.type === 'REORDER') {
3205 return {
3206 impact: lastImpact,
3207 didDropInsideDroppable: true
3208 };
3209 }
3210
3211 var withoutMovement = _extends({}, lastImpact, {
3212 displaced: emptyGroups
3213 });
3214
3215 return {
3216 impact: withoutMovement,
3217 didDropInsideDroppable: true
3218 };
3219});
3220
3221var drop$1 = (function (_ref) {
3222 var getState = _ref.getState,
3223 dispatch = _ref.dispatch;
3224 return function (next) {
3225 return function (action) {
3226 if (action.type !== 'DROP') {
3227 next(action);
3228 return;
3229 }
3230
3231 var state = getState();
3232 var reason = action.payload.reason;
3233
3234 if (state.phase === 'COLLECTING') {
3235 dispatch(dropPending({
3236 reason: reason
3237 }));
3238 return;
3239 }
3240
3241 if (state.phase === 'IDLE') {
3242 return;
3243 }
3244
3245 var isWaitingForDrop = state.phase === 'DROP_PENDING' && state.isWaiting;
3246 !!isWaitingForDrop ? process.env.NODE_ENV !== "production" ? invariant(false, 'A DROP action occurred while DROP_PENDING and still waiting') : invariant(false) : void 0;
3247 !(state.phase === 'DRAGGING' || state.phase === 'DROP_PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot drop in phase: " + state.phase) : invariant(false) : void 0;
3248 var critical = state.critical;
3249 var dimensions = state.dimensions;
3250 var draggable = dimensions.draggables[state.critical.draggable.id];
3251
3252 var _getDropImpact = getDropImpact({
3253 reason: reason,
3254 lastImpact: state.impact,
3255 afterCritical: state.afterCritical,
3256 onLiftImpact: state.onLiftImpact,
3257 home: state.dimensions.droppables[state.critical.droppable.id],
3258 viewport: state.viewport,
3259 draggables: state.dimensions.draggables
3260 }),
3261 impact = _getDropImpact.impact,
3262 didDropInsideDroppable = _getDropImpact.didDropInsideDroppable;
3263
3264 var destination = didDropInsideDroppable ? tryGetDestination(impact) : null;
3265 var combine = didDropInsideDroppable ? tryGetCombine(impact) : null;
3266 var source = {
3267 index: critical.draggable.index,
3268 droppableId: critical.droppable.id
3269 };
3270 var result = {
3271 draggableId: draggable.descriptor.id,
3272 type: draggable.descriptor.type,
3273 source: source,
3274 reason: reason,
3275 mode: state.movementMode,
3276 destination: destination,
3277 combine: combine
3278 };
3279 var newHomeClientOffset = getNewHomeClientOffset({
3280 impact: impact,
3281 draggable: draggable,
3282 dimensions: dimensions,
3283 viewport: state.viewport,
3284 afterCritical: state.afterCritical
3285 });
3286 var completed = {
3287 critical: state.critical,
3288 afterCritical: state.afterCritical,
3289 result: result,
3290 impact: impact
3291 };
3292 var isAnimationRequired = !isEqual(state.current.client.offset, newHomeClientOffset) || Boolean(result.combine);
3293
3294 if (!isAnimationRequired) {
3295 dispatch(completeDrop({
3296 completed: completed
3297 }));
3298 return;
3299 }
3300
3301 var dropDuration = getDropDuration({
3302 current: state.current.client.offset,
3303 destination: newHomeClientOffset,
3304 reason: reason
3305 });
3306 var args = {
3307 newHomeClientOffset: newHomeClientOffset,
3308 dropDuration: dropDuration,
3309 completed: completed
3310 };
3311 dispatch(animateDrop(args));
3312 };
3313 };
3314});
3315
3316var getWindowScroll = (function () {
3317 return {
3318 x: window.pageXOffset,
3319 y: window.pageYOffset
3320 };
3321});
3322
3323function getWindowScrollBinding(update) {
3324 return {
3325 eventName: 'scroll',
3326 options: {
3327 passive: true,
3328 capture: false
3329 },
3330 fn: function fn(event) {
3331 if (event.target !== window && event.target !== window.document) {
3332 return;
3333 }
3334
3335 update();
3336 }
3337 };
3338}
3339
3340function getScrollListener(_ref) {
3341 var onWindowScroll = _ref.onWindowScroll;
3342
3343 function updateScroll() {
3344 onWindowScroll(getWindowScroll());
3345 }
3346
3347 var scheduled = rafSchd(updateScroll);
3348 var binding = getWindowScrollBinding(scheduled);
3349 var unbind = noop;
3350
3351 function isActive() {
3352 return unbind !== noop;
3353 }
3354
3355 function start() {
3356 !!isActive() ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot start scroll listener when already active') : invariant(false) : void 0;
3357 unbind = bindEvents(window, [binding]);
3358 }
3359
3360 function stop() {
3361 !isActive() ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot stop scroll listener when not active') : invariant(false) : void 0;
3362 scheduled.cancel();
3363 unbind();
3364 unbind = noop;
3365 }
3366
3367 return {
3368 start: start,
3369 stop: stop,
3370 isActive: isActive
3371 };
3372}
3373
3374var shouldEnd = function shouldEnd(action) {
3375 return action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATE' || action.type === 'FLUSH';
3376};
3377
3378var scrollListener = (function (store) {
3379 var listener = getScrollListener({
3380 onWindowScroll: function onWindowScroll(newScroll) {
3381 store.dispatch(moveByWindowScroll({
3382 newScroll: newScroll
3383 }));
3384 }
3385 });
3386 return function (next) {
3387 return function (action) {
3388 if (!listener.isActive() && action.type === 'INITIAL_PUBLISH') {
3389 listener.start();
3390 }
3391
3392 if (listener.isActive() && shouldEnd(action)) {
3393 listener.stop();
3394 }
3395
3396 next(action);
3397 };
3398 };
3399});
3400
3401var getExpiringAnnounce = (function (announce) {
3402 var wasCalled = false;
3403 var isExpired = false;
3404 var timeoutId = setTimeout(function () {
3405 isExpired = true;
3406 });
3407
3408 var result = function result(message) {
3409 if (wasCalled) {
3410 process.env.NODE_ENV !== "production" ? warning('Announcement already made. Not making a second announcement') : void 0;
3411 return;
3412 }
3413
3414 if (isExpired) {
3415 process.env.NODE_ENV !== "production" ? warning("\n Announcements cannot be made asynchronously.\n Default message has already been announced.\n ") : void 0;
3416 return;
3417 }
3418
3419 wasCalled = true;
3420 announce(message);
3421 clearTimeout(timeoutId);
3422 };
3423
3424 result.wasCalled = function () {
3425 return wasCalled;
3426 };
3427
3428 return result;
3429});
3430
3431var getAsyncMarshal = (function () {
3432 var entries = [];
3433
3434 var execute = function execute(timerId) {
3435 var index = findIndex(entries, function (item) {
3436 return item.timerId === timerId;
3437 });
3438 !(index !== -1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find timer') : invariant(false) : void 0;
3439
3440 var _entries$splice = entries.splice(index, 1),
3441 entry = _entries$splice[0];
3442
3443 entry.callback();
3444 };
3445
3446 var add = function add(fn) {
3447 var timerId = setTimeout(function () {
3448 return execute(timerId);
3449 });
3450 var entry = {
3451 timerId: timerId,
3452 callback: fn
3453 };
3454 entries.push(entry);
3455 };
3456
3457 var flush = function flush() {
3458 if (!entries.length) {
3459 return;
3460 }
3461
3462 var shallow = [].concat(entries);
3463 entries.length = 0;
3464 shallow.forEach(function (entry) {
3465 clearTimeout(entry.timerId);
3466 entry.callback();
3467 });
3468 };
3469
3470 return {
3471 add: add,
3472 flush: flush
3473 };
3474});
3475
3476var areLocationsEqual = function areLocationsEqual(first, second) {
3477 if (first == null && second == null) {
3478 return true;
3479 }
3480
3481 if (first == null || second == null) {
3482 return false;
3483 }
3484
3485 return first.droppableId === second.droppableId && first.index === second.index;
3486};
3487var isCombineEqual = function isCombineEqual(first, second) {
3488 if (first == null && second == null) {
3489 return true;
3490 }
3491
3492 if (first == null || second == null) {
3493 return false;
3494 }
3495
3496 return first.draggableId === second.draggableId && first.droppableId === second.droppableId;
3497};
3498var isCriticalEqual = function isCriticalEqual(first, second) {
3499 if (first === second) {
3500 return true;
3501 }
3502
3503 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;
3504 var isDroppableEqual = first.droppable.id === second.droppable.id && first.droppable.type === second.droppable.type;
3505 return isDraggableEqual && isDroppableEqual;
3506};
3507
3508var withTimings = function withTimings(key, fn) {
3509 start();
3510 fn();
3511 finish();
3512};
3513
3514var getDragStart = function getDragStart(critical, mode) {
3515 return {
3516 draggableId: critical.draggable.id,
3517 type: critical.droppable.type,
3518 source: {
3519 droppableId: critical.droppable.id,
3520 index: critical.draggable.index
3521 },
3522 mode: mode
3523 };
3524};
3525
3526var execute = function execute(responder, data, announce, getDefaultMessage) {
3527 if (!responder) {
3528 announce(getDefaultMessage(data));
3529 return;
3530 }
3531
3532 var willExpire = getExpiringAnnounce(announce);
3533 var provided = {
3534 announce: willExpire
3535 };
3536 responder(data, provided);
3537
3538 if (!willExpire.wasCalled()) {
3539 announce(getDefaultMessage(data));
3540 }
3541};
3542
3543var getPublisher = (function (getResponders, announce) {
3544 var asyncMarshal = getAsyncMarshal();
3545 var dragging = null;
3546
3547 var beforeCapture = function beforeCapture(draggableId, mode) {
3548 !!dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onBeforeCapture as a drag start has already been published') : invariant(false) : void 0;
3549 withTimings('onBeforeCapture', function () {
3550 var fn = getResponders().onBeforeCapture;
3551
3552 if (fn) {
3553 var before = {
3554 draggableId: draggableId,
3555 mode: mode
3556 };
3557 fn(before);
3558 }
3559 });
3560 };
3561
3562 var beforeStart = function beforeStart(critical, mode) {
3563 !!dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onBeforeDragStart as a drag start has already been published') : invariant(false) : void 0;
3564 withTimings('onBeforeDragStart', function () {
3565 var fn = getResponders().onBeforeDragStart;
3566
3567 if (fn) {
3568 fn(getDragStart(critical, mode));
3569 }
3570 });
3571 };
3572
3573 var start = function start(critical, mode) {
3574 !!dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onBeforeDragStart as a drag start has already been published') : invariant(false) : void 0;
3575 var data = getDragStart(critical, mode);
3576 dragging = {
3577 mode: mode,
3578 lastCritical: critical,
3579 lastLocation: data.source,
3580 lastCombine: null
3581 };
3582 asyncMarshal.add(function () {
3583 withTimings('onDragStart', function () {
3584 return execute(getResponders().onDragStart, data, announce, preset.onDragStart);
3585 });
3586 });
3587 };
3588
3589 var update = function update(critical, impact) {
3590 var location = tryGetDestination(impact);
3591 var combine = tryGetCombine(impact);
3592 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onDragMove when onDragStart has not been called') : invariant(false) : void 0;
3593 var hasCriticalChanged = !isCriticalEqual(critical, dragging.lastCritical);
3594
3595 if (hasCriticalChanged) {
3596 dragging.lastCritical = critical;
3597 }
3598
3599 var hasLocationChanged = !areLocationsEqual(dragging.lastLocation, location);
3600
3601 if (hasLocationChanged) {
3602 dragging.lastLocation = location;
3603 }
3604
3605 var hasGroupingChanged = !isCombineEqual(dragging.lastCombine, combine);
3606
3607 if (hasGroupingChanged) {
3608 dragging.lastCombine = combine;
3609 }
3610
3611 if (!hasCriticalChanged && !hasLocationChanged && !hasGroupingChanged) {
3612 return;
3613 }
3614
3615 var data = _extends({}, getDragStart(critical, dragging.mode), {
3616 combine: combine,
3617 destination: location
3618 });
3619
3620 asyncMarshal.add(function () {
3621 withTimings('onDragUpdate', function () {
3622 return execute(getResponders().onDragUpdate, data, announce, preset.onDragUpdate);
3623 });
3624 });
3625 };
3626
3627 var flush = function flush() {
3628 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Can only flush responders while dragging') : invariant(false) : void 0;
3629 asyncMarshal.flush();
3630 };
3631
3632 var drop = function drop(result) {
3633 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onDragEnd when there is no matching onDragStart') : invariant(false) : void 0;
3634 dragging = null;
3635 withTimings('onDragEnd', function () {
3636 return execute(getResponders().onDragEnd, result, announce, preset.onDragEnd);
3637 });
3638 };
3639
3640 var abort = function abort() {
3641 if (!dragging) {
3642 return;
3643 }
3644
3645 var result = _extends({}, getDragStart(dragging.lastCritical, dragging.mode), {
3646 combine: null,
3647 destination: null,
3648 reason: 'CANCEL'
3649 });
3650
3651 drop(result);
3652 };
3653
3654 return {
3655 beforeCapture: beforeCapture,
3656 beforeStart: beforeStart,
3657 start: start,
3658 update: update,
3659 flush: flush,
3660 drop: drop,
3661 abort: abort
3662 };
3663});
3664
3665var responders = (function (getResponders, announce) {
3666 var publisher = getPublisher(getResponders, announce);
3667 return function (store) {
3668 return function (next) {
3669 return function (action) {
3670 if (action.type === 'BEFORE_INITIAL_CAPTURE') {
3671 publisher.beforeCapture(action.payload.draggableId, action.payload.movementMode);
3672 return;
3673 }
3674
3675 if (action.type === 'INITIAL_PUBLISH') {
3676 var critical = action.payload.critical;
3677 publisher.beforeStart(critical, action.payload.movementMode);
3678 next(action);
3679 publisher.start(critical, action.payload.movementMode);
3680 return;
3681 }
3682
3683 if (action.type === 'DROP_COMPLETE') {
3684 var result = action.payload.completed.result;
3685 publisher.flush();
3686 next(action);
3687 publisher.drop(result);
3688 return;
3689 }
3690
3691 next(action);
3692
3693 if (action.type === 'FLUSH') {
3694 publisher.abort();
3695 return;
3696 }
3697
3698 var state = store.getState();
3699
3700 if (state.phase === 'DRAGGING') {
3701 publisher.update(state.critical, state.impact);
3702 }
3703 };
3704 };
3705 };
3706});
3707
3708var dropAnimationFinish = (function (store) {
3709 return function (next) {
3710 return function (action) {
3711 if (action.type !== 'DROP_ANIMATION_FINISHED') {
3712 next(action);
3713 return;
3714 }
3715
3716 var state = store.getState();
3717 !(state.phase === 'DROP_ANIMATING') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot finish a drop animating when no drop is occurring') : invariant(false) : void 0;
3718 store.dispatch(completeDrop({
3719 completed: state.completed
3720 }));
3721 };
3722 };
3723});
3724
3725var dropAnimationFlushOnScroll = (function (store) {
3726 var unbind = null;
3727 var frameId = null;
3728
3729 function clear() {
3730 if (frameId) {
3731 cancelAnimationFrame(frameId);
3732 frameId = null;
3733 }
3734
3735 if (unbind) {
3736 unbind();
3737 unbind = null;
3738 }
3739 }
3740
3741 return function (next) {
3742 return function (action) {
3743 if (action.type === 'FLUSH' || action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATION_FINISHED') {
3744 clear();
3745 }
3746
3747 next(action);
3748
3749 if (action.type !== 'DROP_ANIMATE') {
3750 return;
3751 }
3752
3753 var binding = {
3754 eventName: 'scroll',
3755 options: {
3756 capture: true,
3757 passive: false,
3758 once: true
3759 },
3760 fn: function flushDropAnimation() {
3761 var state = store.getState();
3762
3763 if (state.phase === 'DROP_ANIMATING') {
3764 store.dispatch(dropAnimationFinished());
3765 }
3766 }
3767 };
3768 frameId = requestAnimationFrame(function () {
3769 frameId = null;
3770 unbind = bindEvents(window, [binding]);
3771 });
3772 };
3773 };
3774});
3775
3776var dimensionMarshalStopper = (function (marshal) {
3777 return function () {
3778 return function (next) {
3779 return function (action) {
3780 if (action.type === 'DROP_COMPLETE' || action.type === 'FLUSH' || action.type === 'DROP_ANIMATE') {
3781 marshal.stopPublishing();
3782 }
3783
3784 next(action);
3785 };
3786 };
3787 };
3788});
3789
3790var focus = (function (marshal) {
3791 var isWatching = false;
3792 return function () {
3793 return function (next) {
3794 return function (action) {
3795 if (action.type === 'INITIAL_PUBLISH') {
3796 isWatching = true;
3797 marshal.tryRecordFocus(action.payload.critical.draggable.id);
3798 next(action);
3799 marshal.tryRestoreFocusRecorded();
3800 return;
3801 }
3802
3803 next(action);
3804
3805 if (!isWatching) {
3806 return;
3807 }
3808
3809 if (action.type === 'FLUSH') {
3810 isWatching = false;
3811 marshal.tryRestoreFocusRecorded();
3812 return;
3813 }
3814
3815 if (action.type === 'DROP_COMPLETE') {
3816 isWatching = false;
3817 var result = action.payload.completed.result;
3818
3819 if (result.combine) {
3820 marshal.tryShiftRecord(result.draggableId, result.combine.draggableId);
3821 }
3822
3823 marshal.tryRestoreFocusRecorded();
3824 }
3825 };
3826 };
3827 };
3828});
3829
3830var shouldStop = function shouldStop(action) {
3831 return action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATE' || action.type === 'FLUSH';
3832};
3833
3834var autoScroll = (function (autoScroller) {
3835 return function (store) {
3836 return function (next) {
3837 return function (action) {
3838 if (shouldStop(action)) {
3839 autoScroller.stop();
3840 next(action);
3841 return;
3842 }
3843
3844 if (action.type === 'INITIAL_PUBLISH') {
3845 next(action);
3846 var state = store.getState();
3847 !(state.phase === 'DRAGGING') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected phase to be DRAGGING after INITIAL_PUBLISH') : invariant(false) : void 0;
3848 autoScroller.start(state);
3849 return;
3850 }
3851
3852 next(action);
3853 autoScroller.scroll(store.getState());
3854 };
3855 };
3856 };
3857});
3858
3859var pendingDrop = (function (store) {
3860 return function (next) {
3861 return function (action) {
3862 next(action);
3863
3864 if (action.type !== 'PUBLISH_WHILE_DRAGGING') {
3865 return;
3866 }
3867
3868 var postActionState = store.getState();
3869
3870 if (postActionState.phase !== 'DROP_PENDING') {
3871 return;
3872 }
3873
3874 if (postActionState.isWaiting) {
3875 return;
3876 }
3877
3878 store.dispatch(drop({
3879 reason: postActionState.reason
3880 }));
3881 };
3882 };
3883});
3884
3885var composeEnhancers = process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
3886 name: 'react-beautiful-dnd'
3887}) : redux.compose;
3888var createStore = (function (_ref) {
3889 var dimensionMarshal = _ref.dimensionMarshal,
3890 focusMarshal = _ref.focusMarshal,
3891 styleMarshal = _ref.styleMarshal,
3892 getResponders = _ref.getResponders,
3893 announce = _ref.announce,
3894 autoScroller = _ref.autoScroller;
3895 return redux.createStore(reducer, composeEnhancers(redux.applyMiddleware(style(styleMarshal), dimensionMarshalStopper(dimensionMarshal), lift$1(dimensionMarshal), drop$1, dropAnimationFinish, dropAnimationFlushOnScroll, pendingDrop, autoScroll(autoScroller), scrollListener, focus(focusMarshal), responders(getResponders, announce))));
3896});
3897
3898var clean$1 = function clean() {
3899 return {
3900 additions: {},
3901 removals: {},
3902 modified: {}
3903 };
3904};
3905function createPublisher(_ref) {
3906 var registry = _ref.registry,
3907 callbacks = _ref.callbacks;
3908 var staging = clean$1();
3909 var frameId = null;
3910
3911 var collect = function collect() {
3912 if (frameId) {
3913 return;
3914 }
3915
3916 callbacks.collectionStarting();
3917 frameId = requestAnimationFrame(function () {
3918 frameId = null;
3919 start();
3920 var _staging = staging,
3921 additions = _staging.additions,
3922 removals = _staging.removals,
3923 modified = _staging.modified;
3924 var added = Object.keys(additions).map(function (id) {
3925 return registry.draggable.getById(id).getDimension(origin);
3926 }).sort(function (a, b) {
3927 return a.descriptor.index - b.descriptor.index;
3928 });
3929 var updated = Object.keys(modified).map(function (id) {
3930 var entry = registry.droppable.getById(id);
3931 var scroll = entry.callbacks.getScrollWhileDragging();
3932 return {
3933 droppableId: id,
3934 scroll: scroll
3935 };
3936 });
3937 var result = {
3938 additions: added,
3939 removals: Object.keys(removals),
3940 modified: updated
3941 };
3942 staging = clean$1();
3943 finish();
3944 callbacks.publish(result);
3945 });
3946 };
3947
3948 var add = function add(entry) {
3949 var id = entry.descriptor.id;
3950 staging.additions[id] = entry;
3951 staging.modified[entry.descriptor.droppableId] = true;
3952
3953 if (staging.removals[id]) {
3954 delete staging.removals[id];
3955 }
3956
3957 collect();
3958 };
3959
3960 var remove = function remove(entry) {
3961 var descriptor = entry.descriptor;
3962 staging.removals[descriptor.id] = true;
3963 staging.modified[descriptor.droppableId] = true;
3964
3965 if (staging.additions[descriptor.id]) {
3966 delete staging.additions[descriptor.id];
3967 }
3968
3969 collect();
3970 };
3971
3972 var stop = function stop() {
3973 if (!frameId) {
3974 return;
3975 }
3976
3977 cancelAnimationFrame(frameId);
3978 frameId = null;
3979 staging = clean$1();
3980 };
3981
3982 return {
3983 add: add,
3984 remove: remove,
3985 stop: stop
3986 };
3987}
3988
3989var getMaxScroll = (function (_ref) {
3990 var scrollHeight = _ref.scrollHeight,
3991 scrollWidth = _ref.scrollWidth,
3992 height = _ref.height,
3993 width = _ref.width;
3994 var maxScroll = subtract({
3995 x: scrollWidth,
3996 y: scrollHeight
3997 }, {
3998 x: width,
3999 y: height
4000 });
4001 var adjustedMaxScroll = {
4002 x: Math.max(0, maxScroll.x),
4003 y: Math.max(0, maxScroll.y)
4004 };
4005 return adjustedMaxScroll;
4006});
4007
4008var getDocumentElement = (function () {
4009 var doc = document.documentElement;
4010 !doc ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot find document.documentElement') : invariant(false) : void 0;
4011 return doc;
4012});
4013
4014var getMaxWindowScroll = (function () {
4015 var doc = getDocumentElement();
4016 var maxScroll = getMaxScroll({
4017 scrollHeight: doc.scrollHeight,
4018 scrollWidth: doc.scrollWidth,
4019 width: doc.clientWidth,
4020 height: doc.clientHeight
4021 });
4022 return maxScroll;
4023});
4024
4025var getViewport = (function () {
4026 var scroll = getWindowScroll();
4027 var maxScroll = getMaxWindowScroll();
4028 var top = scroll.y;
4029 var left = scroll.x;
4030 var doc = getDocumentElement();
4031 var width = doc.clientWidth;
4032 var height = doc.clientHeight;
4033 var right = left + width;
4034 var bottom = top + height;
4035 var frame = cssBoxModel.getRect({
4036 top: top,
4037 left: left,
4038 right: right,
4039 bottom: bottom
4040 });
4041 var viewport = {
4042 frame: frame,
4043 scroll: {
4044 initial: scroll,
4045 current: scroll,
4046 max: maxScroll,
4047 diff: {
4048 value: origin,
4049 displacement: origin
4050 }
4051 }
4052 };
4053 return viewport;
4054});
4055
4056var getInitialPublish = (function (_ref) {
4057 var critical = _ref.critical,
4058 scrollOptions = _ref.scrollOptions,
4059 registry = _ref.registry;
4060 start();
4061 var viewport = getViewport();
4062 var windowScroll = viewport.scroll.current;
4063 var home = critical.droppable;
4064 var droppables = registry.droppable.getAllByType(home.type).map(function (entry) {
4065 return entry.callbacks.getDimensionAndWatchScroll(windowScroll, scrollOptions);
4066 });
4067 var draggables = registry.draggable.getAllByType(critical.draggable.type).map(function (entry) {
4068 return entry.getDimension(windowScroll);
4069 });
4070 var dimensions = {
4071 draggables: toDraggableMap(draggables),
4072 droppables: toDroppableMap(droppables)
4073 };
4074 finish();
4075 var result = {
4076 dimensions: dimensions,
4077 critical: critical,
4078 viewport: viewport
4079 };
4080 return result;
4081});
4082
4083function shouldPublishUpdate(registry, dragging, entry) {
4084 if (entry.descriptor.id === dragging.id) {
4085 return false;
4086 }
4087
4088 if (entry.descriptor.type !== dragging.type) {
4089 return false;
4090 }
4091
4092 var home = registry.droppable.getById(entry.descriptor.droppableId);
4093
4094 if (home.descriptor.mode !== 'virtual') {
4095 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
4096 return false;
4097 }
4098
4099 return true;
4100}
4101
4102var createDimensionMarshal = (function (registry, callbacks) {
4103 var collection = null;
4104 var publisher = createPublisher({
4105 callbacks: {
4106 publish: callbacks.publishWhileDragging,
4107 collectionStarting: callbacks.collectionStarting
4108 },
4109 registry: registry
4110 });
4111
4112 var updateDroppableIsEnabled = function updateDroppableIsEnabled(id, isEnabled) {
4113 !registry.droppable.exists(id) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot update is enabled flag of Droppable " + id + " as it is not registered") : invariant(false) : void 0;
4114
4115 if (!collection) {
4116 return;
4117 }
4118
4119 callbacks.updateDroppableIsEnabled({
4120 id: id,
4121 isEnabled: isEnabled
4122 });
4123 };
4124
4125 var updateDroppableIsCombineEnabled = function updateDroppableIsCombineEnabled(id, isCombineEnabled) {
4126 if (!collection) {
4127 return;
4128 }
4129
4130 !registry.droppable.exists(id) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot update isCombineEnabled flag of Droppable " + id + " as it is not registered") : invariant(false) : void 0;
4131 callbacks.updateDroppableIsCombineEnabled({
4132 id: id,
4133 isCombineEnabled: isCombineEnabled
4134 });
4135 };
4136
4137 var updateDroppableScroll = function updateDroppableScroll(id, newScroll) {
4138 if (!collection) {
4139 return;
4140 }
4141
4142 !registry.droppable.exists(id) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot update the scroll on Droppable " + id + " as it is not registered") : invariant(false) : void 0;
4143 callbacks.updateDroppableScroll({
4144 id: id,
4145 newScroll: newScroll
4146 });
4147 };
4148
4149 var scrollDroppable = function scrollDroppable(id, change) {
4150 if (!collection) {
4151 return;
4152 }
4153
4154 registry.droppable.getById(id).callbacks.scroll(change);
4155 };
4156
4157 var stopPublishing = function stopPublishing() {
4158 if (!collection) {
4159 return;
4160 }
4161
4162 publisher.stop();
4163 var home = collection.critical.droppable;
4164 registry.droppable.getAllByType(home.type).forEach(function (entry) {
4165 return entry.callbacks.dragStopped();
4166 });
4167 collection.unsubscribe();
4168 collection = null;
4169 };
4170
4171 var subscriber = function subscriber(event) {
4172 !collection ? process.env.NODE_ENV !== "production" ? invariant(false, 'Should only be subscribed when a collection is occurring') : invariant(false) : void 0;
4173 var dragging = collection.critical.draggable;
4174
4175 if (event.type === 'ADDITION') {
4176 if (shouldPublishUpdate(registry, dragging, event.value)) {
4177 publisher.add(event.value);
4178 }
4179 }
4180
4181 if (event.type === 'REMOVAL') {
4182 if (shouldPublishUpdate(registry, dragging, event.value)) {
4183 publisher.remove(event.value);
4184 }
4185 }
4186 };
4187
4188 var startPublishing = function startPublishing(request) {
4189 !!collection ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot start capturing critical dimensions as there is already a collection') : invariant(false) : void 0;
4190 var entry = registry.draggable.getById(request.draggableId);
4191 var home = registry.droppable.getById(entry.descriptor.droppableId);
4192 var critical = {
4193 draggable: entry.descriptor,
4194 droppable: home.descriptor
4195 };
4196 var unsubscribe = registry.subscribe(subscriber);
4197 collection = {
4198 critical: critical,
4199 unsubscribe: unsubscribe
4200 };
4201 return getInitialPublish({
4202 critical: critical,
4203 registry: registry,
4204 scrollOptions: request.scrollOptions
4205 });
4206 };
4207
4208 var marshal = {
4209 updateDroppableIsEnabled: updateDroppableIsEnabled,
4210 updateDroppableIsCombineEnabled: updateDroppableIsCombineEnabled,
4211 scrollDroppable: scrollDroppable,
4212 updateDroppableScroll: updateDroppableScroll,
4213 startPublishing: startPublishing,
4214 stopPublishing: stopPublishing
4215 };
4216 return marshal;
4217});
4218
4219var canStartDrag = (function (state, id) {
4220 if (state.phase === 'IDLE') {
4221 return true;
4222 }
4223
4224 if (state.phase !== 'DROP_ANIMATING') {
4225 return false;
4226 }
4227
4228 if (state.completed.result.draggableId === id) {
4229 return false;
4230 }
4231
4232 return state.completed.result.reason === 'DROP';
4233});
4234
4235var scrollWindow = (function (change) {
4236 window.scrollBy(change.x, change.y);
4237});
4238
4239var getScrollableDroppables = memoizeOne(function (droppables) {
4240 return toDroppableList(droppables).filter(function (droppable) {
4241 if (!droppable.isEnabled) {
4242 return false;
4243 }
4244
4245 if (!droppable.frame) {
4246 return false;
4247 }
4248
4249 return true;
4250 });
4251});
4252
4253var getScrollableDroppableOver = function getScrollableDroppableOver(target, droppables) {
4254 var maybe = find(getScrollableDroppables(droppables), function (droppable) {
4255 !droppable.frame ? process.env.NODE_ENV !== "production" ? invariant(false, 'Invalid result') : invariant(false) : void 0;
4256 return isPositionInFrame(droppable.frame.pageMarginBox)(target);
4257 });
4258 return maybe;
4259};
4260
4261var getBestScrollableDroppable = (function (_ref) {
4262 var center = _ref.center,
4263 destination = _ref.destination,
4264 droppables = _ref.droppables;
4265
4266 if (destination) {
4267 var _dimension = droppables[destination];
4268
4269 if (!_dimension.frame) {
4270 return null;
4271 }
4272
4273 return _dimension;
4274 }
4275
4276 var dimension = getScrollableDroppableOver(center, droppables);
4277 return dimension;
4278});
4279
4280var config = {
4281 startFromPercentage: 0.25,
4282 maxScrollAtPercentage: 0.05,
4283 maxPixelScroll: 28,
4284 ease: function ease(percentage) {
4285 return Math.pow(percentage, 2);
4286 },
4287 durationDampening: {
4288 stopDampeningAt: 1200,
4289 accelerateAt: 360
4290 }
4291};
4292
4293var getDistanceThresholds = (function (container, axis) {
4294 var startScrollingFrom = container[axis.size] * config.startFromPercentage;
4295 var maxScrollValueAt = container[axis.size] * config.maxScrollAtPercentage;
4296 var thresholds = {
4297 startScrollingFrom: startScrollingFrom,
4298 maxScrollValueAt: maxScrollValueAt
4299 };
4300 return thresholds;
4301});
4302
4303var getPercentage = (function (_ref) {
4304 var startOfRange = _ref.startOfRange,
4305 endOfRange = _ref.endOfRange,
4306 current = _ref.current;
4307 var range = endOfRange - startOfRange;
4308
4309 if (range === 0) {
4310 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
4311 return 0;
4312 }
4313
4314 var currentInRange = current - startOfRange;
4315 var percentage = currentInRange / range;
4316 return percentage;
4317});
4318
4319var minScroll = 1;
4320
4321var getValueFromDistance = (function (distanceToEdge, thresholds) {
4322 if (distanceToEdge > thresholds.startScrollingFrom) {
4323 return 0;
4324 }
4325
4326 if (distanceToEdge <= thresholds.maxScrollValueAt) {
4327 return config.maxPixelScroll;
4328 }
4329
4330 if (distanceToEdge === thresholds.startScrollingFrom) {
4331 return minScroll;
4332 }
4333
4334 var percentageFromMaxScrollValueAt = getPercentage({
4335 startOfRange: thresholds.maxScrollValueAt,
4336 endOfRange: thresholds.startScrollingFrom,
4337 current: distanceToEdge
4338 });
4339 var percentageFromStartScrollingFrom = 1 - percentageFromMaxScrollValueAt;
4340 var scroll = config.maxPixelScroll * config.ease(percentageFromStartScrollingFrom);
4341 return Math.ceil(scroll);
4342});
4343
4344var accelerateAt = config.durationDampening.accelerateAt;
4345var stopAt = config.durationDampening.stopDampeningAt;
4346var dampenValueByTime = (function (proposedScroll, dragStartTime) {
4347 var startOfRange = dragStartTime;
4348 var endOfRange = stopAt;
4349 var now = Date.now();
4350 var runTime = now - startOfRange;
4351
4352 if (runTime >= stopAt) {
4353 return proposedScroll;
4354 }
4355
4356 if (runTime < accelerateAt) {
4357 return minScroll;
4358 }
4359
4360 var betweenAccelerateAtAndStopAtPercentage = getPercentage({
4361 startOfRange: accelerateAt,
4362 endOfRange: endOfRange,
4363 current: runTime
4364 });
4365 var scroll = proposedScroll * config.ease(betweenAccelerateAtAndStopAtPercentage);
4366 return Math.ceil(scroll);
4367});
4368
4369var getValue = (function (_ref) {
4370 var distanceToEdge = _ref.distanceToEdge,
4371 thresholds = _ref.thresholds,
4372 dragStartTime = _ref.dragStartTime,
4373 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4374 var scroll = getValueFromDistance(distanceToEdge, thresholds);
4375
4376 if (scroll === 0) {
4377 return 0;
4378 }
4379
4380 if (!shouldUseTimeDampening) {
4381 return scroll;
4382 }
4383
4384 return Math.max(dampenValueByTime(scroll, dragStartTime), minScroll);
4385});
4386
4387var getScrollOnAxis = (function (_ref) {
4388 var container = _ref.container,
4389 distanceToEdges = _ref.distanceToEdges,
4390 dragStartTime = _ref.dragStartTime,
4391 axis = _ref.axis,
4392 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4393 var thresholds = getDistanceThresholds(container, axis);
4394 var isCloserToEnd = distanceToEdges[axis.end] < distanceToEdges[axis.start];
4395
4396 if (isCloserToEnd) {
4397 return getValue({
4398 distanceToEdge: distanceToEdges[axis.end],
4399 thresholds: thresholds,
4400 dragStartTime: dragStartTime,
4401 shouldUseTimeDampening: shouldUseTimeDampening
4402 });
4403 }
4404
4405 return -1 * getValue({
4406 distanceToEdge: distanceToEdges[axis.start],
4407 thresholds: thresholds,
4408 dragStartTime: dragStartTime,
4409 shouldUseTimeDampening: shouldUseTimeDampening
4410 });
4411});
4412
4413var adjustForSizeLimits = (function (_ref) {
4414 var container = _ref.container,
4415 subject = _ref.subject,
4416 proposedScroll = _ref.proposedScroll;
4417 var isTooBigVertically = subject.height > container.height;
4418 var isTooBigHorizontally = subject.width > container.width;
4419
4420 if (!isTooBigHorizontally && !isTooBigVertically) {
4421 return proposedScroll;
4422 }
4423
4424 if (isTooBigHorizontally && isTooBigVertically) {
4425 return null;
4426 }
4427
4428 return {
4429 x: isTooBigHorizontally ? 0 : proposedScroll.x,
4430 y: isTooBigVertically ? 0 : proposedScroll.y
4431 };
4432});
4433
4434var clean$2 = apply(function (value) {
4435 return value === 0 ? 0 : value;
4436});
4437var getScroll = (function (_ref) {
4438 var dragStartTime = _ref.dragStartTime,
4439 container = _ref.container,
4440 subject = _ref.subject,
4441 center = _ref.center,
4442 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4443 var distanceToEdges = {
4444 top: center.y - container.top,
4445 right: container.right - center.x,
4446 bottom: container.bottom - center.y,
4447 left: center.x - container.left
4448 };
4449 var y = getScrollOnAxis({
4450 container: container,
4451 distanceToEdges: distanceToEdges,
4452 dragStartTime: dragStartTime,
4453 axis: vertical,
4454 shouldUseTimeDampening: shouldUseTimeDampening
4455 });
4456 var x = getScrollOnAxis({
4457 container: container,
4458 distanceToEdges: distanceToEdges,
4459 dragStartTime: dragStartTime,
4460 axis: horizontal,
4461 shouldUseTimeDampening: shouldUseTimeDampening
4462 });
4463 var required = clean$2({
4464 x: x,
4465 y: y
4466 });
4467
4468 if (isEqual(required, origin)) {
4469 return null;
4470 }
4471
4472 var limited = adjustForSizeLimits({
4473 container: container,
4474 subject: subject,
4475 proposedScroll: required
4476 });
4477
4478 if (!limited) {
4479 return null;
4480 }
4481
4482 return isEqual(limited, origin) ? null : limited;
4483});
4484
4485var smallestSigned = apply(function (value) {
4486 if (value === 0) {
4487 return 0;
4488 }
4489
4490 return value > 0 ? 1 : -1;
4491});
4492var getOverlap = function () {
4493 var getRemainder = function getRemainder(target, max) {
4494 if (target < 0) {
4495 return target;
4496 }
4497
4498 if (target > max) {
4499 return target - max;
4500 }
4501
4502 return 0;
4503 };
4504
4505 return function (_ref) {
4506 var current = _ref.current,
4507 max = _ref.max,
4508 change = _ref.change;
4509 var targetScroll = add(current, change);
4510 var overlap = {
4511 x: getRemainder(targetScroll.x, max.x),
4512 y: getRemainder(targetScroll.y, max.y)
4513 };
4514
4515 if (isEqual(overlap, origin)) {
4516 return null;
4517 }
4518
4519 return overlap;
4520 };
4521}();
4522var canPartiallyScroll = function canPartiallyScroll(_ref2) {
4523 var rawMax = _ref2.max,
4524 current = _ref2.current,
4525 change = _ref2.change;
4526 var max = {
4527 x: Math.max(current.x, rawMax.x),
4528 y: Math.max(current.y, rawMax.y)
4529 };
4530 var smallestChange = smallestSigned(change);
4531 var overlap = getOverlap({
4532 max: max,
4533 current: current,
4534 change: smallestChange
4535 });
4536
4537 if (!overlap) {
4538 return true;
4539 }
4540
4541 if (smallestChange.x !== 0 && overlap.x === 0) {
4542 return true;
4543 }
4544
4545 if (smallestChange.y !== 0 && overlap.y === 0) {
4546 return true;
4547 }
4548
4549 return false;
4550};
4551var canScrollWindow = function canScrollWindow(viewport, change) {
4552 return canPartiallyScroll({
4553 current: viewport.scroll.current,
4554 max: viewport.scroll.max,
4555 change: change
4556 });
4557};
4558var getWindowOverlap = function getWindowOverlap(viewport, change) {
4559 if (!canScrollWindow(viewport, change)) {
4560 return null;
4561 }
4562
4563 var max = viewport.scroll.max;
4564 var current = viewport.scroll.current;
4565 return getOverlap({
4566 current: current,
4567 max: max,
4568 change: change
4569 });
4570};
4571var canScrollDroppable = function canScrollDroppable(droppable, change) {
4572 var frame = droppable.frame;
4573
4574 if (!frame) {
4575 return false;
4576 }
4577
4578 return canPartiallyScroll({
4579 current: frame.scroll.current,
4580 max: frame.scroll.max,
4581 change: change
4582 });
4583};
4584var getDroppableOverlap = function getDroppableOverlap(droppable, change) {
4585 var frame = droppable.frame;
4586
4587 if (!frame) {
4588 return null;
4589 }
4590
4591 if (!canScrollDroppable(droppable, change)) {
4592 return null;
4593 }
4594
4595 return getOverlap({
4596 current: frame.scroll.current,
4597 max: frame.scroll.max,
4598 change: change
4599 });
4600};
4601
4602var getWindowScrollChange = (function (_ref) {
4603 var viewport = _ref.viewport,
4604 subject = _ref.subject,
4605 center = _ref.center,
4606 dragStartTime = _ref.dragStartTime,
4607 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4608 var scroll = getScroll({
4609 dragStartTime: dragStartTime,
4610 container: viewport.frame,
4611 subject: subject,
4612 center: center,
4613 shouldUseTimeDampening: shouldUseTimeDampening
4614 });
4615 return scroll && canScrollWindow(viewport, scroll) ? scroll : null;
4616});
4617
4618var getDroppableScrollChange = (function (_ref) {
4619 var droppable = _ref.droppable,
4620 subject = _ref.subject,
4621 center = _ref.center,
4622 dragStartTime = _ref.dragStartTime,
4623 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4624 var frame = droppable.frame;
4625
4626 if (!frame) {
4627 return null;
4628 }
4629
4630 var scroll = getScroll({
4631 dragStartTime: dragStartTime,
4632 container: frame.pageMarginBox,
4633 subject: subject,
4634 center: center,
4635 shouldUseTimeDampening: shouldUseTimeDampening
4636 });
4637 return scroll && canScrollDroppable(droppable, scroll) ? scroll : null;
4638});
4639
4640var scroll$1 = (function (_ref) {
4641 var state = _ref.state,
4642 dragStartTime = _ref.dragStartTime,
4643 shouldUseTimeDampening = _ref.shouldUseTimeDampening,
4644 scrollWindow = _ref.scrollWindow,
4645 scrollDroppable = _ref.scrollDroppable;
4646 var center = state.current.page.borderBoxCenter;
4647 var draggable = state.dimensions.draggables[state.critical.draggable.id];
4648 var subject = draggable.page.marginBox;
4649
4650 if (state.isWindowScrollAllowed) {
4651 var viewport = state.viewport;
4652
4653 var _change = getWindowScrollChange({
4654 dragStartTime: dragStartTime,
4655 viewport: viewport,
4656 subject: subject,
4657 center: center,
4658 shouldUseTimeDampening: shouldUseTimeDampening
4659 });
4660
4661 if (_change) {
4662 scrollWindow(_change);
4663 return;
4664 }
4665 }
4666
4667 var droppable = getBestScrollableDroppable({
4668 center: center,
4669 destination: whatIsDraggedOver(state.impact),
4670 droppables: state.dimensions.droppables
4671 });
4672
4673 if (!droppable) {
4674 return;
4675 }
4676
4677 var change = getDroppableScrollChange({
4678 dragStartTime: dragStartTime,
4679 droppable: droppable,
4680 subject: subject,
4681 center: center,
4682 shouldUseTimeDampening: shouldUseTimeDampening
4683 });
4684
4685 if (change) {
4686 scrollDroppable(droppable.descriptor.id, change);
4687 }
4688});
4689
4690var createFluidScroller = (function (_ref) {
4691 var scrollWindow = _ref.scrollWindow,
4692 scrollDroppable = _ref.scrollDroppable;
4693 var scheduleWindowScroll = rafSchd(scrollWindow);
4694 var scheduleDroppableScroll = rafSchd(scrollDroppable);
4695 var dragging = null;
4696
4697 var tryScroll = function tryScroll(state) {
4698 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fluid scroll if not dragging') : invariant(false) : void 0;
4699 var _dragging = dragging,
4700 shouldUseTimeDampening = _dragging.shouldUseTimeDampening,
4701 dragStartTime = _dragging.dragStartTime;
4702 scroll$1({
4703 state: state,
4704 scrollWindow: scheduleWindowScroll,
4705 scrollDroppable: scheduleDroppableScroll,
4706 dragStartTime: dragStartTime,
4707 shouldUseTimeDampening: shouldUseTimeDampening
4708 });
4709 };
4710
4711 var start$1 = function start$1(state) {
4712 start();
4713 !!dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot start auto scrolling when already started') : invariant(false) : void 0;
4714 var dragStartTime = Date.now();
4715 var wasScrollNeeded = false;
4716
4717 var fakeScrollCallback = function fakeScrollCallback() {
4718 wasScrollNeeded = true;
4719 };
4720
4721 scroll$1({
4722 state: state,
4723 dragStartTime: 0,
4724 shouldUseTimeDampening: false,
4725 scrollWindow: fakeScrollCallback,
4726 scrollDroppable: fakeScrollCallback
4727 });
4728 dragging = {
4729 dragStartTime: dragStartTime,
4730 shouldUseTimeDampening: wasScrollNeeded
4731 };
4732 finish();
4733
4734 if (wasScrollNeeded) {
4735 tryScroll(state);
4736 }
4737 };
4738
4739 var stop = function stop() {
4740 if (!dragging) {
4741 return;
4742 }
4743
4744 scheduleWindowScroll.cancel();
4745 scheduleDroppableScroll.cancel();
4746 dragging = null;
4747 };
4748
4749 return {
4750 start: start$1,
4751 stop: stop,
4752 scroll: tryScroll
4753 };
4754});
4755
4756var createJumpScroller = (function (_ref) {
4757 var move = _ref.move,
4758 scrollDroppable = _ref.scrollDroppable,
4759 scrollWindow = _ref.scrollWindow;
4760
4761 var moveByOffset = function moveByOffset(state, offset) {
4762 var client = add(state.current.client.selection, offset);
4763 move({
4764 client: client
4765 });
4766 };
4767
4768 var scrollDroppableAsMuchAsItCan = function scrollDroppableAsMuchAsItCan(droppable, change) {
4769 if (!canScrollDroppable(droppable, change)) {
4770 return change;
4771 }
4772
4773 var overlap = getDroppableOverlap(droppable, change);
4774
4775 if (!overlap) {
4776 scrollDroppable(droppable.descriptor.id, change);
4777 return null;
4778 }
4779
4780 var whatTheDroppableCanScroll = subtract(change, overlap);
4781 scrollDroppable(droppable.descriptor.id, whatTheDroppableCanScroll);
4782 var remainder = subtract(change, whatTheDroppableCanScroll);
4783 return remainder;
4784 };
4785
4786 var scrollWindowAsMuchAsItCan = function scrollWindowAsMuchAsItCan(isWindowScrollAllowed, viewport, change) {
4787 if (!isWindowScrollAllowed) {
4788 return change;
4789 }
4790
4791 if (!canScrollWindow(viewport, change)) {
4792 return change;
4793 }
4794
4795 var overlap = getWindowOverlap(viewport, change);
4796
4797 if (!overlap) {
4798 scrollWindow(change);
4799 return null;
4800 }
4801
4802 var whatTheWindowCanScroll = subtract(change, overlap);
4803 scrollWindow(whatTheWindowCanScroll);
4804 var remainder = subtract(change, whatTheWindowCanScroll);
4805 return remainder;
4806 };
4807
4808 var jumpScroller = function jumpScroller(state) {
4809 var request = state.scrollJumpRequest;
4810
4811 if (!request) {
4812 return;
4813 }
4814
4815 var destination = whatIsDraggedOver(state.impact);
4816 !destination ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot perform a jump scroll when there is no destination') : invariant(false) : void 0;
4817 var droppableRemainder = scrollDroppableAsMuchAsItCan(state.dimensions.droppables[destination], request);
4818
4819 if (!droppableRemainder) {
4820 return;
4821 }
4822
4823 var viewport = state.viewport;
4824 var windowRemainder = scrollWindowAsMuchAsItCan(state.isWindowScrollAllowed, viewport, droppableRemainder);
4825
4826 if (!windowRemainder) {
4827 return;
4828 }
4829
4830 moveByOffset(state, windowRemainder);
4831 };
4832
4833 return jumpScroller;
4834});
4835
4836var createAutoScroller = (function (_ref) {
4837 var scrollDroppable = _ref.scrollDroppable,
4838 scrollWindow = _ref.scrollWindow,
4839 move = _ref.move;
4840 var fluidScroller = createFluidScroller({
4841 scrollWindow: scrollWindow,
4842 scrollDroppable: scrollDroppable
4843 });
4844 var jumpScroll = createJumpScroller({
4845 move: move,
4846 scrollWindow: scrollWindow,
4847 scrollDroppable: scrollDroppable
4848 });
4849
4850 var scroll = function scroll(state) {
4851 if (state.phase !== 'DRAGGING') {
4852 return;
4853 }
4854
4855 if (state.movementMode === 'FLUID') {
4856 fluidScroller.scroll(state);
4857 return;
4858 }
4859
4860 if (!state.scrollJumpRequest) {
4861 return;
4862 }
4863
4864 jumpScroll(state);
4865 };
4866
4867 var scroller = {
4868 scroll: scroll,
4869 start: fluidScroller.start,
4870 stop: fluidScroller.stop
4871 };
4872 return scroller;
4873});
4874
4875var prefix$1 = 'data-rbd';
4876var dragHandle = function () {
4877 var base = prefix$1 + "-drag-handle";
4878 return {
4879 base: base,
4880 draggableId: base + "-draggable-id",
4881 contextId: base + "-context-id"
4882 };
4883}();
4884var draggable = function () {
4885 var base = prefix$1 + "-draggable";
4886 return {
4887 base: base,
4888 contextId: base + "-context-id",
4889 id: base + "-id"
4890 };
4891}();
4892var droppable = function () {
4893 var base = prefix$1 + "-droppable";
4894 return {
4895 base: base,
4896 contextId: base + "-context-id",
4897 id: base + "-id"
4898 };
4899}();
4900var scrollContainer = {
4901 contextId: prefix$1 + "-scroll-container-context-id"
4902};
4903
4904var makeGetSelector = function makeGetSelector(context) {
4905 return function (attribute) {
4906 return "[" + attribute + "=\"" + context + "\"]";
4907 };
4908};
4909
4910var getStyles = function getStyles(rules, property) {
4911 return rules.map(function (rule) {
4912 var value = rule.styles[property];
4913
4914 if (!value) {
4915 return '';
4916 }
4917
4918 return rule.selector + " { " + value + " }";
4919 }).join(' ');
4920};
4921
4922var noPointerEvents = 'pointer-events: none;';
4923var getStyles$1 = (function (contextId) {
4924 var getSelector = makeGetSelector(contextId);
4925
4926 var dragHandle$1 = function () {
4927 var grabCursor = "\n cursor: -webkit-grab;\n cursor: grab;\n ";
4928 return {
4929 selector: getSelector(dragHandle.contextId),
4930 styles: {
4931 always: "\n -webkit-touch-callout: none;\n -webkit-tap-highlight-color: rgba(0,0,0,0);\n touch-action: manipulation;\n ",
4932 resting: grabCursor,
4933 dragging: noPointerEvents,
4934 dropAnimating: grabCursor
4935 }
4936 };
4937 }();
4938
4939 var draggable$1 = function () {
4940 var transition = "\n transition: " + transitions.outOfTheWay + ";\n ";
4941 return {
4942 selector: getSelector(draggable.contextId),
4943 styles: {
4944 dragging: transition,
4945 dropAnimating: transition,
4946 userCancel: transition
4947 }
4948 };
4949 }();
4950
4951 var droppable$1 = {
4952 selector: getSelector(droppable.contextId),
4953 styles: {
4954 always: "overflow-anchor: none;"
4955 }
4956 };
4957 var body = {
4958 selector: 'body',
4959 styles: {
4960 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 "
4961 }
4962 };
4963 var rules = [draggable$1, dragHandle$1, droppable$1, body];
4964 return {
4965 always: getStyles(rules, 'always'),
4966 resting: getStyles(rules, 'resting'),
4967 dragging: getStyles(rules, 'dragging'),
4968 dropAnimating: getStyles(rules, 'dropAnimating'),
4969 userCancel: getStyles(rules, 'userCancel')
4970 };
4971});
4972
4973var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect;
4974
4975var getHead = function getHead() {
4976 var head = document.querySelector('head');
4977 !head ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot find the head to append a style to') : invariant(false) : void 0;
4978 return head;
4979};
4980
4981var createStyleEl = function createStyleEl(nonce) {
4982 var el = document.createElement('style');
4983
4984 if (nonce) {
4985 el.setAttribute('nonce', nonce);
4986 }
4987
4988 el.type = 'text/css';
4989 return el;
4990};
4991
4992function useStyleMarshal(contextId, nonce) {
4993 var styles = useMemoOne.useMemo(function () {
4994 return getStyles$1(contextId);
4995 }, [contextId]);
4996 var alwaysRef = React.useRef(null);
4997 var dynamicRef = React.useRef(null);
4998 var setDynamicStyle = useMemoOne.useCallback(memoizeOne(function (proposed) {
4999 var el = dynamicRef.current;
5000 !el ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot set dynamic style element if it is not set') : invariant(false) : void 0;
5001 el.textContent = proposed;
5002 }), []);
5003 var setAlwaysStyle = useMemoOne.useCallback(function (proposed) {
5004 var el = alwaysRef.current;
5005 !el ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot set dynamic style element if it is not set') : invariant(false) : void 0;
5006 el.textContent = proposed;
5007 }, []);
5008 useIsomorphicLayoutEffect(function () {
5009 !(!alwaysRef.current && !dynamicRef.current) ? process.env.NODE_ENV !== "production" ? invariant(false, 'style elements already mounted') : invariant(false) : void 0;
5010 var always = createStyleEl(nonce);
5011 var dynamic = createStyleEl(nonce);
5012 alwaysRef.current = always;
5013 dynamicRef.current = dynamic;
5014 always.setAttribute(prefix$1 + "-always", contextId);
5015 dynamic.setAttribute(prefix$1 + "-dynamic", contextId);
5016 getHead().appendChild(always);
5017 getHead().appendChild(dynamic);
5018 setAlwaysStyle(styles.always);
5019 setDynamicStyle(styles.resting);
5020 return function () {
5021 var remove = function remove(ref) {
5022 var current = ref.current;
5023 !current ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot unmount ref as it is not set') : invariant(false) : void 0;
5024 getHead().removeChild(current);
5025 ref.current = null;
5026 };
5027
5028 remove(alwaysRef);
5029 remove(dynamicRef);
5030 };
5031 }, [nonce, setAlwaysStyle, setDynamicStyle, styles.always, styles.resting, contextId]);
5032 var dragging = useMemoOne.useCallback(function () {
5033 return setDynamicStyle(styles.dragging);
5034 }, [setDynamicStyle, styles.dragging]);
5035 var dropping = useMemoOne.useCallback(function (reason) {
5036 if (reason === 'DROP') {
5037 setDynamicStyle(styles.dropAnimating);
5038 return;
5039 }
5040
5041 setDynamicStyle(styles.userCancel);
5042 }, [setDynamicStyle, styles.dropAnimating, styles.userCancel]);
5043 var resting = useMemoOne.useCallback(function () {
5044 if (!dynamicRef.current) {
5045 return;
5046 }
5047
5048 setDynamicStyle(styles.resting);
5049 }, [setDynamicStyle, styles.resting]);
5050 var marshal = useMemoOne.useMemo(function () {
5051 return {
5052 dragging: dragging,
5053 dropping: dropping,
5054 resting: resting
5055 };
5056 }, [dragging, dropping, resting]);
5057 return marshal;
5058}
5059
5060var getWindowFromEl = (function (el) {
5061 return el && el.ownerDocument ? el.ownerDocument.defaultView : window;
5062});
5063
5064function isHtmlElement(el) {
5065 return el instanceof getWindowFromEl(el).HTMLElement;
5066}
5067
5068function findDragHandle(contextId, draggableId) {
5069 var selector = "[" + dragHandle.contextId + "=\"" + contextId + "\"]";
5070 var possible = toArray(document.querySelectorAll(selector));
5071
5072 if (!possible.length) {
5073 process.env.NODE_ENV !== "production" ? warning("Unable to find any drag handles in the context \"" + contextId + "\"") : void 0;
5074 return null;
5075 }
5076
5077 var handle = find(possible, function (el) {
5078 return el.getAttribute(dragHandle.draggableId) === draggableId;
5079 });
5080
5081 if (!handle) {
5082 process.env.NODE_ENV !== "production" ? warning("Unable to find drag handle with id \"" + draggableId + "\" as no handle with a matching id was found") : void 0;
5083 return null;
5084 }
5085
5086 if (!isHtmlElement(handle)) {
5087 process.env.NODE_ENV !== "production" ? warning('drag handle needs to be a HTMLElement') : void 0;
5088 return null;
5089 }
5090
5091 return handle;
5092}
5093
5094function useFocusMarshal(contextId) {
5095 var entriesRef = React.useRef({});
5096 var recordRef = React.useRef(null);
5097 var restoreFocusFrameRef = React.useRef(null);
5098 var isMountedRef = React.useRef(false);
5099 var register = useMemoOne.useCallback(function register(id, focus) {
5100 var entry = {
5101 id: id,
5102 focus: focus
5103 };
5104 entriesRef.current[id] = entry;
5105 return function unregister() {
5106 var entries = entriesRef.current;
5107 var current = entries[id];
5108
5109 if (current !== entry) {
5110 delete entries[id];
5111 }
5112 };
5113 }, []);
5114 var tryGiveFocus = useMemoOne.useCallback(function tryGiveFocus(tryGiveFocusTo) {
5115 var handle = findDragHandle(contextId, tryGiveFocusTo);
5116
5117 if (handle && handle !== document.activeElement) {
5118 handle.focus();
5119 }
5120 }, [contextId]);
5121 var tryShiftRecord = useMemoOne.useCallback(function tryShiftRecord(previous, redirectTo) {
5122 if (recordRef.current === previous) {
5123 recordRef.current = redirectTo;
5124 }
5125 }, []);
5126 var tryRestoreFocusRecorded = useMemoOne.useCallback(function tryRestoreFocusRecorded() {
5127 if (restoreFocusFrameRef.current) {
5128 return;
5129 }
5130
5131 if (!isMountedRef.current) {
5132 return;
5133 }
5134
5135 restoreFocusFrameRef.current = requestAnimationFrame(function () {
5136 restoreFocusFrameRef.current = null;
5137 var record = recordRef.current;
5138
5139 if (record) {
5140 tryGiveFocus(record);
5141 }
5142 });
5143 }, [tryGiveFocus]);
5144 var tryRecordFocus = useMemoOne.useCallback(function tryRecordFocus(id) {
5145 recordRef.current = null;
5146 var focused = document.activeElement;
5147
5148 if (!focused) {
5149 return;
5150 }
5151
5152 if (focused.getAttribute(dragHandle.draggableId) !== id) {
5153 return;
5154 }
5155
5156 recordRef.current = id;
5157 }, []);
5158 useIsomorphicLayoutEffect(function () {
5159 isMountedRef.current = true;
5160 return function clearFrameOnUnmount() {
5161 isMountedRef.current = false;
5162 var frameId = restoreFocusFrameRef.current;
5163
5164 if (frameId) {
5165 cancelAnimationFrame(frameId);
5166 }
5167 };
5168 }, []);
5169 var marshal = useMemoOne.useMemo(function () {
5170 return {
5171 register: register,
5172 tryRecordFocus: tryRecordFocus,
5173 tryRestoreFocusRecorded: tryRestoreFocusRecorded,
5174 tryShiftRecord: tryShiftRecord
5175 };
5176 }, [register, tryRecordFocus, tryRestoreFocusRecorded, tryShiftRecord]);
5177 return marshal;
5178}
5179
5180function createRegistry() {
5181 var entries = {
5182 draggables: {},
5183 droppables: {}
5184 };
5185 var subscribers = [];
5186
5187 function subscribe(cb) {
5188 subscribers.push(cb);
5189 return function unsubscribe() {
5190 var index = subscribers.indexOf(cb);
5191
5192 if (index === -1) {
5193 return;
5194 }
5195
5196 subscribers.splice(index, 1);
5197 };
5198 }
5199
5200 function notify(event) {
5201 if (subscribers.length) {
5202 subscribers.forEach(function (cb) {
5203 return cb(event);
5204 });
5205 }
5206 }
5207
5208 function findDraggableById(id) {
5209 return entries.draggables[id] || null;
5210 }
5211
5212 function getDraggableById(id) {
5213 var entry = findDraggableById(id);
5214 !entry ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot find draggable entry with id [" + id + "]") : invariant(false) : void 0;
5215 return entry;
5216 }
5217
5218 var draggableAPI = {
5219 register: function register(entry) {
5220 entries.draggables[entry.descriptor.id] = entry;
5221 notify({
5222 type: 'ADDITION',
5223 value: entry
5224 });
5225 },
5226 update: function update(entry, last) {
5227 var current = entries.draggables[last.descriptor.id];
5228
5229 if (!current) {
5230 return;
5231 }
5232
5233 if (current.uniqueId !== entry.uniqueId) {
5234 return;
5235 }
5236
5237 delete entries.draggables[last.descriptor.id];
5238 entries.draggables[entry.descriptor.id] = entry;
5239 },
5240 unregister: function unregister(entry) {
5241 var draggableId = entry.descriptor.id;
5242 var current = findDraggableById(draggableId);
5243
5244 if (!current) {
5245 return;
5246 }
5247
5248 if (entry.uniqueId !== current.uniqueId) {
5249 return;
5250 }
5251
5252 delete entries.draggables[draggableId];
5253 notify({
5254 type: 'REMOVAL',
5255 value: entry
5256 });
5257 },
5258 getById: getDraggableById,
5259 findById: findDraggableById,
5260 exists: function exists(id) {
5261 return Boolean(findDraggableById(id));
5262 },
5263 getAllByType: function getAllByType(type) {
5264 return values(entries.draggables).filter(function (entry) {
5265 return entry.descriptor.type === type;
5266 });
5267 }
5268 };
5269
5270 function findDroppableById(id) {
5271 return entries.droppables[id] || null;
5272 }
5273
5274 function getDroppableById(id) {
5275 var entry = findDroppableById(id);
5276 !entry ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot find droppable entry with id [" + id + "]") : invariant(false) : void 0;
5277 return entry;
5278 }
5279
5280 var droppableAPI = {
5281 register: function register(entry) {
5282 entries.droppables[entry.descriptor.id] = entry;
5283 },
5284 unregister: function unregister(entry) {
5285 var current = findDroppableById(entry.descriptor.id);
5286
5287 if (!current) {
5288 return;
5289 }
5290
5291 if (entry.uniqueId !== current.uniqueId) {
5292 return;
5293 }
5294
5295 delete entries.droppables[entry.descriptor.id];
5296 },
5297 getById: getDroppableById,
5298 findById: findDroppableById,
5299 exists: function exists(id) {
5300 return Boolean(findDroppableById(id));
5301 },
5302 getAllByType: function getAllByType(type) {
5303 return values(entries.droppables).filter(function (entry) {
5304 return entry.descriptor.type === type;
5305 });
5306 }
5307 };
5308
5309 function clean() {
5310 entries.draggables = {};
5311 entries.droppables = {};
5312 subscribers.length = 0;
5313 }
5314
5315 return {
5316 draggable: draggableAPI,
5317 droppable: droppableAPI,
5318 subscribe: subscribe,
5319 clean: clean
5320 };
5321}
5322
5323function useRegistry() {
5324 var registry = useMemoOne.useMemo(createRegistry, []);
5325 React.useEffect(function () {
5326 return function unmount() {
5327 requestAnimationFrame(registry.clean);
5328 };
5329 }, [registry]);
5330 return registry;
5331}
5332
5333var StoreContext = React__default.createContext(null);
5334
5335var getBodyElement = (function () {
5336 var body = document.body;
5337 !body ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot find document.body') : invariant(false) : void 0;
5338 return body;
5339});
5340
5341var visuallyHidden = {
5342 position: 'absolute',
5343 width: '1px',
5344 height: '1px',
5345 margin: '-1px',
5346 border: '0',
5347 padding: '0',
5348 overflow: 'hidden',
5349 clip: 'rect(0 0 0 0)',
5350 'clip-path': 'inset(100%)'
5351};
5352
5353var getId = function getId(contextId) {
5354 return "rbd-announcement-" + contextId;
5355};
5356function useAnnouncer(contextId) {
5357 var id = useMemoOne.useMemo(function () {
5358 return getId(contextId);
5359 }, [contextId]);
5360 var ref = React.useRef(null);
5361 React.useEffect(function setup() {
5362 var el = document.createElement('div');
5363 ref.current = el;
5364 el.id = id;
5365 el.setAttribute('aria-live', 'assertive');
5366 el.setAttribute('aria-atomic', 'true');
5367
5368 _extends(el.style, visuallyHidden);
5369
5370 getBodyElement().appendChild(el);
5371 return function cleanup() {
5372 setTimeout(function remove() {
5373 var body = getBodyElement();
5374
5375 if (body.contains(el)) {
5376 body.removeChild(el);
5377 }
5378
5379 if (el === ref.current) {
5380 ref.current = null;
5381 }
5382 });
5383 };
5384 }, [id]);
5385 var announce = useMemoOne.useCallback(function (message) {
5386 var el = ref.current;
5387
5388 if (el) {
5389 el.textContent = message;
5390 return;
5391 }
5392
5393 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
5394 }, []);
5395 return announce;
5396}
5397
5398var count = 0;
5399var defaults = {
5400 separator: '::'
5401};
5402function reset() {
5403 count = 0;
5404}
5405function useUniqueId(prefix, options) {
5406 if (options === void 0) {
5407 options = defaults;
5408 }
5409
5410 return useMemoOne.useMemo(function () {
5411 return "" + prefix + options.separator + count++;
5412 }, [options.separator, prefix]);
5413}
5414
5415function getElementId(_ref) {
5416 var contextId = _ref.contextId,
5417 uniqueId = _ref.uniqueId;
5418 return "rbd-hidden-text-" + contextId + "-" + uniqueId;
5419}
5420function useHiddenTextElement(_ref2) {
5421 var contextId = _ref2.contextId,
5422 text = _ref2.text;
5423 var uniqueId = useUniqueId('hidden-text', {
5424 separator: '-'
5425 });
5426 var id = useMemoOne.useMemo(function () {
5427 return getElementId({
5428 contextId: contextId,
5429 uniqueId: uniqueId
5430 });
5431 }, [uniqueId, contextId]);
5432 React.useEffect(function mount() {
5433 var el = document.createElement('div');
5434 el.id = id;
5435 el.textContent = text;
5436 el.style.display = 'none';
5437 getBodyElement().appendChild(el);
5438 return function unmount() {
5439 var body = getBodyElement();
5440
5441 if (body.contains(el)) {
5442 body.removeChild(el);
5443 }
5444 };
5445 }, [id, text]);
5446 return id;
5447}
5448
5449var AppContext = React__default.createContext(null);
5450
5451var peerDependencies = {
5452 react: "^16.8.5 || ^17.0.0 || ^18.0.0",
5453 "react-dom": "^16.8.5 || ^17.0.0 || ^18.0.0"
5454};
5455
5456var semver = /(\d+)\.(\d+)\.(\d+)/;
5457
5458var getVersion = function getVersion(value) {
5459 var result = semver.exec(value);
5460 !(result != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Unable to parse React version " + value) : invariant(false) : void 0;
5461 var major = Number(result[1]);
5462 var minor = Number(result[2]);
5463 var patch = Number(result[3]);
5464 return {
5465 major: major,
5466 minor: minor,
5467 patch: patch,
5468 raw: value
5469 };
5470};
5471
5472var isSatisfied = function isSatisfied(expected, actual) {
5473 if (actual.major > expected.major) {
5474 return true;
5475 }
5476
5477 if (actual.major < expected.major) {
5478 return false;
5479 }
5480
5481 if (actual.minor > expected.minor) {
5482 return true;
5483 }
5484
5485 if (actual.minor < expected.minor) {
5486 return false;
5487 }
5488
5489 return actual.patch >= expected.patch;
5490};
5491
5492var checkReactVersion = (function (peerDepValue, actualValue) {
5493 var peerDep = getVersion(peerDepValue);
5494 var actual = getVersion(actualValue);
5495
5496 if (isSatisfied(peerDep, actual)) {
5497 return;
5498 }
5499
5500 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
5501});
5502
5503var 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";
5504var checkDoctype = (function (doc) {
5505 var doctype = doc.doctype;
5506
5507 if (!doctype) {
5508 process.env.NODE_ENV !== "production" ? warning("\n No <!doctype html> found.\n\n " + suffix + "\n ") : void 0;
5509 return;
5510 }
5511
5512 if (doctype.name.toLowerCase() !== 'html') {
5513 process.env.NODE_ENV !== "production" ? warning("\n Unexpected <!doctype> found: (" + doctype.name + ")\n\n " + suffix + "\n ") : void 0;
5514 }
5515
5516 if (doctype.publicId !== '') {
5517 process.env.NODE_ENV !== "production" ? warning("\n Unexpected <!doctype> publicId found: (" + doctype.publicId + ")\n A html5 doctype does not have a publicId\n\n " + suffix + "\n ") : void 0;
5518 }
5519});
5520
5521function useDev(useHook) {
5522 if (process.env.NODE_ENV !== 'production') {
5523 useHook();
5524 }
5525}
5526
5527function useDevSetupWarning(fn, inputs) {
5528 useDev(function () {
5529 React.useEffect(function () {
5530 try {
5531 fn();
5532 } catch (e) {
5533 error("\n A setup problem was encountered.\n\n > " + e.message + "\n ");
5534 }
5535 }, inputs);
5536 });
5537}
5538
5539function useStartupValidation() {
5540 useDevSetupWarning(function () {
5541 checkReactVersion(peerDependencies.react, React__default.version);
5542 checkDoctype(document);
5543 }, []);
5544}
5545
5546function usePrevious(current) {
5547 var ref = React.useRef(current);
5548 React.useEffect(function () {
5549 ref.current = current;
5550 });
5551 return ref;
5552}
5553
5554function create() {
5555 var lock = null;
5556
5557 function isClaimed() {
5558 return Boolean(lock);
5559 }
5560
5561 function isActive(value) {
5562 return value === lock;
5563 }
5564
5565 function claim(abandon) {
5566 !!lock ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot claim lock as it is already claimed') : invariant(false) : void 0;
5567 var newLock = {
5568 abandon: abandon
5569 };
5570 lock = newLock;
5571 return newLock;
5572 }
5573
5574 function release() {
5575 !lock ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot release lock when there is no lock') : invariant(false) : void 0;
5576 lock = null;
5577 }
5578
5579 function tryAbandon() {
5580 if (lock) {
5581 lock.abandon();
5582 release();
5583 }
5584 }
5585
5586 return {
5587 isClaimed: isClaimed,
5588 isActive: isActive,
5589 claim: claim,
5590 release: release,
5591 tryAbandon: tryAbandon
5592 };
5593}
5594
5595var tab = 9;
5596var enter = 13;
5597var escape = 27;
5598var space = 32;
5599var pageUp = 33;
5600var pageDown = 34;
5601var end = 35;
5602var home = 36;
5603var arrowLeft = 37;
5604var arrowUp = 38;
5605var arrowRight = 39;
5606var arrowDown = 40;
5607
5608var _preventedKeys;
5609var preventedKeys = (_preventedKeys = {}, _preventedKeys[enter] = true, _preventedKeys[tab] = true, _preventedKeys);
5610var preventStandardKeyEvents = (function (event) {
5611 if (preventedKeys[event.keyCode]) {
5612 event.preventDefault();
5613 }
5614});
5615
5616var supportedEventName = function () {
5617 var base = 'visibilitychange';
5618
5619 if (typeof document === 'undefined') {
5620 return base;
5621 }
5622
5623 var candidates = [base, "ms" + base, "webkit" + base, "moz" + base, "o" + base];
5624 var supported = find(candidates, function (eventName) {
5625 return "on" + eventName in document;
5626 });
5627 return supported || base;
5628}();
5629
5630var primaryButton = 0;
5631var sloppyClickThreshold = 5;
5632
5633function isSloppyClickThresholdExceeded(original, current) {
5634 return Math.abs(current.x - original.x) >= sloppyClickThreshold || Math.abs(current.y - original.y) >= sloppyClickThreshold;
5635}
5636
5637var idle$1 = {
5638 type: 'IDLE'
5639};
5640
5641function getCaptureBindings(_ref) {
5642 var cancel = _ref.cancel,
5643 completed = _ref.completed,
5644 getPhase = _ref.getPhase,
5645 setPhase = _ref.setPhase;
5646 return [{
5647 eventName: 'mousemove',
5648 fn: function fn(event) {
5649 var button = event.button,
5650 clientX = event.clientX,
5651 clientY = event.clientY;
5652
5653 if (button !== primaryButton) {
5654 return;
5655 }
5656
5657 var point = {
5658 x: clientX,
5659 y: clientY
5660 };
5661 var phase = getPhase();
5662
5663 if (phase.type === 'DRAGGING') {
5664 event.preventDefault();
5665 phase.actions.move(point);
5666 return;
5667 }
5668
5669 !(phase.type === 'PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot be IDLE') : invariant(false) : void 0;
5670 var pending = phase.point;
5671
5672 if (!isSloppyClickThresholdExceeded(pending, point)) {
5673 return;
5674 }
5675
5676 event.preventDefault();
5677 var actions = phase.actions.fluidLift(point);
5678 setPhase({
5679 type: 'DRAGGING',
5680 actions: actions
5681 });
5682 }
5683 }, {
5684 eventName: 'mouseup',
5685 fn: function fn(event) {
5686 var phase = getPhase();
5687
5688 if (phase.type !== 'DRAGGING') {
5689 cancel();
5690 return;
5691 }
5692
5693 event.preventDefault();
5694 phase.actions.drop({
5695 shouldBlockNextClick: true
5696 });
5697 completed();
5698 }
5699 }, {
5700 eventName: 'mousedown',
5701 fn: function fn(event) {
5702 if (getPhase().type === 'DRAGGING') {
5703 event.preventDefault();
5704 }
5705
5706 cancel();
5707 }
5708 }, {
5709 eventName: 'keydown',
5710 fn: function fn(event) {
5711 var phase = getPhase();
5712
5713 if (phase.type === 'PENDING') {
5714 cancel();
5715 return;
5716 }
5717
5718 if (event.keyCode === escape) {
5719 event.preventDefault();
5720 cancel();
5721 return;
5722 }
5723
5724 preventStandardKeyEvents(event);
5725 }
5726 }, {
5727 eventName: 'resize',
5728 fn: cancel
5729 }, {
5730 eventName: 'scroll',
5731 options: {
5732 passive: true,
5733 capture: false
5734 },
5735 fn: function fn() {
5736 if (getPhase().type === 'PENDING') {
5737 cancel();
5738 }
5739 }
5740 }, {
5741 eventName: 'webkitmouseforcedown',
5742 fn: function fn(event) {
5743 var phase = getPhase();
5744 !(phase.type !== 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Unexpected phase') : invariant(false) : void 0;
5745
5746 if (phase.actions.shouldRespectForcePress()) {
5747 cancel();
5748 return;
5749 }
5750
5751 event.preventDefault();
5752 }
5753 }, {
5754 eventName: supportedEventName,
5755 fn: cancel
5756 }];
5757}
5758
5759function useMouseSensor(api) {
5760 var phaseRef = React.useRef(idle$1);
5761 var unbindEventsRef = React.useRef(noop);
5762 var startCaptureBinding = useMemoOne.useMemo(function () {
5763 return {
5764 eventName: 'mousedown',
5765 fn: function onMouseDown(event) {
5766 if (event.defaultPrevented) {
5767 return;
5768 }
5769
5770 if (event.button !== primaryButton) {
5771 return;
5772 }
5773
5774 if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
5775 return;
5776 }
5777
5778 var draggableId = api.findClosestDraggableId(event);
5779
5780 if (!draggableId) {
5781 return;
5782 }
5783
5784 var actions = api.tryGetLock(draggableId, stop, {
5785 sourceEvent: event
5786 });
5787
5788 if (!actions) {
5789 return;
5790 }
5791
5792 event.preventDefault();
5793 var point = {
5794 x: event.clientX,
5795 y: event.clientY
5796 };
5797 unbindEventsRef.current();
5798 startPendingDrag(actions, point);
5799 }
5800 };
5801 }, [api]);
5802 var preventForcePressBinding = useMemoOne.useMemo(function () {
5803 return {
5804 eventName: 'webkitmouseforcewillbegin',
5805 fn: function fn(event) {
5806 if (event.defaultPrevented) {
5807 return;
5808 }
5809
5810 var id = api.findClosestDraggableId(event);
5811
5812 if (!id) {
5813 return;
5814 }
5815
5816 var options = api.findOptionsForDraggable(id);
5817
5818 if (!options) {
5819 return;
5820 }
5821
5822 if (options.shouldRespectForcePress) {
5823 return;
5824 }
5825
5826 if (!api.canGetLock(id)) {
5827 return;
5828 }
5829
5830 event.preventDefault();
5831 }
5832 };
5833 }, [api]);
5834 var listenForCapture = useMemoOne.useCallback(function listenForCapture() {
5835 var options = {
5836 passive: false,
5837 capture: true
5838 };
5839 unbindEventsRef.current = bindEvents(window, [preventForcePressBinding, startCaptureBinding], options);
5840 }, [preventForcePressBinding, startCaptureBinding]);
5841 var stop = useMemoOne.useCallback(function () {
5842 var current = phaseRef.current;
5843
5844 if (current.type === 'IDLE') {
5845 return;
5846 }
5847
5848 phaseRef.current = idle$1;
5849 unbindEventsRef.current();
5850 listenForCapture();
5851 }, [listenForCapture]);
5852 var cancel = useMemoOne.useCallback(function () {
5853 var phase = phaseRef.current;
5854 stop();
5855
5856 if (phase.type === 'DRAGGING') {
5857 phase.actions.cancel({
5858 shouldBlockNextClick: true
5859 });
5860 }
5861
5862 if (phase.type === 'PENDING') {
5863 phase.actions.abort();
5864 }
5865 }, [stop]);
5866 var bindCapturingEvents = useMemoOne.useCallback(function bindCapturingEvents() {
5867 var options = {
5868 capture: true,
5869 passive: false
5870 };
5871 var bindings = getCaptureBindings({
5872 cancel: cancel,
5873 completed: stop,
5874 getPhase: function getPhase() {
5875 return phaseRef.current;
5876 },
5877 setPhase: function setPhase(phase) {
5878 phaseRef.current = phase;
5879 }
5880 });
5881 unbindEventsRef.current = bindEvents(window, bindings, options);
5882 }, [cancel, stop]);
5883 var startPendingDrag = useMemoOne.useCallback(function startPendingDrag(actions, point) {
5884 !(phaseRef.current.type === 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected to move from IDLE to PENDING drag') : invariant(false) : void 0;
5885 phaseRef.current = {
5886 type: 'PENDING',
5887 point: point,
5888 actions: actions
5889 };
5890 bindCapturingEvents();
5891 }, [bindCapturingEvents]);
5892 useIsomorphicLayoutEffect(function mount() {
5893 listenForCapture();
5894 return function unmount() {
5895 unbindEventsRef.current();
5896 };
5897 }, [listenForCapture]);
5898}
5899
5900var _scrollJumpKeys;
5901
5902function noop$1() {}
5903
5904var scrollJumpKeys = (_scrollJumpKeys = {}, _scrollJumpKeys[pageDown] = true, _scrollJumpKeys[pageUp] = true, _scrollJumpKeys[home] = true, _scrollJumpKeys[end] = true, _scrollJumpKeys);
5905
5906function getDraggingBindings(actions, stop) {
5907 function cancel() {
5908 stop();
5909 actions.cancel();
5910 }
5911
5912 function drop() {
5913 stop();
5914 actions.drop();
5915 }
5916
5917 return [{
5918 eventName: 'keydown',
5919 fn: function fn(event) {
5920 if (event.keyCode === escape) {
5921 event.preventDefault();
5922 cancel();
5923 return;
5924 }
5925
5926 if (event.keyCode === space) {
5927 event.preventDefault();
5928 drop();
5929 return;
5930 }
5931
5932 if (event.keyCode === arrowDown) {
5933 event.preventDefault();
5934 actions.moveDown();
5935 return;
5936 }
5937
5938 if (event.keyCode === arrowUp) {
5939 event.preventDefault();
5940 actions.moveUp();
5941 return;
5942 }
5943
5944 if (event.keyCode === arrowRight) {
5945 event.preventDefault();
5946 actions.moveRight();
5947 return;
5948 }
5949
5950 if (event.keyCode === arrowLeft) {
5951 event.preventDefault();
5952 actions.moveLeft();
5953 return;
5954 }
5955
5956 if (scrollJumpKeys[event.keyCode]) {
5957 event.preventDefault();
5958 return;
5959 }
5960
5961 preventStandardKeyEvents(event);
5962 }
5963 }, {
5964 eventName: 'mousedown',
5965 fn: cancel
5966 }, {
5967 eventName: 'mouseup',
5968 fn: cancel
5969 }, {
5970 eventName: 'click',
5971 fn: cancel
5972 }, {
5973 eventName: 'touchstart',
5974 fn: cancel
5975 }, {
5976 eventName: 'resize',
5977 fn: cancel
5978 }, {
5979 eventName: 'wheel',
5980 fn: cancel,
5981 options: {
5982 passive: true
5983 }
5984 }, {
5985 eventName: supportedEventName,
5986 fn: cancel
5987 }];
5988}
5989
5990function useKeyboardSensor(api) {
5991 var unbindEventsRef = React.useRef(noop$1);
5992 var startCaptureBinding = useMemoOne.useMemo(function () {
5993 return {
5994 eventName: 'keydown',
5995 fn: function onKeyDown(event) {
5996 if (event.defaultPrevented) {
5997 return;
5998 }
5999
6000 if (event.keyCode !== space) {
6001 return;
6002 }
6003
6004 var draggableId = api.findClosestDraggableId(event);
6005
6006 if (!draggableId) {
6007 return;
6008 }
6009
6010 var preDrag = api.tryGetLock(draggableId, stop, {
6011 sourceEvent: event
6012 });
6013
6014 if (!preDrag) {
6015 return;
6016 }
6017
6018 event.preventDefault();
6019 var isCapturing = true;
6020 var actions = preDrag.snapLift();
6021 unbindEventsRef.current();
6022
6023 function stop() {
6024 !isCapturing ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot stop capturing a keyboard drag when not capturing') : invariant(false) : void 0;
6025 isCapturing = false;
6026 unbindEventsRef.current();
6027 listenForCapture();
6028 }
6029
6030 unbindEventsRef.current = bindEvents(window, getDraggingBindings(actions, stop), {
6031 capture: true,
6032 passive: false
6033 });
6034 }
6035 };
6036 }, [api]);
6037 var listenForCapture = useMemoOne.useCallback(function tryStartCapture() {
6038 var options = {
6039 passive: false,
6040 capture: true
6041 };
6042 unbindEventsRef.current = bindEvents(window, [startCaptureBinding], options);
6043 }, [startCaptureBinding]);
6044 useIsomorphicLayoutEffect(function mount() {
6045 listenForCapture();
6046 return function unmount() {
6047 unbindEventsRef.current();
6048 };
6049 }, [listenForCapture]);
6050}
6051
6052var idle$2 = {
6053 type: 'IDLE'
6054};
6055var timeForLongPress = 120;
6056var forcePressThreshold = 0.15;
6057
6058function getWindowBindings(_ref) {
6059 var cancel = _ref.cancel,
6060 getPhase = _ref.getPhase;
6061 return [{
6062 eventName: 'orientationchange',
6063 fn: cancel
6064 }, {
6065 eventName: 'resize',
6066 fn: cancel
6067 }, {
6068 eventName: 'contextmenu',
6069 fn: function fn(event) {
6070 event.preventDefault();
6071 }
6072 }, {
6073 eventName: 'keydown',
6074 fn: function fn(event) {
6075 if (getPhase().type !== 'DRAGGING') {
6076 cancel();
6077 return;
6078 }
6079
6080 if (event.keyCode === escape) {
6081 event.preventDefault();
6082 }
6083
6084 cancel();
6085 }
6086 }, {
6087 eventName: supportedEventName,
6088 fn: cancel
6089 }];
6090}
6091
6092function getHandleBindings(_ref2) {
6093 var cancel = _ref2.cancel,
6094 completed = _ref2.completed,
6095 getPhase = _ref2.getPhase;
6096 return [{
6097 eventName: 'touchmove',
6098 options: {
6099 capture: false
6100 },
6101 fn: function fn(event) {
6102 var phase = getPhase();
6103
6104 if (phase.type !== 'DRAGGING') {
6105 cancel();
6106 return;
6107 }
6108
6109 phase.hasMoved = true;
6110 var _event$touches$ = event.touches[0],
6111 clientX = _event$touches$.clientX,
6112 clientY = _event$touches$.clientY;
6113 var point = {
6114 x: clientX,
6115 y: clientY
6116 };
6117 event.preventDefault();
6118 phase.actions.move(point);
6119 }
6120 }, {
6121 eventName: 'touchend',
6122 fn: function fn(event) {
6123 var phase = getPhase();
6124
6125 if (phase.type !== 'DRAGGING') {
6126 cancel();
6127 return;
6128 }
6129
6130 event.preventDefault();
6131 phase.actions.drop({
6132 shouldBlockNextClick: true
6133 });
6134 completed();
6135 }
6136 }, {
6137 eventName: 'touchcancel',
6138 fn: function fn(event) {
6139 if (getPhase().type !== 'DRAGGING') {
6140 cancel();
6141 return;
6142 }
6143
6144 event.preventDefault();
6145 cancel();
6146 }
6147 }, {
6148 eventName: 'touchforcechange',
6149 fn: function fn(event) {
6150 var phase = getPhase();
6151 !(phase.type !== 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
6152 var touch = event.touches[0];
6153
6154 if (!touch) {
6155 return;
6156 }
6157
6158 var isForcePress = touch.force >= forcePressThreshold;
6159
6160 if (!isForcePress) {
6161 return;
6162 }
6163
6164 var shouldRespect = phase.actions.shouldRespectForcePress();
6165
6166 if (phase.type === 'PENDING') {
6167 if (shouldRespect) {
6168 cancel();
6169 }
6170
6171 return;
6172 }
6173
6174 if (shouldRespect) {
6175 if (phase.hasMoved) {
6176 event.preventDefault();
6177 return;
6178 }
6179
6180 cancel();
6181 return;
6182 }
6183
6184 event.preventDefault();
6185 }
6186 }, {
6187 eventName: supportedEventName,
6188 fn: cancel
6189 }];
6190}
6191
6192function useTouchSensor(api) {
6193 var phaseRef = React.useRef(idle$2);
6194 var unbindEventsRef = React.useRef(noop);
6195 var getPhase = useMemoOne.useCallback(function getPhase() {
6196 return phaseRef.current;
6197 }, []);
6198 var setPhase = useMemoOne.useCallback(function setPhase(phase) {
6199 phaseRef.current = phase;
6200 }, []);
6201 var startCaptureBinding = useMemoOne.useMemo(function () {
6202 return {
6203 eventName: 'touchstart',
6204 fn: function onTouchStart(event) {
6205 if (event.defaultPrevented) {
6206 return;
6207 }
6208
6209 var draggableId = api.findClosestDraggableId(event);
6210
6211 if (!draggableId) {
6212 return;
6213 }
6214
6215 var actions = api.tryGetLock(draggableId, stop, {
6216 sourceEvent: event
6217 });
6218
6219 if (!actions) {
6220 return;
6221 }
6222
6223 var touch = event.touches[0];
6224 var clientX = touch.clientX,
6225 clientY = touch.clientY;
6226 var point = {
6227 x: clientX,
6228 y: clientY
6229 };
6230 unbindEventsRef.current();
6231 startPendingDrag(actions, point);
6232 }
6233 };
6234 }, [api]);
6235 var listenForCapture = useMemoOne.useCallback(function listenForCapture() {
6236 var options = {
6237 capture: true,
6238 passive: false
6239 };
6240 unbindEventsRef.current = bindEvents(window, [startCaptureBinding], options);
6241 }, [startCaptureBinding]);
6242 var stop = useMemoOne.useCallback(function () {
6243 var current = phaseRef.current;
6244
6245 if (current.type === 'IDLE') {
6246 return;
6247 }
6248
6249 if (current.type === 'PENDING') {
6250 clearTimeout(current.longPressTimerId);
6251 }
6252
6253 setPhase(idle$2);
6254 unbindEventsRef.current();
6255 listenForCapture();
6256 }, [listenForCapture, setPhase]);
6257 var cancel = useMemoOne.useCallback(function () {
6258 var phase = phaseRef.current;
6259 stop();
6260
6261 if (phase.type === 'DRAGGING') {
6262 phase.actions.cancel({
6263 shouldBlockNextClick: true
6264 });
6265 }
6266
6267 if (phase.type === 'PENDING') {
6268 phase.actions.abort();
6269 }
6270 }, [stop]);
6271 var bindCapturingEvents = useMemoOne.useCallback(function bindCapturingEvents() {
6272 var options = {
6273 capture: true,
6274 passive: false
6275 };
6276 var args = {
6277 cancel: cancel,
6278 completed: stop,
6279 getPhase: getPhase
6280 };
6281 var unbindTarget = bindEvents(window, getHandleBindings(args), options);
6282 var unbindWindow = bindEvents(window, getWindowBindings(args), options);
6283
6284 unbindEventsRef.current = function unbindAll() {
6285 unbindTarget();
6286 unbindWindow();
6287 };
6288 }, [cancel, getPhase, stop]);
6289 var startDragging = useMemoOne.useCallback(function startDragging() {
6290 var phase = getPhase();
6291 !(phase.type === 'PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot start dragging from phase " + phase.type) : invariant(false) : void 0;
6292 var actions = phase.actions.fluidLift(phase.point);
6293 setPhase({
6294 type: 'DRAGGING',
6295 actions: actions,
6296 hasMoved: false
6297 });
6298 }, [getPhase, setPhase]);
6299 var startPendingDrag = useMemoOne.useCallback(function startPendingDrag(actions, point) {
6300 !(getPhase().type === 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected to move from IDLE to PENDING drag') : invariant(false) : void 0;
6301 var longPressTimerId = setTimeout(startDragging, timeForLongPress);
6302 setPhase({
6303 type: 'PENDING',
6304 point: point,
6305 actions: actions,
6306 longPressTimerId: longPressTimerId
6307 });
6308 bindCapturingEvents();
6309 }, [bindCapturingEvents, getPhase, setPhase, startDragging]);
6310 useIsomorphicLayoutEffect(function mount() {
6311 listenForCapture();
6312 return function unmount() {
6313 unbindEventsRef.current();
6314 var phase = getPhase();
6315
6316 if (phase.type === 'PENDING') {
6317 clearTimeout(phase.longPressTimerId);
6318 setPhase(idle$2);
6319 }
6320 };
6321 }, [getPhase, listenForCapture, setPhase]);
6322 useIsomorphicLayoutEffect(function webkitHack() {
6323 var unbind = bindEvents(window, [{
6324 eventName: 'touchmove',
6325 fn: function fn() {},
6326 options: {
6327 capture: false,
6328 passive: false
6329 }
6330 }]);
6331 return unbind;
6332 }, []);
6333}
6334
6335function useValidateSensorHooks(sensorHooks) {
6336 useDev(function () {
6337 var previousRef = usePrevious(sensorHooks);
6338 useDevSetupWarning(function () {
6339 !(previousRef.current.length === sensorHooks.length) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot change the amount of sensor hooks after mounting') : invariant(false) : void 0;
6340 });
6341 });
6342}
6343
6344var interactiveTagNames = {
6345 input: true,
6346 button: true,
6347 textarea: true,
6348 select: true,
6349 option: true,
6350 optgroup: true,
6351 video: true,
6352 audio: true
6353};
6354
6355function isAnInteractiveElement(parent, current) {
6356 if (current == null) {
6357 return false;
6358 }
6359
6360 var hasAnInteractiveTag = Boolean(interactiveTagNames[current.tagName.toLowerCase()]);
6361
6362 if (hasAnInteractiveTag) {
6363 return true;
6364 }
6365
6366 var attribute = current.getAttribute('contenteditable');
6367
6368 if (attribute === 'true' || attribute === '') {
6369 return true;
6370 }
6371
6372 if (current === parent) {
6373 return false;
6374 }
6375
6376 return isAnInteractiveElement(parent, current.parentElement);
6377}
6378
6379function isEventInInteractiveElement(draggable, event) {
6380 var target = event.target;
6381
6382 if (!isHtmlElement(target)) {
6383 return false;
6384 }
6385
6386 return isAnInteractiveElement(draggable, target);
6387}
6388
6389var getBorderBoxCenterPosition = (function (el) {
6390 return cssBoxModel.getRect(el.getBoundingClientRect()).center;
6391});
6392
6393function isElement(el) {
6394 return el instanceof getWindowFromEl(el).Element;
6395}
6396
6397var supportedMatchesName = function () {
6398 var base = 'matches';
6399
6400 if (typeof document === 'undefined') {
6401 return base;
6402 }
6403
6404 var candidates = [base, 'msMatchesSelector', 'webkitMatchesSelector'];
6405 var value = find(candidates, function (name) {
6406 return name in Element.prototype;
6407 });
6408 return value || base;
6409}();
6410
6411function closestPonyfill(el, selector) {
6412 if (el == null) {
6413 return null;
6414 }
6415
6416 if (el[supportedMatchesName](selector)) {
6417 return el;
6418 }
6419
6420 return closestPonyfill(el.parentElement, selector);
6421}
6422
6423function closest$1(el, selector) {
6424 if (el.closest) {
6425 return el.closest(selector);
6426 }
6427
6428 return closestPonyfill(el, selector);
6429}
6430
6431function getSelector(contextId) {
6432 return "[" + dragHandle.contextId + "=\"" + contextId + "\"]";
6433}
6434
6435function findClosestDragHandleFromEvent(contextId, event) {
6436 var target = event.target;
6437
6438 if (!isElement(target)) {
6439 process.env.NODE_ENV !== "production" ? warning('event.target must be a Element') : void 0;
6440 return null;
6441 }
6442
6443 var selector = getSelector(contextId);
6444 var handle = closest$1(target, selector);
6445
6446 if (!handle) {
6447 return null;
6448 }
6449
6450 if (!isHtmlElement(handle)) {
6451 process.env.NODE_ENV !== "production" ? warning('drag handle must be a HTMLElement') : void 0;
6452 return null;
6453 }
6454
6455 return handle;
6456}
6457
6458function tryGetClosestDraggableIdFromEvent(contextId, event) {
6459 var handle = findClosestDragHandleFromEvent(contextId, event);
6460
6461 if (!handle) {
6462 return null;
6463 }
6464
6465 return handle.getAttribute(dragHandle.draggableId);
6466}
6467
6468function findDraggable(contextId, draggableId) {
6469 var selector = "[" + draggable.contextId + "=\"" + contextId + "\"]";
6470 var possible = toArray(document.querySelectorAll(selector));
6471 var draggable$1 = find(possible, function (el) {
6472 return el.getAttribute(draggable.id) === draggableId;
6473 });
6474
6475 if (!draggable$1) {
6476 return null;
6477 }
6478
6479 if (!isHtmlElement(draggable$1)) {
6480 process.env.NODE_ENV !== "production" ? warning('Draggable element is not a HTMLElement') : void 0;
6481 return null;
6482 }
6483
6484 return draggable$1;
6485}
6486
6487function preventDefault(event) {
6488 event.preventDefault();
6489}
6490
6491function _isActive(_ref) {
6492 var expected = _ref.expected,
6493 phase = _ref.phase,
6494 isLockActive = _ref.isLockActive,
6495 shouldWarn = _ref.shouldWarn;
6496
6497 if (!isLockActive()) {
6498 if (shouldWarn) {
6499 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
6500 }
6501
6502 return false;
6503 }
6504
6505 if (expected !== phase) {
6506 if (shouldWarn) {
6507 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
6508 }
6509
6510 return false;
6511 }
6512
6513 return true;
6514}
6515
6516function canStart(_ref2) {
6517 var lockAPI = _ref2.lockAPI,
6518 store = _ref2.store,
6519 registry = _ref2.registry,
6520 draggableId = _ref2.draggableId;
6521
6522 if (lockAPI.isClaimed()) {
6523 return false;
6524 }
6525
6526 var entry = registry.draggable.findById(draggableId);
6527
6528 if (!entry) {
6529 process.env.NODE_ENV !== "production" ? warning("Unable to find draggable with id: " + draggableId) : void 0;
6530 return false;
6531 }
6532
6533 if (!entry.options.isEnabled) {
6534 return false;
6535 }
6536
6537 if (!canStartDrag(store.getState(), draggableId)) {
6538 return false;
6539 }
6540
6541 return true;
6542}
6543
6544function tryStart(_ref3) {
6545 var lockAPI = _ref3.lockAPI,
6546 contextId = _ref3.contextId,
6547 store = _ref3.store,
6548 registry = _ref3.registry,
6549 draggableId = _ref3.draggableId,
6550 forceSensorStop = _ref3.forceSensorStop,
6551 sourceEvent = _ref3.sourceEvent;
6552 var shouldStart = canStart({
6553 lockAPI: lockAPI,
6554 store: store,
6555 registry: registry,
6556 draggableId: draggableId
6557 });
6558
6559 if (!shouldStart) {
6560 return null;
6561 }
6562
6563 var entry = registry.draggable.getById(draggableId);
6564 var el = findDraggable(contextId, entry.descriptor.id);
6565
6566 if (!el) {
6567 process.env.NODE_ENV !== "production" ? warning("Unable to find draggable element with id: " + draggableId) : void 0;
6568 return null;
6569 }
6570
6571 if (sourceEvent && !entry.options.canDragInteractiveElements && isEventInInteractiveElement(el, sourceEvent)) {
6572 return null;
6573 }
6574
6575 var lock = lockAPI.claim(forceSensorStop || noop);
6576 var phase = 'PRE_DRAG';
6577
6578 function getShouldRespectForcePress() {
6579 return entry.options.shouldRespectForcePress;
6580 }
6581
6582 function isLockActive() {
6583 return lockAPI.isActive(lock);
6584 }
6585
6586 function tryDispatch(expected, getAction) {
6587 if (_isActive({
6588 expected: expected,
6589 phase: phase,
6590 isLockActive: isLockActive,
6591 shouldWarn: true
6592 })) {
6593 store.dispatch(getAction());
6594 }
6595 }
6596
6597 var tryDispatchWhenDragging = tryDispatch.bind(null, 'DRAGGING');
6598
6599 function lift$1(args) {
6600 function completed() {
6601 lockAPI.release();
6602 phase = 'COMPLETED';
6603 }
6604
6605 if (phase !== 'PRE_DRAG') {
6606 completed();
6607 !(phase === 'PRE_DRAG') ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot lift in phase " + phase) : invariant(false) : void 0;
6608 }
6609
6610 store.dispatch(lift(args.liftActionArgs));
6611 phase = 'DRAGGING';
6612
6613 function finish(reason, options) {
6614 if (options === void 0) {
6615 options = {
6616 shouldBlockNextClick: false
6617 };
6618 }
6619
6620 args.cleanup();
6621
6622 if (options.shouldBlockNextClick) {
6623 var unbind = bindEvents(window, [{
6624 eventName: 'click',
6625 fn: preventDefault,
6626 options: {
6627 once: true,
6628 passive: false,
6629 capture: true
6630 }
6631 }]);
6632 setTimeout(unbind);
6633 }
6634
6635 completed();
6636 store.dispatch(drop({
6637 reason: reason
6638 }));
6639 }
6640
6641 return _extends({
6642 isActive: function isActive() {
6643 return _isActive({
6644 expected: 'DRAGGING',
6645 phase: phase,
6646 isLockActive: isLockActive,
6647 shouldWarn: false
6648 });
6649 },
6650 shouldRespectForcePress: getShouldRespectForcePress,
6651 drop: function drop(options) {
6652 return finish('DROP', options);
6653 },
6654 cancel: function cancel(options) {
6655 return finish('CANCEL', options);
6656 }
6657 }, args.actions);
6658 }
6659
6660 function fluidLift(clientSelection) {
6661 var move$1 = rafSchd(function (client) {
6662 tryDispatchWhenDragging(function () {
6663 return move({
6664 client: client
6665 });
6666 });
6667 });
6668 var api = lift$1({
6669 liftActionArgs: {
6670 id: draggableId,
6671 clientSelection: clientSelection,
6672 movementMode: 'FLUID'
6673 },
6674 cleanup: function cleanup() {
6675 return move$1.cancel();
6676 },
6677 actions: {
6678 move: move$1
6679 }
6680 });
6681 return _extends({}, api, {
6682 move: move$1
6683 });
6684 }
6685
6686 function snapLift() {
6687 var actions = {
6688 moveUp: function moveUp$1() {
6689 return tryDispatchWhenDragging(moveUp);
6690 },
6691 moveRight: function moveRight$1() {
6692 return tryDispatchWhenDragging(moveRight);
6693 },
6694 moveDown: function moveDown$1() {
6695 return tryDispatchWhenDragging(moveDown);
6696 },
6697 moveLeft: function moveLeft$1() {
6698 return tryDispatchWhenDragging(moveLeft);
6699 }
6700 };
6701 return lift$1({
6702 liftActionArgs: {
6703 id: draggableId,
6704 clientSelection: getBorderBoxCenterPosition(el),
6705 movementMode: 'SNAP'
6706 },
6707 cleanup: noop,
6708 actions: actions
6709 });
6710 }
6711
6712 function abortPreDrag() {
6713 var shouldRelease = _isActive({
6714 expected: 'PRE_DRAG',
6715 phase: phase,
6716 isLockActive: isLockActive,
6717 shouldWarn: true
6718 });
6719
6720 if (shouldRelease) {
6721 lockAPI.release();
6722 }
6723 }
6724
6725 var preDrag = {
6726 isActive: function isActive() {
6727 return _isActive({
6728 expected: 'PRE_DRAG',
6729 phase: phase,
6730 isLockActive: isLockActive,
6731 shouldWarn: false
6732 });
6733 },
6734 shouldRespectForcePress: getShouldRespectForcePress,
6735 fluidLift: fluidLift,
6736 snapLift: snapLift,
6737 abort: abortPreDrag
6738 };
6739 return preDrag;
6740}
6741
6742var defaultSensors = [useMouseSensor, useKeyboardSensor, useTouchSensor];
6743function useSensorMarshal(_ref4) {
6744 var contextId = _ref4.contextId,
6745 store = _ref4.store,
6746 registry = _ref4.registry,
6747 customSensors = _ref4.customSensors,
6748 enableDefaultSensors = _ref4.enableDefaultSensors;
6749 var useSensors = [].concat(enableDefaultSensors ? defaultSensors : [], customSensors || []);
6750 var lockAPI = React.useState(function () {
6751 return create();
6752 })[0];
6753 var tryAbandonLock = useMemoOne.useCallback(function tryAbandonLock(previous, current) {
6754 if (previous.isDragging && !current.isDragging) {
6755 lockAPI.tryAbandon();
6756 }
6757 }, [lockAPI]);
6758 useIsomorphicLayoutEffect(function listenToStore() {
6759 var previous = store.getState();
6760 var unsubscribe = store.subscribe(function () {
6761 var current = store.getState();
6762 tryAbandonLock(previous, current);
6763 previous = current;
6764 });
6765 return unsubscribe;
6766 }, [lockAPI, store, tryAbandonLock]);
6767 useIsomorphicLayoutEffect(function () {
6768 return lockAPI.tryAbandon;
6769 }, [lockAPI.tryAbandon]);
6770 var canGetLock = useMemoOne.useCallback(function (draggableId) {
6771 return canStart({
6772 lockAPI: lockAPI,
6773 registry: registry,
6774 store: store,
6775 draggableId: draggableId
6776 });
6777 }, [lockAPI, registry, store]);
6778 var tryGetLock = useMemoOne.useCallback(function (draggableId, forceStop, options) {
6779 return tryStart({
6780 lockAPI: lockAPI,
6781 registry: registry,
6782 contextId: contextId,
6783 store: store,
6784 draggableId: draggableId,
6785 forceSensorStop: forceStop,
6786 sourceEvent: options && options.sourceEvent ? options.sourceEvent : null
6787 });
6788 }, [contextId, lockAPI, registry, store]);
6789 var findClosestDraggableId = useMemoOne.useCallback(function (event) {
6790 return tryGetClosestDraggableIdFromEvent(contextId, event);
6791 }, [contextId]);
6792 var findOptionsForDraggable = useMemoOne.useCallback(function (id) {
6793 var entry = registry.draggable.findById(id);
6794 return entry ? entry.options : null;
6795 }, [registry.draggable]);
6796 var tryReleaseLock = useMemoOne.useCallback(function tryReleaseLock() {
6797 if (!lockAPI.isClaimed()) {
6798 return;
6799 }
6800
6801 lockAPI.tryAbandon();
6802
6803 if (store.getState().phase !== 'IDLE') {
6804 store.dispatch(flush());
6805 }
6806 }, [lockAPI, store]);
6807 var isLockClaimed = useMemoOne.useCallback(lockAPI.isClaimed, [lockAPI]);
6808 var api = useMemoOne.useMemo(function () {
6809 return {
6810 canGetLock: canGetLock,
6811 tryGetLock: tryGetLock,
6812 findClosestDraggableId: findClosestDraggableId,
6813 findOptionsForDraggable: findOptionsForDraggable,
6814 tryReleaseLock: tryReleaseLock,
6815 isLockClaimed: isLockClaimed
6816 };
6817 }, [canGetLock, tryGetLock, findClosestDraggableId, findOptionsForDraggable, tryReleaseLock, isLockClaimed]);
6818 useValidateSensorHooks(useSensors);
6819
6820 for (var i = 0; i < useSensors.length; i++) {
6821 useSensors[i](api);
6822 }
6823}
6824
6825var createResponders = function createResponders(props) {
6826 return {
6827 onBeforeCapture: props.onBeforeCapture,
6828 onBeforeDragStart: props.onBeforeDragStart,
6829 onDragStart: props.onDragStart,
6830 onDragEnd: props.onDragEnd,
6831 onDragUpdate: props.onDragUpdate
6832 };
6833};
6834
6835function getStore(lazyRef) {
6836 !lazyRef.current ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find store from lazy ref') : invariant(false) : void 0;
6837 return lazyRef.current;
6838}
6839
6840function App(props) {
6841 var contextId = props.contextId,
6842 setCallbacks = props.setCallbacks,
6843 sensors = props.sensors,
6844 nonce = props.nonce,
6845 dragHandleUsageInstructions = props.dragHandleUsageInstructions;
6846 var lazyStoreRef = React.useRef(null);
6847 useStartupValidation();
6848 var lastPropsRef = usePrevious(props);
6849 var getResponders = useMemoOne.useCallback(function () {
6850 return createResponders(lastPropsRef.current);
6851 }, [lastPropsRef]);
6852 var announce = useAnnouncer(contextId);
6853 var dragHandleUsageInstructionsId = useHiddenTextElement({
6854 contextId: contextId,
6855 text: dragHandleUsageInstructions
6856 });
6857 var styleMarshal = useStyleMarshal(contextId, nonce);
6858 var lazyDispatch = useMemoOne.useCallback(function (action) {
6859 getStore(lazyStoreRef).dispatch(action);
6860 }, []);
6861 var marshalCallbacks = useMemoOne.useMemo(function () {
6862 return redux.bindActionCreators({
6863 publishWhileDragging: publishWhileDragging,
6864 updateDroppableScroll: updateDroppableScroll,
6865 updateDroppableIsEnabled: updateDroppableIsEnabled,
6866 updateDroppableIsCombineEnabled: updateDroppableIsCombineEnabled,
6867 collectionStarting: collectionStarting
6868 }, lazyDispatch);
6869 }, [lazyDispatch]);
6870 var registry = useRegistry();
6871 var dimensionMarshal = useMemoOne.useMemo(function () {
6872 return createDimensionMarshal(registry, marshalCallbacks);
6873 }, [registry, marshalCallbacks]);
6874 var autoScroller = useMemoOne.useMemo(function () {
6875 return createAutoScroller(_extends({
6876 scrollWindow: scrollWindow,
6877 scrollDroppable: dimensionMarshal.scrollDroppable
6878 }, redux.bindActionCreators({
6879 move: move
6880 }, lazyDispatch)));
6881 }, [dimensionMarshal.scrollDroppable, lazyDispatch]);
6882 var focusMarshal = useFocusMarshal(contextId);
6883 var store = useMemoOne.useMemo(function () {
6884 return createStore({
6885 announce: announce,
6886 autoScroller: autoScroller,
6887 dimensionMarshal: dimensionMarshal,
6888 focusMarshal: focusMarshal,
6889 getResponders: getResponders,
6890 styleMarshal: styleMarshal
6891 });
6892 }, [announce, autoScroller, dimensionMarshal, focusMarshal, getResponders, styleMarshal]);
6893
6894 if (process.env.NODE_ENV !== 'production') {
6895 if (lazyStoreRef.current && lazyStoreRef.current !== store) {
6896 process.env.NODE_ENV !== "production" ? warning('unexpected store change') : void 0;
6897 }
6898 }
6899
6900 lazyStoreRef.current = store;
6901 var tryResetStore = useMemoOne.useCallback(function () {
6902 var current = getStore(lazyStoreRef);
6903 var state = current.getState();
6904
6905 if (state.phase !== 'IDLE') {
6906 current.dispatch(flush());
6907 }
6908 }, []);
6909 var isDragging = useMemoOne.useCallback(function () {
6910 var state = getStore(lazyStoreRef).getState();
6911 return state.isDragging || state.phase === 'DROP_ANIMATING';
6912 }, []);
6913 var appCallbacks = useMemoOne.useMemo(function () {
6914 return {
6915 isDragging: isDragging,
6916 tryAbort: tryResetStore
6917 };
6918 }, [isDragging, tryResetStore]);
6919 setCallbacks(appCallbacks);
6920 var getCanLift = useMemoOne.useCallback(function (id) {
6921 return canStartDrag(getStore(lazyStoreRef).getState(), id);
6922 }, []);
6923 var getIsMovementAllowed = useMemoOne.useCallback(function () {
6924 return isMovementAllowed(getStore(lazyStoreRef).getState());
6925 }, []);
6926 var appContext = useMemoOne.useMemo(function () {
6927 return {
6928 marshal: dimensionMarshal,
6929 focus: focusMarshal,
6930 contextId: contextId,
6931 canLift: getCanLift,
6932 isMovementAllowed: getIsMovementAllowed,
6933 dragHandleUsageInstructionsId: dragHandleUsageInstructionsId,
6934 registry: registry
6935 };
6936 }, [contextId, dimensionMarshal, dragHandleUsageInstructionsId, focusMarshal, getCanLift, getIsMovementAllowed, registry]);
6937 useSensorMarshal({
6938 contextId: contextId,
6939 store: store,
6940 registry: registry,
6941 customSensors: sensors,
6942 enableDefaultSensors: props.enableDefaultSensors !== false
6943 });
6944 React.useEffect(function () {
6945 return tryResetStore;
6946 }, [tryResetStore]);
6947 return React__default.createElement(AppContext.Provider, {
6948 value: appContext
6949 }, React__default.createElement(reactRedux.Provider, {
6950 context: StoreContext,
6951 store: store
6952 }, props.children));
6953}
6954
6955var count$1 = 0;
6956function reset$1() {
6957 count$1 = 0;
6958}
6959function useInstanceCount() {
6960 return useMemoOne.useMemo(function () {
6961 return "" + count$1++;
6962 }, []);
6963}
6964
6965function resetServerContext() {
6966 reset$1();
6967 reset();
6968}
6969function DragDropContext(props) {
6970 var contextId = useInstanceCount();
6971 var dragHandleUsageInstructions = props.dragHandleUsageInstructions || preset.dragHandleUsageInstructions;
6972 return React__default.createElement(ErrorBoundary, null, function (setCallbacks) {
6973 return React__default.createElement(App, {
6974 nonce: props.nonce,
6975 contextId: contextId,
6976 setCallbacks: setCallbacks,
6977 dragHandleUsageInstructions: dragHandleUsageInstructions,
6978 enableDefaultSensors: props.enableDefaultSensors,
6979 sensors: props.sensors,
6980 onBeforeCapture: props.onBeforeCapture,
6981 onBeforeDragStart: props.onBeforeDragStart,
6982 onDragStart: props.onDragStart,
6983 onDragUpdate: props.onDragUpdate,
6984 onDragEnd: props.onDragEnd
6985 }, props.children);
6986 });
6987}
6988
6989var isEqual$1 = function isEqual(base) {
6990 return function (value) {
6991 return base === value;
6992 };
6993};
6994
6995var isScroll = isEqual$1('scroll');
6996var isAuto = isEqual$1('auto');
6997var isVisible$1 = isEqual$1('visible');
6998
6999var isEither = function isEither(overflow, fn) {
7000 return fn(overflow.overflowX) || fn(overflow.overflowY);
7001};
7002
7003var isBoth = function isBoth(overflow, fn) {
7004 return fn(overflow.overflowX) && fn(overflow.overflowY);
7005};
7006
7007var isElementScrollable = function isElementScrollable(el) {
7008 var style = window.getComputedStyle(el);
7009 var overflow = {
7010 overflowX: style.overflowX,
7011 overflowY: style.overflowY
7012 };
7013 return isEither(overflow, isScroll) || isEither(overflow, isAuto);
7014};
7015
7016var isBodyScrollable = function isBodyScrollable() {
7017 if (process.env.NODE_ENV === 'production') {
7018 return false;
7019 }
7020
7021 var body = getBodyElement();
7022 var html = document.documentElement;
7023 !html ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
7024
7025 if (!isElementScrollable(body)) {
7026 return false;
7027 }
7028
7029 var htmlStyle = window.getComputedStyle(html);
7030 var htmlOverflow = {
7031 overflowX: htmlStyle.overflowX,
7032 overflowY: htmlStyle.overflowY
7033 };
7034
7035 if (isBoth(htmlOverflow, isVisible$1)) {
7036 return false;
7037 }
7038
7039 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
7040 return false;
7041};
7042
7043var getClosestScrollable = function getClosestScrollable(el) {
7044 if (el == null) {
7045 return null;
7046 }
7047
7048 if (el === document.body) {
7049 return isBodyScrollable() ? el : null;
7050 }
7051
7052 if (el === document.documentElement) {
7053 return null;
7054 }
7055
7056 if (!isElementScrollable(el)) {
7057 return getClosestScrollable(el.parentElement);
7058 }
7059
7060 return el;
7061};
7062
7063var checkForNestedScrollContainers = (function (scrollable) {
7064 if (!scrollable) {
7065 return;
7066 }
7067
7068 var anotherScrollParent = getClosestScrollable(scrollable.parentElement);
7069
7070 if (!anotherScrollParent) {
7071 return;
7072 }
7073
7074 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
7075});
7076
7077var getScroll$1 = (function (el) {
7078 return {
7079 x: el.scrollLeft,
7080 y: el.scrollTop
7081 };
7082});
7083
7084var getIsFixed = function getIsFixed(el) {
7085 if (!el) {
7086 return false;
7087 }
7088
7089 var style = window.getComputedStyle(el);
7090
7091 if (style.position === 'fixed') {
7092 return true;
7093 }
7094
7095 return getIsFixed(el.parentElement);
7096};
7097
7098var getEnv = (function (start) {
7099 var closestScrollable = getClosestScrollable(start);
7100 var isFixedOnPage = getIsFixed(start);
7101 return {
7102 closestScrollable: closestScrollable,
7103 isFixedOnPage: isFixedOnPage
7104 };
7105});
7106
7107var getDroppableDimension = (function (_ref) {
7108 var descriptor = _ref.descriptor,
7109 isEnabled = _ref.isEnabled,
7110 isCombineEnabled = _ref.isCombineEnabled,
7111 isFixedOnPage = _ref.isFixedOnPage,
7112 direction = _ref.direction,
7113 client = _ref.client,
7114 page = _ref.page,
7115 closest = _ref.closest;
7116
7117 var frame = function () {
7118 if (!closest) {
7119 return null;
7120 }
7121
7122 var scrollSize = closest.scrollSize,
7123 frameClient = closest.client;
7124 var maxScroll = getMaxScroll({
7125 scrollHeight: scrollSize.scrollHeight,
7126 scrollWidth: scrollSize.scrollWidth,
7127 height: frameClient.paddingBox.height,
7128 width: frameClient.paddingBox.width
7129 });
7130 return {
7131 pageMarginBox: closest.page.marginBox,
7132 frameClient: frameClient,
7133 scrollSize: scrollSize,
7134 shouldClipSubject: closest.shouldClipSubject,
7135 scroll: {
7136 initial: closest.scroll,
7137 current: closest.scroll,
7138 max: maxScroll,
7139 diff: {
7140 value: origin,
7141 displacement: origin
7142 }
7143 }
7144 };
7145 }();
7146
7147 var axis = direction === 'vertical' ? vertical : horizontal;
7148 var subject = getSubject({
7149 page: page,
7150 withPlaceholder: null,
7151 axis: axis,
7152 frame: frame
7153 });
7154 var dimension = {
7155 descriptor: descriptor,
7156 isCombineEnabled: isCombineEnabled,
7157 isFixedOnPage: isFixedOnPage,
7158 axis: axis,
7159 isEnabled: isEnabled,
7160 client: client,
7161 page: page,
7162 frame: frame,
7163 subject: subject
7164 };
7165 return dimension;
7166});
7167
7168var getClient = function getClient(targetRef, closestScrollable) {
7169 var base = cssBoxModel.getBox(targetRef);
7170
7171 if (!closestScrollable) {
7172 return base;
7173 }
7174
7175 if (targetRef !== closestScrollable) {
7176 return base;
7177 }
7178
7179 var top = base.paddingBox.top - closestScrollable.scrollTop;
7180 var left = base.paddingBox.left - closestScrollable.scrollLeft;
7181 var bottom = top + closestScrollable.scrollHeight;
7182 var right = left + closestScrollable.scrollWidth;
7183 var paddingBox = {
7184 top: top,
7185 right: right,
7186 bottom: bottom,
7187 left: left
7188 };
7189 var borderBox = cssBoxModel.expand(paddingBox, base.border);
7190 var client = cssBoxModel.createBox({
7191 borderBox: borderBox,
7192 margin: base.margin,
7193 border: base.border,
7194 padding: base.padding
7195 });
7196 return client;
7197};
7198
7199var getDimension = (function (_ref) {
7200 var ref = _ref.ref,
7201 descriptor = _ref.descriptor,
7202 env = _ref.env,
7203 windowScroll = _ref.windowScroll,
7204 direction = _ref.direction,
7205 isDropDisabled = _ref.isDropDisabled,
7206 isCombineEnabled = _ref.isCombineEnabled,
7207 shouldClipSubject = _ref.shouldClipSubject;
7208 var closestScrollable = env.closestScrollable;
7209 var client = getClient(ref, closestScrollable);
7210 var page = cssBoxModel.withScroll(client, windowScroll);
7211
7212 var closest = function () {
7213 if (!closestScrollable) {
7214 return null;
7215 }
7216
7217 var frameClient = cssBoxModel.getBox(closestScrollable);
7218 var scrollSize = {
7219 scrollHeight: closestScrollable.scrollHeight,
7220 scrollWidth: closestScrollable.scrollWidth
7221 };
7222 return {
7223 client: frameClient,
7224 page: cssBoxModel.withScroll(frameClient, windowScroll),
7225 scroll: getScroll$1(closestScrollable),
7226 scrollSize: scrollSize,
7227 shouldClipSubject: shouldClipSubject
7228 };
7229 }();
7230
7231 var dimension = getDroppableDimension({
7232 descriptor: descriptor,
7233 isEnabled: !isDropDisabled,
7234 isCombineEnabled: isCombineEnabled,
7235 isFixedOnPage: env.isFixedOnPage,
7236 direction: direction,
7237 client: client,
7238 page: page,
7239 closest: closest
7240 });
7241 return dimension;
7242});
7243
7244var immediate = {
7245 passive: false
7246};
7247var delayed = {
7248 passive: true
7249};
7250var getListenerOptions = (function (options) {
7251 return options.shouldPublishImmediately ? immediate : delayed;
7252});
7253
7254function useRequiredContext(Context) {
7255 var result = React.useContext(Context);
7256 !result ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find required context') : invariant(false) : void 0;
7257 return result;
7258}
7259
7260var getClosestScrollableFromDrag = function getClosestScrollableFromDrag(dragging) {
7261 return dragging && dragging.env.closestScrollable || null;
7262};
7263
7264function useDroppablePublisher(args) {
7265 var whileDraggingRef = React.useRef(null);
7266 var appContext = useRequiredContext(AppContext);
7267 var uniqueId = useUniqueId('droppable');
7268 var registry = appContext.registry,
7269 marshal = appContext.marshal;
7270 var previousRef = usePrevious(args);
7271 var descriptor = useMemoOne.useMemo(function () {
7272 return {
7273 id: args.droppableId,
7274 type: args.type,
7275 mode: args.mode
7276 };
7277 }, [args.droppableId, args.mode, args.type]);
7278 var publishedDescriptorRef = React.useRef(descriptor);
7279 var memoizedUpdateScroll = useMemoOne.useMemo(function () {
7280 return memoizeOne(function (x, y) {
7281 !whileDraggingRef.current ? process.env.NODE_ENV !== "production" ? invariant(false, 'Can only update scroll when dragging') : invariant(false) : void 0;
7282 var scroll = {
7283 x: x,
7284 y: y
7285 };
7286 marshal.updateDroppableScroll(descriptor.id, scroll);
7287 });
7288 }, [descriptor.id, marshal]);
7289 var getClosestScroll = useMemoOne.useCallback(function () {
7290 var dragging = whileDraggingRef.current;
7291
7292 if (!dragging || !dragging.env.closestScrollable) {
7293 return origin;
7294 }
7295
7296 return getScroll$1(dragging.env.closestScrollable);
7297 }, []);
7298 var updateScroll = useMemoOne.useCallback(function () {
7299 var scroll = getClosestScroll();
7300 memoizedUpdateScroll(scroll.x, scroll.y);
7301 }, [getClosestScroll, memoizedUpdateScroll]);
7302 var scheduleScrollUpdate = useMemoOne.useMemo(function () {
7303 return rafSchd(updateScroll);
7304 }, [updateScroll]);
7305 var onClosestScroll = useMemoOne.useCallback(function () {
7306 var dragging = whileDraggingRef.current;
7307 var closest = getClosestScrollableFromDrag(dragging);
7308 !(dragging && closest) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find scroll options while scrolling') : invariant(false) : void 0;
7309 var options = dragging.scrollOptions;
7310
7311 if (options.shouldPublishImmediately) {
7312 updateScroll();
7313 return;
7314 }
7315
7316 scheduleScrollUpdate();
7317 }, [scheduleScrollUpdate, updateScroll]);
7318 var getDimensionAndWatchScroll = useMemoOne.useCallback(function (windowScroll, options) {
7319 !!whileDraggingRef.current ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot collect a droppable while a drag is occurring') : invariant(false) : void 0;
7320 var previous = previousRef.current;
7321 var ref = previous.getDroppableRef();
7322 !ref ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot collect without a droppable ref') : invariant(false) : void 0;
7323 var env = getEnv(ref);
7324 var dragging = {
7325 ref: ref,
7326 descriptor: descriptor,
7327 env: env,
7328 scrollOptions: options
7329 };
7330 whileDraggingRef.current = dragging;
7331 var dimension = getDimension({
7332 ref: ref,
7333 descriptor: descriptor,
7334 env: env,
7335 windowScroll: windowScroll,
7336 direction: previous.direction,
7337 isDropDisabled: previous.isDropDisabled,
7338 isCombineEnabled: previous.isCombineEnabled,
7339 shouldClipSubject: !previous.ignoreContainerClipping
7340 });
7341 var scrollable = env.closestScrollable;
7342
7343 if (scrollable) {
7344 scrollable.setAttribute(scrollContainer.contextId, appContext.contextId);
7345 scrollable.addEventListener('scroll', onClosestScroll, getListenerOptions(dragging.scrollOptions));
7346
7347 if (process.env.NODE_ENV !== 'production') {
7348 checkForNestedScrollContainers(scrollable);
7349 }
7350 }
7351
7352 return dimension;
7353 }, [appContext.contextId, descriptor, onClosestScroll, previousRef]);
7354 var getScrollWhileDragging = useMemoOne.useCallback(function () {
7355 var dragging = whileDraggingRef.current;
7356 var closest = getClosestScrollableFromDrag(dragging);
7357 !(dragging && closest) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Can only recollect Droppable client for Droppables that have a scroll container') : invariant(false) : void 0;
7358 return getScroll$1(closest);
7359 }, []);
7360 var dragStopped = useMemoOne.useCallback(function () {
7361 var dragging = whileDraggingRef.current;
7362 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot stop drag when no active drag') : invariant(false) : void 0;
7363 var closest = getClosestScrollableFromDrag(dragging);
7364 whileDraggingRef.current = null;
7365
7366 if (!closest) {
7367 return;
7368 }
7369
7370 scheduleScrollUpdate.cancel();
7371 closest.removeAttribute(scrollContainer.contextId);
7372 closest.removeEventListener('scroll', onClosestScroll, getListenerOptions(dragging.scrollOptions));
7373 }, [onClosestScroll, scheduleScrollUpdate]);
7374 var scroll = useMemoOne.useCallback(function (change) {
7375 var dragging = whileDraggingRef.current;
7376 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot scroll when there is no drag') : invariant(false) : void 0;
7377 var closest = getClosestScrollableFromDrag(dragging);
7378 !closest ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot scroll a droppable with no closest scrollable') : invariant(false) : void 0;
7379 closest.scrollTop += change.y;
7380 closest.scrollLeft += change.x;
7381 }, []);
7382 var callbacks = useMemoOne.useMemo(function () {
7383 return {
7384 getDimensionAndWatchScroll: getDimensionAndWatchScroll,
7385 getScrollWhileDragging: getScrollWhileDragging,
7386 dragStopped: dragStopped,
7387 scroll: scroll
7388 };
7389 }, [dragStopped, getDimensionAndWatchScroll, getScrollWhileDragging, scroll]);
7390 var entry = useMemoOne.useMemo(function () {
7391 return {
7392 uniqueId: uniqueId,
7393 descriptor: descriptor,
7394 callbacks: callbacks
7395 };
7396 }, [callbacks, descriptor, uniqueId]);
7397 useIsomorphicLayoutEffect(function () {
7398 publishedDescriptorRef.current = entry.descriptor;
7399 registry.droppable.register(entry);
7400 return function () {
7401 if (whileDraggingRef.current) {
7402 process.env.NODE_ENV !== "production" ? warning('Unsupported: changing the droppableId or type of a Droppable during a drag') : void 0;
7403 dragStopped();
7404 }
7405
7406 registry.droppable.unregister(entry);
7407 };
7408 }, [callbacks, descriptor, dragStopped, entry, marshal, registry.droppable]);
7409 useIsomorphicLayoutEffect(function () {
7410 if (!whileDraggingRef.current) {
7411 return;
7412 }
7413
7414 marshal.updateDroppableIsEnabled(publishedDescriptorRef.current.id, !args.isDropDisabled);
7415 }, [args.isDropDisabled, marshal]);
7416 useIsomorphicLayoutEffect(function () {
7417 if (!whileDraggingRef.current) {
7418 return;
7419 }
7420
7421 marshal.updateDroppableIsCombineEnabled(publishedDescriptorRef.current.id, args.isCombineEnabled);
7422 }, [args.isCombineEnabled, marshal]);
7423}
7424
7425function noop$2() {}
7426
7427var empty = {
7428 width: 0,
7429 height: 0,
7430 margin: noSpacing
7431};
7432
7433var getSize = function getSize(_ref) {
7434 var isAnimatingOpenOnMount = _ref.isAnimatingOpenOnMount,
7435 placeholder = _ref.placeholder,
7436 animate = _ref.animate;
7437
7438 if (isAnimatingOpenOnMount) {
7439 return empty;
7440 }
7441
7442 if (animate === 'close') {
7443 return empty;
7444 }
7445
7446 return {
7447 height: placeholder.client.borderBox.height,
7448 width: placeholder.client.borderBox.width,
7449 margin: placeholder.client.margin
7450 };
7451};
7452
7453var getStyle = function getStyle(_ref2) {
7454 var isAnimatingOpenOnMount = _ref2.isAnimatingOpenOnMount,
7455 placeholder = _ref2.placeholder,
7456 animate = _ref2.animate;
7457 var size = getSize({
7458 isAnimatingOpenOnMount: isAnimatingOpenOnMount,
7459 placeholder: placeholder,
7460 animate: animate
7461 });
7462 return {
7463 display: placeholder.display,
7464 boxSizing: 'border-box',
7465 width: size.width,
7466 height: size.height,
7467 marginTop: size.margin.top,
7468 marginRight: size.margin.right,
7469 marginBottom: size.margin.bottom,
7470 marginLeft: size.margin.left,
7471 flexShrink: '0',
7472 flexGrow: '0',
7473 pointerEvents: 'none',
7474 transition: animate !== 'none' ? transitions.placeholder : null
7475 };
7476};
7477
7478function Placeholder(props) {
7479 var animateOpenTimerRef = React.useRef(null);
7480 var tryClearAnimateOpenTimer = useMemoOne.useCallback(function () {
7481 if (!animateOpenTimerRef.current) {
7482 return;
7483 }
7484
7485 clearTimeout(animateOpenTimerRef.current);
7486 animateOpenTimerRef.current = null;
7487 }, []);
7488 var animate = props.animate,
7489 onTransitionEnd = props.onTransitionEnd,
7490 onClose = props.onClose,
7491 contextId = props.contextId;
7492
7493 var _useState = React.useState(props.animate === 'open'),
7494 isAnimatingOpenOnMount = _useState[0],
7495 setIsAnimatingOpenOnMount = _useState[1];
7496
7497 React.useEffect(function () {
7498 if (!isAnimatingOpenOnMount) {
7499 return noop$2;
7500 }
7501
7502 if (animate !== 'open') {
7503 tryClearAnimateOpenTimer();
7504 setIsAnimatingOpenOnMount(false);
7505 return noop$2;
7506 }
7507
7508 if (animateOpenTimerRef.current) {
7509 return noop$2;
7510 }
7511
7512 animateOpenTimerRef.current = setTimeout(function () {
7513 animateOpenTimerRef.current = null;
7514 setIsAnimatingOpenOnMount(false);
7515 });
7516 return tryClearAnimateOpenTimer;
7517 }, [animate, isAnimatingOpenOnMount, tryClearAnimateOpenTimer]);
7518 var onSizeChangeEnd = useMemoOne.useCallback(function (event) {
7519 if (event.propertyName !== 'height') {
7520 return;
7521 }
7522
7523 onTransitionEnd();
7524
7525 if (animate === 'close') {
7526 onClose();
7527 }
7528 }, [animate, onClose, onTransitionEnd]);
7529 var style = getStyle({
7530 isAnimatingOpenOnMount: isAnimatingOpenOnMount,
7531 animate: props.animate,
7532 placeholder: props.placeholder
7533 });
7534 return React__default.createElement(props.placeholder.tagName, {
7535 style: style,
7536 'data-rbd-placeholder-context-id': contextId,
7537 onTransitionEnd: onSizeChangeEnd,
7538 ref: props.innerRef
7539 });
7540}
7541
7542var Placeholder$1 = React__default.memo(Placeholder);
7543
7544var DroppableContext = React__default.createContext(null);
7545
7546function checkIsValidInnerRef(el) {
7547 !(el && isHtmlElement(el)) ? process.env.NODE_ENV !== "production" ? 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 ") : invariant(false) : void 0;
7548}
7549
7550function isBoolean(value) {
7551 return typeof value === 'boolean';
7552}
7553
7554function runChecks(args, checks) {
7555 checks.forEach(function (check) {
7556 return check(args);
7557 });
7558}
7559
7560var shared = [function required(_ref) {
7561 var props = _ref.props;
7562 !props.droppableId ? process.env.NODE_ENV !== "production" ? invariant(false, 'A Droppable requires a droppableId prop') : invariant(false) : void 0;
7563 !(typeof props.droppableId === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, "A Droppable requires a [string] droppableId. Provided: [" + typeof props.droppableId + "]") : invariant(false) : void 0;
7564}, function _boolean(_ref2) {
7565 var props = _ref2.props;
7566 !isBoolean(props.isDropDisabled) ? process.env.NODE_ENV !== "production" ? invariant(false, 'isDropDisabled must be a boolean') : invariant(false) : void 0;
7567 !isBoolean(props.isCombineEnabled) ? process.env.NODE_ENV !== "production" ? invariant(false, 'isCombineEnabled must be a boolean') : invariant(false) : void 0;
7568 !isBoolean(props.ignoreContainerClipping) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ignoreContainerClipping must be a boolean') : invariant(false) : void 0;
7569}, function ref(_ref3) {
7570 var getDroppableRef = _ref3.getDroppableRef;
7571 checkIsValidInnerRef(getDroppableRef());
7572}];
7573var standard = [function placeholder(_ref4) {
7574 var props = _ref4.props,
7575 getPlaceholderRef = _ref4.getPlaceholderRef;
7576
7577 if (!props.placeholder) {
7578 return;
7579 }
7580
7581 var ref = getPlaceholderRef();
7582
7583 if (ref) {
7584 return;
7585 }
7586
7587 process.env.NODE_ENV !== "production" ? 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 ") : void 0;
7588}];
7589var virtual = [function hasClone(_ref5) {
7590 var props = _ref5.props;
7591 !props.renderClone ? process.env.NODE_ENV !== "production" ? invariant(false, 'Must provide a clone render function (renderClone) for virtual lists') : invariant(false) : void 0;
7592}, function hasNoPlaceholder(_ref6) {
7593 var getPlaceholderRef = _ref6.getPlaceholderRef;
7594 !!getPlaceholderRef() ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected virtual list to not have a placeholder') : invariant(false) : void 0;
7595}];
7596function useValidation(args) {
7597 useDevSetupWarning(function () {
7598 runChecks(args, shared);
7599
7600 if (args.props.mode === 'standard') {
7601 runChecks(args, standard);
7602 }
7603
7604 if (args.props.mode === 'virtual') {
7605 runChecks(args, virtual);
7606 }
7607 });
7608}
7609
7610var AnimateInOut = function (_React$PureComponent) {
7611 _inheritsLoose(AnimateInOut, _React$PureComponent);
7612
7613 function AnimateInOut() {
7614 var _this;
7615
7616 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7617 args[_key] = arguments[_key];
7618 }
7619
7620 _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
7621 _this.state = {
7622 isVisible: Boolean(_this.props.on),
7623 data: _this.props.on,
7624 animate: _this.props.shouldAnimate && _this.props.on ? 'open' : 'none'
7625 };
7626
7627 _this.onClose = function () {
7628 if (_this.state.animate !== 'close') {
7629 return;
7630 }
7631
7632 _this.setState({
7633 isVisible: false
7634 });
7635 };
7636
7637 return _this;
7638 }
7639
7640 AnimateInOut.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
7641 if (!props.shouldAnimate) {
7642 return {
7643 isVisible: Boolean(props.on),
7644 data: props.on,
7645 animate: 'none'
7646 };
7647 }
7648
7649 if (props.on) {
7650 return {
7651 isVisible: true,
7652 data: props.on,
7653 animate: 'open'
7654 };
7655 }
7656
7657 if (state.isVisible) {
7658 return {
7659 isVisible: true,
7660 data: state.data,
7661 animate: 'close'
7662 };
7663 }
7664
7665 return {
7666 isVisible: false,
7667 animate: 'close',
7668 data: null
7669 };
7670 };
7671
7672 var _proto = AnimateInOut.prototype;
7673
7674 _proto.render = function render() {
7675 if (!this.state.isVisible) {
7676 return null;
7677 }
7678
7679 var provided = {
7680 onClose: this.onClose,
7681 data: this.state.data,
7682 animate: this.state.animate
7683 };
7684 return this.props.children(provided);
7685 };
7686
7687 return AnimateInOut;
7688}(React__default.PureComponent);
7689
7690var zIndexOptions = {
7691 dragging: 5000,
7692 dropAnimating: 4500
7693};
7694
7695var getDraggingTransition = function getDraggingTransition(shouldAnimateDragMovement, dropping) {
7696 if (dropping) {
7697 return transitions.drop(dropping.duration);
7698 }
7699
7700 if (shouldAnimateDragMovement) {
7701 return transitions.snap;
7702 }
7703
7704 return transitions.fluid;
7705};
7706
7707var getDraggingOpacity = function getDraggingOpacity(isCombining, isDropAnimating) {
7708 if (!isCombining) {
7709 return null;
7710 }
7711
7712 return isDropAnimating ? combine.opacity.drop : combine.opacity.combining;
7713};
7714
7715var getShouldDraggingAnimate = function getShouldDraggingAnimate(dragging) {
7716 if (dragging.forceShouldAnimate != null) {
7717 return dragging.forceShouldAnimate;
7718 }
7719
7720 return dragging.mode === 'SNAP';
7721};
7722
7723function getDraggingStyle(dragging) {
7724 var dimension = dragging.dimension;
7725 var box = dimension.client;
7726 var offset = dragging.offset,
7727 combineWith = dragging.combineWith,
7728 dropping = dragging.dropping;
7729 var isCombining = Boolean(combineWith);
7730 var shouldAnimate = getShouldDraggingAnimate(dragging);
7731 var isDropAnimating = Boolean(dropping);
7732 var transform = isDropAnimating ? transforms.drop(offset, isCombining) : transforms.moveTo(offset);
7733 var style = {
7734 position: 'fixed',
7735 top: box.marginBox.top,
7736 left: box.marginBox.left,
7737 boxSizing: 'border-box',
7738 width: box.borderBox.width,
7739 height: box.borderBox.height,
7740 transition: getDraggingTransition(shouldAnimate, dropping),
7741 transform: transform,
7742 opacity: getDraggingOpacity(isCombining, isDropAnimating),
7743 zIndex: isDropAnimating ? zIndexOptions.dropAnimating : zIndexOptions.dragging,
7744 pointerEvents: 'none'
7745 };
7746 return style;
7747}
7748
7749function getSecondaryStyle(secondary) {
7750 return {
7751 transform: transforms.moveTo(secondary.offset),
7752 transition: secondary.shouldAnimateDisplacement ? null : 'none'
7753 };
7754}
7755
7756function getStyle$1(mapped) {
7757 return mapped.type === 'DRAGGING' ? getDraggingStyle(mapped) : getSecondaryStyle(mapped);
7758}
7759
7760function getDimension$1(descriptor, el, windowScroll) {
7761 if (windowScroll === void 0) {
7762 windowScroll = origin;
7763 }
7764
7765 var computedStyles = window.getComputedStyle(el);
7766 var borderBox = el.getBoundingClientRect();
7767 var client = cssBoxModel.calculateBox(borderBox, computedStyles);
7768 var page = cssBoxModel.withScroll(client, windowScroll);
7769 var placeholder = {
7770 client: client,
7771 tagName: el.tagName.toLowerCase(),
7772 display: computedStyles.display
7773 };
7774 var displaceBy = {
7775 x: client.marginBox.width,
7776 y: client.marginBox.height
7777 };
7778 var dimension = {
7779 descriptor: descriptor,
7780 placeholder: placeholder,
7781 displaceBy: displaceBy,
7782 client: client,
7783 page: page
7784 };
7785 return dimension;
7786}
7787
7788function useDraggablePublisher(args) {
7789 var uniqueId = useUniqueId('draggable');
7790 var descriptor = args.descriptor,
7791 registry = args.registry,
7792 getDraggableRef = args.getDraggableRef,
7793 canDragInteractiveElements = args.canDragInteractiveElements,
7794 shouldRespectForcePress = args.shouldRespectForcePress,
7795 isEnabled = args.isEnabled;
7796 var options = useMemoOne.useMemo(function () {
7797 return {
7798 canDragInteractiveElements: canDragInteractiveElements,
7799 shouldRespectForcePress: shouldRespectForcePress,
7800 isEnabled: isEnabled
7801 };
7802 }, [canDragInteractiveElements, isEnabled, shouldRespectForcePress]);
7803 var getDimension = useMemoOne.useCallback(function (windowScroll) {
7804 var el = getDraggableRef();
7805 !el ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot get dimension when no ref is set') : invariant(false) : void 0;
7806 return getDimension$1(descriptor, el, windowScroll);
7807 }, [descriptor, getDraggableRef]);
7808 var entry = useMemoOne.useMemo(function () {
7809 return {
7810 uniqueId: uniqueId,
7811 descriptor: descriptor,
7812 options: options,
7813 getDimension: getDimension
7814 };
7815 }, [descriptor, getDimension, options, uniqueId]);
7816 var publishedRef = React.useRef(entry);
7817 var isFirstPublishRef = React.useRef(true);
7818 useIsomorphicLayoutEffect(function () {
7819 registry.draggable.register(publishedRef.current);
7820 return function () {
7821 return registry.draggable.unregister(publishedRef.current);
7822 };
7823 }, [registry.draggable]);
7824 useIsomorphicLayoutEffect(function () {
7825 if (isFirstPublishRef.current) {
7826 isFirstPublishRef.current = false;
7827 return;
7828 }
7829
7830 var last = publishedRef.current;
7831 publishedRef.current = entry;
7832 registry.draggable.update(entry, last);
7833 }, [entry, registry.draggable]);
7834}
7835
7836function useValidation$1(props, contextId, getRef) {
7837 useDevSetupWarning(function () {
7838 function prefix(id) {
7839 return "Draggable[id: " + id + "]: ";
7840 }
7841
7842 var id = props.draggableId;
7843 !id ? process.env.NODE_ENV !== "production" ? invariant(false, 'Draggable requires a draggableId') : invariant(false) : void 0;
7844 !(typeof id === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, "Draggable requires a [string] draggableId.\n Provided: [type: " + typeof id + "] (value: " + id + ")") : invariant(false) : void 0;
7845 !isInteger(props.index) ? process.env.NODE_ENV !== "production" ? invariant(false, prefix(id) + " requires an integer index prop") : invariant(false) : void 0;
7846
7847 if (props.mapped.type === 'DRAGGING') {
7848 return;
7849 }
7850
7851 checkIsValidInnerRef(getRef());
7852
7853 if (props.isEnabled) {
7854 !findDragHandle(contextId, id) ? process.env.NODE_ENV !== "production" ? invariant(false, prefix(id) + " Unable to find drag handle") : invariant(false) : void 0;
7855 }
7856 });
7857}
7858function useClonePropValidation(isClone) {
7859 useDev(function () {
7860 var initialRef = React.useRef(isClone);
7861 useDevSetupWarning(function () {
7862 !(isClone === initialRef.current) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Draggable isClone prop value changed during component life') : invariant(false) : void 0;
7863 }, [isClone]);
7864 });
7865}
7866
7867function preventHtml5Dnd(event) {
7868 event.preventDefault();
7869}
7870
7871function Draggable(props) {
7872 var ref = React.useRef(null);
7873 var setRef = useMemoOne.useCallback(function (el) {
7874 ref.current = el;
7875 }, []);
7876 var getRef = useMemoOne.useCallback(function () {
7877 return ref.current;
7878 }, []);
7879
7880 var _useRequiredContext = useRequiredContext(AppContext),
7881 contextId = _useRequiredContext.contextId,
7882 dragHandleUsageInstructionsId = _useRequiredContext.dragHandleUsageInstructionsId,
7883 registry = _useRequiredContext.registry;
7884
7885 var _useRequiredContext2 = useRequiredContext(DroppableContext),
7886 type = _useRequiredContext2.type,
7887 droppableId = _useRequiredContext2.droppableId;
7888
7889 var descriptor = useMemoOne.useMemo(function () {
7890 return {
7891 id: props.draggableId,
7892 index: props.index,
7893 type: type,
7894 droppableId: droppableId
7895 };
7896 }, [props.draggableId, props.index, type, droppableId]);
7897 var children = props.children,
7898 draggableId = props.draggableId,
7899 isEnabled = props.isEnabled,
7900 shouldRespectForcePress = props.shouldRespectForcePress,
7901 canDragInteractiveElements = props.canDragInteractiveElements,
7902 isClone = props.isClone,
7903 mapped = props.mapped,
7904 dropAnimationFinishedAction = props.dropAnimationFinished;
7905 useValidation$1(props, contextId, getRef);
7906 useClonePropValidation(isClone);
7907
7908 if (!isClone) {
7909 var forPublisher = useMemoOne.useMemo(function () {
7910 return {
7911 descriptor: descriptor,
7912 registry: registry,
7913 getDraggableRef: getRef,
7914 canDragInteractiveElements: canDragInteractiveElements,
7915 shouldRespectForcePress: shouldRespectForcePress,
7916 isEnabled: isEnabled
7917 };
7918 }, [descriptor, registry, getRef, canDragInteractiveElements, shouldRespectForcePress, isEnabled]);
7919 useDraggablePublisher(forPublisher);
7920 }
7921
7922 var dragHandleProps = useMemoOne.useMemo(function () {
7923 return isEnabled ? {
7924 tabIndex: 0,
7925 role: 'button',
7926 'aria-describedby': dragHandleUsageInstructionsId,
7927 'data-rbd-drag-handle-draggable-id': draggableId,
7928 'data-rbd-drag-handle-context-id': contextId,
7929 draggable: false,
7930 onDragStart: preventHtml5Dnd
7931 } : null;
7932 }, [contextId, dragHandleUsageInstructionsId, draggableId, isEnabled]);
7933 var onMoveEnd = useMemoOne.useCallback(function (event) {
7934 if (mapped.type !== 'DRAGGING') {
7935 return;
7936 }
7937
7938 if (!mapped.dropping) {
7939 return;
7940 }
7941
7942 if (event.propertyName !== 'transform') {
7943 return;
7944 }
7945
7946 dropAnimationFinishedAction();
7947 }, [dropAnimationFinishedAction, mapped]);
7948 var provided = useMemoOne.useMemo(function () {
7949 var style = getStyle$1(mapped);
7950 var onTransitionEnd = mapped.type === 'DRAGGING' && mapped.dropping ? onMoveEnd : null;
7951 var result = {
7952 innerRef: setRef,
7953 draggableProps: {
7954 'data-rbd-draggable-context-id': contextId,
7955 'data-rbd-draggable-id': draggableId,
7956 style: style,
7957 onTransitionEnd: onTransitionEnd
7958 },
7959 dragHandleProps: dragHandleProps
7960 };
7961 return result;
7962 }, [contextId, dragHandleProps, draggableId, mapped, onMoveEnd, setRef]);
7963 var rubric = useMemoOne.useMemo(function () {
7964 return {
7965 draggableId: descriptor.id,
7966 type: descriptor.type,
7967 source: {
7968 index: descriptor.index,
7969 droppableId: descriptor.droppableId
7970 }
7971 };
7972 }, [descriptor.droppableId, descriptor.id, descriptor.index, descriptor.type]);
7973 return children(provided, mapped.snapshot, rubric);
7974}
7975
7976var isStrictEqual = (function (a, b) {
7977 return a === b;
7978});
7979
7980var whatIsDraggedOverFromResult = (function (result) {
7981 var combine = result.combine,
7982 destination = result.destination;
7983
7984 if (destination) {
7985 return destination.droppableId;
7986 }
7987
7988 if (combine) {
7989 return combine.droppableId;
7990 }
7991
7992 return null;
7993});
7994
7995var getCombineWithFromResult = function getCombineWithFromResult(result) {
7996 return result.combine ? result.combine.draggableId : null;
7997};
7998
7999var getCombineWithFromImpact = function getCombineWithFromImpact(impact) {
8000 return impact.at && impact.at.type === 'COMBINE' ? impact.at.combine.draggableId : null;
8001};
8002
8003function getDraggableSelector() {
8004 var memoizedOffset = memoizeOne(function (x, y) {
8005 return {
8006 x: x,
8007 y: y
8008 };
8009 });
8010 var getMemoizedSnapshot = memoizeOne(function (mode, isClone, draggingOver, combineWith, dropping) {
8011 return {
8012 isDragging: true,
8013 isClone: isClone,
8014 isDropAnimating: Boolean(dropping),
8015 dropAnimation: dropping,
8016 mode: mode,
8017 draggingOver: draggingOver,
8018 combineWith: combineWith,
8019 combineTargetFor: null
8020 };
8021 });
8022 var getMemoizedProps = memoizeOne(function (offset, mode, dimension, isClone, draggingOver, combineWith, forceShouldAnimate) {
8023 return {
8024 mapped: {
8025 type: 'DRAGGING',
8026 dropping: null,
8027 draggingOver: draggingOver,
8028 combineWith: combineWith,
8029 mode: mode,
8030 offset: offset,
8031 dimension: dimension,
8032 forceShouldAnimate: forceShouldAnimate,
8033 snapshot: getMemoizedSnapshot(mode, isClone, draggingOver, combineWith, null)
8034 }
8035 };
8036 });
8037
8038 var selector = function selector(state, ownProps) {
8039 if (state.isDragging) {
8040 if (state.critical.draggable.id !== ownProps.draggableId) {
8041 return null;
8042 }
8043
8044 var offset = state.current.client.offset;
8045 var dimension = state.dimensions.draggables[ownProps.draggableId];
8046 var draggingOver = whatIsDraggedOver(state.impact);
8047 var combineWith = getCombineWithFromImpact(state.impact);
8048 var forceShouldAnimate = state.forceShouldAnimate;
8049 return getMemoizedProps(memoizedOffset(offset.x, offset.y), state.movementMode, dimension, ownProps.isClone, draggingOver, combineWith, forceShouldAnimate);
8050 }
8051
8052 if (state.phase === 'DROP_ANIMATING') {
8053 var completed = state.completed;
8054
8055 if (completed.result.draggableId !== ownProps.draggableId) {
8056 return null;
8057 }
8058
8059 var isClone = ownProps.isClone;
8060 var _dimension = state.dimensions.draggables[ownProps.draggableId];
8061 var result = completed.result;
8062 var mode = result.mode;
8063
8064 var _draggingOver = whatIsDraggedOverFromResult(result);
8065
8066 var _combineWith = getCombineWithFromResult(result);
8067
8068 var duration = state.dropDuration;
8069 var dropping = {
8070 duration: duration,
8071 curve: curves.drop,
8072 moveTo: state.newHomeClientOffset,
8073 opacity: _combineWith ? combine.opacity.drop : null,
8074 scale: _combineWith ? combine.scale.drop : null
8075 };
8076 return {
8077 mapped: {
8078 type: 'DRAGGING',
8079 offset: state.newHomeClientOffset,
8080 dimension: _dimension,
8081 dropping: dropping,
8082 draggingOver: _draggingOver,
8083 combineWith: _combineWith,
8084 mode: mode,
8085 forceShouldAnimate: null,
8086 snapshot: getMemoizedSnapshot(mode, isClone, _draggingOver, _combineWith, dropping)
8087 }
8088 };
8089 }
8090
8091 return null;
8092 };
8093
8094 return selector;
8095}
8096
8097function getSecondarySnapshot(combineTargetFor) {
8098 return {
8099 isDragging: false,
8100 isDropAnimating: false,
8101 isClone: false,
8102 dropAnimation: null,
8103 mode: null,
8104 draggingOver: null,
8105 combineTargetFor: combineTargetFor,
8106 combineWith: null
8107 };
8108}
8109
8110var atRest = {
8111 mapped: {
8112 type: 'SECONDARY',
8113 offset: origin,
8114 combineTargetFor: null,
8115 shouldAnimateDisplacement: true,
8116 snapshot: getSecondarySnapshot(null)
8117 }
8118};
8119
8120function getSecondarySelector() {
8121 var memoizedOffset = memoizeOne(function (x, y) {
8122 return {
8123 x: x,
8124 y: y
8125 };
8126 });
8127 var getMemoizedSnapshot = memoizeOne(getSecondarySnapshot);
8128 var getMemoizedProps = memoizeOne(function (offset, combineTargetFor, shouldAnimateDisplacement) {
8129 if (combineTargetFor === void 0) {
8130 combineTargetFor = null;
8131 }
8132
8133 return {
8134 mapped: {
8135 type: 'SECONDARY',
8136 offset: offset,
8137 combineTargetFor: combineTargetFor,
8138 shouldAnimateDisplacement: shouldAnimateDisplacement,
8139 snapshot: getMemoizedSnapshot(combineTargetFor)
8140 }
8141 };
8142 });
8143
8144 var getFallback = function getFallback(combineTargetFor) {
8145 return combineTargetFor ? getMemoizedProps(origin, combineTargetFor, true) : null;
8146 };
8147
8148 var getProps = function getProps(ownId, draggingId, impact, afterCritical) {
8149 var visualDisplacement = impact.displaced.visible[ownId];
8150 var isAfterCriticalInVirtualList = Boolean(afterCritical.inVirtualList && afterCritical.effected[ownId]);
8151 var combine = tryGetCombine(impact);
8152 var combineTargetFor = combine && combine.draggableId === ownId ? draggingId : null;
8153
8154 if (!visualDisplacement) {
8155 if (!isAfterCriticalInVirtualList) {
8156 return getFallback(combineTargetFor);
8157 }
8158
8159 if (impact.displaced.invisible[ownId]) {
8160 return null;
8161 }
8162
8163 var change = negate(afterCritical.displacedBy.point);
8164
8165 var _offset = memoizedOffset(change.x, change.y);
8166
8167 return getMemoizedProps(_offset, combineTargetFor, true);
8168 }
8169
8170 if (isAfterCriticalInVirtualList) {
8171 return getFallback(combineTargetFor);
8172 }
8173
8174 var displaceBy = impact.displacedBy.point;
8175 var offset = memoizedOffset(displaceBy.x, displaceBy.y);
8176 return getMemoizedProps(offset, combineTargetFor, visualDisplacement.shouldAnimate);
8177 };
8178
8179 var selector = function selector(state, ownProps) {
8180 if (state.isDragging) {
8181 if (state.critical.draggable.id === ownProps.draggableId) {
8182 return null;
8183 }
8184
8185 return getProps(ownProps.draggableId, state.critical.draggable.id, state.impact, state.afterCritical);
8186 }
8187
8188 if (state.phase === 'DROP_ANIMATING') {
8189 var completed = state.completed;
8190
8191 if (completed.result.draggableId === ownProps.draggableId) {
8192 return null;
8193 }
8194
8195 return getProps(ownProps.draggableId, completed.result.draggableId, completed.impact, completed.afterCritical);
8196 }
8197
8198 return null;
8199 };
8200
8201 return selector;
8202}
8203
8204var makeMapStateToProps = function makeMapStateToProps() {
8205 var draggingSelector = getDraggableSelector();
8206 var secondarySelector = getSecondarySelector();
8207
8208 var selector = function selector(state, ownProps) {
8209 return draggingSelector(state, ownProps) || secondarySelector(state, ownProps) || atRest;
8210 };
8211
8212 return selector;
8213};
8214var mapDispatchToProps = {
8215 dropAnimationFinished: dropAnimationFinished
8216};
8217var ConnectedDraggable = reactRedux.connect(makeMapStateToProps, mapDispatchToProps, null, {
8218 context: StoreContext,
8219 pure: true,
8220 areStatePropsEqual: isStrictEqual
8221})(Draggable);
8222
8223function PrivateDraggable(props) {
8224 var droppableContext = useRequiredContext(DroppableContext);
8225 var isUsingCloneFor = droppableContext.isUsingCloneFor;
8226
8227 if (isUsingCloneFor === props.draggableId && !props.isClone) {
8228 return null;
8229 }
8230
8231 return React__default.createElement(ConnectedDraggable, props);
8232}
8233function PublicDraggable(props) {
8234 var isEnabled = typeof props.isDragDisabled === 'boolean' ? !props.isDragDisabled : true;
8235 var canDragInteractiveElements = Boolean(props.disableInteractiveElementBlocking);
8236 var shouldRespectForcePress = Boolean(props.shouldRespectForcePress);
8237 return React__default.createElement(PrivateDraggable, _extends({}, props, {
8238 isClone: false,
8239 isEnabled: isEnabled,
8240 canDragInteractiveElements: canDragInteractiveElements,
8241 shouldRespectForcePress: shouldRespectForcePress
8242 }));
8243}
8244
8245function Droppable(props) {
8246 var appContext = React.useContext(AppContext);
8247 !appContext ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find app context') : invariant(false) : void 0;
8248 var contextId = appContext.contextId,
8249 isMovementAllowed = appContext.isMovementAllowed;
8250 var droppableRef = React.useRef(null);
8251 var placeholderRef = React.useRef(null);
8252 var children = props.children,
8253 droppableId = props.droppableId,
8254 type = props.type,
8255 mode = props.mode,
8256 direction = props.direction,
8257 ignoreContainerClipping = props.ignoreContainerClipping,
8258 isDropDisabled = props.isDropDisabled,
8259 isCombineEnabled = props.isCombineEnabled,
8260 snapshot = props.snapshot,
8261 useClone = props.useClone,
8262 updateViewportMaxScroll = props.updateViewportMaxScroll,
8263 getContainerForClone = props.getContainerForClone;
8264 var getDroppableRef = useMemoOne.useCallback(function () {
8265 return droppableRef.current;
8266 }, []);
8267 var setDroppableRef = useMemoOne.useCallback(function (value) {
8268 droppableRef.current = value;
8269 }, []);
8270 var getPlaceholderRef = useMemoOne.useCallback(function () {
8271 return placeholderRef.current;
8272 }, []);
8273 var setPlaceholderRef = useMemoOne.useCallback(function (value) {
8274 placeholderRef.current = value;
8275 }, []);
8276 useValidation({
8277 props: props,
8278 getDroppableRef: getDroppableRef,
8279 getPlaceholderRef: getPlaceholderRef
8280 });
8281 var onPlaceholderTransitionEnd = useMemoOne.useCallback(function () {
8282 if (isMovementAllowed()) {
8283 updateViewportMaxScroll({
8284 maxScroll: getMaxWindowScroll()
8285 });
8286 }
8287 }, [isMovementAllowed, updateViewportMaxScroll]);
8288 useDroppablePublisher({
8289 droppableId: droppableId,
8290 type: type,
8291 mode: mode,
8292 direction: direction,
8293 isDropDisabled: isDropDisabled,
8294 isCombineEnabled: isCombineEnabled,
8295 ignoreContainerClipping: ignoreContainerClipping,
8296 getDroppableRef: getDroppableRef
8297 });
8298 var placeholder = React__default.createElement(AnimateInOut, {
8299 on: props.placeholder,
8300 shouldAnimate: props.shouldAnimatePlaceholder
8301 }, function (_ref) {
8302 var onClose = _ref.onClose,
8303 data = _ref.data,
8304 animate = _ref.animate;
8305 return React__default.createElement(Placeholder$1, {
8306 placeholder: data,
8307 onClose: onClose,
8308 innerRef: setPlaceholderRef,
8309 animate: animate,
8310 contextId: contextId,
8311 onTransitionEnd: onPlaceholderTransitionEnd
8312 });
8313 });
8314 var provided = useMemoOne.useMemo(function () {
8315 return {
8316 innerRef: setDroppableRef,
8317 placeholder: placeholder,
8318 droppableProps: {
8319 'data-rbd-droppable-id': droppableId,
8320 'data-rbd-droppable-context-id': contextId
8321 }
8322 };
8323 }, [contextId, droppableId, placeholder, setDroppableRef]);
8324 var isUsingCloneFor = useClone ? useClone.dragging.draggableId : null;
8325 var droppableContext = useMemoOne.useMemo(function () {
8326 return {
8327 droppableId: droppableId,
8328 type: type,
8329 isUsingCloneFor: isUsingCloneFor
8330 };
8331 }, [droppableId, isUsingCloneFor, type]);
8332
8333 function getClone() {
8334 if (!useClone) {
8335 return null;
8336 }
8337
8338 var dragging = useClone.dragging,
8339 render = useClone.render;
8340 var node = React__default.createElement(PrivateDraggable, {
8341 draggableId: dragging.draggableId,
8342 index: dragging.source.index,
8343 isClone: true,
8344 isEnabled: true,
8345 shouldRespectForcePress: false,
8346 canDragInteractiveElements: true
8347 }, function (draggableProvided, draggableSnapshot) {
8348 return render(draggableProvided, draggableSnapshot, dragging);
8349 });
8350 return ReactDOM.createPortal(node, getContainerForClone());
8351 }
8352
8353 return React__default.createElement(DroppableContext.Provider, {
8354 value: droppableContext
8355 }, children(provided, snapshot), getClone());
8356}
8357
8358var isMatchingType = function isMatchingType(type, critical) {
8359 return type === critical.droppable.type;
8360};
8361
8362var getDraggable = function getDraggable(critical, dimensions) {
8363 return dimensions.draggables[critical.draggable.id];
8364};
8365
8366var makeMapStateToProps$1 = function makeMapStateToProps() {
8367 var idleWithAnimation = {
8368 placeholder: null,
8369 shouldAnimatePlaceholder: true,
8370 snapshot: {
8371 isDraggingOver: false,
8372 draggingOverWith: null,
8373 draggingFromThisWith: null,
8374 isUsingPlaceholder: false
8375 },
8376 useClone: null
8377 };
8378
8379 var idleWithoutAnimation = _extends({}, idleWithAnimation, {
8380 shouldAnimatePlaceholder: false
8381 });
8382
8383 var getDraggableRubric = memoizeOne(function (descriptor) {
8384 return {
8385 draggableId: descriptor.id,
8386 type: descriptor.type,
8387 source: {
8388 index: descriptor.index,
8389 droppableId: descriptor.droppableId
8390 }
8391 };
8392 });
8393 var getMapProps = memoizeOne(function (id, isEnabled, isDraggingOverForConsumer, isDraggingOverForImpact, dragging, renderClone) {
8394 var draggableId = dragging.descriptor.id;
8395 var isHome = dragging.descriptor.droppableId === id;
8396
8397 if (isHome) {
8398 var useClone = renderClone ? {
8399 render: renderClone,
8400 dragging: getDraggableRubric(dragging.descriptor)
8401 } : null;
8402 var _snapshot = {
8403 isDraggingOver: isDraggingOverForConsumer,
8404 draggingOverWith: isDraggingOverForConsumer ? draggableId : null,
8405 draggingFromThisWith: draggableId,
8406 isUsingPlaceholder: true
8407 };
8408 return {
8409 placeholder: dragging.placeholder,
8410 shouldAnimatePlaceholder: false,
8411 snapshot: _snapshot,
8412 useClone: useClone
8413 };
8414 }
8415
8416 if (!isEnabled) {
8417 return idleWithoutAnimation;
8418 }
8419
8420 if (!isDraggingOverForImpact) {
8421 return idleWithAnimation;
8422 }
8423
8424 var snapshot = {
8425 isDraggingOver: isDraggingOverForConsumer,
8426 draggingOverWith: draggableId,
8427 draggingFromThisWith: null,
8428 isUsingPlaceholder: true
8429 };
8430 return {
8431 placeholder: dragging.placeholder,
8432 shouldAnimatePlaceholder: true,
8433 snapshot: snapshot,
8434 useClone: null
8435 };
8436 });
8437
8438 var selector = function selector(state, ownProps) {
8439 var id = ownProps.droppableId;
8440 var type = ownProps.type;
8441 var isEnabled = !ownProps.isDropDisabled;
8442 var renderClone = ownProps.renderClone;
8443
8444 if (state.isDragging) {
8445 var critical = state.critical;
8446
8447 if (!isMatchingType(type, critical)) {
8448 return idleWithoutAnimation;
8449 }
8450
8451 var dragging = getDraggable(critical, state.dimensions);
8452 var isDraggingOver = whatIsDraggedOver(state.impact) === id;
8453 return getMapProps(id, isEnabled, isDraggingOver, isDraggingOver, dragging, renderClone);
8454 }
8455
8456 if (state.phase === 'DROP_ANIMATING') {
8457 var completed = state.completed;
8458
8459 if (!isMatchingType(type, completed.critical)) {
8460 return idleWithoutAnimation;
8461 }
8462
8463 var _dragging = getDraggable(completed.critical, state.dimensions);
8464
8465 return getMapProps(id, isEnabled, whatIsDraggedOverFromResult(completed.result) === id, whatIsDraggedOver(completed.impact) === id, _dragging, renderClone);
8466 }
8467
8468 if (state.phase === 'IDLE' && state.completed && !state.shouldFlush) {
8469 var _completed = state.completed;
8470
8471 if (!isMatchingType(type, _completed.critical)) {
8472 return idleWithoutAnimation;
8473 }
8474
8475 var wasOver = whatIsDraggedOver(_completed.impact) === id;
8476 var wasCombining = Boolean(_completed.impact.at && _completed.impact.at.type === 'COMBINE');
8477 var isHome = _completed.critical.droppable.id === id;
8478
8479 if (wasOver) {
8480 return wasCombining ? idleWithAnimation : idleWithoutAnimation;
8481 }
8482
8483 if (isHome) {
8484 return idleWithAnimation;
8485 }
8486
8487 return idleWithoutAnimation;
8488 }
8489
8490 return idleWithoutAnimation;
8491 };
8492
8493 return selector;
8494};
8495var mapDispatchToProps$1 = {
8496 updateViewportMaxScroll: updateViewportMaxScroll
8497};
8498
8499function getBody() {
8500 !document.body ? process.env.NODE_ENV !== "production" ? invariant(false, 'document.body is not ready') : invariant(false) : void 0;
8501 return document.body;
8502}
8503
8504var defaultProps = {
8505 mode: 'standard',
8506 type: 'DEFAULT',
8507 direction: 'vertical',
8508 isDropDisabled: false,
8509 isCombineEnabled: false,
8510 ignoreContainerClipping: false,
8511 renderClone: null,
8512 getContainerForClone: getBody
8513};
8514var ConnectedDroppable = reactRedux.connect(makeMapStateToProps$1, mapDispatchToProps$1, null, {
8515 context: StoreContext,
8516 pure: true,
8517 areStatePropsEqual: isStrictEqual
8518})(Droppable);
8519ConnectedDroppable.defaultProps = defaultProps;
8520
8521exports.DragDropContext = DragDropContext;
8522exports.Draggable = PublicDraggable;
8523exports.Droppable = ConnectedDroppable;
8524exports.resetServerContext = resetServerContext;
8525exports.useKeyboardSensor = useKeyboardSensor;
8526exports.useMouseSensor = useMouseSensor;
8527exports.useTouchSensor = useTouchSensor;