From d08a599b943f2e77028f110b7e75b867a8cd75e5 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 2 Feb 2024 12:28:26 +1300 Subject: [PATCH] ENH Improve keyboard support --- client/dist/js/bundle.js | 6806 ++++++++++++++++- client/dist/styles/bundle.css | 217 +- client/src/components/LinkField/LinkField.js | 160 +- .../src/components/LinkPicker/LinkPicker.js | 17 +- .../src/components/LinkPicker/LinkPicker.scss | 13 +- .../components/LinkPicker/LinkPickerMenu.js | 21 +- .../components/LinkPicker/LinkPickerTitle.js | 51 +- 7 files changed, 7247 insertions(+), 38 deletions(-) diff --git a/client/dist/js/bundle.js b/client/dist/js/bundle.js index 043c3cd1..dacf0a66 100644 --- a/client/dist/js/bundle.js +++ b/client/dist/js/bundle.js @@ -1 +1,6805 @@ -!function(){"use strict";var e={33:function(e,t,n){n.r(t),n.d(t,{AutoScrollActivator:function(){return xe},DndContext:function(){return Ge},DragOverlay:function(){return bt},KeyboardCode:function(){return ie},KeyboardSensor:function(){return ce},MeasuringFrequency:function(){return De},MeasuringStrategy:function(){return ke},MouseSensor:function(){return me},PointerSensor:function(){return ge},TouchSensor:function(){return we},TraversalOrder:function(){return Ce},applyModifiers:function(){return Ye},closestCenter:function(){return S},closestCorners:function(){return O},defaultAnnouncements:function(){return p},defaultCoordinates:function(){return y},defaultDropAnimation:function(){return pt},defaultDropAnimationSideEffects:function(){return ft},defaultScreenReaderInstructions:function(){return f},getClientRect:function(){return j},getFirstCollision:function(){return k},getScrollableAncestors:function(){return K},pointerWithin:function(){return L},rectIntersection:function(){return _},useDndContext:function(){return nt},useDndMonitor:function(){return d},useDraggable:function(){return tt},useDroppable:function(){return it},useSensor:function(){return b},useSensors:function(){return m}});var r=n(363),o=n.n(r),i=ReactDom,a=n(285);const l={display:"none"};function s(e){let{id:t,value:n}=e;return o().createElement("div",{id:t,style:l},n)}function u(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return o().createElement("div",{id:t,style:{position:"fixed",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":r,"aria-atomic":!0},n)}const c=(0,r.createContext)(null);function d(e){const t=(0,r.useContext)(c);(0,r.useEffect)((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)}),[e,t])}const f={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},p={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function v(e){let{announcements:t=p,container:n,hiddenTextDescribedById:l,screenReaderInstructions:c=f}=e;const{announce:v,announcement:g}=function(){const[e,t]=(0,r.useState)("");return{announce:(0,r.useCallback)((e=>{null!=e&&t(e)}),[]),announcement:e}}(),h=(0,a.useUniqueId)("DndLiveRegion"),[b,m]=(0,r.useState)(!1);if((0,r.useEffect)((()=>{m(!0)}),[]),d((0,r.useMemo)((()=>({onDragStart(e){let{active:n}=e;v(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&v(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;v(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;v(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;v(t.onDragCancel({active:n,over:r}))}})),[v,t])),!b)return null;const y=o().createElement(o().Fragment,null,o().createElement(s,{id:l,value:c.draggable}),o().createElement(u,{id:h,announcement:g}));return n?(0,i.createPortal)(y,n):y}var g;function h(){}function b(e,t){return(0,r.useMemo)((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}function m(){for(var e=arguments.length,t=new Array(e),n=0;n[...t].filter((e=>null!=e))),[...t])}!function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"}(g||(g={}));const y=Object.freeze({x:0,y:0});function w(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function x(e,t){const n=(0,a.getEventCoordinates)(e);if(!n)return"0 0";return(n.x-t.left)/t.width*100+"% "+(n.y-t.top)/t.height*100+"%"}function C(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function E(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function R(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function k(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function D(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const S=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=D(t,t.left,t.top),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=w(D(r),o);i.push({id:t,data:{droppableContainer:e,value:n}})}}return i.sort(C)},O=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=R(t),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=R(r),a=o.reduce(((e,t,r)=>e+w(n[r],t)),0),l=Number((a/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:l}})}}return i.sort(C)};function M(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,l=i-n;if(r{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const e of r){const{id:r}=e,i=n.get(r);if(i){const n=M(i,t);n>0&&o.push({id:r,data:{droppableContainer:e,value:n}})}}return o.sort(E)};function I(e,t){const{top:n,left:r,bottom:o,right:i}=t;return n<=e.y&&e.y<=o&&r<=e.x&&e.x<=i}const L=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];const o=[];for(const e of t){const{id:t}=e,i=n.get(t);if(i&&I(r,i)){const n=R(i).reduce(((e,t)=>e+w(r,t)),0),a=Number((n/4).toFixed(4));o.push({id:t,data:{droppableContainer:e,value:a}})}}return o.sort(C)};function N(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:y}function T(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const A=T(1);function F(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}const P={ignoreTransform:!1};function j(e,t){void 0===t&&(t=P);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=(0,a.getWindow)(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=F(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,s=e.left-a-(1-o)*parseFloat(n),u=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),c=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:c,height:d,top:u,right:s+c,bottom:u+d,left:s}}(n,t,r))}const{top:r,left:o,width:i,height:l,bottom:s,right:u}=n;return{top:r,left:o,width:i,height:l,bottom:s,right:u}}function q(e){return j(e,{ignoreTransform:!0})}function K(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if((0,a.isDocument)(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!(0,a.isHTMLElement)(o)||(0,a.isSVGElement)(o))return n;if(n.includes(o))return n;const i=(0,a.getWindow)(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=(0,a.getWindow)(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const r=t[e];return"string"==typeof r&&n.test(r)}))}(o,i)&&n.push(o),function(e,t){return void 0===t&&(t=(0,a.getWindow)(e).getComputedStyle(e)),"fixed"===t.position}(o,i)?n:r(o.parentNode)}(e):n}function W(e){const[t]=K(e,1);return null!=t?t:null}function B(e){return a.canUseDOM&&e?(0,a.isWindow)(e)?e:(0,a.isNode)(e)?(0,a.isDocument)(e)||e===(0,a.getOwnerDocument)(e).scrollingElement?window:(0,a.isHTMLElement)(e)?e:null:null:null}function U(e){return(0,a.isWindow)(e)?e.scrollX:e.scrollLeft}function z(e){return(0,a.isWindow)(e)?e.scrollY:e.scrollTop}function V(e){return{x:U(e),y:z(e)}}var X;function H(e){return!(!a.canUseDOM||!e)&&e===document.scrollingElement}function Y(e){const t={x:0,y:0},n=H(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(X||(X={}));const $={x:.2,y:.2};function J(e,t,n,r,o){let{top:i,left:a,right:l,bottom:s}=n;void 0===r&&(r=10),void 0===o&&(o=$);const{isTop:u,isBottom:c,isLeft:d,isRight:f}=Y(e),p={x:0,y:0},v={x:0,y:0},g=t.height*o.y,h=t.width*o.x;return!u&&i<=t.top+g?(p.y=X.Backward,v.y=r*Math.abs((t.top+g-i)/g)):!c&&s>=t.bottom-g&&(p.y=X.Forward,v.y=r*Math.abs((t.bottom-g-s)/g)),!f&&l>=t.right-h?(p.x=X.Forward,v.x=r*Math.abs((t.right-h-l)/h)):!d&&a<=t.left+h&&(p.x=X.Backward,v.x=r*Math.abs((t.left+h-a)/h)),{direction:p,speed:v}}function G(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Q(e){return e.reduce(((e,t)=>(0,a.add)(e,V(t))),y)}function Z(e,t){if(void 0===t&&(t=j),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);W(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ee=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+U(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+z(t)),0)}]];class te{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=K(t),r=Q(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,o]of ee)for(const i of t)Object.defineProperty(this,i,{get:()=>{const t=o(n),a=r[e]-t;return this.rect[i]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ne{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function re(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var oe,ie;function ae(e){e.preventDefault()}function le(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(oe||(oe={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter"}(ie||(ie={}));const se={start:[ie.Space,ie.Enter],cancel:[ie.Esc],end:[ie.Space,ie.Enter]},ue=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case ie.Right:return{...n,x:n.x+25};case ie.Left:return{...n,x:n.x-25};case ie.Down:return{...n,y:n.y+25};case ie.Up:return{...n,y:n.y-25}}};class ce{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new ne((0,a.getOwnerDocument)(t)),this.windowListeners=new ne((0,a.getWindow)(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(oe.Resize,this.handleCancel),this.windowListeners.add(oe.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(oe.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Z(n),t(y)}handleKeyDown(e){if((0,a.isKeyboardEvent)(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=se,coordinateGetter:i=ue,scrollBehavior:l="smooth"}=r,{code:s}=e;if(o.end.includes(s))return void this.handleEnd(e);if(o.cancel.includes(s))return void this.handleCancel(e);const{collisionRect:u}=n.current,c=u?{x:u.left,y:u.top}:y;this.referenceCoordinates||(this.referenceCoordinates=c);const d=i(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=(0,a.subtract)(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:i,isRight:a,isLeft:s,isBottom:u,maxScroll:c,minScroll:f}=Y(n),p=G(n),v={x:Math.min(o===ie.Right?p.right-p.width/2:p.right,Math.max(o===ie.Right?p.left:p.left+p.width/2,d.x)),y:Math.min(o===ie.Down?p.bottom-p.height/2:p.bottom,Math.max(o===ie.Down?p.top:p.top+p.height/2,d.y))},g=o===ie.Right&&!a||o===ie.Left&&!s,h=o===ie.Down&&!u||o===ie.Up&&!i;if(g&&v.x!==d.x){const e=n.scrollLeft+t.x,i=o===ie.Right&&e<=c.x||o===ie.Left&&e>=f.x;if(i&&!t.y)return void n.scrollTo({left:e,behavior:l});r.x=i?n.scrollLeft-e:o===ie.Right?n.scrollLeft-c.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:l});break}if(h&&v.y!==d.y){const e=n.scrollTop+t.y,i=o===ie.Down&&e<=c.y||o===ie.Up&&e>=f.y;if(i&&!t.x)return void n.scrollTo({top:e,behavior:l});r.y=i?n.scrollTop-e:o===ie.Down?n.scrollTop-c.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:l});break}}this.handleMove(e,(0,a.add)((0,a.subtract)(d,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function de(e){return Boolean(e&&"distance"in e)}function fe(e){return Boolean(e&&"delay"in e)}ce.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=se,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const t=i.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==o||o({event:e.nativeEvent}),!0)}return!1}}];class pe{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=(0,a.getWindow)(e);return e instanceof t?e:(0,a.getOwnerDocument)(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:o}=e,{target:i}=o;this.props=e,this.events=t,this.document=(0,a.getOwnerDocument)(i),this.documentListeners=new ne(this.document),this.listeners=new ne(n),this.windowListeners=new ne((0,a.getWindow)(i)),this.initialCoordinates=null!=(r=(0,a.getEventCoordinates)(o))?r:y,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add(oe.Resize,this.handleCancel),this.windowListeners.add(oe.DragStart,ae),this.windowListeners.add(oe.VisibilityChange,this.handleCancel),this.windowListeners.add(oe.ContextMenu,ae),this.documentListeners.add(oe.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(fe(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay));if(de(t))return}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(oe.Click,le,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(oe.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:i,options:{activationConstraint:l}}=o;if(!r)return;const s=null!=(t=(0,a.getEventCoordinates)(e))?t:y,u=(0,a.subtract)(r,s);if(!n&&l){if(de(l)){if(null!=l.tolerance&&re(u,l.tolerance))return this.handleCancel();if(re(u,l.distance))return this.handleStart()}return fe(l)&&re(u,l.tolerance)?this.handleCancel():void 0}e.cancelable&&e.preventDefault(),i(s)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===ie.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const ve={move:{name:"pointermove"},end:{name:"pointerup"}};class ge extends pe{constructor(e){const{event:t}=e,n=(0,a.getOwnerDocument)(t.target);super(e,ve,n)}}ge.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const he={move:{name:"mousemove"},end:{name:"mouseup"}};var be;!function(e){e[e.RightClick=2]="RightClick"}(be||(be={}));class me extends pe{constructor(e){super(e,he,(0,a.getOwnerDocument)(e.event.target))}}me.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==be.RightClick&&(null==r||r({event:n}),!0)}}];const ye={move:{name:"touchmove"},end:{name:"touchend"}};class we extends pe{constructor(e){super(e,ye)}static setup(){return window.addEventListener(ye.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(ye.move.name,e)};function e(){}}}var xe,Ce;function Ee(e){let{acceleration:t,activator:n=xe.Pointer,canScroll:o,draggingRect:i,enabled:l,interval:s=5,order:u=Ce.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:f,delta:p,threshold:v}=e;const g=function(e){let{delta:t,disabled:n}=e;const r=(0,a.usePrevious)(t);return(0,a.useLazyMemo)((e=>{if(n||!r||!e)return Re;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[X.Backward]:e.x[X.Backward]||-1===o.x,[X.Forward]:e.x[X.Forward]||1===o.x},y:{[X.Backward]:e.y[X.Backward]||-1===o.y,[X.Forward]:e.y[X.Forward]||1===o.y}}}),[n,t,r])}({delta:p,disabled:!l}),[h,b]=(0,a.useInterval)(),m=(0,r.useRef)({x:0,y:0}),y=(0,r.useRef)({x:0,y:0}),w=(0,r.useMemo)((()=>{switch(n){case xe.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case xe.DraggableRect:return i}}),[n,i,c]),x=(0,r.useRef)(null),C=(0,r.useCallback)((()=>{const e=x.current;if(!e)return;const t=m.current.x*y.current.x,n=m.current.y*y.current.y;e.scrollBy(t,n)}),[]),E=(0,r.useMemo)((()=>u===Ce.TreeOrder?[...d].reverse():d),[u,d]);(0,r.useEffect)((()=>{if(l&&d.length&&w){for(const e of E){if(!1===(null==o?void 0:o(e)))continue;const n=d.indexOf(e),r=f[n];if(!r)continue;const{direction:i,speed:a}=J(e,r,w,t,v);for(const e of["x","y"])g[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0)return b(),x.current=e,h(C,s),m.current=a,void(y.current=i)}m.current={x:0,y:0},y.current={x:0,y:0},b()}else b()}),[t,C,o,b,l,s,JSON.stringify(w),JSON.stringify(g),h,d,E,f,JSON.stringify(v)])}we.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return!(o.length>1)&&(null==r||r({event:n}),!0)}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(xe||(xe={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(Ce||(Ce={}));const Re={x:{[X.Backward]:!1,[X.Forward]:!1},y:{[X.Backward]:!1,[X.Forward]:!1}};var ke,De;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(ke||(ke={})),function(e){e.Optimized="optimized"}(De||(De={}));const Se=new Map;function Oe(e,t){return(0,a.useLazyMemo)((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function Me(e){let{callback:t,disabled:n}=e;const o=(0,a.useEvent)(t),i=(0,r.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(o)}),[n]);return(0,r.useEffect)((()=>()=>null==i?void 0:i.disconnect()),[i]),i}function _e(e){return new te(j(e),e)}function Ie(e,t,n){void 0===t&&(t=_e);const[o,i]=(0,r.useReducer)((function(r){if(!e)return null;var o;if(!1===e.isConnected)return null!=(o=null!=r?r:n)?o:null;const i=t(e);if(JSON.stringify(r)===JSON.stringify(i))return r;return i}),null),l=function(e){let{callback:t,disabled:n}=e;const o=(0,a.useEvent)(t),i=(0,r.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(o)}),[o,n]);return(0,r.useEffect)((()=>()=>null==i?void 0:i.disconnect()),[i]),i}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){i();break}}}}),s=Me({callback:i});return(0,a.useIsomorphicLayoutEffect)((()=>{i(),e?(null==s||s.observe(e),null==l||l.observe(document.body,{childList:!0,subtree:!0})):(null==s||s.disconnect(),null==l||l.disconnect())}),[e]),o}const Le=[];function Ne(e,t){void 0===t&&(t=[]);const n=(0,r.useRef)(null);return(0,r.useEffect)((()=>{n.current=null}),t),(0,r.useEffect)((()=>{const t=e!==y;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?(0,a.subtract)(e,n.current):y}function Te(e){return(0,r.useMemo)((()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null),[e])}const Ae=[];function Fe(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return(0,a.isHTMLElement)(t)?t:e}const Pe=[{sensor:ge,options:{}},{sensor:ce,options:{}}],je={current:{}},qe={draggable:{measure:q},droppable:{measure:q,strategy:ke.WhileDragging,frequency:De.Optimized},dragOverlay:{measure:j}};class Ke extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const We={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ke,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:h},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:qe,measureDroppableContainers:h,windowRect:null,measuringScheduled:!1},Be={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:h,draggableNodes:new Map,over:null,measureDroppableContainers:h},Ue=(0,r.createContext)(Be),ze=(0,r.createContext)(We);function Ve(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ke}}}function Xe(e,t){switch(t.type){case g.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case g.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case g.DragEnd:case g.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case g.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Ke(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case g.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Ke(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case g.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Ke(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function He(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:i}=(0,r.useContext)(Ue),l=(0,a.usePrevious)(o),s=(0,a.usePrevious)(null==n?void 0:n.id);return(0,r.useEffect)((()=>{if(!t&&!o&&l&&null!=s){if(!(0,a.isKeyboardEvent)(l))return;if(document.activeElement===l.target)return;const e=i.get(s);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=(0,a.findFirstFocusableNode)(e);if(t){t.focus();break}}}))}}),[o,t,i,s,l]),null}function Ye(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...r})),n):n}const $e=(0,r.createContext)({...y,scaleX:1,scaleY:1});var Je;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(Je||(Je={}));const Ge=(0,r.memo)((function(e){var t,n,l,s;let{id:u,accessibility:d,autoScroll:f=!0,children:p,sensors:h=Pe,collisionDetection:b=_,measuring:m,modifiers:w,...x}=e;const C=(0,r.useReducer)(Xe,void 0,Ve),[E,R]=C,[D,S]=function(){const[e]=(0,r.useState)((()=>new Set)),t=(0,r.useCallback)((t=>(e.add(t),()=>e.delete(t))),[e]);return[(0,r.useCallback)((t=>{let{type:n,event:r}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)}))}),[e]),t]}(),[O,M]=(0,r.useState)(Je.Uninitialized),I=O===Je.Initialized,{draggable:{active:L,nodes:T,translate:F},droppable:{containers:P}}=E,q=L?T.get(L):null,U=(0,r.useRef)({initial:null,translated:null}),z=(0,r.useMemo)((()=>{var e;return null!=L?{id:L,data:null!=(e=null==q?void 0:q.data)?e:je,rect:U}:null}),[L,q]),X=(0,r.useRef)(null),[Y,$]=(0,r.useState)(null),[J,G]=(0,r.useState)(null),Z=(0,a.useLatestValue)(x,Object.values(x)),ee=(0,a.useUniqueId)("DndDescribedBy",u),ne=(0,r.useMemo)((()=>P.getEnabled()),[P]),re=(oe=m,(0,r.useMemo)((()=>({draggable:{...qe.draggable,...null==oe?void 0:oe.draggable},droppable:{...qe.droppable,...null==oe?void 0:oe.droppable},dragOverlay:{...qe.dragOverlay,...null==oe?void 0:oe.dragOverlay}})),[null==oe?void 0:oe.draggable,null==oe?void 0:oe.droppable,null==oe?void 0:oe.dragOverlay]));var oe;const{droppableRects:ie,measureDroppableContainers:ae,measuringScheduled:le}=function(e,t){let{dragging:n,dependencies:o,config:i}=t;const[l,s]=(0,r.useState)(null),{frequency:u,measure:c,strategy:d}=i,f=(0,r.useRef)(e),p=function(){switch(d){case ke.Always:return!1;case ke.BeforeDragging:return n;default:return!n}}(),v=(0,a.useLatestValue)(p),g=(0,r.useCallback)((function(e){void 0===e&&(e=[]),v.current||s((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[v]),h=(0,r.useRef)(null),b=(0,a.useLazyMemo)((t=>{if(p&&!n)return Se;if(!t||t===Se||f.current!==e||null!=l){const t=new Map;for(let n of e){if(!n)continue;if(l&&l.length>0&&!l.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new te(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t}),[e,l,n,p,c]);return(0,r.useEffect)((()=>{f.current=e}),[e]),(0,r.useEffect)((()=>{p||g()}),[n,p]),(0,r.useEffect)((()=>{l&&l.length>0&&s(null)}),[JSON.stringify(l)]),(0,r.useEffect)((()=>{p||"number"!=typeof u||null!==h.current||(h.current=setTimeout((()=>{g(),h.current=null}),u))}),[u,p,g,...o]),{droppableRects:b,measureDroppableContainers:g,measuringScheduled:null!=l}}(ne,{dragging:I,dependencies:[F.x,F.y],config:re.droppable}),se=function(e,t){const n=null!==t?e.get(t):void 0,r=n?n.node.current:null;return(0,a.useLazyMemo)((e=>{var n;return null===t?null:null!=(n=null!=r?r:e)?n:null}),[r,t])}(T,L),ue=(0,r.useMemo)((()=>J?(0,a.getEventCoordinates)(J):null),[J]),ce=function(){const e=!1===(null==Y?void 0:Y.autoScrollEnabled),t="object"==typeof f?!1===f.enabled:!1===f,n=I&&!e&&!t;if("object"==typeof f)return{...f,enabled:n};return{enabled:n}}(),de=function(e,t){return Oe(e,t)}(se,re.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:o,config:i=!0}=e;const l=(0,r.useRef)(!1),{x:s,y:u}="boolean"==typeof i?{x:i,y:i}:i;(0,a.useIsomorphicLayoutEffect)((()=>{if(!s&&!u||!t)return void(l.current=!1);if(l.current||!o)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=N(n(e),o);if(s||(r.x=0),u||(r.y=0),l.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=W(e);t&&t.scrollBy({top:r.y,left:r.x})}}),[t,s,u,o,n])}({activeNode:L?T.get(L):null,config:ce.layoutShiftCompensation,initialRect:de,measure:re.draggable.measure});const fe=Ie(se,re.draggable.measure,de),pe=Ie(se?se.parentElement:null),ve=(0,r.useRef)({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:ie,draggableNodes:T,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ge=P.getNodeFor(null==(t=ve.current.over)?void 0:t.id),he=function(e){let{measure:t}=e;const[n,o]=(0,r.useState)(null),i=Me({callback:(0,r.useCallback)((e=>{for(const{target:n}of e)if((0,a.isHTMLElement)(n)){o((e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r}));break}}),[t])}),l=(0,r.useCallback)((e=>{const n=Fe(e);null==i||i.disconnect(),n&&(null==i||i.observe(n)),o(n?t(n):null)}),[t,i]),[s,u]=(0,a.useNodeRef)(l);return(0,r.useMemo)((()=>({nodeRef:s,rect:n,setRef:u})),[n,s,u])}({measure:re.dragOverlay.measure}),be=null!=(n=he.nodeRef.current)?n:se,me=I?null!=(l=he.rect)?l:fe:null,ye=Boolean(he.nodeRef.current&&he.rect),we=N(xe=ye?null:fe,Oe(xe));var xe;const Ce=Te(be?(0,a.getWindow)(be):null),Re=function(e){const t=(0,r.useRef)(e),n=(0,a.useLazyMemo)((n=>e?n&&n!==Le&&e&&t.current&&e.parentNode===t.current.parentNode?n:K(e):Le),[e]);return(0,r.useEffect)((()=>{t.current=e}),[e]),n}(I?null!=ge?ge:se:null),De=function(e,t){void 0===t&&(t=j);const[n]=e,o=Te(n?(0,a.getWindow)(n):null),[i,l]=(0,r.useReducer)((function(){return e.length?e.map((e=>H(e)?o:new te(t(e),e))):Ae}),Ae),s=Me({callback:l});return e.length>0&&i===Ae&&l(),(0,a.useIsomorphicLayoutEffect)((()=>{e.length?e.forEach((e=>null==s?void 0:s.observe(e))):(null==s||s.disconnect(),l())}),[e]),i}(Re),_e=Ye(w,{transform:{x:F.x-we.x,y:F.y-we.y,scaleX:1,scaleY:1},activatorEvent:J,active:z,activeNodeRect:fe,containerNodeRect:pe,draggingNodeRect:me,over:ve.current.over,overlayNodeRect:he.rect,scrollableAncestors:Re,scrollableAncestorRects:De,windowRect:Ce}),Ke=ue?(0,a.add)(ue,F):null,We=function(e){const[t,n]=(0,r.useState)(null),o=(0,r.useRef)(e),i=(0,r.useCallback)((e=>{const t=B(e.target);t&&n((e=>e?(e.set(t,V(t)),new Map(e)):null))}),[]);return(0,r.useEffect)((()=>{const t=o.current;if(e!==t){r(t);const a=e.map((e=>{const t=B(e);return t?(t.addEventListener("scroll",i,{passive:!0}),[t,V(t)]):null})).filter((e=>null!=e));n(a.length?new Map(a):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach((e=>{const t=B(e);null==t||t.removeEventListener("scroll",i)}))}}),[i,e]),(0,r.useMemo)((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>(0,a.add)(e,t)),y):Q(e):y),[e,t])}(Re),Be=Ne(We),Ge=Ne(We,[fe]),Qe=(0,a.add)(_e,Be),Ze=me?A(me,_e):null,et=z&&Ze?b({active:z,collisionRect:Ze,droppableRects:ie,droppableContainers:ne,pointerCoordinates:Ke}):null,tt=k(et,"id"),[nt,rt]=(0,r.useState)(null),ot=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(ye?_e:(0,a.add)(_e,Ge),null!=(s=null==nt?void 0:nt.rect)?s:null,fe),it=(0,r.useCallback)(((e,t)=>{let{sensor:n,options:r}=t;if(null==X.current)return;const o=T.get(X.current);if(!o)return;const a=e.nativeEvent,l=new n({active:X.current,activeNode:o,event:a,options:r,context:ve,onStart(e){const t=X.current;if(null==t)return;const n=T.get(t);if(!n)return;const{onDragStart:r}=Z.current,o={active:{id:t,data:n.data,rect:U}};(0,i.unstable_batchedUpdates)((()=>{null==r||r(o),M(Je.Initializing),R({type:g.DragStart,initialCoordinates:e,active:t}),D({type:"onDragStart",event:o})}))},onMove(e){R({type:g.DragMove,coordinates:e})},onEnd:s(g.DragEnd),onCancel:s(g.DragCancel)});function s(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:o}=ve.current;let l=null;if(t&&o){const{cancelDrop:i}=Z.current;if(l={activatorEvent:a,active:t,collisions:n,delta:o,over:r},e===g.DragEnd&&"function"==typeof i){await Promise.resolve(i(l))&&(e=g.DragCancel)}}X.current=null,(0,i.unstable_batchedUpdates)((()=>{R({type:e}),M(Je.Uninitialized),rt(null),$(null),G(null);const t=e===g.DragEnd?"onDragEnd":"onDragCancel";if(l){const e=Z.current[t];null==e||e(l),D({type:t,event:l})}}))}}(0,i.unstable_batchedUpdates)((()=>{$(l),G(e.nativeEvent)}))}),[T]),at=(0,r.useCallback)(((e,t)=>(n,r)=>{const o=n.nativeEvent,i=T.get(r);if(null!==X.current||!i||o.dndKit||o.defaultPrevented)return;const a={active:i};!0===e(n,t.options,a)&&(o.dndKit={capturedBy:t.sensor},X.current=r,it(n,t))}),[T,it]),lt=function(e,t){return(0,r.useMemo)((()=>e.reduce(((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(h,at);!function(e){(0,r.useEffect)((()=>{if(!a.canUseDOM)return;const t=e.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const e of t)null==e||e()}}),e.map((e=>{let{sensor:t}=e;return t})))}(h),(0,a.useIsomorphicLayoutEffect)((()=>{fe&&O===Je.Initializing&&M(Je.Initialized)}),[fe,O]),(0,r.useEffect)((()=>{const{onDragMove:e}=Z.current,{active:t,activatorEvent:n,collisions:r,over:o}=ve.current;if(!t||!n)return;const a={active:t,activatorEvent:n,collisions:r,delta:{x:Qe.x,y:Qe.y},over:o};(0,i.unstable_batchedUpdates)((()=>{null==e||e(a),D({type:"onDragMove",event:a})}))}),[Qe.x,Qe.y]),(0,r.useEffect)((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:o}=ve.current;if(!e||null==X.current||!t||!o)return;const{onDragOver:a}=Z.current,l=r.get(tt),s=l&&l.rect.current?{id:l.id,rect:l.rect.current,data:l.data,disabled:l.disabled}:null,u={active:e,activatorEvent:t,collisions:n,delta:{x:o.x,y:o.y},over:s};(0,i.unstable_batchedUpdates)((()=>{rt(s),null==a||a(u),D({type:"onDragOver",event:u})}))}),[tt]),(0,a.useIsomorphicLayoutEffect)((()=>{ve.current={activatorEvent:J,active:z,activeNode:se,collisionRect:Ze,collisions:et,droppableRects:ie,draggableNodes:T,draggingNode:be,draggingNodeRect:me,droppableContainers:P,over:nt,scrollableAncestors:Re,scrollAdjustedTranslate:Qe},U.current={initial:me,translated:Ze}}),[z,se,et,Ze,T,be,me,ie,P,nt,Re,Qe]),Ee({...ce,delta:F,draggingRect:Ze,pointerCoordinates:Ke,scrollableAncestors:Re,scrollableAncestorRects:De});const st=(0,r.useMemo)((()=>({active:z,activeNode:se,activeNodeRect:fe,activatorEvent:J,collisions:et,containerNodeRect:pe,dragOverlay:he,draggableNodes:T,droppableContainers:P,droppableRects:ie,over:nt,measureDroppableContainers:ae,scrollableAncestors:Re,scrollableAncestorRects:De,measuringConfiguration:re,measuringScheduled:le,windowRect:Ce})),[z,se,fe,J,et,pe,he,T,P,ie,nt,ae,Re,De,re,le,Ce]),ut=(0,r.useMemo)((()=>({activatorEvent:J,activators:lt,active:z,activeNodeRect:fe,ariaDescribedById:{draggable:ee},dispatch:R,draggableNodes:T,over:nt,measureDroppableContainers:ae})),[J,lt,z,fe,R,ee,T,nt,ae]);return o().createElement(c.Provider,{value:S},o().createElement(Ue.Provider,{value:ut},o().createElement(ze.Provider,{value:st},o().createElement($e.Provider,{value:ot},p)),o().createElement(He,{disabled:!1===(null==d?void 0:d.restoreFocus)})),o().createElement(v,{...d,hiddenTextDescribedById:ee}))})),Qe=(0,r.createContext)(null),Ze="button",et="Droppable";function tt(e){let{id:t,data:n,disabled:o=!1,attributes:i}=e;const l=(0,a.useUniqueId)(et),{activators:s,activatorEvent:u,active:c,activeNodeRect:d,ariaDescribedById:f,draggableNodes:p,over:v}=(0,r.useContext)(Ue),{role:g=Ze,roleDescription:h="draggable",tabIndex:b=0}=null!=i?i:{},m=(null==c?void 0:c.id)===t,y=(0,r.useContext)(m?$e:Qe),[w,x]=(0,a.useNodeRef)(),[C,E]=(0,a.useNodeRef)(),R=function(e,t){return(0,r.useMemo)((()=>e.reduce(((e,n)=>{let{eventName:r,handler:o}=n;return e[r]=e=>{o(e,t)},e}),{})),[e,t])}(s,t),k=(0,a.useLatestValue)(n);(0,a.useIsomorphicLayoutEffect)((()=>(p.set(t,{id:t,key:l,node:w,activatorNode:C,data:k}),()=>{const e=p.get(t);e&&e.key===l&&p.delete(t)})),[p,t]);return{active:c,activatorEvent:u,activeNodeRect:d,attributes:(0,r.useMemo)((()=>({role:g,tabIndex:b,"aria-disabled":o,"aria-pressed":!(!m||g!==Ze)||void 0,"aria-roledescription":h,"aria-describedby":f.draggable})),[o,g,b,m,h,f.draggable]),isDragging:m,listeners:o?void 0:R,node:w,over:v,setNodeRef:x,setActivatorNodeRef:E,transform:y}}function nt(){return(0,r.useContext)(ze)}const rt="Droppable",ot={timeout:25};function it(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:i}=e;const l=(0,a.useUniqueId)(rt),{active:s,dispatch:u,over:c,measureDroppableContainers:d}=(0,r.useContext)(Ue),f=(0,r.useRef)({disabled:n}),p=(0,r.useRef)(!1),v=(0,r.useRef)(null),h=(0,r.useRef)(null),{disabled:b,updateMeasurementsFor:m,timeout:y}={...ot,...i},w=(0,a.useLatestValue)(null!=m?m:o),x=Me({callback:(0,r.useCallback)((()=>{p.current?(null!=h.current&&clearTimeout(h.current),h.current=setTimeout((()=>{d(Array.isArray(w.current)?w.current:[w.current]),h.current=null}),y)):p.current=!0}),[y]),disabled:b||!s}),C=(0,r.useCallback)(((e,t)=>{x&&(t&&(x.unobserve(t),p.current=!1),e&&x.observe(e))}),[x]),[E,R]=(0,a.useNodeRef)(C),k=(0,a.useLatestValue)(t);return(0,r.useEffect)((()=>{x&&E.current&&(x.disconnect(),p.current=!1,x.observe(E.current))}),[E,x]),(0,a.useIsomorphicLayoutEffect)((()=>(u({type:g.RegisterDroppable,element:{id:o,key:l,disabled:n,node:E,rect:v,data:k}}),()=>u({type:g.UnregisterDroppable,key:l,id:o}))),[o]),(0,r.useEffect)((()=>{n!==f.current.disabled&&(u({type:g.SetDroppableDisabled,id:o,key:l,disabled:n}),f.current.disabled=n)}),[o,l,n,u]),{active:s,rect:v,isOver:(null==c?void 0:c.id)===o,node:E,over:c,setNodeRef:R}}function at(e){let{animation:t,children:n}=e;const[i,l]=(0,r.useState)(null),[s,u]=(0,r.useState)(null),c=(0,a.usePrevious)(n);return n||i||!c||l(c),(0,a.useIsomorphicLayoutEffect)((()=>{if(!s)return;const e=null==i?void 0:i.key,n=null==i?void 0:i.props.id;null!=e&&null!=n?Promise.resolve(t(n,s)).then((()=>{l(null)})):l(null)}),[t,i,s]),o().createElement(o().Fragment,null,n,i?(0,r.cloneElement)(i,{ref:u}):null)}const lt={x:0,y:0,scaleX:1,scaleY:1};function st(e){let{children:t}=e;return o().createElement(Ue.Provider,{value:Be},o().createElement($e.Provider,{value:lt},t))}const ut={position:"fixed",touchAction:"none"},ct=e=>(0,a.isKeyboardEvent)(e)?"transform 250ms ease":void 0,dt=(0,r.forwardRef)(((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:l,className:s,rect:u,style:c,transform:d,transition:f=ct}=e;if(!u)return null;const p=i?d:{...d,scaleX:1,scaleY:1},v={...ut,width:u.width,height:u.height,top:u.top,left:u.left,transform:a.CSS.Transform.toString(p),transformOrigin:i&&r?x(r,u):void 0,transition:"function"==typeof f?f(r):f,...c};return o().createElement(n,{className:s,style:v,ref:t},l)})),ft=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:a}=e;if(null!=i&&i.active)for(const[e,t]of Object.entries(i.active))void 0!==t&&(o[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(null!=i&&i.dragOverlay)for(const[e,t]of Object.entries(i.dragOverlay))void 0!==t&&r.node.style.setProperty(e,t);return null!=a&&a.active&&n.node.classList.add(a.active),null!=a&&a.dragOverlay&&r.node.classList.add(a.dragOverlay),function(){for(const[e,t]of Object.entries(o))n.node.style.setProperty(e,t);null!=a&&a.active&&n.node.classList.remove(a.active)}},pt={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:a.CSS.Transform.toString(t)},{transform:a.CSS.Transform.toString(n)}]},sideEffects:ft({styles:{active:{opacity:"0"}}})};function vt(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return(0,a.useEvent)(((e,i)=>{if(null===t)return;const l=n.get(e);if(!l)return;const s=l.node.current;if(!s)return;const u=Fe(i);if(!u)return;const{transform:c}=(0,a.getWindow)(i).getComputedStyle(i),d=F(c);if(!d)return;const f="function"==typeof t?t:function(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...pt,...e};return e=>{let{active:i,dragOverlay:a,transform:l,...s}=e;if(!t)return;const u={x:a.rect.left-i.rect.left,y:a.rect.top-i.rect.top},c={scaleX:1!==l.scaleX?i.rect.width*l.scaleX/a.rect.width:1,scaleY:1!==l.scaleY?i.rect.height*l.scaleY/a.rect.height:1},d={x:l.x-u.x,y:l.y-u.y,...c},f=o({...s,active:i,dragOverlay:a,transform:{initial:l,final:d}}),[p]=f,v=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(v))return;const g=null==r?void 0:r({active:i,dragOverlay:a,...s}),h=a.node.animate(f,{duration:t,easing:n,fill:"forwards"});return new Promise((e=>{h.onfinish=()=>{null==g||g(),e()}}))}}(t);return Z(s,o.draggable.measure),f({active:{id:e,data:l.data,node:s,rect:o.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:i,rect:o.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:o,transform:d})}))}let gt=0;function ht(e){return(0,r.useMemo)((()=>{if(null!=e)return gt++,gt}),[e])}const bt=o().memo((e=>{let{adjustScale:t=!1,children:n,dropAnimation:i,style:a,transition:l,modifiers:s,wrapperElement:u="div",className:c,zIndex:d=999}=e;const{activatorEvent:f,active:p,activeNodeRect:v,containerNodeRect:g,draggableNodes:h,droppableContainers:b,dragOverlay:m,over:y,measuringConfiguration:w,scrollableAncestors:x,scrollableAncestorRects:C,windowRect:E}=nt(),R=(0,r.useContext)($e),k=ht(null==p?void 0:p.id),D=Ye(s,{activatorEvent:f,active:p,activeNodeRect:v,containerNodeRect:g,draggingNodeRect:m.rect,over:y,overlayNodeRect:m.rect,scrollableAncestors:x,scrollableAncestorRects:C,transform:R,windowRect:E}),S=Oe(v),O=vt({config:i,draggableNodes:h,droppableContainers:b,measuringConfiguration:w}),M=S?m.setRef:void 0;return o().createElement(st,null,o().createElement(at,{animation:O},p&&k?o().createElement(dt,{key:k,id:p.id,ref:M,as:u,activatorEvent:f,adjustScale:t,className:c,transition:l,rect:S,style:{zIndex:d,...a},transform:D},n):null))}))},339:function(e,t,n){n.r(t),n.d(t,{createSnapModifier:function(){return o},restrictToFirstScrollableAncestor:function(){return s},restrictToHorizontalAxis:function(){return i},restrictToParentElement:function(){return l},restrictToVerticalAxis:function(){return u},restrictToWindowEdges:function(){return c},snapCenterToCursor:function(){return d}});var r=n(285);function o(e){return t=>{let{transform:n}=t;return{...n,x:Math.ceil(n.x/e)*e,y:Math.ceil(n.y/e)*e}}}const i=e=>{let{transform:t}=e;return{...t,y:0}};function a(e,t,n){const r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}const l=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:r}=e;return n&&t?a(r,n,t):r},s=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e;const o=r[0];return t&&o?a(n,t,o):n},u=e=>{let{transform:t}=e;return{...t,x:0}},c=e=>{let{transform:t,draggingNodeRect:n,windowRect:r}=e;return n&&r?a(t,n,r):t},d=e=>{let{activatorEvent:t,draggingNodeRect:n,transform:o}=e;if(n&&t){const e=(0,r.getEventCoordinates)(t);if(!e)return o;const i=e.x-n.left,a=e.y-n.top;return{...o,x:o.x+i-n.width/2,y:o.y+a-n.height/2}}return o}},587:function(e,t,n){n.r(t),n.d(t,{SortableContext:function(){return y},arrayMove:function(){return l},arraySwap:function(){return s},defaultAnimateLayoutChanges:function(){return x},defaultNewIndexGetter:function(){return w},hasSortableData:function(){return S},horizontalListSortingStrategy:function(){return f},rectSortingStrategy:function(){return p},rectSwappingStrategy:function(){return v},sortableKeyboardCoordinates:function(){return M},useSortable:function(){return D},verticalListSortingStrategy:function(){return h}});var r=n(363),o=n.n(r),i=n(33),a=n(285);function l(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function s(e,t,n){const r=e.slice();return r[t]=e[n],r[n]=e[t],r}function u(e,t){return e.reduce(((e,n,r)=>{const o=t.get(n);return o&&(e[r]=o),e}),Array(e.length))}function c(e){return null!==e&&e>=0}const d={scaleX:1,scaleY:1},f=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:a}=e;const l=null!=(t=n[o])?t:r;if(!l)return null;const s=function(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];if(!r||!o&&!i)return 0;if(no&&a<=i?{x:-l.width-s,y:0,...d}:a=i?{x:l.width+s,y:0,...d}:{x:0,y:0,...d}};const p=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=l(t,r,n),a=t[o],s=i[o];return s&&a?{x:s.left-a.left,y:s.top-a.top,scaleX:s.width/a.width,scaleY:s.height/a.height}:null},v=e=>{let t,n,{activeIndex:r,index:o,rects:i,overIndex:a}=e;return o===r&&(t=i[o],n=i[a]),o===a&&(t=i[o],n=i[r]),n&&t?{x:n.left-t.left,y:n.top-t.top,scaleX:n.width/t.width,scaleY:n.height/t.height}:null},g={scaleX:1,scaleY:1},h=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const l=null!=(t=i[n])?t:r;if(!l)return null;if(o===n){const e=i[a];return e?{x:0,y:nn&&o<=a?{x:0,y:-l.height-s,...g}:o=a?{x:0,y:l.height+s,...g}:{x:0,y:0,...g}};const b="Sortable",m=o().createContext({activeIndex:-1,containerId:b,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:p,disabled:{draggable:!1,droppable:!1}});function y(e){let{children:t,id:n,items:l,strategy:s=p,disabled:c=!1}=e;const{active:d,dragOverlay:f,droppableRects:v,over:g,measureDroppableContainers:h}=(0,i.useDndContext)(),y=(0,a.useUniqueId)(b,n),w=Boolean(null!==f.rect),x=(0,r.useMemo)((()=>l.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[l]),C=null!=d,E=d?x.indexOf(d.id):-1,R=g?x.indexOf(g.id):-1,k=(0,r.useRef)(x),D=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n{D&&C&&h(x)}),[D,x,C,h]),(0,r.useEffect)((()=>{k.current=x}),[x]);const M=(0,r.useMemo)((()=>({activeIndex:E,containerId:y,disabled:O,disableTransforms:S,items:x,overIndex:R,useDragOverlay:w,sortedRects:u(x,v),strategy:s})),[E,y,O.draggable,O.droppable,S,x,R,v,w,s]);return o().createElement(m.Provider,{value:M},t)}const w=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return l(n,r,o).indexOf(t)},x=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:s,transition:u}=e;return!(!u||!r)&&((l===i||o!==a)&&(!!n||a!==o&&t===s))},C={duration:200,easing:"ease"},E="transform",R=a.CSS.Transition.toString({property:E,duration:0,easing:"linear"}),k={roleDescription:"sortable"};function D(e){let{animateLayoutChanges:t=x,attributes:n,disabled:o,data:l,getNewIndex:s=w,id:u,strategy:d,resizeObserverConfig:f,transition:p=C}=e;const{items:v,containerId:g,activeIndex:h,disabled:b,disableTransforms:y,sortedRects:D,overIndex:S,useDragOverlay:O,strategy:M}=(0,r.useContext)(m),_=function(e,t){var n,r;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(o,b),I=v.indexOf(u),L=(0,r.useMemo)((()=>({sortable:{containerId:g,index:I,items:v},...l})),[g,l,I,v]),N=(0,r.useMemo)((()=>v.slice(v.indexOf(u))),[v,u]),{rect:T,node:A,isOver:F,setNodeRef:P}=(0,i.useDroppable)({id:u,data:L,disabled:_.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...f}}),{active:j,activatorEvent:q,activeNodeRect:K,attributes:W,setNodeRef:B,listeners:U,isDragging:z,over:V,setActivatorNodeRef:X,transform:H}=(0,i.useDraggable)({id:u,data:L,attributes:{...k,...n},disabled:_.draggable}),Y=(0,a.useCombinedRefs)(P,B),$=Boolean(j),J=$&&!y&&c(h)&&c(S),G=!O&&z,Q=G&&J?H:null,Z=J?null!=Q?Q:(null!=d?d:M)({rects:D,activeNodeRect:K,activeIndex:h,overIndex:S,index:I}):null,ee=c(h)&&c(S)?s({id:u,items:v,activeIndex:h,overIndex:S}):I,te=null==j?void 0:j.id,ne=(0,r.useRef)({activeId:te,items:v,newIndex:ee,containerId:g}),re=v!==ne.current.items,oe=t({active:j,containerId:g,isDragging:z,isSorting:$,id:u,index:I,items:v,newIndex:ne.current.newIndex,previousItems:ne.current.items,previousContainerId:ne.current.containerId,transition:p,wasDragging:null!=ne.current.activeId}),ie=function(e){let{disabled:t,index:n,node:o,rect:l}=e;const[s,u]=(0,r.useState)(null),c=(0,r.useRef)(n);return(0,a.useIsomorphicLayoutEffect)((()=>{if(!t&&n!==c.current&&o.current){const e=l.current;if(e){const t=(0,i.getClientRect)(o.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&u(n)}}n!==c.current&&(c.current=n)}),[t,n,o,l]),(0,r.useEffect)((()=>{s&&u(null)}),[s]),s}({disabled:!oe,index:I,node:A,rect:T});return(0,r.useEffect)((()=>{$&&ne.current.newIndex!==ee&&(ne.current.newIndex=ee),g!==ne.current.containerId&&(ne.current.containerId=g),v!==ne.current.items&&(ne.current.items=v)}),[$,ee,g,v]),(0,r.useEffect)((()=>{if(te===ne.current.activeId)return;if(te&&!ne.current.activeId)return void(ne.current.activeId=te);const e=setTimeout((()=>{ne.current.activeId=te}),50);return()=>clearTimeout(e)}),[te]),{active:j,activeIndex:h,attributes:W,data:L,rect:T,index:I,newIndex:ee,items:v,isOver:F,isSorting:$,isDragging:z,listeners:U,node:A,overIndex:S,over:V,setNodeRef:Y,setActivatorNodeRef:X,setDroppableNodeRef:P,setDraggableNodeRef:B,transform:null!=ie?ie:Z,transition:function(){if(ie||re&&ne.current.newIndex===I)return R;if(G&&!(0,a.isKeyboardEvent)(q)||!p)return;if($||oe)return a.CSS.Transition.toString({...p,property:E});return}()}}function S(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const O=[i.KeyboardCode.Down,i.KeyboardCode.Right,i.KeyboardCode.Up,i.KeyboardCode.Left],M=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:l,over:s,scrollableAncestors:u}}=t;if(O.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];l.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const a=o.get(n.id);if(a)switch(e.code){case i.KeyboardCode.Down:r.topa.top&&t.push(n);break;case i.KeyboardCode.Left:r.left>a.left&&t.push(n);break;case i.KeyboardCode.Right:r.left1&&(d=c[1].id),null!=d){const e=l.get(n.id),t=l.get(d),s=t?o.get(t.id):null,c=null==t?void 0:t.node.current;if(c&&s&&e&&t){const n=(0,i.getScrollableAncestors)(c).some(((e,t)=>u[t]!==e)),o=_(e,t),l=function(e,t){if(!S(e)||!S(t))return!1;if(!_(e,t))return!1;return e.data.current.sortable.indexe=>{t.forEach((t=>t(e)))}),t)}const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function a(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function l(e){return"nodeType"in e}function s(e){var t,n;return e?a(e)?e:l(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function u(e){const{Document:t}=s(e);return e instanceof t}function c(e){return!a(e)&&e instanceof s(e).HTMLElement}function d(e){return e instanceof s(e).SVGElement}function f(e){return e?a(e)?e.document:l(e)?u(e)?e:c(e)||d(e)?e.ownerDocument:document:document:document}const p=i?r.useLayoutEffect:r.useEffect;function v(e){const t=(0,r.useRef)(e);return p((()=>{t.current=e})),(0,r.useCallback)((function(){for(var e=arguments.length,n=new Array(e),r=0;r{e.current=setInterval(t,n)}),[]),(0,r.useCallback)((()=>{null!==e.current&&(clearInterval(e.current),e.current=null)}),[])]}function h(e,t){void 0===t&&(t=[e]);const n=(0,r.useRef)(e);return p((()=>{n.current!==e&&(n.current=e)}),t),n}function b(e,t){const n=(0,r.useRef)();return(0,r.useMemo)((()=>{const t=e(n.current);return n.current=t,t}),[...t])}function m(e){const t=v(e),n=(0,r.useRef)(null),o=(0,r.useCallback)((e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e}),[]);return[n,o]}function y(e){const t=(0,r.useRef)();return(0,r.useEffect)((()=>{t.current=e}),[e]),t.current}let w={};function x(e,t){return(0,r.useMemo)((()=>{if(t)return t;const n=null==w[e]?0:w[e]+1;return w[e]=n,e+"-"+n}),[e,t])}function C(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o{const r=Object.entries(n);for(const[n,o]of r){const r=t[n];null!=r&&(t[n]=r+e*o)}return t}),{...t})}}const E=C(1),R=C(-1);function k(e){return"clientX"in e&&"clientY"in e}function D(e){if(!e)return!1;const{KeyboardEvent:t}=s(e.target);return t&&e instanceof t}function S(e){if(!e)return!1;const{TouchEvent:t}=s(e.target);return t&&e instanceof t}function O(e){if(S(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return k(e)?{x:e.clientX,y:e.clientY}:null}const M=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[M.Translate.toString(e),M.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),_="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function I(e){return e.matches(_)?e:e.querySelector(_)}},274:function(e,t,n){var r,o=(r=n(521))&&r.__esModule?r:{default:r};document.addEventListener("DOMContentLoaded",(()=>{(0,o.default)()}))},521:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=s(n(648)),o=s(n(809)),i=s(n(852)),a=s(n(117)),l=s(n(606));function s(e){return e&&e.__esModule?e:{default:e}}var u=()=>{r.default.component.registerMany({LinkPicker:o.default,LinkField:i.default,"LinkModal.FormBuilderModal":a.default,"LinkModal.InsertMediaModal":l.default})};t.default=u},852:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.LinkFieldContext=t.Component=void 0;var r=k(n(363)),o=n(827),i=n(624),a=n(33),l=n(587),s=n(339),u=(n(648),E(n(42))),c=E(n(809)),d=E(n(734)),f=E(n(264)),p=E(n(697)),v=k(n(123)),g=E(n(159)),h=E(n(510)),b=n(845),m=E(n(86)),y=E(n(754)),w=E(n(872)),x=E(n(902)),C=E(n(820));function E(e){return e&&e.__esModule?e:{default:e}}function R(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(R=function(e){return e?n:t})(e)}function k(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=R(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}const D=(0,r.createContext)(null);t.LinkFieldContext=D;const S="SilverStripe\\LinkField\\Controllers\\LinkFieldController",O=e=>{var t;let{value:n=null,onChange:o,onNonPublishedVersionedState:i,types:u={},actions:v,isMulti:m=!1,canCreate:E,readonly:R,disabled:k,ownerID:O,ownerClass:M,ownerRelation:_}=e;const[I,L]=(0,r.useState)({}),[N,T]=(0,r.useState)(0),[A,F]=(0,r.useState)(!1),[P,j]=(0,r.useState)(0),[q,K]=(0,r.useState)(!1),[W,B]=(0,r.useState)((0,C.default)({"link-picker-links":!0})),U=(0,a.useSensors)((0,a.useSensor)(a.PointerSensor,{activationConstraint:{distance:10}}));let z=n;Array.isArray(z)||("number"==typeof z&&0!=z&&(z=[z]),z||(z=[])),(0,r.useEffect)((()=>{if(!N&&z.length>0){F(!0);const e=[];for(const t of z)e.push(`itemIDs[]=${t}`);const t=`${h.default.getSection(S).form.linkForm.dataUrl}?${e.join("&")}`;g.default.get(t).then((e=>e.json())).then((e=>{L(e),F(!1),K(!1)})).catch((()=>{v.toasts.error(y.default._t("LinkField.FAILED_TO_LOAD_LINKS","Failed to load links")),F(!1),K(!1)}))}}),[N,n&&n.length,P]);const V=()=>{T(0)},X=e=>{T(0);const t=[...z];t.includes(e)||t.push(e),o(m?t:t[0]),v.toasts.success(y.default._t("LinkField.SAVE_SUCCESS","Saved link"))},H=(e,t)=>{var n;const r=(null===(n=I[e])||void 0===n?void 0:n.versionState)||"",i=["draft","modified","published"].includes(r),a=i?y.default._t("LinkField.ARCHIVE_CONFIRM","Are you sure you want to archive this link?"):y.default._t("LinkField.DELETE_CONFIRM","Are you sure you want to delete this link?");if(!window.confirm(a))return!1;let l=(0,b.joinUrlPaths)(h.default.getSection(S).form.linkForm.deleteUrl,e.toString());const s=w.default.parse(l),u=x.default.parse(s.query);u.ownerID=O,u.ownerClass=M,u.ownerRelation=_,l=w.default.format({...s,search:x.default.stringify(u)});const c=i?y.default._t("LinkField.ARCHIVE_SUCCESS","Archived link"):y.default._t("LinkField.DELETE_SUCCESS","Deleted link"),d=i?y.default._t("LinkField.ARCHIVE_ERROR","Failed to archive link"):y.default._t("LinkField.DELETE_ERROR","Failed to delete link");g.default.delete(l,{},{"X-SecurityID":h.default.get("SecurityID")}).then((()=>v.toasts.success(c))).catch((()=>v.toasts.error(d)));const f={...I};delete f[e],L(f),o(m?Object.keys(f):0)},Y=()=>{const e=[".cms-edit-form button[data-text-alternate]#Form_EditForm_action_publish",".cms-edit-form button[data-text-alternate]#Form_ItemEditForm_action_doPublish"].join(","),t=document.querySelector(e);if(!t)return;(t.getAttribute("data-btn-alternate-remove")||"").split(" ").forEach((e=>{e&&t.classList.remove(e)}));(t.getAttribute("data-btn-alternate-add")||"").split(" ").forEach((e=>{e&&t.classList.add(e)}));const n=t.getAttribute("data-text-alternate");n&&(t.innerHTML=n)},$=e=>{B((0,C.default)({"link-picker__links":!0,"link-picker__links--dragging":!0})),K(!0)},J=e=>{const{active:t,over:n}=e;if(B((0,C.default)({"link-picker__links":!0,"link-picker__links--dragging":!1})),t.id===n.id)return void K(!1);const r=z.indexOf(t.id),i=z.indexOf(n.id),a=(0,l.arrayMove)(z,r,i);o(a);let s=`${h.default.getSection(S).form.linkForm.sortUrl}`;g.default.post(s,{newLinkIDs:a},{"X-SecurityID":h.default.get("SecurityID")}).then((async()=>{o(a),v.toasts.success(y.default._t("LinkField.SORT_SUCCESS","Updated link sort order")),j(P+1)})).catch((()=>{v.toasts.error(y.default._t("LinkField.SORT_ERROR","Failed to sort links"))}))},G=0===O,Q=!G&&(m||0===Object.keys(I).length),Z=!G&&Boolean(N),ee=y.default._t("LinkField.SAVE_RECORD_FIRST","Cannot add links until the record has been saved"),te=(()=>{const e=[];for(let s=0;s{T(c)},onUnpublishedVersionedState:Y,canDelete:!(null===(l=I[c])||void 0===l||!l.canDelete),isMulti:m,isFirst:0===s,isLast:s===z.length-1,isSorting:q,canCreate:E,readonly:R,disabled:k}))}return e})();return r.default.createElement(D.Provider,{value:{ownerID:O,ownerClass:M,ownerRelation:_,actions:v,loading:A}},r.default.createElement("div",{className:"link-field__container"},G&&r.default.createElement("div",{className:"link-field__save-record-first"},ee),A&&!q&&!G&&r.default.createElement(f.default,{containerClass:"link-field__loading"}),Q&&r.default.createElement(c.default,{onModalSuccess:X,onModalClosed:V,types:u,canCreate:E,readonly:R,disabled:k}),!m||R||k?r.default.createElement("div",null,te):r.default.createElement("div",{className:W},r.default.createElement(a.DndContext,{modifiers:[s.restrictToVerticalAxis,s.restrictToParentElement],sensors:U,collisionDetection:a.closestCenter,onDragStart:$,onDragEnd:J},r.default.createElement(l.SortableContext,{items:z,strategy:l.verticalListSortingStrategy},te))),Z&&r.default.createElement(p.default,{types:u,typeKey:null===(t=I[N])||void 0===t?void 0:t.typeKey,isOpen:Boolean(N),onSuccess:X,onClosed:V,linkID:N})))};t.Component=O,O.propTypes={value:m.default.oneOfType([m.default.arrayOf(m.default.number),m.default.number]),onChange:m.default.func.isRequired,types:m.default.object.isRequired,actions:m.default.object.isRequired,isMulti:m.default.bool,canCreate:m.default.bool.isRequired,readonly:m.default.bool.isRequired,disabled:m.default.bool.isRequired,ownerID:m.default.number.isRequired,ownerClass:m.default.string.isRequired,ownerRelation:m.default.string.isRequired};var M=(0,o.compose)(u.default,(0,i.connect)(null,(e=>({actions:{toasts:(0,o.bindActionCreators)(v,e)}}))))(O);t.default=M},606:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;u(n(754));var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=s(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}r.default=e,n&&n.set(e,r);return r}(n(363)),o=u(n(475)),i=n(624),a=u(n(686)),l=u(n(86));function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(s=function(e){return e?n:t})(e)}function u(e){return e&&e.__esModule?e:{default:e}}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{type:t,editing:n,data:i,actions:a,onSubmit:l,...s}=e;if(!t)return!1;(0,r.useEffect)((()=>{n?a.initModal():a.reset()}),[n]);const u=i?{ID:i.FileID,Description:i.Title,TargetBlank:!!i.OpenInNew}:{};return r.default.createElement(o.default,c({isOpen:n,type:"insert-link",title:!1,bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--internal",fileAttributes:u,onInsert:e=>{let{ID:n,Description:r,TargetBlank:o}=e;return l({FileID:n,Title:r,OpenInNew:o,typeKey:t.key},"",(()=>{}))}},s))};d.propTypes={type:a.default.isRequired,editing:l.default.bool.isRequired,data:l.default.object.isRequired,actions:l.default.object.isRequired,onClick:l.default.func.isRequired};var f=(0,i.connect)((function(){return{}}),(function(e){return{actions:{initModal:()=>e({type:"INIT_FORM_SCHEMA_STACK",payload:{formSchema:{type:"insert-link",nextType:"admin"}}}),reset:()=>e({type:"RESET"})}}}))(d);t.default=f},117:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=f(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}r.default=e,n&&n.set(e,r);return r}(n(363)),o=d(n(912)),i=n(852),a=d(n(872)),l=d(n(902)),s=d(n(510)),u=n(845),c=d(n(86));function d(e){return e&&e.__esModule?e:{default:e}}function f(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(f=function(e){return e?n:t})(e)}const p=(e,t)=>{const{schemaUrl:n}=s.default.getSection("SilverStripe\\LinkField\\Controllers\\LinkFieldController").form.linkForm,o=a.default.parse(n),c=l.default.parse(o.query);c.typeKey=e;const{ownerID:d,ownerClass:f,ownerRelation:p}=(0,r.useContext)(i.LinkFieldContext);c.ownerID=d,c.ownerClass=f,c.ownerRelation=p;for(const e of["href","path","pathname"])o[e]=(0,u.joinUrlPaths)(o[e],t.toString());return a.default.format({...o,search:l.default.stringify(c)})},v=e=>{let{typeTitle:t,typeKey:n,linkID:a=0,isOpen:l,onSuccess:s,onClosed:u}=e;const{actions:c}=(0,r.useContext)(i.LinkFieldContext);if(!n)return!1;return r.default.createElement(o.default,{title:t,isOpen:l,schemaUrl:p(n,a),identifier:"Link.EditingLinkInfo",onSubmit:async(e,t,n)=>{let r=null;if(document.getElementById("Form_fileSelectForm_action_insert")||document.getElementById("Form_fileEditForm_Actions_Holder"))return Promise.resolve();try{r=await n()}catch(e){return c.toasts.error(i18n._t("LinkField.FAILED_TO_SAVE_LINK","Failed to save link")),Promise.resolve()}if(!r.id.match(/\/schema\/linkfield\/([0-9]+)/)){const e=r.id.match(/\/linkForm\/([0-9]+)/),t=parseInt(e[1],10);s(t)}return Promise.resolve()},onClosed:u})};v.propTypes={typeTitle:c.default.string.isRequired,typeKey:c.default.string.isRequired,linkID:c.default.number,isOpen:c.default.bool.isRequired,onSuccess:c.default.func.isRequired,onClosed:c.default.func.isRequired};var g=v;t.default=g},809:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.Component=void 0;var r=c(n(754)),o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=u(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}r.default=e,n&&n.set(e,r);return r}(n(363)),i=c(n(86)),a=c(n(820)),l=c(n(97)),s=c(n(697));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(u=function(e){return e?n:t})(e)}function c(e){return e&&e.__esModule?e:{default:e}}const d=e=>{let{types:t,onModalSuccess:n,onModalClosed:i,canCreate:u,readonly:c,disabled:d}=e;const[f,p]=(0,o.useState)(""),v=""!==f,g=(0,a.default)("link-picker","form-control"),h=Object.values(t),b=h.filter((e=>e.allowed)),m=r.default._t("LinkField.CANNOT_CREATE_LINK","Cannot create link");return!u||0===b.length||c||d?o.default.createElement("div",{className:g},o.default.createElement("div",{className:"link-picker__cannot-create"},m)):o.default.createElement("div",{className:g},o.default.createElement(l.default,{types:h,onSelect:e=>{p(e)}}),v&&o.default.createElement(s.default,{types:t,typeKey:f,isOpen:v,onSuccess:e=>{p(""),n(e)},onClosed:()=>{"function"==typeof i&&i(),p("")}}))};t.Component=d,d.propTypes={types:i.default.object.isRequired,onModalSuccess:i.default.func.isRequired,onModalClosed:i.default.func,canCreate:i.default.bool.isRequired,readonly:i.default.bool.isRequired,disabled:i.default.bool.isRequired};var f=d;t.default=f},97:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=c(n(754)),o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=u(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}r.default=e,n&&n.set(e,r);return r}(n(363)),i=c(n(86)),a=n(127),l=n(852),s=c(n(686));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(u=function(e){return e?n:t})(e)}function c(e){return e&&e.__esModule?e:{default:e}}const d=e=>{let{types:t,onSelect:n}=e;const[i,s]=(0,o.useState)(!1),{loading:u}=(0,o.useContext)(l.LinkFieldContext);return o.default.createElement(a.Dropdown,{disabled:u,isOpen:i,toggle:()=>s((e=>!e)),className:"link-picker__menu"},o.default.createElement(a.DropdownToggle,{className:"link-picker__menu-toggle font-icon-plus-1",caret:!0,color:"secondary"},r.default._t("LinkField.ADD_LINK","Add Link")),o.default.createElement(a.DropdownMenu,null,t.map((e=>{let{key:t,title:r,icon:i,allowed:l}=e;return l&&o.default.createElement(a.DropdownItem,{key:t,onClick:()=>n(t)},o.default.createElement("span",{className:`link-picker__menu-icon ${i}`}),r)}))))};d.propTypes={types:i.default.arrayOf(s.default).isRequired,onSelect:i.default.func.isRequired};var f=d;t.default=f},734:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=f(n(820)),o=f(n(754)),i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=d(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}r.default=e,n&&n.set(e,r);return r}(n(363)),a=f(n(86)),l=n(852),s=n(127),u=n(587),c=n(285);function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(d=function(e){return e?n:t})(e)}function f(e){return e&&e.__esModule?e:{default:e}}function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;tt=>{t.nativeEvent.stopImmediatePropagation(),t.preventDefault(),t.nativeEvent.preventDefault(),t.stopPropagation(),e&&e()},g=e=>{let{id:t,title:n,description:a,versionState:d,typeTitle:f,typeIcon:g,onDelete:h,onClick:b,onUnpublishedVersionedState:m,canDelete:y,isMulti:w,isFirst:x,isLast:C,isSorting:E,canCreate:R,readonly:k,disabled:D}=e;const{loading:S}=(0,i.useContext)(l.LinkFieldContext),{attributes:O,listeners:M,setNodeRef:_,transform:I,transition:L}=(0,u.useSortable)({id:t}),N={transform:c.CSS.Transform.toString(I),transition:L},T={"link-picker__link":!0,"link-picker__link--is-first":x,"link-picker__link--is-last":C,"link-picker__link--is-sorting":E,"form-control":!0,"link-picker__link--readonly":k||!R,"link-picker__link--disabled":D};d&&(T[`link-picker__link--${d}`]=!0);const A=(0,r.default)(T),F=["unversioned","unsaved"].includes(d)?o.default._t("LinkField.DELETE","Delete"):o.default._t("LinkField.ARCHIVE","Archive");return["draft","modified"].includes(d)&&m(),i.default.createElement("div",p({className:A,ref:_,style:N},O,M),w&&!k&&!D&&i.default.createElement("div",{className:"link-picker__drag-handle"},i.default.createElement("i",{className:"font-icon-drag-handle"})),i.default.createElement(s.Button,{disabled:S,className:`link-picker__button ${g}`,color:"secondary",onClick:v(b)},i.default.createElement("div",{className:"link-picker__link-detail"},i.default.createElement("div",{className:"link-picker__title"},i.default.createElement("span",{className:"link-picker__title-text"},n),(e=>{let t="",n="";if("draft"===e)t=o.default._t("LinkField.LINK_DRAFT_TITLE","Link has draft changes"),n=o.default._t("LinkField.LINK_DRAFT_LABEL","Draft");else{if("modified"!==e)return null;t=o.default._t("LinkField.LINK_MODIFIED_TITLE","Link has unpublished changes"),n=o.default._t("LinkField.LINK_MODIFIED_LABEL","Modified")}const a=(0,r.default)("badge",`status-${e}`);return i.default.createElement("span",{className:a,title:t},n)})(d)),i.default.createElement("small",{className:"link-picker__type"},f,": ",i.default.createElement("span",{className:"link-picker__url"},a))),y&&!k&&i.default.createElement("span",{role:"button",tabIndex:"0",className:"link-picker__delete btn btn-link",onKeyDown:e=>{"Enter"!==e.code&&"Space"!==e.code||S||(e.nativeEvent.stopImmediatePropagation(),e.stopPropagation(),h(t),e.nativeEvent.preventDefault(),e.preventDefault())},onClick:v((()=>S?null:h(t)))},F)))};g.propTypes={id:a.default.number.isRequired,title:a.default.string,description:a.default.string,versionState:a.default.string,typeTitle:a.default.string.isRequired,typeIcon:a.default.string.isRequired,onDelete:a.default.func.isRequired,onClick:a.default.func.isRequired,onUnpublishedVersionedState:a.default.func.isRequired,canDelete:a.default.bool.isRequired,isMulti:a.default.bool.isRequired,isFirst:a.default.bool.isRequired,isLast:a.default.bool.isRequired,isSorting:a.default.bool.isRequired,canCreate:a.default.bool.isRequired,readonly:a.default.bool.isRequired,disabled:a.default.bool.isRequired};var h=g;t.default=h},697:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=a(n(363)),o=n(648),i=a(n(86));function a(e){return e&&e.__esModule?e:{default:e}}const l=e=>{let{types:t,typeKey:n,linkID:i=0,isOpen:a,onSuccess:l,onClosed:s}=e;if(!n)return!1;const u=t.hasOwnProperty(n)?t[n]:{},c=u&&u.hasOwnProperty("handlerName")?u.handlerName:"FormBuilderModal",d=(0,o.loadComponent)(`LinkModal.${c}`);return r.default.createElement(d,{typeTitle:u.title||"",typeKey:n,linkID:i,isOpen:a,onSuccess:l,onClosed:s})};l.propTypes={types:i.default.object.isRequired,typeKey:i.default.string.isRequired,linkID:i.default.number,isOpen:i.default.bool.isRequired,onSuccess:i.default.func.isRequired,onClosed:i.default.func.isRequired};var s=l;t.default=s},41:function(e,t,n){var r=l(n(311)),o=l(n(363)),i=l(n(691)),a=n(648);function l(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t{e(".js-injector-boot .entwine-linkfield").entwine({Component:null,Root:null,onmatch(){const e=this.closest(".cms-content").attr("id"),t=e?{context:e}:{},n=this.data("schema-component"),r=(0,a.loadComponent)(n,t);this.setComponent(r),this.setRoot(i.default.createRoot(this[0])),this._super(),this.refresh()},refresh(){const e=this.getProps();this.getInputField().val(e.value);const t=this.getComponent();this.getRoot().render(o.default.createElement(t,s({},e,{noHolder:!0})))},handleChange(e){this.getInputField().data("value",e),this.refresh()},getProps(){const e=this.getInputField();return{value:e.data("value"),ownerID:e.data("owner-id"),ownerClass:e.data("owner-class"),ownerRelation:e.data("owner-relation"),onChange:this.handleChange.bind(this),isMulti:this.data("is-multi")??!1,types:this.data("types")??{},canCreate:!!e.data("can-create"),readonly:!!e.data("readonly"),disabled:!!e.data("disabled")}},getInputField(){const t=this.data("field-id");return e(`#${t}`)},onunmatch(){const e=this.getRoot();e&&e.unmount()}})}))},686:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(86))&&r.__esModule?r:{default:r};var i=o.default.shape({key:o.default.string.isRequired,title:o.default.string.isRequired,icon:o.default.string.isRequired});t.default=i},159:function(e){e.exports=Backend},510:function(e){e.exports=Config},42:function(e){e.exports=FieldHolder},912:function(e){e.exports=FormBuilderModal},648:function(e){e.exports=Injector},475:function(e){e.exports=InsertMediaModal},264:function(e){e.exports=Loading},872:function(e){e.exports=NodeUrl},86:function(e){e.exports=PropTypes},363:function(e){e.exports=React},691:function(e){e.exports=ReactDomClient},624:function(e){e.exports=ReactRedux},127:function(e){e.exports=Reactstrap},827:function(e){e.exports=Redux},123:function(e){e.exports=ToastsActions},820:function(e){e.exports=classnames},754:function(e){e.exports=i18n},311:function(e){e.exports=jQuery},902:function(e){e.exports=qs},845:function(e){e.exports=ssUrlLib}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(274),n(41)}(); \ No newline at end of file +/******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "./node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js": +/*!***********************************************************************!*\ + !*** ./node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js ***! + \***********************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "HiddenText": function() { return /* binding */ HiddenText; }, +/* harmony export */ "LiveRegion": function() { return /* binding */ LiveRegion; }, +/* harmony export */ "useAnnouncement": function() { return /* binding */ useAnnouncement; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); + + +const hiddenStyles = { + display: 'none' +}; +function HiddenText(_ref) { + let { + id, + value + } = _ref; + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { + id: id, + style: hiddenStyles + }, value); +} + +function LiveRegion(_ref) { + let { + id, + announcement, + ariaLiveType = "assertive" + } = _ref; + // Hide element visually but keep it readable by screen readers + const visuallyHidden = { + position: 'fixed', + width: 1, + height: 1, + margin: -1, + border: 0, + padding: 0, + overflow: 'hidden', + clip: 'rect(0 0 0 0)', + clipPath: 'inset(100%)', + whiteSpace: 'nowrap' + }; + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { + id: id, + style: visuallyHidden, + role: "status", + "aria-live": ariaLiveType, + "aria-atomic": true + }, announcement); +} + +function useAnnouncement() { + const [announcement, setAnnouncement] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''); + const announce = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(value => { + if (value != null) { + setAnnouncement(value); + } + }, []); + return { + announce, + announcement + }; +} + + +//# sourceMappingURL=accessibility.esm.js.map + + +/***/ }), + +/***/ "./node_modules/@dnd-kit/core/dist/core.esm.js": +/*!*****************************************************!*\ + !*** ./node_modules/@dnd-kit/core/dist/core.esm.js ***! + \*****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "AutoScrollActivator": function() { return /* binding */ AutoScrollActivator; }, +/* harmony export */ "DndContext": function() { return /* binding */ DndContext; }, +/* harmony export */ "DragOverlay": function() { return /* binding */ DragOverlay; }, +/* harmony export */ "KeyboardCode": function() { return /* binding */ KeyboardCode; }, +/* harmony export */ "KeyboardSensor": function() { return /* binding */ KeyboardSensor; }, +/* harmony export */ "MeasuringFrequency": function() { return /* binding */ MeasuringFrequency; }, +/* harmony export */ "MeasuringStrategy": function() { return /* binding */ MeasuringStrategy; }, +/* harmony export */ "MouseSensor": function() { return /* binding */ MouseSensor; }, +/* harmony export */ "PointerSensor": function() { return /* binding */ PointerSensor; }, +/* harmony export */ "TouchSensor": function() { return /* binding */ TouchSensor; }, +/* harmony export */ "TraversalOrder": function() { return /* binding */ TraversalOrder; }, +/* harmony export */ "applyModifiers": function() { return /* binding */ applyModifiers; }, +/* harmony export */ "closestCenter": function() { return /* binding */ closestCenter; }, +/* harmony export */ "closestCorners": function() { return /* binding */ closestCorners; }, +/* harmony export */ "defaultAnnouncements": function() { return /* binding */ defaultAnnouncements; }, +/* harmony export */ "defaultCoordinates": function() { return /* binding */ defaultCoordinates; }, +/* harmony export */ "defaultDropAnimation": function() { return /* binding */ defaultDropAnimationConfiguration; }, +/* harmony export */ "defaultDropAnimationSideEffects": function() { return /* binding */ defaultDropAnimationSideEffects; }, +/* harmony export */ "defaultScreenReaderInstructions": function() { return /* binding */ defaultScreenReaderInstructions; }, +/* harmony export */ "getClientRect": function() { return /* binding */ getClientRect; }, +/* harmony export */ "getFirstCollision": function() { return /* binding */ getFirstCollision; }, +/* harmony export */ "getScrollableAncestors": function() { return /* binding */ getScrollableAncestors; }, +/* harmony export */ "pointerWithin": function() { return /* binding */ pointerWithin; }, +/* harmony export */ "rectIntersection": function() { return /* binding */ rectIntersection; }, +/* harmony export */ "useDndContext": function() { return /* binding */ useDndContext; }, +/* harmony export */ "useDndMonitor": function() { return /* binding */ useDndMonitor; }, +/* harmony export */ "useDraggable": function() { return /* binding */ useDraggable; }, +/* harmony export */ "useDroppable": function() { return /* binding */ useDroppable; }, +/* harmony export */ "useSensor": function() { return /* binding */ useSensor; }, +/* harmony export */ "useSensors": function() { return /* binding */ useSensors; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "react-dom"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @dnd-kit/utilities */ "./node_modules/@dnd-kit/utilities/dist/utilities.esm.js"); +/* harmony import */ var _dnd_kit_accessibility__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @dnd-kit/accessibility */ "./node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js"); + + + + + +const DndMonitorContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null); + +function useDndMonitor(listener) { + const registerListener = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(DndMonitorContext); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!registerListener) { + throw new Error('useDndMonitor must be used within a children of '); + } + + const unsubscribe = registerListener(listener); + return unsubscribe; + }, [listener, registerListener]); +} + +function useDndMonitorProvider() { + const [listeners] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(() => new Set()); + const registerListener = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(listener => { + listeners.add(listener); + return () => listeners.delete(listener); + }, [listeners]); + const dispatch = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(_ref => { + let { + type, + event + } = _ref; + listeners.forEach(listener => { + var _listener$type; + + return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event); + }); + }, [listeners]); + return [dispatch, registerListener]; +} + +const defaultScreenReaderInstructions = { + draggable: "\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n " +}; +const defaultAnnouncements = { + onDragStart(_ref) { + let { + active + } = _ref; + return "Picked up draggable item " + active.id + "."; + }, + + onDragOver(_ref2) { + let { + active, + over + } = _ref2; + + if (over) { + return "Draggable item " + active.id + " was moved over droppable area " + over.id + "."; + } + + return "Draggable item " + active.id + " is no longer over a droppable area."; + }, + + onDragEnd(_ref3) { + let { + active, + over + } = _ref3; + + if (over) { + return "Draggable item " + active.id + " was dropped over droppable area " + over.id; + } + + return "Draggable item " + active.id + " was dropped."; + }, + + onDragCancel(_ref4) { + let { + active + } = _ref4; + return "Dragging was cancelled. Draggable item " + active.id + " was dropped."; + } + +}; + +function Accessibility(_ref) { + let { + announcements = defaultAnnouncements, + container, + hiddenTextDescribedById, + screenReaderInstructions = defaultScreenReaderInstructions + } = _ref; + const { + announce, + announcement + } = (0,_dnd_kit_accessibility__WEBPACK_IMPORTED_MODULE_3__.useAnnouncement)(); + const liveRegionId = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useUniqueId)("DndLiveRegion"); + const [mounted, setMounted] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + setMounted(true); + }, []); + useDndMonitor((0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + onDragStart(_ref2) { + let { + active + } = _ref2; + announce(announcements.onDragStart({ + active + })); + }, + + onDragMove(_ref3) { + let { + active, + over + } = _ref3; + + if (announcements.onDragMove) { + announce(announcements.onDragMove({ + active, + over + })); + } + }, + + onDragOver(_ref4) { + let { + active, + over + } = _ref4; + announce(announcements.onDragOver({ + active, + over + })); + }, + + onDragEnd(_ref5) { + let { + active, + over + } = _ref5; + announce(announcements.onDragEnd({ + active, + over + })); + }, + + onDragCancel(_ref6) { + let { + active, + over + } = _ref6; + announce(announcements.onDragCancel({ + active, + over + })); + } + + }), [announce, announcements])); + + if (!mounted) { + return null; + } + + const markup = react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_dnd_kit_accessibility__WEBPACK_IMPORTED_MODULE_3__.HiddenText, { + id: hiddenTextDescribedById, + value: screenReaderInstructions.draggable + }), react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_dnd_kit_accessibility__WEBPACK_IMPORTED_MODULE_3__.LiveRegion, { + id: liveRegionId, + announcement: announcement + })); + return container ? (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal)(markup, container) : markup; +} + +var Action; + +(function (Action) { + Action["DragStart"] = "dragStart"; + Action["DragMove"] = "dragMove"; + Action["DragEnd"] = "dragEnd"; + Action["DragCancel"] = "dragCancel"; + Action["DragOver"] = "dragOver"; + Action["RegisterDroppable"] = "registerDroppable"; + Action["SetDroppableDisabled"] = "setDroppableDisabled"; + Action["UnregisterDroppable"] = "unregisterDroppable"; +})(Action || (Action = {})); + +function noop() {} + +function useSensor(sensor, options) { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + sensor, + options: options != null ? options : {} + }), // eslint-disable-next-line react-hooks/exhaustive-deps + [sensor, options]); +} + +function useSensors() { + for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) { + sensors[_key] = arguments[_key]; + } + + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => [...sensors].filter(sensor => sensor != null), // eslint-disable-next-line react-hooks/exhaustive-deps + [...sensors]); +} + +const defaultCoordinates = /*#__PURE__*/Object.freeze({ + x: 0, + y: 0 +}); + +/** + * Returns the distance between two points + */ +function distanceBetween(p1, p2) { + return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); +} + +function getRelativeTransformOrigin(event, rect) { + const eventCoordinates = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getEventCoordinates)(event); + + if (!eventCoordinates) { + return '0 0'; + } + + const transformOrigin = { + x: (eventCoordinates.x - rect.left) / rect.width * 100, + y: (eventCoordinates.y - rect.top) / rect.height * 100 + }; + return transformOrigin.x + "% " + transformOrigin.y + "%"; +} + +/** + * Sort collisions from smallest to greatest value + */ +function sortCollisionsAsc(_ref, _ref2) { + let { + data: { + value: a + } + } = _ref; + let { + data: { + value: b + } + } = _ref2; + return a - b; +} +/** + * Sort collisions from greatest to smallest value + */ + +function sortCollisionsDesc(_ref3, _ref4) { + let { + data: { + value: a + } + } = _ref3; + let { + data: { + value: b + } + } = _ref4; + return b - a; +} +/** + * Returns the coordinates of the corners of a given rectangle: + * [TopLeft {x, y}, TopRight {x, y}, BottomLeft {x, y}, BottomRight {x, y}] + */ + +function cornersOfRectangle(_ref5) { + let { + left, + top, + height, + width + } = _ref5; + return [{ + x: left, + y: top + }, { + x: left + width, + y: top + }, { + x: left, + y: top + height + }, { + x: left + width, + y: top + height + }]; +} +function getFirstCollision(collisions, property) { + if (!collisions || collisions.length === 0) { + return null; + } + + const [firstCollision] = collisions; + return property ? firstCollision[property] : firstCollision; +} + +/** + * Returns the coordinates of the center of a given ClientRect + */ + +function centerOfRectangle(rect, left, top) { + if (left === void 0) { + left = rect.left; + } + + if (top === void 0) { + top = rect.top; + } + + return { + x: left + rect.width * 0.5, + y: top + rect.height * 0.5 + }; +} +/** + * Returns the closest rectangles from an array of rectangles to the center of a given + * rectangle. + */ + + +const closestCenter = _ref => { + let { + collisionRect, + droppableRects, + droppableContainers + } = _ref; + const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top); + const collisions = []; + + for (const droppableContainer of droppableContainers) { + const { + id + } = droppableContainer; + const rect = droppableRects.get(id); + + if (rect) { + const distBetween = distanceBetween(centerOfRectangle(rect), centerRect); + collisions.push({ + id, + data: { + droppableContainer, + value: distBetween + } + }); + } + } + + return collisions.sort(sortCollisionsAsc); +}; + +/** + * Returns the closest rectangles from an array of rectangles to the corners of + * another rectangle. + */ + +const closestCorners = _ref => { + let { + collisionRect, + droppableRects, + droppableContainers + } = _ref; + const corners = cornersOfRectangle(collisionRect); + const collisions = []; + + for (const droppableContainer of droppableContainers) { + const { + id + } = droppableContainer; + const rect = droppableRects.get(id); + + if (rect) { + const rectCorners = cornersOfRectangle(rect); + const distances = corners.reduce((accumulator, corner, index) => { + return accumulator + distanceBetween(rectCorners[index], corner); + }, 0); + const effectiveDistance = Number((distances / 4).toFixed(4)); + collisions.push({ + id, + data: { + droppableContainer, + value: effectiveDistance + } + }); + } + } + + return collisions.sort(sortCollisionsAsc); +}; + +/** + * Returns the intersecting rectangle area between two rectangles + */ + +function getIntersectionRatio(entry, target) { + const top = Math.max(target.top, entry.top); + const left = Math.max(target.left, entry.left); + const right = Math.min(target.left + target.width, entry.left + entry.width); + const bottom = Math.min(target.top + target.height, entry.top + entry.height); + const width = right - left; + const height = bottom - top; + + if (left < right && top < bottom) { + const targetArea = target.width * target.height; + const entryArea = entry.width * entry.height; + const intersectionArea = width * height; + const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea); + return Number(intersectionRatio.toFixed(4)); + } // Rectangles do not overlap, or overlap has an area of zero (edge/corner overlap) + + + return 0; +} +/** + * Returns the rectangles that has the greatest intersection area with a given + * rectangle in an array of rectangles. + */ + +const rectIntersection = _ref => { + let { + collisionRect, + droppableRects, + droppableContainers + } = _ref; + const collisions = []; + + for (const droppableContainer of droppableContainers) { + const { + id + } = droppableContainer; + const rect = droppableRects.get(id); + + if (rect) { + const intersectionRatio = getIntersectionRatio(rect, collisionRect); + + if (intersectionRatio > 0) { + collisions.push({ + id, + data: { + droppableContainer, + value: intersectionRatio + } + }); + } + } + } + + return collisions.sort(sortCollisionsDesc); +}; + +/** + * Check if a given point is contained within a bounding rectangle + */ + +function isPointWithinRect(point, rect) { + const { + top, + left, + bottom, + right + } = rect; + return top <= point.y && point.y <= bottom && left <= point.x && point.x <= right; +} +/** + * Returns the rectangles that the pointer is hovering over + */ + + +const pointerWithin = _ref => { + let { + droppableContainers, + droppableRects, + pointerCoordinates + } = _ref; + + if (!pointerCoordinates) { + return []; + } + + const collisions = []; + + for (const droppableContainer of droppableContainers) { + const { + id + } = droppableContainer; + const rect = droppableRects.get(id); + + if (rect && isPointWithinRect(pointerCoordinates, rect)) { + /* There may be more than a single rectangle intersecting + * with the pointer coordinates. In order to sort the + * colliding rectangles, we measure the distance between + * the pointer and the corners of the intersecting rectangle + */ + const corners = cornersOfRectangle(rect); + const distances = corners.reduce((accumulator, corner) => { + return accumulator + distanceBetween(pointerCoordinates, corner); + }, 0); + const effectiveDistance = Number((distances / 4).toFixed(4)); + collisions.push({ + id, + data: { + droppableContainer, + value: effectiveDistance + } + }); + } + } + + return collisions.sort(sortCollisionsAsc); +}; + +function adjustScale(transform, rect1, rect2) { + return { ...transform, + scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1, + scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1 + }; +} + +function getRectDelta(rect1, rect2) { + return rect1 && rect2 ? { + x: rect1.left - rect2.left, + y: rect1.top - rect2.top + } : defaultCoordinates; +} + +function createRectAdjustmentFn(modifier) { + return function adjustClientRect(rect) { + for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + adjustments[_key - 1] = arguments[_key]; + } + + return adjustments.reduce((acc, adjustment) => ({ ...acc, + top: acc.top + modifier * adjustment.y, + bottom: acc.bottom + modifier * adjustment.y, + left: acc.left + modifier * adjustment.x, + right: acc.right + modifier * adjustment.x + }), { ...rect + }); + }; +} +const getAdjustedRect = /*#__PURE__*/createRectAdjustmentFn(1); + +function parseTransform(transform) { + if (transform.startsWith('matrix3d(')) { + const transformArray = transform.slice(9, -1).split(/, /); + return { + x: +transformArray[12], + y: +transformArray[13], + scaleX: +transformArray[0], + scaleY: +transformArray[5] + }; + } else if (transform.startsWith('matrix(')) { + const transformArray = transform.slice(7, -1).split(/, /); + return { + x: +transformArray[4], + y: +transformArray[5], + scaleX: +transformArray[0], + scaleY: +transformArray[3] + }; + } + + return null; +} + +function inverseTransform(rect, transform, transformOrigin) { + const parsedTransform = parseTransform(transform); + + if (!parsedTransform) { + return rect; + } + + const { + scaleX, + scaleY, + x: translateX, + y: translateY + } = parsedTransform; + const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin); + const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(' ') + 1)); + const w = scaleX ? rect.width / scaleX : rect.width; + const h = scaleY ? rect.height / scaleY : rect.height; + return { + width: w, + height: h, + top: y, + right: x + w, + bottom: y + h, + left: x + }; +} + +const defaultOptions = { + ignoreTransform: false +}; +/** + * Returns the bounding client rect of an element relative to the viewport. + */ + +function getClientRect(element, options) { + if (options === void 0) { + options = defaultOptions; + } + + let rect = element.getBoundingClientRect(); + + if (options.ignoreTransform) { + const { + transform, + transformOrigin + } = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(element).getComputedStyle(element); + + if (transform) { + rect = inverseTransform(rect, transform, transformOrigin); + } + } + + const { + top, + left, + width, + height, + bottom, + right + } = rect; + return { + top, + left, + width, + height, + bottom, + right + }; +} +/** + * Returns the bounding client rect of an element relative to the viewport. + * + * @remarks + * The ClientRect returned by this method does not take into account transforms + * applied to the element it measures. + * + */ + +function getTransformAgnosticClientRect(element) { + return getClientRect(element, { + ignoreTransform: true + }); +} + +function getWindowClientRect(element) { + const width = element.innerWidth; + const height = element.innerHeight; + return { + top: 0, + left: 0, + right: width, + bottom: height, + width, + height + }; +} + +function isFixed(node, computedStyle) { + if (computedStyle === void 0) { + computedStyle = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(node).getComputedStyle(node); + } + + return computedStyle.position === 'fixed'; +} + +function isScrollable(element, computedStyle) { + if (computedStyle === void 0) { + computedStyle = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(element).getComputedStyle(element); + } + + const overflowRegex = /(auto|scroll|overlay)/; + const properties = ['overflow', 'overflowX', 'overflowY']; + return properties.some(property => { + const value = computedStyle[property]; + return typeof value === 'string' ? overflowRegex.test(value) : false; + }); +} + +function getScrollableAncestors(element, limit) { + const scrollParents = []; + + function findScrollableAncestors(node) { + if (limit != null && scrollParents.length >= limit) { + return scrollParents; + } + + if (!node) { + return scrollParents; + } + + if ((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isDocument)(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) { + scrollParents.push(node.scrollingElement); + return scrollParents; + } + + if (!(0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isHTMLElement)(node) || (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isSVGElement)(node)) { + return scrollParents; + } + + if (scrollParents.includes(node)) { + return scrollParents; + } + + const computedStyle = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(element).getComputedStyle(node); + + if (node !== element) { + if (isScrollable(node, computedStyle)) { + scrollParents.push(node); + } + } + + if (isFixed(node, computedStyle)) { + return scrollParents; + } + + return findScrollableAncestors(node.parentNode); + } + + if (!element) { + return scrollParents; + } + + return findScrollableAncestors(element); +} +function getFirstScrollableAncestor(node) { + const [firstScrollableAncestor] = getScrollableAncestors(node, 1); + return firstScrollableAncestor != null ? firstScrollableAncestor : null; +} + +function getScrollableElement(element) { + if (!_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.canUseDOM || !element) { + return null; + } + + if ((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isWindow)(element)) { + return element; + } + + if (!(0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isNode)(element)) { + return null; + } + + if ((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isDocument)(element) || element === (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getOwnerDocument)(element).scrollingElement) { + return window; + } + + if ((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isHTMLElement)(element)) { + return element; + } + + return null; +} + +function getScrollXCoordinate(element) { + if ((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isWindow)(element)) { + return element.scrollX; + } + + return element.scrollLeft; +} +function getScrollYCoordinate(element) { + if ((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isWindow)(element)) { + return element.scrollY; + } + + return element.scrollTop; +} +function getScrollCoordinates(element) { + return { + x: getScrollXCoordinate(element), + y: getScrollYCoordinate(element) + }; +} + +var Direction; + +(function (Direction) { + Direction[Direction["Forward"] = 1] = "Forward"; + Direction[Direction["Backward"] = -1] = "Backward"; +})(Direction || (Direction = {})); + +function isDocumentScrollingElement(element) { + if (!_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.canUseDOM || !element) { + return false; + } + + return element === document.scrollingElement; +} + +function getScrollPosition(scrollingContainer) { + const minScroll = { + x: 0, + y: 0 + }; + const dimensions = isDocumentScrollingElement(scrollingContainer) ? { + height: window.innerHeight, + width: window.innerWidth + } : { + height: scrollingContainer.clientHeight, + width: scrollingContainer.clientWidth + }; + const maxScroll = { + x: scrollingContainer.scrollWidth - dimensions.width, + y: scrollingContainer.scrollHeight - dimensions.height + }; + const isTop = scrollingContainer.scrollTop <= minScroll.y; + const isLeft = scrollingContainer.scrollLeft <= minScroll.x; + const isBottom = scrollingContainer.scrollTop >= maxScroll.y; + const isRight = scrollingContainer.scrollLeft >= maxScroll.x; + return { + isTop, + isLeft, + isBottom, + isRight, + maxScroll, + minScroll + }; +} + +const defaultThreshold = { + x: 0.2, + y: 0.2 +}; +function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) { + let { + top, + left, + right, + bottom + } = _ref; + + if (acceleration === void 0) { + acceleration = 10; + } + + if (thresholdPercentage === void 0) { + thresholdPercentage = defaultThreshold; + } + + const { + isTop, + isBottom, + isLeft, + isRight + } = getScrollPosition(scrollContainer); + const direction = { + x: 0, + y: 0 + }; + const speed = { + x: 0, + y: 0 + }; + const threshold = { + height: scrollContainerRect.height * thresholdPercentage.y, + width: scrollContainerRect.width * thresholdPercentage.x + }; + + if (!isTop && top <= scrollContainerRect.top + threshold.height) { + // Scroll Up + direction.y = Direction.Backward; + speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height); + } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) { + // Scroll Down + direction.y = Direction.Forward; + speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height); + } + + if (!isRight && right >= scrollContainerRect.right - threshold.width) { + // Scroll Right + direction.x = Direction.Forward; + speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width); + } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) { + // Scroll Left + direction.x = Direction.Backward; + speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width); + } + + return { + direction, + speed + }; +} + +function getScrollElementRect(element) { + if (element === document.scrollingElement) { + const { + innerWidth, + innerHeight + } = window; + return { + top: 0, + left: 0, + right: innerWidth, + bottom: innerHeight, + width: innerWidth, + height: innerHeight + }; + } + + const { + top, + left, + right, + bottom + } = element.getBoundingClientRect(); + return { + top, + left, + right, + bottom, + width: element.clientWidth, + height: element.clientHeight + }; +} + +function getScrollOffsets(scrollableAncestors) { + return scrollableAncestors.reduce((acc, node) => { + return (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.add)(acc, getScrollCoordinates(node)); + }, defaultCoordinates); +} +function getScrollXOffset(scrollableAncestors) { + return scrollableAncestors.reduce((acc, node) => { + return acc + getScrollXCoordinate(node); + }, 0); +} +function getScrollYOffset(scrollableAncestors) { + return scrollableAncestors.reduce((acc, node) => { + return acc + getScrollYCoordinate(node); + }, 0); +} + +function scrollIntoViewIfNeeded(element, measure) { + if (measure === void 0) { + measure = getClientRect; + } + + if (!element) { + return; + } + + const { + top, + left, + bottom, + right + } = measure(element); + const firstScrollableAncestor = getFirstScrollableAncestor(element); + + if (!firstScrollableAncestor) { + return; + } + + if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) { + element.scrollIntoView({ + block: 'center', + inline: 'center' + }); + } +} + +const properties = [['x', ['left', 'right'], getScrollXOffset], ['y', ['top', 'bottom'], getScrollYOffset]]; +class Rect { + constructor(rect, element) { + this.rect = void 0; + this.width = void 0; + this.height = void 0; + this.top = void 0; + this.bottom = void 0; + this.right = void 0; + this.left = void 0; + const scrollableAncestors = getScrollableAncestors(element); + const scrollOffsets = getScrollOffsets(scrollableAncestors); + this.rect = { ...rect + }; + this.width = rect.width; + this.height = rect.height; + + for (const [axis, keys, getScrollOffset] of properties) { + for (const key of keys) { + Object.defineProperty(this, key, { + get: () => { + const currentOffsets = getScrollOffset(scrollableAncestors); + const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets; + return this.rect[key] + scrollOffsetsDeltla; + }, + enumerable: true + }); + } + } + + Object.defineProperty(this, 'rect', { + enumerable: false + }); + } + +} + +class Listeners { + constructor(target) { + this.target = void 0; + this.listeners = []; + + this.removeAll = () => { + this.listeners.forEach(listener => { + var _this$target; + + return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener); + }); + }; + + this.target = target; + } + + add(eventName, handler, options) { + var _this$target2; + + (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options); + this.listeners.push([eventName, handler, options]); + } + +} + +function getEventListenerTarget(target) { + // If the `event.target` element is removed from the document events will still be targeted + // at it, and hence won't always bubble up to the window or document anymore. + // If there is any risk of an element being removed while it is being dragged, + // the best practice is to attach the event listeners directly to the target. + // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget + const { + EventTarget + } = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(target); + return target instanceof EventTarget ? target : (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getOwnerDocument)(target); +} + +function hasExceededDistance(delta, measurement) { + const dx = Math.abs(delta.x); + const dy = Math.abs(delta.y); + + if (typeof measurement === 'number') { + return Math.sqrt(dx ** 2 + dy ** 2) > measurement; + } + + if ('x' in measurement && 'y' in measurement) { + return dx > measurement.x && dy > measurement.y; + } + + if ('x' in measurement) { + return dx > measurement.x; + } + + if ('y' in measurement) { + return dy > measurement.y; + } + + return false; +} + +var EventName; + +(function (EventName) { + EventName["Click"] = "click"; + EventName["DragStart"] = "dragstart"; + EventName["Keydown"] = "keydown"; + EventName["ContextMenu"] = "contextmenu"; + EventName["Resize"] = "resize"; + EventName["SelectionChange"] = "selectionchange"; + EventName["VisibilityChange"] = "visibilitychange"; +})(EventName || (EventName = {})); + +function preventDefault(event) { + event.preventDefault(); +} +function stopPropagation(event) { + event.stopPropagation(); +} + +var KeyboardCode; + +(function (KeyboardCode) { + KeyboardCode["Space"] = "Space"; + KeyboardCode["Down"] = "ArrowDown"; + KeyboardCode["Right"] = "ArrowRight"; + KeyboardCode["Left"] = "ArrowLeft"; + KeyboardCode["Up"] = "ArrowUp"; + KeyboardCode["Esc"] = "Escape"; + KeyboardCode["Enter"] = "Enter"; +})(KeyboardCode || (KeyboardCode = {})); + +const defaultKeyboardCodes = { + start: [KeyboardCode.Space, KeyboardCode.Enter], + cancel: [KeyboardCode.Esc], + end: [KeyboardCode.Space, KeyboardCode.Enter] +}; +const defaultKeyboardCoordinateGetter = (event, _ref) => { + let { + currentCoordinates + } = _ref; + + switch (event.code) { + case KeyboardCode.Right: + return { ...currentCoordinates, + x: currentCoordinates.x + 25 + }; + + case KeyboardCode.Left: + return { ...currentCoordinates, + x: currentCoordinates.x - 25 + }; + + case KeyboardCode.Down: + return { ...currentCoordinates, + y: currentCoordinates.y + 25 + }; + + case KeyboardCode.Up: + return { ...currentCoordinates, + y: currentCoordinates.y - 25 + }; + } + + return undefined; +}; + +class KeyboardSensor { + constructor(props) { + this.props = void 0; + this.autoScrollEnabled = false; + this.referenceCoordinates = void 0; + this.listeners = void 0; + this.windowListeners = void 0; + this.props = props; + const { + event: { + target + } + } = props; + this.props = props; + this.listeners = new Listeners((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getOwnerDocument)(target)); + this.windowListeners = new Listeners((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(target)); + this.handleKeyDown = this.handleKeyDown.bind(this); + this.handleCancel = this.handleCancel.bind(this); + this.attach(); + } + + attach() { + this.handleStart(); + this.windowListeners.add(EventName.Resize, this.handleCancel); + this.windowListeners.add(EventName.VisibilityChange, this.handleCancel); + setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown)); + } + + handleStart() { + const { + activeNode, + onStart + } = this.props; + const node = activeNode.node.current; + + if (node) { + scrollIntoViewIfNeeded(node); + } + + onStart(defaultCoordinates); + } + + handleKeyDown(event) { + if ((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isKeyboardEvent)(event)) { + const { + active, + context, + options + } = this.props; + const { + keyboardCodes = defaultKeyboardCodes, + coordinateGetter = defaultKeyboardCoordinateGetter, + scrollBehavior = 'smooth' + } = options; + const { + code + } = event; + + if (keyboardCodes.end.includes(code)) { + this.handleEnd(event); + return; + } + + if (keyboardCodes.cancel.includes(code)) { + this.handleCancel(event); + return; + } + + const { + collisionRect + } = context.current; + const currentCoordinates = collisionRect ? { + x: collisionRect.left, + y: collisionRect.top + } : defaultCoordinates; + + if (!this.referenceCoordinates) { + this.referenceCoordinates = currentCoordinates; + } + + const newCoordinates = coordinateGetter(event, { + active, + context: context.current, + currentCoordinates + }); + + if (newCoordinates) { + const coordinatesDelta = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.subtract)(newCoordinates, currentCoordinates); + const scrollDelta = { + x: 0, + y: 0 + }; + const { + scrollableAncestors + } = context.current; + + for (const scrollContainer of scrollableAncestors) { + const direction = event.code; + const { + isTop, + isRight, + isLeft, + isBottom, + maxScroll, + minScroll + } = getScrollPosition(scrollContainer); + const scrollElementRect = getScrollElementRect(scrollContainer); + const clampedCoordinates = { + x: Math.min(direction === KeyboardCode.Right ? scrollElementRect.right - scrollElementRect.width / 2 : scrollElementRect.right, Math.max(direction === KeyboardCode.Right ? scrollElementRect.left : scrollElementRect.left + scrollElementRect.width / 2, newCoordinates.x)), + y: Math.min(direction === KeyboardCode.Down ? scrollElementRect.bottom - scrollElementRect.height / 2 : scrollElementRect.bottom, Math.max(direction === KeyboardCode.Down ? scrollElementRect.top : scrollElementRect.top + scrollElementRect.height / 2, newCoordinates.y)) + }; + const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft; + const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop; + + if (canScrollX && clampedCoordinates.x !== newCoordinates.x) { + const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x; + const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x; + + if (canScrollToNewCoordinates && !coordinatesDelta.y) { + // We don't need to update coordinates, the scroll adjustment alone will trigger + // logic to auto-detect the new container we are over + scrollContainer.scrollTo({ + left: newScrollCoordinates, + behavior: scrollBehavior + }); + return; + } + + if (canScrollToNewCoordinates) { + scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates; + } else { + scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x; + } + + if (scrollDelta.x) { + scrollContainer.scrollBy({ + left: -scrollDelta.x, + behavior: scrollBehavior + }); + } + + break; + } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) { + const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y; + const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y; + + if (canScrollToNewCoordinates && !coordinatesDelta.x) { + // We don't need to update coordinates, the scroll adjustment alone will trigger + // logic to auto-detect the new container we are over + scrollContainer.scrollTo({ + top: newScrollCoordinates, + behavior: scrollBehavior + }); + return; + } + + if (canScrollToNewCoordinates) { + scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates; + } else { + scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y; + } + + if (scrollDelta.y) { + scrollContainer.scrollBy({ + top: -scrollDelta.y, + behavior: scrollBehavior + }); + } + + break; + } + } + + this.handleMove(event, (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.add)((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.subtract)(newCoordinates, this.referenceCoordinates), scrollDelta)); + } + } + } + + handleMove(event, coordinates) { + const { + onMove + } = this.props; + event.preventDefault(); + onMove(coordinates); + } + + handleEnd(event) { + const { + onEnd + } = this.props; + event.preventDefault(); + this.detach(); + onEnd(); + } + + handleCancel(event) { + const { + onCancel + } = this.props; + event.preventDefault(); + this.detach(); + onCancel(); + } + + detach() { + this.listeners.removeAll(); + this.windowListeners.removeAll(); + } + +} +KeyboardSensor.activators = [{ + eventName: 'onKeyDown', + handler: (event, _ref, _ref2) => { + let { + keyboardCodes = defaultKeyboardCodes, + onActivation + } = _ref; + let { + active + } = _ref2; + const { + code + } = event.nativeEvent; + + if (keyboardCodes.start.includes(code)) { + const activator = active.activatorNode.current; + + if (activator && event.target !== activator) { + return false; + } + + event.preventDefault(); + onActivation == null ? void 0 : onActivation({ + event: event.nativeEvent + }); + return true; + } + + return false; + } +}]; + +function isDistanceConstraint(constraint) { + return Boolean(constraint && 'distance' in constraint); +} + +function isDelayConstraint(constraint) { + return Boolean(constraint && 'delay' in constraint); +} + +class AbstractPointerSensor { + constructor(props, events, listenerTarget) { + var _getEventCoordinates; + + if (listenerTarget === void 0) { + listenerTarget = getEventListenerTarget(props.event.target); + } + + this.props = void 0; + this.events = void 0; + this.autoScrollEnabled = true; + this.document = void 0; + this.activated = false; + this.initialCoordinates = void 0; + this.timeoutId = null; + this.listeners = void 0; + this.documentListeners = void 0; + this.windowListeners = void 0; + this.props = props; + this.events = events; + const { + event + } = props; + const { + target + } = event; + this.props = props; + this.events = events; + this.document = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getOwnerDocument)(target); + this.documentListeners = new Listeners(this.document); + this.listeners = new Listeners(listenerTarget); + this.windowListeners = new Listeners((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(target)); + this.initialCoordinates = (_getEventCoordinates = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getEventCoordinates)(event)) != null ? _getEventCoordinates : defaultCoordinates; + this.handleStart = this.handleStart.bind(this); + this.handleMove = this.handleMove.bind(this); + this.handleEnd = this.handleEnd.bind(this); + this.handleCancel = this.handleCancel.bind(this); + this.handleKeydown = this.handleKeydown.bind(this); + this.removeTextSelection = this.removeTextSelection.bind(this); + this.attach(); + } + + attach() { + const { + events, + props: { + options: { + activationConstraint, + bypassActivationConstraint + } + } + } = this; + this.listeners.add(events.move.name, this.handleMove, { + passive: false + }); + this.listeners.add(events.end.name, this.handleEnd); + this.windowListeners.add(EventName.Resize, this.handleCancel); + this.windowListeners.add(EventName.DragStart, preventDefault); + this.windowListeners.add(EventName.VisibilityChange, this.handleCancel); + this.windowListeners.add(EventName.ContextMenu, preventDefault); + this.documentListeners.add(EventName.Keydown, this.handleKeydown); + + if (activationConstraint) { + if (bypassActivationConstraint != null && bypassActivationConstraint({ + event: this.props.event, + activeNode: this.props.activeNode, + options: this.props.options + })) { + return this.handleStart(); + } + + if (isDelayConstraint(activationConstraint)) { + this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay); + return; + } + + if (isDistanceConstraint(activationConstraint)) { + return; + } + } + + this.handleStart(); + } + + detach() { + this.listeners.removeAll(); + this.windowListeners.removeAll(); // Wait until the next event loop before removing document listeners + // This is necessary because we listen for `click` and `selection` events on the document + + setTimeout(this.documentListeners.removeAll, 50); + + if (this.timeoutId !== null) { + clearTimeout(this.timeoutId); + this.timeoutId = null; + } + } + + handleStart() { + const { + initialCoordinates + } = this; + const { + onStart + } = this.props; + + if (initialCoordinates) { + this.activated = true; // Stop propagation of click events once activation constraints are met + + this.documentListeners.add(EventName.Click, stopPropagation, { + capture: true + }); // Remove any text selection from the document + + this.removeTextSelection(); // Prevent further text selection while dragging + + this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection); + onStart(initialCoordinates); + } + } + + handleMove(event) { + var _getEventCoordinates2; + + const { + activated, + initialCoordinates, + props + } = this; + const { + onMove, + options: { + activationConstraint + } + } = props; + + if (!initialCoordinates) { + return; + } + + const coordinates = (_getEventCoordinates2 = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getEventCoordinates)(event)) != null ? _getEventCoordinates2 : defaultCoordinates; + const delta = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.subtract)(initialCoordinates, coordinates); // Constraint validation + + if (!activated && activationConstraint) { + if (isDistanceConstraint(activationConstraint)) { + if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) { + return this.handleCancel(); + } + + if (hasExceededDistance(delta, activationConstraint.distance)) { + return this.handleStart(); + } + } + + if (isDelayConstraint(activationConstraint)) { + if (hasExceededDistance(delta, activationConstraint.tolerance)) { + return this.handleCancel(); + } + } + + return; + } + + if (event.cancelable) { + event.preventDefault(); + } + + onMove(coordinates); + } + + handleEnd() { + const { + onEnd + } = this.props; + this.detach(); + onEnd(); + } + + handleCancel() { + const { + onCancel + } = this.props; + this.detach(); + onCancel(); + } + + handleKeydown(event) { + if (event.code === KeyboardCode.Esc) { + this.handleCancel(); + } + } + + removeTextSelection() { + var _this$document$getSel; + + (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges(); + } + +} + +const events = { + move: { + name: 'pointermove' + }, + end: { + name: 'pointerup' + } +}; +class PointerSensor extends AbstractPointerSensor { + constructor(props) { + const { + event + } = props; // Pointer events stop firing if the target is unmounted while dragging + // Therefore we attach listeners to the owner document instead + + const listenerTarget = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getOwnerDocument)(event.target); + super(props, events, listenerTarget); + } + +} +PointerSensor.activators = [{ + eventName: 'onPointerDown', + handler: (_ref, _ref2) => { + let { + nativeEvent: event + } = _ref; + let { + onActivation + } = _ref2; + + if (!event.isPrimary || event.button !== 0) { + return false; + } + + onActivation == null ? void 0 : onActivation({ + event + }); + return true; + } +}]; + +const events$1 = { + move: { + name: 'mousemove' + }, + end: { + name: 'mouseup' + } +}; +var MouseButton; + +(function (MouseButton) { + MouseButton[MouseButton["RightClick"] = 2] = "RightClick"; +})(MouseButton || (MouseButton = {})); + +class MouseSensor extends AbstractPointerSensor { + constructor(props) { + super(props, events$1, (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getOwnerDocument)(props.event.target)); + } + +} +MouseSensor.activators = [{ + eventName: 'onMouseDown', + handler: (_ref, _ref2) => { + let { + nativeEvent: event + } = _ref; + let { + onActivation + } = _ref2; + + if (event.button === MouseButton.RightClick) { + return false; + } + + onActivation == null ? void 0 : onActivation({ + event + }); + return true; + } +}]; + +const events$2 = { + move: { + name: 'touchmove' + }, + end: { + name: 'touchend' + } +}; +class TouchSensor extends AbstractPointerSensor { + constructor(props) { + super(props, events$2); + } + + static setup() { + // Adding a non-capture and non-passive `touchmove` listener in order + // to force `event.preventDefault()` calls to work in dynamically added + // touchmove event handlers. This is required for iOS Safari. + window.addEventListener(events$2.move.name, noop, { + capture: false, + passive: false + }); + return function teardown() { + window.removeEventListener(events$2.move.name, noop); + }; // We create a new handler because the teardown function of another sensor + // could remove our event listener if we use a referentially equal listener. + + function noop() {} + } + +} +TouchSensor.activators = [{ + eventName: 'onTouchStart', + handler: (_ref, _ref2) => { + let { + nativeEvent: event + } = _ref; + let { + onActivation + } = _ref2; + const { + touches + } = event; + + if (touches.length > 1) { + return false; + } + + onActivation == null ? void 0 : onActivation({ + event + }); + return true; + } +}]; + +var AutoScrollActivator; + +(function (AutoScrollActivator) { + AutoScrollActivator[AutoScrollActivator["Pointer"] = 0] = "Pointer"; + AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect"; +})(AutoScrollActivator || (AutoScrollActivator = {})); + +var TraversalOrder; + +(function (TraversalOrder) { + TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder"; + TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder"; +})(TraversalOrder || (TraversalOrder = {})); + +function useAutoScroller(_ref) { + let { + acceleration, + activator = AutoScrollActivator.Pointer, + canScroll, + draggingRect, + enabled, + interval = 5, + order = TraversalOrder.TreeOrder, + pointerCoordinates, + scrollableAncestors, + scrollableAncestorRects, + delta, + threshold + } = _ref; + const scrollIntent = useScrollIntent({ + delta, + disabled: !enabled + }); + const [setAutoScrollInterval, clearAutoScrollInterval] = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useInterval)(); + const scrollSpeed = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({ + x: 0, + y: 0 + }); + const scrollDirection = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({ + x: 0, + y: 0 + }); + const rect = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + switch (activator) { + case AutoScrollActivator.Pointer: + return pointerCoordinates ? { + top: pointerCoordinates.y, + bottom: pointerCoordinates.y, + left: pointerCoordinates.x, + right: pointerCoordinates.x + } : null; + + case AutoScrollActivator.DraggableRect: + return draggingRect; + } + }, [activator, draggingRect, pointerCoordinates]); + const scrollContainerRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + const autoScroll = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + const scrollContainer = scrollContainerRef.current; + + if (!scrollContainer) { + return; + } + + const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x; + const scrollTop = scrollSpeed.current.y * scrollDirection.current.y; + scrollContainer.scrollBy(scrollLeft, scrollTop); + }, []); + const sortedScrollableAncestors = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!enabled || !scrollableAncestors.length || !rect) { + clearAutoScrollInterval(); + return; + } + + for (const scrollContainer of sortedScrollableAncestors) { + if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) { + continue; + } + + const index = scrollableAncestors.indexOf(scrollContainer); + const scrollContainerRect = scrollableAncestorRects[index]; + + if (!scrollContainerRect) { + continue; + } + + const { + direction, + speed + } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold); + + for (const axis of ['x', 'y']) { + if (!scrollIntent[axis][direction[axis]]) { + speed[axis] = 0; + direction[axis] = 0; + } + } + + if (speed.x > 0 || speed.y > 0) { + clearAutoScrollInterval(); + scrollContainerRef.current = scrollContainer; + setAutoScrollInterval(autoScroll, interval); + scrollSpeed.current = speed; + scrollDirection.current = direction; + return; + } + } + + scrollSpeed.current = { + x: 0, + y: 0 + }; + scrollDirection.current = { + x: 0, + y: 0 + }; + clearAutoScrollInterval(); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [acceleration, autoScroll, canScroll, clearAutoScrollInterval, enabled, interval, // eslint-disable-next-line react-hooks/exhaustive-deps + JSON.stringify(rect), // eslint-disable-next-line react-hooks/exhaustive-deps + JSON.stringify(scrollIntent), setAutoScrollInterval, scrollableAncestors, sortedScrollableAncestors, scrollableAncestorRects, // eslint-disable-next-line react-hooks/exhaustive-deps + JSON.stringify(threshold)]); +} +const defaultScrollIntent = { + x: { + [Direction.Backward]: false, + [Direction.Forward]: false + }, + y: { + [Direction.Backward]: false, + [Direction.Forward]: false + } +}; + +function useScrollIntent(_ref2) { + let { + delta, + disabled + } = _ref2; + const previousDelta = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.usePrevious)(delta); + return (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLazyMemo)(previousIntent => { + if (disabled || !previousDelta || !previousIntent) { + // Reset scroll intent tracking when auto-scrolling is disabled + return defaultScrollIntent; + } + + const direction = { + x: Math.sign(delta.x - previousDelta.x), + y: Math.sign(delta.y - previousDelta.y) + }; // Keep track of the user intent to scroll in each direction for both axis + + return { + x: { + [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1, + [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1 + }, + y: { + [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1, + [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1 + } + }; + }, [disabled, delta, previousDelta]); +} + +function useCachedNode(draggableNodes, id) { + const draggableNode = id !== null ? draggableNodes.get(id) : undefined; + const node = draggableNode ? draggableNode.node.current : null; + return (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLazyMemo)(cachedNode => { + var _ref; + + if (id === null) { + return null; + } // In some cases, the draggable node can unmount while dragging + // This is the case for virtualized lists. In those situations, + // we fall back to the last known value for that node. + + + return (_ref = node != null ? node : cachedNode) != null ? _ref : null; + }, [node, id]); +} + +function useCombineActivators(sensors, getSyntheticHandler) { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => sensors.reduce((accumulator, sensor) => { + const { + sensor: Sensor + } = sensor; + const sensorActivators = Sensor.activators.map(activator => ({ + eventName: activator.eventName, + handler: getSyntheticHandler(activator.handler, sensor) + })); + return [...accumulator, ...sensorActivators]; + }, []), [sensors, getSyntheticHandler]); +} + +var MeasuringStrategy; + +(function (MeasuringStrategy) { + MeasuringStrategy[MeasuringStrategy["Always"] = 0] = "Always"; + MeasuringStrategy[MeasuringStrategy["BeforeDragging"] = 1] = "BeforeDragging"; + MeasuringStrategy[MeasuringStrategy["WhileDragging"] = 2] = "WhileDragging"; +})(MeasuringStrategy || (MeasuringStrategy = {})); + +var MeasuringFrequency; + +(function (MeasuringFrequency) { + MeasuringFrequency["Optimized"] = "optimized"; +})(MeasuringFrequency || (MeasuringFrequency = {})); + +const defaultValue = /*#__PURE__*/new Map(); +function useDroppableMeasuring(containers, _ref) { + let { + dragging, + dependencies, + config + } = _ref; + const [queue, setQueue] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const { + frequency, + measure, + strategy + } = config; + const containersRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(containers); + const disabled = isDisabled(); + const disabledRef = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLatestValue)(disabled); + const measureDroppableContainers = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (ids) { + if (ids === void 0) { + ids = []; + } + + if (disabledRef.current) { + return; + } + + setQueue(value => { + if (value === null) { + return ids; + } + + return value.concat(ids.filter(id => !value.includes(id))); + }); + }, [disabledRef]); + const timeoutId = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + const droppableRects = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLazyMemo)(previousValue => { + if (disabled && !dragging) { + return defaultValue; + } + + if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) { + const map = new Map(); + + for (let container of containers) { + if (!container) { + continue; + } + + if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) { + // This container does not need to be re-measured + map.set(container.id, container.rect.current); + continue; + } + + const node = container.node.current; + const rect = node ? new Rect(measure(node), node) : null; + container.rect.current = rect; + + if (rect) { + map.set(container.id, rect); + } + } + + return map; + } + + return previousValue; + }, [containers, queue, dragging, disabled, measure]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + containersRef.current = containers; + }, [containers]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (disabled) { + return; + } + + measureDroppableContainers(); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [dragging, disabled]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (queue && queue.length > 0) { + setQueue(null); + } + }, //eslint-disable-next-line react-hooks/exhaustive-deps + [JSON.stringify(queue)]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (disabled || typeof frequency !== 'number' || timeoutId.current !== null) { + return; + } + + timeoutId.current = setTimeout(() => { + measureDroppableContainers(); + timeoutId.current = null; + }, frequency); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [frequency, disabled, measureDroppableContainers, ...dependencies]); + return { + droppableRects, + measureDroppableContainers, + measuringScheduled: queue != null + }; + + function isDisabled() { + switch (strategy) { + case MeasuringStrategy.Always: + return false; + + case MeasuringStrategy.BeforeDragging: + return dragging; + + default: + return !dragging; + } + } +} + +function useInitialValue(value, computeFn) { + return (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLazyMemo)(previousValue => { + if (!value) { + return null; + } + + if (previousValue) { + return previousValue; + } + + return typeof computeFn === 'function' ? computeFn(value) : value; + }, [computeFn, value]); +} + +function useInitialRect(node, measure) { + return useInitialValue(node, measure); +} + +/** + * Returns a new MutationObserver instance. + * If `MutationObserver` is undefined in the execution environment, returns `undefined`. + */ + +function useMutationObserver(_ref) { + let { + callback, + disabled + } = _ref; + const handleMutations = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useEvent)(callback); + const mutationObserver = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + if (disabled || typeof window === 'undefined' || typeof window.MutationObserver === 'undefined') { + return undefined; + } + + const { + MutationObserver + } = window; + return new MutationObserver(handleMutations); + }, [handleMutations, disabled]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + return () => mutationObserver == null ? void 0 : mutationObserver.disconnect(); + }, [mutationObserver]); + return mutationObserver; +} + +/** + * Returns a new ResizeObserver instance bound to the `onResize` callback. + * If `ResizeObserver` is undefined in the execution environment, returns `undefined`. + */ + +function useResizeObserver(_ref) { + let { + callback, + disabled + } = _ref; + const handleResize = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useEvent)(callback); + const resizeObserver = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + if (disabled || typeof window === 'undefined' || typeof window.ResizeObserver === 'undefined') { + return undefined; + } + + const { + ResizeObserver + } = window; + return new ResizeObserver(handleResize); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [disabled]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + return () => resizeObserver == null ? void 0 : resizeObserver.disconnect(); + }, [resizeObserver]); + return resizeObserver; +} + +function defaultMeasure(element) { + return new Rect(getClientRect(element), element); +} + +function useRect(element, measure, fallbackRect) { + if (measure === void 0) { + measure = defaultMeasure; + } + + const [rect, measureRect] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useReducer)(reducer, null); + const mutationObserver = useMutationObserver({ + callback(records) { + if (!element) { + return; + } + + for (const record of records) { + const { + type, + target + } = record; + + if (type === 'childList' && target instanceof HTMLElement && target.contains(element)) { + measureRect(); + break; + } + } + } + + }); + const resizeObserver = useResizeObserver({ + callback: measureRect + }); + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + measureRect(); + + if (element) { + resizeObserver == null ? void 0 : resizeObserver.observe(element); + mutationObserver == null ? void 0 : mutationObserver.observe(document.body, { + childList: true, + subtree: true + }); + } else { + resizeObserver == null ? void 0 : resizeObserver.disconnect(); + mutationObserver == null ? void 0 : mutationObserver.disconnect(); + } + }, [element]); + return rect; + + function reducer(currentRect) { + if (!element) { + return null; + } + + if (element.isConnected === false) { + var _ref; + + // Fall back to last rect we measured if the element is + // no longer connected to the DOM. + return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null; + } + + const newRect = measure(element); + + if (JSON.stringify(currentRect) === JSON.stringify(newRect)) { + return currentRect; + } + + return newRect; + } +} + +function useRectDelta(rect) { + const initialRect = useInitialValue(rect); + return getRectDelta(rect, initialRect); +} + +const defaultValue$1 = []; +function useScrollableAncestors(node) { + const previousNode = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(node); + const ancestors = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLazyMemo)(previousValue => { + if (!node) { + return defaultValue$1; + } + + if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) { + return previousValue; + } + + return getScrollableAncestors(node); + }, [node]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + previousNode.current = node; + }, [node]); + return ancestors; +} + +function useScrollOffsets(elements) { + const [scrollCoordinates, setScrollCoordinates] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const prevElements = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(elements); // To-do: Throttle the handleScroll callback + + const handleScroll = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(event => { + const scrollingElement = getScrollableElement(event.target); + + if (!scrollingElement) { + return; + } + + setScrollCoordinates(scrollCoordinates => { + if (!scrollCoordinates) { + return null; + } + + scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement)); + return new Map(scrollCoordinates); + }); + }, []); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + const previousElements = prevElements.current; + + if (elements !== previousElements) { + cleanup(previousElements); + const entries = elements.map(element => { + const scrollableElement = getScrollableElement(element); + + if (scrollableElement) { + scrollableElement.addEventListener('scroll', handleScroll, { + passive: true + }); + return [scrollableElement, getScrollCoordinates(scrollableElement)]; + } + + return null; + }).filter(entry => entry != null); + setScrollCoordinates(entries.length ? new Map(entries) : null); + prevElements.current = elements; + } + + return () => { + cleanup(elements); + cleanup(previousElements); + }; + + function cleanup(elements) { + elements.forEach(element => { + const scrollableElement = getScrollableElement(element); + scrollableElement == null ? void 0 : scrollableElement.removeEventListener('scroll', handleScroll); + }); + } + }, [handleScroll, elements]); + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + if (elements.length) { + return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.add)(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements); + } + + return defaultCoordinates; + }, [elements, scrollCoordinates]); +} + +function useScrollOffsetsDelta(scrollOffsets, dependencies) { + if (dependencies === void 0) { + dependencies = []; + } + + const initialScrollOffsets = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + initialScrollOffsets.current = null; + }, // eslint-disable-next-line react-hooks/exhaustive-deps + dependencies); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + const hasScrollOffsets = scrollOffsets !== defaultCoordinates; + + if (hasScrollOffsets && !initialScrollOffsets.current) { + initialScrollOffsets.current = scrollOffsets; + } + + if (!hasScrollOffsets && initialScrollOffsets.current) { + initialScrollOffsets.current = null; + } + }, [scrollOffsets]); + return initialScrollOffsets.current ? (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.subtract)(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates; +} + +function useSensorSetup(sensors) { + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.canUseDOM) { + return; + } + + const teardownFns = sensors.map(_ref => { + let { + sensor + } = _ref; + return sensor.setup == null ? void 0 : sensor.setup(); + }); + return () => { + for (const teardown of teardownFns) { + teardown == null ? void 0 : teardown(); + } + }; + }, // TO-DO: Sensors length could theoretically change which would not be a valid dependency + // eslint-disable-next-line react-hooks/exhaustive-deps + sensors.map(_ref2 => { + let { + sensor + } = _ref2; + return sensor; + })); +} + +function useSyntheticListeners(listeners, id) { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + return listeners.reduce((acc, _ref) => { + let { + eventName, + handler + } = _ref; + + acc[eventName] = event => { + handler(event, id); + }; + + return acc; + }, {}); + }, [listeners, id]); +} + +function useWindowRect(element) { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => element ? getWindowClientRect(element) : null, [element]); +} + +const defaultValue$2 = []; +function useRects(elements, measure) { + if (measure === void 0) { + measure = getClientRect; + } + + const [firstElement] = elements; + const windowRect = useWindowRect(firstElement ? (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(firstElement) : null); + const [rects, measureRects] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useReducer)(reducer, defaultValue$2); + const resizeObserver = useResizeObserver({ + callback: measureRects + }); + + if (elements.length > 0 && rects === defaultValue$2) { + measureRects(); + } + + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + if (elements.length) { + elements.forEach(element => resizeObserver == null ? void 0 : resizeObserver.observe(element)); + } else { + resizeObserver == null ? void 0 : resizeObserver.disconnect(); + measureRects(); + } + }, [elements]); + return rects; + + function reducer() { + if (!elements.length) { + return defaultValue$2; + } + + return elements.map(element => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element)); + } +} + +function getMeasurableNode(node) { + if (!node) { + return null; + } + + if (node.children.length > 1) { + return node; + } + + const firstChild = node.children[0]; + return (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isHTMLElement)(firstChild) ? firstChild : node; +} + +function useDragOverlayMeasuring(_ref) { + let { + measure + } = _ref; + const [rect, setRect] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const handleResize = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(entries => { + for (const { + target + } of entries) { + if ((0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isHTMLElement)(target)) { + setRect(rect => { + const newRect = measure(target); + return rect ? { ...rect, + width: newRect.width, + height: newRect.height + } : newRect; + }); + break; + } + } + }, [measure]); + const resizeObserver = useResizeObserver({ + callback: handleResize + }); + const handleNodeChange = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(element => { + const node = getMeasurableNode(element); + resizeObserver == null ? void 0 : resizeObserver.disconnect(); + + if (node) { + resizeObserver == null ? void 0 : resizeObserver.observe(node); + } + + setRect(node ? measure(node) : null); + }, [measure, resizeObserver]); + const [nodeRef, setRef] = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useNodeRef)(handleNodeChange); + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + nodeRef, + rect, + setRef + }), [rect, nodeRef, setRef]); +} + +const defaultSensors = [{ + sensor: PointerSensor, + options: {} +}, { + sensor: KeyboardSensor, + options: {} +}]; +const defaultData = { + current: {} +}; +const defaultMeasuringConfiguration = { + draggable: { + measure: getTransformAgnosticClientRect + }, + droppable: { + measure: getTransformAgnosticClientRect, + strategy: MeasuringStrategy.WhileDragging, + frequency: MeasuringFrequency.Optimized + }, + dragOverlay: { + measure: getClientRect + } +}; + +class DroppableContainersMap extends Map { + get(id) { + var _super$get; + + return id != null ? (_super$get = super.get(id)) != null ? _super$get : undefined : undefined; + } + + toArray() { + return Array.from(this.values()); + } + + getEnabled() { + return this.toArray().filter(_ref => { + let { + disabled + } = _ref; + return !disabled; + }); + } + + getNodeFor(id) { + var _this$get$node$curren, _this$get; + + return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : undefined; + } + +} + +const defaultPublicContext = { + activatorEvent: null, + active: null, + activeNode: null, + activeNodeRect: null, + collisions: null, + containerNodeRect: null, + draggableNodes: /*#__PURE__*/new Map(), + droppableRects: /*#__PURE__*/new Map(), + droppableContainers: /*#__PURE__*/new DroppableContainersMap(), + over: null, + dragOverlay: { + nodeRef: { + current: null + }, + rect: null, + setRef: noop + }, + scrollableAncestors: [], + scrollableAncestorRects: [], + measuringConfiguration: defaultMeasuringConfiguration, + measureDroppableContainers: noop, + windowRect: null, + measuringScheduled: false +}; +const defaultInternalContext = { + activatorEvent: null, + activators: [], + active: null, + activeNodeRect: null, + ariaDescribedById: { + draggable: '' + }, + dispatch: noop, + draggableNodes: /*#__PURE__*/new Map(), + over: null, + measureDroppableContainers: noop +}; +const InternalContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(defaultInternalContext); +const PublicContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(defaultPublicContext); + +function getInitialState() { + return { + draggable: { + active: null, + initialCoordinates: { + x: 0, + y: 0 + }, + nodes: new Map(), + translate: { + x: 0, + y: 0 + } + }, + droppable: { + containers: new DroppableContainersMap() + } + }; +} +function reducer(state, action) { + switch (action.type) { + case Action.DragStart: + return { ...state, + draggable: { ...state.draggable, + initialCoordinates: action.initialCoordinates, + active: action.active + } + }; + + case Action.DragMove: + if (!state.draggable.active) { + return state; + } + + return { ...state, + draggable: { ...state.draggable, + translate: { + x: action.coordinates.x - state.draggable.initialCoordinates.x, + y: action.coordinates.y - state.draggable.initialCoordinates.y + } + } + }; + + case Action.DragEnd: + case Action.DragCancel: + return { ...state, + draggable: { ...state.draggable, + active: null, + initialCoordinates: { + x: 0, + y: 0 + }, + translate: { + x: 0, + y: 0 + } + } + }; + + case Action.RegisterDroppable: + { + const { + element + } = action; + const { + id + } = element; + const containers = new DroppableContainersMap(state.droppable.containers); + containers.set(id, element); + return { ...state, + droppable: { ...state.droppable, + containers + } + }; + } + + case Action.SetDroppableDisabled: + { + const { + id, + key, + disabled + } = action; + const element = state.droppable.containers.get(id); + + if (!element || key !== element.key) { + return state; + } + + const containers = new DroppableContainersMap(state.droppable.containers); + containers.set(id, { ...element, + disabled + }); + return { ...state, + droppable: { ...state.droppable, + containers + } + }; + } + + case Action.UnregisterDroppable: + { + const { + id, + key + } = action; + const element = state.droppable.containers.get(id); + + if (!element || key !== element.key) { + return state; + } + + const containers = new DroppableContainersMap(state.droppable.containers); + containers.delete(id); + return { ...state, + droppable: { ...state.droppable, + containers + } + }; + } + + default: + { + return state; + } + } +} + +function RestoreFocus(_ref) { + let { + disabled + } = _ref; + const { + active, + activatorEvent, + draggableNodes + } = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(InternalContext); + const previousActivatorEvent = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.usePrevious)(activatorEvent); + const previousActiveId = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.usePrevious)(active == null ? void 0 : active.id); // Restore keyboard focus on the activator node + + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (disabled) { + return; + } + + if (!activatorEvent && previousActivatorEvent && previousActiveId != null) { + if (!(0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isKeyboardEvent)(previousActivatorEvent)) { + return; + } + + if (document.activeElement === previousActivatorEvent.target) { + // No need to restore focus + return; + } + + const draggableNode = draggableNodes.get(previousActiveId); + + if (!draggableNode) { + return; + } + + const { + activatorNode, + node + } = draggableNode; + + if (!activatorNode.current && !node.current) { + return; + } + + requestAnimationFrame(() => { + for (const element of [activatorNode.current, node.current]) { + if (!element) { + continue; + } + + const focusableNode = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.findFirstFocusableNode)(element); + + if (focusableNode) { + focusableNode.focus(); + break; + } + } + }); + } + }, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]); + return null; +} + +function applyModifiers(modifiers, _ref) { + let { + transform, + ...args + } = _ref; + return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => { + return modifier({ + transform: accumulator, + ...args + }); + }, transform) : transform; +} + +function useMeasuringConfiguration(config) { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + draggable: { ...defaultMeasuringConfiguration.draggable, + ...(config == null ? void 0 : config.draggable) + }, + droppable: { ...defaultMeasuringConfiguration.droppable, + ...(config == null ? void 0 : config.droppable) + }, + dragOverlay: { ...defaultMeasuringConfiguration.dragOverlay, + ...(config == null ? void 0 : config.dragOverlay) + } + }), // eslint-disable-next-line react-hooks/exhaustive-deps + [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]); +} + +function useLayoutShiftScrollCompensation(_ref) { + let { + activeNode, + measure, + initialRect, + config = true + } = _ref; + const initialized = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false); + const { + x, + y + } = typeof config === 'boolean' ? { + x: config, + y: config + } : config; + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + const disabled = !x && !y; + + if (disabled || !activeNode) { + initialized.current = false; + return; + } + + if (initialized.current || !initialRect) { + // Return early if layout shift scroll compensation was already attempted + // or if there is no initialRect to compare to. + return; + } // Get the most up to date node ref for the active draggable + + + const node = activeNode == null ? void 0 : activeNode.node.current; + + if (!node || node.isConnected === false) { + // Return early if there is no attached node ref or if the node is + // disconnected from the document. + return; + } + + const rect = measure(node); + const rectDelta = getRectDelta(rect, initialRect); + + if (!x) { + rectDelta.x = 0; + } + + if (!y) { + rectDelta.y = 0; + } // Only perform layout shift scroll compensation once + + + initialized.current = true; + + if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) { + const firstScrollableAncestor = getFirstScrollableAncestor(node); + + if (firstScrollableAncestor) { + firstScrollableAncestor.scrollBy({ + top: rectDelta.y, + left: rectDelta.x + }); + } + } + }, [activeNode, x, y, initialRect, measure]); +} + +const ActiveDraggableContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)({ ...defaultCoordinates, + scaleX: 1, + scaleY: 1 +}); +var Status; + +(function (Status) { + Status[Status["Uninitialized"] = 0] = "Uninitialized"; + Status[Status["Initializing"] = 1] = "Initializing"; + Status[Status["Initialized"] = 2] = "Initialized"; +})(Status || (Status = {})); + +const DndContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.memo)(function DndContext(_ref) { + var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect; + + let { + id, + accessibility, + autoScroll = true, + children, + sensors = defaultSensors, + collisionDetection = rectIntersection, + measuring, + modifiers, + ...props + } = _ref; + const store = (0,react__WEBPACK_IMPORTED_MODULE_0__.useReducer)(reducer, undefined, getInitialState); + const [state, dispatch] = store; + const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider(); + const [status, setStatus] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(Status.Uninitialized); + const isInitialized = status === Status.Initialized; + const { + draggable: { + active: activeId, + nodes: draggableNodes, + translate + }, + droppable: { + containers: droppableContainers + } + } = state; + const node = activeId ? draggableNodes.get(activeId) : null; + const activeRects = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({ + initial: null, + translated: null + }); + const active = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + var _node$data; + + return activeId != null ? { + id: activeId, + // It's possible for the active node to unmount while dragging + data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData, + rect: activeRects + } : null; + }, [activeId, node]); + const activeRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + const [activeSensor, setActiveSensor] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const [activatorEvent, setActivatorEvent] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const latestProps = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLatestValue)(props, Object.values(props)); + const draggableDescribedById = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useUniqueId)("DndDescribedBy", id); + const enabledDroppableContainers = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => droppableContainers.getEnabled(), [droppableContainers]); + const measuringConfiguration = useMeasuringConfiguration(measuring); + const { + droppableRects, + measureDroppableContainers, + measuringScheduled + } = useDroppableMeasuring(enabledDroppableContainers, { + dragging: isInitialized, + dependencies: [translate.x, translate.y], + config: measuringConfiguration.droppable + }); + const activeNode = useCachedNode(draggableNodes, activeId); + const activationCoordinates = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => activatorEvent ? (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getEventCoordinates)(activatorEvent) : null, [activatorEvent]); + const autoScrollOptions = getAutoScrollerOptions(); + const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure); + useLayoutShiftScrollCompensation({ + activeNode: activeId ? draggableNodes.get(activeId) : null, + config: autoScrollOptions.layoutShiftCompensation, + initialRect: initialActiveNodeRect, + measure: measuringConfiguration.draggable.measure + }); + const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect); + const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null); + const sensorContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({ + activatorEvent: null, + active: null, + activeNode, + collisionRect: null, + collisions: null, + droppableRects, + draggableNodes, + draggingNode: null, + draggingNodeRect: null, + droppableContainers, + over: null, + scrollableAncestors: [], + scrollAdjustedTranslate: null + }); + const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id); + const dragOverlay = useDragOverlayMeasuring({ + measure: measuringConfiguration.dragOverlay.measure + }); // Use the rect of the drag overlay if it is mounted + + const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode; + const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null; + const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect); // The delta between the previous and new position of the draggable node + // is only relevant when there is no drag overlay + + const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect); // Get the window rect of the dragging node + + const windowRect = useWindowRect(draggingNode ? (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(draggingNode) : null); // Get scrollable ancestors of the dragging node + + const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null); + const scrollableAncestorRects = useRects(scrollableAncestors); // Apply modifiers + + const modifiedTranslate = applyModifiers(modifiers, { + transform: { + x: translate.x - nodeRectDelta.x, + y: translate.y - nodeRectDelta.y, + scaleX: 1, + scaleY: 1 + }, + activatorEvent, + active, + activeNodeRect, + containerNodeRect, + draggingNodeRect, + over: sensorContext.current.over, + overlayNodeRect: dragOverlay.rect, + scrollableAncestors, + scrollableAncestorRects, + windowRect + }); + const pointerCoordinates = activationCoordinates ? (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.add)(activationCoordinates, translate) : null; + const scrollOffsets = useScrollOffsets(scrollableAncestors); // Represents the scroll delta since dragging was initiated + + const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets); // Represents the scroll delta since the last time the active node rect was measured + + const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]); + const scrollAdjustedTranslate = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.add)(modifiedTranslate, scrollAdjustment); + const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null; + const collisions = active && collisionRect ? collisionDetection({ + active, + collisionRect, + droppableRects, + droppableContainers: enabledDroppableContainers, + pointerCoordinates + }) : null; + const overId = getFirstCollision(collisions, 'id'); + const [over, setOver] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); // When there is no drag overlay used, we need to account for the + // window scroll delta + + const appliedTranslate = usesDragOverlay ? modifiedTranslate : (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.add)(modifiedTranslate, activeNodeScrollDelta); + const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect); + const instantiateSensor = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((event, _ref2) => { + let { + sensor: Sensor, + options + } = _ref2; + + if (activeRef.current == null) { + return; + } + + const activeNode = draggableNodes.get(activeRef.current); + + if (!activeNode) { + return; + } + + const activatorEvent = event.nativeEvent; + const sensorInstance = new Sensor({ + active: activeRef.current, + activeNode, + event: activatorEvent, + options, + // Sensors need to be instantiated with refs for arguments that change over time + // otherwise they are frozen in time with the stale arguments + context: sensorContext, + + onStart(initialCoordinates) { + const id = activeRef.current; + + if (id == null) { + return; + } + + const draggableNode = draggableNodes.get(id); + + if (!draggableNode) { + return; + } + + const { + onDragStart + } = latestProps.current; + const event = { + active: { + id, + data: draggableNode.data, + rect: activeRects + } + }; + (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.unstable_batchedUpdates)(() => { + onDragStart == null ? void 0 : onDragStart(event); + setStatus(Status.Initializing); + dispatch({ + type: Action.DragStart, + initialCoordinates, + active: id + }); + dispatchMonitorEvent({ + type: 'onDragStart', + event + }); + }); + }, + + onMove(coordinates) { + dispatch({ + type: Action.DragMove, + coordinates + }); + }, + + onEnd: createHandler(Action.DragEnd), + onCancel: createHandler(Action.DragCancel) + }); + (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.unstable_batchedUpdates)(() => { + setActiveSensor(sensorInstance); + setActivatorEvent(event.nativeEvent); + }); + + function createHandler(type) { + return async function handler() { + const { + active, + collisions, + over, + scrollAdjustedTranslate + } = sensorContext.current; + let event = null; + + if (active && scrollAdjustedTranslate) { + const { + cancelDrop + } = latestProps.current; + event = { + activatorEvent, + active: active, + collisions, + delta: scrollAdjustedTranslate, + over + }; + + if (type === Action.DragEnd && typeof cancelDrop === 'function') { + const shouldCancel = await Promise.resolve(cancelDrop(event)); + + if (shouldCancel) { + type = Action.DragCancel; + } + } + } + + activeRef.current = null; + (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.unstable_batchedUpdates)(() => { + dispatch({ + type + }); + setStatus(Status.Uninitialized); + setOver(null); + setActiveSensor(null); + setActivatorEvent(null); + const eventName = type === Action.DragEnd ? 'onDragEnd' : 'onDragCancel'; + + if (event) { + const handler = latestProps.current[eventName]; + handler == null ? void 0 : handler(event); + dispatchMonitorEvent({ + type: eventName, + event + }); + } + }); + }; + } + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [draggableNodes]); + const bindActivatorToSensorInstantiator = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((handler, sensor) => { + return (event, active) => { + const nativeEvent = event.nativeEvent; + const activeDraggableNode = draggableNodes.get(active); + + if ( // Another sensor is already instantiating + activeRef.current !== null || // No active draggable + !activeDraggableNode || // Event has already been captured + nativeEvent.dndKit || nativeEvent.defaultPrevented) { + return; + } + + const activationContext = { + active: activeDraggableNode + }; + const shouldActivate = handler(event, sensor.options, activationContext); + + if (shouldActivate === true) { + nativeEvent.dndKit = { + capturedBy: sensor.sensor + }; + activeRef.current = active; + instantiateSensor(event, sensor); + } + }; + }, [draggableNodes, instantiateSensor]); + const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator); + useSensorSetup(sensors); + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + if (activeNodeRect && status === Status.Initializing) { + setStatus(Status.Initialized); + } + }, [activeNodeRect, status]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + const { + onDragMove + } = latestProps.current; + const { + active, + activatorEvent, + collisions, + over + } = sensorContext.current; + + if (!active || !activatorEvent) { + return; + } + + const event = { + active, + activatorEvent, + collisions, + delta: { + x: scrollAdjustedTranslate.x, + y: scrollAdjustedTranslate.y + }, + over + }; + (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.unstable_batchedUpdates)(() => { + onDragMove == null ? void 0 : onDragMove(event); + dispatchMonitorEvent({ + type: 'onDragMove', + event + }); + }); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + const { + active, + activatorEvent, + collisions, + droppableContainers, + scrollAdjustedTranslate + } = sensorContext.current; + + if (!active || activeRef.current == null || !activatorEvent || !scrollAdjustedTranslate) { + return; + } + + const { + onDragOver + } = latestProps.current; + const overContainer = droppableContainers.get(overId); + const over = overContainer && overContainer.rect.current ? { + id: overContainer.id, + rect: overContainer.rect.current, + data: overContainer.data, + disabled: overContainer.disabled + } : null; + const event = { + active, + activatorEvent, + collisions, + delta: { + x: scrollAdjustedTranslate.x, + y: scrollAdjustedTranslate.y + }, + over + }; + (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.unstable_batchedUpdates)(() => { + setOver(over); + onDragOver == null ? void 0 : onDragOver(event); + dispatchMonitorEvent({ + type: 'onDragOver', + event + }); + }); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [overId]); + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + sensorContext.current = { + activatorEvent, + active, + activeNode, + collisionRect, + collisions, + droppableRects, + draggableNodes, + draggingNode, + draggingNodeRect, + droppableContainers, + over, + scrollableAncestors, + scrollAdjustedTranslate + }; + activeRects.current = { + initial: draggingNodeRect, + translated: collisionRect + }; + }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]); + useAutoScroller({ ...autoScrollOptions, + delta: translate, + draggingRect: collisionRect, + pointerCoordinates, + scrollableAncestors, + scrollableAncestorRects + }); + const publicContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + const context = { + active, + activeNode, + activeNodeRect, + activatorEvent, + collisions, + containerNodeRect, + dragOverlay, + draggableNodes, + droppableContainers, + droppableRects, + over, + measureDroppableContainers, + scrollableAncestors, + scrollableAncestorRects, + measuringConfiguration, + measuringScheduled, + windowRect + }; + return context; + }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]); + const internalContext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + const context = { + activatorEvent, + activators, + active, + activeNodeRect, + ariaDescribedById: { + draggable: draggableDescribedById + }, + dispatch, + draggableNodes, + over, + measureDroppableContainers + }; + return context; + }, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]); + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(DndMonitorContext.Provider, { + value: registerMonitorListener + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(InternalContext.Provider, { + value: internalContext + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(PublicContext.Provider, { + value: publicContext + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ActiveDraggableContext.Provider, { + value: transform + }, children)), react__WEBPACK_IMPORTED_MODULE_0___default().createElement(RestoreFocus, { + disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false + })), react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Accessibility, { ...accessibility, + hiddenTextDescribedById: draggableDescribedById + })); + + function getAutoScrollerOptions() { + const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false; + const autoScrollGloballyDisabled = typeof autoScroll === 'object' ? autoScroll.enabled === false : autoScroll === false; + const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled; + + if (typeof autoScroll === 'object') { + return { ...autoScroll, + enabled + }; + } + + return { + enabled + }; + } +}); + +const NullContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null); +const defaultRole = 'button'; +const ID_PREFIX = 'Droppable'; +function useDraggable(_ref) { + let { + id, + data, + disabled = false, + attributes + } = _ref; + const key = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useUniqueId)(ID_PREFIX); + const { + activators, + activatorEvent, + active, + activeNodeRect, + ariaDescribedById, + draggableNodes, + over + } = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(InternalContext); + const { + role = defaultRole, + roleDescription = 'draggable', + tabIndex = 0 + } = attributes != null ? attributes : {}; + const isDragging = (active == null ? void 0 : active.id) === id; + const transform = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(isDragging ? ActiveDraggableContext : NullContext); + const [node, setNodeRef] = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useNodeRef)(); + const [activatorNode, setActivatorNodeRef] = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useNodeRef)(); + const listeners = useSyntheticListeners(activators, id); + const dataRef = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLatestValue)(data); + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + draggableNodes.set(id, { + id, + key, + node, + activatorNode, + data: dataRef + }); + return () => { + const node = draggableNodes.get(id); + + if (node && node.key === key) { + draggableNodes.delete(id); + } + }; + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [draggableNodes, id]); + const memoizedAttributes = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + role, + tabIndex, + 'aria-disabled': disabled, + 'aria-pressed': isDragging && role === defaultRole ? true : undefined, + 'aria-roledescription': roleDescription, + 'aria-describedby': ariaDescribedById.draggable + }), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]); + return { + active, + activatorEvent, + activeNodeRect, + attributes: memoizedAttributes, + isDragging, + listeners: disabled ? undefined : listeners, + node, + over, + setNodeRef, + setActivatorNodeRef, + transform + }; +} + +function useDndContext() { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(PublicContext); +} + +const ID_PREFIX$1 = 'Droppable'; +const defaultResizeObserverConfig = { + timeout: 25 +}; +function useDroppable(_ref) { + let { + data, + disabled = false, + id, + resizeObserverConfig + } = _ref; + const key = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useUniqueId)(ID_PREFIX$1); + const { + active, + dispatch, + over, + measureDroppableContainers + } = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(InternalContext); + const previous = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({ + disabled + }); + const resizeObserverConnected = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false); + const rect = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + const callbackId = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + const { + disabled: resizeObserverDisabled, + updateMeasurementsFor, + timeout: resizeObserverTimeout + } = { ...defaultResizeObserverConfig, + ...resizeObserverConfig + }; + const ids = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLatestValue)(updateMeasurementsFor != null ? updateMeasurementsFor : id); + const handleResize = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + if (!resizeObserverConnected.current) { + // ResizeObserver invokes the `handleResize` callback as soon as `observe` is called, + // assuming the element is rendered and displayed. + resizeObserverConnected.current = true; + return; + } + + if (callbackId.current != null) { + clearTimeout(callbackId.current); + } + + callbackId.current = setTimeout(() => { + measureDroppableContainers(Array.isArray(ids.current) ? ids.current : [ids.current]); + callbackId.current = null; + }, resizeObserverTimeout); + }, //eslint-disable-next-line react-hooks/exhaustive-deps + [resizeObserverTimeout]); + const resizeObserver = useResizeObserver({ + callback: handleResize, + disabled: resizeObserverDisabled || !active + }); + const handleNodeChange = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((newElement, previousElement) => { + if (!resizeObserver) { + return; + } + + if (previousElement) { + resizeObserver.unobserve(previousElement); + resizeObserverConnected.current = false; + } + + if (newElement) { + resizeObserver.observe(newElement); + } + }, [resizeObserver]); + const [nodeRef, setNodeRef] = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useNodeRef)(handleNodeChange); + const dataRef = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useLatestValue)(data); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (!resizeObserver || !nodeRef.current) { + return; + } + + resizeObserver.disconnect(); + resizeObserverConnected.current = false; + resizeObserver.observe(nodeRef.current); + }, [nodeRef, resizeObserver]); + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + dispatch({ + type: Action.RegisterDroppable, + element: { + id, + key, + disabled, + node: nodeRef, + rect, + data: dataRef + } + }); + return () => dispatch({ + type: Action.UnregisterDroppable, + key, + id + }); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [id]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (disabled !== previous.current.disabled) { + dispatch({ + type: Action.SetDroppableDisabled, + id, + key, + disabled + }); + previous.current.disabled = disabled; + } + }, [id, key, disabled, dispatch]); + return { + active, + rect, + isOver: (over == null ? void 0 : over.id) === id, + node: nodeRef, + over, + setNodeRef + }; +} + +function AnimationManager(_ref) { + let { + animation, + children + } = _ref; + const [clonedChildren, setClonedChildren] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const [element, setElement] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const previousChildren = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.usePrevious)(children); + + if (!children && !clonedChildren && previousChildren) { + setClonedChildren(previousChildren); + } + + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + if (!element) { + return; + } + + const key = clonedChildren == null ? void 0 : clonedChildren.key; + const id = clonedChildren == null ? void 0 : clonedChildren.props.id; + + if (key == null || id == null) { + setClonedChildren(null); + return; + } + + Promise.resolve(animation(id, element)).then(() => { + setClonedChildren(null); + }); + }, [animation, clonedChildren, element]); + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, children, clonedChildren ? (0,react__WEBPACK_IMPORTED_MODULE_0__.cloneElement)(clonedChildren, { + ref: setElement + }) : null); +} + +const defaultTransform = { + x: 0, + y: 0, + scaleX: 1, + scaleY: 1 +}; +function NullifiedContextProvider(_ref) { + let { + children + } = _ref; + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(InternalContext.Provider, { + value: defaultInternalContext + }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(ActiveDraggableContext.Provider, { + value: defaultTransform + }, children)); +} + +const baseStyles = { + position: 'fixed', + touchAction: 'none' +}; + +const defaultTransition = activatorEvent => { + const isKeyboardActivator = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isKeyboardEvent)(activatorEvent); + return isKeyboardActivator ? 'transform 250ms ease' : undefined; +}; + +const PositionedOverlay = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)((_ref, ref) => { + let { + as, + activatorEvent, + adjustScale, + children, + className, + rect, + style, + transform, + transition = defaultTransition + } = _ref; + + if (!rect) { + return null; + } + + const scaleAdjustedTransform = adjustScale ? transform : { ...transform, + scaleX: 1, + scaleY: 1 + }; + const styles = { ...baseStyles, + width: rect.width, + height: rect.height, + top: rect.top, + left: rect.left, + transform: _dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.CSS.Transform.toString(scaleAdjustedTransform), + transformOrigin: adjustScale && activatorEvent ? getRelativeTransformOrigin(activatorEvent, rect) : undefined, + transition: typeof transition === 'function' ? transition(activatorEvent) : transition, + ...style + }; + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(as, { + className, + style: styles, + ref + }, children); +}); + +const defaultDropAnimationSideEffects = options => _ref => { + let { + active, + dragOverlay + } = _ref; + const originalStyles = {}; + const { + styles, + className + } = options; + + if (styles != null && styles.active) { + for (const [key, value] of Object.entries(styles.active)) { + if (value === undefined) { + continue; + } + + originalStyles[key] = active.node.style.getPropertyValue(key); + active.node.style.setProperty(key, value); + } + } + + if (styles != null && styles.dragOverlay) { + for (const [key, value] of Object.entries(styles.dragOverlay)) { + if (value === undefined) { + continue; + } + + dragOverlay.node.style.setProperty(key, value); + } + } + + if (className != null && className.active) { + active.node.classList.add(className.active); + } + + if (className != null && className.dragOverlay) { + dragOverlay.node.classList.add(className.dragOverlay); + } + + return function cleanup() { + for (const [key, value] of Object.entries(originalStyles)) { + active.node.style.setProperty(key, value); + } + + if (className != null && className.active) { + active.node.classList.remove(className.active); + } + }; +}; + +const defaultKeyframeResolver = _ref2 => { + let { + transform: { + initial, + final + } + } = _ref2; + return [{ + transform: _dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.CSS.Transform.toString(initial) + }, { + transform: _dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.CSS.Transform.toString(final) + }]; +}; + +const defaultDropAnimationConfiguration = { + duration: 250, + easing: 'ease', + keyframes: defaultKeyframeResolver, + sideEffects: /*#__PURE__*/defaultDropAnimationSideEffects({ + styles: { + active: { + opacity: '0' + } + } + }) +}; +function useDropAnimation(_ref3) { + let { + config, + draggableNodes, + droppableContainers, + measuringConfiguration + } = _ref3; + return (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useEvent)((id, node) => { + if (config === null) { + return; + } + + const activeDraggable = draggableNodes.get(id); + + if (!activeDraggable) { + return; + } + + const activeNode = activeDraggable.node.current; + + if (!activeNode) { + return; + } + + const measurableNode = getMeasurableNode(node); + + if (!measurableNode) { + return; + } + + const { + transform + } = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.getWindow)(node).getComputedStyle(node); + const parsedTransform = parseTransform(transform); + + if (!parsedTransform) { + return; + } + + const animation = typeof config === 'function' ? config : createDefaultDropAnimation(config); + scrollIntoViewIfNeeded(activeNode, measuringConfiguration.draggable.measure); + return animation({ + active: { + id, + data: activeDraggable.data, + node: activeNode, + rect: measuringConfiguration.draggable.measure(activeNode) + }, + draggableNodes, + dragOverlay: { + node, + rect: measuringConfiguration.dragOverlay.measure(measurableNode) + }, + droppableContainers, + measuringConfiguration, + transform: parsedTransform + }); + }); +} + +function createDefaultDropAnimation(options) { + const { + duration, + easing, + sideEffects, + keyframes + } = { ...defaultDropAnimationConfiguration, + ...options + }; + return _ref4 => { + let { + active, + dragOverlay, + transform, + ...rest + } = _ref4; + + if (!duration) { + // Do not animate if animation duration is zero. + return; + } + + const delta = { + x: dragOverlay.rect.left - active.rect.left, + y: dragOverlay.rect.top - active.rect.top + }; + const scale = { + scaleX: transform.scaleX !== 1 ? active.rect.width * transform.scaleX / dragOverlay.rect.width : 1, + scaleY: transform.scaleY !== 1 ? active.rect.height * transform.scaleY / dragOverlay.rect.height : 1 + }; + const finalTransform = { + x: transform.x - delta.x, + y: transform.y - delta.y, + ...scale + }; + const animationKeyframes = keyframes({ ...rest, + active, + dragOverlay, + transform: { + initial: transform, + final: finalTransform + } + }); + const [firstKeyframe] = animationKeyframes; + const lastKeyframe = animationKeyframes[animationKeyframes.length - 1]; + + if (JSON.stringify(firstKeyframe) === JSON.stringify(lastKeyframe)) { + // The start and end keyframes are the same, infer that there is no animation needed. + return; + } + + const cleanup = sideEffects == null ? void 0 : sideEffects({ + active, + dragOverlay, + ...rest + }); + const animation = dragOverlay.node.animate(animationKeyframes, { + duration, + easing, + fill: 'forwards' + }); + return new Promise(resolve => { + animation.onfinish = () => { + cleanup == null ? void 0 : cleanup(); + resolve(); + }; + }); + }; +} + +let key = 0; +function useKey(id) { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + if (id == null) { + return; + } + + key++; + return key; + }, [id]); +} + +const DragOverlay = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().memo(_ref => { + let { + adjustScale = false, + children, + dropAnimation: dropAnimationConfig, + style, + transition, + modifiers, + wrapperElement = 'div', + className, + zIndex = 999 + } = _ref; + const { + activatorEvent, + active, + activeNodeRect, + containerNodeRect, + draggableNodes, + droppableContainers, + dragOverlay, + over, + measuringConfiguration, + scrollableAncestors, + scrollableAncestorRects, + windowRect + } = useDndContext(); + const transform = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(ActiveDraggableContext); + const key = useKey(active == null ? void 0 : active.id); + const modifiedTransform = applyModifiers(modifiers, { + activatorEvent, + active, + activeNodeRect, + containerNodeRect, + draggingNodeRect: dragOverlay.rect, + over, + overlayNodeRect: dragOverlay.rect, + scrollableAncestors, + scrollableAncestorRects, + transform, + windowRect + }); + const initialRect = useInitialValue(activeNodeRect); + const dropAnimation = useDropAnimation({ + config: dropAnimationConfig, + draggableNodes, + droppableContainers, + measuringConfiguration + }); // We need to wait for the active node to be measured before connecting the drag overlay ref + // otherwise collisions can be computed against a mispositioned drag overlay + + const ref = initialRect ? dragOverlay.setRef : undefined; + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(NullifiedContextProvider, null, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(AnimationManager, { + animation: dropAnimation + }, active && key ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement(PositionedOverlay, { + key: key, + id: active.id, + ref: ref, + as: wrapperElement, + activatorEvent: activatorEvent, + adjustScale: adjustScale, + className: className, + transition: transition, + rect: initialRect, + style: { + zIndex, + ...style + }, + transform: modifiedTransform + }, children) : null)); +}); + + +//# sourceMappingURL=core.esm.js.map + + +/***/ }), + +/***/ "./node_modules/@dnd-kit/modifiers/dist/modifiers.esm.js": +/*!***************************************************************!*\ + !*** ./node_modules/@dnd-kit/modifiers/dist/modifiers.esm.js ***! + \***************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "createSnapModifier": function() { return /* binding */ createSnapModifier; }, +/* harmony export */ "restrictToFirstScrollableAncestor": function() { return /* binding */ restrictToFirstScrollableAncestor; }, +/* harmony export */ "restrictToHorizontalAxis": function() { return /* binding */ restrictToHorizontalAxis; }, +/* harmony export */ "restrictToParentElement": function() { return /* binding */ restrictToParentElement; }, +/* harmony export */ "restrictToVerticalAxis": function() { return /* binding */ restrictToVerticalAxis; }, +/* harmony export */ "restrictToWindowEdges": function() { return /* binding */ restrictToWindowEdges; }, +/* harmony export */ "snapCenterToCursor": function() { return /* binding */ snapCenterToCursor; } +/* harmony export */ }); +/* harmony import */ var _dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @dnd-kit/utilities */ "./node_modules/@dnd-kit/utilities/dist/utilities.esm.js"); + + +function createSnapModifier(gridSize) { + return _ref => { + let { + transform + } = _ref; + return { ...transform, + x: Math.ceil(transform.x / gridSize) * gridSize, + y: Math.ceil(transform.y / gridSize) * gridSize + }; + }; +} + +const restrictToHorizontalAxis = _ref => { + let { + transform + } = _ref; + return { ...transform, + y: 0 + }; +}; + +function restrictToBoundingRect(transform, rect, boundingRect) { + const value = { ...transform + }; + + if (rect.top + transform.y <= boundingRect.top) { + value.y = boundingRect.top - rect.top; + } else if (rect.bottom + transform.y >= boundingRect.top + boundingRect.height) { + value.y = boundingRect.top + boundingRect.height - rect.bottom; + } + + if (rect.left + transform.x <= boundingRect.left) { + value.x = boundingRect.left - rect.left; + } else if (rect.right + transform.x >= boundingRect.left + boundingRect.width) { + value.x = boundingRect.left + boundingRect.width - rect.right; + } + + return value; +} + +const restrictToParentElement = _ref => { + let { + containerNodeRect, + draggingNodeRect, + transform + } = _ref; + + if (!draggingNodeRect || !containerNodeRect) { + return transform; + } + + return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect); +}; + +const restrictToFirstScrollableAncestor = _ref => { + let { + draggingNodeRect, + transform, + scrollableAncestorRects + } = _ref; + const firstScrollableAncestorRect = scrollableAncestorRects[0]; + + if (!draggingNodeRect || !firstScrollableAncestorRect) { + return transform; + } + + return restrictToBoundingRect(transform, draggingNodeRect, firstScrollableAncestorRect); +}; + +const restrictToVerticalAxis = _ref => { + let { + transform + } = _ref; + return { ...transform, + x: 0 + }; +}; + +const restrictToWindowEdges = _ref => { + let { + transform, + draggingNodeRect, + windowRect + } = _ref; + + if (!draggingNodeRect || !windowRect) { + return transform; + } + + return restrictToBoundingRect(transform, draggingNodeRect, windowRect); +}; + +const snapCenterToCursor = _ref => { + let { + activatorEvent, + draggingNodeRect, + transform + } = _ref; + + if (draggingNodeRect && activatorEvent) { + const activatorCoordinates = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_0__.getEventCoordinates)(activatorEvent); + + if (!activatorCoordinates) { + return transform; + } + + const offsetX = activatorCoordinates.x - draggingNodeRect.left; + const offsetY = activatorCoordinates.y - draggingNodeRect.top; + return { ...transform, + x: transform.x + offsetX - draggingNodeRect.width / 2, + y: transform.y + offsetY - draggingNodeRect.height / 2 + }; + } + + return transform; +}; + + +//# sourceMappingURL=modifiers.esm.js.map + + +/***/ }), + +/***/ "./node_modules/@dnd-kit/sortable/dist/sortable.esm.js": +/*!*************************************************************!*\ + !*** ./node_modules/@dnd-kit/sortable/dist/sortable.esm.js ***! + \*************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SortableContext": function() { return /* binding */ SortableContext; }, +/* harmony export */ "arrayMove": function() { return /* binding */ arrayMove; }, +/* harmony export */ "arraySwap": function() { return /* binding */ arraySwap; }, +/* harmony export */ "defaultAnimateLayoutChanges": function() { return /* binding */ defaultAnimateLayoutChanges; }, +/* harmony export */ "defaultNewIndexGetter": function() { return /* binding */ defaultNewIndexGetter; }, +/* harmony export */ "hasSortableData": function() { return /* binding */ hasSortableData; }, +/* harmony export */ "horizontalListSortingStrategy": function() { return /* binding */ horizontalListSortingStrategy; }, +/* harmony export */ "rectSortingStrategy": function() { return /* binding */ rectSortingStrategy; }, +/* harmony export */ "rectSwappingStrategy": function() { return /* binding */ rectSwappingStrategy; }, +/* harmony export */ "sortableKeyboardCoordinates": function() { return /* binding */ sortableKeyboardCoordinates; }, +/* harmony export */ "useSortable": function() { return /* binding */ useSortable; }, +/* harmony export */ "verticalListSortingStrategy": function() { return /* binding */ verticalListSortingStrategy; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @dnd-kit/core */ "./node_modules/@dnd-kit/core/dist/core.esm.js"); +/* harmony import */ var _dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @dnd-kit/utilities */ "./node_modules/@dnd-kit/utilities/dist/utilities.esm.js"); + + + + +/** + * Move an array item to a different position. Returns a new array with the item moved to the new position. + */ +function arrayMove(array, from, to) { + const newArray = array.slice(); + newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]); + return newArray; +} + +/** + * Swap an array item to a different position. Returns a new array with the item swapped to the new position. + */ +function arraySwap(array, from, to) { + const newArray = array.slice(); + newArray[from] = array[to]; + newArray[to] = array[from]; + return newArray; +} + +function getSortedRects(items, rects) { + return items.reduce((accumulator, id, index) => { + const rect = rects.get(id); + + if (rect) { + accumulator[index] = rect; + } + + return accumulator; + }, Array(items.length)); +} + +function isValidIndex(index) { + return index !== null && index >= 0; +} + +function itemsEqual(a, b) { + if (a === b) { + return true; + } + + if (a.length !== b.length) { + return false; + } + + for (let i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { + return false; + } + } + + return true; +} + +function normalizeDisabled(disabled) { + if (typeof disabled === 'boolean') { + return { + draggable: disabled, + droppable: disabled + }; + } + + return disabled; +} + +// To-do: We should be calculating scale transformation +const defaultScale = { + scaleX: 1, + scaleY: 1 +}; +const horizontalListSortingStrategy = _ref => { + var _rects$activeIndex; + + let { + rects, + activeNodeRect: fallbackActiveRect, + activeIndex, + overIndex, + index + } = _ref; + const activeNodeRect = (_rects$activeIndex = rects[activeIndex]) != null ? _rects$activeIndex : fallbackActiveRect; + + if (!activeNodeRect) { + return null; + } + + const itemGap = getItemGap(rects, index, activeIndex); + + if (index === activeIndex) { + const newIndexRect = rects[overIndex]; + + if (!newIndexRect) { + return null; + } + + return { + x: activeIndex < overIndex ? newIndexRect.left + newIndexRect.width - (activeNodeRect.left + activeNodeRect.width) : newIndexRect.left - activeNodeRect.left, + y: 0, + ...defaultScale + }; + } + + if (index > activeIndex && index <= overIndex) { + return { + x: -activeNodeRect.width - itemGap, + y: 0, + ...defaultScale + }; + } + + if (index < activeIndex && index >= overIndex) { + return { + x: activeNodeRect.width + itemGap, + y: 0, + ...defaultScale + }; + } + + return { + x: 0, + y: 0, + ...defaultScale + }; +}; + +function getItemGap(rects, index, activeIndex) { + const currentRect = rects[index]; + const previousRect = rects[index - 1]; + const nextRect = rects[index + 1]; + + if (!currentRect || !previousRect && !nextRect) { + return 0; + } + + if (activeIndex < index) { + return previousRect ? currentRect.left - (previousRect.left + previousRect.width) : nextRect.left - (currentRect.left + currentRect.width); + } + + return nextRect ? nextRect.left - (currentRect.left + currentRect.width) : currentRect.left - (previousRect.left + previousRect.width); +} + +const rectSortingStrategy = _ref => { + let { + rects, + activeIndex, + overIndex, + index + } = _ref; + const newRects = arrayMove(rects, overIndex, activeIndex); + const oldRect = rects[index]; + const newRect = newRects[index]; + + if (!newRect || !oldRect) { + return null; + } + + return { + x: newRect.left - oldRect.left, + y: newRect.top - oldRect.top, + scaleX: newRect.width / oldRect.width, + scaleY: newRect.height / oldRect.height + }; +}; + +const rectSwappingStrategy = _ref => { + let { + activeIndex, + index, + rects, + overIndex + } = _ref; + let oldRect; + let newRect; + + if (index === activeIndex) { + oldRect = rects[index]; + newRect = rects[overIndex]; + } + + if (index === overIndex) { + oldRect = rects[index]; + newRect = rects[activeIndex]; + } + + if (!newRect || !oldRect) { + return null; + } + + return { + x: newRect.left - oldRect.left, + y: newRect.top - oldRect.top, + scaleX: newRect.width / oldRect.width, + scaleY: newRect.height / oldRect.height + }; +}; + +// To-do: We should be calculating scale transformation +const defaultScale$1 = { + scaleX: 1, + scaleY: 1 +}; +const verticalListSortingStrategy = _ref => { + var _rects$activeIndex; + + let { + activeIndex, + activeNodeRect: fallbackActiveRect, + index, + rects, + overIndex + } = _ref; + const activeNodeRect = (_rects$activeIndex = rects[activeIndex]) != null ? _rects$activeIndex : fallbackActiveRect; + + if (!activeNodeRect) { + return null; + } + + if (index === activeIndex) { + const overIndexRect = rects[overIndex]; + + if (!overIndexRect) { + return null; + } + + return { + x: 0, + y: activeIndex < overIndex ? overIndexRect.top + overIndexRect.height - (activeNodeRect.top + activeNodeRect.height) : overIndexRect.top - activeNodeRect.top, + ...defaultScale$1 + }; + } + + const itemGap = getItemGap$1(rects, index, activeIndex); + + if (index > activeIndex && index <= overIndex) { + return { + x: 0, + y: -activeNodeRect.height - itemGap, + ...defaultScale$1 + }; + } + + if (index < activeIndex && index >= overIndex) { + return { + x: 0, + y: activeNodeRect.height + itemGap, + ...defaultScale$1 + }; + } + + return { + x: 0, + y: 0, + ...defaultScale$1 + }; +}; + +function getItemGap$1(clientRects, index, activeIndex) { + const currentRect = clientRects[index]; + const previousRect = clientRects[index - 1]; + const nextRect = clientRects[index + 1]; + + if (!currentRect) { + return 0; + } + + if (activeIndex < index) { + return previousRect ? currentRect.top - (previousRect.top + previousRect.height) : nextRect ? nextRect.top - (currentRect.top + currentRect.height) : 0; + } + + return nextRect ? nextRect.top - (currentRect.top + currentRect.height) : previousRect ? currentRect.top - (previousRect.top + previousRect.height) : 0; +} + +const ID_PREFIX = 'Sortable'; +const Context = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext({ + activeIndex: -1, + containerId: ID_PREFIX, + disableTransforms: false, + items: [], + overIndex: -1, + useDragOverlay: false, + sortedRects: [], + strategy: rectSortingStrategy, + disabled: { + draggable: false, + droppable: false + } +}); +function SortableContext(_ref) { + let { + children, + id, + items: userDefinedItems, + strategy = rectSortingStrategy, + disabled: disabledProp = false + } = _ref; + const { + active, + dragOverlay, + droppableRects, + over, + measureDroppableContainers + } = (0,_dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.useDndContext)(); + const containerId = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useUniqueId)(ID_PREFIX, id); + const useDragOverlay = Boolean(dragOverlay.rect !== null); + const items = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => userDefinedItems.map(item => typeof item === 'object' && 'id' in item ? item.id : item), [userDefinedItems]); + const isDragging = active != null; + const activeIndex = active ? items.indexOf(active.id) : -1; + const overIndex = over ? items.indexOf(over.id) : -1; + const previousItemsRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(items); + const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current); + const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged; + const disabled = normalizeDisabled(disabledProp); + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + if (itemsHaveChanged && isDragging) { + measureDroppableContainers(items); + } + }, [itemsHaveChanged, items, isDragging, measureDroppableContainers]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + previousItemsRef.current = items; + }, [items]); + const contextValue = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + activeIndex, + containerId, + disabled, + disableTransforms, + items, + overIndex, + useDragOverlay, + sortedRects: getSortedRects(items, droppableRects), + strategy + }), // eslint-disable-next-line react-hooks/exhaustive-deps + [activeIndex, containerId, disabled.draggable, disabled.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]); + return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Context.Provider, { + value: contextValue + }, children); +} + +const defaultNewIndexGetter = _ref => { + let { + id, + items, + activeIndex, + overIndex + } = _ref; + return arrayMove(items, activeIndex, overIndex).indexOf(id); +}; +const defaultAnimateLayoutChanges = _ref2 => { + let { + containerId, + isSorting, + wasDragging, + index, + items, + newIndex, + previousItems, + previousContainerId, + transition + } = _ref2; + + if (!transition || !wasDragging) { + return false; + } + + if (previousItems !== items && index === newIndex) { + return false; + } + + if (isSorting) { + return true; + } + + return newIndex !== index && containerId === previousContainerId; +}; +const defaultTransition = { + duration: 200, + easing: 'ease' +}; +const transitionProperty = 'transform'; +const disabledTransition = /*#__PURE__*/_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.CSS.Transition.toString({ + property: transitionProperty, + duration: 0, + easing: 'linear' +}); +const defaultAttributes = { + roleDescription: 'sortable' +}; + +/* + * When the index of an item changes while sorting, + * we need to temporarily disable the transforms + */ + +function useDerivedTransform(_ref) { + let { + disabled, + index, + node, + rect + } = _ref; + const [derivedTransform, setDerivedtransform] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); + const previousIndex = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(index); + (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useIsomorphicLayoutEffect)(() => { + if (!disabled && index !== previousIndex.current && node.current) { + const initial = rect.current; + + if (initial) { + const current = (0,_dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.getClientRect)(node.current, { + ignoreTransform: true + }); + const delta = { + x: initial.left - current.left, + y: initial.top - current.top, + scaleX: initial.width / current.width, + scaleY: initial.height / current.height + }; + + if (delta.x || delta.y) { + setDerivedtransform(delta); + } + } + } + + if (index !== previousIndex.current) { + previousIndex.current = index; + } + }, [disabled, index, node, rect]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (derivedTransform) { + setDerivedtransform(null); + } + }, [derivedTransform]); + return derivedTransform; +} + +function useSortable(_ref) { + let { + animateLayoutChanges = defaultAnimateLayoutChanges, + attributes: userDefinedAttributes, + disabled: localDisabled, + data: customData, + getNewIndex = defaultNewIndexGetter, + id, + strategy: localStrategy, + resizeObserverConfig, + transition = defaultTransition + } = _ref; + const { + items, + containerId, + activeIndex, + disabled: globalDisabled, + disableTransforms, + sortedRects, + overIndex, + useDragOverlay, + strategy: globalStrategy + } = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(Context); + const disabled = normalizeLocalDisabled(localDisabled, globalDisabled); + const index = items.indexOf(id); + const data = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => ({ + sortable: { + containerId, + index, + items + }, + ...customData + }), [containerId, customData, index, items]); + const itemsAfterCurrentSortable = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => items.slice(items.indexOf(id)), [items, id]); + const { + rect, + node, + isOver, + setNodeRef: setDroppableNodeRef + } = (0,_dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.useDroppable)({ + id, + data, + disabled: disabled.droppable, + resizeObserverConfig: { + updateMeasurementsFor: itemsAfterCurrentSortable, + ...resizeObserverConfig + } + }); + const { + active, + activatorEvent, + activeNodeRect, + attributes, + setNodeRef: setDraggableNodeRef, + listeners, + isDragging, + over, + setActivatorNodeRef, + transform + } = (0,_dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.useDraggable)({ + id, + data, + attributes: { ...defaultAttributes, + ...userDefinedAttributes + }, + disabled: disabled.draggable + }); + const setNodeRef = (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef); + const isSorting = Boolean(active); + const displaceItem = isSorting && !disableTransforms && isValidIndex(activeIndex) && isValidIndex(overIndex); + const shouldDisplaceDragSource = !useDragOverlay && isDragging; + const dragSourceDisplacement = shouldDisplaceDragSource && displaceItem ? transform : null; + const strategy = localStrategy != null ? localStrategy : globalStrategy; + const finalTransform = displaceItem ? dragSourceDisplacement != null ? dragSourceDisplacement : strategy({ + rects: sortedRects, + activeNodeRect, + activeIndex, + overIndex, + index + }) : null; + const newIndex = isValidIndex(activeIndex) && isValidIndex(overIndex) ? getNewIndex({ + id, + items, + activeIndex, + overIndex + }) : index; + const activeId = active == null ? void 0 : active.id; + const previous = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({ + activeId, + items, + newIndex, + containerId + }); + const itemsHaveChanged = items !== previous.current.items; + const shouldAnimateLayoutChanges = animateLayoutChanges({ + active, + containerId, + isDragging, + isSorting, + id, + index, + items, + newIndex: previous.current.newIndex, + previousItems: previous.current.items, + previousContainerId: previous.current.containerId, + transition, + wasDragging: previous.current.activeId != null + }); + const derivedTransform = useDerivedTransform({ + disabled: !shouldAnimateLayoutChanges, + index, + node, + rect + }); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (isSorting && previous.current.newIndex !== newIndex) { + previous.current.newIndex = newIndex; + } + + if (containerId !== previous.current.containerId) { + previous.current.containerId = containerId; + } + + if (items !== previous.current.items) { + previous.current.items = items; + } + }, [isSorting, newIndex, containerId, items]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + if (activeId === previous.current.activeId) { + return; + } + + if (activeId && !previous.current.activeId) { + previous.current.activeId = activeId; + return; + } + + const timeoutId = setTimeout(() => { + previous.current.activeId = activeId; + }, 50); + return () => clearTimeout(timeoutId); + }, [activeId]); + return { + active, + activeIndex, + attributes, + data, + rect, + index, + newIndex, + items, + isOver, + isSorting, + isDragging, + listeners, + node, + overIndex, + over, + setNodeRef, + setActivatorNodeRef, + setDroppableNodeRef, + setDraggableNodeRef, + transform: derivedTransform != null ? derivedTransform : finalTransform, + transition: getTransition() + }; + + function getTransition() { + if ( // Temporarily disable transitions for a single frame to set up derived transforms + derivedTransform || // Or to prevent items jumping to back to their "new" position when items change + itemsHaveChanged && previous.current.newIndex === index) { + return disabledTransition; + } + + if (shouldDisplaceDragSource && !(0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.isKeyboardEvent)(activatorEvent) || !transition) { + return undefined; + } + + if (isSorting || shouldAnimateLayoutChanges) { + return _dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.CSS.Transition.toString({ ...transition, + property: transitionProperty + }); + } + + return undefined; + } +} + +function normalizeLocalDisabled(localDisabled, globalDisabled) { + var _localDisabled$dragga, _localDisabled$droppa; + + if (typeof localDisabled === 'boolean') { + return { + draggable: localDisabled, + // Backwards compatibility + droppable: false + }; + } + + return { + draggable: (_localDisabled$dragga = localDisabled == null ? void 0 : localDisabled.draggable) != null ? _localDisabled$dragga : globalDisabled.draggable, + droppable: (_localDisabled$droppa = localDisabled == null ? void 0 : localDisabled.droppable) != null ? _localDisabled$droppa : globalDisabled.droppable + }; +} + +function hasSortableData(entry) { + if (!entry) { + return false; + } + + const data = entry.data.current; + + if (data && 'sortable' in data && typeof data.sortable === 'object' && 'containerId' in data.sortable && 'items' in data.sortable && 'index' in data.sortable) { + return true; + } + + return false; +} + +const directions = [_dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.KeyboardCode.Down, _dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.KeyboardCode.Right, _dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.KeyboardCode.Up, _dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.KeyboardCode.Left]; +const sortableKeyboardCoordinates = (event, _ref) => { + let { + context: { + active, + collisionRect, + droppableRects, + droppableContainers, + over, + scrollableAncestors + } + } = _ref; + + if (directions.includes(event.code)) { + event.preventDefault(); + + if (!active || !collisionRect) { + return; + } + + const filteredContainers = []; + droppableContainers.getEnabled().forEach(entry => { + if (!entry || entry != null && entry.disabled) { + return; + } + + const rect = droppableRects.get(entry.id); + + if (!rect) { + return; + } + + switch (event.code) { + case _dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.KeyboardCode.Down: + if (collisionRect.top < rect.top) { + filteredContainers.push(entry); + } + + break; + + case _dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.KeyboardCode.Up: + if (collisionRect.top > rect.top) { + filteredContainers.push(entry); + } + + break; + + case _dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.KeyboardCode.Left: + if (collisionRect.left > rect.left) { + filteredContainers.push(entry); + } + + break; + + case _dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.KeyboardCode.Right: + if (collisionRect.left < rect.left) { + filteredContainers.push(entry); + } + + break; + } + }); + const collisions = (0,_dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.closestCorners)({ + active, + collisionRect: collisionRect, + droppableRects, + droppableContainers: filteredContainers, + pointerCoordinates: null + }); + let closestId = (0,_dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.getFirstCollision)(collisions, 'id'); + + if (closestId === (over == null ? void 0 : over.id) && collisions.length > 1) { + closestId = collisions[1].id; + } + + if (closestId != null) { + const activeDroppable = droppableContainers.get(active.id); + const newDroppable = droppableContainers.get(closestId); + const newRect = newDroppable ? droppableRects.get(newDroppable.id) : null; + const newNode = newDroppable == null ? void 0 : newDroppable.node.current; + + if (newNode && newRect && activeDroppable && newDroppable) { + const newScrollAncestors = (0,_dnd_kit_core__WEBPACK_IMPORTED_MODULE_1__.getScrollableAncestors)(newNode); + const hasDifferentScrollAncestors = newScrollAncestors.some((element, index) => scrollableAncestors[index] !== element); + const hasSameContainer = isSameContainer(activeDroppable, newDroppable); + const isAfterActive = isAfter(activeDroppable, newDroppable); + const offset = hasDifferentScrollAncestors || !hasSameContainer ? { + x: 0, + y: 0 + } : { + x: isAfterActive ? collisionRect.width - newRect.width : 0, + y: isAfterActive ? collisionRect.height - newRect.height : 0 + }; + const rectCoordinates = { + x: newRect.left, + y: newRect.top + }; + const newCoordinates = offset.x && offset.y ? rectCoordinates : (0,_dnd_kit_utilities__WEBPACK_IMPORTED_MODULE_2__.subtract)(rectCoordinates, offset); + return newCoordinates; + } + } + } + + return undefined; +}; + +function isSameContainer(a, b) { + if (!hasSortableData(a) || !hasSortableData(b)) { + return false; + } + + return a.data.current.sortable.containerId === b.data.current.sortable.containerId; +} + +function isAfter(a, b) { + if (!hasSortableData(a) || !hasSortableData(b)) { + return false; + } + + if (!isSameContainer(a, b)) { + return false; + } + + return a.data.current.sortable.index < b.data.current.sortable.index; +} + + +//# sourceMappingURL=sortable.esm.js.map + + +/***/ }), + +/***/ "./node_modules/@dnd-kit/utilities/dist/utilities.esm.js": +/*!***************************************************************!*\ + !*** ./node_modules/@dnd-kit/utilities/dist/utilities.esm.js ***! + \***************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "CSS": function() { return /* binding */ CSS; }, +/* harmony export */ "add": function() { return /* binding */ add; }, +/* harmony export */ "canUseDOM": function() { return /* binding */ canUseDOM; }, +/* harmony export */ "findFirstFocusableNode": function() { return /* binding */ findFirstFocusableNode; }, +/* harmony export */ "getEventCoordinates": function() { return /* binding */ getEventCoordinates; }, +/* harmony export */ "getOwnerDocument": function() { return /* binding */ getOwnerDocument; }, +/* harmony export */ "getWindow": function() { return /* binding */ getWindow; }, +/* harmony export */ "hasViewportRelativeCoordinates": function() { return /* binding */ hasViewportRelativeCoordinates; }, +/* harmony export */ "isDocument": function() { return /* binding */ isDocument; }, +/* harmony export */ "isHTMLElement": function() { return /* binding */ isHTMLElement; }, +/* harmony export */ "isKeyboardEvent": function() { return /* binding */ isKeyboardEvent; }, +/* harmony export */ "isNode": function() { return /* binding */ isNode; }, +/* harmony export */ "isSVGElement": function() { return /* binding */ isSVGElement; }, +/* harmony export */ "isTouchEvent": function() { return /* binding */ isTouchEvent; }, +/* harmony export */ "isWindow": function() { return /* binding */ isWindow; }, +/* harmony export */ "subtract": function() { return /* binding */ subtract; }, +/* harmony export */ "useCombinedRefs": function() { return /* binding */ useCombinedRefs; }, +/* harmony export */ "useEvent": function() { return /* binding */ useEvent; }, +/* harmony export */ "useInterval": function() { return /* binding */ useInterval; }, +/* harmony export */ "useIsomorphicLayoutEffect": function() { return /* binding */ useIsomorphicLayoutEffect; }, +/* harmony export */ "useLatestValue": function() { return /* binding */ useLatestValue; }, +/* harmony export */ "useLazyMemo": function() { return /* binding */ useLazyMemo; }, +/* harmony export */ "useNodeRef": function() { return /* binding */ useNodeRef; }, +/* harmony export */ "usePrevious": function() { return /* binding */ usePrevious; }, +/* harmony export */ "useUniqueId": function() { return /* binding */ useUniqueId; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); + + +function useCombinedRefs() { + for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { + refs[_key] = arguments[_key]; + } + + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => node => { + refs.forEach(ref => ref(node)); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + refs); +} + +// https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js +const canUseDOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'; + +function isWindow(element) { + const elementString = Object.prototype.toString.call(element); + return elementString === '[object Window]' || // In Electron context the Window object serializes to [object global] + elementString === '[object global]'; +} + +function isNode(node) { + return 'nodeType' in node; +} + +function getWindow(target) { + var _target$ownerDocument, _target$ownerDocument2; + + if (!target) { + return window; + } + + if (isWindow(target)) { + return target; + } + + if (!isNode(target)) { + return window; + } + + return (_target$ownerDocument = (_target$ownerDocument2 = target.ownerDocument) == null ? void 0 : _target$ownerDocument2.defaultView) != null ? _target$ownerDocument : window; +} + +function isDocument(node) { + const { + Document + } = getWindow(node); + return node instanceof Document; +} + +function isHTMLElement(node) { + if (isWindow(node)) { + return false; + } + + return node instanceof getWindow(node).HTMLElement; +} + +function isSVGElement(node) { + return node instanceof getWindow(node).SVGElement; +} + +function getOwnerDocument(target) { + if (!target) { + return document; + } + + if (isWindow(target)) { + return target.document; + } + + if (!isNode(target)) { + return document; + } + + if (isDocument(target)) { + return target; + } + + if (isHTMLElement(target) || isSVGElement(target)) { + return target.ownerDocument; + } + + return document; +} + +/** + * A hook that resolves to useEffect on the server and useLayoutEffect on the client + * @param callback {function} Callback function that is invoked when the dependencies of the hook change + */ + +const useIsomorphicLayoutEffect = canUseDOM ? react__WEBPACK_IMPORTED_MODULE_0__.useLayoutEffect : react__WEBPACK_IMPORTED_MODULE_0__.useEffect; + +function useEvent(handler) { + const handlerRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(handler); + useIsomorphicLayoutEffect(() => { + handlerRef.current = handler; + }); + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return handlerRef.current == null ? void 0 : handlerRef.current(...args); + }, []); +} + +function useInterval() { + const intervalRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + const set = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((listener, duration) => { + intervalRef.current = setInterval(listener, duration); + }, []); + const clear = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => { + if (intervalRef.current !== null) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + }, []); + return [set, clear]; +} + +function useLatestValue(value, dependencies) { + if (dependencies === void 0) { + dependencies = [value]; + } + + const valueRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(value); + useIsomorphicLayoutEffect(() => { + if (valueRef.current !== value) { + valueRef.current = value; + } + }, dependencies); + return valueRef; +} + +function useLazyMemo(callback, dependencies) { + const valueRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + const newValue = callback(valueRef.current); + valueRef.current = newValue; + return newValue; + }, // eslint-disable-next-line react-hooks/exhaustive-deps + [...dependencies]); +} + +function useNodeRef(onChange) { + const onChangeHandler = useEvent(onChange); + const node = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + const setNodeRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(element => { + if (element !== node.current) { + onChangeHandler == null ? void 0 : onChangeHandler(element, node.current); + } + + node.current = element; + }, //eslint-disable-next-line + []); + return [node, setNodeRef]; +} + +function usePrevious(value) { + const ref = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + ref.current = value; + }, [value]); + return ref.current; +} + +let ids = {}; +function useUniqueId(prefix, value) { + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => { + if (value) { + return value; + } + + const id = ids[prefix] == null ? 0 : ids[prefix] + 1; + ids[prefix] = id; + return prefix + "-" + id; + }, [prefix, value]); +} + +function createAdjustmentFn(modifier) { + return function (object) { + for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + adjustments[_key - 1] = arguments[_key]; + } + + return adjustments.reduce((accumulator, adjustment) => { + const entries = Object.entries(adjustment); + + for (const [key, valueAdjustment] of entries) { + const value = accumulator[key]; + + if (value != null) { + accumulator[key] = value + modifier * valueAdjustment; + } + } + + return accumulator; + }, { ...object + }); + }; +} + +const add = /*#__PURE__*/createAdjustmentFn(1); +const subtract = /*#__PURE__*/createAdjustmentFn(-1); + +function hasViewportRelativeCoordinates(event) { + return 'clientX' in event && 'clientY' in event; +} + +function isKeyboardEvent(event) { + if (!event) { + return false; + } + + const { + KeyboardEvent + } = getWindow(event.target); + return KeyboardEvent && event instanceof KeyboardEvent; +} + +function isTouchEvent(event) { + if (!event) { + return false; + } + + const { + TouchEvent + } = getWindow(event.target); + return TouchEvent && event instanceof TouchEvent; +} + +/** + * Returns the normalized x and y coordinates for mouse and touch events. + */ + +function getEventCoordinates(event) { + if (isTouchEvent(event)) { + if (event.touches && event.touches.length) { + const { + clientX: x, + clientY: y + } = event.touches[0]; + return { + x, + y + }; + } else if (event.changedTouches && event.changedTouches.length) { + const { + clientX: x, + clientY: y + } = event.changedTouches[0]; + return { + x, + y + }; + } + } + + if (hasViewportRelativeCoordinates(event)) { + return { + x: event.clientX, + y: event.clientY + }; + } + + return null; +} + +const CSS = /*#__PURE__*/Object.freeze({ + Translate: { + toString(transform) { + if (!transform) { + return; + } + + const { + x, + y + } = transform; + return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)"; + } + + }, + Scale: { + toString(transform) { + if (!transform) { + return; + } + + const { + scaleX, + scaleY + } = transform; + return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")"; + } + + }, + Transform: { + toString(transform) { + if (!transform) { + return; + } + + return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(' '); + } + + }, + Transition: { + toString(_ref) { + let { + property, + duration, + easing + } = _ref; + return property + " " + duration + "ms " + easing; + } + + } +}); + +const SELECTOR = 'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]'; +function findFirstFocusableNode(element) { + if (element.matches(SELECTOR)) { + return element; + } + + return element.querySelector(SELECTOR); +} + + +//# sourceMappingURL=utilities.esm.js.map + + +/***/ }), + +/***/ "./client/src/boot/index.js": +/*!**********************************!*\ + !*** ./client/src/boot/index.js ***! + \**********************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + + + +var _registerComponents = _interopRequireDefault(__webpack_require__(/*! ./registerComponents */ "./client/src/boot/registerComponents.js")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +document.addEventListener('DOMContentLoaded', () => { + (0, _registerComponents.default)(); +}); + +/***/ }), + +/***/ "./client/src/boot/registerComponents.js": +/*!***********************************************!*\ + !*** ./client/src/boot/registerComponents.js ***! + \***********************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _Injector = _interopRequireDefault(__webpack_require__(/*! lib/Injector */ "lib/Injector")); +var _LinkPicker = _interopRequireDefault(__webpack_require__(/*! components/LinkPicker/LinkPicker */ "./client/src/components/LinkPicker/LinkPicker.js")); +var _LinkField = _interopRequireDefault(__webpack_require__(/*! components/LinkField/LinkField */ "./client/src/components/LinkField/LinkField.js")); +var _LinkModal = _interopRequireDefault(__webpack_require__(/*! components/LinkModal/LinkModal */ "./client/src/components/LinkModal/LinkModal.js")); +var _FileLinkModal = _interopRequireDefault(__webpack_require__(/*! components/LinkModal/FileLinkModal */ "./client/src/components/LinkModal/FileLinkModal.js")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const registerComponents = () => { + _Injector.default.component.registerMany({ + LinkPicker: _LinkPicker.default, + LinkField: _LinkField.default, + 'LinkModal.FormBuilderModal': _LinkModal.default, + 'LinkModal.InsertMediaModal': _FileLinkModal.default + }); +}; +var _default = registerComponents; +exports["default"] = _default; + +/***/ }), + +/***/ "./client/src/components/LinkField/LinkField.js": +/*!******************************************************!*\ + !*** ./client/src/components/LinkField/LinkField.js ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = exports.LinkFieldContext = exports.Component = void 0; +var _react = _interopRequireWildcard(__webpack_require__(/*! react */ "react")); +var _redux = __webpack_require__(/*! redux */ "redux"); +var _reactRedux = __webpack_require__(/*! react-redux */ "react-redux"); +var _core = __webpack_require__(/*! @dnd-kit/core */ "./node_modules/@dnd-kit/core/dist/core.esm.js"); +var _sortable = __webpack_require__(/*! @dnd-kit/sortable */ "./node_modules/@dnd-kit/sortable/dist/sortable.esm.js"); +var _modifiers = __webpack_require__(/*! @dnd-kit/modifiers */ "./node_modules/@dnd-kit/modifiers/dist/modifiers.esm.js"); +var _FieldHolder = _interopRequireDefault(__webpack_require__(/*! components/FieldHolder/FieldHolder */ "components/FieldHolder/FieldHolder")); +var _LinkPicker = _interopRequireDefault(__webpack_require__(/*! components/LinkPicker/LinkPicker */ "./client/src/components/LinkPicker/LinkPicker.js")); +var _LinkPickerTitle = _interopRequireDefault(__webpack_require__(/*! components/LinkPicker/LinkPickerTitle */ "./client/src/components/LinkPicker/LinkPickerTitle.js")); +var _Loading = _interopRequireDefault(__webpack_require__(/*! components/Loading/Loading */ "components/Loading/Loading")); +var _LinkModalContainer = _interopRequireDefault(__webpack_require__(/*! containers/LinkModalContainer */ "./client/src/containers/LinkModalContainer.js")); +var toastsActions = _interopRequireWildcard(__webpack_require__(/*! state/toasts/ToastsActions */ "state/toasts/ToastsActions")); +var _Backend = _interopRequireDefault(__webpack_require__(/*! lib/Backend */ "lib/Backend")); +var _Config = _interopRequireDefault(__webpack_require__(/*! lib/Config */ "lib/Config")); +var _urls = __webpack_require__(/*! lib/urls */ "lib/urls"); +var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "prop-types")); +var _i18n = _interopRequireDefault(__webpack_require__(/*! i18n */ "i18n")); +var _url = _interopRequireDefault(__webpack_require__(/*! url */ "url")); +var _qs = _interopRequireDefault(__webpack_require__(/*! qs */ "qs")); +var _classnames = _interopRequireDefault(__webpack_require__(/*! classnames */ "classnames")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } +function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +const LinkFieldContext = (0, _react.createContext)(null); +exports.LinkFieldContext = LinkFieldContext; +const section = 'SilverStripe\\LinkField\\Controllers\\LinkFieldController'; +const LinkField = _ref => { + var _data$editingID; + let { + value = null, + onChange, + types = {}, + actions, + isMulti = false, + canCreate, + readonly, + disabled, + ownerID, + ownerClass, + ownerRelation + } = _ref; + const [data, setData] = (0, _react.useState)({}); + const [editingID, setEditingID] = (0, _react.useState)(0); + const [isKeyboardEditing, setIsKeyboardEditing] = (0, _react.useState)(false); + const [focusOnID, setFocusOnID] = (0, _react.useState)(0); + const [focusOnNewLinkWhenClosed, setFocusOnNewLinkWhenClosed] = (0, _react.useState)(false); + const [focusOnNewLink, setFocusOnNewLink] = (0, _react.useState)(false); + const [loading, setLoading] = (0, _react.useState)(false); + const [forceFetch, setForceFetch] = (0, _react.useState)(0); + const [isSorting, setIsSorting] = (0, _react.useState)(false); + const [linksClassName, setLinksClassName] = (0, _react.useState)((0, _classnames.default)({ + 'link-picker-links': true + })); + const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.PointerSensor, { + activationConstraint: { + distance: 10 + } + }), (0, _core.useSensor)(_core.KeyboardSensor, { + coordinateGetter: (event, args) => { + event.preventDefault(); + const { + active, + over, + droppableContainers + } = args.context; + if (!active || !active.data || !active.data.current) { + return; + } + const items = active.data.current.sortable.items; + const overId = over ? over.id : active.id; + const overIndex = items.indexOf(overId); + const activeIndex = items.indexOf(active.id); + const directionUp = -1; + const directionDown = 1; + let nextIndex = overIndex; + let direction = directionDown; + switch (event.code) { + case _core.KeyboardCode.Down: + case _core.KeyboardCode.Right: + nextIndex = Math.min(overIndex + 1, items.length - 1); + break; + case _core.KeyboardCode.Up: + case _core.KeyboardCode.Left: + nextIndex = Math.max(0, overIndex - 1); + direction = directionUp; + break; + default: + return; + } + if (overIndex === nextIndex) { + return; + } + const sortedItems = (0, _sortable.arrayMove)(items, activeIndex, overIndex); + const currentNodeIdAtNextIndex = sortedItems[nextIndex]; + if (!droppableContainers.has(currentNodeIdAtNextIndex)) { + return; + } + const activeNode = droppableContainers.get(active.id).node.current; + if (!droppableContainers.has(active.id)) { + return; + } + const newNode = droppableContainers.get(currentNodeIdAtNextIndex).node.current; + const activeRect = activeNode.getBoundingClientRect(); + const newRect = newNode.getBoundingClientRect(); + const offset = direction === directionDown ? newRect.top - activeRect.bottom : activeRect.top - newRect.bottom; + return { + x: 0, + y: activeRect.top + direction * (newRect.height + offset) + }; + } + })); + let linkIDs = value; + if (!Array.isArray(linkIDs)) { + if (typeof linkIDs === 'number' && linkIDs != 0) { + linkIDs = [linkIDs]; + } + if (!linkIDs) { + linkIDs = []; + } + } + (0, _react.useEffect)(() => { + if (!editingID && linkIDs.length > 0) { + setLoading(true); + const query = []; + for (const linkID of linkIDs) { + query.push(`itemIDs[]=${linkID}`); + } + const endpoint = `${_Config.default.getSection(section).form.linkForm.dataUrl}?${query.join('&')}`; + _Backend.default.get(endpoint).then(response => response.json()).then(responseJson => { + setData(responseJson); + setLoading(false); + setIsSorting(false); + }).catch(() => { + actions.toasts.error(_i18n.default._t('LinkField.FAILED_TO_LOAD_LINKS', 'Failed to load links')); + setLoading(false); + setIsSorting(false); + }); + } + }, [editingID, value && value.length, forceFetch]); + let refCount = 0; + const linkButtonRefs = []; + for (const linkID of linkIDs) { + linkButtonRefs[linkID] = (0, _react.useRef)(null); + refCount++; + } + while (refCount < 256) { + (0, _react.useRef)(null); + refCount++; + } + (0, _react.useEffect)(() => { + if (!focusOnID && !focusOnNewLink || loading) { + return; + } + let c = 0; + const interval = setInterval(() => { + if (focusOnID && linkButtonRefs[focusOnID].current) { + linkButtonRefs[focusOnID].current.focus(); + clearInterval(interval); + } else if (focusOnNewLink) { + if (linkIDs.length === 0) { + clearInterval(interval); + } else { + const linkID = linkIDs[0]; + if (linkButtonRefs[linkID].current) { + linkButtonRefs[linkID].current.focus(); + clearInterval(interval); + } + } + } + if (++c >= 50) { + clearInterval(interval); + } + }, 50); + setFocusOnID(0); + setFocusOnNewLink(false); + }, [focusOnID, focusOnNewLink, loading]); + const handleModalClosed = () => { + if (isKeyboardEditing) { + setIsKeyboardEditing(false); + if (editingID) { + setFocusOnID(editingID); + } else if (focusOnNewLinkWhenClosed) { + setFocusOnNewLink(true); + } + } + setEditingID(0); + setFocusOnNewLinkWhenClosed(false); + }; + const handleModalSuccess = value => { + handleModalClosed(); + const ids = [...linkIDs]; + if (!ids.includes(value)) { + ids.push(value); + } + onChange(isMulti ? ids : ids[0]); + actions.toasts.success(_i18n.default._t('LinkField.SAVE_SUCCESS', 'Saved link')); + }; + const handleLinkPickerKeyDownEdit = () => { + if (!isMulti) { + setFocusOnNewLinkWhenClosed(true); + setIsKeyboardEditing(true); + } + }; + const handleDelete = (linkID, deleteType) => { + var _data$linkID; + const versionState = ((_data$linkID = data[linkID]) === null || _data$linkID === void 0 ? void 0 : _data$linkID.versionState) || ''; + const isVersioned = ['draft', 'modified', 'published'].includes(versionState); + const deleteText = isVersioned ? _i18n.default._t('LinkField.ARCHIVE_CONFIRM', 'Are you sure you want to archive this link?') : _i18n.default._t('LinkField.DELETE_CONFIRM', 'Are you sure you want to delete this link?'); + if (!window.confirm(deleteText)) { + return false; + } + let endpoint = (0, _urls.joinUrlPaths)(_Config.default.getSection(section).form.linkForm.deleteUrl, linkID.toString()); + const parsedURL = _url.default.parse(endpoint); + const parsedQs = _qs.default.parse(parsedURL.query); + parsedQs.ownerID = ownerID; + parsedQs.ownerClass = ownerClass; + parsedQs.ownerRelation = ownerRelation; + endpoint = _url.default.format({ + ...parsedURL, + search: _qs.default.stringify(parsedQs) + }); + const successText = isVersioned ? _i18n.default._t('LinkField.ARCHIVE_SUCCESS', 'Archived link') : _i18n.default._t('LinkField.DELETE_SUCCESS', 'Deleted link'); + const failedText = isVersioned ? _i18n.default._t('LinkField.ARCHIVE_ERROR', 'Failed to archive link') : _i18n.default._t('LinkField.DELETE_ERROR', 'Failed to delete link'); + _Backend.default.delete(endpoint, {}, { + 'X-SecurityID': _Config.default.get('SecurityID') + }).then(() => actions.toasts.success(successText)).catch(() => actions.toasts.error(failedText)); + const newData = { + ...data + }; + delete newData[linkID]; + setData(newData); + onChange(isMulti ? Object.keys(newData) : 0); + }; + const handleUnpublishedVersionedState = () => { + const cssSelector = ['.cms-edit-form button[data-text-alternate]#Form_EditForm_action_publish', '.cms-edit-form button[data-text-alternate]#Form_ItemEditForm_action_doPublish'].join(','); + const publishButton = document.querySelector(cssSelector); + if (!publishButton) { + return; + } + const dataBtnAlternateRemove = publishButton.getAttribute('data-btn-alternate-remove') || ''; + dataBtnAlternateRemove.split(' ').forEach(className => { + if (className) { + publishButton.classList.remove(className); + } + }); + const dataBtnAlternateAdd = publishButton.getAttribute('data-btn-alternate-add') || ''; + dataBtnAlternateAdd.split(' ').forEach(className => { + if (className) { + publishButton.classList.add(className); + } + }); + const dataTextAlternate = publishButton.getAttribute('data-text-alternate'); + if (dataTextAlternate) { + publishButton.innerHTML = dataTextAlternate; + } + }; + const renderLinks = () => { + const links = []; + for (let i = 0; i < linkIDs.length; i++) { + var _data$linkID2, _data$linkID3, _data$linkID4, _data$linkID5, _data$linkID6, _data$linkID7; + const linkID = linkIDs[i]; + const linkData = data[linkID]; + if (!linkData) { + continue; + } + const type = types.hasOwnProperty((_data$linkID2 = data[linkID]) === null || _data$linkID2 === void 0 ? void 0 : _data$linkID2.typeKey) ? types[(_data$linkID3 = data[linkID]) === null || _data$linkID3 === void 0 ? void 0 : _data$linkID3.typeKey] : {}; + links.push(_react.default.createElement(_LinkPickerTitle.default, { + key: linkID, + id: linkID, + title: (_data$linkID4 = data[linkID]) === null || _data$linkID4 === void 0 ? void 0 : _data$linkID4.Title, + description: (_data$linkID5 = data[linkID]) === null || _data$linkID5 === void 0 ? void 0 : _data$linkID5.description, + versionState: (_data$linkID6 = data[linkID]) === null || _data$linkID6 === void 0 ? void 0 : _data$linkID6.versionState, + typeTitle: type.title || '', + typeIcon: type.icon, + onDelete: handleDelete, + onClick: () => { + setEditingID(linkID); + }, + onButtonKeyDownEdit: () => setIsKeyboardEditing(true), + onUnpublishedVersionedState: handleUnpublishedVersionedState, + canDelete: (_data$linkID7 = data[linkID]) !== null && _data$linkID7 !== void 0 && _data$linkID7.canDelete ? true : false, + isMulti: isMulti, + isFirst: i === 0, + isLast: i === linkIDs.length - 1, + isSorting: isSorting, + canCreate: canCreate, + readonly: readonly, + disabled: disabled, + buttonRef: linkButtonRefs[linkID] + })); + } + return links; + }; + const sortableLinks = () => { + if (isMulti && !readonly && !disabled) { + return _react.default.createElement("div", { + className: linksClassName, + onBlur: () => setIsSorting(false) + }, _react.default.createElement(_core.DndContext, { + modifiers: [_modifiers.restrictToVerticalAxis, _modifiers.restrictToParentElement], + sensors: sensors, + collisionDetection: _core.closestCenter, + onDragStart: handleDragStart, + onDragEnd: handleDragEnd + }, _react.default.createElement(_sortable.SortableContext, { + items: linkIDs, + strategy: _sortable.verticalListSortingStrategy + }, links))); + } + return _react.default.createElement("div", null, links); + }; + const handleDragStart = event => { + setLinksClassName((0, _classnames.default)({ + 'link-picker__links': true, + 'link-picker__links--dragging': true + })); + setIsSorting(true); + }; + const handleDragEnd = event => { + const { + active, + over + } = event; + setLinksClassName((0, _classnames.default)({ + 'link-picker__links': true, + 'link-picker__links--dragging': false + })); + if (active.id === over.id) { + setIsSorting(false); + return; + } + const fromIndex = linkIDs.indexOf(active.id); + const toIndex = linkIDs.indexOf(over.id); + const newLinkIDs = (0, _sortable.arrayMove)(linkIDs, fromIndex, toIndex); + onChange(newLinkIDs); + let endpoint = `${_Config.default.getSection(section).form.linkForm.sortUrl}`; + _Backend.default.post(endpoint, { + newLinkIDs + }, { + 'X-SecurityID': _Config.default.get('SecurityID') + }).then(async () => { + onChange(newLinkIDs); + actions.toasts.success(_i18n.default._t('LinkField.SORT_SUCCESS', 'Updated link sort order')); + setForceFetch(forceFetch + 1); + }).catch(() => { + actions.toasts.error(_i18n.default._t('LinkField.SORT_ERROR', 'Failed to sort links')); + }); + }; + const saveRecordFirst = ownerID === 0; + const renderPicker = !saveRecordFirst && (isMulti || Object.keys(data).length === 0); + const renderModal = !saveRecordFirst && Boolean(editingID); + const saveRecordFirstText = _i18n.default._t('LinkField.SAVE_RECORD_FIRST', 'Cannot add links until the record has been saved'); + const links = renderLinks(); + return _react.default.createElement(LinkFieldContext.Provider, { + value: { + ownerID, + ownerClass, + ownerRelation, + actions, + loading + } + }, _react.default.createElement("div", { + className: "link-field__container" + }, saveRecordFirst && _react.default.createElement("div", { + className: "link-field__save-record-first" + }, saveRecordFirstText), loading && !isSorting && !saveRecordFirst && _react.default.createElement(_Loading.default, { + containerClass: "link-field__loading" + }), renderPicker && _react.default.createElement(_LinkPicker.default, { + onModalSuccess: handleModalSuccess, + onModalClosed: handleModalClosed, + types: types, + canCreate: canCreate, + readonly: readonly, + disabled: disabled, + onKeyDownEdit: handleLinkPickerKeyDownEdit + }), sortableLinks(), renderModal && _react.default.createElement(_LinkModalContainer.default, { + types: types, + typeKey: (_data$editingID = data[editingID]) === null || _data$editingID === void 0 ? void 0 : _data$editingID.typeKey, + isOpen: Boolean(editingID), + onSuccess: handleModalSuccess, + onClosed: handleModalClosed, + linkID: editingID + }))); +}; +exports.Component = LinkField; +LinkField.propTypes = { + value: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.number), _propTypes.default.number]), + onChange: _propTypes.default.func.isRequired, + types: _propTypes.default.object.isRequired, + actions: _propTypes.default.object.isRequired, + isMulti: _propTypes.default.bool, + canCreate: _propTypes.default.bool.isRequired, + readonly: _propTypes.default.bool.isRequired, + disabled: _propTypes.default.bool.isRequired, + ownerID: _propTypes.default.number.isRequired, + ownerClass: _propTypes.default.string.isRequired, + ownerRelation: _propTypes.default.string.isRequired +}; +const mapDispatchToProps = dispatch => ({ + actions: { + toasts: (0, _redux.bindActionCreators)(toastsActions, dispatch) + } +}); +var _default = (0, _redux.compose)(_FieldHolder.default, (0, _reactRedux.connect)(null, mapDispatchToProps))(LinkField); +exports["default"] = _default; + +/***/ }), + +/***/ "./client/src/components/LinkModal/FileLinkModal.js": +/*!**********************************************************!*\ + !*** ./client/src/components/LinkModal/FileLinkModal.js ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _i18n = _interopRequireDefault(__webpack_require__(/*! i18n */ "i18n")); +var _react = _interopRequireWildcard(__webpack_require__(/*! react */ "react")); +var _InsertMediaModal = _interopRequireDefault(__webpack_require__(/*! containers/InsertMediaModal/InsertMediaModal */ "containers/InsertMediaModal/InsertMediaModal")); +var _reactRedux = __webpack_require__(/*! react-redux */ "react-redux"); +var _LinkType = _interopRequireDefault(__webpack_require__(/*! types/LinkType */ "./client/src/types/LinkType.js")); +var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "prop-types")); +function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } +function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } +const FileLinkModal = _ref => { + let { + type, + editing, + data, + actions, + onSubmit, + ...props + } = _ref; + if (!type) { + return false; + } + (0, _react.useEffect)(() => { + if (editing) { + actions.initModal(); + } else { + actions.reset(); + } + }, [editing]); + const attrs = data ? { + ID: data.FileID, + Description: data.Title, + TargetBlank: data.OpenInNew ? true : false + } : {}; + const onInsert = _ref2 => { + let { + ID, + Description, + TargetBlank + } = _ref2; + return onSubmit({ + FileID: ID, + Title: Description, + OpenInNew: TargetBlank, + typeKey: type.key + }, '', () => {}); + }; + return _react.default.createElement(_InsertMediaModal.default, _extends({ + isOpen: editing, + type: "insert-link", + title: false, + bodyClassName: "modal__dialog", + className: "insert-link__dialog-wrapper--internal", + fileAttributes: attrs, + onInsert: onInsert + }, props)); +}; +FileLinkModal.propTypes = { + type: _LinkType.default.isRequired, + editing: _propTypes.default.bool.isRequired, + data: _propTypes.default.object.isRequired, + actions: _propTypes.default.object.isRequired, + onClick: _propTypes.default.func.isRequired +}; +function mapStateToProps() { + return {}; +} +function mapDispatchToProps(dispatch) { + return { + actions: { + initModal: () => dispatch({ + type: 'INIT_FORM_SCHEMA_STACK', + payload: { + formSchema: { + type: 'insert-link', + nextType: 'admin' + } + } + }), + reset: () => dispatch({ + type: 'RESET' + }) + } + }; +} +var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(FileLinkModal); +exports["default"] = _default; + +/***/ }), + +/***/ "./client/src/components/LinkModal/LinkModal.js": +/*!******************************************************!*\ + !*** ./client/src/components/LinkModal/LinkModal.js ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _react = _interopRequireWildcard(__webpack_require__(/*! react */ "react")); +var _FormBuilderModal = _interopRequireDefault(__webpack_require__(/*! components/FormBuilderModal/FormBuilderModal */ "components/FormBuilderModal/FormBuilderModal")); +var _LinkField = __webpack_require__(/*! components/LinkField/LinkField */ "./client/src/components/LinkField/LinkField.js"); +var _url = _interopRequireDefault(__webpack_require__(/*! url */ "url")); +var _qs = _interopRequireDefault(__webpack_require__(/*! qs */ "qs")); +var _Config = _interopRequireDefault(__webpack_require__(/*! lib/Config */ "lib/Config")); +var _urls = __webpack_require__(/*! lib/urls */ "lib/urls"); +var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "prop-types")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } +function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +const buildSchemaUrl = (typeKey, linkID) => { + const { + schemaUrl + } = _Config.default.getSection('SilverStripe\\LinkField\\Controllers\\LinkFieldController').form.linkForm; + const parsedURL = _url.default.parse(schemaUrl); + const parsedQs = _qs.default.parse(parsedURL.query); + parsedQs.typeKey = typeKey; + const { + ownerID, + ownerClass, + ownerRelation + } = (0, _react.useContext)(_LinkField.LinkFieldContext); + parsedQs.ownerID = ownerID; + parsedQs.ownerClass = ownerClass; + parsedQs.ownerRelation = ownerRelation; + for (const prop of ['href', 'path', 'pathname']) { + parsedURL[prop] = (0, _urls.joinUrlPaths)(parsedURL[prop], linkID.toString()); + } + return _url.default.format({ + ...parsedURL, + search: _qs.default.stringify(parsedQs) + }); +}; +const LinkModal = _ref => { + let { + typeTitle, + typeKey, + linkID = 0, + isOpen, + onSuccess, + onClosed + } = _ref; + const { + actions + } = (0, _react.useContext)(_LinkField.LinkFieldContext); + if (!typeKey) { + return false; + } + const onSubmit = async (modalData, action, submitFn) => { + let formSchema = null; + if (document.getElementById('Form_fileSelectForm_action_insert') || document.getElementById('Form_fileEditForm_Actions_Holder')) { + return Promise.resolve(); + } + try { + formSchema = await submitFn(); + } catch (error) { + actions.toasts.error(i18n._t('LinkField.FAILED_TO_SAVE_LINK', 'Failed to save link')); + return Promise.resolve(); + } + const hasValidationErrors = formSchema.id.match(/\/schema\/linkfield\/([0-9]+)/); + if (!hasValidationErrors) { + const match = formSchema.id.match(/\/linkForm\/([0-9]+)/); + const valueFromSchemaResponse = parseInt(match[1], 10); + onSuccess(valueFromSchemaResponse); + } + return Promise.resolve(); + }; + return _react.default.createElement(_FormBuilderModal.default, { + title: typeTitle, + isOpen: isOpen, + schemaUrl: buildSchemaUrl(typeKey, linkID), + identifier: "Link.EditingLinkInfo", + onSubmit: onSubmit, + onClosed: onClosed + }); +}; +LinkModal.propTypes = { + typeTitle: _propTypes.default.string.isRequired, + typeKey: _propTypes.default.string.isRequired, + linkID: _propTypes.default.number, + isOpen: _propTypes.default.bool.isRequired, + onSuccess: _propTypes.default.func.isRequired, + onClosed: _propTypes.default.func.isRequired +}; +LinkModal.defaultProps; +var _default = LinkModal; +exports["default"] = _default; + +/***/ }), + +/***/ "./client/src/components/LinkPicker/LinkPicker.js": +/*!********************************************************!*\ + !*** ./client/src/components/LinkPicker/LinkPicker.js ***! + \********************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = exports.Component = void 0; +var _i18n = _interopRequireDefault(__webpack_require__(/*! i18n */ "i18n")); +var _react = _interopRequireWildcard(__webpack_require__(/*! react */ "react")); +var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "prop-types")); +var _classnames = _interopRequireDefault(__webpack_require__(/*! classnames */ "classnames")); +var _LinkPickerMenu = _interopRequireDefault(__webpack_require__(/*! ./LinkPickerMenu */ "./client/src/components/LinkPicker/LinkPickerMenu.js")); +var _LinkModalContainer = _interopRequireDefault(__webpack_require__(/*! containers/LinkModalContainer */ "./client/src/containers/LinkModalContainer.js")); +function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } +function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const LinkPicker = _ref => { + let { + types, + onModalSuccess, + onModalClosed, + canCreate, + readonly, + disabled, + onKeyDownEdit + } = _ref; + const [typeKey, setTypeKey] = (0, _react.useState)(''); + const handleSelect = key => { + setTypeKey(key); + }; + const handleClosed = () => { + if (typeof onModalClosed === 'function') { + onModalClosed(); + } + setTypeKey(''); + }; + const handleSuccess = value => { + setTypeKey(''); + onModalSuccess(value); + }; + const shouldOpenModal = typeKey !== ''; + const className = (0, _classnames.default)('link-picker', 'form-control'); + const typeArray = Object.values(types); + const allowedTypes = typeArray.filter(type => type.allowed); + const message = _i18n.default._t('LinkField.CANNOT_CREATE_LINK', 'Cannot create link'); + if (!canCreate || allowedTypes.length === 0 || readonly || disabled) { + return _react.default.createElement("div", { + className: className + }, _react.default.createElement("div", { + className: "link-picker__cannot-create" + }, message)); + } + return _react.default.createElement("div", { + className: className + }, _react.default.createElement(_LinkPickerMenu.default, { + types: typeArray, + onSelect: handleSelect, + onKeyDownEdit: onKeyDownEdit + }), shouldOpenModal && _react.default.createElement(_LinkModalContainer.default, { + types: types, + typeKey: typeKey, + isOpen: shouldOpenModal, + onSuccess: handleSuccess, + onClosed: handleClosed + })); +}; +exports.Component = LinkPicker; +LinkPicker.propTypes = { + types: _propTypes.default.object.isRequired, + onModalSuccess: _propTypes.default.func.isRequired, + onModalClosed: _propTypes.default.func, + canCreate: _propTypes.default.bool.isRequired, + readonly: _propTypes.default.bool.isRequired, + disabled: _propTypes.default.bool.isRequired, + onKeyDownEdit: _propTypes.default.func.isRequired +}; +var _default = LinkPicker; +exports["default"] = _default; + +/***/ }), + +/***/ "./client/src/components/LinkPicker/LinkPickerMenu.js": +/*!************************************************************!*\ + !*** ./client/src/components/LinkPicker/LinkPickerMenu.js ***! + \************************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _i18n = _interopRequireDefault(__webpack_require__(/*! i18n */ "i18n")); +var _react = _interopRequireWildcard(__webpack_require__(/*! react */ "react")); +var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "prop-types")); +var _reactstrap = __webpack_require__(/*! reactstrap */ "reactstrap"); +var _LinkField = __webpack_require__(/*! components/LinkField/LinkField */ "./client/src/components/LinkField/LinkField.js"); +var _LinkType = _interopRequireDefault(__webpack_require__(/*! types/LinkType */ "./client/src/types/LinkType.js")); +function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } +function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const LinkPickerMenu = _ref => { + let { + types, + onSelect, + onKeyDownEdit + } = _ref; + const [isOpen, setIsOpen] = (0, _react.useState)(false); + const toggle = () => setIsOpen(prevState => !prevState); + const { + loading + } = (0, _react.useContext)(_LinkField.LinkFieldContext); + const handleKeyDown = event => { + if (['Enter', 'Space'].includes(event.code)) { + onKeyDownEdit(); + } + }; + return _react.default.createElement(_reactstrap.Dropdown, { + disabled: loading, + isOpen: isOpen, + toggle: toggle, + className: "link-picker__menu" + }, _react.default.createElement(_reactstrap.DropdownToggle, { + className: "link-picker__menu-toggle font-icon-plus-1", + caret: true, + color: "secondary" + }, _i18n.default._t('LinkField.ADD_LINK', 'Add Link')), _react.default.createElement(_reactstrap.DropdownMenu, null, types.map(_ref2 => { + let { + key, + title, + icon, + allowed + } = _ref2; + return allowed && _react.default.createElement(_reactstrap.DropdownItem, { + key: key, + onClick: () => { + onSelect(key); + }, + onKeyDown: handleKeyDown + }, _react.default.createElement("span", { + className: `link-picker__menu-icon ${icon}` + }), title); + }))); +}; +LinkPickerMenu.propTypes = { + types: _propTypes.default.arrayOf(_LinkType.default).isRequired, + onSelect: _propTypes.default.func.isRequired, + onKeyDownEdit: _propTypes.default.func.isRequired +}; +var _default = LinkPickerMenu; +exports["default"] = _default; + +/***/ }), + +/***/ "./client/src/components/LinkPicker/LinkPickerTitle.js": +/*!*************************************************************!*\ + !*** ./client/src/components/LinkPicker/LinkPickerTitle.js ***! + \*************************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _classnames = _interopRequireDefault(__webpack_require__(/*! classnames */ "classnames")); +var _i18n = _interopRequireDefault(__webpack_require__(/*! i18n */ "i18n")); +var _react = _interopRequireWildcard(__webpack_require__(/*! react */ "react")); +var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "prop-types")); +var _LinkField = __webpack_require__(/*! components/LinkField/LinkField */ "./client/src/components/LinkField/LinkField.js"); +var _reactstrap = __webpack_require__(/*! reactstrap */ "reactstrap"); +var _sortable = __webpack_require__(/*! @dnd-kit/sortable */ "./node_modules/@dnd-kit/sortable/dist/sortable.esm.js"); +var _utilities = __webpack_require__(/*! @dnd-kit/utilities */ "./node_modules/@dnd-kit/utilities/dist/utilities.esm.js"); +function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } +function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } +const stopPropagation = fn => e => { + e.nativeEvent.stopImmediatePropagation(); + e.preventDefault(); + e.nativeEvent.preventDefault(); + e.stopPropagation(); + fn && fn(); +}; +const getVersionedBadge = versionState => { + let title = ''; + let label = ''; + if (versionState === 'draft') { + title = _i18n.default._t('LinkField.LINK_DRAFT_TITLE', 'Link has draft changes'); + label = _i18n.default._t('LinkField.LINK_DRAFT_LABEL', 'Draft'); + } else if (versionState === 'modified') { + title = _i18n.default._t('LinkField.LINK_MODIFIED_TITLE', 'Link has unpublished changes'); + label = _i18n.default._t('LinkField.LINK_MODIFIED_LABEL', 'Modified'); + } else { + return null; + } + const className = (0, _classnames.default)('badge', `status-${versionState}`); + return _react.default.createElement("span", { + className: className, + title: title + }, label); +}; +const LinkPickerTitle = _ref => { + let { + id, + title, + description, + versionState, + typeTitle, + typeIcon, + onDelete, + onClick, + onButtonKeyDownEdit, + onUnpublishedVersionedState, + canDelete, + isMulti, + isFirst, + isLast, + isSorting, + canCreate, + readonly, + disabled, + buttonRef + } = _ref; + const { + loading + } = (0, _react.useContext)(_LinkField.LinkFieldContext); + const { + attributes, + listeners, + setNodeRef, + transform, + transition + } = (0, _sortable.useSortable)({ + id + }); + const handleButtonKeyDown = event => { + event.nativeEvent.stopImmediatePropagation(); + event.stopPropagation(); + if (['Enter', 'Space'].includes(event.code) && !loading) { + onButtonKeyDownEdit(event); + } + }; + const handleDeleteKeyDown = event => { + if (!['Enter', 'Space'].includes(event.code) || loading) { + return; + } + event.nativeEvent.stopImmediatePropagation(); + event.stopPropagation(); + onDelete(id); + event.nativeEvent.preventDefault(); + event.preventDefault(); + }; + const style = { + transform: _utilities.CSS.Transform.toString(transform), + transition + }; + const classes = { + 'link-picker__link': true, + 'link-picker__link--is-first': isFirst, + 'link-picker__link--is-last': isLast, + 'link-picker__link--is-sorting': isSorting, + 'form-control': true, + 'link-picker__link--readonly': readonly || !canCreate, + 'link-picker__link--disabled': disabled + }; + if (versionState) { + classes[`link-picker__link--${versionState}`] = true; + } + const className = (0, _classnames.default)(classes); + const deleteText = ['unversioned', 'unsaved'].includes(versionState) ? _i18n.default._t('LinkField.DELETE', 'Delete') : _i18n.default._t('LinkField.ARCHIVE', 'Archive'); + if (['draft', 'modified'].includes(versionState)) { + onUnpublishedVersionedState(); + } + delete attributes.tabIndex; + return _react.default.createElement("div", _extends({ + className: className, + ref: setNodeRef, + style: style + }, attributes, listeners), isMulti && !readonly && !disabled && _react.default.createElement("div", { + className: "link-picker__drag-handle" + }, _react.default.createElement("i", { + className: "font-icon-drag-handle", + tabIndex: "0", + role: "button" + })), _react.default.createElement(_reactstrap.Button, { + disabled: loading, + className: `link-picker__button ${typeIcon}`, + color: "secondary", + onClick: stopPropagation(onClick), + innerRef: buttonRef, + onKeyDown: handleButtonKeyDown + }, _react.default.createElement("div", { + className: "link-picker__link-detail" + }, _react.default.createElement("div", { + className: "link-picker__title" + }, _react.default.createElement("span", { + className: "link-picker__title-text" + }, title), getVersionedBadge(versionState)), _react.default.createElement("small", { + className: "link-picker__type" + }, typeTitle, ":\xA0", _react.default.createElement("span", { + className: "link-picker__url" + }, description))), canDelete && !readonly && _react.default.createElement("span", { + role: "button", + tabIndex: "0", + className: "link-picker__delete btn btn-link", + onKeyDown: handleDeleteKeyDown, + onClick: stopPropagation(() => !loading ? onDelete(id) : null) + }, deleteText))); +}; +LinkPickerTitle.propTypes = { + id: _propTypes.default.number.isRequired, + title: _propTypes.default.string, + description: _propTypes.default.string, + versionState: _propTypes.default.string, + typeTitle: _propTypes.default.string.isRequired, + typeIcon: _propTypes.default.string.isRequired, + onDelete: _propTypes.default.func.isRequired, + onClick: _propTypes.default.func.isRequired, + onButtonKeyDownEdit: _propTypes.default.func.isRequired, + onUnpublishedVersionedState: _propTypes.default.func.isRequired, + canDelete: _propTypes.default.bool.isRequired, + isMulti: _propTypes.default.bool.isRequired, + isFirst: _propTypes.default.bool.isRequired, + isLast: _propTypes.default.bool.isRequired, + isSorting: _propTypes.default.bool.isRequired, + canCreate: _propTypes.default.bool.isRequired, + readonly: _propTypes.default.bool.isRequired, + disabled: _propTypes.default.bool.isRequired, + buttonRef: _propTypes.default.object.isRequired +}; +var _default = LinkPickerTitle; +exports["default"] = _default; + +/***/ }), + +/***/ "./client/src/containers/LinkModalContainer.js": +/*!*****************************************************!*\ + !*** ./client/src/containers/LinkModalContainer.js ***! + \*****************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _react = _interopRequireDefault(__webpack_require__(/*! react */ "react")); +var _Injector = __webpack_require__(/*! lib/Injector */ "lib/Injector"); +var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "prop-types")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const LinkModalContainer = _ref => { + let { + types, + typeKey, + linkID = 0, + isOpen, + onSuccess, + onClosed + } = _ref; + if (!typeKey) { + return false; + } + const type = types.hasOwnProperty(typeKey) ? types[typeKey] : {}; + const handlerName = type && type.hasOwnProperty('handlerName') ? type.handlerName : 'FormBuilderModal'; + const LinkModal = (0, _Injector.loadComponent)(`LinkModal.${handlerName}`); + return _react.default.createElement(LinkModal, { + typeTitle: type.title || '', + typeKey: typeKey, + linkID: linkID, + isOpen: isOpen, + onSuccess: onSuccess, + onClosed: onClosed + }); +}; +LinkModalContainer.propTypes = { + types: _propTypes.default.object.isRequired, + typeKey: _propTypes.default.string.isRequired, + linkID: _propTypes.default.number, + isOpen: _propTypes.default.bool.isRequired, + onSuccess: _propTypes.default.func.isRequired, + onClosed: _propTypes.default.func.isRequired +}; +var _default = LinkModalContainer; +exports["default"] = _default; + +/***/ }), + +/***/ "./client/src/entwine/LinkField.js": +/*!*****************************************!*\ + !*** ./client/src/entwine/LinkField.js ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + + + +var _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ "jquery")); +var _react = _interopRequireDefault(__webpack_require__(/*! react */ "react")); +var _client = _interopRequireDefault(__webpack_require__(/*! react-dom/client */ "react-dom/client")); +var _Injector = __webpack_require__(/*! lib/Injector */ "lib/Injector"); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } +_jquery.default.entwine('ss', $ => { + $('.js-injector-boot .entwine-linkfield').entwine({ + Component: null, + Root: null, + onmatch() { + const cmsContent = this.closest('.cms-content').attr('id'); + const context = cmsContent ? { + context: cmsContent + } : {}; + const schemaComponent = this.data('schema-component'); + const ReactField = (0, _Injector.loadComponent)(schemaComponent, context); + this.setComponent(ReactField); + this.setRoot(_client.default.createRoot(this[0])); + this._super(); + this.refresh(); + }, + refresh() { + const props = this.getProps(); + this.getInputField().val(props.value); + const ReactField = this.getComponent(); + const Root = this.getRoot(); + Root.render(_react.default.createElement(ReactField, _extends({}, props, { + noHolder: true + }))); + }, + handleChange(value) { + this.getInputField().data('value', value); + this.refresh(); + }, + getProps() { + const inputField = this.getInputField(); + return { + value: inputField.data('value'), + ownerID: inputField.data('owner-id'), + ownerClass: inputField.data('owner-class'), + ownerRelation: inputField.data('owner-relation'), + onChange: this.handleChange.bind(this), + isMulti: this.data('is-multi') ?? false, + types: this.data('types') ?? {}, + canCreate: inputField.data('can-create') ? true : false, + readonly: inputField.data('readonly') ? true : false, + disabled: inputField.data('disabled') ? true : false + }; + }, + getInputField() { + const fieldID = this.data('field-id'); + return $(`#${fieldID}`); + }, + onunmatch() { + const Root = this.getRoot(); + if (Root) { + Root.unmount(); + } + } + }); +}); + +/***/ }), + +/***/ "./client/src/types/LinkType.js": +/*!**************************************!*\ + !*** ./client/src/types/LinkType.js ***! + \**************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "prop-types")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const LinkType = _propTypes.default.shape({ + key: _propTypes.default.string.isRequired, + title: _propTypes.default.string.isRequired, + icon: _propTypes.default.string.isRequired +}); +var _default = LinkType; +exports["default"] = _default; + +/***/ }), + +/***/ "lib/Backend": +/*!**************************!*\ + !*** external "Backend" ***! + \**************************/ +/***/ (function(module) { + +module.exports = Backend; + +/***/ }), + +/***/ "lib/Config": +/*!*************************!*\ + !*** external "Config" ***! + \*************************/ +/***/ (function(module) { + +module.exports = Config; + +/***/ }), + +/***/ "components/FieldHolder/FieldHolder": +/*!******************************!*\ + !*** external "FieldHolder" ***! + \******************************/ +/***/ (function(module) { + +module.exports = FieldHolder; + +/***/ }), + +/***/ "components/FormBuilderModal/FormBuilderModal": +/*!***********************************!*\ + !*** external "FormBuilderModal" ***! + \***********************************/ +/***/ (function(module) { + +module.exports = FormBuilderModal; + +/***/ }), + +/***/ "lib/Injector": +/*!***************************!*\ + !*** external "Injector" ***! + \***************************/ +/***/ (function(module) { + +module.exports = Injector; + +/***/ }), + +/***/ "containers/InsertMediaModal/InsertMediaModal": +/*!***********************************!*\ + !*** external "InsertMediaModal" ***! + \***********************************/ +/***/ (function(module) { + +module.exports = InsertMediaModal; + +/***/ }), + +/***/ "components/Loading/Loading": +/*!**************************!*\ + !*** external "Loading" ***! + \**************************/ +/***/ (function(module) { + +module.exports = Loading; + +/***/ }), + +/***/ "url": +/*!**************************!*\ + !*** external "NodeUrl" ***! + \**************************/ +/***/ (function(module) { + +module.exports = NodeUrl; + +/***/ }), + +/***/ "prop-types": +/*!****************************!*\ + !*** external "PropTypes" ***! + \****************************/ +/***/ (function(module) { + +module.exports = PropTypes; + +/***/ }), + +/***/ "react": +/*!************************!*\ + !*** external "React" ***! + \************************/ +/***/ (function(module) { + +module.exports = React; + +/***/ }), + +/***/ "react-dom": +/*!***************************!*\ + !*** external "ReactDom" ***! + \***************************/ +/***/ (function(module) { + +module.exports = ReactDom; + +/***/ }), + +/***/ "react-dom/client": +/*!*********************************!*\ + !*** external "ReactDomClient" ***! + \*********************************/ +/***/ (function(module) { + +module.exports = ReactDomClient; + +/***/ }), + +/***/ "react-redux": +/*!*****************************!*\ + !*** external "ReactRedux" ***! + \*****************************/ +/***/ (function(module) { + +module.exports = ReactRedux; + +/***/ }), + +/***/ "reactstrap": +/*!*****************************!*\ + !*** external "Reactstrap" ***! + \*****************************/ +/***/ (function(module) { + +module.exports = Reactstrap; + +/***/ }), + +/***/ "redux": +/*!************************!*\ + !*** external "Redux" ***! + \************************/ +/***/ (function(module) { + +module.exports = Redux; + +/***/ }), + +/***/ "state/toasts/ToastsActions": +/*!********************************!*\ + !*** external "ToastsActions" ***! + \********************************/ +/***/ (function(module) { + +module.exports = ToastsActions; + +/***/ }), + +/***/ "classnames": +/*!*****************************!*\ + !*** external "classnames" ***! + \*****************************/ +/***/ (function(module) { + +module.exports = classnames; + +/***/ }), + +/***/ "i18n": +/*!***********************!*\ + !*** external "i18n" ***! + \***********************/ +/***/ (function(module) { + +module.exports = i18n; + +/***/ }), + +/***/ "jquery": +/*!*************************!*\ + !*** external "jQuery" ***! + \*************************/ +/***/ (function(module) { + +module.exports = jQuery; + +/***/ }), + +/***/ "qs": +/*!*********************!*\ + !*** external "qs" ***! + \*********************/ +/***/ (function(module) { + +module.exports = qs; + +/***/ }), + +/***/ "lib/urls": +/*!***************************!*\ + !*** external "ssUrlLib" ***! + \***************************/ +/***/ (function(module) { + +module.exports = ssUrlLib; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +!function() { +/*!**************************************!*\ + !*** ./client/src/bundles/bundle.js ***! + \**************************************/ + + +__webpack_require__(/*! boot */ "./client/src/boot/index.js"); +__webpack_require__(/*! entwine/LinkField */ "./client/src/entwine/LinkField.js"); +}(); +/******/ })() +; +//# sourceMappingURL=bundle.js.map \ No newline at end of file diff --git a/client/dist/styles/bundle.css b/client/dist/styles/bundle.css index 84c0f3a3..893afa23 100644 --- a/client/dist/styles/bundle.css +++ b/client/dist/styles/bundle.css @@ -1 +1,216 @@ -.link-field__container{position:relative}.link-field__loading{position:absolute;top:0;left:0;width:100%;height:100%}.link-field__loading .cms-content-loading-overlay{position:relative}.link-field__save-record-first{padding-top:7px}.link-field__container .btn-link{position:absolute;right:0}.link-field__container .btn-link:focus,.link-field__container .btn-link:not(:disabled):not(.disabled):active{box-shadow:none}.link-picker__link,.link-picker{display:flex;height:auto;width:100%;min-height:54px;background:#fff;padding:0}.link-picker{align-items:stretch;cursor:pointer;box-shadow:none}.link-picker:not(:last-child){margin-bottom:10px}.link-picker.font-icon-link::before{margin:.76925rem}.link-picker__cannot-create{cursor:default;flex-grow:1;padding:16px 13px}.link-picker__menu{flex-grow:1}.link-picker__menu-toggle{width:100%;height:100%;text-align:left}.link-picker__menu-toggle::before{padding:.76925rem}.link-picker__menu-icon{vertical-align:middle;padding-right:.7rem}.link-picker__link{align-items:center;text-align:left;margin-right:0;justify-content:space-between;position:relative;border-top:0;border-top-left-radius:0;border-top-right-radius:0;border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0}.link-picker__link:hover,.link-picker__link:focus{text-decoration:none;color:inherit}.link-picker__link::before{top:29px;left:32px;content:" ";position:absolute;border:1px solid #cf3f00;border-radius:100%;bottom:6px;box-shadow:0 0 1px .5px #fff;display:block;height:8px;width:8px;z-index:1}.link-picker__link--draft::before{background-color:#ff7f22}.link-picker__link--modified::before{background-color:#fff7f0}.link-picker__link--unsaved::before,.link-picker__link--unversioned::before,.link-picker__link--published::before{display:none}.link-picker__link--readonly,.link-picker__link--disabled{background-color:#eef0f4}.link-picker__link--is-first,.link-picker__link--is-sorting{border-top:1px solid #ced5e1;border-top-left-radius:.23rem;border-top-right-radius:.23rem}.link-picker__link--is-last,.link-picker__link--is-sorting{border-bottom:1px solid #ced5e1;border-bottom-left-radius:.23rem;border-bottom-right-radius:.23rem}.link-picker__button{display:flex;align-items:center;flex-grow:1;height:100%;min-width:0;text-align:left;border:none;margin-right:0}.link-picker__button[class*=font-icon-]::before{position:absolute;font-size:1.231rem;padding:.76925rem;margin-right:6px;flex-grow:0}.link-picker__drag-handle{display:none;left:5px;position:absolute;z-index:100}.link-picker__drag-handle:hover{cursor:grab}.link-picker__link:hover .link-picker__drag-handle{display:block}.link-picker__links--dragging *{cursor:grabbing !important}.link-picker__link-detail{flex-grow:1;width:100%;padding:0 5rem 0 3.5rem}.link-picker__delete{flex-grow:0}.link-picker__url{color:#0071c4}.link-picker__type,.link-picker__title-text{display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.link-picker__title{display:flex;align-items:center;width:100%}.link-picker__title .badge{color:#cf3f00;background-color:#fff2ea;padding:2px 3px 2px 4px}.link-picker__title-text{min-width:0;margin-right:5px}.link-picker__type{width:100%} +/*!*****************************************************************************************************************************************************************************************************************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[0].use[2]!./node_modules/resolve-url-loader/index.js??ruleSet[1].rules[0].use[3]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[0].use[4]!./client/src/styles/bundle.scss ***! + \*****************************************************************************************************************************************************************************************************************************************************************************************************************************/ +.link-field__container { + position: relative; +} + +.link-field__loading { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} +.link-field__loading .cms-content-loading-overlay { + position: relative; +} + +.link-field__save-record-first { + padding-top: 7px; +} + +.link-field__container .btn-link { + position: absolute; + right: 0; +} +.link-field__container .btn-link:focus, .link-field__container .btn-link:not(:disabled):not(.disabled):active { + box-shadow: none; +} + +.link-picker__link, .link-picker { + display: flex; + height: auto; + width: 100%; + min-height: 54px; + background: white; + padding: 0; +} + +.link-picker { + align-items: stretch; + cursor: pointer; + box-shadow: none; +} +.link-picker:not(:last-child) { + margin-bottom: 10px; +} +.link-picker.font-icon-link::before { + margin: 0.76925rem; +} + +.link-picker__cannot-create { + cursor: default; + flex-grow: 1; + padding: 16px 13px; +} + +.link-picker__menu { + flex-grow: 1; +} + +.link-picker__menu-toggle { + width: 100%; + height: 100%; + text-align: left; +} +.link-picker__menu-toggle::before { + padding: 0.76925rem; +} + +.link-picker__menu-icon { + vertical-align: middle; + padding-right: 0.7rem; +} + +.link-picker__link { + align-items: center; + text-align: left; + margin-right: 0; + justify-content: space-between; + position: relative; + border-top: 0; + border-top-left-radius: 0; + border-top-right-radius: 0; + border-bottom: 0; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} +.link-picker__link:hover, .link-picker__link:focus { + text-decoration: none; + color: inherit; +} +.link-picker__link::before { + top: 29px; + left: 32px; + content: " "; + position: absolute; + border: 1px solid #cf3f00; + border-radius: 100%; + bottom: 6px; + box-shadow: 0 0 1px 0.5px #fff; + display: block; + height: 8px; + width: 8px; + z-index: 1; +} +.link-picker__link--draft::before { + background-color: #ff7f22; +} +.link-picker__link--modified::before { + background-color: #fff7f0; +} +.link-picker__link--unsaved::before, .link-picker__link--unversioned::before, .link-picker__link--published::before { + display: none; +} +.link-picker__link--readonly, .link-picker__link--disabled { + background-color: #eef0f4; +} + +.link-picker__link--is-first, +.link-picker__link--is-sorting { + border-top: 1px solid #ced5e1; + border-top-left-radius: 0.23rem; + border-top-right-radius: 0.23rem; +} + +.link-picker__link--is-last, +.link-picker__link--is-sorting { + border-bottom: 1px solid #ced5e1; + border-bottom-left-radius: 0.23rem; + border-bottom-right-radius: 0.23rem; +} + +.link-picker__button { + display: flex; + align-items: center; + flex-grow: 1; + height: 100%; + min-width: 0; + text-align: left; + border: none; + margin-right: 0; +} +.link-picker__button[class*=font-icon-]::before { + position: absolute; + font-size: 1.231rem; + padding: 0.76925rem; + margin-right: 6px; + flex-grow: 0; +} + +.link-picker__drag-handle { + left: 5px; + position: absolute; + z-index: 100; +} +.link-picker__drag-handle:hover { + cursor: grab; +} +.link-picker__drag-handle .font-icon-drag-handle { + opacity: 0%; +} +.link-picker__drag-handle .font-icon-drag-handle:focus { + opacity: 100%; +} + +.link-picker__link:hover .link-picker__drag-handle .font-icon-drag-handle { + opacity: 100%; +} + +.link-picker__links--dragging * { + cursor: grabbing !important; +} + +.link-picker__link-detail { + flex-grow: 1; + width: 100%; + padding: 0 5rem 0 3.5rem; +} + +.link-picker__delete { + flex-grow: 0; +} + +.link-picker__url { + color: #0071c4; +} + +.link-picker__type, .link-picker__title-text { + display: inline-block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.link-picker__title { + display: flex; + align-items: center; + width: 100%; +} +.link-picker__title .badge { + color: #cf3f00; + background-color: #fff2ea; + padding: 2px 3px 2px 4px; +} + +.link-picker__title-text { + min-width: 0; + margin-right: 5px; +} + +.link-picker__type { + width: 100%; +} + +/*# sourceMappingURL=bundle.css.map*/ \ No newline at end of file diff --git a/client/src/components/LinkField/LinkField.js b/client/src/components/LinkField/LinkField.js index b4cf8142..cff7457e 100644 --- a/client/src/components/LinkField/LinkField.js +++ b/client/src/components/LinkField/LinkField.js @@ -1,11 +1,18 @@ /* eslint-disable */ -import React, { useState, useEffect, createContext } from 'react'; +import React, { useState, useEffect, useRef, createContext } from 'react'; import { bindActionCreators, compose } from 'redux'; import { connect } from 'react-redux'; -import { DndContext, closestCenter, PointerSensor, useSensor, useSensors } from '@dnd-kit/core'; +import { + closestCenter, + DndContext, + KeyboardCode, + KeyboardSensor, + PointerSensor, + useSensor, + useSensors +} from '@dnd-kit/core'; import { arrayMove, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'; import { restrictToVerticalAxis, restrictToParentElement } from '@dnd-kit/modifiers'; -import { injectGraphql } from 'lib/Injector'; import fieldHolder from 'components/FieldHolder/FieldHolder'; import LinkPicker from 'components/LinkPicker/LinkPicker'; import LinkPickerTitle from 'components/LinkPicker/LinkPickerTitle'; @@ -42,7 +49,6 @@ const section = 'SilverStripe\\LinkField\\Controllers\\LinkFieldController'; const LinkField = ({ value = null, onChange, - onNonPublishedVersionedState, types = {}, actions, isMulti = false, @@ -55,6 +61,10 @@ const LinkField = ({ }) => { const [data, setData] = useState({}); const [editingID, setEditingID] = useState(0); + const [isKeyboardEditing, setIsKeyboardEditing] = useState(false); + const [focusOnID, setFocusOnID] = useState(0); + const [focusOnNewLinkWhenClosed, setFocusOnNewLinkWhenClosed] = useState(false); + const [focusOnNewLink, setFocusOnNewLink] = useState(false); const [loading, setLoading] = useState(false); const [forceFetch, setForceFetch] = useState(0); const [isSorting, setIsSorting] = useState(false); @@ -65,6 +75,58 @@ const LinkField = ({ activationConstraint: { distance: 10 } + }), + useSensor(KeyboardSensor, { + coordinateGetter: (event, args) => { + event.preventDefault(); + const { active, over, droppableContainers } = args.context; + if (!active || !active.data || !active.data.current) { + return; + } + const items = active.data.current.sortable.items; + const overId = over ? over.id : active.id; + const overIndex = items.indexOf(overId); + const activeIndex = items.indexOf(active.id); + const directionUp = -1; + const directionDown = 1; + let nextIndex = overIndex; + let direction = directionDown; + switch (event.code) { + case KeyboardCode.Down: + case KeyboardCode.Right: + nextIndex = Math.min(overIndex + 1, items.length - 1); + break; + case KeyboardCode.Up: + case KeyboardCode.Left: + nextIndex = Math.max(0, overIndex - 1); + direction = directionUp; + break; + default: + return; + } + if (overIndex === nextIndex) { + return; + } + const sortedItems = arrayMove(items, activeIndex, overIndex); + const currentNodeIdAtNextIndex = sortedItems[nextIndex]; + if (!droppableContainers.has(currentNodeIdAtNextIndex)) { + return; + } + const activeNode = droppableContainers.get(active.id).node.current; + if (!droppableContainers.has(active.id)) { + return; + } + const newNode = droppableContainers.get(currentNodeIdAtNextIndex).node.current; + const activeRect = activeNode.getBoundingClientRect(); + const newRect = newNode.getBoundingClientRect(); + const offset = direction === directionDown + ? newRect.top - activeRect.bottom + : activeRect.top - newRect.bottom; + return { + x: 0, + y: activeRect.top + direction * (newRect.height + offset), + }; + } }) ); @@ -106,34 +168,96 @@ const LinkField = ({ } }, [editingID, value && value.length, forceFetch]); + // Create refs for each LinkPickerTitle button so they can be focused when the editing modal is closed via keyboard + let refCount = 0; + const linkButtonRefs = [] + for (const linkID of linkIDs) { + linkButtonRefs[linkID] = useRef(null); + refCount++; + } + // Ensure the exact same number of hooks are called on every render + // If this this isn't done then a react error will be thrown when a link is deleted + while (refCount < 256) { + useRef(null); + refCount++; + } + + // Focus on the LinkPickerTitle edit button when the editing modal is closed via keyboard + // or focus on newly created link for single (has_one) linkfield + useEffect(() => { + if ((!focusOnID && !focusOnNewLink) || loading) { + return; + } + let c = 0; + const interval = setInterval(() => { + if (focusOnID && linkButtonRefs[focusOnID].current) { + // Multi linkfield + linkButtonRefs[focusOnID].current.focus(); + clearInterval(interval); + } else if (focusOnNewLink) { + // Non-multi linkfield + if (linkIDs.length === 0) { + // User opened modal but did exited instead of saving + clearInterval(interval); + } else { + // User opened modal and created a new link + const linkID = linkIDs[0]; + if (linkButtonRefs[linkID].current) { + linkButtonRefs[linkID].current.focus(); + clearInterval(interval); + } + } + } + // Safety check + if (++c >= 50) { + clearInterval(interval); + } + }, 50); + setFocusOnID(0); + setFocusOnNewLink(false); + }, [focusOnID, focusOnNewLink, loading]); + /** * Unset the editing ID when the editing modal is closed + * If using keyboard, focus on button used to open the modal */ - const onModalClosed = () => { + const handleModalClosed = () => { + if (isKeyboardEditing) { + setIsKeyboardEditing(false); + if (editingID) { + setFocusOnID(editingID); + } else if (focusOnNewLinkWhenClosed) { + setFocusOnNewLink(true); + } + } setEditingID(0); + setFocusOnNewLinkWhenClosed(false); }; /** * Update the component when the modal successfully saves a link */ - const onModalSuccess = (value) => { - // update component state - setEditingID(0); - + const handleModalSuccess = (value) => { + handleModalClosed(); const ids = [...linkIDs]; if (!ids.includes(value)) { ids.push(value); } - // Update value in the underlying form field // so that the Page (or other parent DataObject) gets the Link relation set. // Also likely required in react context for dirty form state, etc. onChange(isMulti ? ids : ids[0]); - // success toast actions.toasts.success(i18n._t('LinkField.SAVE_SUCCESS', 'Saved link')); } + const handleLinkPickerKeyDownEdit = () => { + if (!isMulti) { + setFocusOnNewLinkWhenClosed(true); + setIsKeyboardEditing(true); + } + } + /** * Update the component when the 'Delete' button in the LinkPicker is clicked */ @@ -218,7 +342,6 @@ const LinkField = ({ */ const renderLinks = () => { const links = []; - for (let i = 0; i < linkIDs.length; i++) { const linkID = linkIDs[i]; // Only render items we have data for @@ -237,6 +360,7 @@ const LinkField = ({ typeIcon={type.icon} onDelete={handleDelete} onClick={() => { setEditingID(linkID); }} + onButtonKeyDownEdit={() => setIsKeyboardEditing(true)} onUnpublishedVersionedState={handleUnpublishedVersionedState} canDelete={data[linkID]?.canDelete ? true : false} isMulti={isMulti} @@ -246,6 +370,7 @@ const LinkField = ({ canCreate={canCreate} readonly={readonly} disabled={disabled} + buttonRef={linkButtonRefs[linkID]} />); } return links; @@ -253,7 +378,7 @@ const LinkField = ({ const sortableLinks = () => { if (isMulti && !readonly && !disabled) { - return
+ return
setIsSorting(false)}> {saveRecordFirstText}
} { loading && !isSorting && !saveRecordFirst && } { renderPicker && } {sortableLinks()} { renderModal && } diff --git a/client/src/components/LinkPicker/LinkPicker.js b/client/src/components/LinkPicker/LinkPicker.js index c7d20678..4e17450d 100644 --- a/client/src/components/LinkPicker/LinkPicker.js +++ b/client/src/components/LinkPicker/LinkPicker.js @@ -9,7 +9,15 @@ import LinkModalContainer from 'containers/LinkModalContainer'; /** * Component which allows users to choose a type of link to create, and opens a modal form for it. */ -const LinkPicker = ({ types, onModalSuccess, onModalClosed, canCreate, readonly, disabled }) => { +const LinkPicker = ({ + types, + onModalSuccess, + onModalClosed, + canCreate, + readonly, + disabled, + onKeyDownEdit, +}) => { const [typeKey, setTypeKey] = useState(''); /** @@ -55,7 +63,11 @@ const LinkPicker = ({ types, onModalSuccess, onModalClosed, canCreate, readonly, return (
- + { shouldOpenModal && { +const LinkPickerMenu = ({ types, onSelect, onKeyDownEdit }) => { const [isOpen, setIsOpen] = useState(false); const toggle = () => setIsOpen(prevState => !prevState); const { loading } = useContext(LinkFieldContext); + const handleKeyDown = (event) => { + if (['Enter', 'Space'].includes(event.code)) { + onKeyDownEdit(); + } + } + return - + {i18n._t('LinkField.ADD_LINK', 'Add Link')} {types.map(({key, title, icon, allowed}) => { return allowed && - onSelect(key)}> + {onSelect(key)}} + onKeyDown={handleKeyDown} + > {title} @@ -36,6 +50,7 @@ const LinkPickerMenu = ({ types, onSelect }) => { LinkPickerMenu.propTypes = { types: PropTypes.arrayOf(LinkType).isRequired, onSelect: PropTypes.func.isRequired, + onKeyDownEdit: PropTypes.func.isRequired, }; export default LinkPickerMenu; diff --git a/client/src/components/LinkPicker/LinkPickerTitle.js b/client/src/components/LinkPicker/LinkPickerTitle.js index ab2f1197..9b69516f 100644 --- a/client/src/components/LinkPicker/LinkPickerTitle.js +++ b/client/src/components/LinkPicker/LinkPickerTitle.js @@ -41,6 +41,7 @@ const LinkPickerTitle = ({ typeIcon, onDelete, onClick, + onButtonKeyDownEdit, onUnpublishedVersionedState, canDelete, isMulti, @@ -50,6 +51,7 @@ const LinkPickerTitle = ({ canCreate, readonly, disabled, + buttonRef, }) => { const { loading } = useContext(LinkFieldContext); const { @@ -59,6 +61,27 @@ const LinkPickerTitle = ({ transform, transition, } = useSortable({id}); + + const handleButtonKeyDown = (event) => { + // Prevent the triggering the parent's keyboard sorting handler + event.nativeEvent.stopImmediatePropagation(); + event.stopPropagation(); + if (['Enter', 'Space'].includes(event.code) && !loading) { + onButtonKeyDownEdit(event); + } + }; + + const handleDeleteKeyDown = (event) => { + if (!['Enter', 'Space'].includes(event.code) || loading) { + return; + } + event.nativeEvent.stopImmediatePropagation(); + event.stopPropagation(); + onDelete(id); + event.nativeEvent.preventDefault(); + event.preventDefault(); + }; + const style = { transform: CSS.Transform.toString(transform), transition, @@ -82,6 +105,9 @@ const LinkPickerTitle = ({ if (['draft', 'modified'].includes(versionState)) { onUnpublishedVersionedState(); } + // Remove the default tabindex="0" attribute from the sortable element because we're going to manually + // add this to the drag handle instead + delete attributes.tabIndex; return
- { (isMulti && !readonly && !disabled) &&
} -