text: !function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var K=require("tslib"),Q=K.__importStar(require("react")),U=require("react-gesture-responder"),V=require("react-spring"),W=require("./use-measure"),Y=K.__importDefault(require("use-scroll-lock")),Z=require("./use-previous");exports.default=Q.forwardRef(function(e,n){var t=e.children,r=e.id,i=e.value,o=e.onRequestChange,a=(e.focusOnChange,e.enableScrollLock),u=void 0===a||a,s=e.enableGestures,l=void 0===s||s,f=e.enableMouse,c=void 0!==f&&f,d=e.lazyLoad,v=void 0!==d&&d,m=e.onSetLazy,h=e.animationConfig,y=void 0===h?{tension:190,friction:20,mass:.4}:h,p=e.onTerminationRequest,x=e.onMoveShouldSet,S=e.style,g=K.__rest(e,["children","id","value","onRequestChange","focusOnChange","enableScrollLock","enableGestures","enableMouse","lazyLoad","onSetLazy","animationConfig","onTerminationRequest","onMoveShouldSet","style"]),_="number"==typeof i?{immediate:!1,index:i}:i,b=_.immediate,w=_.index,R=Q.useRef(null),M=Q.useState(!1),q=M[0],C=M[1],G=Q.useState(function(){return new Set(m?m(w):[w])}),E=G[0],L=G[1],k=W.useMeasure(R).width,D=Q.useRef(new Map),z=Z.usePrevious(w),T=Q.useRef(null);function N(e){var n=D.current.get(e);n&&n.focus()}Y.default(q&&u),Q.useEffect(function(){T.current="number"==typeof z&&z!==w?w:null},[z,w]),Q.useImperativeHandle(n,function(){return{focus:function(e){N(e||w)}}});var O=V.useSpring(function(){return{x:-100*w,config:y}}),j=O[0].x,A=O[1];function H(){"number"==typeof T.current&&N(T.current)}var I=t.filter(function(e){return null!==e}),P=I.length-1,X=0;function B(e){return 0<e&&e<=P}function F(e){var n=k/2;Math.abs(e)>n?e<0&&w<P?o(w+1):0<e&&X<w?o(w-1):A({x:-100*w}):A({x:-100*w,onRest:H})}Q.useEffect(function(){A({x:-100*w,onRest:H,immediate:b}),E.add(w)},[w,b]);var J=U.useGestureResponder({onTerminationRequest:p,onStartShouldSet:function(){return!1},onMoveShouldSet:function(e,n){e.xy;var t=e.initialDirection;if(!l)return!1;var r=Math.abs(t[0])>Math.abs(t[1]);return x?x(e,n,r):r},onGrant:function(){C(!0)},onMove:function(e){var n=e.delta,t=e.direction,r=n[0];A({x:r/k*100+-100*w,immediate:!0,onRest:function(){}}),function(n){if(B(n)){var e=n;m&&(e=m(n));var t=Array.isArray(e)?e:[e],r=new Set(E);t.forEach(function(e){!E.has(e)&&B(n)&&r.add(e)}),L(r)}}(0<t[0]?w-1:w+1)},onRelease:function(e){var n=e.delta,t=e.velocity,r=e.direction,i=n[0];return C(!1),.2<t&&0<r[0]&&X<w?o(w-1):.2<t&&r[0]<0&&w<P?o(w+1):void F(i)},onTerminate:function(e){var n=e.delta;C(!1),F(n[0])}},{uid:r,enableMouse:c}).bind;return Q.createElement("div",K.__assign({},J,{ref:R,className:"Gesture-view",style:K.__assign({display:"flex",flexDirection:"column",overflow:"hidden",width:"100%"},S)},g),Q.createElement(V.animated.div,{className:"Gesture-view__animated-container",style:{flexDirection:"row",direction:"ltr",willChange:"transform",minHeight:0,flex:1,display:"flex",transform:j.interpolate(function(e){return"translateX("+function(e,n){if(0<e)return.3*e;if(e<n){var t=e-n;return e-.7*t}return e}(e,-100*P)+"%)"})}},I.map(function(e,n){var t={key:n,tabIndex:w===n?0:-1,style:{display:"flex",flexDirection:"column",width:"100%",alignSelf:"stretch",justifyContent:"flex-start",flexShrink:0,height:"100%",overflow:"hidden",outline:"none"},"aria-hidden":n!==w,ref:function(e){D.current.set(n,e)}},r=!v||w===n||E.has(n);return"function"==typeof e?e(t,w===n,r):Q.createElement("div",K.__assign({className:"Gesture-view__pane"},t),r&&e)})))})});
  