@starlly-labs/photo-viewer
Advanced tools
Comparing version 1.0.14 to 1.0.15
@@ -1,2 +0,2 @@ | ||
var e=require("react"),t=require("react-dom");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/n(e);function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(null,arguments)}function a(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function i(t){var n=e.useRef({fn:t,curr:void 0}).current;if(n.fn=t,!n.curr){var r=Object.create(null);Object.keys(t).forEach(function(e){r[e]=function(){var t;return(t=n.fn[e]).call.apply(t,[n.fn].concat([].slice.call(arguments)))}}),n.curr=r}return n.curr}function u(t){return e.useReducer(function(e,t){return o({},e,"function"==typeof t?t(e):t)},t)}var l=e.createContext(void 0),c="cubic-bezier(0.25, 0.8, 0.25, 1)",s=20,d="undefined"!=typeof window&&"ontouchstart"in window,f=function(e,t,n){return Math.max(Math.min(e,n),t)},v=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),f(e,1*(1-n),Math.max(6,t)*(1+n))},h="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?e.useEffect:e.useLayoutEffect;function m(t,n,r){var o=e.useRef(n);o.current=n,e.useEffect(function(){function e(e){o.current(e)}return t&&window.addEventListener(t,e,r),function(){t&&window.removeEventListener(t,e)}},[t])}var g=["container"];function p(e){var n=e.container,i=void 0===n?document.body:n,u=a(e,g);return t.createPortal(r.default.createElement("div",o({},u)),i)}function w(e){return r.default.createElement("svg",o({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function b(e){return r.default.createElement("svg",o({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function E(){return e.useEffect(function(){var e=document.body.style,t=e.overflow;return e.overflow="hidden",function(){e.overflow=t}},[]),null}function R(e){return r.default.createElement("svg",o({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function y(e){var t=e.toolbarRender,n=e.overlayParams,o=e.toolbarLeftRender,a=e.toolbarRightRender;return r.default.createElement(r.default.Fragment,null,e.bannerVisible&&r.default.createElement("div",{className:"PhotoView-Slider__BannerWrap"},r.default.createElement("div",{className:"PhotoView-Slider__Counter"},e.index+1," / ",e.imageLength),r.default.createElement("div",{className:"PhotoView-Slider__BannerRight"},t&&n&&t(n),r.default.createElement(R,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),o&&n&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},o(n)),a&&n&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},a(n)))}function x(e){var t=e.touches[0],n=t.clientX,r=t.clientY;if(e.touches.length>=2){var o=e.touches[1],a=o.clientX,i=o.clientY;return[(n+a)/2,(r+i)/2,Math.sqrt(Math.pow(a-n,2)+Math.pow(i-r,2))]}return[n,r,0]}var C=function(e,t,n,r){var o,a=n*t,i=(a-r)/2,u=e;return a<=r?(o=1,u=0):e>0&&i-e<=0?(o=2,u=i):e<0&&i+e<=0&&(o=3,u=-i),[o,u]};function P(e,t,n){var r=e%180!=0;return r?[n,t,r]:[t,n,r]}function _(t,n){var r=n.leading,o=void 0!==r&&r,a=n.maxWait,i=n.wait,u=void 0===i?a||0:i,l=e.useRef(t);l.current=t;var c=e.useRef(0),s=e.useRef(),d=function(){return s.current&&clearTimeout(s.current)},f=e.useCallback(function(){var e=[].slice.call(arguments),t=Date.now();function n(){c.current=t,d(),l.current.apply(null,e)}var r=c.current,i=t-r;if(0===r&&(o&&n(),c.current=t),void 0!==a){if(i>a)return void n()}else i<u&&(c.current=t);d(),s.current=setTimeout(function(){n(),c.current=0},u)},[u,a,o]);return f.cancel=d,f}var S=function(){};S.globalDivRef=null,S.sidebarWidth=400;var k=function(e){S.globalDivRef=e},M=function(){return innerWidth-(innerWidth<=900?0:S.sidebarWidth)};function V(e,t,n,r,o,a,i,u,l,c){void 0===i&&(i=M()/2),void 0===u&&(u=innerHeight/2),void 0===l&&(l=0),void 0===c&&(c=0);var s=C(e,a,n,M())[0],d=C(t,a,r,innerHeight)[0],f=M()/2,v=innerHeight/2,h=u-a/o*(u-(v+t))-v;return{x:i-a/o*(i-(f+e))-f+(r/n>=3&&n*a===M()?0:s?l/2:l),y:h+(d?c/2:c),lastCX:i,lastCY:u}}var N=function(e,t,n){return F(e,t,n,100,function(e){return e},function(){return F(t,e,n)})},Y=function(e){return 1-Math.pow(1-e,4)};function F(e,t,n,r,o,a){void 0===r&&(r=400),void 0===o&&(o=Y);var i=t-e;if(0!==i){var u=Date.now(),l=0,c=function(){var t=Math.min(1,(Date.now()-u)/r);n(e+o(t)*i)&&t<1?s():(cancelAnimationFrame(l),t>=1&&a&&a())};s()}function s(){l=requestAnimationFrame(c)}}var T={T:0,L:0,W:0,H:0,FIT:void 0},X=function(){var t=e.useRef(!1);return e.useEffect(function(){return t.current=!0,function(){t.current=!1}},[]),t},L=["className"];function W(e){var t=e.className,n=void 0===t?"":t,i=a(e,L);return r.default.createElement("div",o({className:"PhotoView__Spinner "+n},i),r.default.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},r.default.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),r.default.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var I=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function A(e){var t=e.src,n=e.loaded,i=e.broken,u=e.className,l=e.onPhotoLoad,c=e.loadingElement,s=e.brokenElement,d=a(e,I),f=X();return t&&!i?r.default.createElement(r.default.Fragment,null,r.default.createElement("img",o({className:"PhotoView__Photo"+(u?" "+u:""),src:t,onLoad:function(e){var t=e.target;f.current&&l({loaded:!0,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight})},onError:function(){f.current&&l({broken:!0})},alt:""},d)),!n&&(r.default.createElement("span",{className:"PhotoView__icon"},c)||r.default.createElement(W,{className:"PhotoView__icon"}))):s?r.default.createElement("span",{className:"PhotoView__icon"},"function"==typeof s?s({src:t}):s):null}function q(e,t,n){var r=P(n,M(),innerHeight),o=r[0],a=r[1],i=0,u=o,l=a,c=e/t*a,s=t/e*o;return e<o&&t<a?(u=e,l=t):e<o&&t>=a?u=c:e>=o&&t<a||e/t>o/a?l=s:t/e>=3&&!r[2]?i=((l=s)-a)/2:u=c,{width:u,height:l,x:0,y:i,pause:!0}}var D={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function H(t){var n=t.item,a=n.src,l=n.render,c=n.width,s=void 0===c?0:c,f=n.height,g=void 0===f?0:f,p=n.originRef,w=t.visible,b=t.speed,E=t.easing,R=t.wrapClassName,y=t.className,S=t.style,k=t.loadingElement,Y=t.brokenElement,L=t.onPhotoTap,W=t.onMaskTap,I=t.onReachMove,H=t.onReachUp,B=t.onPhotoResize,O=t.isActive,z=t.expose,j=u(D),K=j[0],U=j[1],G=e.useRef(0),J=X(),Q=K.naturalWidth,Z=void 0===Q?s:Q,$=K.naturalHeight,ee=void 0===$?g:$,te=K.width,ne=void 0===te?s:te,re=K.height,oe=void 0===re?g:re,ae=K.loaded,ie=void 0===ae?!a:ae,ue=K.broken,le=K.x,ce=K.y,se=K.touched,de=K.stopRaf,fe=K.maskTouched,ve=K.rotate,he=K.scale,me=K.CX,ge=K.CY,pe=K.lastX,we=K.lastY,be=K.lastCX,Ee=K.lastCY,Re=K.lastScale,ye=K.touchTime,xe=K.touchLength,Ce=K.pause,Pe=K.reach,_e=i({onScale:function(e){return Se(v(e))},onRotate:function(e){ve!==e&&(z({rotate:e}),U(o({rotate:e},q(Z,ee,e))))}});function Se(e,t,n){he!==e&&(z({scale:e}),U(o({scale:e},V(le,ce,ne,oe,he,e,t,n),e<=1&&{x:0,y:0})))}var ke=_(function(e,t,n){if(void 0===n&&(n=0),(se||fe)&&O){var r=P(ve,ne,oe),a=r[0],i=r[1];if(0===n&&0===G.current){var u=Math.abs(e-me)<=20,l=Math.abs(t-ge)<=20;if(u&&l)return void U({lastCX:e,lastCY:t});G.current=u?t>ge?3:2:1}var c,s=e-be,d=t-Ee;if(0===n){var f=C(s+pe,he,a,M())[0],h=C(d+we,he,i,innerHeight);c=function(e,t,n,r){return t&&1===e||"x"===r?"x":n&&e>1||"y"===r?"y":void 0}(G.current,f,h[0],Pe),void 0!==c&&I(c,e,t,he)}if("x"===c||fe)return void U({reach:"x"});var m=v(he+(n-xe)/100/2*he,Z/ne,.2);z({scale:m}),U(o({touchLength:n,reach:c,scale:m},V(le,ce,ne,oe,he,m,e,t,s,d)))}},{maxWait:8});function Me(e){return!de&&!se&&(J.current&&U(o({},e,{pause:w})),J.current)}var Ve,Ne,Ye,Fe,Te,Xe,Le,We,Ie=(Te=function(e){return Me({x:e})},Xe=function(e){return Me({y:e})},Le=function(e){return J.current&&(z({scale:e}),U({scale:e})),!se&&J.current},We=i({X:function(e){return Te(e)},Y:function(e){return Xe(e)},S:function(e){return Le(e)}}),function(e,t,n,r,o,a,i,u,l,c,s){var d=P(c,o,a),f=d[0],v=d[1],h=C(e,u,f,M()),m=h[0],g=h[1],p=C(t,u,v,innerHeight),w=p[0],b=p[1],E=Date.now()-s;if(E>=200||u!==i||Math.abs(l-i)>1){var R=V(e,t,o,a,i,u),y=R.x,x=R.y,_=m?g:y!==e?y:null,S=w?b:x!==t?x:null;return null!==_&&F(e,_,We.X),null!==S&&F(t,S,We.Y),void(u!==i&&F(i,u,We.S))}var k=(e-n)/E,Y=(t-r)/E,T=Math.sqrt(Math.pow(k,2)+Math.pow(Y,2)),X=!1,L=!1;!function(e,t){var n,r=e,o=0,a=0,i=function(a){n||(n=a);var i=a-n,c=Math.sign(e),s=-.001*c,d=Math.sign(-r)*Math.pow(r,2)*2e-4,f=r*i+(s+d)*Math.pow(i,2)/2;o+=f,n=a,c*(r+=(s+d)*i)<=0?l():t(o)?u():l()};function u(){a=requestAnimationFrame(i)}function l(){cancelAnimationFrame(a)}u()}(T,function(n){var r=e+n*(k/T),o=t+n*(Y/T),a=C(r,i,f,M()),u=a[0],l=a[1],c=C(o,i,v,innerHeight),s=c[0],d=c[1];if(u&&!X&&(X=!0,m?F(r,l,We.X):N(l,r+(r-l),We.X)),s&&!L&&(L=!0,w?F(o,d,We.Y):N(d,o+(o-d),We.Y)),X&&L)return!1;var h=X||We.X(l),g=L||We.Y(d);return h&&g})}),Ae=(Ve=L,Ne=function(e,t){Pe||Se(1!==he?1:Math.max(2,Z/ne),e,t)},Ye=e.useRef(0),Fe=_(function(){Ye.current=0,Ve.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);Ye.current+=1,Fe.apply(void 0,e),Ye.current>=2&&(Fe.cancel(),Ye.current=0,Ne.apply(void 0,e))});function qe(e,t){if(G.current=0,(se||fe)&&O){U({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var n=v(he,Z/ne);if(Ie(le,ce,pe,we,ne,oe,he,n,Re,ve,ye),H(e,t),me===e&&ge===t){if(se)return void Ae(e,t);fe&&W(e,t)}}}function De(e,t,n){void 0===n&&(n=0),U({touched:!0,CX:e,CY:t,lastCX:e,lastCY:t,lastX:le,lastY:ce,lastScale:he,touchLength:n,touchTime:Date.now()})}function He(e){U({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:le,lastY:ce})}m(d?void 0:"mousemove",function(e){e.preventDefault(),ke(e.clientX,e.clientY)}),m(d?void 0:"mouseup",function(e){qe(e.clientX,e.clientY)}),m(d?"touchmove":void 0,function(e){e.preventDefault();var t=x(e);ke.apply(void 0,t)},{passive:!1}),m(d?"touchend":void 0,function(e){var t=e.changedTouches[0];qe(t.clientX,t.clientY)},{passive:!1}),m("resize",_(function(){ie&&!se&&(U(q(Z,ee,ve)),B())},{maxWait:8})),h(function(){O&&z(o({scale:he,rotate:ve},_e))},[O]);var Be=function(t,n,r,o,a,l,c,s,d,f){var v=function(t,n,r,o,a){var i=e.useRef(!1),l=u({lead:!0,scale:r}),c=l[0],s=c.lead,d=c.scale,f=l[1],v=_(function(e){try{return a(!0),f({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:o});return h(function(){i.current?(a(!1),f({lead:!0}),v(r)):i.current=!0},[r]),s?[t*d,n*d,r/d]:[t*r,n*r,1]}(l,c,s,d,f),m=v[0],g=v[1],p=v[2],w=function(t,n,r,o,a){var u=e.useState(T),l=u[0],c=u[1],s=e.useState(0),d=s[0],f=s[1],v=e.useRef(),h=i({OK:function(){return t&&f(4)}});function m(e){a(!1),f(e)}return e.useEffect(function(){if(v.current||(v.current=Date.now()),r){if(function(e,t){var n=e&&e.current;if(n&&1===n.nodeType){var r=n.getBoundingClientRect();t({T:r.top,L:r.left,W:r.width,H:r.height,FIT:"IMG"===n.tagName?getComputedStyle(n).objectFit:void 0})}}(n,c),t)return Date.now()-v.current<250?(f(1),requestAnimationFrame(function(){f(2),requestAnimationFrame(function(){return m(3)})}),void setTimeout(h.OK,o)):void f(4);m(5)}},[t,r]),[d,l]}(t,n,r,d,f),b=w[0],E=w[1],R=E.T,y=E.L,x=E.W,C=E.H,P=E.FIT,S=M()/2,k=innerHeight/2,V=b<3||b>4;return[V?x?y:S:o+(S-l*s/2),V?x?R:k:a+(k-c*s/2),m,V&&P?m*(C/x):g,0===b?p:V?x/(l*s)||.01:p,V?P?1:0:1,b,P]}(w,p,ie,le,ce,ne,oe,he,b,function(e){return U({pause:e})}),Oe=Be[4],ze=Be[6],je="transform "+b+"ms "+E,Ke={className:y,onMouseDown:d?void 0:function(e){e.stopPropagation(),0===e.button&&De(e.clientX,e.clientY,0)},onTouchStart:d?function(e){e.stopPropagation(),De.apply(void 0,x(e))}:void 0,onWheel:function(e){if(!Pe){var t=v(he-e.deltaY/100/2,Z/ne);U({stopRaf:!0}),Se(t,e.clientX,e.clientY)}},style:{width:Be[2]+"px",height:Be[3]+"px",opacity:Be[5],objectFit:4===ze?void 0:Be[7],transform:ve?"rotate("+ve+"deg)":void 0,transition:ze>2?je+", opacity "+b+"ms ease, height "+(ze<4?b/2:ze>4?b:0)+"ms "+E:void 0}};return r.default.createElement("div",{className:"PhotoView__PhotoWrap"+(R?" "+R:""),style:S,onMouseDown:!d&&O?He:void 0,onTouchStart:d&&O?function(e){return He(e.touches[0])}:void 0},r.default.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+Oe+", 0, 0, "+Oe+", "+Be[0]+", "+Be[1]+")",transition:se||Ce?void 0:je,willChange:O?"transform":void 0}},a?r.default.createElement(A,o({src:a,loaded:ie,broken:ue},Ke,{onPhotoLoad:function(e){U(o({},e,e.loaded&&q(e.naturalWidth||0,e.naturalHeight||0,ve)))},loadingElement:k,brokenElement:Y})):l&&l({attrs:Ke,scale:Oe,rotate:ve})))}var B={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function O(t){var n=t.loop,o=void 0===n?3:n,a=t.speed,l=t.easing,v=t.photoClosable,g=t.maskClosable,R=void 0===g||g,x=t.maskOpacity,C=void 0===x?1:x,P=t.pullClosable,_=void 0===P||P,S=t.pullAction,V=t.bannerVisible,N=void 0===V||V,Y=t.overlayRender,F=t.toolbarRender,T=t.showBackdropImage,X=t.disableScroll,L=void 0===X||X,W=t.toolbarLeftRender,I=t.toolbarRightRender,A=t.toolbarBottomRender,q=t.sidebarWidth,D=t.sidebarLeftRender,O=t.sidebarRightRender,z=t.className,j=t.maskClassName,K=t.photoClassName,U=t.photoWrapClassName,G=t.loadingElement,J=t.brokenElement,Q=t.images,Z=t.index,$=void 0===Z?0:Z,ee=t.onIndexChange,te=t.visible,ne=t.onClose,re=t.afterClose,oe=t.portalContainer,ae=t.fullScreen,ie=t.onFullScreen,ue=u(B),le=ue[0],ce=ue[1],se=e.useState(0),de=se[0],fe=se[1],ve=e.useRef();e.useEffect(function(){return ve.current&&k(ve.current),function(){k(null)}},[te]);var he=le.x,me=le.touched,ge=le.pause,pe=le.lastCX,we=le.lastCY,be=le.bg,Ee=void 0===be?C:be,Re=le.lastBg,ye=le.overlay,xe=le.minimal,Ce=le.scale,Pe=le.rotate,_e=le.onScale,Se=le.onRotate,ke=t.hasOwnProperty("index"),Me=ke?$:de,Ve=ke?ee:fe,Ne=e.useRef(Me),Ye=Q.length,Fe=Q[Me],Te="boolean"==typeof o?o:Ye>o,Xe=function(t,n){var r=e.useReducer(function(e){return!e},!1)[1],o=e.useRef(0),a=function(n){var r=e.useRef(n);function a(e){r.current=e}return e.useMemo(function(){!function(e){t?(e(t),o.current=1):o.current=2}(a)},[n]),[r.current,a]}(t),i=a[1];return[a[0],o.current,function(){r(),2===o.current&&(i(!1),n&&n()),o.current=0}]}(te,re),Le=Xe[0],We=Xe[1],Ie=Xe[2];h(function(){if(Le)return ce({pause:!0,x:Me*-(M()+s)}),void(Ne.current=Me);ce(B)},[Le]);var Ae=i({close:function(e){Se&&Se(0),ce({overlay:!0,lastBg:Ee}),ne(e)},changeIndex:function(e,t){void 0===t&&(t=!1);var n=Te?Ne.current+(e-Me):e,r=Ye-1,o=f(n,0,r),a=Te?n:o,i=M()+s;ce({touched:!1,lastCX:void 0,lastCY:void 0,x:-i*a,pause:t}),Ne.current=a,Ve&&Ve(Te?e<0?r:e>r?0:e:o)}}),qe=Ae.close,De=Ae.changeIndex,He=e.useCallback(function(){ie(!ae)},[ae,ie]),Be=e.useMemo(function(){return function(){!document.fullscreenElement&&ae&&He()}},[ae,He]),Oe=e.useMemo(function(){return function(){if(document.fullscreenElement)document.exitFullscreen();else if(ae){var e=ve.current;if(!e)return;!function(e){try{e&&(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}catch(e){console.log("Error al intentar activar el modo de pantalla completa",e)}}(e)}}},[ve,ae]);function ze(e){return e?qe():ce({overlay:!ye})}function je(){ce({x:-(M()+s)*Me,lastCX:void 0,lastCY:void 0,pause:!0}),Ne.current=Me}function Ke(e,t,n,r){"x"===e?function(e){if(void 0!==pe){var t=e-pe,n=t;!Te&&(0===Me&&t>0||Me===Ye-1&&t<0)&&(n=t/2),ce({touched:!0,lastCX:pe,x:-(M()+s)*Ne.current+n,pause:!1})}else ce({touched:!0,lastCX:e,x:he,pause:!1})}(t):"y"===e&&function(e,t){if(void 0!==we){var n=null===C?null:f(C,.01,C-Math.abs(e-we)/100/4);ce({touched:!0,lastCY:we,bg:1===t?n:C,minimal:1===t})}else ce({touched:!0,lastCY:e,bg:Ee,minimal:!0})}(n,r)}function Ue(e,t){var n=e-(null!=pe?pe:e),r=t-(null!=we?we:t),o=!1;if(n<-40)De(Me+1);else if(n>40)De(Me-1);else{var a=-(M()+s)*Ne.current;Math.abs(r)>100&&xe&&_?(o=!0,qe()):Math.abs(r)>100&&xe&&"function"==typeof S&&S({direction:r<0?"top":"bottom",offsetY:r}),ce({touched:!1,x:a,lastCX:void 0,lastCY:void 0,bg:C,overlay:!!o||ye})}}e.useEffect(function(){if(ve.current)return Oe(),document.addEventListener("fullscreenchange",Be),function(){document.removeEventListener("fullscreenchange",Be)}},[ve,ae,Be,Oe]),m("keydown",function(e){if(te)switch(e.key){case"ArrowLeft":De(Me-1,!1);break;case"ArrowRight":De(Me+1,!1);break;case"Escape":qe()}});var Ge=function(t,n,r){return e.useMemo(function(){var e=t.length;return r?t.concat(t).concat(t).slice(e+n-1,e+n+2):t.slice(Math.max(n-1,0),Math.min(n+2,e+1))},[t,n,r])}(Q,Me,Te);if(!Le)return null;var Je=ye&&!We,Qe=te?Ee:Re,Ze=_e&&Se&&{images:Q,index:Me,visible:te,onClose:qe,onIndexChange:De,overlayVisible:Je,overlay:Fe&&Fe.overlay,scale:Ce,rotate:Pe,onScale:_e,onRotate:Se,fullScreen:ae,fullScreenAvailable:document.documentElement.requestFullscreen||document.documentElement.mozRequestFullScreen||document.documentElement.webkitRequestFullscreen||document.documentElement.msRequestFullscreen,toggleFullScreen:function(){return ie(!ae)}},$e=a?a(We):400,et=l?l(We):c,tt=a?a(3):600,nt=l?l(3):c,rt="number"==typeof q?q+"px":q,ot=window.innerWidth<=900;return r.default.createElement(p,{className:"PhotoView-Portal"+(Je?"":" PhotoView-Slider__clean")+(te?"":" PhotoView-Slider__willClose")+(z?" "+z:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:oe},te&&L&&r.default.createElement(E,null),r.default.createElement("div",{className:"PhotoView-Container"},D&&Ze&&!ot&&r.default.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===We?" PhotoView-Slider__fadeIn":2===We?" PhotoView-Slider__fadeOut":""),style:{width:rt,transitionTimingFunction:et,transitionDuration:(me?0:$e)+"ms",animationDuration:$e+"ms"}},D(Ze)),r.default.createElement("div",{ref:ve,className:"PhotoView-Viewer"},r.default.createElement("div",{className:"PhotoView-Slider__Backdrop"+(j?" "+j:"")+(1===We?" PhotoView-Slider__fadeIn":2===We?" PhotoView-Slider__fadeOut":"")+" "+(T?"with-backdrop-image":""),style:{background:T?"url("+Fe.src+")":Qe?"rgba(0, 0, 0, "+Qe+")":void 0,transitionTimingFunction:et,transitionDuration:(me?0:$e)+"ms",animationDuration:$e+"ms"},onAnimationEnd:Ie}),r.default.createElement(y,{bannerVisible:N,index:Me,imageLength:Ye,overlayParams:Ze,toolbarRender:F,toolbarLeftRender:W,toolbarRightRender:I,toolbarBottomRender:A}),Ge.map(function(e,t){var n=Te||0!==Me?Ne.current-1+t:Me+t;return r.default.createElement(H,{key:Te?e.key+"/"+e.src+"/"+n:e.key,item:e,speed:$e,easing:et,visible:te,onReachMove:Ke,onReachUp:Ue,onPhotoTap:function(){return ze(v)},onMaskTap:function(){return ze(R)},wrapClassName:U,className:K,style:{left:(M()+s)*n+"px",transform:"translate3d("+he+"px, 0px, 0)",transition:me||ge?void 0:"transform "+tt+"ms "+nt},loadingElement:G,brokenElement:J,onPhotoResize:je,isActive:Ne.current===n,expose:ce})}),!d&&N&&r.default.createElement(r.default.Fragment,null,(Te||0!==Me)&&r.default.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return De(Me-1,!0)}},r.default.createElement(w,null)),(Te||Me+1<Ye)&&r.default.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return De(Me+1,!0)}},r.default.createElement(b,null))),Y&&Ze&&r.default.createElement("div",{className:"PhotoView-Slider__Overlay"},Y(Ze))),O&&Ze&&!ot&&r.default.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===We?" PhotoView-Slider__fadeIn":2===We?" PhotoView-Slider__fadeOut":""),style:{width:rt,transitionTimingFunction:et,transitionDuration:(me?0:$e)+"ms",animationDuration:$e+"ms"}},O(Ze)),A&&Ze&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Bottom",style:{width:"calc(100% - "+(ot?0:rt)+")"}},A(Ze))))}var z=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],j={images:[],visible:!1,index:0,fullScreen:!1};exports.PhotoProvider=function(t){var n=t.children,c=t.onIndexChange,s=t.onVisibleChange,d=t.sidebarLeftRender,f=t.sidebarRightRender,v=t.sidebarWidth,h=void 0===v?400:v,m=a(t,z),g=u(j),p=g[0],w=g[1],b=e.useRef(0),E=p.images,R=p.visible,y=p.index;e.useEffect(function(){S.sidebarWidth=d||f?h:0},[d,f,h]);var x=i({nextId:function(){return b.current+=1},update:function(e){var t=E.findIndex(function(t){return t.key===e.key});if(t>-1){var n=E.slice();return n.splice(t,1,e),void w({images:n})}w(function(t){return{images:t.images.concat(e)}})},remove:function(e){w(function(t){var n=t.images.filter(function(t){return t.key!==e});return{images:n,index:Math.min(n.length-1,y)}})},show:function(e){var t=E.findIndex(function(t){return t.key===e});w({visible:!0,index:t}),s&&s(!0,t,p)}}),C=i({close:function(){w({visible:!1}),s&&s(!1,y,p)},changeIndex:function(e){w({index:e}),c&&c(e,p)},fullScreen:function(e){w({fullScreen:e})}}),P=e.useMemo(function(){return o({},p,x)},[p,x]);return r.default.createElement(l.Provider,{value:P},n,r.default.createElement(O,o({images:E,visible:R,index:y,fullScreen:p.fullScreen,onIndexChange:C.changeIndex,onClose:C.close,onFullScreen:C.fullScreen,sidebarWidth:h,sidebarLeftRender:d,sidebarRightRender:f},m)))},exports.PhotoSlider=O,exports.PhotoView=function(t){var n,r,a=t.src,u=t.render,c=t.overlay,s=t.width,d=t.height,f=t.triggers,v=void 0===f?["onClick"]:f,h=t.children,m=e.useContext(l),g=(n=function(){return m.nextId()},(r=e.useRef({sign:!1,fn:void 0}).current).sign||(r.sign=!0,r.fn=n()),r.fn),p=e.useRef(null);e.useImperativeHandle(null==h?void 0:h.ref,function(){return p.current}),e.useEffect(function(){return function(){m.remove(g)}},[]);var w=i({render:function(e){return u&&u(e)},show:function(e,t){m.show(g),function(e,t){if(h){var n=h.props[e];n&&n(t)}}(e,t)}}),b=e.useMemo(function(){var e={};return v.forEach(function(t){e[t]=w.show.bind(null,t)}),e},[]);return e.useEffect(function(){m.update({key:g,src:a,originRef:p,render:w.render,overlay:c,width:s,height:d})},[a]),h?e.Children.only(e.cloneElement(h,o({},b,{ref:p}))):null}; | ||
var e=require("react"),t=require("react-dom");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/n(e);function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(null,arguments)}function i(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function a(t){var n=e.useRef({fn:t,curr:void 0}).current;if(n.fn=t,!n.curr){var r=Object.create(null);Object.keys(t).forEach(function(e){r[e]=function(){var t;return(t=n.fn[e]).call.apply(t,[n.fn].concat([].slice.call(arguments)))}}),n.curr=r}return n.curr}function u(t){return e.useReducer(function(e,t){return o({},e,"function"==typeof t?t(e):t)},t)}var l=e.createContext(void 0),c="cubic-bezier(0.25, 0.8, 0.25, 1)",s=20,d="undefined"!=typeof window&&"ontouchstart"in window,f=function(e,t,n){return Math.max(Math.min(e,n),t)},v=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),f(e,1*(1-n),Math.max(6,t)*(1+n))},h="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?e.useEffect:e.useLayoutEffect;function m(t,n,r){var o=e.useRef(n);o.current=n,e.useEffect(function(){function e(e){o.current(e)}return t&&window.addEventListener(t,e,r),function(){t&&window.removeEventListener(t,e)}},[t])}var g=["container"];function p(e){var n=e.container,a=void 0===n?document.body:n,u=i(e,g);return t.createPortal(r.default.createElement("div",o({},u)),a)}function w(e){return r.default.createElement("svg",o({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function b(e){return r.default.createElement("svg",o({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function E(){return e.useEffect(function(){var e=document.body.style,t=e.overflow;return e.overflow="hidden",function(){e.overflow=t}},[]),null}function R(e){return r.default.createElement("svg",o({width:"44",height:"44",viewBox:"0 0 768 768"},e),r.default.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function y(e){var t=e.toolbarRender,n=e.overlayParams,o=e.toolbarLeftRender,i=e.toolbarRightRender;return r.default.createElement(r.default.Fragment,null,e.bannerVisible&&r.default.createElement("div",{className:"PhotoView-Slider__BannerWrap"},r.default.createElement("div",{className:"PhotoView-Slider__Counter"},e.index+1," / ",e.imageLength),r.default.createElement("div",{className:"PhotoView-Slider__BannerRight"},t&&n&&t(n),r.default.createElement(R,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),o&&n&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},o(n)),i&&n&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},i(n)))}function x(e){var t=e.touches[0],n=t.clientX,r=t.clientY;if(e.touches.length>=2){var o=e.touches[1],i=o.clientX,a=o.clientY;return[(n+i)/2,(r+a)/2,Math.sqrt(Math.pow(i-n,2)+Math.pow(a-r,2))]}return[n,r,0]}var C=function(e,t,n,r){var o,i=n*t,a=(i-r)/2,u=e;return i<=r?(o=1,u=0):e>0&&a-e<=0?(o=2,u=a):e<0&&a+e<=0&&(o=3,u=-a),[o,u]};function P(e,t,n){var r=e%180!=0;return r?[n,t,r]:[t,n,r]}function S(t,n){var r=n.leading,o=void 0!==r&&r,i=n.maxWait,a=n.wait,u=void 0===a?i||0:a,l=e.useRef(t);l.current=t;var c=e.useRef(0),s=e.useRef(),d=function(){return s.current&&clearTimeout(s.current)},f=e.useCallback(function(){var e=[].slice.call(arguments),t=Date.now();function n(){c.current=t,d(),l.current.apply(null,e)}var r=c.current,a=t-r;if(0===r&&(o&&n(),c.current=t),void 0!==i){if(a>i)return void n()}else a<u&&(c.current=t);d(),s.current=setTimeout(function(){n(),c.current=0},u)},[u,i,o]);return f.cancel=d,f}var _=function(){};_.globalDivRef=null,_.sidebarWidth=400,_.fullScreen=!1;var k=function(e){_.globalDivRef=e},M=function(){return innerWidth-(innerWidth<=900||_.fullScreen?0:_.sidebarWidth)};function V(e,t,n,r,o,i,a,u,l,c){void 0===a&&(a=M()/2),void 0===u&&(u=innerHeight/2),void 0===l&&(l=0),void 0===c&&(c=0);var s=C(e,i,n,M())[0],d=C(t,i,r,innerHeight)[0],f=M()/2,v=innerHeight/2,h=u-i/o*(u-(v+t))-v;return{x:a-i/o*(a-(f+e))-f+(r/n>=3&&n*i===M()?0:s?l/2:l),y:h+(d?c/2:c),lastCX:a,lastCY:u}}var N=function(e,t,n){return F(e,t,n,100,function(e){return e},function(){return F(t,e,n)})},Y=function(e){return 1-Math.pow(1-e,4)};function F(e,t,n,r,o,i){void 0===r&&(r=400),void 0===o&&(o=Y);var a=t-e;if(0!==a){var u=Date.now(),l=0,c=function(){var t=Math.min(1,(Date.now()-u)/r);n(e+o(t)*a)&&t<1?s():(cancelAnimationFrame(l),t>=1&&i&&i())};s()}function s(){l=requestAnimationFrame(c)}}var T={T:0,L:0,W:0,H:0,FIT:void 0},X=function(){var t=e.useRef(!1);return e.useEffect(function(){return t.current=!0,function(){t.current=!1}},[]),t},L=["className"];function W(e){var t=e.className,n=void 0===t?"":t,a=i(e,L);return r.default.createElement("div",o({className:"PhotoView__Spinner "+n},a),r.default.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},r.default.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),r.default.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var I=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function A(e){var t=e.src,n=e.loaded,a=e.broken,u=e.className,l=e.onPhotoLoad,c=e.loadingElement,s=e.brokenElement,d=i(e,I),f=X();return t&&!a?r.default.createElement(r.default.Fragment,null,r.default.createElement("img",o({className:"PhotoView__Photo"+(u?" "+u:""),src:t,onLoad:function(e){var t=e.target;f.current&&l({loaded:!0,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight})},onError:function(){f.current&&l({broken:!0})},alt:""},d)),!n&&(r.default.createElement("span",{className:"PhotoView__icon"},c)||r.default.createElement(W,{className:"PhotoView__icon"}))):s?r.default.createElement("span",{className:"PhotoView__icon"},"function"==typeof s?s({src:t}):s):null}function q(e,t,n){var r=P(n,M(),innerHeight),o=r[0],i=r[1],a=0,u=o,l=i,c=e/t*i,s=t/e*o;return e<o&&t<i?(u=e,l=t):e<o&&t>=i?u=c:e>=o&&t<i||e/t>o/i?l=s:t/e>=3&&!r[2]?a=((l=s)-i)/2:u=c,{width:u,height:l,x:0,y:a,pause:!0}}var D={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function H(t){var n=t.item,i=n.src,l=n.render,c=n.width,s=void 0===c?0:c,f=n.height,g=void 0===f?0:f,p=n.originRef,w=t.visible,b=t.speed,E=t.easing,R=t.wrapClassName,y=t.className,_=t.style,k=t.loadingElement,Y=t.brokenElement,L=t.onPhotoTap,W=t.onMaskTap,I=t.onReachMove,H=t.onReachUp,B=t.onPhotoResize,O=t.isActive,z=t.expose,j=u(D),K=j[0],U=j[1],G=e.useRef(0),J=X(),Q=K.naturalWidth,Z=void 0===Q?s:Q,$=K.naturalHeight,ee=void 0===$?g:$,te=K.width,ne=void 0===te?s:te,re=K.height,oe=void 0===re?g:re,ie=K.loaded,ae=void 0===ie?!i:ie,ue=K.broken,le=K.x,ce=K.y,se=K.touched,de=K.stopRaf,fe=K.maskTouched,ve=K.rotate,he=K.scale,me=K.CX,ge=K.CY,pe=K.lastX,we=K.lastY,be=K.lastCX,Ee=K.lastCY,Re=K.lastScale,ye=K.touchTime,xe=K.touchLength,Ce=K.pause,Pe=K.reach,Se=a({onScale:function(e){return _e(v(e))},onRotate:function(e){ve!==e&&(z({rotate:e}),U(o({rotate:e},q(Z,ee,e))))}});function _e(e,t,n){he!==e&&(z({scale:e}),U(o({scale:e},V(le,ce,ne,oe,he,e,t,n),e<=1&&{x:0,y:0})))}var ke=S(function(e,t,n){if(void 0===n&&(n=0),(se||fe)&&O){var r=P(ve,ne,oe),i=r[0],a=r[1];if(0===n&&0===G.current){var u=Math.abs(e-me)<=20,l=Math.abs(t-ge)<=20;if(u&&l)return void U({lastCX:e,lastCY:t});G.current=u?t>ge?3:2:1}var c,s=e-be,d=t-Ee;if(0===n){var f=C(s+pe,he,i,M())[0],h=C(d+we,he,a,innerHeight);c=function(e,t,n,r){return t&&1===e||"x"===r?"x":n&&e>1||"y"===r?"y":void 0}(G.current,f,h[0],Pe),void 0!==c&&I(c,e,t,he)}if("x"===c||fe)return void U({reach:"x"});var m=v(he+(n-xe)/100/2*he,Z/ne,.2);z({scale:m}),U(o({touchLength:n,reach:c,scale:m},V(le,ce,ne,oe,he,m,e,t,s,d)))}},{maxWait:8});function Me(e){return!de&&!se&&(J.current&&U(o({},e,{pause:w})),J.current)}var Ve,Ne,Ye,Fe,Te,Xe,Le,We,Ie=(Te=function(e){return Me({x:e})},Xe=function(e){return Me({y:e})},Le=function(e){return J.current&&(z({scale:e}),U({scale:e})),!se&&J.current},We=a({X:function(e){return Te(e)},Y:function(e){return Xe(e)},S:function(e){return Le(e)}}),function(e,t,n,r,o,i,a,u,l,c,s){var d=P(c,o,i),f=d[0],v=d[1],h=C(e,u,f,M()),m=h[0],g=h[1],p=C(t,u,v,innerHeight),w=p[0],b=p[1],E=Date.now()-s;if(E>=200||u!==a||Math.abs(l-a)>1){var R=V(e,t,o,i,a,u),y=R.x,x=R.y,S=m?g:y!==e?y:null,_=w?b:x!==t?x:null;return null!==S&&F(e,S,We.X),null!==_&&F(t,_,We.Y),void(u!==a&&F(a,u,We.S))}var k=(e-n)/E,Y=(t-r)/E,T=Math.sqrt(Math.pow(k,2)+Math.pow(Y,2)),X=!1,L=!1;!function(e,t){var n,r=e,o=0,i=0,a=function(i){n||(n=i);var a=i-n,c=Math.sign(e),s=-.001*c,d=Math.sign(-r)*Math.pow(r,2)*2e-4,f=r*a+(s+d)*Math.pow(a,2)/2;o+=f,n=i,c*(r+=(s+d)*a)<=0?l():t(o)?u():l()};function u(){i=requestAnimationFrame(a)}function l(){cancelAnimationFrame(i)}u()}(T,function(n){var r=e+n*(k/T),o=t+n*(Y/T),i=C(r,a,f,M()),u=i[0],l=i[1],c=C(o,a,v,innerHeight),s=c[0],d=c[1];if(u&&!X&&(X=!0,m?F(r,l,We.X):N(l,r+(r-l),We.X)),s&&!L&&(L=!0,w?F(o,d,We.Y):N(d,o+(o-d),We.Y)),X&&L)return!1;var h=X||We.X(l),g=L||We.Y(d);return h&&g})}),Ae=(Ve=L,Ne=function(e,t){Pe||_e(1!==he?1:Math.max(2,Z/ne),e,t)},Ye=e.useRef(0),Fe=S(function(){Ye.current=0,Ve.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);Ye.current+=1,Fe.apply(void 0,e),Ye.current>=2&&(Fe.cancel(),Ye.current=0,Ne.apply(void 0,e))});function qe(e,t){if(G.current=0,(se||fe)&&O){U({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var n=v(he,Z/ne);if(Ie(le,ce,pe,we,ne,oe,he,n,Re,ve,ye),H(e,t),me===e&&ge===t){if(se)return void Ae(e,t);fe&&W(e,t)}}}function De(e,t,n){void 0===n&&(n=0),U({touched:!0,CX:e,CY:t,lastCX:e,lastCY:t,lastX:le,lastY:ce,lastScale:he,touchLength:n,touchTime:Date.now()})}function He(e){U({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:le,lastY:ce})}m(d?void 0:"mousemove",function(e){e.preventDefault(),ke(e.clientX,e.clientY)}),m(d?void 0:"mouseup",function(e){qe(e.clientX,e.clientY)}),m(d?"touchmove":void 0,function(e){e.preventDefault();var t=x(e);ke.apply(void 0,t)},{passive:!1}),m(d?"touchend":void 0,function(e){var t=e.changedTouches[0];qe(t.clientX,t.clientY)},{passive:!1}),m("resize",S(function(){ae&&!se&&(U(q(Z,ee,ve)),B())},{maxWait:8})),h(function(){O&&z(o({scale:he,rotate:ve},Se))},[O]);var Be=function(t,n,r,o,i,l,c,s,d,f){var v=function(t,n,r,o,i){var a=e.useRef(!1),l=u({lead:!0,scale:r}),c=l[0],s=c.lead,d=c.scale,f=l[1],v=S(function(e){try{return i(!0),f({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:o});return h(function(){a.current?(i(!1),f({lead:!0}),v(r)):a.current=!0},[r]),s?[t*d,n*d,r/d]:[t*r,n*r,1]}(l,c,s,d,f),m=v[0],g=v[1],p=v[2],w=function(t,n,r,o,i){var u=e.useState(T),l=u[0],c=u[1],s=e.useState(0),d=s[0],f=s[1],v=e.useRef(),h=a({OK:function(){return t&&f(4)}});function m(e){i(!1),f(e)}return e.useEffect(function(){if(v.current||(v.current=Date.now()),r){if(function(e,t){var n=e&&e.current;if(n&&1===n.nodeType){var r=n.getBoundingClientRect();t({T:r.top,L:r.left,W:r.width,H:r.height,FIT:"IMG"===n.tagName?getComputedStyle(n).objectFit:void 0})}}(n,c),t)return Date.now()-v.current<250?(f(1),requestAnimationFrame(function(){f(2),requestAnimationFrame(function(){return m(3)})}),void setTimeout(h.OK,o)):void f(4);m(5)}},[t,r]),[d,l]}(t,n,r,d,f),b=w[0],E=w[1],R=E.T,y=E.L,x=E.W,C=E.H,P=E.FIT,_=M()/2,k=innerHeight/2,V=b<3||b>4;return[V?x?y:_:o+(_-l*s/2),V?x?R:k:i+(k-c*s/2),m,V&&P?m*(C/x):g,0===b?p:V?x/(l*s)||.01:p,V?P?1:0:1,b,P]}(w,p,ae,le,ce,ne,oe,he,b,function(e){return U({pause:e})}),Oe=Be[4],ze=Be[6],je="transform "+b+"ms "+E,Ke={className:y,onMouseDown:d?void 0:function(e){e.stopPropagation(),0===e.button&&De(e.clientX,e.clientY,0)},onTouchStart:d?function(e){e.stopPropagation(),De.apply(void 0,x(e))}:void 0,onWheel:function(e){if(!Pe){var t=v(he-e.deltaY/100/2,Z/ne);U({stopRaf:!0}),_e(t,e.clientX,e.clientY)}},style:{width:Be[2]+"px",height:Be[3]+"px",opacity:Be[5],objectFit:4===ze?void 0:Be[7],transform:ve?"rotate("+ve+"deg)":void 0,transition:ze>2?je+", opacity "+b+"ms ease, height "+(ze<4?b/2:ze>4?b:0)+"ms "+E:void 0}};return r.default.createElement("div",{className:"PhotoView__PhotoWrap"+(R?" "+R:""),style:_,onMouseDown:!d&&O?He:void 0,onTouchStart:d&&O?function(e){return He(e.touches[0])}:void 0},r.default.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+Oe+", 0, 0, "+Oe+", "+Be[0]+", "+Be[1]+")",transition:se||Ce?void 0:je,willChange:O?"transform":void 0}},i?r.default.createElement(A,o({src:i,loaded:ae,broken:ue},Ke,{onPhotoLoad:function(e){U(o({},e,e.loaded&&q(e.naturalWidth||0,e.naturalHeight||0,ve)))},loadingElement:k,brokenElement:Y})):l&&l({attrs:Ke,scale:Oe,rotate:ve})))}var B={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function O(t){var n=t.loop,o=void 0===n?3:n,i=t.speed,l=t.easing,v=t.photoClosable,g=t.maskClosable,R=void 0===g||g,x=t.maskOpacity,C=void 0===x?1:x,P=t.pullClosable,S=void 0===P||P,V=t.pullAction,N=t.bannerVisible,Y=void 0===N||N,F=t.overlayRender,T=t.toolbarRender,X=t.showBackdropImage,L=t.disableScroll,W=void 0===L||L,I=t.toolbarLeftRender,A=t.toolbarRightRender,q=t.toolbarBottomRender,D=t.sidebarWidth,O=t.sidebarLeftRender,z=t.sidebarRightRender,j=t.className,K=t.maskClassName,U=t.photoClassName,G=t.photoWrapClassName,J=t.loadingElement,Q=t.brokenElement,Z=t.images,$=t.index,ee=void 0===$?0:$,te=t.onIndexChange,ne=t.visible,re=t.onClose,oe=t.afterClose,ie=t.portalContainer,ae=t.fullScreen,ue=t.onFullScreen,le=u(B),ce=le[0],se=le[1],de=e.useState(0),fe=de[0],ve=de[1],he=e.useRef();e.useEffect(function(){return he.current&&k(he.current),function(){k(null)}},[ne]);var me=ce.x,ge=ce.touched,pe=ce.pause,we=ce.lastCX,be=ce.lastCY,Ee=ce.bg,Re=void 0===Ee?C:Ee,ye=ce.lastBg,xe=ce.overlay,Ce=ce.minimal,Pe=ce.scale,Se=ce.rotate,_e=ce.onScale,ke=ce.onRotate,Me=t.hasOwnProperty("index"),Ve=Me?ee:fe,Ne=Me?te:ve,Ye=e.useRef(Ve),Fe=Z.length,Te=Z[Ve],Xe="boolean"==typeof o?o:Fe>o,Le=function(t,n){var r=e.useReducer(function(e){return!e},!1)[1],o=e.useRef(0),i=function(n){var r=e.useRef(n);function i(e){r.current=e}return e.useMemo(function(){!function(e){t?(e(t),o.current=1):o.current=2}(i)},[n]),[r.current,i]}(t),a=i[1];return[i[0],o.current,function(){r(),2===o.current&&(a(!1),n&&n()),o.current=0}]}(ne,oe),We=Le[0],Ie=Le[1],Ae=Le[2];h(function(){if(We)return se({pause:!0,x:Ve*-(M()+s)}),void(Ye.current=Ve);se(B)},[We]);var qe=a({close:function(e){ke&&ke(0),se({overlay:!0,lastBg:Re}),re(e)},changeIndex:function(e,t){void 0===t&&(t=!1);var n=Xe?Ye.current+(e-Ve):e,r=Fe-1,o=f(n,0,r),i=Xe?n:o,a=M()+s;se({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*i,pause:t}),Ye.current=i,Ne&&Ne(Xe?e<0?r:e>r?0:e:o)}}),De=qe.close,He=qe.changeIndex,Be=e.useCallback(function(){ue(!ae)},[ae,ue]),Oe=e.useMemo(function(){return function(){!document.fullscreenElement&&ae&&Be()}},[ae,Be]),ze=e.useMemo(function(){return function(){if(document.fullscreenElement)document.exitFullscreen();else if(ae){var e=he.current;if(!e)return;!function(e){try{e&&(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}catch(e){console.log("Error al intentar activar el modo de pantalla completa",e)}}(e)}}},[he,ae]);function je(e){return e?De():se({overlay:!xe})}function Ke(){se({x:-(M()+s)*Ve,lastCX:void 0,lastCY:void 0,pause:!0}),Ye.current=Ve}function Ue(e,t,n,r){"x"===e?function(e){if(void 0!==we){var t=e-we,n=t;!Xe&&(0===Ve&&t>0||Ve===Fe-1&&t<0)&&(n=t/2),se({touched:!0,lastCX:we,x:-(M()+s)*Ye.current+n,pause:!1})}else se({touched:!0,lastCX:e,x:me,pause:!1})}(t):"y"===e&&function(e,t){if(void 0!==be){var n=null===C?null:f(C,.01,C-Math.abs(e-be)/100/4);se({touched:!0,lastCY:be,bg:1===t?n:C,minimal:1===t})}else se({touched:!0,lastCY:e,bg:Re,minimal:!0})}(n,r)}function Ge(e,t){var n=e-(null!=we?we:e),r=t-(null!=be?be:t),o=!1;if(n<-40)He(Ve+1);else if(n>40)He(Ve-1);else{var i=-(M()+s)*Ye.current;Math.abs(r)>100&&Ce&&S?(o=!0,De()):Math.abs(r)>100&&Ce&&"function"==typeof V&&V({direction:r<0?"top":"bottom",offsetY:r}),se({touched:!1,x:i,lastCX:void 0,lastCY:void 0,bg:C,overlay:!!o||xe})}}e.useEffect(function(){if(he.current)return ze(),function(e){_.fullScreen=e}(ae),document.addEventListener("fullscreenchange",Oe),function(){document.removeEventListener("fullscreenchange",Oe)}},[he,ae,Oe,ze]),m("keydown",function(e){if(ne)switch(e.key){case"ArrowLeft":He(Ve-1,!1);break;case"ArrowRight":He(Ve+1,!1);break;case"Escape":De()}});var Je=function(t,n,r){return e.useMemo(function(){var e=t.length;return r?t.concat(t).concat(t).slice(e+n-1,e+n+2):t.slice(Math.max(n-1,0),Math.min(n+2,e+1))},[t,n,r])}(Z,Ve,Xe);if(!We)return null;var Qe=xe&&!Ie,Ze=ne?Re:ye,$e=_e&&ke&&{images:Z,index:Ve,visible:ne,onClose:De,onIndexChange:He,overlayVisible:Qe,overlay:Te&&Te.overlay,scale:Pe,rotate:Se,onScale:_e,onRotate:ke,fullScreen:ae,fullScreenAvailable:document.documentElement.requestFullscreen||document.documentElement.mozRequestFullScreen||document.documentElement.webkitRequestFullscreen||document.documentElement.msRequestFullscreen,toggleFullScreen:function(){return ue(!ae)}},et=i?i(Ie):400,tt=l?l(Ie):c,nt=i?i(3):600,rt=l?l(3):c,ot="number"==typeof D?D+"px":D,it=window.innerWidth<=900;return r.default.createElement(p,{className:"PhotoView-Portal"+(Qe?"":" PhotoView-Slider__clean")+(ne?"":" PhotoView-Slider__willClose")+(j?" "+j:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:ie},ne&&W&&r.default.createElement(E,null),r.default.createElement("div",{className:"PhotoView-Container"},O&&$e&&!it&&r.default.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===Ie?" PhotoView-Slider__fadeIn":2===Ie?" PhotoView-Slider__fadeOut":""),style:{width:ot,transitionTimingFunction:tt,transitionDuration:(ge?0:et)+"ms",animationDuration:et+"ms"}},O($e)),r.default.createElement("div",{ref:he,className:"PhotoView-Viewer"},r.default.createElement("div",{className:"PhotoView-Slider__Backdrop"+(K?" "+K:"")+(1===Ie?" PhotoView-Slider__fadeIn":2===Ie?" PhotoView-Slider__fadeOut":"")+" "+(X?"with-backdrop-image":""),style:{background:X?"url("+Te.src+")":Ze?"rgba(0, 0, 0, "+Ze+")":void 0,transitionTimingFunction:tt,transitionDuration:(ge?0:et)+"ms",animationDuration:et+"ms"},onAnimationEnd:Ae}),r.default.createElement(y,{bannerVisible:Y,index:Ve,imageLength:Fe,overlayParams:$e,toolbarRender:T,toolbarLeftRender:I,toolbarRightRender:A,toolbarBottomRender:q}),Je.map(function(e,t){var n=Xe||0!==Ve?Ye.current-1+t:Ve+t;return r.default.createElement(H,{key:Xe?e.key+"/"+e.src+"/"+n:e.key,item:e,speed:et,easing:tt,visible:ne,onReachMove:Ue,onReachUp:Ge,onPhotoTap:function(){return je(v)},onMaskTap:function(){return je(R)},wrapClassName:G,className:U,style:{left:(M()+s)*n+"px",transform:"translate3d("+me+"px, 0px, 0)",transition:ge||pe?void 0:"transform "+nt+"ms "+rt},loadingElement:J,brokenElement:Q,onPhotoResize:Ke,isActive:Ye.current===n,expose:se})}),!d&&Y&&r.default.createElement(r.default.Fragment,null,(Xe||0!==Ve)&&r.default.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return He(Ve-1,!0)}},r.default.createElement(w,null)),(Xe||Ve+1<Fe)&&r.default.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return He(Ve+1,!0)}},r.default.createElement(b,null))),F&&$e&&r.default.createElement("div",{className:"PhotoView-Slider__Overlay"},F($e))),z&&$e&&!it&&r.default.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===Ie?" PhotoView-Slider__fadeIn":2===Ie?" PhotoView-Slider__fadeOut":""),style:{width:ot,transitionTimingFunction:tt,transitionDuration:(ge?0:et)+"ms",animationDuration:et+"ms"}},z($e)),q&&$e&&r.default.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Bottom",style:{width:"calc(100% - "+(it?0:ot)+")"}},q($e))))}var z=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],j={images:[],visible:!1,index:0,fullScreen:!1};exports.PhotoProvider=function(t){var n=t.children,c=t.onIndexChange,s=t.onVisibleChange,d=t.sidebarLeftRender,f=t.sidebarRightRender,v=t.sidebarWidth,h=void 0===v?400:v,m=i(t,z),g=u(j),p=g[0],w=g[1],b=e.useRef(0),E=p.images,R=p.visible,y=p.index;e.useEffect(function(){_.sidebarWidth=d||f?h:0},[d,f,h]);var x=a({nextId:function(){return b.current+=1},update:function(e){var t=E.findIndex(function(t){return t.key===e.key});if(t>-1){var n=E.slice();return n.splice(t,1,e),void w({images:n})}w(function(t){return{images:t.images.concat(e)}})},remove:function(e){w(function(t){var n=t.images.filter(function(t){return t.key!==e});return{images:n,index:Math.min(n.length-1,y)}})},show:function(e){var t=E.findIndex(function(t){return t.key===e});w({visible:!0,index:t}),s&&s(!0,t,p)}}),C=a({close:function(){w({visible:!1}),s&&s(!1,y,p)},changeIndex:function(e){w({index:e}),c&&c(e,p)},fullScreen:function(e){w({fullScreen:e})}}),P=e.useMemo(function(){return o({},p,x)},[p,x]);return r.default.createElement(l.Provider,{value:P},n,r.default.createElement(O,o({images:E,visible:R,index:y,fullScreen:p.fullScreen,onIndexChange:C.changeIndex,onClose:C.close,onFullScreen:C.fullScreen,sidebarWidth:h,sidebarLeftRender:d,sidebarRightRender:f},m)))},exports.PhotoSlider=O,exports.PhotoView=function(t){var n,r,i=t.src,u=t.render,c=t.overlay,s=t.width,d=t.height,f=t.triggers,v=void 0===f?["onClick"]:f,h=t.children,m=e.useContext(l),g=(n=function(){return m.nextId()},(r=e.useRef({sign:!1,fn:void 0}).current).sign||(r.sign=!0,r.fn=n()),r.fn),p=e.useRef(null);e.useImperativeHandle(null==h?void 0:h.ref,function(){return p.current}),e.useEffect(function(){return function(){m.remove(g)}},[]);var w=a({render:function(e){return u&&u(e)},show:function(e,t){m.show(g),function(e,t){if(h){var n=h.props[e];n&&n(t)}}(e,t)}}),b=e.useMemo(function(){var e={};return v.forEach(function(t){e[t]=w.show.bind(null,t)}),e},[]);return e.useEffect(function(){m.update({key:g,src:i,originRef:p,render:w.render,overlay:c,width:s,height:d})},[i]),h?e.Children.only(e.cloneElement(h,o({},b,{ref:p}))):null}; | ||
//# sourceMappingURL=react-photo-view.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{useRef as t,useReducer as n,createContext as o,useEffect as r,useLayoutEffect as i,useMemo as a,useCallback as c,useState as l,useContext as s,useImperativeHandle as u,Children as d,cloneElement as h}from"react";import{createPortal as m}from"react-dom";function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},f.apply(null,arguments)}function v(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}function g(e){const{current:n}=t({fn:e,curr:void 0});if(n.fn=e,!n.curr){const t=Object.create(null);Object.keys(e).forEach(e=>{t[e]=(...t)=>n.fn[e].call(n.fn,...t)}),n.curr=t}return n.curr}function b(e){return n((e,t)=>f({},e,"function"==typeof t?t(e):t),e)}var w=o(void 0);const p="cubic-bezier(0.25, 0.8, 0.25, 1)",E=20,y=1,x="undefined"!=typeof window&&"ontouchstart"in window,C=(e,t,n)=>Math.max(Math.min(e,n),t),_=(e,t=0,n=0)=>C(e,1*(1-n),Math.max(6,t)*(1+n));var R="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?r:i;function P(e,n,o){const i=t(n);i.current=n,r(()=>{function t(e){i.current(e)}return e&&window.addEventListener(e,t,o),()=>{e&&window.removeEventListener(e,t)}},[e])}const S=["container"];function k(t){let{container:n=document.body}=t,o=v(t,S);return m(e.createElement("div",f({},o)),n)}function V(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function $(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function N(){return r(()=>{const{style:e}=document.body,t=e.overflow;return e.overflow="hidden",()=>{e.overflow=t}},[]),null}function Y(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function F({bannerVisible:t,index:n,imageLength:o,toolbarRender:r,overlayParams:i,toolbarLeftRender:a,toolbarRightRender:c}){return e.createElement(e.Fragment,null,t&&e.createElement("div",{className:"PhotoView-Slider__BannerWrap"},e.createElement("div",{className:"PhotoView-Slider__Counter"},n+1," / ",o),e.createElement("div",{className:"PhotoView-Slider__BannerRight"},r&&i&&r(i),e.createElement(Y,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),a&&i&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},a(i)),c&&i&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},c(i)))}function T(e){const{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>=2){const{clientX:o,clientY:r}=e.touches[1];return[(t+o)/2,(n+r)/2,Math.sqrt((o-t)**2+(r-n)**2)]}return[t,n,0]}const X=(e,t,n,o)=>{const r=n*t,i=(r-o)/2;let a,c=e;return r<=o?(a=1,c=0):e>0&&i-e<=0?(a=2,c=i):e<0&&i+e<=0&&(a=3,c=-i),[a,c]};function M(e,t,n){const o=e%180!=0;return o?[n,t,o]:[t,n,o]}function L(e,{leading:n=!1,maxWait:o,wait:r=o||0}){const i=t(e);i.current=e;const a=t(0),l=t(),s=()=>l.current&&clearTimeout(l.current),u=c((...e)=>{const t=Date.now();function c(){a.current=t,s(),i.current.apply(null,e)}const u=a.current,d=t-u;if(0===u&&(n&&c(),a.current=t),void 0!==o){if(d>o)return void c()}else d<r&&(a.current=t);s(),l.current=setTimeout(()=>{c(),a.current=0},r)},[r,o,n]);return u.cancel=s,u}class W{}W.globalDivRef=null,W.sidebarWidth=400;const A=e=>{W.globalDivRef=e},I=()=>innerWidth-(innerWidth<=900?0:W.sidebarWidth);function D(e,t,n,o,r,i,a=I()/2,c=innerHeight/2,l=0,s=0){const[u]=X(e,i,n,I()),[d]=X(t,i,o,innerHeight),h=I()/2,m=innerHeight/2,f=c-i/r*(c-(m+t))-m;return{x:a-i/r*(a-(h+e))-h+(o/n>=3&&n*i===I()?0:u?l/2:l),y:f+(d?s/2:s),lastCX:a,lastCY:c}}const q=(e,t,n)=>H(e,t,n,100,e=>e,()=>H(t,e,n)),B=e=>1-(1-e)**4;function H(e,t,n,o=400,r=B,i){const a=t-e;if(0===a)return;const c=Date.now();let l=0;const s=()=>{const t=Math.min(1,(Date.now()-c)/o);n(e+r(t)*a)&&t<1?u():(cancelAnimationFrame(l),t>=1&&i&&i())};function u(){l=requestAnimationFrame(s)}u()}const O={T:0,L:0,W:0,H:0,FIT:void 0},z=()=>{const e=t(!1);return r(()=>(e.current=!0,()=>{e.current=!1}),[]),e},j=["className"];function K(t){let{className:n=""}=t,o=v(t,j);return e.createElement("div",f({className:`PhotoView__Spinner ${n}`},o),e.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},e.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),e.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}const U=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function G(t){let{src:n,loaded:o,broken:r,className:i,onPhotoLoad:a,loadingElement:c,brokenElement:l}=t,s=v(t,U);const u=z();return n&&!r?e.createElement(e.Fragment,null,e.createElement("img",f({className:"PhotoView__Photo"+(i?` ${i}`:""),src:n,onLoad:function(e){const{naturalWidth:t,naturalHeight:n}=e.target;u.current&&a({loaded:!0,naturalWidth:t,naturalHeight:n})},onError:function(){u.current&&a({broken:!0})},alt:""},s)),!o&&(e.createElement("span",{className:"PhotoView__icon"},c)||e.createElement(K,{className:"PhotoView__icon"}))):l?e.createElement("span",{className:"PhotoView__icon"},"function"==typeof l?l({src:n}):l):null}function J(e,t,n){const[o,r,i]=M(n,I(),innerHeight);let a=0,c=o,l=r;const s=e/t*r,u=t/e*o;return e<o&&t<r?(c=e,l=t):e<o&&t>=r?c=s:e>=o&&t<r||e/t>o/r?l=u:t/e>=3&&!i?(l=u,a=(l-r)/2):c=s,{width:c,height:l,x:0,y:a,pause:!0}}const Q={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function Z({item:{src:n,render:o,width:i=0,height:a=0,originRef:c},visible:s,speed:u,easing:d,wrapClassName:h,className:m,style:v,loadingElement:w,brokenElement:p,onPhotoTap:E,onMaskTap:y,onReachMove:C,onReachUp:S,onPhotoResize:k,isActive:V,expose:$}){const[N,Y]=b(Q),F=t(0),W=z(),{naturalWidth:A=i,naturalHeight:B=a,width:j=i,height:K=a,loaded:U=!n,broken:Z,x:ee,y:te,touched:ne,stopRaf:oe,maskTouched:re,rotate:ie,scale:ae,CX:ce,CY:le,lastX:se,lastY:ue,lastCX:de,lastCY:he,lastScale:me,touchTime:fe,touchLength:ve,pause:ge,reach:be}=N,we=g({onScale:e=>pe(_(e)),onRotate(e){ie!==e&&($({rotate:e}),Y(f({rotate:e},J(A,B,e))))}});function pe(e,t,n){ae!==e&&($({scale:e}),Y(f({scale:e},D(ee,te,j,K,ae,e,t,n),e<=1&&{x:0,y:0})))}const Ee=L((e,t,n=0)=>{if((ne||re)&&V){const[o,r]=M(ie,j,K);if(0===n&&0===F.current){const n=Math.abs(e-ce)<=20,o=Math.abs(t-le)<=20;if(n&&o)return void Y({lastCX:e,lastCY:t});F.current=n?t>le?3:2:1}const i=e-de,a=t-he;let c;if(0===n){const[n]=X(i+se,ae,o,I()),[l]=X(a+ue,ae,r,innerHeight);c=((e,t,n,o)=>t&&1===e||"x"===o?"x":n&&e>1||"y"===o?"y":void 0)(F.current,n,l,be),void 0!==c&&C(c,e,t,ae)}if("x"===c||re)return void Y({reach:"x"});const l=_(ae+(n-ve)/100/2*ae,A/j,.2);$({scale:l}),Y(f({touchLength:n,reach:c,scale:l},D(ee,te,j,K,ae,l,e,t,i,a)))}},{maxWait:8});function ye(e){return!oe&&!ne&&(W.current&&Y(f({},e,{pause:s})),W.current)}const xe=function(){const e=g({X:e=>ye({x:e}),Y:e=>ye({y:e}),S:e=>{return t=e,W.current&&($({scale:t}),Y({scale:t})),!ne&&W.current;var t}});return(t,n,o,r,i,a,c,l,s,u,d)=>{const[h,m]=M(u,i,a),[f,v]=X(t,l,h,I()),[g,b]=X(n,l,m,innerHeight),w=Date.now()-d;if(w>=200||l!==c||Math.abs(s-c)>1){const{x:o,y:r}=D(t,n,i,a,c,l),s=f?v:o!==t?o:null,u=g?b:r!==n?r:null;return null!==s&&H(t,s,e.X),null!==u&&H(n,u,e.Y),void(l!==c&&H(c,l,e.S))}const p=(t-o)/w,E=(n-r)/w,y=Math.sqrt(p**2+E**2);let x=!1,C=!1;!function(e,t){let n,o=e,r=0,i=0;const a=i=>{n||(n=i);const a=i-n,s=Math.sign(e),u=-.001*s,d=Math.sign(-o)*o**2*2e-4,h=o*a+(u+d)*a**2/2;o+=(u+d)*a,r+=h,n=i,s*o<=0?l():t(r)?c():l()};function c(){i=requestAnimationFrame(a)}function l(){cancelAnimationFrame(i)}c()}(y,o=>{const r=t+o*(p/y),i=n+o*(E/y),[a,l]=X(r,c,h,I()),[s,u]=X(i,c,m,innerHeight);if(a&&!x&&(x=!0,f?H(r,l,e.X):q(l,r+(r-l),e.X)),s&&!C&&(C=!0,g?H(i,u,e.Y):q(u,i+(i-u),e.Y)),x&&C)return!1;const d=x||e.X(l),v=C||e.Y(u);return d&&v})}}(),Ce=function(e){const n=t(0),o=L((...t)=>{n.current=0,e(...t)},{wait:300});return function(...e){n.current+=1,o(...e),n.current>=2&&(o.cancel(),n.current=0,((e,t)=>{be||pe(1!==ae?1:Math.max(2,A/j),e,t)})(...e))}}(E);function _e(e,t){if(F.current=0,(ne||re)&&V){Y({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});const n=_(ae,A/j);if(xe(ee,te,se,ue,j,K,ae,n,me,ie,fe),S(e,t),ce===e&&le===t){if(ne)return void Ce(e,t);re&&y(e,t)}}}function Re(e,t,n=0){Y({touched:!0,CX:e,CY:t,lastCX:e,lastCY:t,lastX:ee,lastY:te,lastScale:ae,touchLength:n,touchTime:Date.now()})}function Pe(e){Y({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:ee,lastY:te})}P(x?void 0:"mousemove",e=>{e.preventDefault(),Ee(e.clientX,e.clientY)}),P(x?void 0:"mouseup",e=>{_e(e.clientX,e.clientY)}),P(x?"touchmove":void 0,e=>{e.preventDefault();const t=T(e);Ee(...t)},{passive:!1}),P(x?"touchend":void 0,({changedTouches:e})=>{const t=e[0];_e(t.clientX,t.clientY)},{passive:!1}),P("resize",L(()=>{U&&!ne&&(Y(J(A,B,ie)),k())},{maxWait:8})),R(()=>{V&&$(f({scale:ae,rotate:ie},we))},[V]);const[Se,ke,Ve,$e,Ne,Ye,Fe,Te]=function(e,n,o,i,a,c,s,u,d,h){const[m,f,v]=function(e,n,o,r,i){const a=t(!1),[{lead:c,scale:l},s]=b({lead:!0,scale:o}),u=L(async e=>{i(!0),s({lead:!1,scale:e})},{wait:r});return R(()=>{a.current?(i(!1),s({lead:!0}),u(o)):a.current=!0},[o]),c?[e*l,n*l,o/l]:[e*o,n*o,1]}(c,s,u,d,h),[w,p]=function(e,n,o,i,a){const[c,s]=l(O),[u,d]=l(0),h=t(),m=g({OK:()=>e&&d(4)});function f(e){a(!1),d(e)}return r(()=>{if(h.current||(h.current=Date.now()),o){if(function(e,t){const n=e&&e.current;if(n&&1===n.nodeType){const{top:e,left:o,width:r,height:i}=n.getBoundingClientRect();t({T:e,L:o,W:r,H:i,FIT:"IMG"===n.tagName?getComputedStyle(n).objectFit:void 0})}}(n,s),e)return Date.now()-h.current<250?(d(1),requestAnimationFrame(()=>{d(2),requestAnimationFrame(()=>f(3))}),void setTimeout(m.OK,i)):void d(4);f(5)}},[e,o]),[u,c]}(e,n,o,d,h),{T:E,L:y,W:x,H:C,FIT:_}=p,P=I()/2,S=innerHeight/2,k=w<3||w>4;return[k?x?y:P:i+(P-c*u/2),k?x?E:S:a+(S-s*u/2),m,k&&_?m*(C/x):f,0===w?v:k?x/(c*u)||.01:v,k?_?1:0:1,w,_]}(s,c,U,ee,te,j,K,ae,u,e=>Y({pause:e})),Xe=`transform ${u}ms ${d}`,Me={className:m,onMouseDown:x?void 0:function(e){e.stopPropagation(),0===e.button&&Re(e.clientX,e.clientY,0)},onTouchStart:x?function(e){e.stopPropagation(),Re(...T(e))}:void 0,onWheel:function(e){if(!be){const t=_(ae-e.deltaY/100/2,A/j);Y({stopRaf:!0}),pe(t,e.clientX,e.clientY)}},style:{width:`${Ve}px`,height:`${$e}px`,opacity:Ye,objectFit:4===Fe?void 0:Te,transform:ie?`rotate(${ie}deg)`:void 0,transition:Fe>2?`${Xe}, opacity ${u}ms ease, height ${Fe<4?u/2:Fe>4?u:0}ms ${d}`:void 0}};return e.createElement("div",{className:"PhotoView__PhotoWrap"+(h?` ${h}`:""),style:v,onMouseDown:!x&&V?Pe:void 0,onTouchStart:x&&V?e=>Pe(e.touches[0]):void 0},e.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:`matrix(${Ne}, 0, 0, ${Ne}, ${Se}, ${ke})`,transition:ne||ge?void 0:Xe,willChange:V?"transform":void 0}},n?e.createElement(G,f({src:n,loaded:U,broken:Z},Me,{onPhotoLoad:function(e){Y(f({},e,e.loaded&&J(e.naturalWidth||0,e.naturalHeight||0,ie)))},loadingElement:w,brokenElement:p})):o&&o({attrs:Me,scale:Ne,rotate:ie})))}const ee={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function te(o){const{loop:i=3,speed:s,easing:u,photoClosable:d,maskClosable:h=!0,maskOpacity:m=y,pullClosable:f=!0,pullAction:v,bannerVisible:w=!0,overlayRender:_,toolbarRender:S,showBackdropImage:Y,disableScroll:T=!0,toolbarLeftRender:X,toolbarRightRender:M,toolbarBottomRender:L,sidebarWidth:W,sidebarLeftRender:D,sidebarRightRender:q,className:B,maskClassName:H,photoClassName:O,photoWrapClassName:z,loadingElement:j,brokenElement:K,images:U,index:G=0,onIndexChange:J,visible:Q,onClose:te,afterClose:ne,portalContainer:oe,fullScreen:re,onFullScreen:ie}=o,[ae,ce]=b(ee),[le,se]=l(0),ue=t();r(()=>(ue.current&&A(ue.current),()=>{A(null)}),[Q]);const{x:de,touched:he,pause:me,lastCX:fe,lastCY:ve,bg:ge=m,lastBg:be,overlay:we,minimal:pe,scale:Ee,rotate:ye,onScale:xe,onRotate:Ce}=ae,_e=o.hasOwnProperty("index"),Re=_e?G:le,Pe=_e?J:se,Se=t(Re),ke=U.length,Ve=U[Re],$e="boolean"==typeof i?i:ke>i,[Ne,Ye,Fe]=function(e,o){const[,r]=n(e=>!e,!1),i=t(0),[c,l]=function(n){const o=t(n);function r(e){o.current=e}return a(()=>{(t=>{e?(t(e),i.current=1):i.current=2})(r)},[n]),[o.current,r]}(e);return[c,i.current,function(){r(),2===i.current&&(l(!1),o&&o()),i.current=0}]}(Q,ne);R(()=>{if(Ne)return ce({pause:!0,x:Re*-(I()+E)}),void(Se.current=Re);ce(ee)},[Ne]);const{close:Te,changeIndex:Xe}=g({close(e){Ce&&Ce(0),ce({overlay:!0,lastBg:ge}),te(e)},changeIndex(e,t=!1){const n=$e?Se.current+(e-Re):e,o=ke-1,r=C(n,0,o),i=$e?n:r,a=I()+E;ce({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*i,pause:t}),Se.current=i,Pe&&Pe($e?e<0?o:e>o?0:e:r)}}),Me=c(()=>{ie(!re)},[re,ie]),Le=a(()=>()=>{!document.fullscreenElement&&re&&Me()},[re,Me]),We=a(()=>()=>{if(document.fullscreenElement)document.exitFullscreen();else if(re){const e=ue.current;if(!e)return;(e=>{try{e&&(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}catch(e){console.log("Error al intentar activar el modo de pantalla completa",e)}})(e)}},[ue,re]);function Ae(e){return e?Te():ce({overlay:!we})}function Ie(){ce({x:-(I()+E)*Re,lastCX:void 0,lastCY:void 0,pause:!0}),Se.current=Re}function De(e,t,n,o){"x"===e?function(e){if(void 0===fe)return void ce({touched:!0,lastCX:e,x:de,pause:!1});const t=e-fe;let n=t;!$e&&(0===Re&&t>0||Re===ke-1&&t<0)&&(n=t/2),ce({touched:!0,lastCX:fe,x:-(I()+E)*Se.current+n,pause:!1})}(t):"y"===e&&function(e,t){if(void 0===ve)return void ce({touched:!0,lastCY:e,bg:ge,minimal:!0});const n=null===m?null:C(m,.01,m-Math.abs(e-ve)/100/4);ce({touched:!0,lastCY:ve,bg:1===t?n:m,minimal:1===t})}(n,o)}function qe(e,t){const n=e-(null!=fe?fe:e),o=t-(null!=ve?ve:t);let r=!1;if(n<-40)return void Xe(Re+1);if(n>40)return void Xe(Re-1);const i=-(I()+E)*Se.current;Math.abs(o)>100&&pe&&f?(r=!0,Te()):Math.abs(o)>100&&pe&&"function"==typeof v&&v({direction:o<0?"top":"bottom",offsetY:o}),ce({touched:!1,x:i,lastCX:void 0,lastCY:void 0,bg:m,overlay:!!r||we})}r(()=>{if(ue.current)return We(),document.addEventListener("fullscreenchange",Le),()=>{document.removeEventListener("fullscreenchange",Le)}},[ue,re,Le,We]),P("keydown",e=>{if(Q)switch(e.key){case"ArrowLeft":Xe(Re-1,!1);break;case"ArrowRight":Xe(Re+1,!1);break;case"Escape":Te()}});const Be=function(e,t,n){return a(()=>{const o=e.length;return n?e.concat(e).concat(e).slice(o+t-1,o+t+2):e.slice(Math.max(t-1,0),Math.min(t+2,o+1))},[e,t,n])}(U,Re,$e);if(!Ne)return null;const He=we&&!Ye,Oe=Q?ge:be,ze=xe&&Ce&&{images:U,index:Re,visible:Q,onClose:Te,onIndexChange:Xe,overlayVisible:He,overlay:Ve&&Ve.overlay,scale:Ee,rotate:ye,onScale:xe,onRotate:Ce,fullScreen:re,fullScreenAvailable:document.documentElement.requestFullscreen||document.documentElement.mozRequestFullScreen||document.documentElement.webkitRequestFullscreen||document.documentElement.msRequestFullscreen,toggleFullScreen:()=>ie(!re)},je=s?s(Ye):400,Ke=u?u(Ye):p,Ue=s?s(3):600,Ge=u?u(3):p,Je="number"==typeof W?`${W}px`:W,Qe=window.innerWidth<=900;return e.createElement(k,{className:`PhotoView-Portal${He?"":" PhotoView-Slider__clean"}${Q?"":" PhotoView-Slider__willClose"}${B?` ${B}`:""}`,role:"dialog",onClick:e=>e.stopPropagation(),container:oe},Q&&T&&e.createElement(N,null),e.createElement("div",{className:"PhotoView-Container"},D&&ze&&!Qe&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===Ye?" PhotoView-Slider__fadeIn":2===Ye?" PhotoView-Slider__fadeOut":""),style:{width:Je,transitionTimingFunction:Ke,transitionDuration:`${he?0:je}ms`,animationDuration:`${je}ms`}},D(ze)),e.createElement("div",{ref:ue,className:"PhotoView-Viewer"},e.createElement("div",{className:`PhotoView-Slider__Backdrop${H?` ${H}`:""}${1===Ye?" PhotoView-Slider__fadeIn":2===Ye?" PhotoView-Slider__fadeOut":""} ${Y?"with-backdrop-image":""}`,style:{background:Y?`url(${Ve.src})`:Oe?`rgba(0, 0, 0, ${Oe})`:void 0,transitionTimingFunction:Ke,transitionDuration:`${he?0:je}ms`,animationDuration:`${je}ms`},onAnimationEnd:Fe}),e.createElement(F,{bannerVisible:w,index:Re,imageLength:ke,overlayParams:ze,toolbarRender:S,toolbarLeftRender:X,toolbarRightRender:M,toolbarBottomRender:L}),Be.map((t,n)=>{const o=$e||0!==Re?Se.current-1+n:Re+n;return e.createElement(Z,{key:$e?`${t.key}/${t.src}/${o}`:t.key,item:t,speed:je,easing:Ke,visible:Q,onReachMove:De,onReachUp:qe,onPhotoTap:()=>Ae(d),onMaskTap:()=>Ae(h),wrapClassName:z,className:O,style:{left:(I()+E)*o+"px",transform:`translate3d(${de}px, 0px, 0)`,transition:he||me?void 0:`transform ${Ue}ms ${Ge}`},loadingElement:j,brokenElement:K,onPhotoResize:Ie,isActive:Se.current===o,expose:ce})}),!x&&w&&e.createElement(e.Fragment,null,($e||0!==Re)&&e.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:()=>Xe(Re-1,!0)},e.createElement(V,null)),($e||Re+1<ke)&&e.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:()=>Xe(Re+1,!0)},e.createElement($,null))),_&&ze&&e.createElement("div",{className:"PhotoView-Slider__Overlay"},_(ze))),q&&ze&&!Qe&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===Ye?" PhotoView-Slider__fadeIn":2===Ye?" PhotoView-Slider__fadeOut":""),style:{width:Je,transitionTimingFunction:Ke,transitionDuration:`${he?0:je}ms`,animationDuration:`${je}ms`}},q(ze)),L&&ze&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Bottom",style:{width:`calc(100% - ${Qe?0:Je})`}},L(ze))))}const ne=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],oe={images:[],visible:!1,index:0,fullScreen:!1};function re(n){let{children:o,onIndexChange:i,onVisibleChange:c,sidebarLeftRender:l,sidebarRightRender:s,sidebarWidth:u=400}=n,d=v(n,ne);const[h,m]=b(oe),p=t(0),{images:E,visible:y,index:x}=h;r(()=>{W.sidebarWidth=l||s?u:0},[l,s,u]);const C=g({nextId:()=>p.current+=1,update(e){const t=E.findIndex(t=>t.key===e.key);if(t>-1){const n=E.slice();return n.splice(t,1,e),void m({images:n})}m(t=>({images:t.images.concat(e)}))},remove(e){m(t=>{const n=t.images.filter(t=>t.key!==e);return{images:n,index:Math.min(n.length-1,x)}})},show(e){const t=E.findIndex(t=>t.key===e);m({visible:!0,index:t}),c&&c(!0,t,h)}}),_=g({close(){m({visible:!1}),c&&c(!1,x,h)},changeIndex(e){m({index:e}),i&&i(e,h)},fullScreen(e){m({fullScreen:e})}}),R=a(()=>f({},h,C),[h,C]);return e.createElement(w.Provider,{value:R},o,e.createElement(te,f({images:E,visible:y,index:x,fullScreen:h.fullScreen,onIndexChange:_.changeIndex,onClose:_.close,onFullScreen:_.fullScreen,sidebarWidth:u,sidebarLeftRender:l,sidebarRightRender:s},d)))}const ie=({src:e,render:n,overlay:o,width:i,height:c,triggers:l=["onClick"],children:m})=>{const v=s(w),b=function(){const{current:e}=t({sign:!1,fn:void 0});return e.sign||(e.sign=!0,e.fn=v.nextId()),e.fn}(),p=t(null);u(null==m?void 0:m.ref,()=>p.current),r(()=>()=>{v.remove(b)},[]);const E=g({render:e=>n&&n(e),show(e,t){v.show(b),function(e,t){if(m){const n=m.props[e];n&&n(t)}}(e,t)}}),y=a(()=>{const e={};return l.forEach(t=>{e[t]=E.show.bind(null,t)}),e},[]);return r(()=>{v.update({key:b,src:e,originRef:p,render:E.render,overlay:o,width:i,height:c})},[e]),m?d.only(h(m,f({},y,{ref:p}))):null};export{re as PhotoProvider,te as PhotoSlider,ie as PhotoView}; | ||
import e,{useRef as t,useReducer as n,createContext as o,useEffect as r,useLayoutEffect as i,useMemo as a,useCallback as l,useState as c,useContext as s,useImperativeHandle as u,Children as d,cloneElement as h}from"react";import{createPortal as m}from"react-dom";function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},f.apply(null,arguments)}function v(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}function g(e){const{current:n}=t({fn:e,curr:void 0});if(n.fn=e,!n.curr){const t=Object.create(null);Object.keys(e).forEach(e=>{t[e]=(...t)=>n.fn[e].call(n.fn,...t)}),n.curr=t}return n.curr}function b(e){return n((e,t)=>f({},e,"function"==typeof t?t(e):t),e)}var w=o(void 0);const p="cubic-bezier(0.25, 0.8, 0.25, 1)",E=20,y=1,x="undefined"!=typeof window&&"ontouchstart"in window,C=(e,t,n)=>Math.max(Math.min(e,n),t),_=(e,t=0,n=0)=>C(e,1*(1-n),Math.max(6,t)*(1+n));var R="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?r:i;function S(e,n,o){const i=t(n);i.current=n,r(()=>{function t(e){i.current(e)}return e&&window.addEventListener(e,t,o),()=>{e&&window.removeEventListener(e,t)}},[e])}const P=["container"];function k(t){let{container:n=document.body}=t,o=v(t,P);return m(e.createElement("div",f({},o)),n)}function V(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function $(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function N(){return r(()=>{const{style:e}=document.body,t=e.overflow;return e.overflow="hidden",()=>{e.overflow=t}},[]),null}function Y(t){return e.createElement("svg",f({width:"44",height:"44",viewBox:"0 0 768 768"},t),e.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function F({bannerVisible:t,index:n,imageLength:o,toolbarRender:r,overlayParams:i,toolbarLeftRender:a,toolbarRightRender:l}){return e.createElement(e.Fragment,null,t&&e.createElement("div",{className:"PhotoView-Slider__BannerWrap"},e.createElement("div",{className:"PhotoView-Slider__Counter"},n+1," / ",o),e.createElement("div",{className:"PhotoView-Slider__BannerRight"},r&&i&&r(i),e.createElement(Y,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),a&&i&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},a(i)),l&&i&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},l(i)))}function T(e){const{clientX:t,clientY:n}=e.touches[0];if(e.touches.length>=2){const{clientX:o,clientY:r}=e.touches[1];return[(t+o)/2,(n+r)/2,Math.sqrt((o-t)**2+(r-n)**2)]}return[t,n,0]}const X=(e,t,n,o)=>{const r=n*t,i=(r-o)/2;let a,l=e;return r<=o?(a=1,l=0):e>0&&i-e<=0?(a=2,l=i):e<0&&i+e<=0&&(a=3,l=-i),[a,l]};function M(e,t,n){const o=e%180!=0;return o?[n,t,o]:[t,n,o]}function L(e,{leading:n=!1,maxWait:o,wait:r=o||0}){const i=t(e);i.current=e;const a=t(0),c=t(),s=()=>c.current&&clearTimeout(c.current),u=l((...e)=>{const t=Date.now();function l(){a.current=t,s(),i.current.apply(null,e)}const u=a.current,d=t-u;if(0===u&&(n&&l(),a.current=t),void 0!==o){if(d>o)return void l()}else d<r&&(a.current=t);s(),c.current=setTimeout(()=>{l(),a.current=0},r)},[r,o,n]);return u.cancel=s,u}class W{}W.globalDivRef=null,W.sidebarWidth=400,W.fullScreen=!1;const A=e=>{W.globalDivRef=e},I=()=>innerWidth-(innerWidth<=900||W.fullScreen?0:W.sidebarWidth);function D(e,t,n,o,r,i,a=I()/2,l=innerHeight/2,c=0,s=0){const[u]=X(e,i,n,I()),[d]=X(t,i,o,innerHeight),h=I()/2,m=innerHeight/2,f=l-i/r*(l-(m+t))-m;return{x:a-i/r*(a-(h+e))-h+(o/n>=3&&n*i===I()?0:u?c/2:c),y:f+(d?s/2:s),lastCX:a,lastCY:l}}const q=(e,t,n)=>H(e,t,n,100,e=>e,()=>H(t,e,n)),B=e=>1-(1-e)**4;function H(e,t,n,o=400,r=B,i){const a=t-e;if(0===a)return;const l=Date.now();let c=0;const s=()=>{const t=Math.min(1,(Date.now()-l)/o);n(e+r(t)*a)&&t<1?u():(cancelAnimationFrame(c),t>=1&&i&&i())};function u(){c=requestAnimationFrame(s)}u()}const O={T:0,L:0,W:0,H:0,FIT:void 0},z=()=>{const e=t(!1);return r(()=>(e.current=!0,()=>{e.current=!1}),[]),e},j=["className"];function K(t){let{className:n=""}=t,o=v(t,j);return e.createElement("div",f({className:`PhotoView__Spinner ${n}`},o),e.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},e.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),e.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}const U=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function G(t){let{src:n,loaded:o,broken:r,className:i,onPhotoLoad:a,loadingElement:l,brokenElement:c}=t,s=v(t,U);const u=z();return n&&!r?e.createElement(e.Fragment,null,e.createElement("img",f({className:"PhotoView__Photo"+(i?` ${i}`:""),src:n,onLoad:function(e){const{naturalWidth:t,naturalHeight:n}=e.target;u.current&&a({loaded:!0,naturalWidth:t,naturalHeight:n})},onError:function(){u.current&&a({broken:!0})},alt:""},s)),!o&&(e.createElement("span",{className:"PhotoView__icon"},l)||e.createElement(K,{className:"PhotoView__icon"}))):c?e.createElement("span",{className:"PhotoView__icon"},"function"==typeof c?c({src:n}):c):null}function J(e,t,n){const[o,r,i]=M(n,I(),innerHeight);let a=0,l=o,c=r;const s=e/t*r,u=t/e*o;return e<o&&t<r?(l=e,c=t):e<o&&t>=r?l=s:e>=o&&t<r||e/t>o/r?c=u:t/e>=3&&!i?(c=u,a=(c-r)/2):l=s,{width:l,height:c,x:0,y:a,pause:!0}}const Q={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function Z({item:{src:n,render:o,width:i=0,height:a=0,originRef:l},visible:s,speed:u,easing:d,wrapClassName:h,className:m,style:v,loadingElement:w,brokenElement:p,onPhotoTap:E,onMaskTap:y,onReachMove:C,onReachUp:P,onPhotoResize:k,isActive:V,expose:$}){const[N,Y]=b(Q),F=t(0),W=z(),{naturalWidth:A=i,naturalHeight:B=a,width:j=i,height:K=a,loaded:U=!n,broken:Z,x:ee,y:te,touched:ne,stopRaf:oe,maskTouched:re,rotate:ie,scale:ae,CX:le,CY:ce,lastX:se,lastY:ue,lastCX:de,lastCY:he,lastScale:me,touchTime:fe,touchLength:ve,pause:ge,reach:be}=N,we=g({onScale:e=>pe(_(e)),onRotate(e){ie!==e&&($({rotate:e}),Y(f({rotate:e},J(A,B,e))))}});function pe(e,t,n){ae!==e&&($({scale:e}),Y(f({scale:e},D(ee,te,j,K,ae,e,t,n),e<=1&&{x:0,y:0})))}const Ee=L((e,t,n=0)=>{if((ne||re)&&V){const[o,r]=M(ie,j,K);if(0===n&&0===F.current){const n=Math.abs(e-le)<=20,o=Math.abs(t-ce)<=20;if(n&&o)return void Y({lastCX:e,lastCY:t});F.current=n?t>ce?3:2:1}const i=e-de,a=t-he;let l;if(0===n){const[n]=X(i+se,ae,o,I()),[c]=X(a+ue,ae,r,innerHeight);l=((e,t,n,o)=>t&&1===e||"x"===o?"x":n&&e>1||"y"===o?"y":void 0)(F.current,n,c,be),void 0!==l&&C(l,e,t,ae)}if("x"===l||re)return void Y({reach:"x"});const c=_(ae+(n-ve)/100/2*ae,A/j,.2);$({scale:c}),Y(f({touchLength:n,reach:l,scale:c},D(ee,te,j,K,ae,c,e,t,i,a)))}},{maxWait:8});function ye(e){return!oe&&!ne&&(W.current&&Y(f({},e,{pause:s})),W.current)}const xe=function(){const e=g({X:e=>ye({x:e}),Y:e=>ye({y:e}),S:e=>{return t=e,W.current&&($({scale:t}),Y({scale:t})),!ne&&W.current;var t}});return(t,n,o,r,i,a,l,c,s,u,d)=>{const[h,m]=M(u,i,a),[f,v]=X(t,c,h,I()),[g,b]=X(n,c,m,innerHeight),w=Date.now()-d;if(w>=200||c!==l||Math.abs(s-l)>1){const{x:o,y:r}=D(t,n,i,a,l,c),s=f?v:o!==t?o:null,u=g?b:r!==n?r:null;return null!==s&&H(t,s,e.X),null!==u&&H(n,u,e.Y),void(c!==l&&H(l,c,e.S))}const p=(t-o)/w,E=(n-r)/w,y=Math.sqrt(p**2+E**2);let x=!1,C=!1;!function(e,t){let n,o=e,r=0,i=0;const a=i=>{n||(n=i);const a=i-n,s=Math.sign(e),u=-.001*s,d=Math.sign(-o)*o**2*2e-4,h=o*a+(u+d)*a**2/2;o+=(u+d)*a,r+=h,n=i,s*o<=0?c():t(r)?l():c()};function l(){i=requestAnimationFrame(a)}function c(){cancelAnimationFrame(i)}l()}(y,o=>{const r=t+o*(p/y),i=n+o*(E/y),[a,c]=X(r,l,h,I()),[s,u]=X(i,l,m,innerHeight);if(a&&!x&&(x=!0,f?H(r,c,e.X):q(c,r+(r-c),e.X)),s&&!C&&(C=!0,g?H(i,u,e.Y):q(u,i+(i-u),e.Y)),x&&C)return!1;const d=x||e.X(c),v=C||e.Y(u);return d&&v})}}(),Ce=function(e){const n=t(0),o=L((...t)=>{n.current=0,e(...t)},{wait:300});return function(...e){n.current+=1,o(...e),n.current>=2&&(o.cancel(),n.current=0,((e,t)=>{be||pe(1!==ae?1:Math.max(2,A/j),e,t)})(...e))}}(E);function _e(e,t){if(F.current=0,(ne||re)&&V){Y({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});const n=_(ae,A/j);if(xe(ee,te,se,ue,j,K,ae,n,me,ie,fe),P(e,t),le===e&&ce===t){if(ne)return void Ce(e,t);re&&y(e,t)}}}function Re(e,t,n=0){Y({touched:!0,CX:e,CY:t,lastCX:e,lastCY:t,lastX:ee,lastY:te,lastScale:ae,touchLength:n,touchTime:Date.now()})}function Se(e){Y({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:ee,lastY:te})}S(x?void 0:"mousemove",e=>{e.preventDefault(),Ee(e.clientX,e.clientY)}),S(x?void 0:"mouseup",e=>{_e(e.clientX,e.clientY)}),S(x?"touchmove":void 0,e=>{e.preventDefault();const t=T(e);Ee(...t)},{passive:!1}),S(x?"touchend":void 0,({changedTouches:e})=>{const t=e[0];_e(t.clientX,t.clientY)},{passive:!1}),S("resize",L(()=>{U&&!ne&&(Y(J(A,B,ie)),k())},{maxWait:8})),R(()=>{V&&$(f({scale:ae,rotate:ie},we))},[V]);const[Pe,ke,Ve,$e,Ne,Ye,Fe,Te]=function(e,n,o,i,a,l,s,u,d,h){const[m,f,v]=function(e,n,o,r,i){const a=t(!1),[{lead:l,scale:c},s]=b({lead:!0,scale:o}),u=L(async e=>{i(!0),s({lead:!1,scale:e})},{wait:r});return R(()=>{a.current?(i(!1),s({lead:!0}),u(o)):a.current=!0},[o]),l?[e*c,n*c,o/c]:[e*o,n*o,1]}(l,s,u,d,h),[w,p]=function(e,n,o,i,a){const[l,s]=c(O),[u,d]=c(0),h=t(),m=g({OK:()=>e&&d(4)});function f(e){a(!1),d(e)}return r(()=>{if(h.current||(h.current=Date.now()),o){if(function(e,t){const n=e&&e.current;if(n&&1===n.nodeType){const{top:e,left:o,width:r,height:i}=n.getBoundingClientRect();t({T:e,L:o,W:r,H:i,FIT:"IMG"===n.tagName?getComputedStyle(n).objectFit:void 0})}}(n,s),e)return Date.now()-h.current<250?(d(1),requestAnimationFrame(()=>{d(2),requestAnimationFrame(()=>f(3))}),void setTimeout(m.OK,i)):void d(4);f(5)}},[e,o]),[u,l]}(e,n,o,d,h),{T:E,L:y,W:x,H:C,FIT:_}=p,S=I()/2,P=innerHeight/2,k=w<3||w>4;return[k?x?y:S:i+(S-l*u/2),k?x?E:P:a+(P-s*u/2),m,k&&_?m*(C/x):f,0===w?v:k?x/(l*u)||.01:v,k?_?1:0:1,w,_]}(s,l,U,ee,te,j,K,ae,u,e=>Y({pause:e})),Xe=`transform ${u}ms ${d}`,Me={className:m,onMouseDown:x?void 0:function(e){e.stopPropagation(),0===e.button&&Re(e.clientX,e.clientY,0)},onTouchStart:x?function(e){e.stopPropagation(),Re(...T(e))}:void 0,onWheel:function(e){if(!be){const t=_(ae-e.deltaY/100/2,A/j);Y({stopRaf:!0}),pe(t,e.clientX,e.clientY)}},style:{width:`${Ve}px`,height:`${$e}px`,opacity:Ye,objectFit:4===Fe?void 0:Te,transform:ie?`rotate(${ie}deg)`:void 0,transition:Fe>2?`${Xe}, opacity ${u}ms ease, height ${Fe<4?u/2:Fe>4?u:0}ms ${d}`:void 0}};return e.createElement("div",{className:"PhotoView__PhotoWrap"+(h?` ${h}`:""),style:v,onMouseDown:!x&&V?Se:void 0,onTouchStart:x&&V?e=>Se(e.touches[0]):void 0},e.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:`matrix(${Ne}, 0, 0, ${Ne}, ${Pe}, ${ke})`,transition:ne||ge?void 0:Xe,willChange:V?"transform":void 0}},n?e.createElement(G,f({src:n,loaded:U,broken:Z},Me,{onPhotoLoad:function(e){Y(f({},e,e.loaded&&J(e.naturalWidth||0,e.naturalHeight||0,ie)))},loadingElement:w,brokenElement:p})):o&&o({attrs:Me,scale:Ne,rotate:ie})))}const ee={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function te(o){const{loop:i=3,speed:s,easing:u,photoClosable:d,maskClosable:h=!0,maskOpacity:m=y,pullClosable:f=!0,pullAction:v,bannerVisible:w=!0,overlayRender:_,toolbarRender:P,showBackdropImage:Y,disableScroll:T=!0,toolbarLeftRender:X,toolbarRightRender:M,toolbarBottomRender:L,sidebarWidth:D,sidebarLeftRender:q,sidebarRightRender:B,className:H,maskClassName:O,photoClassName:z,photoWrapClassName:j,loadingElement:K,brokenElement:U,images:G,index:J=0,onIndexChange:Q,visible:te,onClose:ne,afterClose:oe,portalContainer:re,fullScreen:ie,onFullScreen:ae}=o,[le,ce]=b(ee),[se,ue]=c(0),de=t();r(()=>(de.current&&A(de.current),()=>{A(null)}),[te]);const{x:he,touched:me,pause:fe,lastCX:ve,lastCY:ge,bg:be=m,lastBg:we,overlay:pe,minimal:Ee,scale:ye,rotate:xe,onScale:Ce,onRotate:_e}=le,Re=o.hasOwnProperty("index"),Se=Re?J:se,Pe=Re?Q:ue,ke=t(Se),Ve=G.length,$e=G[Se],Ne="boolean"==typeof i?i:Ve>i,[Ye,Fe,Te]=function(e,o){const[,r]=n(e=>!e,!1),i=t(0),[l,c]=function(n){const o=t(n);function r(e){o.current=e}return a(()=>{(t=>{e?(t(e),i.current=1):i.current=2})(r)},[n]),[o.current,r]}(e);return[l,i.current,function(){r(),2===i.current&&(c(!1),o&&o()),i.current=0}]}(te,oe);R(()=>{if(Ye)return ce({pause:!0,x:Se*-(I()+E)}),void(ke.current=Se);ce(ee)},[Ye]);const{close:Xe,changeIndex:Me}=g({close(e){_e&&_e(0),ce({overlay:!0,lastBg:be}),ne(e)},changeIndex(e,t=!1){const n=Ne?ke.current+(e-Se):e,o=Ve-1,r=C(n,0,o),i=Ne?n:r,a=I()+E;ce({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*i,pause:t}),ke.current=i,Pe&&Pe(Ne?e<0?o:e>o?0:e:r)}}),Le=l(()=>{ae(!ie)},[ie,ae]),We=a(()=>()=>{!document.fullscreenElement&&ie&&Le()},[ie,Le]),Ae=a(()=>()=>{if(document.fullscreenElement)document.exitFullscreen();else if(ie){const e=de.current;if(!e)return;(e=>{try{e&&(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}catch(e){console.log("Error al intentar activar el modo de pantalla completa",e)}})(e)}},[de,ie]);function Ie(e){return e?Xe():ce({overlay:!pe})}function De(){ce({x:-(I()+E)*Se,lastCX:void 0,lastCY:void 0,pause:!0}),ke.current=Se}function qe(e,t,n,o){"x"===e?function(e){if(void 0===ve)return void ce({touched:!0,lastCX:e,x:he,pause:!1});const t=e-ve;let n=t;!Ne&&(0===Se&&t>0||Se===Ve-1&&t<0)&&(n=t/2),ce({touched:!0,lastCX:ve,x:-(I()+E)*ke.current+n,pause:!1})}(t):"y"===e&&function(e,t){if(void 0===ge)return void ce({touched:!0,lastCY:e,bg:be,minimal:!0});const n=null===m?null:C(m,.01,m-Math.abs(e-ge)/100/4);ce({touched:!0,lastCY:ge,bg:1===t?n:m,minimal:1===t})}(n,o)}function Be(e,t){const n=e-(null!=ve?ve:e),o=t-(null!=ge?ge:t);let r=!1;if(n<-40)return void Me(Se+1);if(n>40)return void Me(Se-1);const i=-(I()+E)*ke.current;Math.abs(o)>100&&Ee&&f?(r=!0,Xe()):Math.abs(o)>100&&Ee&&"function"==typeof v&&v({direction:o<0?"top":"bottom",offsetY:o}),ce({touched:!1,x:i,lastCX:void 0,lastCY:void 0,bg:m,overlay:!!r||pe})}r(()=>{if(de.current)return Ae(),(e=>{W.fullScreen=e})(ie),document.addEventListener("fullscreenchange",We),()=>{document.removeEventListener("fullscreenchange",We)}},[de,ie,We,Ae]),S("keydown",e=>{if(te)switch(e.key){case"ArrowLeft":Me(Se-1,!1);break;case"ArrowRight":Me(Se+1,!1);break;case"Escape":Xe()}});const He=function(e,t,n){return a(()=>{const o=e.length;return n?e.concat(e).concat(e).slice(o+t-1,o+t+2):e.slice(Math.max(t-1,0),Math.min(t+2,o+1))},[e,t,n])}(G,Se,Ne);if(!Ye)return null;const Oe=pe&&!Fe,ze=te?be:we,je=Ce&&_e&&{images:G,index:Se,visible:te,onClose:Xe,onIndexChange:Me,overlayVisible:Oe,overlay:$e&&$e.overlay,scale:ye,rotate:xe,onScale:Ce,onRotate:_e,fullScreen:ie,fullScreenAvailable:document.documentElement.requestFullscreen||document.documentElement.mozRequestFullScreen||document.documentElement.webkitRequestFullscreen||document.documentElement.msRequestFullscreen,toggleFullScreen:()=>ae(!ie)},Ke=s?s(Fe):400,Ue=u?u(Fe):p,Ge=s?s(3):600,Je=u?u(3):p,Qe="number"==typeof D?`${D}px`:D,Ze=window.innerWidth<=900;return e.createElement(k,{className:`PhotoView-Portal${Oe?"":" PhotoView-Slider__clean"}${te?"":" PhotoView-Slider__willClose"}${H?` ${H}`:""}`,role:"dialog",onClick:e=>e.stopPropagation(),container:re},te&&T&&e.createElement(N,null),e.createElement("div",{className:"PhotoView-Container"},q&&je&&!Ze&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===Fe?" PhotoView-Slider__fadeIn":2===Fe?" PhotoView-Slider__fadeOut":""),style:{width:Qe,transitionTimingFunction:Ue,transitionDuration:`${me?0:Ke}ms`,animationDuration:`${Ke}ms`}},q(je)),e.createElement("div",{ref:de,className:"PhotoView-Viewer"},e.createElement("div",{className:`PhotoView-Slider__Backdrop${O?` ${O}`:""}${1===Fe?" PhotoView-Slider__fadeIn":2===Fe?" PhotoView-Slider__fadeOut":""} ${Y?"with-backdrop-image":""}`,style:{background:Y?`url(${$e.src})`:ze?`rgba(0, 0, 0, ${ze})`:void 0,transitionTimingFunction:Ue,transitionDuration:`${me?0:Ke}ms`,animationDuration:`${Ke}ms`},onAnimationEnd:Te}),e.createElement(F,{bannerVisible:w,index:Se,imageLength:Ve,overlayParams:je,toolbarRender:P,toolbarLeftRender:X,toolbarRightRender:M,toolbarBottomRender:L}),He.map((t,n)=>{const o=Ne||0!==Se?ke.current-1+n:Se+n;return e.createElement(Z,{key:Ne?`${t.key}/${t.src}/${o}`:t.key,item:t,speed:Ke,easing:Ue,visible:te,onReachMove:qe,onReachUp:Be,onPhotoTap:()=>Ie(d),onMaskTap:()=>Ie(h),wrapClassName:j,className:z,style:{left:(I()+E)*o+"px",transform:`translate3d(${he}px, 0px, 0)`,transition:me||fe?void 0:`transform ${Ge}ms ${Je}`},loadingElement:K,brokenElement:U,onPhotoResize:De,isActive:ke.current===o,expose:ce})}),!x&&w&&e.createElement(e.Fragment,null,(Ne||0!==Se)&&e.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:()=>Me(Se-1,!0)},e.createElement(V,null)),(Ne||Se+1<Ve)&&e.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:()=>Me(Se+1,!0)},e.createElement($,null))),_&&je&&e.createElement("div",{className:"PhotoView-Slider__Overlay"},_(je))),B&&je&&!Ze&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===Fe?" PhotoView-Slider__fadeIn":2===Fe?" PhotoView-Slider__fadeOut":""),style:{width:Qe,transitionTimingFunction:Ue,transitionDuration:`${me?0:Ke}ms`,animationDuration:`${Ke}ms`}},B(je)),L&&je&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Bottom",style:{width:`calc(100% - ${Ze?0:Qe})`}},L(je))))}const ne=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],oe={images:[],visible:!1,index:0,fullScreen:!1};function re(n){let{children:o,onIndexChange:i,onVisibleChange:l,sidebarLeftRender:c,sidebarRightRender:s,sidebarWidth:u=400}=n,d=v(n,ne);const[h,m]=b(oe),p=t(0),{images:E,visible:y,index:x}=h;r(()=>{W.sidebarWidth=c||s?u:0},[c,s,u]);const C=g({nextId:()=>p.current+=1,update(e){const t=E.findIndex(t=>t.key===e.key);if(t>-1){const n=E.slice();return n.splice(t,1,e),void m({images:n})}m(t=>({images:t.images.concat(e)}))},remove(e){m(t=>{const n=t.images.filter(t=>t.key!==e);return{images:n,index:Math.min(n.length-1,x)}})},show(e){const t=E.findIndex(t=>t.key===e);m({visible:!0,index:t}),l&&l(!0,t,h)}}),_=g({close(){m({visible:!1}),l&&l(!1,x,h)},changeIndex(e){m({index:e}),i&&i(e,h)},fullScreen(e){m({fullScreen:e})}}),R=a(()=>f({},h,C),[h,C]);return e.createElement(w.Provider,{value:R},o,e.createElement(te,f({images:E,visible:y,index:x,fullScreen:h.fullScreen,onIndexChange:_.changeIndex,onClose:_.close,onFullScreen:_.fullScreen,sidebarWidth:u,sidebarLeftRender:c,sidebarRightRender:s},d)))}const ie=({src:e,render:n,overlay:o,width:i,height:l,triggers:c=["onClick"],children:m})=>{const v=s(w),b=function(){const{current:e}=t({sign:!1,fn:void 0});return e.sign||(e.sign=!0,e.fn=v.nextId()),e.fn}(),p=t(null);u(null==m?void 0:m.ref,()=>p.current),r(()=>()=>{v.remove(b)},[]);const E=g({render:e=>n&&n(e),show(e,t){v.show(b),function(e,t){if(m){const n=m.props[e];n&&n(t)}}(e,t)}}),y=a(()=>{const e={};return c.forEach(t=>{e[t]=E.show.bind(null,t)}),e},[]);return r(()=>{v.update({key:b,src:e,originRef:p,render:E.render,overlay:o,width:i,height:l})},[e]),m?d.only(h(m,f({},y,{ref:p}))):null};export{re as PhotoProvider,te as PhotoSlider,ie as PhotoView}; | ||
//# sourceMappingURL=react-photo-view.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{useRef as n,useReducer as t,createContext as r,useEffect as o,useLayoutEffect as i,useMemo as a,useCallback as c,useState as l,useContext as u,useImperativeHandle as s,Children as d,cloneElement as f}from"react";import{createPortal as v}from"react-dom";function h(){return h=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},h.apply(null,arguments)}function m(e,n){if(null==e)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(n.includes(r))continue;t[r]=e[r]}return t}function g(e){var t=n({fn:e,curr:void 0}).current;if(t.fn=e,!t.curr){var r=Object.create(null);Object.keys(e).forEach(function(e){r[e]=function(){var n;return(n=t.fn[e]).call.apply(n,[t.fn].concat([].slice.call(arguments)))}}),t.curr=r}return t.curr}function p(e){return t(function(e,n){return h({},e,"function"==typeof n?n(e):n)},e)}var w=r(void 0),b="cubic-bezier(0.25, 0.8, 0.25, 1)",y=20,E="undefined"!=typeof window&&"ontouchstart"in window,x=function(e,n,t){return Math.max(Math.min(e,t),n)},C=function(e,n,t){return void 0===n&&(n=0),void 0===t&&(t=0),x(e,1*(1-t),Math.max(6,n)*(1+t))},_="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?o:i;function R(e,t,r){var i=n(t);i.current=t,o(function(){function n(e){i.current(e)}return e&&window.addEventListener(e,n,r),function(){e&&window.removeEventListener(e,n)}},[e])}var P=["container"];function S(n){var t=n.container,r=void 0===t?document.body:t,o=m(n,P);return v(e.createElement("div",h({},o)),r)}function k(n){return e.createElement("svg",h({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function V(n){return e.createElement("svg",h({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function M(){return o(function(){var e=document.body.style,n=e.overflow;return e.overflow="hidden",function(){e.overflow=n}},[]),null}function N(n){return e.createElement("svg",h({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function Y(n){var t=n.toolbarRender,r=n.overlayParams,o=n.toolbarLeftRender,i=n.toolbarRightRender;return e.createElement(e.Fragment,null,n.bannerVisible&&e.createElement("div",{className:"PhotoView-Slider__BannerWrap"},e.createElement("div",{className:"PhotoView-Slider__Counter"},n.index+1," / ",n.imageLength),e.createElement("div",{className:"PhotoView-Slider__BannerRight"},t&&r&&t(r),e.createElement(N,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),o&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},o(r)),i&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},i(r)))}function F(e){var n=e.touches[0],t=n.clientX,r=n.clientY;if(e.touches.length>=2){var o=e.touches[1],i=o.clientX,a=o.clientY;return[(t+i)/2,(r+a)/2,Math.sqrt(Math.pow(i-t,2)+Math.pow(a-r,2))]}return[t,r,0]}var T=function(e,n,t,r){var o,i=t*n,a=(i-r)/2,c=e;return i<=r?(o=1,c=0):e>0&&a-e<=0?(o=2,c=a):e<0&&a+e<=0&&(o=3,c=-a),[o,c]};function X(e,n,t){var r=e%180!=0;return r?[t,n,r]:[n,t,r]}function L(e,t){var r=t.leading,o=void 0!==r&&r,i=t.maxWait,a=t.wait,l=void 0===a?i||0:a,u=n(e);u.current=e;var s=n(0),d=n(),f=function(){return d.current&&clearTimeout(d.current)},v=c(function(){var e=[].slice.call(arguments),n=Date.now();function t(){s.current=n,f(),u.current.apply(null,e)}var r=s.current,a=n-r;if(0===r&&(o&&t(),s.current=n),void 0!==i){if(a>i)return void t()}else a<l&&(s.current=n);f(),d.current=setTimeout(function(){t(),s.current=0},l)},[l,i,o]);return v.cancel=f,v}var W=function(){};W.globalDivRef=null,W.sidebarWidth=400;var A=function(e){W.globalDivRef=e},I=function(){return innerWidth-(innerWidth<=900?0:W.sidebarWidth)};function D(e,n,t,r,o,i,a,c,l,u){void 0===a&&(a=I()/2),void 0===c&&(c=innerHeight/2),void 0===l&&(l=0),void 0===u&&(u=0);var s=T(e,i,t,I())[0],d=T(n,i,r,innerHeight)[0],f=I()/2,v=innerHeight/2,h=c-i/o*(c-(v+n))-v;return{x:a-i/o*(a-(f+e))-f+(r/t>=3&&t*i===I()?0:s?l/2:l),y:h+(d?u/2:u),lastCX:a,lastCY:c}}var q=function(e,n,t){return H(e,n,t,100,function(e){return e},function(){return H(n,e,t)})},B=function(e){return 1-Math.pow(1-e,4)};function H(e,n,t,r,o,i){void 0===r&&(r=400),void 0===o&&(o=B);var a=n-e;if(0!==a){var c=Date.now(),l=0,u=function(){var n=Math.min(1,(Date.now()-c)/r);t(e+o(n)*a)&&n<1?s():(cancelAnimationFrame(l),n>=1&&i&&i())};s()}function s(){l=requestAnimationFrame(u)}}var O={T:0,L:0,W:0,H:0,FIT:void 0},z=function(){var e=n(!1);return o(function(){return e.current=!0,function(){e.current=!1}},[]),e},j=["className"];function K(n){var t=n.className,r=void 0===t?"":t,o=m(n,j);return e.createElement("div",h({className:"PhotoView__Spinner "+r},o),e.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},e.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),e.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var U=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function G(n){var t=n.src,r=n.loaded,o=n.broken,i=n.className,a=n.onPhotoLoad,c=n.loadingElement,l=n.brokenElement,u=m(n,U),s=z();return t&&!o?e.createElement(e.Fragment,null,e.createElement("img",h({className:"PhotoView__Photo"+(i?" "+i:""),src:t,onLoad:function(e){var n=e.target;s.current&&a({loaded:!0,naturalWidth:n.naturalWidth,naturalHeight:n.naturalHeight})},onError:function(){s.current&&a({broken:!0})},alt:""},u)),!r&&(e.createElement("span",{className:"PhotoView__icon"},c)||e.createElement(K,{className:"PhotoView__icon"}))):l?e.createElement("span",{className:"PhotoView__icon"},"function"==typeof l?l({src:t}):l):null}function J(e,n,t){var r=X(t,I(),innerHeight),o=r[0],i=r[1],a=0,c=o,l=i,u=e/n*i,s=n/e*o;return e<o&&n<i?(c=e,l=n):e<o&&n>=i?c=u:e>=o&&n<i||e/n>o/i?l=s:n/e>=3&&!r[2]?a=((l=s)-i)/2:c=u,{width:c,height:l,x:0,y:a,pause:!0}}var Q={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function Z(t){var r=t.item,i=r.src,a=r.render,c=r.width,u=void 0===c?0:c,s=r.height,d=void 0===s?0:s,f=r.originRef,v=t.visible,m=t.speed,w=t.easing,b=t.wrapClassName,y=t.className,x=t.style,P=t.loadingElement,S=t.brokenElement,k=t.onPhotoTap,V=t.onMaskTap,M=t.onReachMove,N=t.onReachUp,Y=t.onPhotoResize,W=t.isActive,A=t.expose,B=p(Q),j=B[0],K=B[1],U=n(0),Z=z(),$=j.naturalWidth,ee=void 0===$?u:$,ne=j.naturalHeight,te=void 0===ne?d:ne,re=j.width,oe=void 0===re?u:re,ie=j.height,ae=void 0===ie?d:ie,ce=j.loaded,le=void 0===ce?!i:ce,ue=j.broken,se=j.x,de=j.y,fe=j.touched,ve=j.stopRaf,he=j.maskTouched,me=j.rotate,ge=j.scale,pe=j.CX,we=j.CY,be=j.lastX,ye=j.lastY,Ee=j.lastCX,xe=j.lastCY,Ce=j.lastScale,_e=j.touchTime,Re=j.touchLength,Pe=j.pause,Se=j.reach,ke=g({onScale:function(e){return Ve(C(e))},onRotate:function(e){me!==e&&(A({rotate:e}),K(h({rotate:e},J(ee,te,e))))}});function Ve(e,n,t){ge!==e&&(A({scale:e}),K(h({scale:e},D(se,de,oe,ae,ge,e,n,t),e<=1&&{x:0,y:0})))}var Me=L(function(e,n,t){if(void 0===t&&(t=0),(fe||he)&&W){var r=X(me,oe,ae),o=r[0],i=r[1];if(0===t&&0===U.current){var a=Math.abs(e-pe)<=20,c=Math.abs(n-we)<=20;if(a&&c)return void K({lastCX:e,lastCY:n});U.current=a?n>we?3:2:1}var l,u=e-Ee,s=n-xe;if(0===t){var d=T(u+be,ge,o,I())[0],f=T(s+ye,ge,i,innerHeight);l=function(e,n,t,r){return n&&1===e||"x"===r?"x":t&&e>1||"y"===r?"y":void 0}(U.current,d,f[0],Se),void 0!==l&&M(l,e,n,ge)}if("x"===l||he)return void K({reach:"x"});var v=C(ge+(t-Re)/100/2*ge,ee/oe,.2);A({scale:v}),K(h({touchLength:t,reach:l,scale:v},D(se,de,oe,ae,ge,v,e,n,u,s)))}},{maxWait:8});function Ne(e){return!ve&&!fe&&(Z.current&&K(h({},e,{pause:v})),Z.current)}var Ye,Fe,Te,Xe,Le,We,Ae,Ie,De=(Le=function(e){return Ne({x:e})},We=function(e){return Ne({y:e})},Ae=function(e){return Z.current&&(A({scale:e}),K({scale:e})),!fe&&Z.current},Ie=g({X:function(e){return Le(e)},Y:function(e){return We(e)},S:function(e){return Ae(e)}}),function(e,n,t,r,o,i,a,c,l,u,s){var d=X(u,o,i),f=d[0],v=d[1],h=T(e,c,f,I()),m=h[0],g=h[1],p=T(n,c,v,innerHeight),w=p[0],b=p[1],y=Date.now()-s;if(y>=200||c!==a||Math.abs(l-a)>1){var E=D(e,n,o,i,a,c),x=E.x,C=E.y,_=m?g:x!==e?x:null,R=w?b:C!==n?C:null;return null!==_&&H(e,_,Ie.X),null!==R&&H(n,R,Ie.Y),void(c!==a&&H(a,c,Ie.S))}var P=(e-t)/y,S=(n-r)/y,k=Math.sqrt(Math.pow(P,2)+Math.pow(S,2)),V=!1,M=!1;!function(e,n){var t,r=e,o=0,i=0,a=function(i){t||(t=i);var a=i-t,u=Math.sign(e),s=-.001*u,d=Math.sign(-r)*Math.pow(r,2)*2e-4,f=r*a+(s+d)*Math.pow(a,2)/2;o+=f,t=i,u*(r+=(s+d)*a)<=0?l():n(o)?c():l()};function c(){i=requestAnimationFrame(a)}function l(){cancelAnimationFrame(i)}c()}(k,function(t){var r=e+t*(P/k),o=n+t*(S/k),i=T(r,a,f,I()),c=i[0],l=i[1],u=T(o,a,v,innerHeight),s=u[0],d=u[1];if(c&&!V&&(V=!0,m?H(r,l,Ie.X):q(l,r+(r-l),Ie.X)),s&&!M&&(M=!0,w?H(o,d,Ie.Y):q(d,o+(o-d),Ie.Y)),V&&M)return!1;var h=V||Ie.X(l),g=M||Ie.Y(d);return h&&g})}),qe=(Ye=k,Fe=function(e,n){Se||Ve(1!==ge?1:Math.max(2,ee/oe),e,n)},Te=n(0),Xe=L(function(){Te.current=0,Ye.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);Te.current+=1,Xe.apply(void 0,e),Te.current>=2&&(Xe.cancel(),Te.current=0,Fe.apply(void 0,e))});function Be(e,n){if(U.current=0,(fe||he)&&W){K({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var t=C(ge,ee/oe);if(De(se,de,be,ye,oe,ae,ge,t,Ce,me,_e),N(e,n),pe===e&&we===n){if(fe)return void qe(e,n);he&&V(e,n)}}}function He(e,n,t){void 0===t&&(t=0),K({touched:!0,CX:e,CY:n,lastCX:e,lastCY:n,lastX:se,lastY:de,lastScale:ge,touchLength:t,touchTime:Date.now()})}function Oe(e){K({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:se,lastY:de})}R(E?void 0:"mousemove",function(e){e.preventDefault(),Me(e.clientX,e.clientY)}),R(E?void 0:"mouseup",function(e){Be(e.clientX,e.clientY)}),R(E?"touchmove":void 0,function(e){e.preventDefault();var n=F(e);Me.apply(void 0,n)},{passive:!1}),R(E?"touchend":void 0,function(e){var n=e.changedTouches[0];Be(n.clientX,n.clientY)},{passive:!1}),R("resize",L(function(){le&&!fe&&(K(J(ee,te,me)),Y())},{maxWait:8})),_(function(){W&&A(h({scale:ge,rotate:me},ke))},[W]);var ze=function(e,t,r,i,a,c,u,s,d,f){var v=function(e,t,r,o,i){var a=n(!1),c=p({lead:!0,scale:r}),l=c[0],u=l.lead,s=l.scale,d=c[1],f=L(function(e){try{return i(!0),d({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:o});return _(function(){a.current?(i(!1),d({lead:!0}),f(r)):a.current=!0},[r]),u?[e*s,t*s,r/s]:[e*r,t*r,1]}(c,u,s,d,f),h=v[0],m=v[1],w=v[2],b=function(e,t,r,i,a){var c=l(O),u=c[0],s=c[1],d=l(0),f=d[0],v=d[1],h=n(),m=g({OK:function(){return e&&v(4)}});function p(e){a(!1),v(e)}return o(function(){if(h.current||(h.current=Date.now()),r){if(function(e,n){var t=e&&e.current;if(t&&1===t.nodeType){var r=t.getBoundingClientRect();n({T:r.top,L:r.left,W:r.width,H:r.height,FIT:"IMG"===t.tagName?getComputedStyle(t).objectFit:void 0})}}(t,s),e)return Date.now()-h.current<250?(v(1),requestAnimationFrame(function(){v(2),requestAnimationFrame(function(){return p(3)})}),void setTimeout(m.OK,i)):void v(4);p(5)}},[e,r]),[f,u]}(e,t,r,d,f),y=b[0],E=b[1],x=E.T,C=E.L,R=E.W,P=E.H,S=E.FIT,k=I()/2,V=innerHeight/2,M=y<3||y>4;return[M?R?C:k:i+(k-c*s/2),M?R?x:V:a+(V-u*s/2),h,M&&S?h*(P/R):m,0===y?w:M?R/(c*s)||.01:w,M?S?1:0:1,y,S]}(v,f,le,se,de,oe,ae,ge,m,function(e){return K({pause:e})}),je=ze[4],Ke=ze[6],Ue="transform "+m+"ms "+w,Ge={className:y,onMouseDown:E?void 0:function(e){e.stopPropagation(),0===e.button&&He(e.clientX,e.clientY,0)},onTouchStart:E?function(e){e.stopPropagation(),He.apply(void 0,F(e))}:void 0,onWheel:function(e){if(!Se){var n=C(ge-e.deltaY/100/2,ee/oe);K({stopRaf:!0}),Ve(n,e.clientX,e.clientY)}},style:{width:ze[2]+"px",height:ze[3]+"px",opacity:ze[5],objectFit:4===Ke?void 0:ze[7],transform:me?"rotate("+me+"deg)":void 0,transition:Ke>2?Ue+", opacity "+m+"ms ease, height "+(Ke<4?m/2:Ke>4?m:0)+"ms "+w:void 0}};return e.createElement("div",{className:"PhotoView__PhotoWrap"+(b?" "+b:""),style:x,onMouseDown:!E&&W?Oe:void 0,onTouchStart:E&&W?function(e){return Oe(e.touches[0])}:void 0},e.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+je+", 0, 0, "+je+", "+ze[0]+", "+ze[1]+")",transition:fe||Pe?void 0:Ue,willChange:W?"transform":void 0}},i?e.createElement(G,h({src:i,loaded:le,broken:ue},Ge,{onPhotoLoad:function(e){K(h({},e,e.loaded&&J(e.naturalWidth||0,e.naturalHeight||0,me)))},loadingElement:P,brokenElement:S})):a&&a({attrs:Ge,scale:je,rotate:me})))}var $={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function ee(r){var i=r.loop,u=void 0===i?3:i,s=r.speed,d=r.easing,f=r.photoClosable,v=r.maskClosable,h=void 0===v||v,m=r.maskOpacity,w=void 0===m?1:m,C=r.pullClosable,P=void 0===C||C,N=r.pullAction,F=r.bannerVisible,T=void 0===F||F,X=r.overlayRender,L=r.toolbarRender,W=r.showBackdropImage,D=r.disableScroll,q=void 0===D||D,B=r.toolbarLeftRender,H=r.toolbarRightRender,O=r.toolbarBottomRender,z=r.sidebarWidth,j=r.sidebarLeftRender,K=r.sidebarRightRender,U=r.className,G=r.maskClassName,J=r.photoClassName,Q=r.photoWrapClassName,ee=r.loadingElement,ne=r.brokenElement,te=r.images,re=r.index,oe=void 0===re?0:re,ie=r.onIndexChange,ae=r.visible,ce=r.onClose,le=r.afterClose,ue=r.portalContainer,se=r.fullScreen,de=r.onFullScreen,fe=p($),ve=fe[0],he=fe[1],me=l(0),ge=me[0],pe=me[1],we=n();o(function(){return we.current&&A(we.current),function(){A(null)}},[ae]);var be=ve.x,ye=ve.touched,Ee=ve.pause,xe=ve.lastCX,Ce=ve.lastCY,_e=ve.bg,Re=void 0===_e?w:_e,Pe=ve.lastBg,Se=ve.overlay,ke=ve.minimal,Ve=ve.scale,Me=ve.rotate,Ne=ve.onScale,Ye=ve.onRotate,Fe=r.hasOwnProperty("index"),Te=Fe?oe:ge,Xe=Fe?ie:pe,Le=n(Te),We=te.length,Ae=te[Te],Ie="boolean"==typeof u?u:We>u,De=function(e,r){var o=t(function(e){return!e},!1)[1],i=n(0),c=function(t){var r=n(t);function o(e){r.current=e}return a(function(){!function(n){e?(n(e),i.current=1):i.current=2}(o)},[t]),[r.current,o]}(e),l=c[1];return[c[0],i.current,function(){o(),2===i.current&&(l(!1),r&&r()),i.current=0}]}(ae,le),qe=De[0],Be=De[1],He=De[2];_(function(){if(qe)return he({pause:!0,x:Te*-(I()+y)}),void(Le.current=Te);he($)},[qe]);var Oe=g({close:function(e){Ye&&Ye(0),he({overlay:!0,lastBg:Re}),ce(e)},changeIndex:function(e,n){void 0===n&&(n=!1);var t=Ie?Le.current+(e-Te):e,r=We-1,o=x(t,0,r),i=Ie?t:o,a=I()+y;he({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*i,pause:n}),Le.current=i,Xe&&Xe(Ie?e<0?r:e>r?0:e:o)}}),ze=Oe.close,je=Oe.changeIndex,Ke=c(function(){de(!se)},[se,de]),Ue=a(function(){return function(){!document.fullscreenElement&&se&&Ke()}},[se,Ke]),Ge=a(function(){return function(){if(document.fullscreenElement)document.exitFullscreen();else if(se){var e=we.current;if(!e)return;!function(e){try{e&&(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}catch(e){console.log("Error al intentar activar el modo de pantalla completa",e)}}(e)}}},[we,se]);function Je(e){return e?ze():he({overlay:!Se})}function Qe(){he({x:-(I()+y)*Te,lastCX:void 0,lastCY:void 0,pause:!0}),Le.current=Te}function Ze(e,n,t,r){"x"===e?function(e){if(void 0!==xe){var n=e-xe,t=n;!Ie&&(0===Te&&n>0||Te===We-1&&n<0)&&(t=n/2),he({touched:!0,lastCX:xe,x:-(I()+y)*Le.current+t,pause:!1})}else he({touched:!0,lastCX:e,x:be,pause:!1})}(n):"y"===e&&function(e,n){if(void 0!==Ce){var t=null===w?null:x(w,.01,w-Math.abs(e-Ce)/100/4);he({touched:!0,lastCY:Ce,bg:1===n?t:w,minimal:1===n})}else he({touched:!0,lastCY:e,bg:Re,minimal:!0})}(t,r)}function $e(e,n){var t=e-(null!=xe?xe:e),r=n-(null!=Ce?Ce:n),o=!1;if(t<-40)je(Te+1);else if(t>40)je(Te-1);else{var i=-(I()+y)*Le.current;Math.abs(r)>100&&ke&&P?(o=!0,ze()):Math.abs(r)>100&&ke&&"function"==typeof N&&N({direction:r<0?"top":"bottom",offsetY:r}),he({touched:!1,x:i,lastCX:void 0,lastCY:void 0,bg:w,overlay:!!o||Se})}}o(function(){if(we.current)return Ge(),document.addEventListener("fullscreenchange",Ue),function(){document.removeEventListener("fullscreenchange",Ue)}},[we,se,Ue,Ge]),R("keydown",function(e){if(ae)switch(e.key){case"ArrowLeft":je(Te-1,!1);break;case"ArrowRight":je(Te+1,!1);break;case"Escape":ze()}});var en=function(e,n,t){return a(function(){var r=e.length;return t?e.concat(e).concat(e).slice(r+n-1,r+n+2):e.slice(Math.max(n-1,0),Math.min(n+2,r+1))},[e,n,t])}(te,Te,Ie);if(!qe)return null;var nn=Se&&!Be,tn=ae?Re:Pe,rn=Ne&&Ye&&{images:te,index:Te,visible:ae,onClose:ze,onIndexChange:je,overlayVisible:nn,overlay:Ae&&Ae.overlay,scale:Ve,rotate:Me,onScale:Ne,onRotate:Ye,fullScreen:se,fullScreenAvailable:document.documentElement.requestFullscreen||document.documentElement.mozRequestFullScreen||document.documentElement.webkitRequestFullscreen||document.documentElement.msRequestFullscreen,toggleFullScreen:function(){return de(!se)}},on=s?s(Be):400,an=d?d(Be):b,cn=s?s(3):600,ln=d?d(3):b,un="number"==typeof z?z+"px":z,sn=window.innerWidth<=900;return e.createElement(S,{className:"PhotoView-Portal"+(nn?"":" PhotoView-Slider__clean")+(ae?"":" PhotoView-Slider__willClose")+(U?" "+U:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:ue},ae&&q&&e.createElement(M,null),e.createElement("div",{className:"PhotoView-Container"},j&&rn&&!sn&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===Be?" PhotoView-Slider__fadeIn":2===Be?" PhotoView-Slider__fadeOut":""),style:{width:un,transitionTimingFunction:an,transitionDuration:(ye?0:on)+"ms",animationDuration:on+"ms"}},j(rn)),e.createElement("div",{ref:we,className:"PhotoView-Viewer"},e.createElement("div",{className:"PhotoView-Slider__Backdrop"+(G?" "+G:"")+(1===Be?" PhotoView-Slider__fadeIn":2===Be?" PhotoView-Slider__fadeOut":"")+" "+(W?"with-backdrop-image":""),style:{background:W?"url("+Ae.src+")":tn?"rgba(0, 0, 0, "+tn+")":void 0,transitionTimingFunction:an,transitionDuration:(ye?0:on)+"ms",animationDuration:on+"ms"},onAnimationEnd:He}),e.createElement(Y,{bannerVisible:T,index:Te,imageLength:We,overlayParams:rn,toolbarRender:L,toolbarLeftRender:B,toolbarRightRender:H,toolbarBottomRender:O}),en.map(function(n,t){var r=Ie||0!==Te?Le.current-1+t:Te+t;return e.createElement(Z,{key:Ie?n.key+"/"+n.src+"/"+r:n.key,item:n,speed:on,easing:an,visible:ae,onReachMove:Ze,onReachUp:$e,onPhotoTap:function(){return Je(f)},onMaskTap:function(){return Je(h)},wrapClassName:Q,className:J,style:{left:(I()+y)*r+"px",transform:"translate3d("+be+"px, 0px, 0)",transition:ye||Ee?void 0:"transform "+cn+"ms "+ln},loadingElement:ee,brokenElement:ne,onPhotoResize:Qe,isActive:Le.current===r,expose:he})}),!E&&T&&e.createElement(e.Fragment,null,(Ie||0!==Te)&&e.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return je(Te-1,!0)}},e.createElement(k,null)),(Ie||Te+1<We)&&e.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return je(Te+1,!0)}},e.createElement(V,null))),X&&rn&&e.createElement("div",{className:"PhotoView-Slider__Overlay"},X(rn))),K&&rn&&!sn&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===Be?" PhotoView-Slider__fadeIn":2===Be?" PhotoView-Slider__fadeOut":""),style:{width:un,transitionTimingFunction:an,transitionDuration:(ye?0:on)+"ms",animationDuration:on+"ms"}},K(rn)),O&&rn&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Bottom",style:{width:"calc(100% - "+(sn?0:un)+")"}},O(rn))))}var ne=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],te={images:[],visible:!1,index:0,fullScreen:!1};function re(t){var r=t.children,i=t.onIndexChange,c=t.onVisibleChange,l=t.sidebarLeftRender,u=t.sidebarRightRender,s=t.sidebarWidth,d=void 0===s?400:s,f=m(t,ne),v=p(te),b=v[0],y=v[1],E=n(0),x=b.images,C=b.visible,_=b.index;o(function(){W.sidebarWidth=l||u?d:0},[l,u,d]);var R=g({nextId:function(){return E.current+=1},update:function(e){var n=x.findIndex(function(n){return n.key===e.key});if(n>-1){var t=x.slice();return t.splice(n,1,e),void y({images:t})}y(function(n){return{images:n.images.concat(e)}})},remove:function(e){y(function(n){var t=n.images.filter(function(n){return n.key!==e});return{images:t,index:Math.min(t.length-1,_)}})},show:function(e){var n=x.findIndex(function(n){return n.key===e});y({visible:!0,index:n}),c&&c(!0,n,b)}}),P=g({close:function(){y({visible:!1}),c&&c(!1,_,b)},changeIndex:function(e){y({index:e}),i&&i(e,b)},fullScreen:function(e){y({fullScreen:e})}}),S=a(function(){return h({},b,R)},[b,R]);return e.createElement(w.Provider,{value:S},r,e.createElement(ee,h({images:x,visible:C,index:_,fullScreen:b.fullScreen,onIndexChange:P.changeIndex,onClose:P.close,onFullScreen:P.fullScreen,sidebarWidth:d,sidebarLeftRender:l,sidebarRightRender:u},f)))}var oe=function(e){var t,r,i=e.src,c=e.render,l=e.overlay,v=e.width,m=e.height,p=e.triggers,b=void 0===p?["onClick"]:p,y=e.children,E=u(w),x=(t=function(){return E.nextId()},(r=n({sign:!1,fn:void 0}).current).sign||(r.sign=!0,r.fn=t()),r.fn),C=n(null);s(null==y?void 0:y.ref,function(){return C.current}),o(function(){return function(){E.remove(x)}},[]);var _=g({render:function(e){return c&&c(e)},show:function(e,n){E.show(x),function(e,n){if(y){var t=y.props[e];t&&t(n)}}(e,n)}}),R=a(function(){var e={};return b.forEach(function(n){e[n]=_.show.bind(null,n)}),e},[]);return o(function(){E.update({key:x,src:i,originRef:C,render:_.render,overlay:l,width:v,height:m})},[i]),y?d.only(f(y,h({},R,{ref:C}))):null};export{re as PhotoProvider,ee as PhotoSlider,oe as PhotoView}; | ||
import e,{useRef as n,useReducer as t,createContext as r,useEffect as o,useLayoutEffect as i,useMemo as a,useCallback as c,useState as l,useContext as u,useImperativeHandle as s,Children as d,cloneElement as f}from"react";import{createPortal as v}from"react-dom";function h(){return h=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},h.apply(null,arguments)}function m(e,n){if(null==e)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(n.includes(r))continue;t[r]=e[r]}return t}function g(e){var t=n({fn:e,curr:void 0}).current;if(t.fn=e,!t.curr){var r=Object.create(null);Object.keys(e).forEach(function(e){r[e]=function(){var n;return(n=t.fn[e]).call.apply(n,[t.fn].concat([].slice.call(arguments)))}}),t.curr=r}return t.curr}function p(e){return t(function(e,n){return h({},e,"function"==typeof n?n(e):n)},e)}var w=r(void 0),b="cubic-bezier(0.25, 0.8, 0.25, 1)",y=20,E="undefined"!=typeof window&&"ontouchstart"in window,x=function(e,n,t){return Math.max(Math.min(e,t),n)},C=function(e,n,t){return void 0===n&&(n=0),void 0===t&&(t=0),x(e,1*(1-t),Math.max(6,n)*(1+t))},_="undefined"==typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?o:i;function R(e,t,r){var i=n(t);i.current=t,o(function(){function n(e){i.current(e)}return e&&window.addEventListener(e,n,r),function(){e&&window.removeEventListener(e,n)}},[e])}var S=["container"];function P(n){var t=n.container,r=void 0===t?document.body:t,o=m(n,S);return v(e.createElement("div",h({},o)),r)}function k(n){return e.createElement("svg",h({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function V(n){return e.createElement("svg",h({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function M(){return o(function(){var e=document.body.style,n=e.overflow;return e.overflow="hidden",function(){e.overflow=n}},[]),null}function N(n){return e.createElement("svg",h({width:"44",height:"44",viewBox:"0 0 768 768"},n),e.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function Y(n){var t=n.toolbarRender,r=n.overlayParams,o=n.toolbarLeftRender,i=n.toolbarRightRender;return e.createElement(e.Fragment,null,n.bannerVisible&&e.createElement("div",{className:"PhotoView-Slider__BannerWrap"},e.createElement("div",{className:"PhotoView-Slider__Counter"},n.index+1," / ",n.imageLength),e.createElement("div",{className:"PhotoView-Slider__BannerRight"},t&&r&&t(r),e.createElement(N,{className:"PhotoView-Slider__toolbarIcon",onClick:close}))),o&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Left"},o(r)),i&&r&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Right"},i(r)))}function F(e){var n=e.touches[0],t=n.clientX,r=n.clientY;if(e.touches.length>=2){var o=e.touches[1],i=o.clientX,a=o.clientY;return[(t+i)/2,(r+a)/2,Math.sqrt(Math.pow(i-t,2)+Math.pow(a-r,2))]}return[t,r,0]}var T=function(e,n,t,r){var o,i=t*n,a=(i-r)/2,c=e;return i<=r?(o=1,c=0):e>0&&a-e<=0?(o=2,c=a):e<0&&a+e<=0&&(o=3,c=-a),[o,c]};function X(e,n,t){var r=e%180!=0;return r?[t,n,r]:[n,t,r]}function L(e,t){var r=t.leading,o=void 0!==r&&r,i=t.maxWait,a=t.wait,l=void 0===a?i||0:a,u=n(e);u.current=e;var s=n(0),d=n(),f=function(){return d.current&&clearTimeout(d.current)},v=c(function(){var e=[].slice.call(arguments),n=Date.now();function t(){s.current=n,f(),u.current.apply(null,e)}var r=s.current,a=n-r;if(0===r&&(o&&t(),s.current=n),void 0!==i){if(a>i)return void t()}else a<l&&(s.current=n);f(),d.current=setTimeout(function(){t(),s.current=0},l)},[l,i,o]);return v.cancel=f,v}var W=function(){};W.globalDivRef=null,W.sidebarWidth=400,W.fullScreen=!1;var A=function(e){W.globalDivRef=e},I=function(){return innerWidth-(innerWidth<=900||W.fullScreen?0:W.sidebarWidth)};function D(e,n,t,r,o,i,a,c,l,u){void 0===a&&(a=I()/2),void 0===c&&(c=innerHeight/2),void 0===l&&(l=0),void 0===u&&(u=0);var s=T(e,i,t,I())[0],d=T(n,i,r,innerHeight)[0],f=I()/2,v=innerHeight/2,h=c-i/o*(c-(v+n))-v;return{x:a-i/o*(a-(f+e))-f+(r/t>=3&&t*i===I()?0:s?l/2:l),y:h+(d?u/2:u),lastCX:a,lastCY:c}}var q=function(e,n,t){return H(e,n,t,100,function(e){return e},function(){return H(n,e,t)})},B=function(e){return 1-Math.pow(1-e,4)};function H(e,n,t,r,o,i){void 0===r&&(r=400),void 0===o&&(o=B);var a=n-e;if(0!==a){var c=Date.now(),l=0,u=function(){var n=Math.min(1,(Date.now()-c)/r);t(e+o(n)*a)&&n<1?s():(cancelAnimationFrame(l),n>=1&&i&&i())};s()}function s(){l=requestAnimationFrame(u)}}var O={T:0,L:0,W:0,H:0,FIT:void 0},z=function(){var e=n(!1);return o(function(){return e.current=!0,function(){e.current=!1}},[]),e},j=["className"];function K(n){var t=n.className,r=void 0===t?"":t,o=m(n,j);return e.createElement("div",h({className:"PhotoView__Spinner "+r},o),e.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},e.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),e.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var U=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function G(n){var t=n.src,r=n.loaded,o=n.broken,i=n.className,a=n.onPhotoLoad,c=n.loadingElement,l=n.brokenElement,u=m(n,U),s=z();return t&&!o?e.createElement(e.Fragment,null,e.createElement("img",h({className:"PhotoView__Photo"+(i?" "+i:""),src:t,onLoad:function(e){var n=e.target;s.current&&a({loaded:!0,naturalWidth:n.naturalWidth,naturalHeight:n.naturalHeight})},onError:function(){s.current&&a({broken:!0})},alt:""},u)),!r&&(e.createElement("span",{className:"PhotoView__icon"},c)||e.createElement(K,{className:"PhotoView__icon"}))):l?e.createElement("span",{className:"PhotoView__icon"},"function"==typeof l?l({src:t}):l):null}function J(e,n,t){var r=X(t,I(),innerHeight),o=r[0],i=r[1],a=0,c=o,l=i,u=e/n*i,s=n/e*o;return e<o&&n<i?(c=e,l=n):e<o&&n>=i?c=u:e>=o&&n<i||e/n>o/i?l=s:n/e>=3&&!r[2]?a=((l=s)-i)/2:c=u,{width:c,height:l,x:0,y:a,pause:!0}}var Q={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function Z(t){var r=t.item,i=r.src,a=r.render,c=r.width,u=void 0===c?0:c,s=r.height,d=void 0===s?0:s,f=r.originRef,v=t.visible,m=t.speed,w=t.easing,b=t.wrapClassName,y=t.className,x=t.style,S=t.loadingElement,P=t.brokenElement,k=t.onPhotoTap,V=t.onMaskTap,M=t.onReachMove,N=t.onReachUp,Y=t.onPhotoResize,W=t.isActive,A=t.expose,B=p(Q),j=B[0],K=B[1],U=n(0),Z=z(),$=j.naturalWidth,ee=void 0===$?u:$,ne=j.naturalHeight,te=void 0===ne?d:ne,re=j.width,oe=void 0===re?u:re,ie=j.height,ae=void 0===ie?d:ie,ce=j.loaded,le=void 0===ce?!i:ce,ue=j.broken,se=j.x,de=j.y,fe=j.touched,ve=j.stopRaf,he=j.maskTouched,me=j.rotate,ge=j.scale,pe=j.CX,we=j.CY,be=j.lastX,ye=j.lastY,Ee=j.lastCX,xe=j.lastCY,Ce=j.lastScale,_e=j.touchTime,Re=j.touchLength,Se=j.pause,Pe=j.reach,ke=g({onScale:function(e){return Ve(C(e))},onRotate:function(e){me!==e&&(A({rotate:e}),K(h({rotate:e},J(ee,te,e))))}});function Ve(e,n,t){ge!==e&&(A({scale:e}),K(h({scale:e},D(se,de,oe,ae,ge,e,n,t),e<=1&&{x:0,y:0})))}var Me=L(function(e,n,t){if(void 0===t&&(t=0),(fe||he)&&W){var r=X(me,oe,ae),o=r[0],i=r[1];if(0===t&&0===U.current){var a=Math.abs(e-pe)<=20,c=Math.abs(n-we)<=20;if(a&&c)return void K({lastCX:e,lastCY:n});U.current=a?n>we?3:2:1}var l,u=e-Ee,s=n-xe;if(0===t){var d=T(u+be,ge,o,I())[0],f=T(s+ye,ge,i,innerHeight);l=function(e,n,t,r){return n&&1===e||"x"===r?"x":t&&e>1||"y"===r?"y":void 0}(U.current,d,f[0],Pe),void 0!==l&&M(l,e,n,ge)}if("x"===l||he)return void K({reach:"x"});var v=C(ge+(t-Re)/100/2*ge,ee/oe,.2);A({scale:v}),K(h({touchLength:t,reach:l,scale:v},D(se,de,oe,ae,ge,v,e,n,u,s)))}},{maxWait:8});function Ne(e){return!ve&&!fe&&(Z.current&&K(h({},e,{pause:v})),Z.current)}var Ye,Fe,Te,Xe,Le,We,Ae,Ie,De=(Le=function(e){return Ne({x:e})},We=function(e){return Ne({y:e})},Ae=function(e){return Z.current&&(A({scale:e}),K({scale:e})),!fe&&Z.current},Ie=g({X:function(e){return Le(e)},Y:function(e){return We(e)},S:function(e){return Ae(e)}}),function(e,n,t,r,o,i,a,c,l,u,s){var d=X(u,o,i),f=d[0],v=d[1],h=T(e,c,f,I()),m=h[0],g=h[1],p=T(n,c,v,innerHeight),w=p[0],b=p[1],y=Date.now()-s;if(y>=200||c!==a||Math.abs(l-a)>1){var E=D(e,n,o,i,a,c),x=E.x,C=E.y,_=m?g:x!==e?x:null,R=w?b:C!==n?C:null;return null!==_&&H(e,_,Ie.X),null!==R&&H(n,R,Ie.Y),void(c!==a&&H(a,c,Ie.S))}var S=(e-t)/y,P=(n-r)/y,k=Math.sqrt(Math.pow(S,2)+Math.pow(P,2)),V=!1,M=!1;!function(e,n){var t,r=e,o=0,i=0,a=function(i){t||(t=i);var a=i-t,u=Math.sign(e),s=-.001*u,d=Math.sign(-r)*Math.pow(r,2)*2e-4,f=r*a+(s+d)*Math.pow(a,2)/2;o+=f,t=i,u*(r+=(s+d)*a)<=0?l():n(o)?c():l()};function c(){i=requestAnimationFrame(a)}function l(){cancelAnimationFrame(i)}c()}(k,function(t){var r=e+t*(S/k),o=n+t*(P/k),i=T(r,a,f,I()),c=i[0],l=i[1],u=T(o,a,v,innerHeight),s=u[0],d=u[1];if(c&&!V&&(V=!0,m?H(r,l,Ie.X):q(l,r+(r-l),Ie.X)),s&&!M&&(M=!0,w?H(o,d,Ie.Y):q(d,o+(o-d),Ie.Y)),V&&M)return!1;var h=V||Ie.X(l),g=M||Ie.Y(d);return h&&g})}),qe=(Ye=k,Fe=function(e,n){Pe||Ve(1!==ge?1:Math.max(2,ee/oe),e,n)},Te=n(0),Xe=L(function(){Te.current=0,Ye.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);Te.current+=1,Xe.apply(void 0,e),Te.current>=2&&(Xe.cancel(),Te.current=0,Fe.apply(void 0,e))});function Be(e,n){if(U.current=0,(fe||he)&&W){K({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var t=C(ge,ee/oe);if(De(se,de,be,ye,oe,ae,ge,t,Ce,me,_e),N(e,n),pe===e&&we===n){if(fe)return void qe(e,n);he&&V(e,n)}}}function He(e,n,t){void 0===t&&(t=0),K({touched:!0,CX:e,CY:n,lastCX:e,lastCY:n,lastX:se,lastY:de,lastScale:ge,touchLength:t,touchTime:Date.now()})}function Oe(e){K({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:se,lastY:de})}R(E?void 0:"mousemove",function(e){e.preventDefault(),Me(e.clientX,e.clientY)}),R(E?void 0:"mouseup",function(e){Be(e.clientX,e.clientY)}),R(E?"touchmove":void 0,function(e){e.preventDefault();var n=F(e);Me.apply(void 0,n)},{passive:!1}),R(E?"touchend":void 0,function(e){var n=e.changedTouches[0];Be(n.clientX,n.clientY)},{passive:!1}),R("resize",L(function(){le&&!fe&&(K(J(ee,te,me)),Y())},{maxWait:8})),_(function(){W&&A(h({scale:ge,rotate:me},ke))},[W]);var ze=function(e,t,r,i,a,c,u,s,d,f){var v=function(e,t,r,o,i){var a=n(!1),c=p({lead:!0,scale:r}),l=c[0],u=l.lead,s=l.scale,d=c[1],f=L(function(e){try{return i(!0),d({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:o});return _(function(){a.current?(i(!1),d({lead:!0}),f(r)):a.current=!0},[r]),u?[e*s,t*s,r/s]:[e*r,t*r,1]}(c,u,s,d,f),h=v[0],m=v[1],w=v[2],b=function(e,t,r,i,a){var c=l(O),u=c[0],s=c[1],d=l(0),f=d[0],v=d[1],h=n(),m=g({OK:function(){return e&&v(4)}});function p(e){a(!1),v(e)}return o(function(){if(h.current||(h.current=Date.now()),r){if(function(e,n){var t=e&&e.current;if(t&&1===t.nodeType){var r=t.getBoundingClientRect();n({T:r.top,L:r.left,W:r.width,H:r.height,FIT:"IMG"===t.tagName?getComputedStyle(t).objectFit:void 0})}}(t,s),e)return Date.now()-h.current<250?(v(1),requestAnimationFrame(function(){v(2),requestAnimationFrame(function(){return p(3)})}),void setTimeout(m.OK,i)):void v(4);p(5)}},[e,r]),[f,u]}(e,t,r,d,f),y=b[0],E=b[1],x=E.T,C=E.L,R=E.W,S=E.H,P=E.FIT,k=I()/2,V=innerHeight/2,M=y<3||y>4;return[M?R?C:k:i+(k-c*s/2),M?R?x:V:a+(V-u*s/2),h,M&&P?h*(S/R):m,0===y?w:M?R/(c*s)||.01:w,M?P?1:0:1,y,P]}(v,f,le,se,de,oe,ae,ge,m,function(e){return K({pause:e})}),je=ze[4],Ke=ze[6],Ue="transform "+m+"ms "+w,Ge={className:y,onMouseDown:E?void 0:function(e){e.stopPropagation(),0===e.button&&He(e.clientX,e.clientY,0)},onTouchStart:E?function(e){e.stopPropagation(),He.apply(void 0,F(e))}:void 0,onWheel:function(e){if(!Pe){var n=C(ge-e.deltaY/100/2,ee/oe);K({stopRaf:!0}),Ve(n,e.clientX,e.clientY)}},style:{width:ze[2]+"px",height:ze[3]+"px",opacity:ze[5],objectFit:4===Ke?void 0:ze[7],transform:me?"rotate("+me+"deg)":void 0,transition:Ke>2?Ue+", opacity "+m+"ms ease, height "+(Ke<4?m/2:Ke>4?m:0)+"ms "+w:void 0}};return e.createElement("div",{className:"PhotoView__PhotoWrap"+(b?" "+b:""),style:x,onMouseDown:!E&&W?Oe:void 0,onTouchStart:E&&W?function(e){return Oe(e.touches[0])}:void 0},e.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+je+", 0, 0, "+je+", "+ze[0]+", "+ze[1]+")",transition:fe||Se?void 0:Ue,willChange:W?"transform":void 0}},i?e.createElement(G,h({src:i,loaded:le,broken:ue},Ge,{onPhotoLoad:function(e){K(h({},e,e.loaded&&J(e.naturalWidth||0,e.naturalHeight||0,me)))},loadingElement:S,brokenElement:P})):a&&a({attrs:Ge,scale:je,rotate:me})))}var $={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function ee(r){var i=r.loop,u=void 0===i?3:i,s=r.speed,d=r.easing,f=r.photoClosable,v=r.maskClosable,h=void 0===v||v,m=r.maskOpacity,w=void 0===m?1:m,C=r.pullClosable,S=void 0===C||C,N=r.pullAction,F=r.bannerVisible,T=void 0===F||F,X=r.overlayRender,L=r.toolbarRender,D=r.showBackdropImage,q=r.disableScroll,B=void 0===q||q,H=r.toolbarLeftRender,O=r.toolbarRightRender,z=r.toolbarBottomRender,j=r.sidebarWidth,K=r.sidebarLeftRender,U=r.sidebarRightRender,G=r.className,J=r.maskClassName,Q=r.photoClassName,ee=r.photoWrapClassName,ne=r.loadingElement,te=r.brokenElement,re=r.images,oe=r.index,ie=void 0===oe?0:oe,ae=r.onIndexChange,ce=r.visible,le=r.onClose,ue=r.afterClose,se=r.portalContainer,de=r.fullScreen,fe=r.onFullScreen,ve=p($),he=ve[0],me=ve[1],ge=l(0),pe=ge[0],we=ge[1],be=n();o(function(){return be.current&&A(be.current),function(){A(null)}},[ce]);var ye=he.x,Ee=he.touched,xe=he.pause,Ce=he.lastCX,_e=he.lastCY,Re=he.bg,Se=void 0===Re?w:Re,Pe=he.lastBg,ke=he.overlay,Ve=he.minimal,Me=he.scale,Ne=he.rotate,Ye=he.onScale,Fe=he.onRotate,Te=r.hasOwnProperty("index"),Xe=Te?ie:pe,Le=Te?ae:we,We=n(Xe),Ae=re.length,Ie=re[Xe],De="boolean"==typeof u?u:Ae>u,qe=function(e,r){var o=t(function(e){return!e},!1)[1],i=n(0),c=function(t){var r=n(t);function o(e){r.current=e}return a(function(){!function(n){e?(n(e),i.current=1):i.current=2}(o)},[t]),[r.current,o]}(e),l=c[1];return[c[0],i.current,function(){o(),2===i.current&&(l(!1),r&&r()),i.current=0}]}(ce,ue),Be=qe[0],He=qe[1],Oe=qe[2];_(function(){if(Be)return me({pause:!0,x:Xe*-(I()+y)}),void(We.current=Xe);me($)},[Be]);var ze=g({close:function(e){Fe&&Fe(0),me({overlay:!0,lastBg:Se}),le(e)},changeIndex:function(e,n){void 0===n&&(n=!1);var t=De?We.current+(e-Xe):e,r=Ae-1,o=x(t,0,r),i=De?t:o,a=I()+y;me({touched:!1,lastCX:void 0,lastCY:void 0,x:-a*i,pause:n}),We.current=i,Le&&Le(De?e<0?r:e>r?0:e:o)}}),je=ze.close,Ke=ze.changeIndex,Ue=c(function(){fe(!de)},[de,fe]),Ge=a(function(){return function(){!document.fullscreenElement&&de&&Ue()}},[de,Ue]),Je=a(function(){return function(){if(document.fullscreenElement)document.exitFullscreen();else if(de){var e=be.current;if(!e)return;!function(e){try{e&&(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}catch(e){console.log("Error al intentar activar el modo de pantalla completa",e)}}(e)}}},[be,de]);function Qe(e){return e?je():me({overlay:!ke})}function Ze(){me({x:-(I()+y)*Xe,lastCX:void 0,lastCY:void 0,pause:!0}),We.current=Xe}function $e(e,n,t,r){"x"===e?function(e){if(void 0!==Ce){var n=e-Ce,t=n;!De&&(0===Xe&&n>0||Xe===Ae-1&&n<0)&&(t=n/2),me({touched:!0,lastCX:Ce,x:-(I()+y)*We.current+t,pause:!1})}else me({touched:!0,lastCX:e,x:ye,pause:!1})}(n):"y"===e&&function(e,n){if(void 0!==_e){var t=null===w?null:x(w,.01,w-Math.abs(e-_e)/100/4);me({touched:!0,lastCY:_e,bg:1===n?t:w,minimal:1===n})}else me({touched:!0,lastCY:e,bg:Se,minimal:!0})}(t,r)}function en(e,n){var t=e-(null!=Ce?Ce:e),r=n-(null!=_e?_e:n),o=!1;if(t<-40)Ke(Xe+1);else if(t>40)Ke(Xe-1);else{var i=-(I()+y)*We.current;Math.abs(r)>100&&Ve&&S?(o=!0,je()):Math.abs(r)>100&&Ve&&"function"==typeof N&&N({direction:r<0?"top":"bottom",offsetY:r}),me({touched:!1,x:i,lastCX:void 0,lastCY:void 0,bg:w,overlay:!!o||ke})}}o(function(){if(be.current)return Je(),function(e){W.fullScreen=e}(de),document.addEventListener("fullscreenchange",Ge),function(){document.removeEventListener("fullscreenchange",Ge)}},[be,de,Ge,Je]),R("keydown",function(e){if(ce)switch(e.key){case"ArrowLeft":Ke(Xe-1,!1);break;case"ArrowRight":Ke(Xe+1,!1);break;case"Escape":je()}});var nn=function(e,n,t){return a(function(){var r=e.length;return t?e.concat(e).concat(e).slice(r+n-1,r+n+2):e.slice(Math.max(n-1,0),Math.min(n+2,r+1))},[e,n,t])}(re,Xe,De);if(!Be)return null;var tn=ke&&!He,rn=ce?Se:Pe,on=Ye&&Fe&&{images:re,index:Xe,visible:ce,onClose:je,onIndexChange:Ke,overlayVisible:tn,overlay:Ie&&Ie.overlay,scale:Me,rotate:Ne,onScale:Ye,onRotate:Fe,fullScreen:de,fullScreenAvailable:document.documentElement.requestFullscreen||document.documentElement.mozRequestFullScreen||document.documentElement.webkitRequestFullscreen||document.documentElement.msRequestFullscreen,toggleFullScreen:function(){return fe(!de)}},an=s?s(He):400,cn=d?d(He):b,ln=s?s(3):600,un=d?d(3):b,sn="number"==typeof j?j+"px":j,dn=window.innerWidth<=900;return e.createElement(P,{className:"PhotoView-Portal"+(tn?"":" PhotoView-Slider__clean")+(ce?"":" PhotoView-Slider__willClose")+(G?" "+G:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:se},ce&&B&&e.createElement(M,null),e.createElement("div",{className:"PhotoView-Container"},K&&on&&!dn&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Left "+(1===He?" PhotoView-Slider__fadeIn":2===He?" PhotoView-Slider__fadeOut":""),style:{width:sn,transitionTimingFunction:cn,transitionDuration:(Ee?0:an)+"ms",animationDuration:an+"ms"}},K(on)),e.createElement("div",{ref:be,className:"PhotoView-Viewer"},e.createElement("div",{className:"PhotoView-Slider__Backdrop"+(J?" "+J:"")+(1===He?" PhotoView-Slider__fadeIn":2===He?" PhotoView-Slider__fadeOut":"")+" "+(D?"with-backdrop-image":""),style:{background:D?"url("+Ie.src+")":rn?"rgba(0, 0, 0, "+rn+")":void 0,transitionTimingFunction:cn,transitionDuration:(Ee?0:an)+"ms",animationDuration:an+"ms"},onAnimationEnd:Oe}),e.createElement(Y,{bannerVisible:T,index:Xe,imageLength:Ae,overlayParams:on,toolbarRender:L,toolbarLeftRender:H,toolbarRightRender:O,toolbarBottomRender:z}),nn.map(function(n,t){var r=De||0!==Xe?We.current-1+t:Xe+t;return e.createElement(Z,{key:De?n.key+"/"+n.src+"/"+r:n.key,item:n,speed:an,easing:cn,visible:ce,onReachMove:$e,onReachUp:en,onPhotoTap:function(){return Qe(f)},onMaskTap:function(){return Qe(h)},wrapClassName:ee,className:Q,style:{left:(I()+y)*r+"px",transform:"translate3d("+ye+"px, 0px, 0)",transition:Ee||xe?void 0:"transform "+ln+"ms "+un},loadingElement:ne,brokenElement:te,onPhotoResize:Ze,isActive:We.current===r,expose:me})}),!E&&T&&e.createElement(e.Fragment,null,(De||0!==Xe)&&e.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return Ke(Xe-1,!0)}},e.createElement(k,null)),(De||Xe+1<Ae)&&e.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return Ke(Xe+1,!0)}},e.createElement(V,null))),X&&on&&e.createElement("div",{className:"PhotoView-Slider__Overlay"},X(on))),U&&on&&!dn&&e.createElement("div",{className:"PhotoView-Sidebar PhotoView-Sidebar__Right "+(1===He?" PhotoView-Slider__fadeIn":2===He?" PhotoView-Slider__fadeOut":""),style:{width:sn,transitionTimingFunction:cn,transitionDuration:(Ee?0:an)+"ms",animationDuration:an+"ms"}},U(on)),z&&on&&e.createElement("div",{className:"PhotoView-Slider__Toolbar PhotoView-Slider__Toolbar--Bottom",style:{width:"calc(100% - "+(dn?0:sn)+")"}},z(on))))}var ne=["children","onIndexChange","onVisibleChange","sidebarLeftRender","sidebarRightRender","sidebarWidth"],te={images:[],visible:!1,index:0,fullScreen:!1};function re(t){var r=t.children,i=t.onIndexChange,c=t.onVisibleChange,l=t.sidebarLeftRender,u=t.sidebarRightRender,s=t.sidebarWidth,d=void 0===s?400:s,f=m(t,ne),v=p(te),b=v[0],y=v[1],E=n(0),x=b.images,C=b.visible,_=b.index;o(function(){W.sidebarWidth=l||u?d:0},[l,u,d]);var R=g({nextId:function(){return E.current+=1},update:function(e){var n=x.findIndex(function(n){return n.key===e.key});if(n>-1){var t=x.slice();return t.splice(n,1,e),void y({images:t})}y(function(n){return{images:n.images.concat(e)}})},remove:function(e){y(function(n){var t=n.images.filter(function(n){return n.key!==e});return{images:t,index:Math.min(t.length-1,_)}})},show:function(e){var n=x.findIndex(function(n){return n.key===e});y({visible:!0,index:n}),c&&c(!0,n,b)}}),S=g({close:function(){y({visible:!1}),c&&c(!1,_,b)},changeIndex:function(e){y({index:e}),i&&i(e,b)},fullScreen:function(e){y({fullScreen:e})}}),P=a(function(){return h({},b,R)},[b,R]);return e.createElement(w.Provider,{value:P},r,e.createElement(ee,h({images:x,visible:C,index:_,fullScreen:b.fullScreen,onIndexChange:S.changeIndex,onClose:S.close,onFullScreen:S.fullScreen,sidebarWidth:d,sidebarLeftRender:l,sidebarRightRender:u},f)))}var oe=function(e){var t,r,i=e.src,c=e.render,l=e.overlay,v=e.width,m=e.height,p=e.triggers,b=void 0===p?["onClick"]:p,y=e.children,E=u(w),x=(t=function(){return E.nextId()},(r=n({sign:!1,fn:void 0}).current).sign||(r.sign=!0,r.fn=t()),r.fn),C=n(null);s(null==y?void 0:y.ref,function(){return C.current}),o(function(){return function(){E.remove(x)}},[]);var _=g({render:function(e){return c&&c(e)},show:function(e,n){E.show(x),function(e,n){if(y){var t=y.props[e];t&&t(n)}}(e,n)}}),R=a(function(){var e={};return b.forEach(function(n){e[n]=_.show.bind(null,n)}),e},[]);return o(function(){E.update({key:x,src:i,originRef:C,render:_.render,overlay:l,width:v,height:m})},[i]),y?d.only(f(y,h({},R,{ref:C}))):null};export{re as PhotoProvider,ee as PhotoSlider,oe as PhotoView}; | ||
//# sourceMappingURL=react-photo-view.module.js.map |
export declare const setDivRef: (ref: HTMLElement | null) => void; | ||
export declare const setSidebarWidth: (width: number) => void; | ||
export declare const setFullScreen: (fullScreen: boolean) => void; | ||
export declare const getInnerWidth: () => number; | ||
export declare const isMobile: () => boolean; |
{ | ||
"name": "@starlly-labs/photo-viewer", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"description": "An exquisite React photo preview component", | ||
@@ -5,0 +5,0 @@ "author": "johnjaider1000", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
430118
803