mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-28 03:15:16 +00:00
3 lines
15 KiB
JavaScript
3 lines
15 KiB
JavaScript
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("clsx")),r=require("react-dom");function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}function a(e){return"number"==typeof e&&!isNaN(e)}function i(e){return"boolean"==typeof e}function c(e){return"string"==typeof e}function u(e){return"function"==typeof e}function l(e){return c(e)||u(e)?e:null}function d(e){return 0===e||e}var f=!("undefined"==typeof window||!window.document||!window.document.createElement);function p(e){return t.isValidElement(e)||c(e)||u(e)||a(e)}var m={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},g={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default",DARK:"dark"};function v(e,t,n){void 0===n&&(n=300);var o=e.scrollHeight,r=e.style;requestAnimationFrame((function(){r.minHeight="initial",r.height=o+"px",r.transition="all "+n+"ms",requestAnimationFrame((function(){r.height="0",r.padding="0",r.margin="0",setTimeout(t,n)}))}))}function y(e){var o=e.enter,r=e.exit,s=e.appendPosition,a=void 0!==s&&s,i=e.collapse,c=void 0===i||i,u=e.collapseDuration,l=void 0===u?300:u;return function(e){var s=e.children,i=e.position,u=e.preventExitTransition,d=e.done,f=e.nodeRef,p=e.isIn,m=a?o+"--"+i:o,g=a?r+"--"+i:r,y=t.useRef(),T=t.useRef(0);function h(){var e=f.current;e.removeEventListener("animationend",h),0===T.current&&(e.className=y.current)}function b(){var e=f.current;e.removeEventListener("animationend",b),c?v(e,d,l):d()}return t.useLayoutEffect((function(){var e;y.current=(e=f.current).className,e.className+=" "+m,e.addEventListener("animationend",h)}),[]),t.useEffect((function(){p||(u?b():function(){T.current=1;var e=f.current;e.className+=" "+g,e.addEventListener("animationend",b)}())}),[p]),n.createElement(n.Fragment,null,s)}}var T={list:new Map,emitQueue:new Map,on:function(e,t){return this.list.has(e)||this.list.set(e,[]),this.list.get(e).push(t),this},off:function(e,t){if(t){var n=this.list.get(e).filter((function(e){return e!==t}));return this.list.set(e,n),this}return this.list.delete(e),this},cancelEmit:function(e){var t=this.emitQueue.get(e);return t&&(t.forEach(clearTimeout),this.emitQueue.delete(e)),this},emit:function(e){for(var t=this,n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];this.list.has(e)&&this.list.get(e).forEach((function(n){var r=setTimeout((function(){n.apply(void 0,o)}),0);t.emitQueue.has(e)||t.emitQueue.set(e,[]),t.emitQueue.get(e).push(r)}))}};function h(e,n){void 0===n&&(n=!1);var o=t.useRef(e);return t.useEffect((function(){n&&(o.current=e)})),o.current}function b(e,t){switch(t.type){case 0:return[].concat(e,[t.toastId]).filter((function(e){return e!==t.staleId}));case 1:return d(t.toastId)?e.filter((function(e){return e!==t.toastId})):[]}}function E(e){var n=t.useReducer((function(e){return e+1}),0)[1],o=t.useReducer(b,[]),r=o[0],s=o[1],f=t.useRef(null),m=h(0),g=h([]),v=h({}),y=h({toastKey:1,displayedToast:0,props:e,containerId:null,isToastActive:E,getToast:function(e){return v[e]||null}});function E(e){return-1!==r.indexOf(e)}function O(e){var t=e.containerId;!y.props.limit||t&&y.containerId!==t||(m-=g.length,g=[])}function C(e){s({type:1,toastId:e})}function I(){var e=g.shift();x(e.toastContent,e.toastProps,e.staleId)}function _(e,o){var r=o.delay,s=o.staleId,T=function(e,t){if(null==e)return{};var n,o,r={},s=Object.keys(e);for(o=0;o<s.length;o++)t.indexOf(n=s[o])>=0||(r[n]=e[n]);return r}(o,["delay","staleId"]);if(p(e)&&(h=T,!(!f.current||y.props.enableMultiContainer&&h.containerId!==y.props.containerId||v[h.toastId]&&null==h.updateId))){var h,b=T.toastId,E=y.props,O=function(){return C(b)},_=null==T.updateId;_&&m++;var R,N,P={toastId:b,updateId:T.updateId,isIn:!1,key:T.key||y.toastKey++,type:T.type,closeToast:O,closeButton:T.closeButton,rtl:E.rtl,position:T.position||E.position,transition:T.transition||E.transition,className:l(T.className||E.toastClassName),bodyClassName:l(T.bodyClassName||E.bodyClassName),style:T.style||E.toastStyle,bodyStyle:T.bodyStyle||E.bodyStyle,onClick:T.onClick||E.onClick,pauseOnHover:i(T.pauseOnHover)?T.pauseOnHover:E.pauseOnHover,pauseOnFocusLoss:i(T.pauseOnFocusLoss)?T.pauseOnFocusLoss:E.pauseOnFocusLoss,draggable:i(T.draggable)?T.draggable:E.draggable,draggablePercent:a(T.draggablePercent)?T.draggablePercent:E.draggablePercent,draggableDirection:T.draggableDirection||E.draggableDirection,closeOnClick:i(T.closeOnClick)?T.closeOnClick:E.closeOnClick,progressClassName:l(T.progressClassName||E.progressClassName),progressStyle:T.progressStyle||E.progressStyle,autoClose:(R=T.autoClose,N=E.autoClose,!1===R||a(R)&&R>0?R:N),hideProgressBar:i(T.hideProgressBar)?T.hideProgressBar:E.hideProgressBar,progress:T.progress,role:c(T.role)?T.role:E.role,deleteToast:function(){!function(e){delete v[e];var t=g.length;if((m=d(e)?m-1:m-y.displayedToast)<0&&(m=0),t>0){var o=d(e)?1:y.props.limit;if(1===t||1===o)y.displayedToast++,I();else{var r=o>t?t:o;y.displayedToast=r;for(var s=0;s<r;s++)I()}}else n()}(b)}};u(T.onOpen)&&(P.onOpen=T.onOpen),u(T.onClose)&&(P.onClose=T.onClose),"y"===P.draggableDirection&&80===P.draggablePercent&&(P.draggablePercent*=1.5);var L=E.closeButton;!1===T.closeButton||p(T.closeButton)?L=T.closeButton:!0===T.closeButton&&(L=!p(E.closeButton)||E.closeButton),P.closeButton=L;var k=e;t.isValidElement(e)&&!c(e.type)?k=t.cloneElement(e,{closeToast:O,toastProps:P}):u(e)&&(k=e({closeToast:O,toastProps:P})),E.limit&&E.limit>0&&m>E.limit&&_?g.push({toastContent:k,toastProps:P,staleId:s}):a(r)&&r>0?setTimeout((function(){x(k,P,s)}),r):x(k,P,s)}}function x(e,t,n){var o=t.toastId;n&&delete v[n],v[o]={content:e,props:t},s({type:0,toastId:o,staleId:n})}return t.useEffect((function(){return y.containerId=e.containerId,T.cancelEmit(3).on(0,_).on(1,(function(e){return f.current&&C(e)})).on(5,O).emit(2,y),function(){return T.emit(3,y)}}),[]),t.useEffect((function(){y.isToastActive=E,y.displayedToast=r.length,T.emit(4,r.length,e.containerId)}),[r]),t.useEffect((function(){y.props=e})),{getToastToRender:function(t){for(var n={},o=e.newestOnTop?Object.keys(v).reverse():Object.keys(v),r=0;r<o.length;r++){var s=v[o[r]],a=s.props.position;n[a]||(n[a]=[]),n[a].push(s)}return Object.keys(n).map((function(e){return t(e,n[e])}))},collection:v,containerRef:f,isToastActive:E}}function O(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientX:e.clientX}function C(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientY:e.clientY}function I(e){var n=t.useState(!0),o=n[0],r=n[1],s=t.useState(!1),a=s[0],i=s[1],c=t.useRef(null),l=h({start:0,x:0,y:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null}),d=h(e,!0),f=e.autoClose,p=e.pauseOnHover,m=e.closeToast,g=e.onClick,v=e.closeOnClick;function y(t){if(e.draggable){var n=c.current;l.canCloseOnClick=!0,l.canDrag=!0,l.boundingRect=n.getBoundingClientRect(),n.style.transition="",l.x=O(t.nativeEvent),l.y=C(t.nativeEvent),"x"===e.draggableDirection?(l.start=l.x,l.removalDistance=n.offsetWidth*(e.draggablePercent/100)):(l.start=l.y,l.removalDistance=n.offsetHeight*(e.draggablePercent/100))}}function T(){if(l.boundingRect){var t=l.boundingRect;e.pauseOnHover&&l.x>=t.left&&l.x<=t.right&&l.y>=t.top&&l.y<=t.bottom?E():b()}}function b(){r(!0)}function E(){r(!1)}function I(t){if(l.canDrag){t.preventDefault();var n=c.current;o&&E(),l.x=O(t),l.y=C(t),l.delta="x"===e.draggableDirection?l.x-l.start:l.y-l.start,l.start!==l.x&&(l.canCloseOnClick=!1),n.style.transform="translate"+e.draggableDirection+"("+l.delta+"px)",n.style.opacity=""+(1-Math.abs(l.delta/l.removalDistance))}}function _(){var t=c.current;if(l.canDrag){if(l.canDrag=!1,Math.abs(l.delta)>l.removalDistance)return i(!0),void e.closeToast();t.style.transition="transform 0.2s, opacity 0.2s",t.style.transform="translate"+e.draggableDirection+"(0)",t.style.opacity="1"}}t.useEffect((function(){return u(e.onOpen)&&e.onOpen(t.isValidElement(e.children)&&e.children.props),function(){u(d.onClose)&&d.onClose(t.isValidElement(d.children)&&d.children.props)}}),[]),t.useEffect((function(){return e.draggable&&(document.addEventListener("mousemove",I),document.addEventListener("mouseup",_),document.addEventListener("touchmove",I),document.addEventListener("touchend",_)),function(){e.draggable&&(document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",I),document.removeEventListener("touchend",_))}}),[e.draggable]),t.useEffect((function(){return e.pauseOnFocusLoss&&(document.hasFocus()||E(),window.addEventListener("focus",b),window.addEventListener("blur",E)),function(){e.pauseOnFocusLoss&&(window.removeEventListener("focus",b),window.removeEventListener("blur",E))}}),[e.pauseOnFocusLoss]);var x={onMouseDown:y,onTouchStart:y,onMouseUp:T,onTouchEnd:T};return f&&p&&(x.onMouseEnter=E,x.onMouseLeave=b),v&&(x.onClick=function(e){g&&g(e),l.canCloseOnClick&&m()}),{playToast:b,pauseToast:E,isRunning:o,preventExitTransition:a,toastRef:c,eventHandlers:x}}function _(e){var n=e.closeToast,o=e.ariaLabel;return t.createElement("button",{className:"Toastify__close-button Toastify__close-button--"+e.type,type:"button",onClick:function(e){e.stopPropagation(),n(e)},"aria-label":void 0===o?"close":o},t.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},t.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}function x(e){var n,r,a=e.closeToast,i=e.type,c=e.hide,l=e.className,d=e.controlledProgress,f=e.progress,p=e.rtl,m=e.isIn,g=s({},e.style,{animationDuration:e.delay+"ms",animationPlayState:e.isRunning?"running":"paused",opacity:c?0:1});d&&(g.transform="scaleX("+f+")");var v=o("Toastify__progress-bar",d?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated","Toastify__progress-bar--"+i,((n={})["Toastify__progress-bar--rtl"]=p,n)),y=u(l)?l({rtl:p,type:i,defaultClassName:v}):o(v,l),T=((r={})[d&&f>=1?"onTransitionEnd":"onAnimationEnd"]=d&&f<1?null:function(){m&&a()},r);return t.createElement("div",Object.assign({role:"progressbar","aria-hidden":c?"true":"false","aria-label":"notification timer",className:y,style:g},T))}x.defaultProps={type:g.DEFAULT,hide:!1};var R=function(e){var n,r=I(e),s=r.isRunning,a=r.preventExitTransition,i=r.toastRef,c=r.eventHandlers,l=e.closeButton,d=e.children,f=e.autoClose,p=e.onClick,m=e.type,g=e.hideProgressBar,v=e.closeToast,y=e.transition,T=e.position,h=e.className,b=e.style,E=e.bodyClassName,O=e.bodyStyle,C=e.progressClassName,_=e.progressStyle,R=e.updateId,N=e.role,P=e.progress,L=e.rtl,k=e.toastId,w=e.deleteToast,D=e.isIn,B=o("Toastify__toast","Toastify__toast--"+m,((n={})["Toastify__toast--rtl"]=L,n)),S=u(h)?h({rtl:L,position:T,type:m,defaultClassName:B}):o(B,h),F=!!P;return t.createElement(y,{isIn:D,done:w,position:T,preventExitTransition:a,nodeRef:i},t.createElement("div",Object.assign({id:k,onClick:p,className:S},c,{style:b,ref:i}),t.createElement("div",Object.assign({},D&&{role:N},{className:u(E)?E({type:m}):o("Toastify__toast-body",E),style:O}),d),function(e){if(e){var n={closeToast:v,type:m};return u(e)?e(n):t.isValidElement(e)?t.cloneElement(e,n):void 0}}(l),(f||F)&&t.createElement(x,Object.assign({},R&&!F?{key:"pb-"+R}:{},{rtl:L,delay:f,isRunning:s,isIn:D,closeToast:v,hide:g,type:m,style:_,className:C,controlledProgress:F,progress:P}))))},N=y({enter:"Toastify--animate Toastify__bounce-enter",exit:"Toastify--animate Toastify__bounce-exit",appendPosition:!0}),P=y({enter:"Toastify--animate Toastify__slide-enter",exit:"Toastify--animate Toastify__slide-exit",appendPosition:!0}),L=y({enter:"Toastify--animate Toastify__zoom-enter",exit:"Toastify--animate Toastify__zoom-exit"}),k=y({enter:"Toastify--animate Toastify__flip-enter",exit:"Toastify--animate Toastify__flip-exit"}),w=function(e){var n=E(e),r=n.isToastActive,a=e.className,i=e.style,c=e.rtl;function d(e){var t,n=o("Toastify__toast-container","Toastify__toast-container--"+e,((t={})["Toastify__toast-container--rtl"]=c,t));return u(a)?a({position:e,rtl:c,defaultClassName:n}):o(n,l(a))}return t.createElement("div",{ref:n.containerRef,className:"Toastify",id:e.containerId},(0,n.getToastToRender)((function(e,n){var o=0===n.length?s({},i,{pointerEvents:"none"}):s({},i);return t.createElement("div",{className:d(e),style:o,key:"container-"+e},n.map((function(e){var n=e.content,o=e.props;return t.createElement(R,Object.assign({},o,{isIn:r(o.toastId),key:"toast-"+o.key,closeButton:!0===o.closeButton?_:o.closeButton}),n)})))})))};w.defaultProps={position:m.TOP_RIGHT,transition:N,rtl:!1,autoClose:5e3,hideProgressBar:!1,closeButton:_,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,newestOnTop:!1,draggable:!0,draggablePercent:80,draggableDirection:"x",role:"alert"};var D,B,S,F=new Map,A=[],M=!1;function H(){return Math.random().toString(36).substr(2,9)}function j(e){return e&&(c(e.toastId)||a(e.toastId))?e.toastId:H()}function Q(e,n){return F.size>0?T.emit(0,e,n):(A.push({content:e,options:n}),M&&f&&(M=!1,B=document.createElement("div"),document.body.appendChild(B),r.render(t.createElement(w,Object.assign({},S)),B))),n.toastId}function U(e,t){return s({},t,{type:t&&t.type||e,toastId:j(t)})}var q=function(e){return function(t,n){return Q(t,U(e,n))}},z=function(e,t){return Q(e,U(g.DEFAULT,t))};z.success=q(g.SUCCESS),z.info=q(g.INFO),z.error=q(g.ERROR),z.warning=q(g.WARNING),z.dark=q(g.DARK),z.warn=z.warning,z.dismiss=function(e){return T.emit(1,e)},z.clearWaitingQueue=function(e){return void 0===e&&(e={}),T.emit(5,e)},z.isActive=function(e){var t=!1;return F.forEach((function(n){n.isToastActive&&n.isToastActive(e)&&(t=!0)})),t},z.update=function(e,t){void 0===t&&(t={}),setTimeout((function(){var n=function(e,t){var n=F.get(t.containerId||D);return n?n.getToast(e):null}(e,t);if(n){var o=n.content,r=s({},n.props,t,{toastId:t.toastId||e,updateId:H()});r.toastId!==e&&(r.staleId=e);var a=r.render||o;delete r.render,Q(a,r)}}),0)},z.done=function(e){z.update(e,{progress:1})},z.onChange=function(e){return u(e)&&T.on(4,e),function(){u(e)&&T.off(4,e)}},z.configure=function(e){void 0===e&&(e={}),M=!0,S=e},z.POSITION=m,z.TYPE=g,T.on(2,(function(e){F.set(D=e.containerId||e,e),A.forEach((function(e){T.emit(0,e.content,e.options)})),A=[]})).on(3,(function(e){F.delete(e.containerId||e),0===F.size&&T.off(0).off(1).off(5),f&&B&&document.body.removeChild(B)})),exports.Bounce=N,exports.Flip=k,exports.Slide=P,exports.ToastContainer=w,exports.Zoom=L,exports.collapseToast=v,exports.cssTransition=y,exports.toast=z,exports.useToast=I,exports.useToastContainer=E;
|
|
//# sourceMappingURL=react-toastify.cjs.production.min.js.map
|