!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lottie-web"),require("react")):"function"==typeof define&&define.amd?define(["exports","lottie-web","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["lottie-react"]={},e.Lottie,e.React)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(t),i=r(n);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n0&&void 0!==arguments[0]?arguments[0]:{};if(E.current){null===(t=R.current)||void 0===t||t.destroy();var r=s(s(s({},e),n),{},{container:E.current});return R.current=o.default.loadAnimation(r),D(!!R.current),function(){var e;null===(e=R.current)||void 0===e||e.destroy(),R.current=void 0}}}();return function(){return null==t?void 0:t()}}),[r,a]),n.useEffect((function(){R.current&&(R.current.autoplay=!!u)}),[u]),n.useEffect((function(){R.current&&(l?Array.isArray(l)&&l.length&&((R.current.currentRawFramel[1])&&(R.current.currentRawFrame=l[0]),R.current.setSegment(l[0],l[1])):R.current.resetSegments(!0))}),[l]),n.useEffect((function(){var e=[{name:"complete",handler:m},{name:"loopComplete",handler:y},{name:"enterFrame",handler:p},{name:"segmentStart",handler:v},{name:"config_ready",handler:g},{name:"data_ready",handler:b},{name:"data_failed",handler:S},{name:"loaded_images",handler:h},{name:"DOMLoaded",handler:O},{name:"destroy",handler:w}].filter((function(e){return null!=e.handler}));if(e.length){var t=e.map((function(e){var t;return null===(t=R.current)||void 0===t||t.addEventListener(e.name,e.handler),function(){var t;null===(t=R.current)||void 0===t||t.removeEventListener(e.name,e.handler)}}));return function(){t.forEach((function(e){return e()}))}}}),[m,y,p,v,g,b,S,h,O,w]),{View:i.default.createElement("div",s({style:t,ref:E},A)),play:function(){var e;null===(e=R.current)||void 0===e||e.play()},stop:function(){var e;null===(e=R.current)||void 0===e||e.stop()},pause:function(){var e;null===(e=R.current)||void 0===e||e.pause()},setSpeed:function(e){var t;null===(t=R.current)||void 0===t||t.setSpeed(e)},goToAndStop:function(e,t){var n;null===(n=R.current)||void 0===n||n.goToAndStop(e,t)},goToAndPlay:function(e,t){var n;null===(n=R.current)||void 0===n||n.goToAndPlay(e,t)},setDirection:function(e){var t;null===(t=R.current)||void 0===t||t.setDirection(e)},playSegments:function(e,t){var n;null===(n=R.current)||void 0===n||n.playSegments(e,t)},setSubframe:function(e){var t;null===(t=R.current)||void 0===t||t.setSubframe(e)},getDuration:function(e){var t;return null===(t=R.current)||void 0===t?void 0:t.getDuration(e)},destroy:function(){var e;null===(e=R.current)||void 0===e||e.destroy(),R.current=void 0},animationContainerRef:E,animationLoaded:j,animationItem:R.current}};var y=function(e){var t=e.wrapperRef,r=e.animationItem,o=e.mode,i=e.actions;n.useEffect((function(){var e=t.current;if(e&&r&&i.length){r.stop();var n,a,u,l,s;switch(o){case"scroll":return l=null,s=function(){var t,n,o,a=(n=(t=e.getBoundingClientRect()).top,o=t.height,(window.innerHeight-n)/(window.innerHeight+o)),u=i.find((function(e){var t=e.visibility;return t&&a>=t[0]&&a<=t[1]}));if(u){if("seek"===u.type&&u.visibility&&2===u.frames.length){var s=u.frames[0]+Math.ceil((a-u.visibility[0])/(u.visibility[1]-u.visibility[0])*u.frames[1]); //! goToAndStop must be relative to the start of the current segment r.goToAndStop(s-r.firstFrame-1,!0)}"loop"===u.type&&(null===l||l!==u.frames||r.isPaused)&&(r.playSegments(u.frames,!0),l=u.frames),"play"===u.type&&r.isPaused&&(r.resetSegments(!0),r.play()),"stop"===u.type&&r.goToAndStop(u.frames[0]-r.firstFrame-1,!0)}},document.addEventListener("scroll",s),function(){document.removeEventListener("scroll",s)};case"cursor":return n=function(t,n){var o,a,u,l,s=t,c=n;if(-1!==s&&-1!==c){var f=(o=s,a=c,l=(u=e.getBoundingClientRect()).top,{x:(o-u.left)/u.width,y:(a-l)/u.height});s=f.x,c=f.y}var d=i.find((function(e){var t=e.position;return t&&Array.isArray(t.x)&&Array.isArray(t.y)?s>=t.x[0]&&s<=t.x[1]&&c>=t.y[0]&&c<=t.y[1]:!(!t||Number.isNaN(t.x)||Number.isNaN(t.y))&&s===t.x&&c===t.y}));if(d){if("seek"===d.type&&d.position&&Array.isArray(d.position.x)&&Array.isArray(d.position.y)&&2===d.frames.length){var m=(s-d.position.x[0])/(d.position.x[1]-d.position.x[0]),y=(c-d.position.y[0])/(d.position.y[1]-d.position.y[0]);r.playSegments(d.frames,!0),r.goToAndStop(Math.ceil((m+y)/2*(d.frames[1]-d.frames[0])),!0)}"loop"===d.type&&r.playSegments(d.frames,!0),"play"===d.type&&(r.isPaused&&r.resetSegments(!1),r.playSegments(d.frames)),"stop"===d.type&&r.goToAndStop(d.frames[0],!0)}},a=function(e){n(e.clientX,e.clientY)},u=function(){n(-1,-1)},e.addEventListener("mousemove",a),e.addEventListener("mouseout",u),function(){e.removeEventListener("mousemove",a),e.removeEventListener("mouseout",u)}}}}),[o,r])},p=function(e){var t=e.actions,n=e.mode,r=e.lottieObj,o=r.animationItem,i=r.View,a=r.animationContainerRef;return y({actions:t,animationItem:o,mode:n,wrapperRef:a}),i},v=["style","interactivity"];Object.defineProperty(e,"LottiePlayer",{enumerable:!0,get:function(){return o.default}}),e.default=function(e){var t,r,o,i=e.style,a=e.interactivity,u=c(e,v),l=m(u,i),s=l.View,f=l.play,d=l.stop,y=l.pause,g=l.setSpeed,b=l.goToAndStop,S=l.goToAndPlay,h=l.setDirection,O=l.playSegments,w=l.setSubframe,A=l.getDuration,P=l.destroy,j=l.animationContainerRef,D=l.animationLoaded,R=l.animationItem;return n.useEffect((function(){e.lottieRef&&(e.lottieRef.current={play:f,stop:d,pause:y,setSpeed:g,goToAndPlay:S,goToAndStop:b,setDirection:h,playSegments:O,setSubframe:w,getDuration:A,destroy:P,animationContainerRef:j,animationLoaded:D,animationItem:R})}),[null===(t=e.lottieRef)||void 0===t?void 0:t.current]),p({lottieObj:{View:s,play:f,stop:d,pause:y,setSpeed:g,goToAndStop:b,goToAndPlay:S,setDirection:h,playSegments:O,setSubframe:w,getDuration:A,destroy:P,animationContainerRef:j,animationLoaded:D,animationItem:R},actions:null!==(r=null==a?void 0:a.actions)&&void 0!==r?r:[],mode:null!==(o=null==a?void 0:a.mode)&&void 0!==o?o:"scroll"})},e.useLottie=m,e.useLottieInteractivity=p,Object.defineProperty(e,"__esModule",{value:!0})}));